def process(self): """Configure SSPL at prepare stage.""" # Update sspl.conf with provisioner supplied input config copy Conf.set( consts.SSPL_CONFIG_INDEX, "SYSTEM_INFORMATION>global_config_copy_url", consts.global_config_path) Conf.save(consts.SSPL_CONFIG_INDEX)
def update_ldap_credentials(self): """Update ldap credentials (rootdn, sgiam) to openldap_config file.""" try: # Load the openldap config file index_id = 'openldap_config_file_write_index' Conf.load(index_id, f'yaml://{self.openldap_config_file}') # get the rootdn credentials from provisoner config file # set the rootdn credentials in to openldap_config file ldap_root_user = self.get_confvalue( self.get_confkey('CONFIG>CONFSTORE_ROOTDN_USER_KEY')) encrypted_rootdn_pass = self.get_confvalue( self.get_confkey('CONFIG>CONFSTORE_ROOTDN_PASSWD_KEY')) if encrypted_rootdn_pass is None: Log.error('rootdn password cannot be None.') raise Exception('rootdn password cannot be None.') Conf.set(index_id, f'{self.rootdn_user_key}', f'{ldap_root_user}') Conf.set(index_id, f'{self.rootdn_pass_key}', f'{encrypted_rootdn_pass}') # save openldap config file Conf.save(index_id) except Exception as e: Log.error(f'update rootdn credentials failed, error: {e}') raise Exception(f'update rootdn credentials failed, error: {e}')
def upgrade(config_path: str, change_set_path: str): """Perform upgrade steps.""" Conf.load(DELTA_INDEX, change_set_path) Conf.load(GCONF_INDEX, config_path, skip_reload=True) delta_keys = Conf.get_keys(DELTA_INDEX) # if message_bus_backend changed, add new and delete old msg bus entries if CHANGED_PREFIX + MSG_BUS_BACKEND_KEY in delta_keys: new_msg_bus_backend = Conf.get( DELTA_INDEX, CHANGED_PREFIX + MSG_BUS_BACKEND_KEY).split('|')[1] Conf.set(GCONF_INDEX, MSG_BUS_BACKEND_KEY, new_msg_bus_backend) for key in delta_keys: if NEW_PREFIX + EXTERNAL_KEY + new_msg_bus_backend in key: new_key = key.split(NEW_PREFIX)[1] new_val = Conf.get(DELTA_INDEX, key).split('|')[1] Conf.set(GCONF_INDEX, new_key, new_val) if DELETED_PREFIX + EXTERNAL_KEY + new_msg_bus_backend in key: delete_key = key.split(DELETED_PREFIX)[1] Conf.delete(GCONF_INDEX, delete_key) # update existing messagebus parameters else: msg_bus_backend = Conf.get(GCONF_INDEX, MSG_BUS_BACKEND_KEY) for key in delta_keys: if CHANGED_PREFIX + EXTERNAL_KEY + msg_bus_backend in key: new_val = Conf.get(DELTA_INDEX, key).split('|')[1] change_key = key.split(CHANGED_PREFIX)[1] Conf.set(GCONF_INDEX, change_key, new_val) Conf.save(GCONF_INDEX) Utils.init(config_path) return 0
def run(self): """Prepare confstore in factory. cortx_setup prepare_confstore """ template_file_path = str(CONFSTORE_CLUSTER_FILE.parent / 'factory_confstore_template') Conf.load('node_config_index', f'json://{CONFSTORE_CLUSTER_FILE}') StateFunExecuter.execute( 'file.managed', fun_kwargs=dict( name=template_file_path, source= 'salt://components/system/files/factory_confstore_template.j2', template='jinja')) template_data = "" with open(template_file_path, 'r') as f: template_data = f.read().splitlines() for data in template_data: if data: key, value = data.split("=") Conf.set('node_config_index', key, value) Conf.save('node_config_index') self.logger.debug("Done")
def _create_msg_bus_config(kafka_server_list, port_list): """ Create the config file required for message bus """ from cortx.utils.conf_store import Conf with open(r'/etc/cortx/message_bus.conf.new', 'w+') as file: json.dump({}, file, indent=2) Conf.load("index", "json:///etc/cortx/message_bus.conf.new") Conf.set("index", "message_broker>type", "kafka") for i in range(len(kafka_server_list)): Conf.set("index", f"message_broker>cluster[{i}]", \ {"server": kafka_server_list[i], "port": port_list[i]}) Conf.save("index") # copy this conf file as message_bus.conf cmd = "/bin/mv /etc/cortx/message_bus.conf.new" + \ " /etc/cortx/message_bus.conf" try: cmd_proc = SimpleProcess(cmd) res_op, res_err, res_rc = cmd_proc.run() if res_rc != 0: raise SetupError(errno.EIO, \ "/etc/cortx/message_bus.conf file creation failed, \ rc = %d", res_rc) except Exception as e: raise SetupError(errno.EIO, \ "/etc/cortx/message_bus.conf file creation failed, %s", e) return res_rc
def update_sensor_info(config_index, node_type, enclosure_type): """Enable or disable sensor monitoring based on node_type and enclosure_type. """ sensors = dict() sensors["REALSTORSENSORS"] = "true" sensors["NODEHWSENSOR"] = "true" sensors["DISKMONITOR"] = "true" sensors["SERVICEMONITOR"] = "true" sensors["RAIDSENSOR"] = "true" sensors["RAIDINTEGRITYSENSOR"] = "true" sensors["SASPORTSENSOR"] = "true" sensors["MEMFAULTSENSOR"] = "true" sensors["CPUFAULTSENSOR"] = "true" if enclosure_type and enclosure_type.lower() in ["virtual", "vm", "jbod"]: sensors["REALSTORSENSORS"] = "false" if node_type and node_type.lower() in ["virtual", "vm"]: sensors["NODEHWSENSOR"] = "false" sensors["SASPORTSENSOR"] = "false" sensors["MEMFAULTSENSOR"] = "false" sensors["CPUFAULTSENSOR"] = "false" sensors["RAIDSENSOR"] = "false" sensors["RAIDINTEGRITYSENSOR"] = "false" # Update sensor information in config for sect, value in sensors.items(): Conf.set(config_index, '%s>monitor' % sect, value) Conf.save(config_index)
def test_conf_store_merge_02no_key(self): Conf.set('src_index', 'new_key', 'new_value') Conf.save('src_index') Conf.merge('dest_index', 'src_index') Conf.save('dest_index') self.assertEqual(Conf.get('dest_index', 'new_key'), 'new_value') self.assertIn('new_key', Conf.get_keys('dest_index'))
def _copy_cluster_map(url_index: str): cluster_data = Conf.get(url_index, 'server_node') for _, node_data in cluster_data.items(): hostname = node_data.get('hostname') node_name = node_data.get('name') Conf.set('cluster', f'cluster>{node_name}', hostname) Conf.save('cluster')
def update_motr_hare_keys_for_all_nodes(self): hostname = self.server_node["hostname"] nodes_info = Conf.get(self._index, 'server_node') for value in nodes_info.values(): host = value["hostname"] cvg_count = value["storage"]["cvg_count"] name = value["name"] self.logger.info(f"update_motr_hare_keys for {host}\n") for i in range(int(cvg_count)): lv_md_name = f"lv_raw_md{i + 1}" cmd = (f"ssh {host}" f" lvs -o lv_path | grep {lv_md_name}") res = execute_command(self, cmd) lv_path = res[0].rstrip("\n") Conf.set(self._index_motr_hare, f"server>{name}>cvg[{i}]>m0d[0]>md_seg1", f"{lv_path.strip()}") Conf.save(self._index_motr_hare) for value in nodes_info.values(): if (hostname == value["hostname"]): continue else: host = value["hostname"] cmd = (f"scp {self._motr_hare_conf}" f" {host}:{self._motr_hare_conf}") execute_command(self, cmd)
def setUp(self): base_config = "low-level/files/opt/seagate/sspl/conf/sspl.conf.LR2.yaml" base_config = os.path.dirname(os.path.abspath(__file__)).replace( "unittests/framework/base", base_config) base_config_url = f"yaml://{base_config}" self.tmp_dir = "/opt/seagate/cortx/sspl/tmp" self.existing_config = f"/{self.tmp_dir}/existing.conf" self.new_config = f"/{self.tmp_dir}/new.conf" self.merged_config = f"/{self.tmp_dir}/merged.conf" os.makedirs(self.tmp_dir, exist_ok=True) with open(self.existing_config, "w"): pass with open(self.new_config, "w"): pass self.existing_config_url = f"yaml://{self.existing_config}" self.new_config_url = f"yaml://{self.new_config}" self.merged_config_url = f"yaml://{self.merged_config}" Conf.load("base", base_config_url) Conf.load("existing", self.existing_config_url) Conf.load("new", self.new_config_url) # Delete below keys to get clean config Conf.delete("base", "CHANGED") Conf.delete("base", "OBSOLETE") # Create exising and new config file from base file Conf.copy("base", "existing") Conf.copy("base", "new") Conf.save("existing") Conf.save("new")
def _copy_cluster_map(config_path: str): Conf.load('cluster', config_path, skip_reload=True) cluster_data = Conf.get('cluster', 'node') for _, node_data in cluster_data.items(): hostname = node_data.get('hostname') node_name = node_data.get('name') Conf.set('cluster', f'cluster>{node_name}', hostname) Conf.save('cluster')
def test_conf_store_merge_03already_key(self): Conf.set('dest_index', 'cortx>software>kafka>servers[0]', 'host2.com') Conf.save('dest_index') Conf.set('src_index', 'cortx>software>kafka>servers[0]', 'host1.com') Conf.merge('dest_index', 'src_index') Conf.save('dest_index') self.assertEqual('host2.com', Conf.get('dest_index',\ 'cortx>software>kafka>servers[0]'))
def update_sensor_info(config_index): key = 'monitor' sensors = dict() sensors["REALSTORSENSORS"] = "true" sensors["NODEHWSENSOR"] = "true" sensors["DISKMONITOR"] = "true" sensors["SERVICEMONITOR"] = "true" sensors["RAIDSENSOR"] = "true" sensors["SASPORTSENSOR"] = "true" sensors["MEMFAULTSENSOR"] = "true" sensors["CPUFAULTSENSOR"] = "true" try: with open("/etc/machine-id") as f: machine_id = f.read().strip("\n") except Exception as err: raise SetupError(1, "Failed to get machine-id. - %s" % (err)) srvnode = Conf.get(GLOBAL_CONFIG_INDEX, "cluster>server_nodes>%s" % (machine_id)) enclosure_id = Conf.get(GLOBAL_CONFIG_INDEX, "cluster>%s>storage>enclosure_id" % (srvnode)) node_key_id = Conf.get(GLOBAL_CONFIG_INDEX, 'cluster>server_nodes>%s' % (machine_id)) storage_type = Conf.get(GLOBAL_CONFIG_INDEX, 'storage>%s>type' % enclosure_id) if storage_type and storage_type.lower() in ["virtual", "jbod"]: sensors["REALSTORSENSORS"] = "false" server_type = Conf.get(GLOBAL_CONFIG_INDEX, 'cluster>%s>node_type' % (node_key_id)) if server_type and server_type.lower() in ["virtual"]: sensors["NODEHWSENSOR"] = "false" sensors["SASPORTSENSOR"] = "false" sensors["MEMFAULTSENSOR"] = "false" sensors["CPUFAULTSENSOR"] = "false" sensors["RAIDSENSOR"] = "false" # Onward LDR_R2, consul will be abstracted out and it won't exit as hard dependeny of SSPL # Note: SSPL has backward compatibility to LDR_R1 and there consul is a dependency of SSPL. if SSPL_STORE_TYPE == "consul": host = os.getenv('CONSUL_HOST', CONSUL_HOST) port = os.getenv('CONSUL_PORT', CONSUL_PORT) try: consul_conn = consul.Consul(host=host, port=port) for sect, value in sensors.items(): consul_conn.kv.put("sspl/config/%s/monitor" % sect, value) except Exception as cerror: print("Error in connecting with consul: {}".format(cerror)) # Update sensor information in config for sect, value in sensors.items(): Conf.set(config_index, '%s>%s' % (sect, key), value) Conf.save(config_index)
def test_conf_store_by_wrong_value(self): """ Test by setting the wrong value to given key. """ Conf.set('pro_local', 'studio_location', '=amritsar') Conf.save('pro_local') try: load_config('pro_local1', 'properties:///tmp/example.properties') except Exception as err: self.assertEqual('Invalid properties store format %s. %s.', err.args[1])
def delete(args): """ Deletes given set of keys from the config """ key_list = args.args[0].split(';') is_deleted = [] for key in key_list: status = Conf.delete(ConfCli._index, key) is_deleted.append(status) if any(is_deleted): Conf.save(ConfCli._index)
def update_sensor_info(): key = 'monitor' sensors = dict() sensors["REALSTORSENSORS"] = "true" sensors["NODEHWSENSOR"] = "true" sensors["SYSTEMDWATCHDOG"] = "true" sensors["RAIDSENSOR"] = "true" sensors["SASPORTSENSOR"] = "true" sensors["MEMFAULTSENSOR"] = "true" sensors["CPUFAULTSENSOR"] = "true" try: with open("/etc/machine-id") as f: node_key_id = f.read().strip("\n") except Exception as err: print("Failed to get machine-id. - %s" % (err)) storage_type = Conf.get('global_config', 'storage>enclosure_1>type') if storage_type and storage_type.lower() in ["virtual", "jbod"]: sensors["REALSTORSENSORS"] = "false" server_type = Conf.get('global_config', 'cluster>%s>node_type' % (node_key_id)) if server_type and server_type.lower() in ["virtual"]: sensors["NODEHWSENSOR"] = "false" sensors["SASPORTSENSOR"] = "false" sensors["MEMFAULTSENSOR"] = "false" sensors["CPUFAULTSENSOR"] = "false" sensors["RAIDSENSOR"] = "false" for sect, value in sensors.items(): Conf.set('sspl', '%s>%s' % (sect, key), value) Conf.save('sspl') # Onward LDR_R2, consul will be abstracted out and it won't exit as hard dependeny of SSPL # Note: SSPL has backward compatibility to LDR_R1 and there consul is a dependency of SSPL. if SSPL_STORE_TYPE == "consul": host = os.getenv('CONSUL_HOST', CONSUL_HOST) port = os.getenv('CONSUL_PORT', CONSUL_PORT) try: consul_conn = consul.Consul(host=host, port=port) for sect, value in sensors.items(): consul_conn.kv.put("sspl/config/%s/monitor" % sect, value) except Exception as cerror: print("Error in connecting with consul: {}".format(cerror)) # Update sensor information for sspl_test test_file_config_path = "/opt/seagate/%s/sspl/sspl_test/conf/sspl_tests.conf" % PRODUCT_FAMILY Conf.load('sspl_test', 'yaml://%s' % test_file_config_path) for sect, value in sensors.items(): Conf.set('sspl_test', '%s>%s' % (sect, key), value) Conf.save('sspl_test')
def set(args): """ Set Key Value """ kv_list = args.args[0].split(';') for kv in kv_list: try: key, val = kv.split('=') except: raise ConfError(errno.EINVAL, "Invalid KV pair %s", kv) Conf.set(ConfCli._index, key, val) Conf.save(ConfCli._index)
def _add_version_info(_conf_idx: str, node_id): """Add version in confstore.""" version = CortxProvisioner.cortx_release.get_release_version() Conf.set(_conf_idx, 'cortx>common>release>version', version) Conf.set(_conf_idx, f'node>{node_id}>provisioning>version', version) # TODO: Remove the following sdection when gconf is completely moved to consul CortxProvisioner._load_consul_conf(CortxProvisioner._cortx_gconf_consul_index) Conf.set(CortxProvisioner._cortx_gconf_consul_index, 'cortx>common>release>version', version) Conf.set(CortxProvisioner._cortx_gconf_consul_index, f'node>{node_id}>provisioning>version', version) Conf.save(CortxProvisioner._cortx_gconf_consul_index)
def test_conf_store_a_backup_and_save_a_copy(self): """Test by creating a backup file and copying then saving it back.""" conf_file = 'json:/tmp/file1.json' load_config('csm_local', conf_file) Conf.load('backup', f"{conf_file}.bak") Conf.copy('csm_local', 'backup') Conf.save('backup') result_data = Conf.get_keys('backup', key_index=True) # Expected list should match the result_data list output expected_list = Conf.get_keys('csm_local') self.assertListEqual(expected_list, result_data)
def _provision_components(cortx_conf_url: str, _conf_idx: str, interfaces: Enum, apply_phase: str): """Invoke Mini Provisioners of cluster components.""" node_id, _ = CortxProvisioner._get_node_info(_conf_idx) num_components = int(Conf.get(_conf_idx, f'node>{node_id}>num_components')) for interface in interfaces: for comp_idx in range(0, num_components): key_prefix = f'node>{node_id}>components[{comp_idx}]' component_name = Conf.get(_conf_idx, f'{key_prefix}>name') # Check if RPM exists for the component, if it does exist get the build version component_version = CortxProvisioner.cortx_release.get_component_version( component_name) # Get services. service_idx = 0 services = [] while (Conf.get(_conf_idx, f'{key_prefix}>services[{service_idx}]') is not None): services.append(Conf.get(_conf_idx, f'{key_prefix}>services[{service_idx}]')) service_idx = service_idx + 1 service = 'all' if service_idx == 0 else ','.join(services) if apply_phase == ProvisionerStages.UPGRADE.value: version = Conf.get(_conf_idx, f'{key_prefix}>version') # Skip update for component if it is already updated. is_updated = CortxProvisioner._is_component_updated(component_name, version) if is_updated is True: Log.info(f'{component_name} is already updated with {version} version.') continue CortxProvisioner._update_provisioning_status( _conf_idx, node_id, apply_phase, ProvisionerStatus.PROGRESS.value) if interface.value == 'upgrade': # TODO: add --changeset parameter once all components support config upgrade cmd = ( f"/opt/seagate/cortx/{component_name}/bin/{component_name}_setup {interface.value}" f" --config {cortx_conf_url} --services {service}") else: cmd = ( f"/opt/seagate/cortx/{component_name}/bin/{component_name}_setup {interface.value}" f" --config {cortx_conf_url} --services {service}") Log.info(f"{cmd}") cmd_proc = SimpleProcess(cmd) _, err, rc = cmd_proc.run() if rc != 0: CortxProvisioner._update_provisioning_status( _conf_idx, node_id, apply_phase, ProvisionerStatus.ERROR.value) raise CortxProvisionerError( rc, "%s phase of %s, failed. %s", interface.value, component_name, err) # Update version for each component if Provisioning successful. Conf.set(_conf_idx, f'{key_prefix}>version', component_version) # TODO: Remove the following code when gconf is completely moved to consul. CortxProvisioner._load_consul_conf(CortxProvisioner._cortx_gconf_consul_index) Conf.set(CortxProvisioner._cortx_gconf_consul_index, f'{key_prefix}>version', component_version) Conf.save(CortxProvisioner._cortx_gconf_consul_index)
def test_removed_key_should_be_absent_in_config(self): Conf.set("existing", "FOO", {"bar": "qux", "eggs": "ham"}) Conf.set("existing", "OBSOLETE[0]", "FOO>bar") Conf.save("existing") Conf.set("new", "FOO", {"eggs": "ham"}) Conf.save("new") conf_upgrade = ConfUpgrade(self.existing_config_url, self.new_config_url, self.merged_config_url) conf_upgrade.create_merged_config() Conf.load("merged", self.merged_config_url) self.assertIsNone(Conf.get("merged", "FOO>bar"))
def run(self, key=None, value=None): """signature set command execution method. (Specific only to current(given) node.) Sets LR signature. Execution: `cortx_setup signature set --key key --value value` """ try: # Move this definition to common config file lr_sign_file = Path("/etc/node-signature.yaml") index = "signature" # Remove additional trailing spaces if value: value = value.strip() if not (key and value): raise ValueError( "A valid signature is mandatory to set for stamping. " "Expected Signature params format: --key 'key' --value 'value'." ) if not (lr_sign_file.exists() and lr_sign_file.stat().st_size != 0): self.logger.warning("Node Signature was never set " "in ConfStore. Setting now.") else: # Immutable file. Make it editable first. _cmd = f"chattr -i {lr_sign_file}" subprocess.Popen(_cmd, shell=True) # nosec # This step takes a second to process. sleep(1) Conf.load(index, f'yaml://{lr_sign_file}') Conf.set(index, f'signature>{key}', f'{value}') Conf.save(index) # TODO: check if this signature data # should be written to grains and in what format. # Make the file immutable to any editing _cmd = f"chattr +i {lr_sign_file} && lsattr {lr_sign_file}" subprocess.Popen(_cmd, shell=True) # nosec return f"Node Stamping done and '{key}' is set as '{value}' in Signature" except Exception as exc: raise ValueError("Failed to set node signature: %s" % str(exc))
def set(args): """ Set Key Value """ kv_delim = '=' if args.kv_delim == None else args.kv_delim if len(kv_delim) > 1 or kv_delim not in [':', '>', '.', '|', '/', '=']: raise ConfError(errno.EINVAL, "invalid delim %s", kv_delim) kv_list = args.args[0].split(';') for kv in kv_list: try: key, val = kv.split(kv_delim, 1) except: raise ConfError(errno.EINVAL, "Invalid KV pair %s", kv) Conf.set(ConfCli._index, key, val) Conf.save(ConfCli._index)
def dump_global_config(self): """Dump provisioner global config and load it.""" url_spec = urlparse(self.global_config_copy_url) path = url_spec.path store_loc = os.path.dirname(path) if not os.path.exists(store_loc): os.makedirs(store_loc) with open(path, "w") as f: f.write("") # Make copy of global config Conf.load(GLOBAL_CONFIG_INDEX, self.global_config_copy_url) Conf.copy(self.prvsnr_global_config, GLOBAL_CONFIG_INDEX) Conf.save(GLOBAL_CONFIG_INDEX)
def setup_and_generate_sample_files(): """Generate all required types of file.""" with open(r'/tmp/file1.json', 'w+') as file: json.dump(sample_config, file, indent=2) with open(r'/tmp/example.properties', 'w+') as file: sample_config.update(sample_config['bridge']) for key, val in sample_config.items(): file.write("%s = %s\n" % (key, val)) # create conf sample for conf merge Conf.load('merge_index', 'yaml:///tmp/test_conf_merge.conf.sample') Conf.set('merge_index', 'cortx>software>common>message_bus_type', 'kafka') Conf.save('merge_index')
def copy_input_config(self, stage=None): """Dump input config in required format""" # Copy input config in another index url_spec = urlparse(global_config_path) path = url_spec.path store_loc = os.path.dirname(path) if not os.path.exists(store_loc): os.makedirs(store_loc) if not os.path.exists(path) or stage == "post_install": with open(path, "w") as f: f.write("") Conf.load(GLOBAL_CONFIG_INDEX, global_config_path) Conf.copy(PRVSNR_CONFIG_INDEX, GLOBAL_CONFIG_INDEX) Conf.save(GLOBAL_CONFIG_INDEX)
def test_conf_store_backup_and_save_a_copy(self): """Test by creating a backup file and copying then saving it back.""" conf_file = 'json:/tmp/file1.json' load_config('csm_local', conf_file) Conf.load('backup', f"{conf_file}.bak") Conf.copy('csm_local', 'backup') Conf.save('backup') result_data = Conf.get_keys('backup') # Expected list should match the result_data list output expected_list = [ 'bridge>name', 'bridge>username', 'bridge>manufacturer', 'bridge>model', 'bridge>pin', 'bridge>port', 'bridge>lte_type[0]', 'bridge>lte_type[1]' ] self.assertListEqual(expected_list, result_data)
def test_changed_key_should_be_replaced_in_config(self): Conf.set("existing", "FOO>bar", "spam") Conf.save("existing") Conf.set("new", "FOOBAR>bar", "spam") Conf.set("new", "CHANGED[0]>FOO", "FOOBAR") Conf.save("new") conf_upgrade = ConfUpgrade(self.existing_config_url, self.new_config_url, self.merged_config_url) conf_upgrade.create_merged_config() Conf.load("merged", self.merged_config_url) self.assertIsNone(Conf.get("merged", "FOO")) self.assertIsNotNone(Conf.get("merged", "FOOBAR")) self.assertEqual(Conf.get("existing", "FOO>bar"), Conf.get("merged", "FOOBAR>bar"))
def process(self): """Configure SSPL logs and service based on config.""" # Copy and load product specific sspl config if not os.path.exists(file_store_config_path): shutil.copyfile( "%s/conf/sspl.conf.%s.yaml" % (SSPL_BASE_DIR, self.PRODUCT_NAME), file_store_config_path) # Global config copy path in sspl.conf will be referred by sspl-ll service later. Conf.load(SSPL_CONFIG_INDEX, sspl_config_path) Conf.set(SSPL_CONFIG_INDEX, "SYSTEM_INFORMATION>global_config_url", self.global_config_url) Conf.set(SSPL_CONFIG_INDEX, "SYSTEM_INFORMATION>global_config_copy_url", self.global_config_copy_url) Conf.save(SSPL_CONFIG_INDEX) environ = Conf.get(SSPL_CONFIG_INDEX, "SYSTEM_INFORMATION>environment") if environ == "DEV": self.ENVIRONMENT = environ # sspl_setup_consul script install consul in dev env and checks if consul process is running # on prod. For node replacement scenario consul will not be running on the new node. But, # there will be two instance of consul running on healthy node. When new node is configured # consul will be brought back on it. We are using VIP to connect to consul. So, if consul # is not running on new node, we dont need to error out. So, need to skip this step for # node replacement case # TODO: Need to avoid LDR in CORTX and check if we can use "CORTXr1" # Onward LR2, consul will be abstracted out and it won't exit as hard dependeny of SSPL if self.PRODUCT_NAME == "LDR_R1": # setup consul if not running already if not os.path.exists(REPLACEMENT_NODE_ENV_VAR_FILE): sspl_setup_consul = "%s/sspl_setup_consul -e %s" % ( self._script_dir, self.ENVIRONMENT) output, error, returncode = SimpleProcess( sspl_setup_consul).run() if returncode != 0: raise SetupError(returncode, error, sspl_setup_consul) # Install packages which are not available in YUM repo, from PIP pip_cmd = "python3 -m pip install -r %s/low-level/requirements.txt" % ( SSPL_BASE_DIR) output, error, returncode = SimpleProcess(pip_cmd).run() if returncode != 0: raise SetupError(returncode, error, pip_cmd) # Splitting current function into 2 functions to reduce the complexity of the code. self.install_files(self.PRODUCT_NAME)
def _create_cluster_config(server_info: dict): """ Create the config file required for Event Message """ with open(r'/etc/cortx/cluster.conf.sample', 'w+') as file: json.dump({}, file, indent=2) Conf.load('cluster', 'json:///etc/cortx/cluster.conf.sample') for key, value in server_info.items(): Conf.set('cluster', f'server_node>{key}', value) Conf.save('cluster') # copy this conf file as cluster.conf try: os.rename('/etc/cortx/cluster.conf.sample', \ '/etc/cortx/cluster.conf') except OSError as e: raise SetupError(e.errno, "Failed to create /etc/cortx/cluster.conf\ %s", e)