Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
ajbalogh committed Nov 9, 2024
1 parent c888d84 commit 475e2e7
Show file tree
Hide file tree
Showing 5 changed files with 149 additions and 118 deletions.
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,10 @@ build: ## compile all .proto files and generate artifacts
mkdir -p $(GENERATED_DIR)
python3 -m grpc_tools.protoc \
--proto_path=./protos \
--python_out=$(GENERATED_DIR) --pyi_out=$(GENERATED_DIR) \
et_def.proto infra.proto
--python_out=$(GENERATED_DIR) \
--pyi_out=$(GENERATED_DIR) \
--grpc_python_out=$(GENERATED_DIR) \
et_def.proto infra.proto bind.proto
python3 -m pip uninstall -y keysight-chakra
python3 setup.py bdist_wheel
python3 -m pip install --no-cache .
Expand Down
143 changes: 72 additions & 71 deletions protos/bind.proto
Original file line number Diff line number Diff line change
@@ -1,87 +1,40 @@
// bind.proto
//
// A data model to describe binding infrastructure paths to third party
// information.
// A data model to describe binding infrastructure paths to external
// application information.

syntax = "proto3";

package bind;

import "google/protobuf/any.proto";
import "infra.proto";

message CustomAttribute {
message Data {
// Use this field to provide descriptive information about the message
// that is packed into the value field.
string name = 1;

// The value field can be used to store external information outside the
// scope of these protobuf messages.
// scope of the infra.proto messages.
//
// In addition to custom messages any wellknown type can be set into an
// Any message. See the following reference for details:
// https://protobuf.dev/reference/protobuf/google.protobuf/
//
// # The following is a python example of how to serialize a proto message
// into the value field of the CustomAttribute message.
// The following is how to serialize a proto message into the Data.value field
//
// custom_msg = CustomMessage()
// any_message = Any()
// any_message.Pack(custom_msg)
// custom_attr = CustomAttribute(name="a custom message", value=custom_msg)
// data = Data(name="a custom message", value=custom_msg)
//
// The following is how to deserialize the contents of Data.value
//
// # How to deserialize the contents of CustomAttribute.value into a message
// custom_msg = CustomMessage()
// if attr.value.Is(CustomMessage.DESCRIPTOR):
// attr.value.Unpack(custom_msg)
google.protobuf.Any value = 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 is an instance of
// Infrastructure.inventory.devices.name
// example: dgx1.1
LOCATION_DEVICE_INDEX = 3;

// location device index component is an instance of
// Infrastructure.inventory.devices.name and component.name
// example: dgx1.1.nic
LOCATION_DEVICE_INDEX_COMPONENT = 4;

// location device index component index is an instance of
// Infrastructure.inventory.devices.name and an instance of a component.name
// example: dgx1.1.nic.1
LOCATION_DEVICE_INDEX_COMPONENT_INDEX = 5;

// location device instance is an instance of
// Infrastructure.device_instances.name
LOCATION_DEVICE_INSTANCE = 6;

// location device instance is an instance of
// Infrastructure.device_instances.name
// and an index < Infrastructure.device_instances.count
LOCATION_DEVICE_INSTANCE_INDEX = 7;

// location device instance component is an instance of
// Infrastructure.device_instances.name
// and an index < Infrastructure.device_instances.count
// and an Infrastructure.inventory.device.component.name
LOCATION_DEVICE_INSTANCE_INDEX_COMPONENT = 8;

// location device instance component is an instance of
// Infrastructure.device_instances.name
// and an index < Infrastructure.device_instances.count
// and an Infrastructure.inventory.device.component.name
// and an index < Infrastructure.inventory.device.component.name.index
LOCATION_DEVICE_INSTANCE_INDEX_COMPONENT_INDEX = 9;
// if data.value.Is(CustomMessage.DESCRIPTOR):
// data.value.Unpack(custom_msg)
google.protobuf.Any value = 2;
}

// The Binding message offers the option of binding different types of logical
Expand All @@ -96,21 +49,69 @@ enum LocationFormat {
// Multiple custom attributes can be applied to a single binding value
// packed into an Any type.
message Binding {
// The format of the location value
LocationFormat format = 1;

// The location of infrastructure that matches the binding type format
string location = 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 user defined information
repeated CustomAttribute attributes = 100;
oneof infrastructure_path {
// the binding is global to the infrastructure and the value provided here
// is for informational purposes only
string global = 1;

// binding is specific to an Infrastructure.inventory.device.name
// example: dgx
string device = 2;

// binding is specific to an Infrastructure.inventory.device.name
// example: dgx.npu
string device_component = 3;

// binding is specific to an Infrastructure.inventory.device.name
// example: dgx.npu.0
string device_component_index = 4;

// binding is specific to an instance of
// Infrastructure.device_instances.name
// example: host
string device_instance = 5;

// binding is specific to an instance of
// Infrastructure.device_instances.name
// and an index < Infrastructure.device_instances.count
// example: host.1
string device_instance_index = 6;

// binding is specific to an instance of
// Infrastructure.device_instances.name
// and an index < Infrastructure.device_instances.count
// and an Infrastructure.inventory.device.component.name
// example: host.1.npu
string device_instance_index_component = 7;

// binding is specific to an instance of
// Infrastructure.device_instances.name
// and an index < Infrastructure.device_instances.count
// and an Infrastructure.inventory.device.component.name
// and an index < Infrastructure.inventory.device.component.name.index
// example: host.1.npu.0
string device_instance_index_component_index = 8;
}

// the data field accomodates any type of user defined information
Data data = 100;
}

message Bindings {
// A list of user defined information for specific endpoints
repeated Binding bindings = 1;
}

message ValidationRequest {
infra.Infrastructure infrastructure = 1;
repeated Binding bindings = 2;
}

message ValidationResponse {
repeated Binding invalid_bindings = 1;
}

service BindService {
rpc Validate(ValidationRequest) returns (ValidationResponse);
}
93 changes: 48 additions & 45 deletions protos/infra.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ syntax = "proto3";

package infra;

import "google/protobuf/any.proto";

enum MemoryType {
MEM_UNSPECIFIED = 0;

Expand Down Expand Up @@ -122,7 +124,18 @@ message Link {
Bandwidth bandwidth = 10;
}

message ComponentConnection {
// Device contains collections of components and links and the connections
// between those components
message Device {
// the name of the device
string name = 1;

// collection of unique components in the device
repeated Component components = 3;

// collection of unique links in the device
repeated Link links = 4;

// a list of connections that describe how Components are connected to each
// other in a single Device
//
Expand All @@ -141,47 +154,7 @@ message ComponentConnection {
// nic.0.pcie.cpu.0
// npu.0.pcie.nvswitch.0
//
string connection = 1;
}

// DeviceConnection message describes how Devices are connected to each other
message DeviceConnection {
// format: The following pieces of information each separated by a "."
// An * indicates all possible indexes for a component will be mapped
// In the case where an * is used for both indexes then the mapping will be
// a one-to-one mapping.
//
// - name = DeviceInstance.name
// - index < DeviceInstance.count
// - name = Component.name
// - index < Component.count
// - name = Link.name from one of Infrastructure.inventory.links
// - name = DeviceInstance.name
// - index < DeviceInstance.count
// - name = Component.name
// - index < Component.count
//
// examples:
// host.0.nic.0.100gpbs.racksw.0.nic.0
// host.0.nic.0-8.100gpbs.racksw.0.nic.8-15
//
string connection = 1;
}

// Device contains collections of components and links and the connections
// between those components
message Device {
// the name of the device
string name = 1;

// collection of unique components in the device
repeated Component components = 3;

// collection of unique links in the device
repeated Link links = 4;

// a list of connections that describe how Components are connected
repeated ComponentConnection connections = 5;
repeated string connections = 5;
}

message DeviceInstances {
Expand Down Expand Up @@ -231,8 +204,38 @@ message Infrastructure {

// A list of the device instances that represents the total number of devices
// in the infrastructure.
repeated DeviceInstances device_instances = 10;
repeated DeviceInstances device_instances = 2;

// format: The following pieces of information each separated by a "."
// An * indicates all possible indexes for a component will be mapped
// In the case where an * is used for both indexes then the mapping will be
// a one-to-one mapping.
//
// - name = DeviceInstance.name
// - index < DeviceInstance.count
// - name = Component.name
// - index < Component.count
// - name = Link.name from one of Infrastructure.inventory.links
// - name = DeviceInstance.name
// - index < DeviceInstance.count
// - name = Component.name
// - index < Component.count
//
// examples:
// host.0.nic.0.100gpbs.racksw.0.nic.0
// host.0.nic.0-8.100gpbs.racksw.0.nic.8-15
//
repeated string connections = 3;
}

message ValidationRequest {
infra.Infrastructure infrastructure = 1;
}

// A list that describes how device instances are connected
repeated DeviceConnection connections = 20;
message ValidationResponse {
repeated string invalid_connections = 1;
}

service InfraService {
rpc Validate(ValidationRequest) returns (ValidationResponse);
}
Empty file added src/bind_service.py
Empty file.
25 changes: 25 additions & 0 deletions src/infra_service.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
if __package__ is None or __package__ == "":
from generated import infra_pb2, infra_pb2_grpc
else:
from .generated import infra_pb2, infra_pb2_grpc

class InfraService():
@staticmethod
def Validate(request: infra_pb2.ValidationRequest):
"""Validate every connection in Device and Infrastructure.
Every Device in Infrastructure.inventory.devices has connections which
must have a valid number of pieces separated by a ".".
The names in the following connection breakdown must be present in the
Device components and links.
The format of a Device connection is the following:
"component_name.component_index.link_name.component_name.component_index"
"""
validation_response = infra_pb2.ValidationResponse()
for name, device in request.infrastructure.inventory.devices.items():
if name != device.name:
validation_response.inva
for connection in device.connections:
return validation_response

0 comments on commit 475e2e7

Please sign in to comment.