Ejemplo n.º 1
0
    def __init__(self):
        super(Chassis, self).__init__()

        # Initialize SKU name
        self.sku_name = self._get_sku_name()
        mi = get_machine_info()
        if mi is not None:
            self.name = mi['onie_platform']
        else:
            self.name = self.sku_name

        # move the initialization of each components to their dedicated initializer
        # which will be called from platform
        self.sfp_module_initialized = False
        self.sfp_event_initialized = False
        self.reboot_cause_initialized = False
        logger.log_info("Chassis loaded successfully")
Ejemplo n.º 2
0
    def _check_onie_version(self):
        # check ONIE version. To update ONIE requires version 5.2.0016 or later.
        try:
            machine_info = get_machine_info()
            onie_version_string = machine_info['onie_version']
            m = re.search(self.ONIE_VERSION_PARSE_PATTERN, onie_version_string)
            onie_major = m.group(self.ONIE_VERSION_MAJOR_OFFSET)
            onie_minor = m.group(self.ONIE_VERSION_MINOR_OFFSET)
            onie_release = m.group(self.ONIE_VERSION_RELEASE_OFFSET)
        except AttributeError as e:
            print("ERROR: Failed to parse ONIE version by {} from {} due to {}".format(
                                self.ONIE_VERSION_PARSE_PATTERN, machine_conf, repr(e)))
            return False

        if onie_major < self.ONIE_REQUIRED_MAJOR or onie_minor < self.ONIE_REQUIRED_MINOR or onie_release < self.ONIE_REQUIRED_RELEASE:
            print("ERROR: ONIE {}.{}.{} or later is required".format(self.ONIE_REQUIRED_MAJOR, self.ONIE_REQUIRED_MINOR, self.ONIE_REQUIRED_RELEASE))
            return False

        return True
Ejemplo n.º 3
0
    def __get_path_to_port_config_file(self):
        # Get platform and hwsku
        machine_info = sonic_device_util.get_machine_info()
        platform = sonic_device_util.get_platform_info(machine_info)
        config_db = ConfigDBConnector()
        config_db.connect()
        data = config_db.get_table('DEVICE_METADATA')
        try:
            hwsku = data['localhost']['hwsku']
        except KeyError:
            hwsku = "Unknown"

        # Load platform module from source
        platform_path = "/".join([self.PLATFORM_ROOT_PATH, platform])
        hwsku_path = "/".join([platform_path, hwsku])

        # First check for the presence of the new 'port_config.ini' file
        port_config_file_path = "/".join([hwsku_path, "port_config.ini"])
        if not os.path.isfile(port_config_file_path):
            # port_config.ini doesn't exist. Try loading the legacy 'portmap.ini' file
            port_config_file_path = "/".join([hwsku_path, "portmap.ini"])

        return port_config_file_path
Ejemplo n.º 4
0
 def __get_platform_type(self):
     return sonic_device_util.get_platform_info(
         sonic_device_util.get_machine_info())
Ejemplo n.º 5
0
    def install_component_firmware(self, component_name, image_path):

        bios_image = None
        bios_version = "3.25.0."
        bios_file_name = "S6100*BIOS*"
        flashrom = "/usr/local/bin/flashrom"
        PLATFORM_ROOT_PATH = '/usr/share/sonic/device'
        machine_info = sonic_device_util.get_machine_info()
        platform = sonic_device_util.get_platform_info(machine_info)
        platform_path = "/".join([PLATFORM_ROOT_PATH, platform, "bin"])

        warning = """
        ********************************************************************
        * Warning - Upgrading BIOS is inherently risky and should only be  *
        * attempted when necessary.  A failure at this upgrade may cause   *
        * a board RMA.  Proceed with caution !                             *
        ********************************************************************
        """

        if component_name in self._component_name_list:
            if component_name == self._component_name_list[0]:  # BIOS

                # current BIOS version
                current_bios_version = self.get_firmware_version("BIOS")

                # Construct BIOS image path
                if image_path is not None:
                    image_path = image_path + platform_path
                    for name in glob.glob(
                            os.path.join(image_path, bios_file_name)):
                        bios_image = image_path = name

                if not bios_image:
                    print "BIOS image file not found:", image_path
                    return False

                # Extract BIOS image version
                bios_image = os.path.basename(bios_image)
                bios_image = bios_image.strip('S6100-BIOS-')
                bios_image_version = bios_image.strip('.bin')

                if bios_image_version.startswith(bios_version):
                    bios_image_minor = bios_image_version.replace(
                        bios_image_version[:7], '')
                    if bios_image_minor.startswith("2"):
                        bios_image_minor = bios_image_minor.split("-")[1]

                if current_bios_version.startswith(bios_version):
                    current_bios_minor = current_bios_version.replace(
                        current_bios_version[:7], '')
                    if current_bios_minor.startswith("2"):
                        current_bios_minor = current_bios_minor.split("-")[1]

                # BIOS version check
                if bios_image_minor > current_bios_minor:

                    print warning
                    prompt_text = "New BIOS image " + bios_image_version + \
                        " available to install, continue?"
                    yes = click.confirm(prompt_text)

                elif current_bios_minor > bios_image_minor:

                    print warning
                    prompt_text = "Do you want to downgrade BIOS image from " \
                        + current_bios_version + " to " + \
                        bios_image_version + " continue?"

                    yes = click.confirm(prompt_text)

                else:
                    print("BIOS is already with {} latest version".format(
                        current_bios_version))
                    return True

                if yes:
                    command = flashrom + " -p" + " internal" + " -w " + \
                                         image_path
                    self.run_command(command)

            elif component_name == self._component_name_list[1]:  # CPLD1
                return False

            elif component_name == self._component_name_list[2]:  # CPLD2
                return False

            elif component_name == self._component_name_list[3]:  # SMF
                return False
        else:
            print "Invalid component Name:", component_name

        return True
Ejemplo n.º 6
0
    import subprocess
except ImportError, e:
    raise ImportError(str(e) + "- required module not found")

SYSLOG_IDENTIFIER = "eeprom.py"
EEPROM_SYMLINK = "/var/run/hw-management/eeprom/vpd_info"
CACHE_FILE = "/var/cache/sonic/decode-syseeprom/syseeprom_cache"


def log_error(msg):
    syslog.openlog(SYSLOG_IDENTIFIER)
    syslog.syslog(syslog.LOG_ERR, msg)
    syslog.closelog()


machine_info = get_machine_info()
onie_platform = machine_info['onie_platform']
if 'simx' in onie_platform:
    platform_path = os.path.join('/usr/share/sonic/device', onie_platform)
    subprocess.check_call(
        ['/usr/bin/xxd', '-r', '-p', 'syseeprom.hex', 'syseeprom.bin'],
        cwd=platform_path)
    CACHE_FILE = os.path.join(platform_path, 'syseeprom.bin')


class board(eeprom_tlvinfo.TlvInfoDecoder):

    _TLV_INFO_MAX_LEN = 256
    RETRIES = 5

    def __init__(self, name, path, cpld_root, ro):