diff --git a/control/cli.py b/control/cli.py index 1db71925..00829a6c 100644 --- a/control/cli.py +++ b/control/cli.py @@ -25,8 +25,6 @@ from .utils import GatewayUtils from .utils import GatewayEnumUtils -BASE_GATEWAY_VERSION="1.1.0" - def errprint(msg): print(msg, file = sys.stderr) @@ -307,20 +305,14 @@ def parse_version_string(self, version): def gw_get_info(self): ver = os.getenv("NVMEOF_VERSION") - req = pb2.get_gateway_info_req(cli_version=ver) - gw_info = self.stub.get_gateway_info(req) + req = pb2.gateway_info_get_req(cli_version=ver) + gw_info = self.stub.gateway_info_get(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) 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: - 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}" return gw_info def gw_info(self, args): @@ -409,9 +401,9 @@ def gw_get_log_level(self, args): """Get gateway's log level""" out_func, err_func = self.get_output_functions(args) - req = pb2.get_gateway_log_level_req() + req = pb2.gateway_log_level_get_req() try: - ret = self.stub.get_gateway_log_level(req) + ret = self.stub.gateway_log_level_get(req) except Exception as ex: ret = pb2.req_status(status = errno.EINVAL, error_message = f"Failure getting gateway log level:\n{ex}") @@ -448,12 +440,12 @@ def gw_set_log_level(self, args): log_level = args.level.lower() try: - req = pb2.set_gateway_log_level_req(log_level=log_level) + req = pb2.gateway_log_level_set_req(log_level=log_level) except ValueError as err: self.cli.parser.error(f"invalid log level {log_level}, error {err}") try: - ret = self.stub.set_gateway_log_level(req) + ret = self.stub.gateway_log_level_set(req) except Exception as ex: ret = pb2.req_status(status = errno.EINVAL, error_message = f"Failure setting gateway log level:\n{ex}") @@ -508,9 +500,9 @@ def spdk_log_level_disable(self, args): out_func, err_func = self.get_output_functions(args) - req = pb2.disable_spdk_nvmf_logs_req() + req = pb2.spdk_nvmf_logs_disable_req() try: - ret = self.stub.disable_spdk_nvmf_logs(req) + ret = self.stub.spdk_nvmf_logs_disable(req) except Exception as ex: ret = pb2.req_status(status = errno.EINVAL, error_message = f"Failure disabling SPDK nvmf log flags:\n{ex}") @@ -542,9 +534,9 @@ def spdk_log_level_get(self, args): out_func, err_func = self.get_output_functions(args) - req = pb2.get_spdk_nvmf_log_flags_and_level_req() + req = pb2.spdk_nvmf_log_flags_and_level_get_req() try: - ret = self.stub.get_spdk_nvmf_log_flags_and_level(req) + ret = self.stub.spdk_nvmf_log_flags_and_level_get(req) except Exception as ex: ret = pb2.req_status(status = errno.EINVAL, error_message = f"Failure getting SPDK log levels and nvmf log flags:\n{ex}") @@ -592,12 +584,12 @@ def spdk_log_level_set(self, args): print_level = args.print.upper() try: - req = pb2.set_spdk_nvmf_logs_req(log_level=log_level, print_level=print_level) + req = pb2.spdk_nvmf_logs_set_req(log_level=log_level, print_level=print_level) except ValueError as err: self.cli.parser.error(f"invalid log level {log_level}, error {err}") try: - ret = self.stub.set_spdk_nvmf_logs(req) + ret = self.stub.spdk_nvmf_logs_set(req) except Exception as ex: ret = pb2.req_status(status = errno.EINVAL, error_message = f"Failure setting SPDK log levels and nvmf log flags:\n{ex}") @@ -660,12 +652,12 @@ def subsystem_add(self, args): if args.subsystem == GatewayUtils.DISCOVERY_NQN: self.cli.parser.error("Can't add a discovery subsystem") - req = pb2.create_subsystem_req(subsystem_nqn=args.subsystem, + req = pb2.subsystem_create_req(subsystem_nqn=args.subsystem, serial_number=args.serial_number, max_namespaces=args.max_namespaces, enable_ha=True) try: - ret = self.stub.create_subsystem(req) + ret = self.stub.subsystem_create(req) except Exception as ex: ret = pb2.req_status(status = errno.EINVAL, error_message = f"Failure adding subsystem {args.subsystem}:\n{ex}") @@ -699,9 +691,9 @@ def subsystem_del(self, args): if args.subsystem == GatewayUtils.DISCOVERY_NQN: self.cli.parser.error("Can't delete a discovery subsystem") - req = pb2.delete_subsystem_req(subsystem_nqn=args.subsystem, force=args.force) + req = pb2.subsystem_delete_req(subsystem_nqn=args.subsystem, force=args.force) try: - ret = self.stub.delete_subsystem(req) + ret = self.stub.subsystem_delete(req) except Exception as ex: ret = pb2.req_status(status = errno.EINVAL, error_message = f"Failure deleting subsystem {args.subsystem}:\n{ex}") @@ -735,7 +727,7 @@ def subsystem_list(self, args): subsystems = None try: - subsystems = self.stub.list_subsystems(pb2.list_subsystems_req(subsystem_nqn=args.subsystem, serial_number=args.serial_number)) + subsystems = self.stub.subsystem_list(pb2.subsystem_list_req(subsystem_nqn=args.subsystem, serial_number=args.serial_number)) except Exception as ex: subsystems = pb2.subsystems_info_cli(status = errno.EINVAL, error_message = f"Failure listing subsystems:\n{ex}") @@ -844,8 +836,8 @@ def listener_add(self, args): if args.adrfam: adrfam = args.adrfam.lower() - req = pb2.create_listener_req( - nqn=args.subsystem, + req = pb2.listener_create_req( + subsystem_nqn=args.subsystem, host_name=args.host_name, adrfam=adrfam, traddr=traddr, @@ -853,7 +845,7 @@ def listener_add(self, args): ) try: - ret = self.stub.create_listener(req) + ret = self.stub.listener_create(req) except Exception as ex: ret = pb2.req_status(status = errno.EINVAL, error_message = f"Failure adding {args.subsystem} listener at {traddr}:{args.trsvcid}:\n{ex}") @@ -900,8 +892,8 @@ def listener_del(self, args): if args.adrfam: adrfam = args.adrfam.lower() - req = pb2.delete_listener_req( - nqn=args.subsystem, + req = pb2.listener_delete_req( + subsystem_nqn=args.subsystem, host_name=args.host_name, adrfam=adrfam, traddr=traddr, @@ -910,7 +902,7 @@ def listener_del(self, args): ) try: - ret = self.stub.delete_listener(req) + ret = self.stub.listener_delete(req) except Exception as ex: ret = pb2.req_status(status = errno.EINVAL, error_message = f"Failure deleting listener {traddr}:{args.trsvcid} from {args.subsystem}:\n{ex}") @@ -945,7 +937,7 @@ def listener_list(self, args): out_func, err_func = self.get_output_functions(args) listeners_info = None try: - listeners_info = self.stub.list_listeners(pb2.list_listeners_req(subsystem=args.subsystem)) + listeners_info = self.stub.listener_list(pb2.listener_list_req(subsystem_nqn=args.subsystem)) except Exception as ex: listeners_info = pb2.listeners_info(status = errno.EINVAL, error_message = f"Failure listing listeners:\n{ex}", listeners=[]) @@ -1028,9 +1020,9 @@ def host_add(self, args): out_func, err_func = self.get_output_functions(args) if not args.host: self.cli.parser.error("--host argument is mandatory for add command") - req = pb2.add_host_req(subsystem_nqn=args.subsystem, host_nqn=args.host) + req = pb2.host_add_req(subsystem_nqn=args.subsystem, host_nqn=args.host) try: - ret = self.stub.add_host(req) + ret = self.stub.host_add(req) except Exception as ex: if args.host == "*": errmsg = f"Failure allowing open host access to {args.subsystem}" @@ -1070,10 +1062,10 @@ def host_del(self, args): out_func, err_func = self.get_output_functions(args) if not args.host: self.cli.parser.error("--host argument is mandatory for del command") - req = pb2.remove_host_req(subsystem_nqn=args.subsystem, host_nqn=args.host) + req = pb2.host_remove_req(subsystem_nqn=args.subsystem, host_nqn=args.host) try: - ret = self.stub.remove_host(req) + ret = self.stub.host_remove(req) except Exception as ex: if args.host == "*": errmsg = f"Failure disabling open host access to {args.subsystem}" @@ -1114,7 +1106,7 @@ def host_list(self, args): hosts_info = None try: - hosts_info = self.stub.list_hosts(pb2.list_hosts_req(subsystem=args.subsystem)) + hosts_info = self.stub.host_list(pb2.host_list_req(subsystem_nqn=args.subsystem)) except Exception as ex: hosts_info = pb2.hosts_info(status = errno.EINVAL, error_message = f"Failure listing hosts:\n{ex}", hosts=[]) @@ -1190,7 +1182,7 @@ def connection_list(self, args): out_func, err_func = self.get_output_functions(args) connections_info = None try: - connections_info = self.stub.list_connections(pb2.list_connections_req(subsystem=args.subsystem)) + connections_info = self.stub.connection_list(pb2.connection_list_req(subsystem_nqn=args.subsystem)) except Exception as ex: connections_info = pb2.connections_info(status = errno.EINVAL, error_message = f"Failure listing hosts:\n{ex}", connections=[]) @@ -1280,7 +1272,7 @@ def ns_add(self, args): nsid=args.nsid, block_size=args.block_size, uuid=args.uuid, - anagrpid=args.load_balancing_group, + load_balancing_group=args.load_balancing_group, create_image=args.rbd_create_image, size=img_size, force=args.force) @@ -1502,8 +1494,8 @@ def ns_list(self, args): self.cli.parser.error("nsid value must be positive") try: - namespaces_info = self.stub.list_namespaces(pb2.list_namespaces_req(subsystem=args.subsystem, - nsid=args.nsid, uuid=args.uuid)) + namespaces_info = self.stub.namespace_list(pb2.namespace_list_req(subsystem_nqn=args.subsystem, + nsid=args.nsid, uuid=args.uuid)) except Exception as ex: namespaces_info = pb2.namespaces_info(status = errno.EINVAL, error_message = f"Failure listing namespaces:\n{ex}") @@ -1680,7 +1672,7 @@ def ns_change_load_balancing_group(self, args): try: change_lb_group_req = pb2.namespace_change_load_balancing_group_req(subsystem_nqn=args.subsystem, nsid=args.nsid, uuid=args.uuid, - anagrpid=args.load_balancing_group) + load_balancing_group=args.load_balancing_group) ret = self.stub.namespace_change_load_balancing_group(change_lb_group_req) except Exception as ex: ret = pb2.req_status(status = errno.EINVAL, error_message = f"Failure changing namespace load balancing group:\n{ex}") diff --git a/control/discovery.py b/control/discovery.py index 64607ea4..e5e75ffe 100644 --- a/control/discovery.py +++ b/control/discovery.py @@ -715,7 +715,7 @@ def reply_get_log_page(self, conn, data, cmd_id): for listener in listeners: # TODO: It is better to change nqn in the "listener" # to subsystem_nqn to avoid confusion - if host["subsystem_nqn"] == listener["nqn"]: + if host["subsystem_nqn"] == listener["subsystem_nqn"]: allow_listeners += [listener,] self_conn.allow_listeners = allow_listeners @@ -753,9 +753,9 @@ def reply_get_log_page(self, conn, data, cmd_id): [c_ubyte(0x20)] * (32 - len(str_trsvcid)) # NVM subsystem qualified name log_entry.subnqn = (c_ubyte * 256)(*[c_ubyte(x) for x \ - in allow_listeners[log_entry_counter]["nqn"].encode()]) - log_entry.subnqn[len(allow_listeners[log_entry_counter]["nqn"]):] = \ - [c_ubyte(0x00)] * (256 - len(allow_listeners[log_entry_counter]["nqn"])) + in allow_listeners[log_entry_counter]["subsystem_nqn"].encode()]) + log_entry.subnqn[len(allow_listeners[log_entry_counter]["subsystem_nqn"]):] = \ + [c_ubyte(0x00)] * (256 - len(allow_listeners[log_entry_counter]["subsystem_nqn"])) # Transport address log_entry.traddr = (c_ubyte * 256)(*[c_ubyte(x) for x \ in allow_listeners[log_entry_counter]["traddr"].encode()]) diff --git a/control/grpc.py b/control/grpc.py index 6f9cb720..6796f687 100644 --- a/control/grpc.py +++ b/control/grpc.py @@ -457,7 +457,7 @@ def serial_number_already_used(self, context, serial) -> str: continue return None - def create_subsystem_safe(self, request, context): + def subsystem_create_safe(self, request, context): """Creates a subsystem.""" create_subsystem_error_prefix = f"Failure creating subsystem {request.subsystem_nqn}" @@ -557,8 +557,8 @@ def create_subsystem_safe(self, request, context): return pb2.req_status(status=0, error_message=os.strerror(0)) - def create_subsystem(self, request, context=None): - return self.execute_grpc_function(self.create_subsystem_safe, request, context) + def subsystem_create(self, request, context=None): + return self.execute_grpc_function(self.subsystem_create_safe, request, context) def get_subsystem_namespaces(self, nqn) -> list: ns_list = [] @@ -584,7 +584,7 @@ def subsystem_has_listeners(self, nqn) -> bool: continue try: lsnr = json.loads(val) - if lsnr["nqn"] == nqn: + if lsnr["subsystem_nqn"] == nqn: return True except Exception: self.logger.exception(f"Got exception trying to get subsystem {nqn} listener") @@ -606,7 +606,7 @@ def remove_subsystem_from_state(self, nqn, context): return pb2.req_status(status=errno.EINVAL, error_message=errmsg) return pb2.req_status(status=0, error_message=os.strerror(0)) - def delete_subsystem_safe(self, request, context): + def subsystem_delete_safe(self, request, context): """Deletes a subsystem.""" delete_subsystem_error_prefix = f"Failure deleting subsystem {request.subsystem_nqn}" @@ -640,7 +640,7 @@ def delete_subsystem_safe(self, request, context): return self.remove_subsystem_from_state(request.subsystem_nqn, context) - def delete_subsystem(self, request, context=None): + def subsystem_delete(self, request, context=None): """Deletes a subsystem.""" delete_subsystem_error_prefix = f"Failure deleting subsystem {request.subsystem_nqn}" @@ -672,7 +672,7 @@ def delete_subsystem(self, request, context=None): else: self.logger.error(f"Failure removing namespace {nsid} from {request.subsystem_nqn}:\n{ret.error_message}") self.logger.warning(f"Will continue deleting {request.subsystem_nqn} anyway") - return self.execute_grpc_function(self.delete_subsystem_safe, request, context) + return self.execute_grpc_function(self.subsystem_delete_safe, request, context) def check_if_image_used(self, pool_name, image_name): """Check if image is used by any other namespace.""" @@ -866,7 +866,7 @@ def namespace_add_safe(self, request, context): create_image = request.create_image if not context: create_image = False - anagrp = int(request.anagrpid) if request.anagrpid is not None else 0 + anagrp = int(request.load_balancing_group) if request.load_balancing_group is not None else 0 ret_bdev = self.create_bdev(anagrp, bdev_name, request.uuid, request.rbd_pool_name, request.rbd_image_name, request.block_size, create_image, request.size) if ret_bdev.status != 0: @@ -933,7 +933,7 @@ def namespace_change_load_balancing_group_safe(self, request, context): """Changes a namespace load balancing group.""" nsid_msg = self.get_ns_id_message(request.nsid, request.uuid) - self.logger.info(f"Received request to change load balancing group for namespace {nsid_msg}in {request.subsystem_nqn} to {request.anagrpid}, context: {context}") + self.logger.info(f"Received request to change load balancing group for namespace {nsid_msg}in {request.subsystem_nqn} to {request.load_balancing_group}, context: {context}") with self.omap_lock(context=context): find_ret = self.find_namespace_and_bdev_name(request.subsystem_nqn, request.nsid, request.uuid, False, @@ -994,7 +994,7 @@ def namespace_change_load_balancing_group_safe(self, request, context): if nsid: self.remove_namespace_from_state(request.subsystem_nqn, nsid, context) - ret_ns = self.create_namespace(request.subsystem_nqn, bdev_name, nsid, request.anagrpid, uuid, context) + ret_ns = self.create_namespace(request.subsystem_nqn, bdev_name, nsid, request.load_balancing_group, uuid, context) if ret_ns.status != 0: errmsg = f"Failure changing load balancing group for namespace {nsid_msg}in {request.subsystem_nqn}:{ret_ns.error_message}" self.logger.error(errmsg) @@ -1028,7 +1028,7 @@ def namespace_change_load_balancing_group_safe(self, request, context): namespace_add_req.uuid=ns_entry["uuid"] except KeyError: pass - namespace_add_req.anagrpid=request.anagrpid + namespace_add_req.load_balancing_group=request.load_balancing_group json_req = json_format.MessageToJson( namespace_add_req, preserving_proto_field_name=True, including_default_value_fields=True) self.gateway_state.add_namespace(request.subsystem_nqn, nsid, json_req) @@ -1123,7 +1123,7 @@ def get_bdev_info(self, bdev_name, need_to_lock): return ret_bdev - def list_namespaces(self, request, context=None): + def namespace_list(self, request, context=None): """List namespaces.""" if request.nsid == None or request.nsid == 0: @@ -1136,12 +1136,12 @@ def list_namespaces(self, request, context=None): nsid_msg = f"namespace with NSID {request.nsid} and UUID {request.uuid}" else: nsid_msg = f"namespace with NSID {request.nsid}" - self.logger.info(f"Received request to list {nsid_msg} for {request.subsystem}, context: {context}") + self.logger.info(f"Received request to list {nsid_msg} for {request.subsystem_nqn}, context: {context}") with self.rpc_lock: try: - ret = rpc_nvmf.nvmf_get_subsystems(self.spdk_rpc_client, nqn=request.subsystem) - self.logger.info(f"list_namespaces: {ret}") + ret = rpc_nvmf.nvmf_get_subsystems(self.spdk_rpc_client, nqn=request.subsystem_nqn) + self.logger.info(f"get_subsystems: {ret}") except Exception as ex: errmsg = f"Failure listing namespaces" self.logger.exception(errmsg) @@ -1151,13 +1151,13 @@ def list_namespaces(self, request, context=None): if resp: status = resp["code"] errmsg = f"Failure listing namespaces: {resp['message']}" - return pb2.namespaces_info(status=status, error_message=errmsg, subsystem_nqn=request.subsystem, namespaces=[]) + return pb2.namespaces_info(status=status, error_message=errmsg, subsystem_nqn=request.subsystem_nqn, namespaces=[]) namespaces = [] for s in ret: try: - if s["nqn"] != request.subsystem: - self.logger.warning(f'Got subsystem {s["nqn"]} instead of {request.subsystem}, ignore') + if s["nqn"] != request.subsystem_nqn: + self.logger.warning(f'Got subsystem {s["nqn"]} instead of {request.subsystem_nqn}, ignore') continue try: ns_list = s["namespaces"] @@ -1209,7 +1209,7 @@ def list_namespaces(self, request, context=None): self.logger.exception(f"{s=} parse error") pass - return pb2.namespaces_info(status = 0, error_message = os.strerror(0), subsystem_nqn=request.subsystem, namespaces=namespaces) + return pb2.namespaces_info(status = 0, error_message = os.strerror(0), subsystem_nqn=request.subsystem_nqn, namespaces=namespaces) def namespace_get_io_stats(self, request, context=None): """Get namespace's IO stats.""" @@ -1588,7 +1588,7 @@ def matching_host_exists(self, context, subsys_nqn, host_nqn) -> bool: else: return False - def add_host_safe(self, request, context): + def host_add_safe(self, request, context): """Adds a host to a subsystem.""" all_host_failure_prefix=f"Failure allowing open host access to {request.subsystem_nqn}" @@ -1644,7 +1644,7 @@ def add_host_safe(self, request, context): nqn=request.subsystem_nqn, disable=False, ) - self.logger.info(f"add_host *: {ret}") + self.logger.info(f"allow_any_host: {ret}") else: # Allow single host access to subsystem self.logger.info( f"Received request to add host {request.host_nqn} to {request.subsystem_nqn}, context: {context}") @@ -1695,8 +1695,8 @@ def add_host_safe(self, request, context): return pb2.req_status(status=0, error_message=os.strerror(0)) - def add_host(self, request, context=None): - return self.execute_grpc_function(self.add_host_safe, request, context) + def host_add(self, request, context=None): + return self.execute_grpc_function(self.host_add_safe, request, context) def remove_host_from_state(self, subsystem_nqn, host_nqn, context): if not context: @@ -1714,7 +1714,7 @@ def remove_host_from_state(self, subsystem_nqn, host_nqn, context): return pb2.req_status(status=errno.EINVAL, error_message=errmsg) return pb2.req_status(status=0, error_message=os.strerror(0)) - def remove_host_safe(self, request, context): + def host_remove_safe(self, request, context): """Removes a host from a subsystem.""" all_host_failure_prefix=f"Failure disabling open host access to {request.subsystem_nqn}" @@ -1747,7 +1747,7 @@ def remove_host_safe(self, request, context): nqn=request.subsystem_nqn, disable=True, ) - self.logger.info(f"remove_host *: {ret}") + self.logger.info(f"allow_any_host: {ret}") else: # Remove single host access to subsystem self.logger.info( f"Received request to remove host {request.host_nqn} access from" @@ -1789,16 +1789,16 @@ def remove_host_safe(self, request, context): return self.remove_host_from_state(request.subsystem_nqn, request.host_nqn, context) - def remove_host(self, request, context=None): - return self.execute_grpc_function(self.remove_host_safe, request, context) + def host_remove(self, request, context=None): + return self.execute_grpc_function(self.host_remove_safe, request, context) - def list_hosts_safe(self, request, context): + def host_list_safe(self, request, context): """List hosts.""" - self.logger.info(f"Received request to list hosts for {request.subsystem}, context: {context}") + self.logger.info(f"Received request to list hosts for {request.subsystem_nqn}, context: {context}") try: - ret = rpc_nvmf.nvmf_get_subsystems(self.spdk_rpc_client, nqn=request.subsystem) - self.logger.info(f"list_hosts: {ret}") + ret = rpc_nvmf.nvmf_get_subsystems(self.spdk_rpc_client, nqn=request.subsystem_nqn) + self.logger.info(f"get_subsystems: {ret}") except Exception as ex: errmsg = f"Failure listing hosts, can't get subsystems" self.logger.exception(errmsg) @@ -1814,8 +1814,8 @@ def list_hosts_safe(self, request, context): allow_any_host = False for s in ret: try: - if s["nqn"] != request.subsystem: - self.logger.warning(f'Got subsystem {s["nqn"]} instead of {request.subsystem}, ignore') + if s["nqn"] != request.subsystem_nqn: + self.logger.warning(f'Got subsystem {s["nqn"]} instead of {request.subsystem_nqn}, ignore') continue try: allow_any_host = s["allow_any_host"] @@ -1832,18 +1832,18 @@ def list_hosts_safe(self, request, context): pass return pb2.hosts_info(status = 0, error_message = os.strerror(0), allow_any_host=allow_any_host, - subsystem_nqn=request.subsystem, hosts=hosts) + subsystem_nqn=request.subsystem_nqn, hosts=hosts) - def list_hosts(self, request, context=None): - return self.execute_grpc_function(self.list_hosts_safe, request, context) + def host_list(self, request, context=None): + return self.execute_grpc_function(self.host_list_safe, request, context) - def list_connections_safe(self, request, context): + def connection_list_safe(self, request, context): """List connections.""" - self.logger.info(f"Received request to list connections for {request.subsystem}, context: {context}") + self.logger.info(f"Received request to list connections for {request.subsystem_nqn}, context: {context}") try: - qpair_ret = rpc_nvmf.nvmf_subsystem_get_qpairs(self.spdk_rpc_client, nqn=request.subsystem) - self.logger.info(f"list_connections get_qpairs: {qpair_ret}") + qpair_ret = rpc_nvmf.nvmf_subsystem_get_qpairs(self.spdk_rpc_client, nqn=request.subsystem_nqn) + self.logger.info(f"connection_list get_qpairs: {qpair_ret}") except Exception as ex: errmsg = f"Failure listing connections, can't get qpairs" self.logger.exception(errmsg) @@ -1856,8 +1856,8 @@ def list_connections_safe(self, request, context): return pb2.connections_info(status=status, error_message=errmsg, connections=[]) try: - ctrl_ret = rpc_nvmf.nvmf_subsystem_get_controllers(self.spdk_rpc_client, nqn=request.subsystem) - self.logger.info(f"list_connections get_controllers: {ctrl_ret}") + ctrl_ret = rpc_nvmf.nvmf_subsystem_get_controllers(self.spdk_rpc_client, nqn=request.subsystem_nqn) + self.logger.info(f"connection_list get_controllers: {ctrl_ret}") except Exception as ex: errmsg = f"Failure listing connections, can't get controllers" self.logger.exception(errmsg) @@ -1870,8 +1870,8 @@ def list_connections_safe(self, request, context): return pb2.bconnections_info(status=status, error_message=errmsg, connections=[]) try: - subsys_ret = rpc_nvmf.nvmf_get_subsystems(self.spdk_rpc_client, nqn=request.subsystem) - self.logger.info(f"list_connections subsystems: {subsys_ret}") + subsys_ret = rpc_nvmf.nvmf_get_subsystems(self.spdk_rpc_client, nqn=request.subsystem_nqn) + self.logger.info(f"connection list subsystems: {subsys_ret}") except Exception as ex: errmsg = f"Failure listing connections, can't get subsystems" self.logger.exception(errmsg) @@ -1887,8 +1887,8 @@ def list_connections_safe(self, request, context): host_nqns = [] for s in subsys_ret: try: - if s["nqn"] != request.subsystem: - self.logger.warning(f'Got subsystem {s["nqn"]} instead of {request.subsystem}, ignore') + if s["nqn"] != request.subsystem_nqn: + self.logger.warning(f'Got subsystem {s["nqn"]} instead of {request.subsystem_nqn}, ignore') continue try: subsys_hosts = s["hosts"] @@ -1950,10 +1950,10 @@ def list_connections_safe(self, request, context): connections.append(one_conn) return pb2.connections_info(status = 0, error_message = os.strerror(0), - subsystem_nqn=request.subsystem, connections=connections) + subsystem_nqn=request.subsystem_nqn, connections=connections) - def list_connections(self, request, context=None): - return self.execute_grpc_function(self.list_connections_safe, request, context) + def connection_list(self, request, context=None): + return self.execute_grpc_function(self.connection_list_safe, request, context) def get_subsystem_ha_status(self, nqn) -> bool: if nqn not in self.subsys_ha: @@ -1982,12 +1982,12 @@ def matching_listener_exists(self, context, nqn, traddr, trsvcid) -> bool: return False - def create_listener_safe(self, request, context): + def listener_create_safe(self, request, context): """Creates a listener for a subsystem at a given IP/Port.""" ret = True traddr = GatewayUtils.escape_address_if_ipv6(request.traddr) - create_listener_error_prefix = f"Failure adding {request.nqn} listener at {traddr}:{request.trsvcid}" + create_listener_error_prefix = f"Failure adding {request.subsystem_nqn} listener at {traddr}:{request.trsvcid}" adrfam = GatewayEnumUtils.get_key_from_value(pb2.AddressFamily, request.adrfam) if adrfam == None: @@ -1996,10 +1996,10 @@ def create_listener_safe(self, request, context): return pb2.req_status(status=errno.ENOKEY, error_message=errmsg) self.logger.info(f"Received request to create {request.host_name}" - f" TCP {adrfam} listener for {request.nqn} at" + f" TCP {adrfam} listener for {request.subsystem_nqn} at" f" {traddr}:{request.trsvcid}, context: {context}") - if GatewayUtils.is_discovery_nqn(request.nqn): + if GatewayUtils.is_discovery_nqn(request.subsystem_nqn): errmsg=f"{create_listener_error_prefix}: Can't create a listener for a discovery subsystem" self.logger.error(f"{errmsg}") return pb2.req_status(status=errno.EINVAL, error_message=errmsg) @@ -2013,20 +2013,20 @@ def create_listener_safe(self, request, context): try: if request.host_name == self.host_name: listener_already_exist = self.matching_listener_exists( - context, request.nqn, request.traddr, request.trsvcid) + context, request.subsystem_nqn, request.traddr, request.trsvcid) if listener_already_exist: - self.logger.error(f"{request.nqn} already listens on address {traddr}:{request.trsvcid}") + self.logger.error(f"{request.subsystem_nqn} already listens on address {traddr}:{request.trsvcid}") return pb2.req_status(status=errno.EEXIST, error_message=f"{create_listener_error_prefix}: Subsystem already listens on this address") ret = rpc_nvmf.nvmf_subsystem_add_listener( self.spdk_rpc_client, - nqn=request.nqn, + nqn=request.subsystem_nqn, trtype="TCP", traddr=request.traddr, trsvcid=str(request.trsvcid), adrfam=adrfam, ) - self.logger.info(f"create_listener: {ret}") + self.logger.info(f"add_listener: {ret}") else: if context: errmsg=f"{create_listener_error_prefix}: Gateway's host name must match current host ({self.host_name})" @@ -2051,7 +2051,7 @@ def create_listener_safe(self, request, context): self.logger.error(create_listener_error_prefix) return pb2.req_status(status=errno.EINVAL, error_message=create_listener_error_prefix) - enable_ha = self.get_subsystem_ha_status(request.nqn) + enable_ha = self.get_subsystem_ha_status(request.subsystem_nqn) if enable_ha: try: @@ -2059,7 +2059,7 @@ def create_listener_safe(self, request, context): _ana_state = "inaccessible" ret = rpc_nvmf.nvmf_subsystem_listener_set_ana_state( self.spdk_rpc_client, - nqn=request.nqn, + nqn=request.subsystem_nqn, ana_state=_ana_state, trtype="TCP", traddr=request.traddr, @@ -2069,15 +2069,15 @@ def create_listener_safe(self, request, context): # have been provided with ana state for this nqn prior to creation # update optimized ana groups - if self.ana_map[request.nqn]: - for x in range (self.subsys_max_ns[request.nqn]): + if self.ana_map[request.subsystem_nqn]: + for x in range (self.subsys_max_ns[request.subsystem_nqn]): ana_grp = x+1 - if ana_grp in self.ana_map[request.nqn] and self.ana_map[request.nqn][ana_grp] == pb2.ana_state.OPTIMIZED: + if ana_grp in self.ana_map[request.subsystem_nqn] and self.ana_map[request.subsystem_nqn][ana_grp] == pb2.ana_state.OPTIMIZED: _ana_state = "optimized" - self.logger.info(f"using ana_map: set listener on nqn : {request.nqn} ana state : {_ana_state} for group : {ana_grp}") + self.logger.info(f"using ana_map: set listener on nqn : {request.subsystem_nqn} ana state : {_ana_state} for group : {ana_grp}") ret = rpc_nvmf.nvmf_subsystem_listener_set_ana_state( self.spdk_rpc_client, - nqn=request.nqn, + nqn=request.subsystem_nqn, ana_state=_ana_state, trtype="TCP", traddr=request.traddr, @@ -2102,7 +2102,7 @@ def create_listener_safe(self, request, context): try: json_req = json_format.MessageToJson( request, preserving_proto_field_name=True, including_default_value_fields=True) - self.gateway_state.add_listener(request.nqn, + self.gateway_state.add_listener(request.subsystem_nqn, request.host_name, "TCP", request.traddr, request.trsvcid, json_req) @@ -2114,8 +2114,8 @@ def create_listener_safe(self, request, context): return pb2.req_status(status=0, error_message=os.strerror(0)) - def create_listener(self, request, context=None): - return self.execute_grpc_function(self.create_listener_safe, request, context) + def listener_create(self, request, context=None): + return self.execute_grpc_function(self.listener_create_safe, request, context) def remove_listener_from_state(self, nqn, host_name, traddr, port, context): if not context: @@ -2134,7 +2134,7 @@ def remove_listener_from_state(self, nqn, host_name, traddr, port, context): continue try: listener = json.loads(val) - listener_nqn = listener["nqn"] + listener_nqn = listener["subsystem_nqn"] if listener_nqn != nqn: self.logger.warning(f"Got subsystem {listener_nqn} instead of {nqn}, ignore") continue @@ -2165,12 +2165,12 @@ def remove_listener_from_state(self, nqn, host_name, traddr, port, context): return req_status - def delete_listener_safe(self, request, context): + def listener_delete_safe(self, request, context): """Deletes a listener from a subsystem at a given IP/Port.""" ret = True traddr = GatewayUtils.escape_address_if_ipv6(request.traddr) - delete_listener_error_prefix = f"Listener {traddr}:{request.trsvcid} failed to delete from {request.nqn}" + delete_listener_error_prefix = f"Listener {traddr}:{request.trsvcid} failed to delete from {request.subsystem_nqn}" adrfam = GatewayEnumUtils.get_key_from_value(pb2.AddressFamily, request.adrfam) if adrfam == None: @@ -2182,7 +2182,7 @@ def delete_listener_safe(self, request, context): host_msg = "all hosts" if request.host_name == "*" else f"host {request.host_name}" self.logger.info(f"Received request to delete TCP listener of {host_msg}" - f" for subsystem {request.nqn} at" + f" for subsystem {request.subsystem_nqn} at" f" {traddr}:{request.trsvcid}{force_msg}, context: {context}") if request.host_name == "*" and not request.force: @@ -2190,14 +2190,14 @@ def delete_listener_safe(self, request, context): self.logger.error(errmsg) return pb2.req_status(status=errno.EINVAL, error_message=errmsg) - if GatewayUtils.is_discovery_nqn(request.nqn): + if GatewayUtils.is_discovery_nqn(request.subsystem_nqn): errmsg=f"{delete_listener_error_prefix}. Can't delete a listener from a discovery subsystem" self.logger.error(errmsg) return pb2.req_status(status=errno.EINVAL, error_message=errmsg) if not request.force: - list_conn_req = pb2.list_connections_req(subsystem=request.nqn) - list_conn_ret = self.list_connections_safe(list_conn_req, context) + list_conn_req = pb2.connection_list_req(subsystem_nqn=request.subsystem_nqn) + list_conn_ret = self.connection_list_safe(list_conn_req, context) if list_conn_ret.status != 0: errmsg=f"{delete_listener_error_prefix}. Can't verify there are no active connections for this address" self.logger.error(errmsg) @@ -2218,13 +2218,13 @@ def delete_listener_safe(self, request, context): if request.host_name == self.host_name or request.force: ret = rpc_nvmf.nvmf_subsystem_remove_listener( self.spdk_rpc_client, - nqn=request.nqn, + nqn=request.subsystem_nqn, trtype="TCP", traddr=request.traddr, trsvcid=str(request.trsvcid), adrfam=adrfam, ) - self.logger.info(f"delete_listener: {ret}") + self.logger.info(f"remove_listener: {ret}") else: errmsg=f"{delete_listener_error_prefix}. Gateway's host name must match current host ({self.host_name}). You can continue to delete the listener by adding the `--force` parameter." self.logger.error(f"{errmsg}") @@ -2234,7 +2234,7 @@ def delete_listener_safe(self, request, context): # It's OK for SPDK to fail in case we used a different host name, just continue to remove from OMAP if request.host_name == self.host_name: errmsg = f"{delete_listener_error_prefix}:\n{ex}" - self.remove_listener_from_state(request.nqn, request.host_name, + self.remove_listener_from_state(request.subsystem_nqn, request.host_name, request.traddr, request.trsvcid, context) resp = self.parse_json_exeption(ex) status = errno.EINVAL @@ -2247,33 +2247,33 @@ def delete_listener_safe(self, request, context): # Just in case SPDK failed with no exception if not ret: self.logger.error(delete_listener_error_prefix) - self.remove_listener_from_state(request.nqn, request.host_name, + self.remove_listener_from_state(request.subsystem_nqn, request.host_name, request.traddr, request.trsvcid, context) return pb2.req_status(status=errno.EINVAL, error_message=delete_listener_error_prefix) - return self.remove_listener_from_state(request.nqn, request.host_name, + return self.remove_listener_from_state(request.subsystem_nqn, request.host_name, request.traddr, request.trsvcid, context) - def delete_listener(self, request, context=None): - return self.execute_grpc_function(self.delete_listener_safe, request, context) + def listener_delete(self, request, context=None): + return self.execute_grpc_function(self.listener_delete_safe, request, context) - def list_listeners_safe(self, request, context): + def listener_list_safe(self, request, context): """List listeners.""" - self.logger.info(f"Received request to list listeners for {request.subsystem}, context: {context}") + self.logger.info(f"Received request to list listeners for {request.subsystem_nqn}, context: {context}") listeners = [] with self.omap_lock(context=context): state = self.gateway_state.local.get_state() - listener_prefix = GatewayState.build_partial_listener_key(request.subsystem) + listener_prefix = GatewayState.build_partial_listener_key(request.subsystem_nqn) for key, val in state.items(): if not key.startswith(listener_prefix): continue try: listener = json.loads(val) - nqn = listener["nqn"] - if nqn != request.subsystem: - self.logger.warning(f"Got subsystem {nqn} instead of {request.subsystem}, ignore") + nqn = listener["subsystem_nqn"] + if nqn != request.subsystem_nqn: + self.logger.warning(f"Got subsystem {nqn} instead of {request.subsystem_nqn}, ignore") continue one_listener = pb2.listener_info(host_name = listener["host_name"], trtype = "TCP", @@ -2287,10 +2287,10 @@ def list_listeners_safe(self, request, context): return pb2.listeners_info(status = 0, error_message = os.strerror(0), listeners=listeners) - def list_listeners(self, request, context=None): - return self.execute_grpc_function(self.list_listeners_safe, request, context) + def listener_list(self, request, context=None): + return self.execute_grpc_function(self.listener_list_safe, request, context) - def list_subsystems_safe(self, request, context): + def subsystem_list_safe(self, request, context): """List subsystems.""" ser_msg = "" @@ -2307,7 +2307,7 @@ def list_subsystems_safe(self, request, context): ret = rpc_nvmf.nvmf_get_subsystems(self.spdk_rpc_client, nqn=request.subsystem_nqn) else: ret = rpc_nvmf.nvmf_get_subsystems(self.spdk_rpc_client) - self.logger.info(f"list_subsystems: {ret}") + self.logger.info(f"get_subsystems: {ret}") except Exception as ex: errmsg = f"Failure listing subsystems" self.logger.exception(errmsg) @@ -2379,10 +2379,10 @@ def get_subsystems(self, request, context): with self.rpc_lock: return self.get_subsystems_safe(request, context) - def list_subsystems(self, request, context=None): - return self.execute_grpc_function(self.list_subsystems_safe, request, context) + def subsystem_list(self, request, context=None): + return self.execute_grpc_function(self.subsystem_list_safe, request, context) - def get_spdk_nvmf_log_flags_and_level_safe(self, request, context): + def spdk_nvmf_log_flags_and_level_get_safe(self, request, context): """Gets spdk nvmf log flags, log level and log print level""" self.logger.info(f"Received request to get SPDK nvmf log flags and level") log_flags = [] @@ -2416,10 +2416,10 @@ def get_spdk_nvmf_log_flags_and_level_safe(self, request, context): status = 0, error_message = os.strerror(0)) - def get_spdk_nvmf_log_flags_and_level(self, request, context=None): - return self.execute_grpc_function(self.get_spdk_nvmf_log_flags_and_level_safe, request, context) + def spdk_nvmf_log_flags_and_level_get(self, request, context=None): + return self.execute_grpc_function(self.spdk_nvmf_log_flags_and_level_get_safe, request, context) - def set_spdk_nvmf_logs_safe(self, request, context): + def spdk_nvmf_logs_set_safe(self, request, context): """Enables spdk nvmf logs""" log_level = None print_level = None @@ -2482,10 +2482,10 @@ def set_spdk_nvmf_logs_safe(self, request, context): errmsg = "Failure setting some SPDK nvmf log flags" return pb2.req_status(status=status, error_message=errmsg) - def set_spdk_nvmf_logs(self, request, context=None): - return self.execute_grpc_function(self.set_spdk_nvmf_logs_safe, request, context) + def spdk_nvmf_logs_set(self, request, context=None): + return self.execute_grpc_function(self.spdk_nvmf_logs_set_safe, request, context) - def disable_spdk_nvmf_logs_safe(self, request, context): + def spdk_nvmf_logs_disable_safe(self, request, context): """Disables spdk nvmf logs""" self.logger.info(f"Received request to disable SPDK nvmf logs") @@ -2515,8 +2515,8 @@ def disable_spdk_nvmf_logs_safe(self, request, context): errmsg = "Failure in disable SPDK nvmf log flags" return pb2.req_status(status=status, error_message=errmsg) - def disable_spdk_nvmf_logs(self, request, context=None): - return self.execute_grpc_function(self.disable_spdk_nvmf_logs_safe, request, context) + def spdk_nvmf_logs_disable(self, request, context=None): + return self.execute_grpc_function(self.spdk_nvmf_logs_disable_safe, request, context) def parse_version(self, version): if not version: @@ -2533,7 +2533,7 @@ def parse_version(self, version): return None return (v1, v2, v3) - def get_gateway_info_safe(self, request, context): + def gateway_info_get_safe(self, request, context): """Get gateway's info""" self.logger.info(f"Received request to get gateway's info") @@ -2579,11 +2579,11 @@ def get_gateway_info_safe(self, request, context): log_func(f"Gateway's info:\n{ret}") return ret - def get_gateway_info(self, request, context=None): + def gateway_info_get(self, request, context=None): """Get gateway's info""" - return self.execute_grpc_function(self.get_gateway_info_safe, request, context) + return self.execute_grpc_function(self.gateway_info_get_safe, request, context) - def get_gateway_log_level(self, request, context=None): + def gateway_log_level_get(self, request, context=None): """Get gateway's log level""" try: log_level = GatewayEnumUtils.get_key_from_value(pb2.GwLogLevel, self.logger.level) @@ -2594,7 +2594,7 @@ def get_gateway_log_level(self, request, context=None): self.logger.info(f"Received request to get gateway's log level. Level is {log_level}") return pb2.gateway_log_level_info(status = 0, error_message=os.strerror(0), log_level=log_level) - def set_gateway_log_level(self, request, context=None): + def gateway_log_level_set(self, request, context=None): """Set gateway's log level""" log_level = GatewayEnumUtils.get_key_from_value(pb2.GwLogLevel, request.log_level) diff --git a/control/prometheus.py b/control/prometheus.py index 4d3886b1..d1703284 100644 --- a/control/prometheus.py +++ b/control/prometheus.py @@ -138,8 +138,8 @@ def __init__(self, spdk_rpc_client, config, gateway_rpc): def _get_gw_metadata(self): """Fetch Gateway metadata""" ver = os.getenv("NVMEOF_VERSION") - req = pb2.get_gateway_info_req(cli_version=ver) - metadata = self.gateway_rpc.get_gateway_info(req) + req = pb2.gateway_info_get_req(cli_version=ver) + metadata = self.gateway_rpc.gateway_info_get(req) # Since empty values result in a missing label, when the group name is not # defined _null_ is used to ensure any promql queries will always work against @@ -170,11 +170,11 @@ def _get_subsystems(self): return subsystems_info.subsystems @timer - def _list_subsystems(self): + def _subsystem_list(self): """Fetch abbreviated subsystem information used by the CLI""" - resp = self.gateway_rpc.list_subsystems(pb2.list_subsystems_req()) + resp = self.gateway_rpc.subsystem_list(pb2.subsystem_list_req()) if resp.status != 0: - logger.error(f"Exporter failed to execute list_subsystems: {resp.error_message}") + logger.error(f"Exporter failed to execute subsystem_list: {resp.error_message}") return {} return {subsys.nqn: subsys for subsys in resp.subsystems} @@ -184,7 +184,7 @@ def _get_connection_map(self, subsystem_list): """Fetch connection information for all defined subsystems""" connection_map = {} for subsys in subsystem_list: - resp = self.gateway_rpc.list_connections(pb2.list_connections_req(subsystem=subsys.nqn)) + resp = self.gateway_rpc.connection_list(pb2.connection_list_req(subsystem_nqn=subsys.nqn)) if resp.status != 0: logger.error(f"Exporter failed to fetch connection info for {subsys.nqn}: {resp.error_message}") continue @@ -197,7 +197,7 @@ def _get_data(self): self.bdev_io_stats = self._get_bdev_io_stats() self.spdk_thread_stats = self._get_spdk_thread_stats() self.subsystems = self._get_subsystems() - self.subsystems_cli = self._list_subsystems() + self.subsystems_cli = self._subsystem_list() self.connections = self._get_connection_map(self.subsystems) @ttl diff --git a/control/proto/gateway.proto b/control/proto/gateway.proto index 3b44515e..e2bae97d 100644 --- a/control/proto/gateway.proto +++ b/control/proto/gateway.proto @@ -37,13 +37,13 @@ service Gateway { rpc namespace_add(namespace_add_req) returns (nsid_status) {} // Creates a subsystem - rpc create_subsystem(create_subsystem_req) returns(req_status) {} + rpc subsystem_create(subsystem_create_req) returns(req_status) {} // Deletes a subsystem - rpc delete_subsystem(delete_subsystem_req) returns(req_status) {} + rpc subsystem_delete(subsystem_delete_req) returns(req_status) {} // List namespaces - rpc list_namespaces(list_namespaces_req) returns(namespaces_info) {} + rpc namespace_list(namespace_list_req) returns(namespaces_info) {} // Resizes a namespace rpc namespace_resize(namespace_resize_req) returns (req_status) {} @@ -61,28 +61,28 @@ service Gateway { rpc namespace_delete(namespace_delete_req) returns (req_status) {} // Adds a host to a subsystem - rpc add_host(add_host_req) returns (req_status) {} + rpc host_add(host_add_req) returns (req_status) {} // Removes a host from a subsystem - rpc remove_host(remove_host_req) returns (req_status) {} + rpc host_remove(host_remove_req) returns (req_status) {} // List hosts - rpc list_hosts(list_hosts_req) returns(hosts_info) {} + rpc host_list(host_list_req) returns(hosts_info) {} // List connections - rpc list_connections(list_connections_req) returns(connections_info) {} + rpc connection_list(connection_list_req) returns(connections_info) {} // Creates a listener for a subsystem at a given IP/Port - rpc create_listener(create_listener_req) returns(req_status) {} + rpc listener_create(listener_create_req) returns(req_status) {} // Deletes a listener from a subsystem at a given IP/Port - rpc delete_listener(delete_listener_req) returns(req_status) {} + rpc listener_delete(listener_delete_req) returns(req_status) {} // List listeners - rpc list_listeners(list_listeners_req) returns(listeners_info) {} + rpc listener_list(listener_list_req) returns(listeners_info) {} // List subsystems - rpc list_subsystems(list_subsystems_req) returns(subsystems_info_cli) {} + rpc subsystem_list(subsystem_list_req) returns(subsystems_info_cli) {} // Gets subsystems rpc get_subsystems(get_subsystems_req) returns(subsystems_info) {} @@ -91,22 +91,22 @@ service Gateway { rpc set_ana_state(ana_info) returns(req_status) {} // 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) {} + rpc spdk_nvmf_log_flags_and_level_get(spdk_nvmf_log_flags_and_level_get_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) {} + rpc spdk_nvmf_logs_disable(spdk_nvmf_logs_disable_req) returns(req_status) {} // Set spdk nvmf logs - rpc set_spdk_nvmf_logs(set_spdk_nvmf_logs_req) returns(req_status) {} + rpc spdk_nvmf_logs_set(spdk_nvmf_logs_set_req) returns(req_status) {} // Get gateway info - rpc get_gateway_info(get_gateway_info_req) returns(gateway_info) {} + rpc gateway_info_get(gateway_info_get_req) returns(gateway_info) {} // Get gateway log level - rpc get_gateway_log_level(get_gateway_log_level_req) returns(gateway_log_level_info) {} + rpc gateway_log_level_get(gateway_log_level_get_req) returns(gateway_log_level_info) {} // Set gateway log level - rpc set_gateway_log_level(set_gateway_log_level_req) returns(req_status) {} + rpc gateway_log_level_set(gateway_log_level_set_req) returns(req_status) {} } // Request messages @@ -118,7 +118,7 @@ message namespace_add_req { optional uint32 nsid = 4; uint32 block_size = 5; optional string uuid = 6; - optional int32 anagrpid = 7; + optional int32 load_balancing_group = 7; optional bool create_image = 8; optional uint64 size = 9; optional bool force = 10; @@ -151,7 +151,13 @@ message namespace_change_load_balancing_group_req { string subsystem_nqn = 1; optional uint32 nsid = 2; optional string uuid = 3; - int32 anagrpid = 4; + int32 load_balancing_group = 4; +} + +message namespace_list_req { + string subsystem_nqn = 1; + optional uint32 nsid = 2; + optional string uuid = 3; } message namespace_delete_req { @@ -160,52 +166,46 @@ message namespace_delete_req { optional string uuid = 3; } -message create_subsystem_req { +message subsystem_create_req { string subsystem_nqn = 1; string serial_number = 2; optional uint32 max_namespaces = 3; bool enable_ha = 4; } -message delete_subsystem_req { +message subsystem_delete_req { string subsystem_nqn = 1; optional bool force = 2; } -message list_namespaces_req { - string subsystem = 1; - optional uint32 nsid = 2; - optional string uuid = 3; -} - -message add_host_req { +message host_add_req { string subsystem_nqn = 1; string host_nqn = 2; } -message remove_host_req { +message host_remove_req { string subsystem_nqn = 1; string host_nqn = 2; } -message list_hosts_req { - string subsystem = 1; +message host_list_req { + string subsystem_nqn = 1; } -message list_connections_req { - string subsystem = 1; +message connection_list_req { + string subsystem_nqn = 1; } -message create_listener_req { - string nqn = 1; +message listener_create_req { + string subsystem_nqn = 1; string host_name = 2; string traddr = 3; optional AddressFamily adrfam = 5; optional uint32 trsvcid = 6; } -message delete_listener_req { - string nqn = 1; +message listener_delete_req { + string subsystem_nqn = 1; string host_name = 2; string traddr = 3; optional AddressFamily adrfam = 5; @@ -213,11 +213,11 @@ message delete_listener_req { optional bool force = 7; } -message list_listeners_req { - string subsystem = 1; +message listener_list_req { + string subsystem_nqn = 1; } -message list_subsystems_req { +message subsystem_list_req { optional string subsystem_nqn = 1; optional string serial_number = 2; } @@ -225,25 +225,25 @@ message list_subsystems_req { message get_subsystems_req { } -message get_spdk_nvmf_log_flags_and_level_req { +message spdk_nvmf_log_flags_and_level_get_req { } -message disable_spdk_nvmf_logs_req { +message spdk_nvmf_logs_disable_req { } -message set_spdk_nvmf_logs_req { +message spdk_nvmf_logs_set_req { optional LogLevel log_level = 1; optional LogLevel print_level = 2; } -message get_gateway_info_req { +message gateway_info_get_req { optional string cli_version = 1; } -message get_gateway_log_level_req { +message gateway_log_level_get_req { } -message set_gateway_log_level_req { +message gateway_log_level_set_req { GwLogLevel log_level = 1; } diff --git a/control/server.py b/control/server.py index 63253a89..f803f386 100644 --- a/control/server.py +++ b/control/server.py @@ -463,13 +463,13 @@ def gateway_rpc_caller(self, requests, is_add_req): for key, val in requests.items(): if key.startswith(GatewayState.SUBSYSTEM_PREFIX): if is_add_req: - req = json_format.Parse(val, pb2.create_subsystem_req()) - self.gateway_rpc.create_subsystem(req) + req = json_format.Parse(val, pb2.subsystem_create_req()) + self.gateway_rpc.subsystem_create(req) else: req = json_format.Parse(val, - pb2.delete_subsystem_req(), + pb2.subsystem_delete_req(), ignore_unknown_fields=True) - self.gateway_rpc.delete_subsystem(req) + self.gateway_rpc.subsystem_delete(req) elif key.startswith(GatewayState.NAMESPACE_PREFIX): if is_add_req: req = json_format.Parse(val, pb2.namespace_add_req()) @@ -488,15 +488,15 @@ def gateway_rpc_caller(self, requests, is_add_req): pass elif key.startswith(GatewayState.HOST_PREFIX): if is_add_req: - req = json_format.Parse(val, pb2.add_host_req()) - self.gateway_rpc.add_host(req) + req = json_format.Parse(val, pb2.host_add_req()) + self.gateway_rpc.host_add(req) else: - req = json_format.Parse(val, pb2.remove_host_req(), ignore_unknown_fields=True) - self.gateway_rpc.remove_host(req) + req = json_format.Parse(val, pb2.host_remove_req(), ignore_unknown_fields=True) + self.gateway_rpc.host_remove(req) elif key.startswith(GatewayState.LISTENER_PREFIX): if is_add_req: - req = json_format.Parse(val, pb2.create_listener_req()) - self.gateway_rpc.create_listener(req) + req = json_format.Parse(val, pb2.listener_create_req()) + self.gateway_rpc.listener_create(req) else: - req = json_format.Parse(val, pb2.delete_listener_req(), ignore_unknown_fields=True) - self.gateway_rpc.delete_listener(req) + req = json_format.Parse(val, pb2.listener_delete_req(), ignore_unknown_fields=True) + self.gateway_rpc.listener_delete(req) diff --git a/tests/test_cli.py b/tests/test_cli.py index daabd524..425360cd 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -72,27 +72,27 @@ def test_get_subsystems_ipv6(self, caplog, gateway): cli(["--server-address", server_addr_ipv6, "subsystem", "list"]) assert "No subsystems" in caplog.text - def test_get_gateway_info(self, caplog, gateway): + def test_gateway_info_get(self, caplog, gateway): gw, stub = gateway caplog.clear() - gw_info_req = pb2.get_gateway_info_req(cli_version="0.0.1") - ret = stub.get_gateway_info(gw_info_req) + gw_info_req = pb2.gateway_info_get_req(cli_version="0.0.1") + ret = stub.gateway_info_get(gw_info_req) assert ret.status != 0 assert "is older than gateway" in caplog.text caplog.clear() - gw_info_req = pb2.get_gateway_info_req() - ret = stub.get_gateway_info(gw_info_req) + gw_info_req = pb2.gateway_info_get_req() + ret = stub.gateway_info_get(gw_info_req) assert "No CLI version specified" in caplog.text assert ret.status == 0 caplog.clear() - gw_info_req = pb2.get_gateway_info_req(cli_version="0.0.1.4") - ret = stub.get_gateway_info(gw_info_req) + gw_info_req = pb2.gateway_info_get_req(cli_version="0.0.1.4") + ret = stub.gateway_info_get(gw_info_req) assert "Can't parse version" in caplog.text assert "Invalid CLI version" in caplog.text assert ret.status == 0 caplog.clear() - gw_info_req = pb2.get_gateway_info_req(cli_version="0.X.4") - ret = stub.get_gateway_info(gw_info_req) + gw_info_req = pb2.gateway_info_get_req(cli_version="0.X.4") + ret = stub.gateway_info_get(gw_info_req) assert "Can't parse version" in caplog.text assert "Invalid CLI version" in caplog.text assert ret.status == 0 @@ -102,8 +102,8 @@ def test_get_gateway_info(self, caplog, gateway): save_addr = gw.config.config["gateway"]["addr"] gw.config.config["gateway"]["port"] = "6789" gw.config.config["gateway"]["addr"] = "10.10.10.10" - gw_info_req = pb2.get_gateway_info_req(cli_version=cli_ver) - ret = stub.get_gateway_info(gw_info_req) + gw_info_req = pb2.gateway_info_get_req(cli_version=cli_ver) + ret = stub.gateway_info_get(gw_info_req) assert ret.status == 0 assert f'version: "{cli_ver}"' in caplog.text assert 'port: "6789"' in caplog.text @@ -542,7 +542,7 @@ def test_namespace_io_stats(self, caplog, gateway): assert rc == 2 @pytest.mark.parametrize("host", host_list) - def test_add_host(self, caplog, host): + def test_host_add(self, caplog, host): caplog.clear() rc = 0 try: @@ -559,7 +559,7 @@ def test_add_host(self, caplog, host): else: assert f"Adding host {host} to {subsystem}: Successful" in caplog.text - def test_add_host_invalid_nqn(self, caplog): + def test_host_add_invalid_nqn(self, caplog): caplog.clear() cli(["host", "add", "--subsystem", subsystem, "--host", "nqn.2016"]) assert f'NQN "nqn.2016" is too short, minimal length is 11' in caplog.text @@ -663,7 +663,7 @@ def test_create_listener_on_discovery(self, caplog, listener, gateway): class TestDelete: @pytest.mark.parametrize("host", host_list) - def test_remove_host(self, caplog, host, gateway): + def test_host_remove(self, caplog, host, gateway): caplog.clear() rc = 0 try: @@ -747,14 +747,15 @@ def test_remove_namespace(self, caplog, gateway): bdev_name = ns_list.namespaces[0].bdev_name assert bdev_name bdev_found = False - bdev_list = rpc_bdev.bdev_get_bdevs(gw.spdk_rpc_client) - for b in bdev_list: + bdevs_list = rpc_bdev.bdev_get_bdevs(gw.spdk_rpc_client) + for b in bdevs_list: try: if bdev_name == b["name"]: bdev_found = True break except KeyError: print(f"Couldn't find field name in: {b}") + print(f"bdev list is: {bdevs_list}") assert bdev_found caplog.clear() del_ns_req = pb2.namespace_delete_req(subsystem_nqn=subsystem) @@ -765,14 +766,15 @@ def test_remove_namespace(self, caplog, gateway): assert f"Deleting namespace {nsid} from {subsystem}: Successful" in caplog.text assert f"Error removing namespace's QOS limits, they might not have been set" not in caplog.text bdev_found = False - bdev_list = rpc_bdev.bdev_get_bdevs(gw.spdk_rpc_client) - for b in bdev_list: + bdevs_list = rpc_bdev.bdev_get_bdevs(gw.spdk_rpc_client) + for b in bdevs_list: try: if bdev_name == b["name"]: bdev_found = True break except KeyError: print(f"Couldn't find field name in: {b}") + print(f"bdev list is: {bdevs_list}") assert not bdev_found caplog.clear() cli(["namespace", "del", "--subsystem", subsystem, "--nsid", "2"]) @@ -782,7 +784,7 @@ def test_remove_namespace(self, caplog, gateway): cli(["namespace", "del", "--subsystem", subsystem, "--nsid", nsid_ipv6]) assert f"Deleting namespace {nsid_ipv6} from {subsystem}: Successful" in caplog.text - def test_delete_subsystem(self, caplog, gateway): + def test_subsystem_delete(self, caplog, gateway): caplog.clear() cli(["subsystem", "del", "--subsystem", subsystem]) assert f"Failure deleting subsystem {subsystem}: Namespace 2 is still using the subsystem" @@ -796,7 +798,7 @@ def test_delete_subsystem(self, caplog, gateway): cli(["subsystem", "list"]) assert "No subsystems" in caplog.text - def test_delete_subsystem_with_discovery_nqn(self, caplog, gateway): + def test_subsystem_delete_with_discovery_nqn(self, caplog, gateway): caplog.clear() rc = 0 try: @@ -862,7 +864,7 @@ def test_remove_namespace_ana(self, caplog, gateway): cli(["namespace", "del", "--subsystem", subsystem, "--nsid", nsid]) assert f"Deleting namespace {nsid} from {subsystem}: Successful" in caplog.text - def test_delete_subsystem_ana(self, caplog, gateway): + def test_subsystem_delete_ana(self, caplog, gateway): caplog.clear() cli(["subsystem", "del", "--subsystem", subsystem]) assert f"Deleting subsystem {subsystem}: Successful" in caplog.text diff --git a/tests/test_multi_gateway.py b/tests/test_multi_gateway.py index a1936351..3bbf94e9 100644 --- a/tests/test_multi_gateway.py +++ b/tests/test_multi_gateway.py @@ -73,22 +73,22 @@ def test_multi_gateway_coordination(config, image, conn): pool = config.get("ceph", "pool") # Send requests to create a subsystem with one namespace to GatewayA - subsystem_req = pb2.create_subsystem_req(subsystem_nqn=nqn, + subsystem_req = pb2.subsystem_create_req(subsystem_nqn=nqn, serial_number=serial, enable_ha=True) namespace_req = pb2.namespace_add_req(subsystem_nqn=nqn, rbd_pool_name=pool, rbd_image_name=image, block_size=4096, nsid=nsid, create_image=True, size=16*1024*1024) - list_subsystems_req = pb2.list_subsystems_req() - list_namespaces_req = pb2.list_namespaces_req(subsystem=nqn) - ret_subsystem = stubA.create_subsystem(subsystem_req) + subsystem_list_req = pb2.subsystem_list_req() + namespace_list_req = pb2.namespace_list_req(subsystem_nqn=nqn) + ret_subsystem = stubA.subsystem_create(subsystem_req) ret_namespace = stubA.namespace_add(namespace_req) assert ret_subsystem.status == 0 assert ret_namespace.status == 0 nsListA = json.loads(json_format.MessageToJson( - stubA.list_namespaces(list_namespaces_req), + stubA.namespace_list(namespace_list_req), preserving_proto_field_name=True, including_default_value_fields=True))['namespaces'] assert len(nsListA) == 1 assert nsListA[0]["nsid"] == nsid @@ -98,7 +98,7 @@ def test_multi_gateway_coordination(config, image, conn): if update_notify: time.sleep(1) listB = json.loads(json_format.MessageToJson( - stubB.list_subsystems(list_subsystems_req), + stubB.subsystem_list(subsystem_list_req), preserving_proto_field_name=True, including_default_value_fields=True))['subsystems'] assert len(listB) == num_subsystems assert listB[num_subsystems-1]["nqn"] == nqn @@ -106,7 +106,7 @@ def test_multi_gateway_coordination(config, image, conn): assert listB[num_subsystems-1]["namespace_count"] == 1 nsListB = json.loads(json_format.MessageToJson( - stubB.list_namespaces(list_namespaces_req), + stubB.namespace_list(namespace_list_req), preserving_proto_field_name=True, including_default_value_fields=True))['namespaces'] assert len(nsListB) == 1 assert nsListB[0]["nsid"] == nsid @@ -117,14 +117,14 @@ def test_multi_gateway_coordination(config, image, conn): # Periodic update time.sleep(update_interval_sec + 1) listB = json.loads(json_format.MessageToJson( - stubB.list_subsystems(list_subsystems_req), + stubB.subsystem_list(subsystem_list_req), preserving_proto_field_name=True, including_default_value_fields=True))['subsystems'] assert len(listB) == num_subsystems assert listB[num_subsystems-1]["nqn"] == nqn assert listB[num_subsystems-1]["serial_number"] == serial assert listB[num_subsystems-1]["namespace_count"] == 1 nsListB = json.loads(json_format.MessageToJson( - stubB.list_namespaces(list_namespaces_req), + stubB.namespace_list(namespace_list_req), preserving_proto_field_name=True, including_default_value_fields=True))['namespaces'] assert len(nsListB) == 1 assert nsListB[0]["nsid"] == nsid diff --git a/tests/test_namespaces.py b/tests/test_namespaces.py index 065fea15..91200b33 100644 --- a/tests/test_namespaces.py +++ b/tests/test_namespaces.py @@ -86,18 +86,18 @@ def delete_namespace(stub, nsid): ret_del_namespace = stub.namespace_delete(del_ns_req) assert ret_del_namespace.status == 0 -def create_subsystem(stub, nqn, max_ns): - subsystem_req = pb2.create_subsystem_req(subsystem_nqn=nqn, max_namespaces=max_ns, enable_ha=True) - ret_subsystem = stub.create_subsystem(subsystem_req) +def subsystem_create(stub, nqn, max_ns): + subsystem_req = pb2.subsystem_create_req(subsystem_nqn=nqn, max_namespaces=max_ns, enable_ha=True) + ret_subsystem = stub.subsystem_create(subsystem_req) assert ret_subsystem.status == 0 -def create_listener(stub, nqn, name, addr, port): - listener_req = pb2.create_listener_req(nqn=nqn, +def listener_create(stub, nqn, name, addr, port): + listener_req = pb2.listener_create_req(subsystem_nqn=nqn, host_name=name, adrfam="ipv4", traddr=addr, trsvcid=port) - listener_ret = stub.create_listener(listener_req) + listener_ret = stub.listener_create(listener_req) assert listener_ret.status == 0 def wait_for_update(): @@ -119,17 +119,17 @@ def test_create_subsystem_and_namespaces(config, image, conn): # Send requests to create a subsystem to GatewayA max_ns = namespace_count * run_count + 10 - create_subsystem(stubA, subsystem_nqn, max_ns) - list_namespaces_req = pb2.list_namespaces_req(subsystem=subsystem_nqn) + subsystem_create(stubA, subsystem_nqn, max_ns) + namespace_list_req = pb2.namespace_list_req(subsystem_nqn=subsystem_nqn) listA = json.loads(json_format.MessageToJson( - stubA.list_subsystems(pb2.list_subsystems_req()), + stubA.subsystem_list(pb2.subsystem_list_req()), preserving_proto_field_name=True, including_default_value_fields=True))['subsystems'] assert len(listA) == 2 assert listA[1]["nqn"] == subsystem_nqn wait_for_update() listB = json.loads(json_format.MessageToJson( - stubB.list_subsystems(pb2.list_subsystems_req()), + stubB.subsystem_list(pb2.subsystem_list_req()), preserving_proto_field_name=True, including_default_value_fields=True))['subsystems'] assert len(listB) == 2 @@ -138,8 +138,8 @@ def test_create_subsystem_and_namespaces(config, image, conn): wait_for_update() - create_listener(stubA, subsystem_nqn, gwA.host_name, "127.0.0.1", 5101) - create_listener(stubB, subsystem_nqn, gwB.host_name, "127.0.0.1", 5102) + listener_create(stubA, subsystem_nqn, gwA.host_name, "127.0.0.1", 5101) + listener_create(stubB, subsystem_nqn, gwB.host_name, "127.0.0.1", 5102) wait_for_update() @@ -152,7 +152,7 @@ def test_create_subsystem_and_namespaces(config, image, conn): create_namespace(stubB, pool, image, nsid) time.sleep(0.5) - create_subsystem(stubA, f"{subsystem_nqn}A{nsid}", 256) + subsystem_create(stubA, f"{subsystem_nqn}A{nsid}", 256) for ns in range(int(namespace_count / 2), namespace_count): nsid += 1 @@ -160,23 +160,23 @@ def test_create_subsystem_and_namespaces(config, image, conn): create_namespace(stubB, f"{pool}2", f"{image}2", nsid) time.sleep(0.5) - create_subsystem(stubA, f"{subsystem_nqn}B{nsid}", 256) + subsystem_create(stubA, f"{subsystem_nqn}B{nsid}", 256) listB = json.loads(json_format.MessageToJson( - stubB.list_subsystems(pb2.list_subsystems_req()), + stubB.subsystem_list(pb2.subsystem_list_req()), preserving_proto_field_name=True, including_default_value_fields=True))['subsystems'] assert listB[1]["namespace_count"] == ns_count nsListB = json.loads(json_format.MessageToJson( - stubB.list_namespaces(list_namespaces_req), + stubB.namespace_list(namespace_list_req), preserving_proto_field_name=True, including_default_value_fields=True))['namespaces'] assert len(nsListB) == ns_count wait_for_update() listA = json.loads(json_format.MessageToJson( - stubA.list_subsystems(pb2.list_subsystems_req()), + stubA.subsystem_list(pb2.subsystem_list_req()), preserving_proto_field_name=True, including_default_value_fields=True))['subsystems'] assert listA[1]["namespace_count"] == ns_count nsListA = json.loads(json_format.MessageToJson( - stubA.list_namespaces(list_namespaces_req), + stubA.namespace_list(namespace_list_req), preserving_proto_field_name=True, including_default_value_fields=True))['namespaces'] assert len(nsListA) == ns_count @@ -185,22 +185,22 @@ def test_create_subsystem_and_namespaces(config, image, conn): delete_namespace(stubB, run * namespace_count + ns) time.sleep(0.5) - create_subsystem(stubA, f"{subsystem_nqn}C{nsid}", 256) + subsystem_create(stubA, f"{subsystem_nqn}C{nsid}", 256) listB = json.loads(json_format.MessageToJson( - stubB.list_subsystems(pb2.list_subsystems_req()), + stubB.subsystem_list(pb2.subsystem_list_req()), preserving_proto_field_name=True, including_default_value_fields=True))['subsystems'] assert listB[1]["namespace_count"] == ns_count nsListB = json.loads(json_format.MessageToJson( - stubB.list_namespaces(list_namespaces_req), + stubB.namespace_list(namespace_list_req), preserving_proto_field_name=True, including_default_value_fields=True))['namespaces'] assert len(nsListB) == ns_count wait_for_update() listA = json.loads(json_format.MessageToJson( - stubA.list_subsystems(pb2.list_subsystems_req()), + stubA.subsystem_list(pb2.subsystem_list_req()), preserving_proto_field_name=True, including_default_value_fields=True))['subsystems'] assert listA[1]["namespace_count"] == ns_count nsListA = json.loads(json_format.MessageToJson( - stubA.list_namespaces(list_namespaces_req), + stubA.namespace_list(namespace_list_req), preserving_proto_field_name=True, including_default_value_fields=True))['namespaces'] assert len(nsListA) == ns_count diff --git a/tests/test_nsid.py b/tests/test_nsid.py index 01f78dcf..74ab891c 100644 --- a/tests/test_nsid.py +++ b/tests/test_nsid.py @@ -75,14 +75,14 @@ def test_multi_gateway_namespace_ids(config, image, caplog): # Send requests to create a subsystem on GatewayA caplog.clear() subsystem = f"{subsystem_prefix}PPP" - subsystem_add_req = pb2.create_subsystem_req(subsystem_nqn=subsystem) - ret_subsystem = stubA.create_subsystem(subsystem_add_req) + subsystem_add_req = pb2.subsystem_create_req(subsystem_nqn=subsystem) + ret_subsystem = stubA.subsystem_create(subsystem_add_req) assert ret_subsystem.status != 0 assert "HA must be enabled for subsystems" in caplog.text caplog.clear() subsystem = f"{subsystem_prefix}WWW" - subsystem_add_req = pb2.create_subsystem_req(subsystem_nqn=subsystem, enable_ha=True) - ret_subsystem = stubA.create_subsystem(subsystem_add_req) + subsystem_add_req = pb2.subsystem_create_req(subsystem_nqn=subsystem, enable_ha=True) + ret_subsystem = stubA.subsystem_create(subsystem_add_req) assert ret_subsystem.status == 0 assert f"create_subsystem {subsystem}: True" in caplog.text assert f"Failure creating subsystem {subsystem}" not in caplog.text @@ -102,9 +102,9 @@ def test_multi_gateway_namespace_ids(config, image, caplog): assert ret_ns.status == 0 time.sleep(10) - namespace_list_req = pb2.list_namespaces_req(subsystem=subsystem) + namespace_list_req = pb2.namespace_list_req(subsystem_nqn=subsystem) listA = json.loads(json_format.MessageToJson( - stubA.list_namespaces(namespace_list_req), + stubA.namespace_list(namespace_list_req), preserving_proto_field_name=True, including_default_value_fields=True)) assert listA["status"] == 0 assert len(listA["namespaces"]) == 2 @@ -118,7 +118,7 @@ def test_multi_gateway_namespace_ids(config, image, caplog): imgA2 = listA["namespaces"][1]["rbd_image_name"] time.sleep(10) listB = json.loads(json_format.MessageToJson( - stubB.list_namespaces(namespace_list_req), + stubB.namespace_list(namespace_list_req), preserving_proto_field_name=True, including_default_value_fields=True)) assert listB["status"] == 0 assert len(listB["namespaces"]) == 2 @@ -156,7 +156,7 @@ def test_multi_gateway_namespace_ids(config, image, caplog): stubB = pb2_grpc.GatewayStub(channelB) time.sleep(10) listB = json.loads(json_format.MessageToJson( - stubB.list_namespaces(namespace_list_req), + stubB.namespace_list(namespace_list_req), preserving_proto_field_name=True, including_default_value_fields=True)) assert listB["status"] == 0 assert len(listB["namespaces"]) == 2 diff --git a/tests/test_omap_lock.py b/tests/test_omap_lock.py index 3bc15804..b5da6a8e 100644 --- a/tests/test_omap_lock.py +++ b/tests/test_omap_lock.py @@ -135,8 +135,8 @@ def build_host_nqn(i): def create_resource_by_index(stub, i, caplog): subsystem = f"{subsystem_prefix}{i}" - subsystem_req = pb2.create_subsystem_req(subsystem_nqn=subsystem, enable_ha=True) - ret_subsystem = stub.create_subsystem(subsystem_req) + subsystem_req = pb2.subsystem_create_req(subsystem_nqn=subsystem, enable_ha=True) + ret_subsystem = stub.subsystem_create(subsystem_req) assert ret_subsystem.status == 0 if caplog != None: assert f"create_subsystem {subsystem}: True" in caplog.text @@ -147,15 +147,15 @@ def create_resource_by_index(stub, i, caplog): ret_namespace = stub.namespace_add(namespace_req) assert ret_namespace.status == 0 hostnqn = build_host_nqn(i) - host_req = pb2.add_host_req(subsystem_nqn=subsystem, host_nqn=hostnqn) - ret_host = stub.add_host(host_req) + host_req = pb2.host_add_req(subsystem_nqn=subsystem, host_nqn=hostnqn) + ret_host = stub.host_add(host_req) assert ret_host.status == 0 - host_req = pb2.add_host_req(subsystem_nqn=subsystem, host_nqn="*") - ret_host = stub.add_host(host_req) + host_req = pb2.host_add_req(subsystem_nqn=subsystem, host_nqn="*") + ret_host = stub.host_add(host_req) assert ret_host.status == 0 if caplog != None: assert f"add_host {hostnqn}: True" in caplog.text - assert "add_host *: True" in caplog.text + assert f"allow_any_host: True" in caplog.text assert f"Failure allowing open host access to {subsystem}" not in caplog.text assert f"Failure adding host {hostnqn} to {subsystem}" not in caplog.text @@ -187,25 +187,25 @@ def test_multi_gateway_omap_reread(config, conn_omap_reread, caplog): num_subsystems = 2 # Send requests to create a subsystem with one namespace to GatewayA - subsystem_req = pb2.create_subsystem_req(subsystem_nqn=nqn, serial_number=serial, enable_ha=True) + subsystem_req = pb2.subsystem_create_req(subsystem_nqn=nqn, serial_number=serial, enable_ha=True) namespace_req = pb2.namespace_add_req(subsystem_nqn=nqn, nsid=nsid, rbd_pool_name=pool, rbd_image_name=image, block_size=4096, create_image=True, size=16*1024*1024, force=True) - subsystem_list_req = pb2.list_subsystems_req() - ret_subsystem = stubA.create_subsystem(subsystem_req) + subsystem_list_req = pb2.subsystem_list_req() + ret_subsystem = stubA.subsystem_create(subsystem_req) assert ret_subsystem.status == 0 ret_namespace = stubA.namespace_add(namespace_req) assert ret_namespace.status == 0 # Until we create some resource on GW-B it shouldn't still have the resrouces created on GW-A, only the discovery subsystem listB = json.loads(json_format.MessageToJson( - stubB.list_subsystems(subsystem_list_req), + stubB.subsystem_list(subsystem_list_req), preserving_proto_field_name=True, including_default_value_fields=True))['subsystems'] assert len(listB) == 1 listA = json.loads(json_format.MessageToJson( - stubA.list_subsystems(subsystem_list_req), + stubA.subsystem_list(subsystem_list_req), preserving_proto_field_name=True, including_default_value_fields=True))['subsystems'] assert len(listA) == num_subsystems @@ -219,7 +219,7 @@ def test_multi_gateway_omap_reread(config, conn_omap_reread, caplog): # Make sure that after reading the OMAP file GW-B has the subsystem and namespace created on GW-A listB = json.loads(json_format.MessageToJson( - stubB.list_subsystems(subsystem_list_req), + stubB.subsystem_list(subsystem_list_req), preserving_proto_field_name=True, including_default_value_fields=True))['subsystems'] assert len(listB) == num_subsystems assert listB[num_subsystems-1]["nqn"] == nqn @@ -268,15 +268,15 @@ def test_multi_gateway_concurrent_changes(config, image, conn_concurrent, caplog else: create_resource_by_index(stubB, i, caplog) assert "failed" not in caplog.text.lower() - listener_req = pb2.create_listener_req(nqn=f"{subsystem_prefix}0", + listener_req = pb2.listener_create_req(subsystem_nqn=f"{subsystem_prefix}0", host_name=gwA.host_name, adrfam="ipv4", traddr="127.0.0.1", trsvcid=5001) - listener_ret = stubA.create_listener(listener_req) + listener_ret = stubA.listener_create(listener_req) assert listener_ret.status == 0 assert f"Received request to create {gwA.host_name} TCP ipv4 listener for {subsystem_prefix}0 at 127.0.0.1:5001" in caplog.text - assert f"create_listener: True" in caplog.text + assert f"add_listener: True" in caplog.text timeout = 15 # Maximum time to wait (in seconds) start_time = time.time() @@ -289,21 +289,21 @@ def test_multi_gateway_concurrent_changes(config, image, conn_concurrent, caplog assert expected_warning_other_gw in caplog.text caplog.clear() - subsystem_list_req = pb2.list_subsystems_req() + subsystem_list_req = pb2.subsystem_list_req() subListA = json.loads(json_format.MessageToJson( - stubA.list_subsystems(subsystem_list_req), + stubA.subsystem_list(subsystem_list_req), preserving_proto_field_name=True, including_default_value_fields=True))['subsystems'] subListB = json.loads(json_format.MessageToJson( - stubB.list_subsystems(subsystem_list_req), + stubB.subsystem_list(subsystem_list_req), preserving_proto_field_name=True, including_default_value_fields=True))['subsystems'] for i in range(created_resource_count): subsystem = f"{subsystem_prefix}{i}" - host_list_req = pb2.list_hosts_req(subsystem=subsystem) + host_list_req = pb2.host_list_req(subsystem_nqn=subsystem) hostListA = json.loads(json_format.MessageToJson( - stubA.list_hosts(host_list_req), + stubA.host_list(host_list_req), preserving_proto_field_name=True, including_default_value_fields=True)) hostListB = json.loads(json_format.MessageToJson( - stubB.list_hosts(host_list_req), + stubB.host_list(host_list_req), preserving_proto_field_name=True, including_default_value_fields=True)) check_resource_by_index(i, subListA, hostListA) check_resource_by_index(i, subListB, hostListB) @@ -315,51 +315,51 @@ def test_multi_gateway_listener_update(config, image, conn_concurrent, caplog): caplog.clear() subsystem = f"{subsystem_prefix}QQQ" - subsystem_add_req = pb2.create_subsystem_req(subsystem_nqn=subsystem, enable_ha=True) - ret_subsystem = stubA.create_subsystem(subsystem_add_req) + subsystem_add_req = pb2.subsystem_create_req(subsystem_nqn=subsystem, enable_ha=True) + ret_subsystem = stubA.subsystem_create(subsystem_add_req) assert ret_subsystem.status == 0 assert f"create_subsystem {subsystem}: True" in caplog.text assert f"Failure creating subsystem {subsystem}" not in caplog.text caplog.clear() - listenerA_req = pb2.create_listener_req(nqn=subsystem, + listenerA_req = pb2.listener_create_req(subsystem_nqn=subsystem, host_name=gwA.host_name, adrfam="ipv4", traddr="127.0.0.1", trsvcid=5101) - listener_ret = stubA.create_listener(listenerA_req) + listener_ret = stubA.listener_create(listenerA_req) assert listener_ret.status == 0 assert f"Received request to create {gwA.host_name} TCP ipv4 listener for {subsystem} at 127.0.0.1:5101" in caplog.text - assert f"create_listener: True" in caplog.text + assert f"add_listener: True" in caplog.text caplog.clear() - listenerB_req = pb2.create_listener_req(nqn=subsystem, + listenerB_req = pb2.listener_create_req(subsystem_nqn=subsystem, host_name=gwB.host_name, adrfam="ipv4", traddr="127.0.0.1", trsvcid=5102) - listener_ret = stubB.create_listener(listenerB_req) + listener_ret = stubB.listener_create(listenerB_req) assert listener_ret.status == 0 assert f"Received request to create {gwB.host_name} TCP ipv4 listener for {subsystem} at 127.0.0.1:5102" in caplog.text - assert f"create_listener: True" in caplog.text + assert f"add_listener: True" in caplog.text caplog.clear() - subsystem_del_req = pb2.delete_subsystem_req(subsystem_nqn=subsystem) - ret_subsystem = stubA.delete_subsystem(subsystem_del_req) + subsystem_del_req = pb2.subsystem_delete_req(subsystem_nqn=subsystem) + ret_subsystem = stubA.subsystem_delete(subsystem_del_req) assert ret_subsystem.status == 0 assert f"delete_subsystem {subsystem}: True" in caplog.text assert f"Failure deleting subsystem {subsystem}" not in caplog.text caplog.clear() - ret_subsystem = stubA.create_subsystem(subsystem_add_req) + ret_subsystem = stubA.subsystem_create(subsystem_add_req) assert ret_subsystem.status == 0 assert f"create_subsystem {subsystem}: True" in caplog.text assert f"Failure creating subsystem {subsystem}" not in caplog.text caplog.clear() - listener_ret = stubA.create_listener(listenerA_req) + listener_ret = stubA.listener_create(listenerA_req) assert listener_ret.status == 0 assert f"Received request to create {gwA.host_name} TCP ipv4 listener for {subsystem} at 127.0.0.1:5101" in caplog.text - assert f"create_listener: True" in caplog.text + assert f"add_listener: True" in caplog.text assert f"Failure adding {subsystem} listener at 127.0.0.1:5101" not in caplog.text caplog.clear() - listener_ret = stubB.create_listener(listenerB_req) + listener_ret = stubB.listener_create(listenerB_req) assert listener_ret.status == 0 assert f"Received request to create {gwB.host_name} TCP ipv4 listener for {subsystem} at 127.0.0.1:5102" in caplog.text - assert f"create_listener: True" in caplog.text + assert f"add_listener: True" in caplog.text assert f"Failure adding {subsystem} listener at 127.0.0.1:5102" not in caplog.text