Skip to content

Commit

Permalink
grpc: structured subsystems_info
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Indenbaum <[email protected]>
  • Loading branch information
Alexander Indenbaum committed Nov 15, 2023
1 parent d0b684d commit 571e5e3
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 6 deletions.
13 changes: 12 additions & 1 deletion control/grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,7 @@ def get_subsystems_safe(self, request, context):
"""Gets subsystems."""

self.logger.info(f"Received request to get subsystems, context: {context}")
subsystems = []
try:
ret = rpc_nvmf.nvmf_get_subsystems(self.spdk_rpc_client)
self.logger.info(f"get_subsystems: {ret}")
Expand All @@ -800,7 +801,17 @@ def get_subsystems_safe(self, request, context):
context.set_details(f"{ex}")
return pb2.subsystems_info()

return pb2.subsystems_info(subsystems=json.dumps(ret))
for s in ret:
try:
# Parse the JSON dictionary into the protobuf message
subsystem = pb2.subsystem()
json_format.Parse(json.dumps(s), subsystem)
subsystems.append(subsystem)
except Exception:
self.logger.exception(f"{s=} parse error: ")
raise

return pb2.subsystems_info(subsystems)

def get_subsystems(self, request, context):
with self.rpc_lock:
Expand Down
43 changes: 38 additions & 5 deletions control/proto/gateway.proto
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,13 @@ message delete_subsystem_req {
message add_namespace_req {
string subsystem_nqn = 1;
string bdev_name = 2;
optional int32 nsid = 3;
optional uint32 nsid = 3;
optional int32 anagrpid = 4;
}

message remove_namespace_req {
string subsystem_nqn = 1;
int32 nsid = 2;
uint32 nsid = 2;
}

message add_host_req {
Expand Down Expand Up @@ -156,15 +156,48 @@ message req_status {
}

message nsid_status {
int32 nsid = 1;
uint32 nsid = 1;
bool status = 2;
}

message subsystems_info {
string subsystems = 1;
repeated subsystem subsystems = 1;
}

message subsystem {
string nqn = 1;
string subtype = 2;
repeated listen_address listen_addresses = 3;
repeated host hosts = 4;
bool allow_any_host = 5;
optional string serial_number = 6;
optional string model_number = 7;
optional uint32 max_namespaces = 8;
optional uint32 min_cntlid = 9;
optional uint32 max_cntlid = 10;
repeated namespace namespaces = 11;
}

message listen_address {
string transport = 1;
string trtype = 2;
string adrfam = 3;
string traddr = 4;
string trsvcid = 5;
}

message host {
string nqn = 1;
}

message namespace {
uint32 nsid = 1;
string name = 2;
optional string bdev_name = 3;
optional string nguid = 4;
optional string uuid = 5;
}

message spdk_nvmf_log_flags_and_level_info {
string flags_level =1;
}

0 comments on commit 571e5e3

Please sign in to comment.