Exemplo n.º 1
0
    def update_thermal_sensor_data(self):
        if not self.thermal_sensor:
            return

        for thermal_sensor_entry in self.thermal_sensor:
            thermal_name = thermal_sensor_entry.split(
                mibs.TABLE_NAME_SEPARATOR_VBAR)[-1]
            thermal_relation_info = self.statedb[
                HOST_NAMESPACE_DB_IDX].get_all(
                    self.statedb[HOST_NAMESPACE_DB_IDX].STATE_DB,
                    mibs.physical_entity_info_table(thermal_name))
            thermal_position, thermal_parent_name = get_db_data(
                thermal_relation_info, PhysicalRelationInfoDB)

            if is_null_empty_str(thermal_parent_name) or is_null_empty_str(thermal_parent_name) or \
                    CHASSIS_NAME_SUB_STRING not in thermal_parent_name.lower():
                continue

            thermal_position = int(thermal_position)

            thermal_sensor_entry_data = self.statedb[
                HOST_NAMESPACE_DB_IDX].get_all(
                    self.statedb[HOST_NAMESPACE_DB_IDX].STATE_DB,
                    thermal_sensor_entry)

            if not thermal_sensor_entry_data:
                continue

            sensor_data_list = ThermalSensorData.create_sensor_data(
                thermal_sensor_entry_data)
            for sensor_data in sensor_data_list:
                raw_sensor_value = sensor_data.get_raw_value()
                if is_null_empty_str(raw_sensor_value):
                    continue
                sensor = sensor_data.get_sensor_interface()
                sub_id = get_chassis_thermal_sub_id(thermal_position)

                try:
                    mib_values = sensor.mib_values(raw_sensor_value)
                except (ValueError, ArithmeticError):
                    mibs.logger.error("Exception occurred when converting"
                                      "value for sensor {} PSU {}".format(
                                          sensor, thermal_name))
                    continue
                else:
                    self.ent_phy_sensor_type_map[sub_id], \
                        self.ent_phy_sensor_scale_map[sub_id], \
                        self.ent_phy_sensor_precision_map[sub_id], \
                        self.ent_phy_sensor_value_map[sub_id], \
                        self.ent_phy_sensor_oper_state_map[sub_id] = mib_values

                    self.sub_ids.append(sub_id)
Exemplo n.º 2
0
    def update_psu_sensor_data(self):
        if not self.psu_sensor:
            return

        for psu_sensor_entry in self.psu_sensor:
            psu_name = psu_sensor_entry.split(
                mibs.TABLE_NAME_SEPARATOR_VBAR)[-1]
            psu_relation_info = self.statedb[HOST_NAMESPACE_DB_IDX].get_all(
                self.statedb[HOST_NAMESPACE_DB_IDX].STATE_DB,
                mibs.physical_entity_info_table(psu_name))
            psu_position, psu_parent_name = get_db_data(
                psu_relation_info, PhysicalRelationInfoDB)
            if is_null_empty_str(psu_position):
                continue
            psu_position = int(psu_position)
            psu_sub_id = get_psu_sub_id(psu_position)

            psu_sensor_entry_data = self.statedb[
                HOST_NAMESPACE_DB_IDX].get_all(
                    self.statedb[HOST_NAMESPACE_DB_IDX].STATE_DB,
                    psu_sensor_entry)

            if not psu_sensor_entry_data:
                continue

            sensor_data_list = PSUSensorData.create_sensor_data(
                psu_sensor_entry_data)
            for sensor_data in sensor_data_list:
                raw_sensor_value = sensor_data.get_raw_value()
                if is_null_empty_str(raw_sensor_value):
                    continue
                sensor = sensor_data.get_sensor_interface()
                sub_id = get_psu_sensor_sub_id(psu_sub_id,
                                               sensor_data.get_name().lower())

                try:
                    mib_values = sensor.mib_values(raw_sensor_value)
                except (ValueError, ArithmeticError):
                    mibs.logger.error("Exception occurred when converting"
                                      "value for sensor {} PSU {}".format(
                                          sensor, psu_name))
                    continue
                else:
                    self.ent_phy_sensor_type_map[sub_id], \
                        self.ent_phy_sensor_scale_map[sub_id], \
                        self.ent_phy_sensor_precision_map[sub_id], \
                        self.ent_phy_sensor_value_map[sub_id], \
                        self.ent_phy_sensor_oper_state_map[sub_id] = mib_values

                    self.sub_ids.append(sub_id)
Exemplo n.º 3
0
 def get_physical_relation_info(self, name):
     return Namespace.dbs_get_all(self.mib_updater.statedb, mibs.STATE_DB,
                                  mibs.physical_entity_info_table(name))
Exemplo n.º 4
0
    def update_fan_sensor_data(self):
        if not self.fan_sensor:
            return

        fan_parent_sub_id = 0
        for fan_sensor_entry in self.fan_sensor:
            fan_name = fan_sensor_entry.split(
                mibs.TABLE_NAME_SEPARATOR_VBAR)[-1]
            fan_relation_info = self.statedb[HOST_NAMESPACE_DB_IDX].get_all(
                self.statedb[HOST_NAMESPACE_DB_IDX].STATE_DB,
                mibs.physical_entity_info_table(fan_name))
            fan_position, fan_parent_name = get_db_data(
                fan_relation_info, PhysicalRelationInfoDB)
            if is_null_empty_str(fan_position):
                continue

            fan_position = int(fan_position)

            if CHASSIS_NAME_SUB_STRING in fan_parent_name:
                fan_parent_sub_id = (CHASSIS_SUB_ID, )
            else:
                fan_parent_relation_info = self.statedb[
                    HOST_NAMESPACE_DB_IDX].get_all(
                        self.statedb[HOST_NAMESPACE_DB_IDX].STATE_DB,
                        mibs.physical_entity_info_table(fan_parent_name))
                if fan_parent_relation_info:
                    fan_parent_position, fan_grad_parent_name = get_db_data(
                        fan_parent_relation_info, PhysicalRelationInfoDB)

                    fan_parent_position = int(fan_parent_position)

                    if PSU_NAME_SUB_STRING in fan_parent_name:
                        fan_parent_sub_id = get_psu_sub_id(fan_parent_position)
                    else:
                        fan_parent_sub_id = get_fan_drawer_sub_id(
                            fan_parent_position)
                else:
                    mibs.logger.error(
                        "fan_name = {} get fan parent failed".format(fan_name))
                    continue

            fan_sub_id = get_fan_sub_id(fan_parent_sub_id, fan_position)

            fan_sensor_entry_data = self.statedb[
                HOST_NAMESPACE_DB_IDX].get_all(
                    self.statedb[HOST_NAMESPACE_DB_IDX].STATE_DB,
                    fan_sensor_entry)

            if not fan_sensor_entry_data:
                mibs.logger.error(
                    "fan_name = {} get fan_sensor_entry_data failed".format(
                        fan_name))
                continue

            sensor_data_list = FANSensorData.create_sensor_data(
                fan_sensor_entry_data)
            for sensor_data in sensor_data_list:
                raw_sensor_value = sensor_data.get_raw_value()
                if is_null_empty_str(raw_sensor_value):
                    continue
                sensor = sensor_data.get_sensor_interface()
                sub_id = get_fan_tachometers_sub_id(fan_sub_id)

                try:
                    mib_values = sensor.mib_values(raw_sensor_value)
                except (ValueError, ArithmeticError):
                    mibs.logger.error("Exception occurred when converting"
                                      "value for sensor {} PSU {}".format(
                                          sensor, fan_name))
                    continue
                else:
                    self.ent_phy_sensor_type_map[sub_id], \
                        self.ent_phy_sensor_scale_map[sub_id], \
                        self.ent_phy_sensor_precision_map[sub_id], \
                        self.ent_phy_sensor_value_map[sub_id], \
                        self.ent_phy_sensor_oper_state_map[sub_id] = mib_values

                    self.sub_ids.append(sub_id)