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
This commit is contained in:
Rajat Dhasmana 2022-07-25 17:51:48 +00:00
parent 4c21b40df2
commit ec7246e17d
2 changed files with 9 additions and 9 deletions

View File

@ -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

View File

@ -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')