def _configure_exchange(self, retry=False): """Configure the RabbitMQ exchange with defaults available""" try: self._virtual_host = self._conf_reader._get_value_with_default( self.LOGGINGPROCESSOR, self.VIRT_HOST, 'SSPL') self._exchange_name = self._conf_reader._get_value_with_default( self.LOGGINGPROCESSOR, self.EXCHANGE_NAME, 'sspl-in') self._queue_name = self._conf_reader._get_value_with_default( self.LOGGINGPROCESSOR, self.QUEUE_NAME, 'iem-queue') self._routing_key = self._conf_reader._get_value_with_default( self.LOGGINGPROCESSOR, self.ROUTING_KEY, 'iem-key') self._username = self._conf_reader._get_value_with_default( self.LOGGINGPROCESSOR, self.USER_NAME, 'sspluser') self._password = self._conf_reader._get_value_with_default( self.LOGGINGPROCESSOR, self.PASSWORD, 'sspl4ever') cluster_id = self._conf_reader._get_value_with_default( self.SYSTEM_INFORMATION_KEY, COMMON_CONFIGS.get(self.SYSTEM_INFORMATION_KEY).get( self.CLUSTER_ID_KEY), '') # Decrypt RabbitMQ Password decryption_key = encryptor.gen_key(cluster_id, ServiceTypes.RABBITMQ.value) self._password = encryptor.decrypt(decryption_key, self._password.encode('ascii'), "LoggingProcessor") self._connection = RabbitMQSafeConnection( self._username, self._password, self._virtual_host, self._exchange_name, self._routing_key, self._queue_name) except Exception as ex: logger.error("_configure_exchange: %s" % ex)
def _read_config(self): """Configure the RabbitMQ exchange with defaults available""" try: self._virtual_host = self._conf_reader._get_value_with_default( self.RABBITMQPROCESSOR, self.VIRT_HOST, 'SSPL') # Read common RabbitMQ configuration self._primary_rabbitmq_host = self._conf_reader._get_value_with_default( self.RABBITMQPROCESSOR, self.PRIMARY_RABBITMQ_HOST, 'localhost') # Read RabbitMQ configuration for sensor messages self._queue_name = self._conf_reader._get_value_with_default( self.RABBITMQPROCESSOR, self.QUEUE_NAME, 'sensor-queue') self._exchange_name = self._conf_reader._get_value_with_default( self.RABBITMQPROCESSOR, self.EXCHANGE_NAME, 'sspl-out') self._routing_key = self._conf_reader._get_value_with_default( self.RABBITMQPROCESSOR, self.ROUTING_KEY, 'sensor-key') # Read RabbitMQ configuration for Ack messages self._ack_queue_name = self._conf_reader._get_value_with_default( self.RABBITMQPROCESSOR, self.ACK_QUEUE_NAME, 'sensor-queue') self._ack_routing_key = self._conf_reader._get_value_with_default( self.RABBITMQPROCESSOR, self.ACK_ROUTING_KEY, 'sensor-key') self._username = self._conf_reader._get_value_with_default( self.RABBITMQPROCESSOR, self.USER_NAME, 'sspluser') self._password = self._conf_reader._get_value_with_default( self.RABBITMQPROCESSOR, self.PASSWORD, '') self._signature_user = self._conf_reader._get_value_with_default( self.RABBITMQPROCESSOR, self.SIGNATURE_USERNAME, 'sspl-ll') self._signature_token = self._conf_reader._get_value_with_default( self.RABBITMQPROCESSOR, self.SIGNATURE_TOKEN, 'FAKETOKEN1234') self._signature_expires = self._conf_reader._get_value_with_default( self.RABBITMQPROCESSOR, self.SIGNATURE_EXPIRES, "3600") self._iem_route_addr = self._conf_reader._get_value_with_default( self.RABBITMQPROCESSOR, self.IEM_ROUTE_ADDR, '') self._iem_route_exchange_name = self._conf_reader._get_value_with_default( self.RABBITMQPROCESSOR, self.IEM_ROUTE_EXCHANGE_NAME, 'sspl-in') cluster_id = self._conf_reader._get_value_with_default( self.SYSTEM_INFORMATION_KEY, COMMON_CONFIGS.get(self.SYSTEM_INFORMATION_KEY).get( self.CLUSTER_ID_KEY), '') # Decrypt RabbitMQ Password decryption_key = encryptor.gen_key(cluster_id, ServiceTypes.RABBITMQ.value) self._password = encryptor.decrypt(decryption_key, self._password.encode('ascii'), "RabbitMQegressProcessor") if self._iem_route_addr != "": logger.info(" Routing IEMs to host: %s" % self._iem_route_addr) logger.info(" Using IEM exchange: %s" % self._iem_route_exchange_name) except Exception as ex: logger.error("RabbitMQegressProcessor, _read_config: %r" % ex)
def __init__(self): super(RealStorEnclosure, self).__init__() # WS Request common headers self.ws = WebServices() self.common_reqheaders = {} self.encl_conf = self.CONF_SECTION_MC self.system_persistent_cache = self.encl_cache + "system/" self.faults_persistent_cache = self.system_persistent_cache + "faults.json" # Read in mc value from configuration file self.mc1 = Conf.get(GLOBAL_CONF, CNTRLR_PRIMARY_IP_KEY, self.DEFAULT_MC_IP) self.mc1_wsport = str( Conf.get(GLOBAL_CONF, CNTRLR_PRIMARY_PORT_KEY, '')) self.mc2 = Conf.get(GLOBAL_CONF, CNTRLR_SECONDARY_IP_KEY, self.DEFAULT_MC_IP) self.mc2_wsport = str( Conf.get(GLOBAL_CONF, CNTRLR_SECONDARY_PORT_KEY, '')) self.active_ip = self.mc1 self.active_wsport = self.mc1_wsport self.user = Conf.get(GLOBAL_CONF, CNTRLR_USER_KEY, self.DEFAULT_USER) _secret = Conf.get(GLOBAL_CONF, CNTRLR_SECRET_KEY, self.DEFAULT_PASSWD) self.mc_interface = Conf.get(SSPL_CONF, f"{STORAGE_ENCLOSURE}>{MGMT_INTERFACE}", "cliapi") self.pollfreq = int( Conf.get(SSPL_CONF, f"{self.CONF_REALSTORSENSORS}>{POLLING_FREQUENCY}", self.DEFAULT_POLL)) 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") # Decrypt MC secret decryption_key = encryptor.gen_key( ENCLOSURE, ServiceTypes.STORAGE_ENCLOSURE.value) self.__passwd = encryptor.decrypt(decryption_key, _secret, "RealStoreEncl") if self.mc_interface not in self.realstor_supported_interfaces: logger.error("Unspported Realstor interface configured," " monitoring and alerts generation may hamper") return # login to mc to get session key, required for querying resources # periodically self.login()
def _configure_exchange(self, retry=False): """Configure the RabbitMQ exchange with defaults available""" # Make methods locally available get_value_with_default = self._conf_reader._get_value_with_default try: self._virtual_host = get_value_with_default( self.RABBITMQPROCESSOR, self.VIRT_HOST, 'SSPL') self._primary_rabbitmq_host = get_value_with_default( self.RABBITMQPROCESSOR, self.PRIMARY_RABBITMQ_HOST, 'localhost') self._exchange_name = get_value_with_default( self.RABBITMQPROCESSOR, self.EXCHANGE_NAME, 'sspl-in') self._queue_name = get_value_with_default(self.RABBITMQPROCESSOR, self.QUEUE_NAME, 'actuator-req-queue') self._routing_key = get_value_with_default(self.RABBITMQPROCESSOR, self.ROUTING_KEY, 'actuator-req-key') self._username = get_value_with_default(self.RABBITMQPROCESSOR, self.USER_NAME, 'sspluser') self._password = get_value_with_default(self.RABBITMQPROCESSOR, self.PASSWORD, 'sspl4ever') cluster_id = get_value_with_default( self.SYSTEM_INFORMATION_KEY, COMMON_CONFIGS.get(self.SYSTEM_INFORMATION_KEY).get( self.CLUSTER_ID_KEY), '') node_id = get_value_with_default( self.SYSTEM_INFORMATION_KEY, COMMON_CONFIGS.get(self.SYSTEM_INFORMATION_KEY).get( self.NODE_ID_KEY), '') # Decrypt RabbitMQ Password decryption_key = encryptor.gen_key(cluster_id, ServiceTypes.RABBITMQ.value) self._password = encryptor.decrypt(decryption_key, self._password.encode('ascii'), "RabbitMQingressProcessor") # Create a routing key unique to this instance unique_routing_key = f'{self._routing_key}_node{node_id}' logger.info(f"Connecting using routing key: {unique_routing_key}") self._connection = RabbitMQSafeConnection( self._username, self._password, self._virtual_host, self._exchange_name, unique_routing_key, self._queue_name) except Exception as ex: logger.error("RabbitMQingressProcessor, _configure_exchange: %r" % ex)
def _configure_exchange(self, retry=False): """Configure the RabbitMQ exchange with defaults available""" # Make methods locally available try: self._virtual_host = Conf.get(SSPL_CONF, f"{self.RABBITMQPROCESSOR}>{self.VIRT_HOST}", 'SSPL') # Read common RabbitMQ configuration self._primary_rabbitmq_host = Conf.get(SSPL_CONF, f"{self.RABBITMQPROCESSOR}>{self.PRIMARY_RABBITMQ_HOST}", 'localhost') # Read RabbitMQ configuration for sensor messages self._queue_name = Conf.get(SSPL_CONF, f"{self.RABBITMQPROCESSOR}>{self.QUEUE_NAME}", 'actuator-req-queue') self._exchange_name = Conf.get(SSPL_CONF, f"{self.RABBITMQPROCESSOR}>{self.EXCHANGE_NAME}", 'sspl-in') self._routing_key = Conf.get(SSPL_CONF, f"{self.RABBITMQPROCESSOR}>{self.ROUTING_KEY}", 'actuator-req-key') self._username = Conf.get(SSPL_CONF, f"{self.RABBITMQPROCESSOR}>{self.USER_NAME}", 'sspluser') self._password = Conf.get(SSPL_CONF, f"{self.RABBITMQPROCESSOR}>{self.PASSWORD}",'') cluster_id = Conf.get(GLOBAL_CONF, f"{CLUSTER}>{self.CLUSTER_ID_KEY}",'CC01') node_id = Conf.get(GLOBAL_CONF, f"{CLUSTER}>{SRVNODE}>{self.NODE_ID_KEY}",'SN01') # Decrypt RabbitMQ Password decryption_key = encryptor.gen_key(cluster_id, ServiceTypes.RABBITMQ.value) self._password = encryptor.decrypt(decryption_key, self._password.encode('ascii'), "RabbitMQingressProcessor") # Create a routing key unique to this instance unique_routing_key = f'{self._routing_key}_node{node_id}' logger.info(f"Connecting using routing key: {unique_routing_key}") self._connection = RabbitMQSafeConnection( self._username, self._password, self._virtual_host, self._exchange_name, unique_routing_key, self._queue_name ) except Exception as ex: logger.error("RabbitMQingressProcessor, _configure_exchange: %r" % ex)
def _configure_exchange(self, retry=False): """Configure the RabbitMQ exchange with defaults available""" try: self._virtual_host = Conf.get( SSPL_CONF, f"{self.LOGGINGPROCESSOR}>{self.VIRT_HOST}", 'SSPL') self._exchange_name = Conf.get( SSPL_CONF, f"{self.LOGGINGPROCESSOR}>{self.EXCHANGE_NAME}", 'sspl-in') self._queue_name = Conf.get( SSPL_CONF, f"{self.LOGGINGPROCESSOR}>{self.QUEUE_NAME}", 'iem-queue') self._routing_key = Conf.get( SSPL_CONF, f"{self.LOGGINGPROCESSOR}>{self.ROUTING_KEY}", 'iem-key') self._username = Conf.get( SSPL_CONF, f"{self.LOGGINGPROCESSOR}>{self.USER_NAME}", 'sspluser') self._password = Conf.get( SSPL_CONF, f"{self.LOGGINGPROCESSOR}>{self.PASSWORD}", 'sspl4ever') cluster_id = Conf.get(GLOBAL_CONF, f"{CLUSTER}>{self.CLUSTER_ID_KEY}", 'CC01') # Decrypt RabbitMQ Password decryption_key = encryptor.gen_key(cluster_id, ServiceTypes.RABBITMQ.value) self._password = encryptor.decrypt(decryption_key, self._password.encode('ascii'), "LoggingProcessor") self._connection = RabbitMQSafeConnection( self._username, self._password, self._virtual_host, self._exchange_name, self._routing_key, self._queue_name) except Exception as ex: logger.error("_configure_exchange: %s" % ex)
def confReader(self): path_to_conf_file = "/etc/sspl.conf" try: conf_reader = ConfigReader(is_test=True, test_config_path=path_to_conf_file) except (IOError, ConfigReader.Error) as err: # We don't have logger yet, need to find log_level from conf file first print("[ Error ] when validating the configuration file %s :" % \ path_to_conf_file) print(err) print("Exiting ...") exit(os.EX_USAGE) self._virtualhost = conf_reader._get_value_with_default( self.module_name, self.VIRTUALHOST, 'SSPL') # Need to keep cluster_id string here to generate decryption key self.cluster_id = conf_reader._get_value_with_default( self.SYSTEM_INFORMATION, self.CLUSTER_ID, 'CC01') # Ingress configuration if self.module_name == "RABBITMQINGRESSPROCESSOR": # Configuration to send message self._ingress_queue = conf_reader._get_value_with_default( self.module_name, self.QUEUE_NAME, 'actuator-req-queue') self._ingress_exchange = conf_reader._get_value_with_default( self.module_name, self.EXCHANGE_NAME, 'sspl-in') self._ingress_key = conf_reader._get_value_with_default( self.module_name, self.ROUTINGKEY, 'actuator-req-key') # Configuration to recieve sensor messages self._egress_queue = conf_reader._get_value_with_default( 'RABBITMQEGRESSPROCESSOR', self.QUEUE_NAME, 'sensor-queue') self._egress_exchange = conf_reader._get_value_with_default( 'RABBITMQEGRESSPROCESSOR', self.EXCHANGE_NAME, 'sspl-out') self._egress_key = conf_reader._get_value_with_default( 'RABBITMQEGRESSPROCESSOR', self.ROUTINGKEY, 'sensor-key') elif self.module_name == "PLANECNTRLRMQINGRESSPROCESSOR": self._ingress_queue = conf_reader._get_value_with_default( self.module_name, self.QUEUE_NAME, 'ras_status') # Egress Queue if self.module_name == "RABBITMQEGRESSPROCESSOR": self._egress_queue = conf_reader._get_value_with_default( self.module_name, self.QUEUE_NAME, 'sensor-queue') elif self.module_name == "PLANECNTRLRMQEGRESSPROCESSOR": self._egress_queue = conf_reader._get_value_with_default( self.module_name, self.QUEUE_NAME, 'ras_control') self._ackexchangename = conf_reader._get_value_with_default( 'RABBITMQEGRESSPROCESSOR', self.ACKEXCHANGE_NAME, 'sspl-out') self._ackqueuename = conf_reader._get_value_with_default( 'RABBITMQEGRESSPROCESSOR', self.ACKQUEUE_NAME, 'actuator-resp-queue') self._ackroutingkey = conf_reader._get_value_with_default( 'RABBITMQEGRESSPROCESSOR', self.ACKROUTINGKEY, 'actuator-resp-key') self._exchangename = conf_reader._get_value_with_default( self.module_name, self.EXCHANGE_NAME, 'sspl-in') self._routingkey = conf_reader._get_value_with_default( self.module_name, self.ROUTINGKEY, 'sensor-key') self._username = conf_reader._get_value_with_default( self.module_name, self.USERNAME, 'sspluser') self._password = conf_reader._get_value_with_default( self.module_name, self.PASSWORD, 'sspl4ever') self._signature_user = conf_reader._get_value_with_default( 'RABBITMQEGRESSPROCESSOR', self.SIGNATURE_USERNAME, 'sspl-ll') self._signature_token = conf_reader._get_value_with_default( 'RABBITMQEGRESSPROCESSOR', self.SIGNATURE_TOKEN, 'ALOIUD986798df69a8koDISLKJ282983') self._signature_expires = conf_reader._get_value_with_default( 'RABBITMQEGRESSPROCESSOR', self.SIGNATURE_EXPIRES, "3600") if self.module_name == "PLANECNTRLRMQEGRESSPROCESSOR": self._primary_rabbitmq_server = conf_reader._get_value_with_default( self.module_name, self.PRIMARY_RABBITMQ, 'localhost') self._secondary_rabbitmq_server = conf_reader._get_value_with_default( self.module_name, self.SECONDARY_RABBITMQ, 'localhost') else: self._primary_rabbitmq_server = "localhost" self._secondary_rabbitmq_server = "localhost" decryption_key = encryptor.gen_key(self.cluster_id, ServiceTypes.RABBITMQ.value) self._password = encryptor.decrypt(decryption_key, self._password.encode('ascii'), "TestRabbitmqEgressProcessor") self._current_rabbitmq_server = self._primary_rabbitmq_server
def _run_ipmitool_subcommand(self, subcommand, grep_args=None): """Executes ipmitool sub-commands, and optionally greps the output.""" self.ACTIVE_IPMI_TOOL = self.IPMITOOL host_conf_cmd = "" # Set ipmitool to ipmisimtool if activated. if os.path.exists(f"{DATA_PATH}/server/activate_ipmisimtool"): cmd = self.IPMISIMTOOL + " sel info" _, _, retcode = SimpleProcess(cmd).run() if retcode in [0, 2]: self.ACTIVE_IPMI_TOOL = self.IPMISIMTOOL logger.debug("IPMI simulator is activated.") # Fetch channel info from config file and cache. _channel_interface = Conf.get( SSPL_CONF, "%s>%s" % (BMC_INTERFACE, BMC_CHANNEL_IF)) _active_interface = store.get(BMCInterface.ACTIVE_BMC_IF.value, None) if isinstance(_active_interface, bytes): _active_interface = _active_interface.decode() # Set host_conf_cmd based on channel info. if (self.ACTIVE_IPMI_TOOL != self.IPMISIMTOOL and _active_interface in BMCInterface.LAN_IF.value): bmc_ip = Conf.get(GLOBAL_CONF, BMC_IP_KEY, '') bmc_user = Conf.get(GLOBAL_CONF, BMC_USER_KEY, 'ADMIN') bmc_secret = Conf.get(GLOBAL_CONF, BMC_SECRET_KEY, 'ADMIN') decryption_key = encryptor.gen_key(MACHINE_ID, ServiceTypes.SERVER_NODE.value) bmc_pass = encryptor.decrypt(decryption_key, bmc_secret, self.NAME) host_conf_cmd = BMCInterface.LAN_CMD.value.format( _active_interface, bmc_ip, bmc_user, bmc_pass) # generate the final cmd and execute on shell. command = " ".join([self.ACTIVE_IPMI_TOOL, host_conf_cmd, subcommand]) command = shlex.split(command) out, error, retcode = SimpleProcess(command).run() # Decode bytes encoded strings. if not isinstance(out, str): out = out.decode(self.IPMI_ENCODING) if not isinstance(error, str): error = error.decode(self.IPMI_ENCODING) # Grep the output as per grep_args provided. if grep_args is not None and retcode == 0: final_list = [] for l in out.split('\n'): if re.search(grep_args, l) is not None: final_list += [l] out = '\n'.join(final_list) # Assign error_msg to err from output if retcode and not error: out, error = error, out # Remove '\n' from error, for matching errors to error stings. if error: error = error.replace('\n', '') return out, error, retcode
def __init__(self): super(RealStorEnclosure, self).__init__() # WS Request common headers self.ws = WebServices() self.common_reqheaders = {} self.encl_conf = self.CONF_SECTION_MC self.system_persistent_cache = self.encl_cache + "system/" self.faults_persistent_cache = self.system_persistent_cache + "faults.json" # Read in mc value from configuration file self.mc1 = self.conf_reader._get_value_with_default( self.encl_conf, COMMON_CONFIGS.get(self.encl_conf).get("primary_controller_ip"), self.DEFAULT_MC_IP) self.mc1_wsport = self.conf_reader._get_value_with_default( self.encl_conf, COMMON_CONFIGS.get(self.encl_conf).get("primary_controller_port"), '') self.mc2 = self.conf_reader._get_value_with_default( self.encl_conf, COMMON_CONFIGS.get(self.encl_conf).get("secondary_controller_ip"), self.DEFAULT_MC_IP) self.mc2_wsport = self.conf_reader._get_value_with_default( self.encl_conf, COMMON_CONFIGS.get( self.encl_conf).get("secondary_controller_port"), '') self.active_ip = self.mc1 self.active_wsport = self.mc1_wsport self.user = self.conf_reader._get_value_with_default( self.encl_conf, COMMON_CONFIGS.get(self.encl_conf).get("user"), self.DEFAULT_USER) self.passwd = self.conf_reader._get_value_with_default( self.encl_conf, COMMON_CONFIGS.get(self.encl_conf).get("password"), self.DEFAULT_PASSWD) self.mc_interface = self.conf_reader._get_value_with_default( self.encl_conf, COMMON_CONFIGS.get(self.encl_conf).get("mgmt_interface"), "cliapi") self.pollfreq = int( self.conf_reader._get_value_with_default(self.CONF_REALSTORSENSORS, "polling_frequency", self.DEFAULT_POLL)) self.site_id = self.conf_reader._get_value_with_default( self.SYSTEM_INFORMATION, COMMON_CONFIGS.get(self.SYSTEM_INFORMATION).get(self.SITE_ID), '001') self.rack_id = self.conf_reader._get_value_with_default( self.SYSTEM_INFORMATION, COMMON_CONFIGS.get(self.SYSTEM_INFORMATION).get(self.RACK_ID), '001') self.node_id = self.conf_reader._get_value_with_default( self.SYSTEM_INFORMATION, COMMON_CONFIGS.get(self.SYSTEM_INFORMATION).get(self.NODE_ID), '001') # Need to keep cluster_id string here to generate decryption key self.cluster_id = self.conf_reader._get_value_with_default( self.SYSTEM_INFORMATION, COMMON_CONFIGS.get(self.SYSTEM_INFORMATION).get(self.CLUSTER_ID), '001') # Decrypt MC Password decryption_key = encryptor.gen_key( self.cluster_id, ServiceTypes.STORAGE_ENCLOSURE.value) self.passwd = encryptor.decrypt(decryption_key, self.passwd.encode('ascii'), "RealStoreEncl") if self.mc_interface not in self.realstor_supported_interfaces: logger.error("Unspported Realstor interface configured," " monitoring and alerts generation may hamper") return # login to mc to get session key, required for querying resources # periodically self.login()
def __init__(self): super(RealStorEnclosure, self).__init__() # WS Request common headers self.ws = WebServices() self.common_reqheaders = {} self.encl_conf = self.CONF_SECTION_MC self.system_persistent_cache = self.encl_cache + "system/" self.faults_persistent_cache = self.system_persistent_cache + "faults.json" # Read in mc value from configuration file self.mc1 = Conf.get( GLOBAL_CONF, f"{STORAGE}>{ENCLOSURE}>{CONTROLLER}>{PRIMARY}>{IP}", self.DEFAULT_MC_IP) self.mc1_wsport = str( Conf.get(GLOBAL_CONF, f"{STORAGE}>{ENCLOSURE}>{CONTROLLER}>{PRIMARY}>{PORT}", '')) self.mc2 = Conf.get(GLOBAL_CONF, f"{STORAGE}>{ENCLOSURE}>{SECONDARY}>{IP}", self.DEFAULT_MC_IP) self.mc2_wsport = str( Conf.get(GLOBAL_CONF, f"{STORAGE}>{ENCLOSURE}>{CONTROLLER}>{SECONDARY}>{PORT}", '')) self.active_ip = self.mc1 self.active_wsport = self.mc1_wsport self.user = Conf.get(GLOBAL_CONF, f"{STORAGE}>{ENCLOSURE}>{CONTROLLER}>{USER}", self.DEFAULT_USER) self.passwd = Conf.get(GLOBAL_CONF, f"{STORAGE}>{ENCLOSURE}>{CONTROLLER}>{SECRET}", self.DEFAULT_PASSWD) self.mc_interface = Conf.get(SSPL_CONF, f"{STORAGE_ENCLOSURE}>{MGMT_INTERFACE}", "cliapi") self.pollfreq = int( Conf.get(SSPL_CONF, f"{self.CONF_REALSTORSENSORS}>{POLLING_FREQUENCY}", self.DEFAULT_POLL)) 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') # Need to keep cluster_id string here to generate decryption key self.cluster_id = Conf.get(GLOBAL_CONF, f"{CLUSTER}>{self.CLUSTER_ID}", 'CC01') # Decrypt MC Password decryption_key = encryptor.gen_key( self.cluster_id, ServiceTypes.STORAGE_ENCLOSURE.value) self.passwd = encryptor.decrypt(decryption_key, self.passwd.encode('ascii'), "RealStoreEncl") if self.mc_interface not in self.realstor_supported_interfaces: logger.error("Unspported Realstor interface configured," " monitoring and alerts generation may hamper") return # login to mc to get session key, required for querying resources # periodically self.login()
GLOBAL_CONF, Conf, ENCLOSURE, CNTRLR_PRIMARY_IP_KEY, CNTRLR_PRIMARY_PORT_KEY, CNTRLR_SECONDARY_IP_KEY, CNTRLR_SECONDARY_PORT_KEY, CNTRLR_USER_KEY, CNTRLR_SECRET_KEY, ENCLOSURE) from framework.utils.encryptor import gen_key, decrypt login_headers = {'datatype': 'json'} timeout = 20 HTTP_OK = 200 primary_ip = Conf.get(GLOBAL_CONF, CNTRLR_PRIMARY_IP_KEY) secondary_ip = Conf.get(GLOBAL_CONF, CNTRLR_SECONDARY_IP_KEY) primary_port = Conf.get(GLOBAL_CONF, CNTRLR_PRIMARY_PORT_KEY) secondary_port = Conf.get(GLOBAL_CONF, CNTRLR_SECONDARY_PORT_KEY) cntrlr_user = Conf.get(GLOBAL_CONF, CNTRLR_USER_KEY) cntrlr_secret = Conf.get(GLOBAL_CONF, CNTRLR_SECRET_KEY) cntrlr_key = gen_key(ENCLOSURE, "storage_enclosure") cntrlr_passwd = decrypt(cntrlr_key, cntrlr_secret) def show_system(ip, port, sessionKey): url = f"http://{ip}:{port}/api/show/system" # request headers for next request request_headers = {'datatype': 'json', 'sessionKey': sessionKey} # make the request response = requests.get(url, headers=request_headers, timeout=timeout) print(response) try: # process the response if response and response.status_code == HTTP_OK: jresponse = json.loads(response.content) if jresponse['status'][0]['return-code'] == 0: print(jresponse)