diff --git a/.github/workflows/build-container.yml b/.github/workflows/build-container.yml index c89c51e9..9916f62a 100644 --- a/.github/workflows/build-container.yml +++ b/.github/workflows/build-container.yml @@ -299,7 +299,7 @@ jobs: echo $conns | grep -q "\"nqn\": \"${NQN}host\"" echo $conns | grep -q "\"trsvcid\": ${NVMEOF_IO_PORT}" echo $conns | grep -q "\"traddr\": \"${NVMEOF_IP_ADDRESS}\"" - echo $conns | grep -q "\"adrfam\": \"ipv4\"" + echo $conns | grep -q "\"adrfam\": \"IPv4\"" echo $conns | grep -q "\"trtype\": \"TCP\"" con_cnt=$(echo $conns | xargs -n 1 | grep traddr | wc -l) if [ $con_cnt -ne 1 ]; then diff --git a/control/cli.py b/control/cli.py index 2e6837db..a61dfdcb 100644 --- a/control/cli.py +++ b/control/cli.py @@ -26,8 +26,6 @@ from .utils import GatewayUtils from .utils import GatewayEnumUtils -BASE_GATEWAY_VERSION="1.1.0" - def errprint(msg): print(msg, file = sys.stderr) @@ -229,15 +227,6 @@ def get_actions(act_list): acts += ", '" + a["name"] + "'" return acts[2:] - def format_adrfam(self, adrfam): - adrfam = adrfam.upper() - if adrfam == "IPV4": - adrfam = "IPv4" - elif adrfam == "IPV6": - adrfam = "IPv6" - - return adrfam - def get_output_functions(self, args): if args.output == "log": return (self.logger.info, self.logger.error) @@ -259,24 +248,28 @@ def version(self, args): else: rc = 0 errmsg = os.strerror(0) + + cli_ver = { + "status": rc, + "error_message": errmsg, + "version": ver + } + if args.format == "text" or args.format == "plain": - if not ver: + if rc != 0: err_func(errmsg) else: out_func(f"CLI version: {ver}") elif args.format == "json" or args.format == "yaml": - cli_ver = pb2.cli_version(status=rc, error_message=errmsg, version=ver) - out_ver = json_format.MessageToJson(cli_ver, - indent=4, - including_default_value_fields=True, - preserving_proto_field_name=True) + # Convert Python object to JSON string + out_ver = json.dumps(cli_ver) if args.format == "json": out_func(f"{out_ver}") elif args.format == "yaml": obj = json.loads(out_ver) out_func(yaml.dump(obj)) elif args.format == "python": - return pb2.cli_version(status=rc, error_message=errmsg, version=ver) + return cli_ver else: assert False @@ -301,17 +294,17 @@ def gw_get_info(self): req = pb2.get_gateway_info_req(cli_version=ver) gw_info = self.stub.get_gateway_info(req) if gw_info.status == 0: - base_ver = self.parse_version_string(BASE_GATEWAY_VERSION) - assert base_ver != None gw_ver = self.parse_version_string(gw_info.version) + cli_ver = self.parse_version_string(ver) + assert cli_ver is not None if gw_ver == None: gw_info.status = errno.EINVAL gw_info.bool_status = False gw_info.error_message = f"Can't parse gateway version \"{gw_info.version}\"." - elif gw_ver < base_ver: + elif gw_ver < cli_ver: gw_info.status = errno.EINVAL gw_info.bool_status = False - gw_info.error_message = f"Can't work with gateway version older than {BASE_GATEWAY_VERSION}" + gw_info.error_message = f"gateway version \"{gw_info.version}\" older than the cli version \"{ver}\"" return gw_info def gw_info(self, args): @@ -371,24 +364,27 @@ def gw_version(self, args): except Exception as ex: gw_info = pb2.gateway_info(status = errno.EINVAL, error_message = f"Failure getting gateway's version:\n{ex}") + gw_ver = { + "status" : gw_info.status, + "error_message" : gw_info.error_message, + "version" : gw_info.version + } + if args.format == "text" or args.format == "plain": if gw_info.status == 0: out_func(f"Gateway's version: {gw_info.version}") else: err_func(f"{gw_info.error_message}") elif args.format == "json" or args.format == "yaml": - gw_ver = pb2.gw_version(status=gw_info.status, error_message=gw_info.error_message, version=gw_info.version) - out_ver = json_format.MessageToJson(gw_ver, - indent=4, - including_default_value_fields=True, - preserving_proto_field_name=True) + # Convert Python object to JSON string + out_ver = json.dumps(gw_ver) if args.format == "json": out_func(f"{out_ver}") elif args.format == "yaml": obj = json.loads(out_ver) out_func(yaml.dump(obj)) elif args.format == "python": - return pb2.gw_version(status=gw_info.status, error_message=gw_info.error_message, version=gw_info.version) + return gw_ver else: assert False @@ -860,9 +856,7 @@ def listener_list(self, args): if listeners_info.status == 0: listeners_list = [] for l in listeners_info.listeners: - adrfam = GatewayEnumUtils.get_key_from_value(pb2.AddressFamily, l.adrfam) - adrfam = self.format_adrfam(adrfam) - listeners_list.append([l.gateway_name, l.trtype, adrfam, f"{l.traddr}:{l.trsvcid}"]) + listeners_list.append([l.gateway_name, l.trtype, l.adrfam, f"{l.traddr}:{l.trsvcid}"]) if len(listeners_list) > 0: if args.format == "text": table_format = "fancy_grid" diff --git a/control/grpc.py b/control/grpc.py index 6116692b..11928c66 100644 --- a/control/grpc.py +++ b/control/grpc.py @@ -1900,16 +1900,9 @@ def list_connections_safe(self, request, context): addr = qp["listen_address"] traddr = addr["traddr"] trsvcid = int(addr["trsvcid"]) - try: - trtype = addr["trtype"].upper() - except Exception: - pass - try: - adrfam = addr["adrfam"].lower() - except Exception: - pass - break - except Exception: + trtype = addr["trtype"] + adrfam = addr["adrfam"] + except Exception as ex: self.logger.exception(f"Got exception while parsing qpair: {qp}") pass one_conn = pb2.connection(nqn=hostnqn, connected=True, diff --git a/control/proto/gateway.proto b/control/proto/gateway.proto index b2698872..5b107de2 100644 --- a/control/proto/gateway.proto +++ b/control/proto/gateway.proto @@ -75,8 +75,8 @@ service Gateway { // List subsystems rpc list_subsystems(list_subsystems_req) returns(subsystems_info_cli) {} - // Gets subsystems - rpc get_subsystems(get_subsystems_req) returns(subsystems_info) {} + // Gets subsystems + rpc get_subsystems(get_subsystems_req) returns(subsystems_info) {} // Set gateway ANA states rpc set_ana_state(ana_info) returns(req_status) {} @@ -84,8 +84,8 @@ service Gateway { // Gets spdk nvmf log flags and level rpc get_spdk_nvmf_log_flags_and_level(get_spdk_nvmf_log_flags_and_level_req) returns(spdk_nvmf_log_flags_and_level_info) {} - // Disables spdk nvmf logs - rpc disable_spdk_nvmf_logs(disable_spdk_nvmf_logs_req) returns(req_status) {} + // Disables spdk nvmf logs + rpc disable_spdk_nvmf_logs(disable_spdk_nvmf_logs_req) returns(req_status) {} // Set spdk nvmf logs rpc set_spdk_nvmf_logs(set_spdk_nvmf_logs_req) returns(req_status) {} @@ -336,22 +336,10 @@ message gateway_info { uint32 load_balancing_group = 11; } -message cli_version { - int32 status = 1; - string error_message = 2; - string version = 3; -} - -message gw_version { - int32 status = 1; - string error_message = 2; - string version = 3; -} - message listener_info { string gateway_name = 1; string trtype = 2; - AddressFamily adrfam = 3; + string adrfam = 3; string traddr = 4; uint32 trsvcid = 5; } @@ -378,8 +366,8 @@ message connection { string nqn = 1; string traddr = 2; uint32 trsvcid = 3; - string trtype = 4; - AddressFamily adrfam = 5; + string trtype = 4; + string adrfam = 5; bool connected = 6; int32 qpairs_count = 7; int32 controller_id = 8;