Ejemplo n.º 1
0
def test_fan_drawer_set_status_led():
    fan_drawer = RealDrawer(0, DEVICE_DATA['x86_64-mlnx_msn2700-r0']['fans'])
    with pytest.raises(Exception):
        fan_drawer.set_status_led(None, 'Invalid color')

    with pytest.raises(Exception):
        fan_drawer.set_status_led(None, Fan.STATUS_LED_COLOR_RED)

    fan1 = Fan(0, fan_drawer)
    fan2 = Fan(1, fan_drawer)
    fan_list = fan_drawer.get_all_fans()
    fan_list.append(fan1)
    fan_list.append(fan2)

    FanLed.set_status = MagicMock()

    fan1.set_status_led(Fan.STATUS_LED_COLOR_RED)
    fan_drawer.set_status_led(Fan.STATUS_LED_COLOR_RED)
    FanLed.set_status.assert_called_with(Fan.STATUS_LED_COLOR_RED)

    fan2.set_status_led(Fan.STATUS_LED_COLOR_GREEN)
    fan_drawer.set_status_led(Fan.STATUS_LED_COLOR_GREEN)
    FanLed.set_status.assert_called_with(Fan.STATUS_LED_COLOR_RED)

    fan1.set_status_led(Fan.STATUS_LED_COLOR_GREEN)
    fan_drawer.set_status_led(Fan.STATUS_LED_COLOR_GREEN)
    FanLed.set_status.assert_called_with(Fan.STATUS_LED_COLOR_GREEN)

    fan1.set_status_led(Fan.STATUS_LED_COLOR_RED)
    fan_drawer.set_status_led(Fan.STATUS_LED_COLOR_RED)
    FanLed.set_status.assert_called_with(Fan.STATUS_LED_COLOR_RED)
Ejemplo n.º 2
0
    def initialize_fan(self):
        from sonic_platform.fan import Fan
        from sonic_platform.fan import FAN_PATH
        self.fan_module = Fan
        self.fan_path = FAN_PATH
        # Initialize FAN list
        multi_rotor_in_drawer = False
        num_of_fan, num_of_drawer = self._extract_num_of_fans_and_fan_drawers()
        multi_rotor_in_drawer = num_of_fan > num_of_drawer

        # Fan's direction isn't supported on spectrum 1 devices for now
        mst_dev_list = glob(MST_DEVICE_NAME_PATTERN)
        if not mst_dev_list:
            raise RuntimeError("Can't get chip type due to {} not found".format(MST_DEVICE_NAME_PATTERN))
        m = re.search(MST_DEVICE_RE_PATTERN, mst_dev_list[0])
        if m.group(1) == SPECTRUM1_CHIP_ID:
            has_fan_dir = False
        else:
            has_fan_dir = True

        for index in range(num_of_fan):
            if multi_rotor_in_drawer:
                fan = Fan(has_fan_dir, index, index/2, False, self.sku_name)
            else:
                fan = Fan(has_fan_dir, index, index, False, self.sku_name)
            self._fan_list.append(fan)
Ejemplo n.º 3
0
    def __init__(self):
        # Initialize EEPROM and watchdog
        self._eeprom = Eeprom()
        self._watchdog = Watchdog()

        #Initialize FAN object
        for index in range(0, NUM_FAN_TRAY):
            fan = Fan(index)
            self._fan_list.append(fan)

        # Initialize PSU and PSU_fan object
        for index in range(0, NUM_PSU):
            psu = Psu(index)
            self._psu_list.append(psu)
            fan = Fan(index, True)
            self._fan_list.append(fan)

        # Initialize SFP/QSFP object
        for index in range(0, NUM_PORTS):
            if index < QSFP_START:
                sfp = Sfp(index)
            else:
                sfp = QSfp(index)
            self._sfp_list.append(sfp)

        # Initialize Thermal object
        for index in range(0, NUM_THERMAL):
            thermal = Thermal(index)
            self._thermal_list.append(thermal)

        # Initialize Component object
        for index in range(0, NUM_COMPONENT):
            component = Component(index)
            self._component_list.append(component)
Ejemplo n.º 4
0
    def __init__(self):
        super(Chassis, self).__init__()

        # Initialize SKU name
        self.sku_name = self._get_sku_name()

        # Initialize PSU list
        for index in range(MLNX_NUM_PSU):
            psu = Psu(index, self.sku_name)
            self._psu_list.append(psu)

        # Initialize watchdog
        self._watchdog = get_watchdog()

        # Initialize FAN list
        multi_rotor_in_drawer = False
        num_of_fan, num_of_drawer = self._extract_num_of_fans_and_fan_drawers()
        multi_rotor_in_drawer = num_of_fan > num_of_drawer

        for index in range(num_of_fan):
            if multi_rotor_in_drawer:
                fan = Fan(index, index / 2)
            else:
                fan = Fan(index, index)
            self._fan_list.append(fan)

        # Initialize SFP list
        port_position_tuple = self._get_port_position_tuple_by_sku_name()
        self.PORT_START = port_position_tuple[0]
        self.QSFP_PORT_START = port_position_tuple[1]
        self.PORT_END = port_position_tuple[2]
        self.PORTS_IN_BLOCK = port_position_tuple[3]

        for index in range(self.PORT_START, self.PORT_END + 1):
            if index in range(self.QSFP_PORT_START, self.PORTS_IN_BLOCK + 1):
                sfp_module = SFP(index, 'QSFP')
            else:
                sfp_module = SFP(index, 'SFP')
            self._sfp_list.append(sfp_module)

        # Initialize thermals
        initialize_thermals(self.sku_name, self._thermal_list, self._psu_list)

        # Initialize EEPROM
        self.eeprom = Eeprom()

        # Initialize component list
        self._component_name_list.append(COMPONENT_BIOS)
        self._component_name_list.append(COMPONENT_FIRMWARE)
        self._component_name_list.append(COMPONENT_CPLD1)
        self._component_name_list.append(COMPONENT_CPLD2)

        # Initialize sfp-change-listening stuff
        self._init_sfp_change_event()
Ejemplo n.º 5
0
    def __init__(self):
        ChassisBase.__init__(self)

        # Initialize EEPROM
        self._eeprom = Eeprom()
        self._eeprom_data = self._eeprom.get_eeprom_data()

        # Initialize FAN
        for index in range(self.__num_of_fans):
            fan = Fan(index)
            self._fan_list.append(fan)

        # Initialize PSU
        for index in range(self.__num_of_psus):
            psu = Psu(index)
            self._psu_list.append(psu)

        # Initialize SFP
        for index in range(self.__num_of_sfps):
            sfp = QSfp(index)  #only qsfp on platform D6332
            self._sfp_list.append(sfp)

        # Initialize THERMAL
        for index in range(self.__num_of_thermals):
            thermal = Thermal(index)
            self._thermal_list.append(thermal)

        # Initialize COMPONENT
        for index in range(self.__num_of_components):
            component = Component(index)
            self._component_list.append(component)

        # Initialize WATCHDOG
        self._watchdog = Watchdog()
Ejemplo n.º 6
0
 def __init__(self, psu_index):
     PsuBase.__init__(self)
     self.index = psu_index
     for fan_index in range(0, PSU_NUM_FAN[self.index]):
         fan = Fan(fan_index, 0, is_psu_fan=True, psu_index=self.index)
         self._fan_list.append(fan)
     self._api_helper = APIHelper()
Ejemplo n.º 7
0
    def __init__(self):
        ChassisBase.__init__(self)
        self.__num_of_fans = 8
        self.__num_of_psus = 2
        self.__num_of_sfps = 56
        self.__start_of_qsfp = 48
        self.__num_of_thermals = 5

        # Initialize EEPROM
        self._eeprom = Eeprom()

        # Initialize FAN
        for index in range(1, self.__num_of_fans + 1):
            fan = Fan(index, False, 0)
            self._fan_list.append(fan)

        # Initialize PSU
        for index in range(1, self.__num_of_psus + 1):
            psu = Psu(index)
            self._psu_list.append(psu)

        # Initialize SFP
        for index in range(0, self.__num_of_sfps):
            if index < self.__start_of_qsfp:
                sfp = Sfp(index)
            else:
                sfp = QSfp(index)
            self._sfp_list.append(sfp)

        # Initialize THERMAL
        for index in range(0, self.__num_of_thermals):
            thermal = Thermal(index)
            self._thermal_list.append(thermal)
Ejemplo n.º 8
0
    def __init__(self):

        ChassisBase.__init__(self)
        # Initialize EEPROM
        self._eeprom = Eeprom()
        for i in range(MAX_S6100_MODULE):
            module = Module(i)
            self._module_list.append(module)
            self._sfp_list.extend(module._sfp_list)

        for i in range(MAX_S6100_FAN):
            fan = Fan(i)
            self._fan_list.append(fan)

        for i in range(MAX_S6100_PSU):
            psu = Psu(i)
            self._psu_list.append(psu)

        for i in range(MAX_S6100_THERMAL):
            thermal = Thermal(i)
            self._thermal_list.append(thermal)

        for i in range(MAX_S6100_COMPONENT):
            component = Component(i)
            self._component_list.append(component)

        self._watchdog = Watchdog()
        self._transceiver_presence = self._get_transceiver_presence()
Ejemplo n.º 9
0
    def __init__(self):
        super(Chassis, self).__init__()

        for fantray_index in range(0, NUM_FAN_TRAY):
            for fan_index in range(0, NUM_FAN):
                fan = Fan(fantray_index, fan_index)
                self._fan_list.append(fan)
        for index in range(0, NUM_PSU):
            psu = Psu(index)
            self._psu_list.append(psu)
        for index in range(0, NUM_THERMAL):
            thermal = Thermal(index)
            self._thermal_list.append(thermal)

        self.PORT_START = SFP_PORT_START
        self.QSFP_PORT_START = QSFP_PORT_START
        self.PORT_END = QSFP_PORT_END
        for index in range(0, NUM_SFP):
            if index in range(self.QSFP_PORT_START, self.QSPORT_END + 1):
                sfp_module = Sfp(index, 'QSFP')
            else:
                sfp_module = Sfp(index, 'SFP')
            self._sfp_list.append(sfp_module)
        self._component_name_list = COMPONENT_NAME_LIST
        self._watchdog = Watchdog()
        self._eeprom = Tlv()
        logger.log_info("Chassis loaded successfully")
Ejemplo n.º 10
0
    def __init__(self):

        ChassisBase.__init__(self)
        # Initialize EEPROM
        self.sys_eeprom = Eeprom()
        for i in range(MAX_S6100_FAN):
            fan = Fan(i)
            self._fan_list.append(fan)

        for i in range(MAX_S6100_PSU):
            psu = Psu(i)
            self._psu_list.append(psu)

        self._populate_port_i2c_mapping()

        # sfp.py will read eeprom contents and retrive the eeprom data.
        # It will also provide support sfp controls like reset and setting
        # low power mode.
        # We pass the eeprom path and sfp control path from chassis.py
        # So that sfp.py implementation can be generic to all platforms
        eeprom_base = "/sys/class/i2c-adapter/i2c-{0}/i2c-{1}/{1}-0050/eeprom"
        sfp_ctrl_base = "/sys/class/i2c-adapter/i2c-{0}/{0}-003e/"
        for index in range(0, self.PORTS_IN_BLOCK):
            eeprom_path = eeprom_base.format(self.EEPROM_I2C_MAPPING[index][0],
                                             self.EEPROM_I2C_MAPPING[index][1])
            sfp_control = sfp_ctrl_base.format(self.PORT_I2C_MAPPING[index])
            sfp_node = Sfp(index, 'QSFP', eeprom_path, sfp_control, index)
            self._sfp_list.append(sfp_node)
Ejemplo n.º 11
0
    def __init__(self):

        ChassisBase.__init__(self)
        # Initialize EEPROM
        self.sys_eeprom = Eeprom()
        for i in range(MAX_S6100_MODULE):
            module = Module(i)
            self._module_list.append(module)

        for i in range(MAX_S6100_FAN):
            fan = Fan(i)
            self._fan_list.append(fan)

        for i in range(MAX_S6100_PSU):
            psu = Psu(i)
            self._psu_list.append(psu)

        for i in range(MAX_S6100_THERMAL):
            thermal = Thermal(i)
            self._thermal_list.append(thermal)

        # Initialize component list
        self._component_name_list.append(COMPONENT_BIOS)
        self._component_name_list.append(SWITCH_CPLD)
        self._component_name_list.append(SMF_FPGA)
Ejemplo n.º 12
0
    def __init__(self, psu_index):
        # PSU is 1-based in DellEMC platforms
        self.index = psu_index + 1
        self.psu_presence_reg = "psu{}_prs".format(psu_index)
        self.psu_status_reg = "powersupply_status"
        self.is_driver_initialized = False

        if self.index == 1:
            ltc_dir = self.I2C_DIR + "i2c-11/11-0042/hwmon/"
        else:
            ltc_dir = self.I2C_DIR + "i2c-11/11-0040/hwmon/"

        try:
            hwmon_node = os.listdir(ltc_dir)[0]
        except OSError:
            hwmon_node = "hwmon*"
        else:
            self.is_driver_initialized = True

        self.HWMON_DIR = ltc_dir + hwmon_node + '/'

        self.psu_voltage_reg = self.HWMON_DIR + "in1_input"
        self.psu_current_reg = self.HWMON_DIR + "curr1_input"
        self.psu_power_reg = self.HWMON_DIR + "power1_input"

        self.eeprom = Eeprom(is_psu=True, psu_index=self.index)

        # Overriding _fan_list class variable defined in PsuBase, to
        # make it unique per Psu object
        self._fan_list = []

        self._fan_list.append(Fan(self.index, psu_fan=True, dependency=self))
Ejemplo n.º 13
0
    def __init__(self):
        PORT_START = 0
        PORT_END = 31
        PORTS_IN_BLOCK = (PORT_END + 1)

        # sfp.py will read eeprom contents and retrive the eeprom data.
        # It will also provide support sfp controls like reset and setting
        # low power mode.
        # We pass the eeprom path and sfp control path from chassis.py
        # So that sfp.py implementation can be generic to all platforms
        eeprom_base = "/sys/class/i2c-adapter/i2c-{0}/i2c-{1}/{1}-0050/eeprom"
        sfp_ctrl_base = "/sys/class/i2c-adapter/i2c-{0}/{0}-003e/"
        for index in range(0, PORTS_IN_BLOCK):
            eeprom_path = eeprom_base.format(self.EEPROM_I2C_MAPPING[index][0],
                                             self.EEPROM_I2C_MAPPING[index][1])
            sfp_control = sfp_ctrl_base.format(self.PORT_I2C_MAPPING[index][0])
            sfp_node = Sfp(index, 'QSFP', eeprom_path, sfp_control,
                           self.PORT_I2C_MAPPING[index][1])
            self._sfp_list.append(sfp_node)

        ChassisBase.__init__(self)
        # Initialize EEPROM
        self.sys_eeprom = Eeprom()
        for i in range(MAX_Z9100_FANTRAY):
            for j in range(MAX_Z9100_FAN):
                fan = Fan(i, j)
                self._fan_list.append(fan)

        # Initialize component list
        self._component_name_list.append(COMPONENT_BIOS)
        self._component_name_list.append(SWITCH_CPLD1)
        self._component_name_list.append(SWITCH_CPLD2)
        self._component_name_list.append(SWITCH_CPLD3)
        self._component_name_list.append(SWITCH_CPLD4)
        self._component_name_list.append(SMF_FPGA)
Ejemplo n.º 14
0
def test_get_absence_fan_direction():
    fan_drawer = RealDrawer(0, DEVICE_DATA['x86_64-mlnx_msn2700-r0']['fans'])
    fan = Fan(0, fan_drawer)
    fan_drawer.get_presence = MagicMock(return_value=False)

    assert not fan.is_psu_fan
    assert fan.get_direction() == Fan.FAN_DIRECTION_NOT_APPLICABLE
Ejemplo n.º 15
0
 def __initialize_fan(self):
     from sonic_platform.fan import Fan
     self._fan_list.append(
         Fan(NUM_FAN_TRAY + self.index,
             is_psu_fan=True,
             psu_index=self.index))
     self._thermal_list.append(Thermal(is_psu=True, psu_index=self.index))
Ejemplo n.º 16
0
 def test_system_fan_set_speed(self, mock_write_file):
     fan_drawer = RealDrawer(0)
     fan = Fan(2, fan_drawer, 1)
     fan.set_speed(60)
     mock_write_file.assert_called_with(fan.fan_speed_set_path,
                                        153,
                                        raise_exception=True)
Ejemplo n.º 17
0
    def __init__(self):
        ChassisBase.__init__(self)
        # sfp.py will read eeprom contents and retrive the eeprom data.
        # We pass the eeprom path from chassis.py
        self.PORT_START = 1
        self.PORT_END = 34 
        self.PORTS_IN_BLOCK = (self.PORT_END + 1)
        _sfp_port = range(33, self.PORT_END + 1)
        eeprom_base = "/sys/class/i2c-adapter/i2c-{0}/{0}-0050/eeprom"

        for index in range(self.PORT_START, self.PORTS_IN_BLOCK):
            port_num = index + 1
            eeprom_path = eeprom_base.format(port_num)
            if index not in _sfp_port:
                sfp_node = Sfp(index, 'QSFP', eeprom_path)
            else:
                sfp_node = Sfp(index, 'SFP', eeprom_path)
            self._sfp_list.append(sfp_node)

        self._eeprom = Eeprom()
        self._watchdog = Watchdog()
        self._num_sfps = self.PORT_END
        self._num_fans = MAX_S5232F_FANTRAY * MAX_S5232F_FAN
        self._fan_list = [Fan(i, j) for i in range(MAX_S5232F_FANTRAY) \
                            for j in range(MAX_S5232F_FAN)]
        self._psu_list = [Psu(i) for i in range(MAX_S5232F_PSU)]
        self._thermal_list = [Thermal(i) for i in range(MAX_S5232F_THERMAL)]
        self._component_list = [Component(i) for i in range(MAX_S5232F_COMPONENT)]

        for port_num in range(self.PORT_START, self.PORTS_IN_BLOCK):
            # sfp get uses zero-indexing, but port numbers start from 1
            presence = self.get_sfp(port_num).get_presence()
            self._global_port_pres_dict[port_num] = '1' if presence else '0'
Ejemplo n.º 18
0
    def __init__(self, psu_index):
        PsuBase.__init__(self)
        # PSU is 1-based in DellEMC platforms
        self.index = psu_index + 1
        self.psu_presence_reg = "psu{}_prs".format(psu_index)
        self.psu_status_reg = "powersupply_status"
        self.is_driver_initialized = False

        if self.index == 1:
            ltc_dir = self.I2C_DIR + "i2c-11/11-0042/hwmon/"
        else:
            ltc_dir = self.I2C_DIR + "i2c-11/11-0040/hwmon/"

        try:
            hwmon_node = os.listdir(ltc_dir)[0]
        except OSError:
            hwmon_node = "hwmon*"
        else:
            self.is_driver_initialized = True

        self.HWMON_DIR = ltc_dir + hwmon_node + '/'

        self.psu_voltage_reg = self.HWMON_DIR + "in1_input"
        self.psu_current_reg = self.HWMON_DIR + "curr1_input"
        self.psu_power_reg = self.HWMON_DIR + "power1_input"

        self.eeprom = Eeprom(is_psu=True, psu_index=self.index)

        self._fan_list.append(Fan(psu_index=self.index, psu_fan=True, dependency=self))
        for i in range(1, MAX_S6000_THERMALS_PER_PSU+1):
            self._thermal_list.append(Thermal(psu_index=self.index, thermal_index=i,
                                              psu_thermal=True, dependency=self))
Ejemplo n.º 19
0
    def __init__(self):
        # Initialize SFP list
        self.PORT_START = 0
        self.PORT_END = 31
        EEPROM_OFFSET = 20
        PORTS_IN_BLOCK = (self.PORT_END + 1)

        # sfp.py will read eeprom contents and retrive the eeprom data.
        # It will also provide support sfp controls like reset and setting
        # low power mode.
        # We pass the eeprom path and sfp control path from chassis.py
        # So that sfp.py implementation can be generic to all platforms
        eeprom_base = "/sys/class/i2c-adapter/i2c-{0}/{0}-0050/eeprom"
        self.sfp_control = "/sys/devices/platform/dell-s6000-cpld.0/"

        for index in range(0, PORTS_IN_BLOCK):
            eeprom_path = eeprom_base.format(index + EEPROM_OFFSET)
            sfp_node = Sfp(index, 'QSFP', eeprom_path, self.sfp_control, index)
            self._sfp_list.append(sfp_node)

        # Get Transceiver status
        self.modprs_register = self._get_transceiver_status()

        self.sys_eeprom = Eeprom()
        for i in range(MAX_S6000_FAN):
            fan = Fan(i)
            self._fan_list.append(fan)

        # Initialize component list
        self._component_name_list.append(COMPONENT_BIOS)
        self._component_name_list.append(COMPONENT_CPLD1)
        self._component_name_list.append(COMPONENT_CPLD2)
        self._component_name_list.append(COMPONENT_CPLD3)
Ejemplo n.º 20
0
    def __init__(self, index):
        self.__index = index
        self.__psu_presence_attr = PSU_SYS_FS + "psu{}".format(self.__index +
                                                               1)
        self.__psu_voltage_out_attr = PSU_SYS_FS + \
            "psoc_psu{}_vout".format(self.__index + 1)
        self.__psu_current_out_attr = PSU_SYS_FS + \
            "psoc_psu{}_iout".format(self.__index + 1)
        self.__psu_power_out_attr = PSU_SYS_FS + \
            "psoc_psu{}_pout".format(self.__index + 1)
        self.__psu_model_attr = PSU_SYS_FS + \
            "psoc_psu{}_vendor".format(self.__index + 1)
        self.__psu_serial_attr = PSU_SYS_FS + \
            "psoc_psu{}_serial".format(self.__index + 1)

        # Get the start index of fan list
        self.__fan_psu_start_index = self.__index + FanConst(
        ).FAN_PSU_START_INDEX

        # Overriding _fan_list class variable defined in PsuBase, to make it unique per Psu object
        self._fan_list = []

        # Initialize FAN
        for x in range(self.__fan_psu_start_index,
                       self.__fan_psu_start_index + self.__num_of_fans):
            fan = Fan(x)
            self._fan_list.append(fan)
Ejemplo n.º 21
0
    def _get_fantray_list(self):
        if not self.is_cpm:
            return []

        channel, stub = nokia_common.channel_setup(nokia_common.NOKIA_GRPC_FAN_SERVICE)
        if not channel or not stub:
            return
        ret, response = nokia_common.try_grpc(stub.GetFanNum,
                                              platform_ndk_pb2.ReqFanTrayOpsPb())
        nokia_common.channel_shutdown(channel)

        if ret is False:
            return

        self.num_fantrays = response.fan_nums.num_fantrays

        fan_index = 0
        for drawer_index in range(self.num_fantrays):
            fan_drawer = FanDrawer(drawer_index)
            fan_drawer.set_maximum_consumed_power(self.fantray_power)
            fan = Fan(fan_index, drawer_index, False, self.fan_stub)
            fan_drawer._fan_list.append(fan)
            fan_index = fan_index + 1
            self._fan_drawer_list.append(fan_drawer)

        return self._fan_drawer_list
Ejemplo n.º 22
0
 def __initialize_fan(self):
     from sonic_platform.fan import Fan
     for fan_index in range(0, PSU_NUM_FAN[self.index]):
         fan = Fan(fan_index, 0, is_psu_fan=True, psu_index=self.index)
         self._fan_list.append(fan)
     
     self._thermal_list.append(Thermal(is_psu=True, psu_index=self.index))
Ejemplo n.º 23
0
    def __init__(self, fantray_index):

        FanDrawerBase.__init__(self)
        # FanTray is 1-based in DellEMC platforms
        self.fantrayindex = fantray_index + 1
        for i in range(Z9332F_FANS_PER_FANTRAY):
            self._fan_list.append(Fan(fantray_index, i))
Ejemplo n.º 24
0
    def __init__(self):
        ChassisBase.__init__(self)
        self.config_data = {}
        for fant_index in range(0, NUM_FAN_TRAY):
            for fan_index in range(0, NUM_FAN):
                fan = Fan(fant_index, fan_index)
                self._fan_list.append(fan)
        for index in range(0, NUM_PSU):
            psu = Psu(index)
            self._psu_list.append(psu)
        for index in range(0, NUM_THERMAL):
            thermal = Thermal(index)
            self._thermal_list.append(thermal)
        # sfp index start from 1
        self._sfp_list.append(None)
        for index in range(1, NUM_SFP + 1):
            sfp = Sfp(index)
            self._sfp_list.append(sfp)
        for index in range(0, NUM_COMPONENT):
            component = Component(index)
            self._component_list.append(component)
        self._reboot_cause_path = HOST_REBOOT_CAUSE_PATH if self.__is_host(
        ) else PMON_REBOOT_CAUSE_PATH

        self._eeprom = Tlv()
Ejemplo n.º 25
0
    def initialize_fan(self):
        from sonic_platform.fan import Fan
        from sonic_platform.fan import FAN_PATH
        self.fan_module = Fan
        self.fan_path = FAN_PATH
        # Initialize FAN list
        multi_rotor_in_drawer = False
        num_of_fan, num_of_drawer = self._extract_num_of_fans_and_fan_drawers()
        multi_rotor_in_drawer = num_of_fan > num_of_drawer

        for index in range(num_of_fan):
            if multi_rotor_in_drawer:
                fan = Fan(index, index/2)
            else:
                fan = Fan(index, index)
            self._fan_list.append(fan)
Ejemplo n.º 26
0
    def __init__(self, index):
        self.__index = index
        psu_id = self.__index + 1

        self.__psu_presence_attr = "{}/i2c-inv_cpld/psu{}".format(
            Common.I2C_PREFIX, psu_id)
        self.__psu_voltage_out_attr = "{}/psu{}/in2_input".format(
            Common.INFO_PREFIX, psu_id)
        self.__psu_current_out_attr = "{}/psu{}/curr2_input".format(
            Common.INFO_PREFIX, psu_id)
        self.__psu_power_out_attr = "{}/psu{}/power2_input".format(
            Common.INFO_PREFIX, psu_id)

        # Get the start index of fan list
        self.__fan_psu_start_index = self.__index + FanConst(
        ).PSU_FAN_START_INDEX

        # Overriding _fan_list class variable defined in PsuBase, to make it unique per Psu object
        self._fan_list = []

        # Initialize FAN
        for x in range(self.__fan_psu_start_index,
                       self.__fan_psu_start_index + self.__num_of_fans):
            fan = Fan(x)
            self._fan_list.append(fan)
Ejemplo n.º 27
0
    def __init__(self):
        self._sfp_list = []

        ChassisBase.__init__(self)
        for index in range(0, NUM_THERMAL):
            thermal = Thermal(index)
            self._thermal_list.append(thermal)
        self.fanled = FanLed()
        for index in range(0, NUM_FANDRAWER):
            fan_drawer = FanDrawer(index)
            for i in range(0, NUM_FANSPERDRAWER):
                fan_index = NUM_FANSPERDRAWER * index + i
                fan = Fan(fan_index)
                fan.fanled = self.fanled
                fan_drawer._fan_list.append(fan)
                self._fan_list.append(fan)
                self.fanled._fan_list.append(fan)
            self._fan_drawer_list.append(fan_drawer)
        self.fanled.update_status()
        self.psuled = PsuLed()
        for index in range(0, NUM_PSU):
            psu = Psu(index)
            psu.psuled = self.psuled
            self._psu_list.append(psu)
            self.psuled._psu_list.append(psu)
        self.psuled.update_status()
        for index in range(0, NUM_SFP):
            if (index < 32):
                sfp = Sfp(index, 'QSFP')
            else:
                sfp = Sfp(index, 'SFP')
            self._sfp_list.append(sfp)
        for index in range(0, NUM_COMPONENT):
            component = Component(index)
            self._component_list.append(component)
Ejemplo n.º 28
0
    def __init__(self, psu_index):
        PsuBase.__init__(self)
        # PSU is 1-based in DellEMC platforms
        self.index = psu_index + 1
        self.state_sensor = IpmiSensor(
            self.SENSOR_MAPPING[self.index]["State"], is_discrete=True)
        self.voltage_sensor = IpmiSensor(
            self.SENSOR_MAPPING[self.index]["Voltage"])
        self.current_sensor = IpmiSensor(
            self.SENSOR_MAPPING[self.index]["Current"])
        self.power_sensor = IpmiSensor(
            self.SENSOR_MAPPING[self.index]["Power"])
        self.input_voltage_sensor = IpmiSensor(
            self.SENSOR_MAPPING[self.index]["InVoltage"])
        self.input_current_sensor = IpmiSensor(
            self.SENSOR_MAPPING[self.index]["InCurrent"])
        self.input_power_sensor = IpmiSensor(
            self.SENSOR_MAPPING[self.index]["InPower"])
        self.temp_sensor = IpmiSensor(
            self.SENSOR_MAPPING[self.index]["Temperature"])
        self.psu_type_offset = PSU_TYPE_OFFSET
        self.fru = IpmiFru(self.FRU_MAPPING[self.index])

        self._fan_list.append(
            Fan(fan_index=self.index, psu_fan=True, dependency=self))
Ejemplo n.º 29
0
    def test_system_fan_basic(self):
        fan_drawer = RealDrawer(0)
        fan = Fan(2, fan_drawer, 1)
        assert fan.get_position_in_parent() == 1
        assert fan.is_replaceable() is False
        assert fan.get_speed_tolerance() == 50
        assert fan.get_name() == 'fan3'

        mock_sysfs_content = {
            fan.fan_speed_get_path: 50,
            fan.fan_max_speed_path: 100,
            fan.fan_status_path: 0,
            fan.fan_speed_set_path: 153
        }

        def mock_read_int_from_file(file_path, default=0, raise_exception=False):
            return mock_sysfs_content[file_path]

        utils.read_int_from_file = mock_read_int_from_file
        assert fan.get_speed() == 50
        mock_sysfs_content[fan.fan_speed_get_path] = 101
        assert fan.get_speed() == 100
        mock_sysfs_content[fan.fan_max_speed_path] = 0
        assert fan.get_speed() == 101

        assert fan.get_status() is True
        mock_sysfs_content[fan.fan_status_path] = 1
        assert fan.get_status() is False

        assert fan.get_target_speed() == 60

        fan.fan_drawer.get_direction = MagicMock(return_value=Fan.FAN_DIRECTION_EXHAUST)
        assert fan.get_direction() == Fan.FAN_DIRECTION_EXHAUST
        fan.fan_drawer.get_presence = MagicMock(return_value=True)
        assert fan.get_presence() is True
Ejemplo n.º 30
0
    def __init__(self):
        ChassisBase.__init__(self)
        # sfp.py will read eeprom contents and retrive the eeprom data.
        # We pass the eeprom path from chassis.py
        self.PORT_START = 1
        self.PORT_END = 56
        self.PORTS_IN_BLOCK = (self.PORT_END + 1)
        _sfp_port = range(49, self.PORTS_IN_BLOCK)
        eeprom_base = "/sys/class/i2c-adapter/i2c-{0}/{0}-0050/eeprom"
        for index in range(self.PORT_START, self.PORTS_IN_BLOCK):
            eeprom_path = eeprom_base.format(self._port_to_i2c_mapping[index])
            port_type = 'QSFP' if index in _sfp_port else 'SFP'
            sfp_node = Sfp(index, port_type, eeprom_path)
            self._sfp_list.append(sfp_node)

        self._eeprom = Eeprom()
        self._watchdog = Watchdog()
        self._num_sfps = self.PORT_END
        self._num_fans = MAX_S5248F_FANTRAY * MAX_S5248F_FAN
        self._fan_list = [Fan(i, j) for i in range(MAX_S5248F_FANTRAY) \
                            for j in range(MAX_S5248F_FAN)]
        for i in range(MAX_S5248F_FANTRAY):
            fandrawer = FanDrawer(i)
            self._fan_drawer_list.append(fandrawer)
            self._fan_list.extend(fandrawer._fan_list)

        self._psu_list = [Psu(i) for i in range(MAX_S5248F_PSU)]
        self._thermal_list = [Thermal(i) for i in range(MAX_S5248F_THERMAL)]
        self._component_list = [
            Component(i) for i in range(MAX_S5248F_COMPONENT)
        ]
        for port_num in range(self.PORT_START, self.PORTS_IN_BLOCK):
            # sfp get uses zero-indexing, but port numbers start from 1
            presence = self.get_sfp(port_num - 1).get_presence()
            self._global_port_pres_dict[port_num] = '1' if presence else '0'