Exemple #1
0
    def reinit_data(self):
        """
        Re-initialize all data.
        """

        # reinit cache
        self.physical_classes_map = {}
        self.physical_description_map = {}
        self.physical_name_map = {}
        self.physical_hw_version_map = {}
        self.physical_serial_number_map = {}
        self.physical_mfg_name_map = {}
        self.physical_model_name_map = {}
        self.physical_contained_in_map = {}
        self.physical_parent_relative_pos_map = {}
        self.physical_fru_map = {}

        self.physical_name_to_oid_map = {}
        self.pending_resolve_parent_name_map = {}

        device_metadata = mibs.get_device_metadata(self.statedb[0])
        chassis_sub_id = (CHASSIS_SUB_ID, )
        self.physical_entities = [chassis_sub_id]
        self.physical_name_to_oid_map[self.CHASSIS_NAME] = chassis_sub_id

        if not device_metadata or not device_metadata.get(
                "chassis_serial_number"):
            chassis_serial_number = ""
        else:
            chassis_serial_number = device_metadata["chassis_serial_number"]

        self.physical_classes_map[chassis_sub_id] = PhysicalClass.CHASSIS
        self.physical_serial_number_map[chassis_sub_id] = chassis_serial_number
        self.physical_name_map[chassis_sub_id] = self.CHASSIS_NAME
        self.physical_description_map[chassis_sub_id] = self.CHASSIS_NAME
        self.physical_contained_in_map[chassis_sub_id] = 0
        self.physical_fru_map[chassis_sub_id] = self.NOT_REPLACEABLE

        # Add a chassis mgmt node
        chassis_mgmt_sub_id = (CHASSIS_MGMT_SUB_ID, )
        self.add_sub_id(chassis_mgmt_sub_id)
        self.physical_classes_map[chassis_mgmt_sub_id] = PhysicalClass.CPU
        self.physical_contained_in_map[chassis_mgmt_sub_id] = CHASSIS_SUB_ID
        self.physical_parent_relative_pos_map[chassis_mgmt_sub_id] = 1
        name = 'MGMT'
        self.physical_description_map[chassis_mgmt_sub_id] = name
        self.physical_name_map[chassis_mgmt_sub_id] = name
        self.physical_fru_map[chassis_mgmt_sub_id] = self.NOT_REPLACEABLE

        for updater in self.physical_entity_updaters:
            updater.reinit_data()
Exemple #2
0
    def reinit_data(self):
        """
        Re-initialize all data.
        """

        # reinit cache
        self.physical_classes_map = {}
        self.physical_description_map = {}
        self.physical_hw_version_map = {}
        self.physical_serial_number_map = {}
        self.physical_mfg_name_map = {}
        self.physical_model_name_map = {}

        # update interface maps
        _, self.if_alias_map, _, _ = \
            Namespace.get_sync_d_from_all_namespace(mibs.init_sync_d_interface_tables, Namespace.init_namespace_dbs())

        device_metadata = mibs.get_device_metadata(self.statedb[0])
        chassis_sub_id = (self.CHASSIS_ID, )
        self.physical_entities = [chassis_sub_id]

        if not device_metadata or not device_metadata.get(
                b"chassis_serial_number"):
            chassis_serial_number = ""
        else:
            chassis_serial_number = device_metadata[b"chassis_serial_number"]

        self.physical_classes_map[chassis_sub_id] = PhysicalClass.CHASSIS
        self.physical_serial_number_map[chassis_sub_id] = chassis_serial_number

        # retrieve the initial list of transceivers that are present in the system
        transceiver_info = Namespace.dbs_keys(self.statedb, mibs.STATE_DB,
                                              self.TRANSCEIVER_KEY_PATTERN)
        if transceiver_info:
            self.transceiver_entries = [entry.decode() \
                for entry in transceiver_info]
        else:
            self.transceiver_entries = []

        # update cache with initial data
        for transceiver_entry in self.transceiver_entries:
            # extract interface name
            interface = transceiver_entry.split(
                mibs.TABLE_NAME_SEPARATOR_VBAR)[-1]
            self._update_transceiver_cache(interface)