Skip to content

Commit

Permalink
rework binding to allow for global custom attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
ajbalogh committed Sep 4, 2024
1 parent a1690fe commit f0d1a7c
Showing 1 changed file with 35 additions and 31 deletions.
66 changes: 35 additions & 31 deletions protos/infra.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,20 @@ package infra;
import "google/protobuf/any.proto";
import "google/protobuf/empty.proto";

message AttributeProto {
message CustomAttribute {
string name = 1;
string doc_string = 2;

// # how to pack a proto message into AttributeProto.any_val
// # in addition to custom messages any wellknown type can be set into Any
// https://protobuf.dev/reference/protobuf/google.protobuf/
//
// # how to pack a proto message into CustomAttribute.any_val
// nic_config = NicConfig()
// any_message = Any()
// any_message.Pack(nic_config)
// attr = AttributeProto(name="proto message", any_val=any_message)
// attr = CustomAttribute(name="proto message", any_val=any_message)
//
// # how to unpack an AttributeProto.any_val message into a message
// # how to unpack an CustomAttribute.any_val message into a message
// nic_config = NicConfig()
// if attr.any_val.Is(NicConfig.DESCRIPTOR):
// attr.any_val.Unpack(nic_config)
Expand Down Expand Up @@ -233,49 +236,50 @@ message DeviceInstances {
uint32 count = 3;
}

enum LocationFormat {
// not to be used
LOCATION_UNSPECIFIED = 0;

// location is global
LOCATION_INFRASTRUCTURE = 1;

// location is a Infrastructure.inventory.devices.name
// example: dgx1
LOCATION_DEVICE = 2;

LOCATION_DEVICE_INDEX = 3;
LOCATION_DEVICE_INDEX_COMPONENT = 4;
LOCATION_DEVICE_INDEX_COMPONENT_INDEX = 5;
LOCATION_DEVICE_INSTANCE = 6;
LOCATION_DEVICE_INSTANCE_INDEX = 7;
LOCATION_DEVICE_INSTANCE_INDEX_COMPONENT = 8;
LOCATION_DEVICE_INSTANCE_INDEX_COMPONENT_INDEX = 9;
}

// The Binding message offers the option of binding different types of logical
// Infrastructure endpoints to custom attributes.
//
// The oneof type allows for attributes to be applied at a macro level such as
// The format allows for attributes to be applied at a macro level such as
// all devices or at a micro level such as an individual component in a
// specific device.
// specific device instance.
//
// The custom attributes allows for user defined information including but not
// limited to configuration, location, identification.
// It can be as simple as a single attribute or a custom proto message
// Multiple custom attributes can be applied to a single binding value
// packed into an Any type.
message Binding {
oneof type {
// a device name in the Infrastructures.devices list
// example: dgx1
string device = 1;

// a device name and device index ie dgx1.0
string device_index = 2;

// string path of DeviceName.DeviceIndex.ComponentName
// example: dgx1.0.npu
string component_name = 3;
// The format of the binding value
LocationFormat location_format = 1;

// string path of DeviceName.DeviceIndex.ComponentName.ComponentIndex
// example: dgx1.0.npy.0
string component_index = 4;

// a Device instance name
// example: rack-switch
string device_instance = 5;

// string path of DeviceInstanceName.DeviceInstanceIndex
// example: rack-switch.0
string device_instance_index = 6;
}
// The location of infrastructure that matches the binding type format
string location_value = 2;

// custom information that can be as simple as a single attribute or as
// complex as a proto/json/yaml message
//
// attributes allow for complete flexibility to accomodate any combination
// of userinformation
repeated AttributeProto attributes = 100;
repeated CustomAttribute attributes = 100;
}

// The Inventory message is a collection of unique devices and links present
Expand Down

0 comments on commit f0d1a7c

Please sign in to comment.