Skip to content

Commit

Permalink
fix(proto): include subsystem in full resource name
Browse files Browse the repository at this point in the history
Signed-off-by: Boris Glimcher <[email protected]>
  • Loading branch information
glimchb authored and artek-koltun committed Oct 4, 2023
1 parent 8f76919 commit b320344
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions pydpu/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def __repr__(self) -> str:

def __init__(self, nqn: str, model="OPI Model", serial="OPI SN", ns=10) -> None:
self.id = "opi-" + str(uuid.uuid1())
self.fullname = "//storage.opiproject.org/volumes/" + str(self.id)
self.fullname = "//storage.opiproject.org/subsystems/" + str(self.id)
self.nqn = nqn
self.model = model
self.serial = serial
Expand Down Expand Up @@ -75,7 +75,7 @@ def list(self, address):
with grpc.insecure_channel(address) as channel:
stub = frontend_nvme_pcie_pb2_grpc.FrontendNvmeServiceStub(channel)
res = stub.ListNvmeSubsystems(
request=frontend_nvme_pcie_pb2.ListNvmeSubsystemsRequest(parent="todo")
request=frontend_nvme_pcie_pb2.ListNvmeSubsystemsRequest()
)
return res

Expand Down Expand Up @@ -122,7 +122,9 @@ def __repr__(self) -> str:

def __init__(self, subsystem: NvmeSubsystem, queue: int) -> None:
self.id = "opi-" + str(uuid.uuid1())
self.fullname = "//storage.opiproject.org/volumes/" + str(self.id)
self.fullname = "//storage.opiproject.org/subsystems/{}/controllers{}".format(
subsystem.id, self.id
)
self.subsystem = subsystem
self.queue = queue

Expand All @@ -131,10 +133,10 @@ def create(self, address):
stub = frontend_nvme_pcie_pb2_grpc.FrontendNvmeServiceStub(channel)
res = stub.CreateNvmeController(
request=frontend_nvme_pcie_pb2.CreateNvmeControllerRequest(
parent=str(self.subsystem.id),
nvme_controller_id=str(self.id),
nvme_controller=frontend_nvme_pcie_pb2.NvmeController(
spec=frontend_nvme_pcie_pb2.NvmeControllerSpec(
subsystem_name_ref=str(self.subsystem.id),
pcie_id=opicommon_pb2.PciEndpoint(
physical_function=wrappers_pb2.Int32Value(value=1),
virtual_function=wrappers_pb2.Int32Value(value=2),
Expand All @@ -160,7 +162,6 @@ def update(self, address):
nvme_controller=frontend_nvme_pcie_pb2.NvmeController(
name=self.fullname,
spec=frontend_nvme_pcie_pb2.NvmeControllerSpec(
subsystem_name_ref=str(self.subsystem.id),
pcie_id=opicommon_pb2.PciEndpoint(
physical_function=1, virtual_function=2, port_id=3
),
Expand Down Expand Up @@ -228,7 +229,9 @@ def __repr__(self) -> str:

def __init__(self, subsystem: NvmeSubsystem, volume: str) -> None:
self.id = "opi-" + str(uuid.uuid1())
self.fullname = "//storage.opiproject.org/volumes/" + str(self.id)
self.fullname = "//storage.opiproject.org/subsystems/{}/namespaces{}".format(
subsystem.id, self.id
)
self.subsystem = subsystem
self.volume = volume

Expand All @@ -237,10 +240,10 @@ def create(self, address):
stub = frontend_nvme_pcie_pb2_grpc.FrontendNvmeServiceStub(channel)
res = stub.CreateNvmeNamespace(
request=frontend_nvme_pcie_pb2.CreateNvmeNamespaceRequest(
parent=str(self.subsystem.id),
nvme_namespace_id=str(self.id),
nvme_namespace=frontend_nvme_pcie_pb2.NvmeNamespace(
spec=frontend_nvme_pcie_pb2.NvmeNamespaceSpec(
subsystem_name_ref=str(self.subsystem.id),
volume_name_ref=self.volume,
uuid=uuid_pb2.Uuid(
value="1b4e28ba-2fa1-11d2-883f-b9a761bde3fb"
Expand All @@ -263,7 +266,6 @@ def update(self, address):
nvme_namespace=frontend_nvme_pcie_pb2.NvmeNamespace(
name=self.fullname,
spec=frontend_nvme_pcie_pb2.NvmeNamespaceSpec(
subsystem_name_ref=str(self.subsystem.id),
volume_name_ref="Malloc1",
uuid=uuid_pb2.Uuid(
value="1b4e28ba-2fa1-11d2-883f-b9a761bde3fb"
Expand Down

0 comments on commit b320344

Please sign in to comment.