Merge "PowerMax Driver - Check for missing port group"

This commit is contained in:
Zuul 2021-03-24 19:23:32 +00:00 committed by Gerrit Code Review
commit 1a29a2ff7c
3 changed files with 19 additions and 5 deletions

View File

@ -1781,6 +1781,14 @@ class PowerMaxCommonTest(test.TestCase):
self.data.array, self.data.port_group_name_i)
self.assertEqual(ref_ip_iqn, ip_iqn_list)
@mock.patch.object(rest.PowerMaxRest, 'get_portgroup',
return_value=None)
def test_find_ip_and_iqns_no_port_group(self, mock_port):
self.assertRaises(
exception.VolumeBackendAPIException,
self.common._find_ip_and_iqns, self.data.array,
self.data.port_group_name_i)
def test_create_replica_snap_name(self):
array = self.data.array
clone_volume = self.data.test_clone_volume

View File

@ -947,8 +947,10 @@ class PowerMaxRestTest(test.TestCase):
pg_name = self.data.port_group_name_f
with mock.patch.object(self.rest, 'get_portgroup',
return_value=None):
port_ids = self.rest.get_port_ids(array, pg_name)
self.assertEqual([], port_ids)
with self.assertRaisesRegex(
exception.VolumeBackendAPIException,
'Cannot find port group OS-fibre-PG.'):
self.rest.get_port_ids(array, pg_name)
def test_get_port(self):
array = self.data.array

View File

@ -1692,20 +1692,24 @@ class PowerMaxRest(object):
return self.get_resource(
array, SLOPROVISIONING, 'portgroup', resource_name=portgroup)
def get_port_ids(self, array, portgroup):
def get_port_ids(self, array, port_group_name):
"""Get a list of port identifiers from a port group.
:param array: the array serial number
:param portgroup: the name of the portgroup
:param port_group_name: the name of the portgroup
:returns: list of port ids, e.g. ['FA-3D:35', 'FA-4D:32']
"""
portlist = []
portgroup_info = self.get_portgroup(array, portgroup)
portgroup_info = self.get_portgroup(array, port_group_name)
if portgroup_info:
port_key = portgroup_info["symmetrixPortKey"]
for key in port_key:
port = "%s:%s" % (key['directorId'], key['portId'])
portlist.append(port)
else:
exception_message = (_("Cannot find port group %(pg)s.")
% {'pg': port_group_name})
raise exception.VolumeBackendAPIException(exception_message)
return portlist
def get_port(self, array, port_id):