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'] self.platform_name = get_platform_info(mi) else: self.name = self.sku_name self.platform_name = self._get_platform_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")
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
def __get_platform_type(self): return sonic_device_util.get_platform_info( sonic_device_util.get_machine_info())
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