def initialize(self, conf_reader, msgQlist, product): """initialize configuration reader and internal msg queues""" # Initialize ScheduledMonitorThread and InternalMsgQ super(CPUFaultSensor, self).initialize(conf_reader) super(CPUFaultSensor, self).initialize_msgQ(msgQlist) # get the cpu fault implementor from configuration cpu_fault_utility = Conf.get(SSPL_CONF, f"{self.name().upper()}>{self.PROBE}", 'sysfs') # Creating the instance of ToolFactory class self.tool_factory = ToolFactory() try: # Get the instance of the utility using ToolFactory self._utility_instance = self._utility_instance or \ self.tool_factory.get_instance(cpu_fault_utility) except Exception as err: raise Exception( "Error while initializing. " f"Unable to get the instance of {cpu_fault_utility} Utility, {err}" ) self._node_id = Conf.get(GLOBAL_CONF, NODE_ID_KEY, 'SN01') cache_dir_path = os.path.join(DATA_PATH, self.CACHE_DIR_NAME) self.CPU_FAULT_SENSOR_DATA = os.path.join( cache_dir_path, f'CPU_FAULT_SENSOR_DATA_{self._node_id}') return True
def __init__(self): """Initialize the relavent datastructures.""" super(ServiceMonitor, self).__init__(self.SENSOR_NAME, self.PRIORITY) self.services_to_monitor = copy.deepcopy( Conf.get(SSPL_CONF, f"{self.SERVICEMONITOR}>{self.MONITORED_SERVICES}", [])) self.not_active_services = { # 'service_name' : [timestamp, prev_state, prev_substate], # timestamp => instance when transition to non_active state occurred. # prev_state => state from which it came to non_active state # prev_substate => substate from which it came to non_acitve substate. } self.failed_services = [] self.service_status = {} self.thread_sleep = \ int(Conf.get(SSPL_CONF, f"{self.SERVICEMONITOR}>{self.THREAD_SLEEP}", 1)) self.polling_frequency = \ int(Conf.get(SSPL_CONF, f"{self.SERVICEMONITOR}>{self.POLLING_FREQUENCY}", 30)) self.max_wait_time = \ int(Conf.get(SSPL_CONF, f"{self.SERVICEMONITOR}>{self.MAX_WAIT_TIME}", 60))
def prepare_message(self, jsonMsg, message_type): """Adds all common key fields to the JsonMsg""" try: if jsonMsg.get("message").get(message_type).get("info") is None: return payload = KvPayload(jsonMsg) if payload.get(f"message>{message_type}>info>site_id") is None: jsonMsg["message"][message_type]["info"]["site_id"] = Conf.get( GLOBAL_CONF, SITE_ID_KEY, DEFAULT_DC) if payload.get(f"message>{message_type}>info>node_id") is None: jsonMsg["message"][message_type]["info"]["node_id"] = Conf.get( GLOBAL_CONF, NODE_ID_KEY, DEFAULT_SN) if payload.get(f"message>{message_type}>info>rack_id") is None: jsonMsg["message"][message_type]["info"]["rack_id"] = Conf.get( GLOBAL_CONF, RACK_ID_KEY, DEFAULT_RACK) if payload.get(f"message>{message_type}>info>cluster_id") is None: jsonMsg["message"][message_type]["info"][ "cluster_id"] = Conf.get(GLOBAL_CONF, CLUSTER_ID_KEY, DEFAULT_CLUSTER) logger.debug("prepare_message, jsonMsg: %s" % jsonMsg) except KeyError as ex: logger.exception( f"Failed to prepare json message. JsonMsg:{jsonMsg}." f"Error:{str(ex)}")
def load_storage_fru_list(self): """Get Storage FRU list and merge it with storage_fru_list, maintained in global config, with which FRU list can be extended for a solution. Ex: Storage Enclosures not listing disk as FRU, though its most common FRU in storage, and practically it can be replaced easily. So if for a solution, FRU list needs to be extended beyond what publishes, 'storage_fru_list' from global config can be used. Some of the usual FRU examples are:- disk. """ self.fru_list = [] # Read FRU data using /show/frus cli api. fru_data = singleton_realstorencl.get_realstor_encl_data("frus") for fru_dict in fru_data: if "name" in fru_dict.keys(): self.fru_list.append(fru_dict["name"]) self.fru_list = list(set(self.fru_list)) try: self.hot_swapped_frus = Conf.get( GLOBAL_CONF, "storage_enclosure>storage_fru_list>hot_swappable", ['disk', 'controller']) self.cold_swapped_frus = Conf.get( GLOBAL_CONF, "storage_enclosure>storage_fru_list", []) except ValueError as e: logger.error("Failed to get storage_fru_list from config." f"Error:{e}") self.fru_list = list( set(self.fru_list + self.hot_swapped_frus + self.cold_swapped_frus)) logger.info(f"Fetched Enclosure FRU list:{self.fru_list}")
def initialize(self, conf_reader, msgQlist, product): """initialize configuration reader and internal msg queues""" # Initialize ScheduledMonitorThread and InternalMsgQ super(CPUFaultSensor, self).initialize(conf_reader) super(CPUFaultSensor, self).initialize_msgQ(msgQlist) self._site_id = Conf.get(GLOBAL_CONF, SITE_ID_KEY,'DC01') self._rack_id = Conf.get(GLOBAL_CONF, RACK_ID_KEY,'RC01') self._node_id = Conf.get(GLOBAL_CONF, NODE_ID_KEY,'SN01') self._cluster_id = Conf.get(GLOBAL_CONF, CLUSTER_ID_KEY,'CC01') # get the cpu fault implementor from configuration cpu_fault_utility = Conf.get(SSPL_CONF, f"{self.name().capitalize()}>{self.PROBE}", 'sysfs') # Creating the instance of ToolFactory class self.tool_factory = ToolFactory() try: # Get the instance of the utility using ToolFactory self._utility_instance = self._utility_instance or \ self.tool_factory.get_instance(cpu_fault_utility) except Exception as e: logger.error(f"Error while initializing, shutting down CPUFaultSensor : {e}") self.shutdown() cache_dir_path = os.path.join(DATA_PATH, self.CACHE_DIR_NAME) self.CPU_FAULT_SENSOR_DATA = os.path.join(cache_dir_path, f'CPU_FAULT_SENSOR_DATA_{self._node_id}') return True
def init_rabbitMQ_msg_processors(): """The main bootstrap for sspl automated tests""" # Initialize logging try: init_logging("SSPL-Tests", "DEBUG") except Exception as err: # We don't have logger since it threw an exception, use generic 'print' print("[ Error ] when initializing logging :") print(err) print("Exiting ...") exit(os.EX_USAGE) # Modules to be used for testing conf_modules = Conf.get(SSPL_TEST_CONF, f"{SSPL_SETTING}>{MODULES}") # Create a map of references to all the module's message queues. Each module # is passed this mapping so that it can send messages to other modules. msgQlist = {} # Create a mapping of all the instantiated modules to their names world.sspl_modules = {} # Read in product value from configuration file product = Conf.get(GLOBAL_CONF, f"release>{PRODUCT_NAME}") logger.info("sspl-ll Bootstrap: product name supported: %s" % product) # Use reflection to instantiate the class based upon its class name in config file for conf_thread in conf_modules: klass = globals()[conf_thread] # Create mappings of modules and their message queues world.sspl_modules[klass.name()] = klass() msgQlist[klass.name()] = queue.Queue() # Convert to a dict # TODO: Check use of this world.diskmonitor_file = json.loads("{}") try: # Loop through the list of instanced modules and start them on threads threads = [] for name, curr_module in list(world.sspl_modules.items()): logger.info("SSPL-Tests Starting %s" % curr_module.name()) curr_module._set_debug(True) thread = Thread(target=_run_thread_capture_errors, args=(curr_module, msgQlist, conf_reader, product)) thread.start() threads.append(thread) # Allow threads to startup before running tests time.sleep(2) # Clear the message queue buffer out from msgs sent at startup while not world.sspl_modules[ RabbitMQingressProcessorTests.name()]._is_my_msgQ_empty(): world.sspl_modules[ RabbitMQingressProcessorTests.name()]._read_my_msgQ() except Exception as ex: logger.exception(ex)
def initialize(self, conf_reader, msgQlist, product): """initialize configuration reader and internal msg queues""" # Initialize ScheduledMonitorThread and InternalMsgQ super(RAIDIntegritySensor, self).initialize(conf_reader) # Initialize internal message queues for this module super(RAIDIntegritySensor, self).initialize_msgQ(msgQlist) self._alert_msg = None self._fault_state = None self._suspended = False self._timestamp_file_path = Conf.get( SSPL_CONF, f"{self.RAIDIntegritySensor}>{self.TIMESTAMP_FILE_PATH_KEY}", self.DEFAULT_TIMESTAMP_FILE_PATH) self._scan_frequency = Conf.get( SSPL_CONF, f"{self.RAIDIntegritySensor}>{self.SCAN_FREQUENCY}", self.DEFAULT_SCAN_FREQUENCY) self._next_scheduled_time = self._scan_frequency if self._scan_frequency < self.MIN_SCAN_FREQUENCY: self._scan_frequency = self.MIN_SCAN_FREQUENCY sysfs_path = Conf.get(SSPL_CONF, f'{SYSTEM_INFORMATION}>{SYSFS_PATH}') self.raid_dir = sysfs_path + BLOCK_DIR self.retry_interval = int( Conf.get(SSPL_CONF, f'{self.RAIDIntegritySensor}>{self.RETRY_INTERVAL}')) # Create DEFAULT_RAID_DATA_PATH if already not exist. self._create_file(self.DEFAULT_RAID_DATA_PATH) return True
def __init__(self, unit): """ Initialize Service. """ self.unit = unit self.properties_iface = Interface(self.unit, dbus_interface=PROPERTIES_IFACE) self.name = str(self.properties_iface.Get(UNIT_IFACE, 'Id')) self.state = "N/A" self.substate = "N/A" self.pid = "N/A" self.previous_state = "N/A" self.previous_substate = "N/A" self.previous_pid = "N/A" self.nonactive_enter_timestamp = time.time() self.active_enter_timestamp = time.time() self.nonactive_threshold = int( Conf.get(SSPL_CONF, f"{ServiceMonitor.name().upper()}>threshold_inactive_time", '60')) self.active_threshold = int(Conf.get(SSPL_CONF, f"{ServiceMonitor.name().upper()}>threshold_active_time", '30')) self.properties_changed_signal = None self._service_state = ActiveState self._unit_state = None
def __init__(self, executor, conf_reader): super(NodeHWactuator, self).__init__() self._site_id = Conf.get(GLOBAL_CONF, SITE_ID_KEY, "DC01") self._rack_id = Conf.get(GLOBAL_CONF, RACK_ID_KEY, "RC01") self._node_id = Conf.get(GLOBAL_CONF, NODE_ID_KEY, "SN01") self.host_id = socket.getfqdn() self.sensor_id_map = None self._executor = executor self.fru_specific_info = {} self._resource_id = "" self._sensor_type = ""
def _read_config(self): """Read in configuration values""" try: self._iem_routing_enabled = Conf.get(SSPL_CONF, f"{self.LOGGINGMSGHANDLER}>{self.IEM_ROUTING_ENABLED}", 'false') self._iem_log_locally = Conf.get(SSPL_CONF, f"{self.LOGGINGMSGHANDLER}>{self.IEM_LOG_LOCALLY}", 'true') logger.info(f"IEM routing enabled: {str(self._iem_routing_enabled)}") logger.info(f"IEM log locally: {str(self._iem_log_locally)}") except Exception as ex: logger.exception(f"_read_config: {ex}")
def _get_config(self): """Retrieves the information in /etc/sspl.conf""" self._enabled_traps = Conf.get(SSPL_CONF, f"{self.SNMPTRAPS}>{self.ENABLED_TRAPS}") self._enabled_MIBS = Conf.get(SSPL_CONF, f"{self.SNMPTRAPS}>{self.ENABLED_MIBS}") self._bind_ip = Conf.get(SSPL_CONF, f"{self.SNMPTRAPS}>{self.BIND_IP}", 'service') self._bind_port = int(Conf.get(SSPL_CONF, f"{self.SNMPTRAPS}>{self.BIND_PORT}", 1620)) logger.info(" Listening on %s:%s" % (self._bind_ip, self._bind_port)) logger.info(" Enabled traps: %s" % str(self._enabled_traps)) logger.info(" Enabled MIBS: %s" % str(self._enabled_MIBS))
def __init__(self, executor, conf_reader): super(NodeHWactuator, self).__init__() self._site_id = Conf.get(GLOBAL_CONF, f"{CLUSTER}>{SRVNODE}>{SITE_ID}", 'DC01') self._rack_id = Conf.get(GLOBAL_CONF, f"{CLUSTER}>{SRVNODE}>{RACK_ID}", 'RC01') self._node_id = Conf.get(GLOBAL_CONF, f"{CLUSTER}>{SRVNODE}>{NODE_ID}", 'SN01') self.host_id = socket.getfqdn() self.sensor_id_map = None self._executor = executor self.fru_specific_info = {} self._resource_id = "" self._sensor_type = ""
def _read_config(self): """Configure the messaging exchange with defaults available.""" # Make methods locally available self._node_id = Conf.get(SSPL_TEST_CONF, NODE_ID_KEY, "SN01") self._consumer_id = Conf.get(SSPL_TEST_CONF, f"{self.PROCESSOR}>{self.CONSUMER_ID}", "sspl_actuator") self._consumer_group = Conf.get( SSPL_TEST_CONF, f"{self.PROCESSOR}>{self.CONSUMER_GROUP}", "cortx_monitor") self._message_type = Conf.get(SSPL_TEST_CONF, f"{self.PROCESSOR}>{self.MESSAGE_TYPE}", "Requests") self._offset = Conf.get(SSPL_TEST_CONF, f"{self.PROCESSOR}>{self.OFFSET}", "earliest")
def __init__(self): super(RealStorLogicalVolumeSensor, self).__init__(self.SENSOR_NAME, self.PRIORITY) self._faulty_disk_group_file_path = None self._faulty_logical_volume_file_path = None self.rssencl = singleton_realstorencl # logical volumes persistent cache self._logical_volume_prcache = None # disk groups persistent cache self._disk_group_prcache = None # Holds Disk Groups with faults. Used for future reference. self._previously_faulty_disk_groups = {} # Holds Logical Volumes with faults. Used for future reference. self._previously_faulty_logical_volumes = {} self.pollfreq_logical_volume_sensor = \ int(Conf.get(SSPL_CONF, f"{self.rssencl.CONF_REALSTORLOGICALVOLUMESENSOR}>{POLLING_FREQUENCY_OVERRIDE}", 0)) if self.pollfreq_logical_volume_sensor == 0: self.pollfreq_logical_volume_sensor = self.rssencl.pollfreq # Flag to indicate suspension of module self._suspended = False self._event = Event()
def __init__(self): self._max_size = int( Conf.get(SSPL_CONF, f"{self.RABBITMQPROCESSOR}>{self.LIMIT_CONSUL_MEMORY}", 50000000)) self.cache_dir_path = os.path.join(DATA_PATH, self.CACHE_DIR_NAME) self.SSPL_MEMORY_USAGE = os.path.join(self.cache_dir_path, 'SSPL_MEMORY_USAGE') self._current_size = store.get(self.SSPL_MEMORY_USAGE) if self._current_size is None: store.put(0, self.SSPL_MEMORY_USAGE) self.SSPL_MESSAGE_HEAD_INDEX = os.path.join(self.cache_dir_path, 'SSPL_MESSAGE_HEAD_INDEX') self._head = store.get(self.SSPL_MESSAGE_HEAD_INDEX) if self._head is None: store.put(0, self.SSPL_MESSAGE_HEAD_INDEX) self.SSPL_MESSAGE_TAIL_INDEX = os.path.join(self.cache_dir_path, 'SSPL_MESSAGE_TAIL_INDEX') self._tail = store.get(self.SSPL_MESSAGE_TAIL_INDEX) if self._tail is None: store.put(0, self.SSPL_MESSAGE_TAIL_INDEX) self.SSPL_UNSENT_MESSAGES = os.path.join(self.cache_dir_path, 'MESSAGES')
def __init__(self): """Initialize server.""" super().__init__() self.log = CustomLog(const.HEALTH_SVC_NAME) server_type = Conf.get(GLOBAL_CONF, NODE_TYPE_KEY) Platform.validate_server_type_support(self.log, ResourceMapError, server_type) self.sysfs = ToolFactory().get_instance('sysfs') self.sysfs.initialize() self.sysfs_base_path = self.sysfs.get_sysfs_base_path() self.cpu_path = self.sysfs_base_path + const.CPU_PATH hw_resources = { 'cpu': self.get_cpu_info, 'platform_sensor': self.get_platform_sensors_info, 'memory': self.get_mem_info, 'fan': self.get_fans_info, 'nw_port': self.get_nw_ports_info, 'sas_hba': self.get_sas_hba_info, 'sas_port': self.get_sas_ports_info, 'disk': self.get_disks_info, 'psu': self.get_psu_info } sw_resources = { 'cortx_sw_services': self.get_cortx_service_info, 'external_sw_services': self.get_external_service_info, 'raid': self.get_raid_info } self.server_resources = {"hw": hw_resources, "sw": sw_resources} self._ipmi = IpmiFactory().get_implementor("ipmitool") self.platform_sensor_list = ['Temperature', 'Voltage', 'Current'] self.service = Service() self.resource_indexing_map = ServerResourceMap.resource_indexing_map\ ["health"]
def get_node_id(): node_id = 'srvnode-1' try: node_id = Conf.get(GLOBAL_CONF, NODE_KEY) except Exception as e: print(f"Can't read node id, using 'srvnode-1' : {e}") return node_id
def __init__(self): super(RealStorPSUSensor, self).__init__( self.SENSOR_NAME, self.PRIORITY) self._faulty_psu_file_path = None self.rssencl = singleton_realstorencl # psus persistent cache self.psu_prcache = None # Holds PSUs with faults. Used for future reference. self._previously_faulty_psus = {} self.pollfreq_psusensor = \ int(Conf.get(SSPL_CONF, f"{self.rssencl.CONF_REALSTORPSUSENSOR}>{POLLING_FREQUENCY_OVERRIDE}", 0)) if self.pollfreq_psusensor == 0: self.pollfreq_psusensor = self.rssencl.pollfreq # Flag to indicate suspension of module self._suspended = False self._event = Event() self.os_utils = OSUtils()
def __init__(self): """Initialize the relevant datastructures.""" super(ServiceMonitor, self).__init__(self.SENSOR_NAME, self.PRIORITY) self.services_to_monitor = set( Platform.get_effective_monitored_services()) self.services = {} self.thread_sleep = int( Conf.get(SSPL_CONF, f"{self.SERVICEMONITOR}>{self.THREAD_SLEEP}", "1")) self.polling_frequency = int( Conf.get(SSPL_CONF, f"{self.SERVICEMONITOR}>{self.POLLING_FREQUENCY}", "30"))
def _read_config(self): """Configure with defaults available""" # Make methods locally available self._node_id = Conf.get(SSPL_CONF, f"{CLUSTER}>{SRVNODE}>{self.NODE_ID_KEY}", 'SN01') self._consumer_id = Conf.get(SSPL_CONF, f"{self.PROCESSOR}>{self.CONSUMER_ID}", 'sspl_in') self._consumer_group = Conf.get( SSPL_CONF, f"{self.PROCESSOR}>{self.CONSUMER_GROUP}", 'cortx_monitor') self._message_type = Conf.get(SSPL_CONF, f"{self.PROCESSOR}>{self.MESSAGE_TYPE}", 'IEM') self._offset = Conf.get(SSPL_CONF, f"{self.PROCESSOR}>{self.OFFSET}", 'earliest')
def initialize(self, conf_reader, msgQlist, product): """initialize configuration reader and internal msg queues""" # Initialize ScheduledMonitorThread super(ServiceMsgHandler, self).initialize(conf_reader) # Initialize internal message queues for this module super(ServiceMsgHandler, self).initialize_msgQ(msgQlist) self._import_products(product) self.host_id = socket.getfqdn() self.site_id = Conf.get(GLOBAL_CONF, SITE_ID_KEY, "DC01") self.rack_id = Conf.get(GLOBAL_CONF, RACK_ID_KEY, "RC01") self.node_id = Conf.get(GLOBAL_CONF, NODE_ID_KEY, "SN01") self.cluster_id = Conf.get(GLOBAL_CONF, CLUSTER_ID_KEY, "CC01") self.storage_set_id = Conf.get(GLOBAL_CONF, STORAGE_SET_ID_KEY, "ST01") self.monitored_services = Platform.get_effective_monitored_services()
def _init_config(self): """Configure the messaging exchange with defaults available.""" # Make methods locally available self._node_id = Conf.get(GLOBAL_CONF, NODE_ID_KEY, DEFAULT_NODE_ID) self._consumer_id = Conf.get(SSPL_TEST_CONF, f"{self.PROCESSOR}>{self.CONSUMER_ID}", 'sspl_actuator') self._consumer_group_prefix = Conf.get( SSPL_TEST_CONF, f"{self.PROCESSOR}>{self.CONSUMER_GROUP_PREFIX}", 'cortx_monitor') self._consumer_group = self._consumer_group_prefix + \ "_" + str(self._node_id) self._message_type = Conf.get(SSPL_TEST_CONF, f"{self.PROCESSOR}>{self.MESSAGE_TYPE}", 'Requests') self._offset = Conf.get(SSPL_TEST_CONF, f"{self.PROCESSOR}>{self.OFFSET}", 'earliest')
def initialize(self, conf_reader, msgQlist, products): """initialize configuration reader and internal msg queues""" # Initialize ScheduledMonitorThread and InternalMsgQ super(IEMSensor, self).initialize(conf_reader) # Initialize internal message queues for this module super(IEMSensor, self).initialize_msgQ(msgQlist) # Read configurations self._log_file_path = Conf.get(SSPL_CONF, f"{self.SENSOR_NAME.upper()}>{self.LOG_FILE_PATH_KEY}", self.DEFAULT_LOG_FILE_PATH) self._timestamp_file_path = Conf.get(SSPL_CONF, f"{self.SENSOR_NAME.upper()}>{self.TIMESTAMP_FILE_PATH_KEY}", self.DEFAULT_TIMESTAMP_FILE_PATH) return True
def _read_config(self): """Read config for messaging bus.""" # Make methods locally available self._node_id = Conf.get(SSPL_CONF, f"{CLUSTER}>{SRVNODE}>{self.NODE_ID_KEY}", 'SN01') self._consumer_id = Conf.get(SSPL_CONF, f"{self.PROCESSOR}>{self.CONSUMER_ID}", 'sspl_actuator') self._consumer_group = Conf.get( SSPL_CONF, f"{self.PROCESSOR}>{self.CONSUMER_GROUP}", 'cortx_monitor') self._message_type = Conf.get(SSPL_CONF, f"{self.PROCESSOR}>{self.MESSAGE_TYPE}", 'requests') self._offset = Conf.get(SSPL_CONF, f"{self.PROCESSOR}>{self.OFFSET}", 'earliest')
def _init_config(self): """Read config for messaging bus.""" # Make methods locally available self._node_id = Conf.get(GLOBAL_CONF, NODE_ID_KEY, 'SN01') self._consumer_group_prefix = Conf.get( SSPL_CONF, f"{self.PROCESSOR}>{self.CONSUMER_GROUP_PREFIX}", 'cortx_monitor') self._consumer_group = self._consumer_group_prefix + "_" + str(self._node_id) self._consumer_id = Conf.get(SSPL_CONF, f"{self.PROCESSOR}>{self.CONSUMER_ID}", 'sspl_actuator') self._message_type = Conf.get(SSPL_CONF, f"{self.PROCESSOR}>{self.MESSAGE_TYPE}", 'requests') self._offset = Conf.get(SSPL_CONF, f"{self.PROCESSOR}>{self.OFFSET}", 'earliest')
def test_bmc_config(args): """Check if BMC configuration are valid. Testing BMC config with ipmitool is possible only when ipmi over lan is configured(out-band setup). It is taken care by test_bmc_is_accessible. So, validation on bmc onfiguration with bmc ip, user and secret value through ssh is fine at this time. """ bmc_ip = Conf.get(GLOBAL_CONF, BMC_IP_KEY) bmc_user = Conf.get(GLOBAL_CONF, BMC_USER_KEY) bmc_secret = Conf.get(GLOBAL_CONF, BMC_SECRET_KEY) bmc_key = Cipher.generate_key(MACHINE_ID, "server_node") bmc_passwd = Cipher.decrypt(bmc_key, bmc_secret.encode("utf-8")).decode("utf-8") # check BMC ip, user, password are valid session = SSHChannel(bmc_ip, bmc_user, bmc_passwd) session.disconnect()
def _read_config(self): """Configure the RabbitMQ exchange with defaults available""" # Make methods locally available self._node_id = Conf.get(SSPL_TEST_CONF, f"{CLUSTER}>{SRVNODE}>{self.NODE_ID_KEY}", 'SN01') self._consumer_id = Conf.get(SSPL_TEST_CONF, f"{self.RABBITMQPROCESSORTEST}>{self.CONSUMER_ID}", 'sspl_actuator') self._consumer_group = Conf.get(SSPL_TEST_CONF, f"{self.RABBITMQPROCESSORTEST}>{self.CONSUMER_GROUP}", 'cortx_monitor') self._message_type = Conf.get(SSPL_TEST_CONF, f"{self.RABBITMQPROCESSORTEST}>{self.MESSAGE_TYPE}", 'Requests') self._offset = Conf.get(SSPL_TEST_CONF, f"{self.RABBITMQPROCESSORTEST}>{self.OFFSET}", 'earliest')
def initialize(self, conf_reader, msgQlist, product): """initialize configuration reader and internal msg queues""" # Initialize ScheduledMonitorThread and InternalMsgQ super(RAIDsensor, self).initialize(conf_reader) # Initialize internal message queues for this module super(RAIDsensor, self).initialize_msgQ(msgQlist) self._RAID_status_file = self._get_RAID_status_file() logger.info(f"Monitoring RAID status file: {self._RAID_status_file}") # The status file contents self._RAID_status_contents = "N/A" # The mdX status line in the status file self._RAID_status = {} self._faulty_drive_list = {} self._faulty_device_list = {} self._drives = {} self._total_drives = {} self._devices = [] self._missing_drv = {} self._prev_drive_dict = {} self._site_id = Conf.get(GLOBAL_CONF, f"{CLUSTER}>{SRVNODE}>{self.SITE_ID}", 'DC01') self._rack_id = Conf.get(GLOBAL_CONF, f"{CLUSTER}>{SRVNODE}>{self.RACK_ID}", 'RC01') self._node_id = Conf.get(GLOBAL_CONF, f"{CLUSTER}>{SRVNODE}>{self.NODE_ID}", 'SN01') self._cluster_id = Conf.get(GLOBAL_CONF, f"{CLUSTER}>{self.CLUSTER_ID}", 'CC01') # Allow systemd to process all the drives so we can map device name to serial numbers #time.sleep(120) return True
def load_server_fru_list(self): """Get Server FRU list and merge it with server_fru_list, maintained in global config, with which FRU list can be extended for a solution. Ex: Supermicro servers not listing disk as FRU, though its most common FRU in servers, and practically it can be replaced easily. So if for a solution, FRU list needs to be extended beyond what server publishes, 'server_fru_list' from global config can be used. Some of the usual FRU examples are:- disk, psu. """ cmd = 'fru list' self.fru_list = [] output, err, rc = self._run_ipmitool_subcommand( cmd, grep_args="FRU Device Description : ") if rc != 0: logger.error("Failed in fetching FRU info from server." f"Error:{err}") if output: for line in output.split('\n'): self.fru_list.append(line.split(': ')[1]) keywords = ['Pwr Supply', 'power', 'PS', 'PSU'] fru_regex = re.compile("|".join(keywords)) for fru in self.fru_list: if fru_regex.search(fru): self.fru_list[self.fru_list.index(fru)] = 'psu' self.fru_list = list(set(self.fru_list)) try: self.hot_swapped_frus = Conf.get( GLOBAL_CONF, "server_node>server_fru_list>hot_swappable", ['disk', 'psu']) self.cold_swapped_frus = Conf.get(GLOBAL_CONF, "server_node>server_fru_list", []) except ValueError as e: logger.error("Failed to get server_fru_list from config." f"Error:{e}") self.fru_list = list( set(self.fru_list + self.hot_swapped_frus + self.cold_swapped_frus)) logger.info(f"Fetched server FRU list:{self.fru_list}")
def __init__(self): """Initialize server manifest.""" super().__init__() self.log = CustomLog(MANIFEST_SVC_NAME) server_type = Conf.get(GLOBAL_CONF, NODE_TYPE_KEY) # import pdb; pdb.set_trace() Platform.validate_server_type_support(self.log, ResourceMapError, server_type) self.field_mapping = { 'id': 'uid', 'class': 'type', 'description': 'description', 'product': 'product', 'serial': 'serial_number', 'vendor': 'manufacturer', 'part_number': 'part_number', 'model_number': 'model_number', 'physid': 'physical_id', 'version': 'version', 'logicalname': 'logical_name' } self.class_mapping = { 'memory': 'hw>memory[%s]>%s', 'disk': 'hw>disk[%s]>%s', 'storage': 'hw>storage[%s]>%s', 'system': 'hw>system[%s]>%s', 'processor': 'hw>cpu[%s]>%s', 'network': 'hw>nw_port[%s]>%s', 'power': 'hw>psu[%s]>%s', 'volume': 'hw>volume[%s]>%s', 'bus': 'hw>bus[%s]>%s', 'bridge': 'hw>bridge[%s]>%s', 'display': 'hw>display[%s]>%s', 'input': 'hw>input[%s]>%s', 'generic': 'hw>generic[%s]>%s' } self.kv_dict = {} sw_resources = { 'os': self.get_os_server_info, 'cortx_sw_services': self.get_cortx_service_info, 'external_sw_services': self.get_external_service_info } fw_resources = {'bmc': self.get_bmc_version_info} # Extracting resource type for 'self.class_mapping' dictionary values # and adding to hw_resources for function mapping. hw_resources = {value[len('hw>'):-len('[%s]>%s')]: \ self.get_hw_resources_info for value in self.class_mapping.values()} self.server_resources = { "hw": hw_resources, "sw": sw_resources, "fw": fw_resources } self.service = Service() self.platform = Platform() self.resource_indexing_map = ServerResourceMap.resource_indexing_map\ ["manifest"]