diff --git a/delfin/drivers/dell_emc/vplex/vplex_stor.py b/delfin/drivers/dell_emc/vplex/vplex_stor.py index ba3f49297..15a718af6 100644 --- a/delfin/drivers/dell_emc/vplex/vplex_stor.py +++ b/delfin/drivers/dell_emc/vplex/vplex_stor.py @@ -481,7 +481,6 @@ def get_hardware_port_info(self, nest_map, first_key, second_key): role = '' port_status = '' operational_status = '' - if nest_map: second_map = nest_map.get(first_key) if second_map: @@ -501,8 +500,10 @@ def analyse_hardware_port(resp, hardware_port_map): port_list = VplexStorageDriver.get_context_list(resp) if port_list: for port in port_list: - port_name = port.get("attributes").get("target-port") - hardware_port_map[port_name] = port + port_attr = port.get("attributes") + if port_attr: + port_name = port_attr.get("target-port") + hardware_port_map[port_name] = port @staticmethod def analyse_port_type(protocols): @@ -531,13 +532,20 @@ def analyse_port_health_status(status): get(status, constants.PortHealthStatus.UNKNOWN) @staticmethod - def analyse_speed(speed): - speed_value = None - if speed: - match_obj = re.search(r'([1-9]\d*\.?\d*)|(0\.\d*[1-9])', speed) + def analyse_speed(speed_value): + speed = None + if speed_value: + match_obj = re.search(r'([1-9]\d*\.?\d*)|(0\.\d*[1-9])', + speed_value) if match_obj: - speed_value = int(match_obj.group(0)) * units.G - return speed_value + speed = int(match_obj.group(0)) + if 'Gbit' in speed_value: + speed = speed * units.G + elif 'Mbit' in speed_value: + speed = speed * units.M + elif 'Kbit' in speed_value: + speed = speed * units.k + return speed @staticmethod