Merge "Fix nits in nvmeof connector"

This commit is contained in:
Zuul 2022-08-11 12:29:53 +00:00 committed by Gerrit Code Review
commit 3102519df8
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'
@ -244,7 +244,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)
@ -315,9 +315,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.
@ -382,7 +382,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]]]] = [
@ -746,7 +746,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')