Пример #1
0
    def __init__(self, module_index):
        # Modules are 1-based in DellEMC platforms
        self.index = module_index + 1
        self.port_start = (self.index - 1) * 16
        self.port_end = (self.index * 16) - 1
        self.port_i2c_line = self.IOM_I2C_MAPPING[self.index]
        self._eeprom = Eeprom(iom_eeprom=True, i2c_line=self.port_i2c_line)

        self.iom_status_reg = "iom_status"
        self.iom_presence_reg = "iom_presence"

        # Overriding _component_list and _sfp_list class variables defined in
        # ModuleBase, to make them unique per Module object
        self._component_list = []
        self._sfp_list = []

        component = Component(is_module=True,
                              iom_index=self.index,
                              i2c_line=self.port_i2c_line)
        self._component_list.append(component)

        eeprom_base = "/sys/class/i2c-adapter/i2c-{0}/i2c-{1}/{1}-0050/eeprom"
        sfp_ctrl_base = "/sys/class/i2c-adapter/i2c-{0}/{0}-003e/"

        # 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.
        for index in range(self.port_start, self.port_end + 1):
            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_line)
            sfp_node = Sfp(index, 'QSFP', eeprom_path, sfp_control, index)
            self._sfp_list.append(sfp_node)
Пример #2
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)
Пример #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)
Пример #4
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)
Пример #5
0
    def __init__(self, fan_index, psu_fan=False, dependency=None):
        self.is_psu_fan = psu_fan
        self.is_driver_initialized = True

        if not self.is_psu_fan:
            # Fan is 1-based in DellEMC platforms
            self.index = fan_index + 1
            self.fan_presence_reg = "fan_prs"
            self.fan_led_reg = "fan{}_led".format(fan_index)
            self.get_fan_speed_reg = self.I2C_DIR + "i2c-11/11-0029/" +\
                    "fan{}_input".format(self.index)
            self.set_fan_speed_reg = self.I2C_DIR + "i2c-11/11-0029/" +\
                    "fan{}_target".format(self.index)
            self.eeprom = Eeprom(is_fan=True, fan_index=self.index)
            self.max_fan_speed = MAX_S6000_FAN_SPEED
            self.supported_led_color = ['off', 'green', 'amber']
        else:
            self.index = fan_index
            self.dependency = dependency
            self.set_fan_speed_reg = self.I2C_DIR +\
                    "i2c-1/1-005{}/fan1_target".format(10 - self.index)

            hwmon_dir = self.I2C_DIR +\
                    "i2c-1/1-005{}/hwmon/".format(10 - self.index)
            try:
                hwmon_node = os.listdir(hwmon_dir)[0]
            except OSError:
                hwmon_node = "hwmon*"
                self.is_driver_initialized = False

            self.get_fan_speed_reg = hwmon_dir + hwmon_node + '/fan1_input'
            self.max_fan_speed = MAX_S6000_PSU_FAN_SPEED
Пример #6
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'
Пример #7
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()
Пример #8
0
    def __init__(self, psu_index):
        # PSU is 1-based in Nokia platforms
        self.index = psu_index + 1
        self._fan_list = []

        # PSU eeprom
        self.eeprom = Eeprom(is_psu=True, psu_index=self.index)
Пример #9
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))
Пример #10
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 = 66
        PORTS_IN_BLOCK = (self.PORT_END + 1)
        _sfp_port = range(65, self.PORT_END + 1)
        eeprom_base = "/sys/class/i2c-adapter/i2c-{0}/{0}-0050/eeprom"

        for index in range(self.PORT_START, 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()

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

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

        for port_num in range(self.PORT_START, (self.PORT_END + 1)):
            presence = self.get_sfp(port_num).get_presence()
            if presence:
                self._global_port_pres_dict[port_num] = '1'
            else:
                self._global_port_pres_dict[port_num] = '0'
Пример #11
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))
Пример #12
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()
Пример #13
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.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 = 'SFP' if index in _sfp_port else 'QSFP'
            sfp_node = Sfp(index, port_type, eeprom_path)
            self._sfp_list.append(sfp_node)

        self._eeprom = Eeprom()
        self._watchdog = Watchdog()
        for i in range(MAX_Z9332F_FANTRAY):
            fandrawer = FanDrawer(i)
            self._fan_drawer_list.append(fandrawer)
            self._fan_list.extend(fandrawer._fan_list)

        self._num_sfps = self.PORT_END
        self._num_fans = MAX_Z9332F_FANTRAY * MAX_Z9332F_FAN
        self._psu_list = [Psu(i) for i in range(MAX_Z9332F_PSU)]
        self._thermal_list = [Thermal(i) for i in range(MAX_Z9332F_THERMAL)]
        self._component_list = [
            Component(i) for i in range(MAX_Z9332F_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'

        self._watchdog = Watchdog()
Пример #14
0
    def __init__(self):

        ChassisBase.__init__(self)
        self.status_led_reg = "sys_status_led"
        self.supported_led_color = [
            'green', 'blinking green', 'amber', 'blinking amber'
        ]
        # 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_FANTRAY):
            fandrawer = FanDrawer(i)
            self._fan_drawer_list.append(fandrawer)
            self._fan_list.extend(fandrawer._fan_list)

        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()
Пример #15
0
    def __init__(self):
        ChassisBase.__init__(self)
        self.system_led_supported_color = ['off', 'amber', 'green', 'amber_blink', 'green_blink']
        # Port numbers for SFP List Initialization
        self.COPPER_PORT_START = COPPER_PORT_START
        self.COPPER_PORT_END = COPPER_PORT_END
        self.SFP_PORT_START = SFP_PORT_START
        self.SFP_PORT_END = SFP_PORT_END
        self.PORT_END = PORT_END

        # for non-sfp ports create dummy objects for copper / non-sfp ports
        for index in range(self.COPPER_PORT_START, self.COPPER_PORT_END+1):
            sfp_node = Sfp(index, 'COPPER', 'N/A', 'N/A')
            self._sfp_list.append(sfp_node)

        # Verify optoe2 driver SFP eeprom devices were enumerated and exist
        # then create the sfp nodes
        eeprom_path = "/sys/class/i2c-adapter/i2c-{0}/{0}-0050/eeprom"
        mux_dev = sorted(glob.glob("/sys/class/i2c-adapter/i2c-0/i2c-[0-9]"))
        y = 0
        for index in range(self.SFP_PORT_START, self.SFP_PORT_END+1):
            mux_dev_num = mux_dev[y]
            port_i2c_map = mux_dev_num[-1]
            y = y + 1
            port_eeprom_path = eeprom_path.format(port_i2c_map)
            if not os.path.exists(port_eeprom_path):
                sonic_logger.log_info("path %s didnt exist" % port_eeprom_path)
            sfp_node = Sfp(index, 'SFP', port_eeprom_path, port_i2c_map)
            self._sfp_list.append(sfp_node)
        self.sfp_event_initialized = False

        # Instantiate system eeprom object
        self._eeprom = Eeprom()

        # Construct lists fans, power supplies, thermals & components
        drawer_num = MAX_7215_FAN_DRAWERS
        fan_num_per_drawer = MAX_7215_FANS_PER_DRAWER
        drawer_ctor = RealDrawer
        fan_index = 0
        for drawer_index in range(drawer_num):
            drawer = drawer_ctor(drawer_index)
            self._fan_drawer_list.append(drawer)
            for index in range(fan_num_per_drawer):
                fan = Fan(fan_index, drawer)
                fan_index += 1
                drawer._fan_list.append(fan)
                self._fan_list.append(fan)

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

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

        for i in range(MAX_7215_COMPONENT):
            component = Component(i)
            self._component_list.append(component)
Пример #16
0
    def __init__(self):
        ChassisBase.__init__(self)

        self.data = {'valid': 0, 'last': 0}
        self.sfp_presence = {}

        if os.path.isdir(CONTAINER_PLATFORM_PATH):
            platform_path = CONTAINER_PLATFORM_PATH
        else:
            platform = device_info.get_platform()
            if platform is None:
                raise
            platform_path = os.path.join(HOST_DEVICE_PATH, platform)

        port_config_file = "/".join(
            [platform_path, "V682-48y8c", "port_config.ini"])
        try:
            f = open(port_config_file)
        except:
            raise
        for line in f:
            line.strip()
            if re.search('^#', line) is not None:
                Port_cfg = collections.namedtuple('Port_cfg', line.split()[1:])
                break
        f.close()
        f = open(port_config_file)
        _port_cfgs = [
            Port_cfg(*tuple((line.strip().split()))) for line in f
            if re.search('^#', line) is None
        ]
        f.close()

        # Initialize EEPROM
        self._eeprom = Eeprom()

        # Initialize FAN
        for i in range(NUM_FAN_TRAY):
            fandrawer = FanDrawer(i + 1)
            self._fan_drawer_list.append(fandrawer)
            self._fan_list.extend(fandrawer._fan_list)

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

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

        # Initialize SFP
        for port_cfg in _port_cfgs:
            sfp = Sfp(int(port_cfg.index),
                      'SFP' if int(port_cfg.index) < 48 else 'QSFP')
            self._sfp_list.append(sfp)
            self.sfp_presence[int(port_cfg.index)] = False
Пример #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 = 28
        self.SFP28_PORT_END = 24

        PORTS_IN_BLOCK = (self.PORT_END + 1)
        _sfp_port = range(1, self.SFP28_PORT_END + 1)
        eeprom_base = "/sys/class/i2c-adapter/i2c-{0}/{0}-0050/eeprom"

        for index in range(self.PORT_START, 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_S5224F_FAN * MAX_S5224F_FANTRAY

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

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

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

        for i in range(MAX_S5224F_FANTRAY):
            for j in range(MAX_S5224F_FAN):
                fan = Fan(i,j)
                self._fan_list.append(fan)

        for i in range(MAX_S5224F_FANTRAY):
            fandrawer = FanDrawer(i)
            self._fan_drawer_list.append(fandrawer)
            self._fan_list.extend(fandrawer._fan_list)

        for port_num in range(self.PORT_START, (self.PORT_END + 1)):
            # sfp get uses zero-indexing, but port numbers start from 1
            presence = self.get_sfp(port_num-1).get_presence()
            if presence:
                self._global_port_pres_dict[port_num] = '1'
            else:
                self._global_port_pres_dict[port_num] = '0'
Пример #18
0
    def __init__(self, fantray_index):
        FanDrawerBase.__init__(self)
        # FanTray is 1-based in DellEMC platforms
        self.index = fantray_index + 1
        self.eeprom = Eeprom(is_fantray=True, fantray_index=self.index)
        self.fantray_presence_reg = "fan_prs"
        self.fantray_led_reg = "fan{}_led".format(self.index - 1)
        self.supported_led_color = ['off', 'green', 'amber']

        for i in range(1, MAX_S6000_FANS_PER_FANTRAY + 1):
            self._fan_list.append(
                Fan(fantray_index=self.index, fan_index=i, dependency=self))
Пример #19
0
def test_get_system_eeprom_info():
    # remove the eeprom file to trigger the GRPC to
    # get the eeprom again
    eeprom = Eeprom()
    eeprom.reset()

    chassis = Chassis()
    eeprom_info = chassis.get_system_eeprom_info()
    assert eeprom_info != ''
    print('')
    for key, value in eeprom_info.items():
        print("{}: {}".format(key, value))
Пример #20
0
    def __init__(self):
        ChassisBase.__init__(self)
        self.status_led_reg = "system_led"
        self.supported_led_color = [
            'green', 'blinking green', 'amber', 'blinking amber'
        ]
        # 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()

        with open("/sys/class/dmi/id/product_name", "r") as fd:
            board_type = fd.read()

        if 'S6000-ON' in board_type:
            self._eeprom = Eeprom()
        else:
            self._eeprom = EepromS6000()

        for i in range(MAX_S6000_FANTRAY):
            fandrawer = FanDrawer(i)
            self._fan_drawer_list.append(fandrawer)
            self._fan_list.extend(fandrawer._fan_list)

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

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

        for i in range(MAX_S6000_COMPONENT):
            component = Component(i)
            self._component_list.append(component)
Пример #21
0
 def test_get_system_eeprom_info_from_hardware(self):
     eeprom = Eeprom()
     eeprom.p = os.path.join(test_path, 'mock_eeprom_data')
     eeprom._redis_hget = MagicMock()
     info = eeprom.get_system_eeprom_info()
     assert eeprom.get_product_name() == 'MSN3800'
     assert eeprom.get_part_number() == 'MSN3800-CS2FO'
     assert eeprom.get_base_mac() == 'B8:59:9F:A9:34:00'
     assert eeprom.get_serial_number() == 'MT1937X00537'
     assert info[hex(Eeprom._TLV_CODE_CRC_32)] == '0x9EFF0119'
Пример #22
0
    def test_get_system_eeprom_info_from_db(self):
        return_values = {
            ('EEPROM_INFO|State', 'Initialized'):
            '1',
            ('EEPROM_INFO|{}'.format(hex(Eeprom._TLV_CODE_PRODUCT_NAME)), 'Value'):
            'MSN3420',
            ('EEPROM_INFO|{}'.format(hex(Eeprom._TLV_CODE_PART_NUMBER)), 'Value'):
            'MSN3420-CB2FO',
            ('EEPROM_INFO|{}'.format(hex(Eeprom._TLV_CODE_MAC_BASE)), 'Value'):
            '1C:34:DA:1C:9F:00',
            ('EEPROM_INFO|{}'.format(hex(Eeprom._TLV_CODE_SERIAL_NUMBER)), 'Value'):
            'MT2019X13878',
            ('EEPROM_INFO|{}'.format(hex(Eeprom._TLV_CODE_VENDOR_EXT)), 'Num_vendor_ext'):
            '2',
            ('EEPROM_INFO|{}'.format(hex(Eeprom._TLV_CODE_VENDOR_EXT)), 'Value_0'):
            'ext1',
            ('EEPROM_INFO|{}'.format(hex(Eeprom._TLV_CODE_VENDOR_EXT)), 'Value_1'):
            'ext2',
            ('EEPROM_INFO|{}'.format(hex(Eeprom._TLV_CODE_CRC_32)), 'Value'):
            'CRC_VALUE',
        }

        def side_effect(key, field):
            return return_values.get((key, field))

        eeprom = Eeprom()
        eeprom._redis_hget = MagicMock(side_effect=side_effect)

        info = eeprom.get_system_eeprom_info()
        assert eeprom.get_product_name() == 'MSN3420'
        assert eeprom.get_part_number() == 'MSN3420-CB2FO'
        assert eeprom.get_base_mac() == '1C:34:DA:1C:9F:00'
        assert eeprom.get_serial_number() == 'MT2019X13878'
        assert info[hex(Eeprom._TLV_CODE_VENDOR_EXT)] == ['ext1', 'ext2']
        assert info[hex(Eeprom._TLV_CODE_CRC_32)] == 'CRC_VALUE'
Пример #23
0
    def __init__(self):
        ChassisBase.__init__(self)
        self.__num_of_psus = 2
        self.__num_of_ports = 32
        self.__num_of_sfps = 0
        self.__num_of_fan_drawers = 6
        self.__fan_per_drawer = 2
        self.__num_of_thermals = 15
        self.__xcvr_presence = {}

        # Initialize EEPROM
        self._eeprom = Eeprom()

        # Initialize watchdog
        #self._watchdog = Watchdog()

        # Initialize FAN
        fan_index = 1
        for drawer_index in range(1, self.__num_of_fan_drawers + 1):
            drawer_fan_list = []
            for index in range(0, self.__fan_per_drawer):
                fan = Fan(fan_index, False)
                fan_index += 1
                self._fan_list.append(fan)
                drawer_fan_list.append(fan)
            fan_drawer = FanDrawer(drawer_index, drawer_fan_list)
            self._fan_drawer_list.append(fan_drawer)

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

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

        # Initialize SFP
        for index in range(1, self.__num_of_ports + 1):
            if index in range(1, self.__num_of_sfps + 1):
                sfp = Sfp(index, 'SFP')
            else:
                sfp = Sfp(index, 'QSFP')

            self._sfp_list.append(sfp)

        for index in range(1, self.__num_of_ports + 1):
            self.__xcvr_presence[index] = self._sfp_list[index -
                                                         1].get_presence()
Пример #24
0
    def __init__(self):

        ChassisBase.__init__(self)
        self.status_led_reg = "sys_status_led"
        self.supported_led_color = [
            'green', 'blinking green', 'amber', 'blinking amber'
        ]
        # 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)

        #SFP ports
        sfp_port = 11
        for index in range(64, 66):
            eeprom_path = "/sys/bus/i2c/devices/i2c-{0}/{0}-0050/eeprom".format(
                sfp_port)
            sfp_control = ""
            sfp_node = Sfp(index, 'SFP', eeprom_path, sfp_control, index)
            self._sfp_list.append(sfp_node)
            sfp_port = sfp_port + 1

        for i in range(MAX_S6100_FANTRAY):
            fandrawer = FanDrawer(i)
            self._fan_drawer_list.append(fandrawer)
            self._fan_list.extend(fandrawer._fan_list)

        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)

        bios_ver = self.get_component(0).get_firmware_version()
        bios_minor_ver = bios_ver.split("-")[-1]
        if bios_minor_ver.isdigit() and (int(bios_minor_ver) >= 9):
            self._watchdog = WatchdogTCO()
        else:
            self._watchdog = Watchdog()

        self._transceiver_presence = self._get_transceiver_presence()
Пример #25
0
    def __init__(self, pddf_data=None, pddf_plugin_data=None):

        ChassisBase.__init__(self)

        self.pddf_obj = pddf_data if pddf_data else None
        self.plugin_data = pddf_plugin_data if pddf_plugin_data else None
        if not self.pddf_obj or not self.plugin_data:
            try:
                from . import pddfapi
                import json
                self.pddf_obj = pddfapi.PddfApi()
                with open(
                        '/usr/share/sonic/platform/pddf/pd-plugin.json') as pd:
                    self.plugin_data = json.load(pd)
            except Exception as e:
                raise Exception("Error: Unable to load PDDF JSON data - %s" %
                                str(e))

        self.platform_inventory = self.pddf_obj.get_platform()

        # Initialize EEPROM
        try:
            self._eeprom = Eeprom(self.pddf_obj, self.plugin_data)
        except Exception as err:
            sys.stderr.write("Unable to initialize syseeprom - {}".format(
                repr(err)))
            # Dont exit as we dont want failure in loading other components

        # FANs
        for i in range(self.platform_inventory['num_fantrays']):
            fandrawer = FanDrawer(i, self.pddf_obj, self.plugin_data)
            self._fan_drawer_list.append(fandrawer)
            self._fan_list.extend(fandrawer._fan_list)

        # PSUs
        for i in range(self.platform_inventory['num_psus']):
            psu = Psu(i, self.pddf_obj, self.plugin_data)
            self._psu_list.append(psu)

        # OPTICs
        for index in range(self.platform_inventory['num_ports']):
            sfp = Sfp(index, self.pddf_obj, self.plugin_data)
            self._sfp_list.append(sfp)

        # THERMALs
        for i in range(self.platform_inventory['num_temps']):
            thermal = Thermal(i, self.pddf_obj, self.plugin_data)
            self._thermal_list.append(thermal)
Пример #26
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 = 54
        self.PORTS_IN_BLOCK = (self.PORT_END + 1)
        self.SFP_PORT_START = 49
        self._sfp_port = range(self.SFP_PORT_START, 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 = ''
            if index in self._sfp_port:
                eeprom_path = eeprom_base.format(
                    self._sfpp_port_to_i2c_mapping[index])
            if (index < 53):
                port_type = 'SFP'
            else:
                port_type = 'QSFP'

            sfp_node = Sfp(index, port_type, eeprom_path)
            self._sfp_list.append(sfp_node)

        self._eeprom = Eeprom()
        self._watchdog = Watchdog()
        self._num_sfps = 54
        self._num_fans = MAX_N3248TE_FANTRAY * MAX_N3248TE_FAN
        for k in range(MAX_N3248TE_FANTRAY):
            fandrawer = FanDrawer(k)
            self._fan_drawer_list.append(fandrawer)
            self._fan_list.extend(fandrawer._fan_list)

        self._psu_list = [Psu(i) for i in range(MAX_N3248TE_PSU)]
        self._thermal_list = [Thermal(i) for i in range(MAX_N3248TE_THERMAL)]
        self._component_list = [
            Component(i) for i in range(MAX_N3248TE_COMPONENT)
        ]
        for port_num in self._sfp_port:
            # 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'

        self._watchdog = Watchdog()
        self.status_led_reg = "system_led"
        self.locator_led_reg = "locator_led"
        self.LOCATOR_LED_ON = "blink_blue"
        self.LOCATOR_LED_OFF = self.STATUS_LED_COLOR_OFF
Пример #27
0
    def __init__(self):
        ChassisBase.__init__(self)

        # logger.set_min_log_priority_info()

        # Chassis specific slot numbering
        self.is_chassis_modular = nokia_common.is_chassis_modular()
        self.cpm_instance = nokia_common._get_cpm_slot()
        self.my_instance = nokia_common._get_my_slot()
        self.is_cpm = nokia_common.is_cpm()

        # Create a GRPC channel
        self.chassis_stub = None
        self.fan_stub = None
        self.thermal_stub = None
        self.psu_stub = None
        self.firmware_stub = None

        # Get maximum power consumed by each module like cards, fan-trays etc
        self._get_modules_consumed_power()

        # Module list
        self.get_module_list()

        # PSU list
        self._get_psu_list()

        # FAN list
        self._get_fantray_list()

        # Thermal list
        self.get_thermal_list()

        # Component List
        self._get_component_list()

        # SFP
        self.sfp_module_initialized = False
        self.sfp_event_initialized = False

        # Watchdog
        if self._watchdog is None:
            self._watchdog = Watchdog("dog")
            logger.log_info('HW Watchdog initialized')

        # system eeprom
        self._eeprom = Eeprom()
Пример #28
0
    def __init__(self, pddf_data=None, pddf_plugin_data=None):

        ChassisBase.__init__(self)

        self.pddf_obj = pddf_data if pddf_data else None
        self.plugin_data = pddf_plugin_data if pddf_plugin_data else None
        if not self.pddf_obj or not self.plugin_data:
            try:
                from . import pddfparse
                import json
                self.pddf_obj = pddfparse.PddfParse()
                with open(
                        '/usr/share/sonic/platform/pddf/pd-plugin.json') as pd:
                    self.plugin_data = json.load(pd)
            except Exception as e:
                raise Exception("Error: Unable to load PDDF JSON data - %s" %
                                str(e))

        self.platform_inventory = self.pddf_obj.get_platform()

        # Initialize EEPROM
        self.sys_eeprom = Eeprom(self.pddf_obj, self.plugin_data)

        # FANs
        for i in range(self.platform_inventory['num_fantrays']):
            for j in range(self.platform_inventory['num_fans_pertray']):
                fan = Fan(i, j, self.pddf_obj, self.plugin_data)
                self._fan_list.append(fan)

        # PSUs
        for i in range(self.platform_inventory['num_psus']):
            psu = Psu(i, self.pddf_obj, self.plugin_data)
            self._psu_list.append(psu)

        # OPTICs
        for index in range(self.platform_inventory['num_ports']):
            sfp = Sfp(index, self.pddf_obj, self.plugin_data)
            self._sfp_list.append(sfp)

        # THERMALs
        for i in range(self.platform_inventory['num_temps']):
            thermal = Thermal(i, self.pddf_obj, self.plugin_data)
            self._thermal_list.append(thermal)

        # SYSTEM LED Test Cases
        """
Пример #29
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
        _sfp_port = list(range(33, PORTS_IN_BLOCK))
        i2c_bus_for_port = 2
        i2c_mux_to_populate = 603
        i2c_mux_address = 70
        i2c_mux_is_good = False
        eeprom_base = "/sys/class/i2c-adapter/i2c-{0}/{0}-0050/eeprom"
        mux_channel = "/sys/class/i2c-adapter/i2c-{0}/{0}-00{1}/channel-0"
        for index in range(PORT_START, PORTS_IN_BLOCK):
            eeprom_path = ""
            if index % 8 == 1:  # 8 buses per i2c mux
                i2c_mux_is_good = True if os.path.exists(
                    mux_channel.format(i2c_mux_to_populate,
                                       i2c_mux_address)) else False
                i2c_mux_to_populate += 1
                i2c_mux_address += 1
            if i2c_mux_is_good:
                eeprom_path = eeprom_base.format(i2c_bus_for_port)
                i2c_bus_for_port += 1
            port_type = 'QSFP_DD' if index not 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 = PORT_END
        self._num_fans = MAX_Z9432F_FANTRAY * MAX_Z9432F_FAN

        for i in range(MAX_Z9432F_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_Z9432F_PSU)]
        self._thermal_list = [Thermal(i) for i in range(MAX_Z9432F_THERMAL)]
        self._component_list = [
            Component(i) for i in range(MAX_Z9432F_COMPONENT)
        ]
        for port_num in range(PORT_START, PORTS_IN_BLOCK):
            presence = self.get_sfp(port_num).get_presence()
            self._global_port_pres_dict[port_num] = '1' if presence else '0'

        self._watchdog = Watchdog()
Пример #30
0
    def __init__(self, fan_index, psu_fan=False):
        # Fan is 1-based in DellEMC platforms
        self.index = fan_index + 1
        self.is_psu_fan = psu_fan

        if not self.is_psu_fan:
            self.fan_presence_reg = "fan_prs"
            self.fan_led_reg = "fan{}_led".format(fan_index)
            self.get_fan_speed_reg = self.I2C_DIR + "i2c-11/11-0029/" +\
                    "fan{}_input".format(self.index)
            self.set_fan_speed_reg = self.I2C_DIR + "i2c-11/11-0029/" +\
                    "fan{}_target".format(self.index)
            self.eeprom = Eeprom(is_fan=True, fan_index=self.index)
            self.max_fan_speed = MAX_S6000_FAN_SPEED
            self.supported_led_color = ['off', 'green', 'amber']
        else:
            self.get_fan_speed_reg = self.I2C_DIR + "i2c-1/1-005{}/" +\
                    "fan1_input".format(10 - self.index)