From ec7246e17de2b2bf67ba074c61c168b0a8d1f2a9 Mon Sep 17 00:00:00 2001 From: Rajat Dhasmana Date: Mon, 25 Jul 2022 17:51:48 +0000 Subject: [PATCH] Fix nits in nvmeof connector There were some review comments for minor changes on patch I6c2a952f7e286f3e3890e3f2fcb2fdd1063f0c17. Since the patch is merged, this patch addresses those comments. Change-Id: I7084da4abb0debedc35ff6248ff38d3bcc4000a4 --- os_brick/initiator/connectors/nvmeof.py | 14 +++++++------- os_brick/tests/initiator/connectors/test_nvmeof.py | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/os_brick/initiator/connectors/nvmeof.py b/os_brick/initiator/connectors/nvmeof.py index 0366fe53b..10939a99c 100644 --- a/os_brick/initiator/connectors/nvmeof.py +++ b/os_brick/initiator/connectors/nvmeof.py @@ -56,7 +56,7 @@ TRANSPORT = 'transport_type' PORTAL = 'target_portal' PORT = 'target_port' -# These were only present in the old connection info, but now we'll allowed +# These were only present in the old connection info, but now we'll allow # both in the old format, the new format, and as part of a volume_replicas # element. NGUID = 'volume_nguid' @@ -230,7 +230,7 @@ class Portal(object): LOG.debug('Device found at %s, using %s', path, result) return result - LOG.debug('Block %s is not the one we look for (%s != %s)', + LOG.debug('Block %s is not the one we are looking for (%s != %s)', path, prop_value, value) LOG.debug('No device Found on controller %s', self.controller) @@ -273,9 +273,9 @@ class Target(object): source_conn_props: 'NVMeOFConnProps', nqn: str, portals: List[str], - uuid: str = None, - nguid: str = None, - ns_id: str = None, + uuid: Optional[str] = None, + nguid: Optional[str] = None, + ns_id: Optional[str] = None, host_nqn=None, find_controllers=False) -> None: """Initialize instance. @@ -340,7 +340,7 @@ class Target(object): hostnqn: str = self.host_nqn or utils.get_host_nqn() # List of portal addresses and transports for this target - # Unlike "nvme list-subsys -o json" sysfs addr is separated by a coma + # Unlike "nvme list-subsys -o json" sysfs addr is separated by a comma sysfs_portals: List[Tuple[Optional[str], Optional[str], Optional[Union[str, utils.Anything]]]] = [ @@ -704,7 +704,7 @@ class NVMeOFConnector(base.BaseLinuxConnector): @classmethod def nvme_present(cls: type) -> bool: - """Check if the nvme command is present.""" + """Check if the nvme CLI is present.""" try: priv_rootwrap.custom_execute('nvme', 'version') return True diff --git a/os_brick/tests/initiator/connectors/test_nvmeof.py b/os_brick/tests/initiator/connectors/test_nvmeof.py index 1b2ba1ae4..d74353c6d 100644 --- a/os_brick/tests/initiator/connectors/test_nvmeof.py +++ b/os_brick/tests/initiator/connectors/test_nvmeof.py @@ -188,11 +188,11 @@ class PortalTestCase(test_base.TestCase): @mock.patch.object(nvmeof.Portal, 'get_device_by_property') def test_get_device_by_ns_id(self, mock_property): - """nguid takes priority over ns_id if no UUID.""" + """ns_id takes priority if no UUID and nguid are present.""" mock_property.return_value = 'result' self.target.uuid = None self.target.nguid = None - self.target.ns_id = 'ns_id_value' # will be ignored + self.target.ns_id = 'ns_id_value' res = self.portal.get_device() self.assertEqual('result', res) mock_property.assert_called_once_with('nsid', 'ns_id_value')