diff --git a/cinder/tests/unit/volume/drivers/dell_emc/vmax/test_vmax.py b/cinder/tests/unit/volume/drivers/dell_emc/vmax/test_vmax.py index 05db302596d..50e3f076b75 100644 --- a/cinder/tests/unit/volume/drivers/dell_emc/vmax/test_vmax.py +++ b/cinder/tests/unit/volume/drivers/dell_emc/vmax/test_vmax.py @@ -659,6 +659,7 @@ class VMAXCommonData(object): {"symmetrixId": array_herc, "model": "VMAXHERC", "ucode": "5978.1091.1092"}] + version_details = {"version": "V9.0.0.1"} headroom = {"headroom": [{"headroomCapacity": 20348.29}]} @@ -847,6 +848,8 @@ class FakeRequestsSession(object): if job['jobId'] in url: return_object = job break + elif 'version' in url: + return_object = self.data.version_details else: for symm in self.data.symmetrix: if symm['symmetrixId'] in url: @@ -1652,6 +1655,13 @@ class VMAXRestTest(test.TestCase): array_details = self.rest.get_array_serial(self.data.failed_resource) self.assertIsNone(array_details) + def test_get_uni_version(self): + version, major_version = self.rest.get_uni_version() + self.assertEqual('90', major_version) + with mock.patch.object(self.rest, '_get_request', return_value=None): + version, major_version = self.rest.get_uni_version() + self.assertIsNone(major_version) + def test_get_srp_by_name(self): ref_details = self.data.srp_details srp_details = self.rest.get_srp_by_name( diff --git a/cinder/volume/drivers/dell_emc/vmax/rest.py b/cinder/volume/drivers/dell_emc/vmax/rest.py index 965877acb0b..aa21c52d810 100644 --- a/cinder/volume/drivers/dell_emc/vmax/rest.py +++ b/cinder/volume/drivers/dell_emc/vmax/rest.py @@ -430,6 +430,20 @@ class VMAXRest(object): is_next_gen = True return is_next_gen + def get_uni_version(self): + """Get the unisphere version from the server. + + :return: version and major_version(e.g. ("V8.4.0.16", "84")) + """ + version, major_version = None, None + target_uri = "/%s/system/version" % U4V_VERSION + response = self._get_request(target_uri, 'version') + if response and response.get('version'): + version = response['version'] + version_list = version.split('.') + major_version = version_list[0][1] + version_list[1] + return version, major_version + def get_srp_by_name(self, array, srp=None): """Returns the details of a storage pool. @@ -944,8 +958,10 @@ class VMAXRest(object): :returns: volume dict :raises: VolumeBackendAPIException """ + version = self.get_uni_version()[1] volume_dict = self.get_resource( - array, SLOPROVISIONING, 'volume', resource_name=device_id) + array, SLOPROVISIONING, 'volume', resource_name=device_id, + version=version) if not volume_dict: exception_message = (_("Volume %(deviceID)s not found.") % {'deviceID': device_id})