diff --git a/delfin/drivers/netapp/dataontap/constants.py b/delfin/drivers/netapp/dataontap/constants.py index 567ac35de..3feea32bc 100644 --- a/delfin/drivers/netapp/dataontap/constants.py +++ b/delfin/drivers/netapp/dataontap/constants.py @@ -64,7 +64,7 @@ } PATTERN = re.compile('^[-]{3,}') -FLOAT_PATTERN = r"\d\.\d" +FLOAT_PATTERN = r"\d\.\d*" IP_PATTERN = re.compile(r'(([01]{0,1}\d{0,1}\d|2[0-4]\d|25[0-5])\.){3}' r'([01]{0,1}\d{0,1}\d|2[0-4]\d|25[0-5])$') IQN_PATTERN = re.compile('^[i][q][n].') diff --git a/delfin/drivers/netapp/dataontap/netapp_handler.py b/delfin/drivers/netapp/dataontap/netapp_handler.py index 9743f1f4c..db943ae13 100644 --- a/delfin/drivers/netapp/dataontap/netapp_handler.py +++ b/delfin/drivers/netapp/dataontap/netapp_handler.py @@ -137,7 +137,7 @@ def login(self): or 'command not found' in result: raise exception.InvalidIpOrPort() version = self.get_storage_version() - if version >= 9.6: + if version >= 96: self.rest_client.do_call( constant.CLUSTER_PERF_URL, None, 'GET') except Exception as e: @@ -1211,23 +1211,23 @@ def get_storage_version(self): version_list = \ re.findall(constant.FLOAT_PATTERN, storage_version[0]) for ver_info in version_list: - if float(ver_info) >= 9.0: - return float(ver_info) - return 9.0 + if int(ver_info.replace(".", "")) >= 90: + return int(ver_info.replace(".", "")) + return 90 @staticmethod def get_cap_by_version(version, capabilities): - if version >= 9.6: + if version >= 96: capabilities['resource_metrics']['storage'] = \ constant.STORAGE_CAPABILITIES - if version >= 9.7: + if version >= 97: capabilities['resource_metrics']['storagePool'] = \ constant.POOL_CAPABILITIES capabilities['resource_metrics']['port'] = \ constant.PORT_CAPABILITIES capabilities['resource_metrics']['filesystem'] = \ constant.FS_CAPABILITIES - if version >= 9.8: + if version >= 98: capabilities['resource_metrics']['volume'] = \ constant.VOLUME_CAPABILITIES return capabilities @@ -1242,20 +1242,20 @@ def get_capabilities(filters): version_List = \ re.findall( constant.FLOAT_PATTERN, filters.get('firmware_version')) - version = 9.0 + version = 90 for ver_info in version_List: - if float(ver_info) >= 9.0: - version = float(ver_info) + if int(ver_info.replace(".", "")) >= 90: + version = int(ver_info.replace(".", "")) break NetAppHandler.get_cap_by_version(version, capabilities) return capabilities cap_map = {} - for i in range(0, 10): + for i in range(0, 11): capabilities = { 'is_historic': True, 'resource_metrics': {} } - version = float('9.' + str(i)) + version = int('9' + str(i)) NetAppHandler.get_cap_by_version(version, capabilities) cap_map[version] = capabilities return cap_map diff --git a/delfin/tests/unit/drivers/netapp/netapp_ontap/test_netapp.py b/delfin/tests/unit/drivers/netapp/netapp_ontap/test_netapp.py index db6bf7c68..6784299c1 100644 --- a/delfin/tests/unit/drivers/netapp/netapp_ontap/test_netapp.py +++ b/delfin/tests/unit/drivers/netapp/netapp_ontap/test_netapp.py @@ -193,7 +193,7 @@ def test_get_storage_performance(self): def test_get_capabilities_is_None(self): data = self.netapp_client.get_capabilities(context, None) - self.assertEqual(data[9.8]['resource_metrics']['storage'] + self.assertEqual(data[98]['resource_metrics']['storage'] ['throughput']['unit'], 'MB/s') def test_get_capabilities(self):