def validate(self): """Check for required packages are installed.""" # RPM dependency rpm_deps = {"cortx-sspl-test": None} # python 3rd party package dependency pip3_3ps_packages_test = {"Flask": "1.1.1"} pkg_validator = PkgV() pkg_validator.validate_pip3_pkgs(host=socket.getfqdn(), pkgs=pip3_3ps_packages_test, skip_version_check=False) pkg_validator.validate_rpm_pkgs(host=socket.getfqdn(), pkgs=rpm_deps, skip_version_check=True) # Load global, sspl and test configs Conf.load(SSPL_CONFIG_INDEX, sspl_config_path) Conf.load(SSPL_TEST_CONFIG_INDEX, sspl_test_config_path) # Take copy of supplied config passed to sspl_test and load it with open(self.sspl_test_gc_copy_file, "w") as f: f.write("") self.sspl_test_gc_copy_url = "yaml://%s" % self.sspl_test_gc_copy_file Conf.load(SSPL_TEST_GLOBAL_CONFIG, self.sspl_test_gc_copy_url) Conf.load("global_config", self.sspl_test_gc_url) Conf.copy("global_config", SSPL_TEST_GLOBAL_CONFIG) # Validate input configs machine_id = Utility.get_machine_id() self.node_type = Conf.get(SSPL_TEST_GLOBAL_CONFIG, "server_node>%s>type" % machine_id) enclosure_id = Conf.get( SSPL_TEST_GLOBAL_CONFIG, "server_node>%s>storage>enclosure_id" % machine_id) self.enclosure_type = Conf.get( SSPL_TEST_GLOBAL_CONFIG, "storage_enclosure>%s>type" % enclosure_id)
def validate(self): """Check for below requirement. 1. Validate input configs 2. Validate sspl conf is created 3. Check if message bus is accessible """ if os.geteuid() != 0: msg = "Run this command with root privileges." logger.error(msg) raise SetupError(errno.EINVAL, msg) # Validate input/provisioner configs machine_id = Utility.get_machine_id() Utility.get_config_value(consts.PRVSNR_CONFIG_INDEX, "server_node>%s>cluster_id" % machine_id) self.node_type = Utility.get_config_value( consts.PRVSNR_CONFIG_INDEX, "server_node>%s>type" % machine_id) enclosure_id = Utility.get_config_value( consts.PRVSNR_CONFIG_INDEX, "server_node>%s>storage>enclosure_id" % machine_id) self.enclosure_type = Utility.get_config_value( consts.PRVSNR_CONFIG_INDEX, "storage_enclosure>%s>type" % enclosure_id) # Validate sspl conf is created if not os.path.isfile(consts.file_store_config_path): msg = "Missing configuration - %s !! Create and rerun." % ( consts.file_store_config_path) logger.error(msg) raise SetupError(errno.EINVAL, msg) # Validate message bus is accessible self.mb = MessageBus()
def validate(self): """Check below requirements are met in setup. 1. Check if given product is supported by SSPL 2. Check if given setup is supported by SSPL 3. Check if required pre-requisites softwares are installed. 4. Validate BMC connectivity 5. Validate storage controller connectivity """ machine_id = Utility.get_machine_id() # Validate input/provisioner configs self.product = Utility.get_config_value(consts.PRVSNR_CONFIG_INDEX, "cortx>release>product") self.setup = Utility.get_config_value(consts.PRVSNR_CONFIG_INDEX, "cortx>release>setup") node_type = Utility.get_config_value( consts.PRVSNR_CONFIG_INDEX, "server_node>%s>type" % machine_id) if node_type.lower() not in ["vm", "virtual"]: bmc_ip = Utility.get_config_value( consts.PRVSNR_CONFIG_INDEX, "server_node>%s>bmc>ip" % machine_id) enclosure_id = Utility.get_config_value( consts.PRVSNR_CONFIG_INDEX, "server_node>%s>storage>enclosure_id" % machine_id) Utility.get_config_value(consts.PRVSNR_CONFIG_INDEX, "storage_enclosure>%s>type" % enclosure_id) primary_ip = Utility.get_config_value( consts.PRVSNR_CONFIG_INDEX, "storage_enclosure>%s>controller>primary>ip" % enclosure_id) secondary_ip = Utility.get_config_value( consts.PRVSNR_CONFIG_INDEX, "storage_enclosure>%s>controller>secondary>ip" % enclosure_id) # Validate product support if self.product not in consts.enabled_products: msg = "Product '%s' is not in sspl supported product list: %s" % ( self.product, consts.enabled_products) logger.error(msg) raise SetupError(errno.EINVAL, msg) # Validate setup support if self.setup not in consts.setups: msg = "Setup '%s' is not in sspl supported setup list: %s" % ( self.setup, consts.setups) logger.error(msg) raise SetupError(errno.EINVAL, msg) # Validate required pip3s and rpms are installed self.validate_dependencies(self.setup) # Validate BMC & Storage controller IP reachability if node_type.lower() not in ["vm", "virtual"]: # cluster_id required for decrypting the secret is only available from # the prepare stage. However accessibility validation will be done in # prepare stage. So at this time, validating ip reachability is fine. NetworkV().validate("connectivity", [bmc_ip, primary_ip, secondary_ip])
def validate(self): """Check for below requirement. 1. Validate if sspl-ll user exists 2. Validate input keys """ # Check sspl-ll user exists sspl_uid = Utility.get_uid(self.user) if sspl_uid == -1: msg = "User %s doesn't exist. Please add user." % self.user logger.error(msg) raise SetupError(errno.EINVAL, msg) # Check input/provisioner configs machine_id = Utility.get_machine_id() cluster_id = Utility.get_config_value( consts.PRVSNR_CONFIG_INDEX, "server_node>%s>cluster_id" % machine_id) Utility.get_config_value(consts.PRVSNR_CONFIG_INDEX, "cluster>%s>name" % cluster_id) Utility.get_config_value(consts.PRVSNR_CONFIG_INDEX, "cluster>%s>site_count" % cluster_id) storage_set_count = int( Utility.get_config_value( consts.PRVSNR_CONFIG_INDEX, "cluster>%s>site>storage_set_count" % cluster_id)) for i in range(storage_set_count): Utility.get_config_value( consts.PRVSNR_CONFIG_INDEX, "cluster>%s>storage_set[%s]>name" % (cluster_id, i)) Utility.get_config_value( consts.PRVSNR_CONFIG_INDEX, "cluster>%s>storage_set[%s]>server_nodes" % (cluster_id, i)) Utility.get_config_value( consts.PRVSNR_CONFIG_INDEX, "cluster>%s>storage_set[%s]>storage_enclosures" % (cluster_id, i))
def validate(self): """Check below requirements. 1. Validate input configs 2. Validate BMC connectivity 3. Validate storage controller connectivity 4. Validate network interface availability """ machine_id = Utility.get_machine_id() mgmt_interfaces = [] data_private_interfaces = [] data_public_interfaces = [] # Validate input/provisioner configs node_type = Utility.get_config_value( PRVSNR_CONFIG_INDEX, "server_node>%s>type" % machine_id) cluster_id = Utility.get_config_value( PRVSNR_CONFIG_INDEX, "server_node>%s>cluster_id" % machine_id) if node_type.lower() not in ["virtual", "vm"]: bmc_ip = Utility.get_config_value( PRVSNR_CONFIG_INDEX, "server_node>%s>bmc>ip" % machine_id) bmc_user = Utility.get_config_value( PRVSNR_CONFIG_INDEX, "server_node>%s>bmc>user" % machine_id) bmc_secret = Utility.get_config_value( PRVSNR_CONFIG_INDEX, "server_node>%s>bmc>secret" % machine_id) bmc_key = Cipher.generate_key(machine_id, ServiceTypes.SERVER_NODE.value) bmc_passwd = Cipher.decrypt( bmc_key, bmc_secret.encode("utf-8")).decode("utf-8") data_private_interfaces = Utility.get_config_value( PRVSNR_CONFIG_INDEX, "server_node>%s>network>data>private_interfaces" % machine_id) data_public_interfaces = Utility.get_config_value( PRVSNR_CONFIG_INDEX, "server_node>%s>network>data>public_interfaces" % machine_id) mgmt_public_fqdn = Utility.get_config_value( PRVSNR_CONFIG_INDEX, "server_node>%s>network>management>public_fqdn" % machine_id) mgmt_interfaces = Utility.get_config_value( PRVSNR_CONFIG_INDEX, "server_node>%s>network>management>interfaces" % machine_id) data_private_fqdn = Utility.get_config_value( PRVSNR_CONFIG_INDEX, "server_node>%s>network>data>private_fqdn" % machine_id) data_public_fqdn = Utility.get_config_value( PRVSNR_CONFIG_INDEX, "server_node>%s>network>data>public_fqdn" % machine_id) enclosure_id = Utility.get_config_value( PRVSNR_CONFIG_INDEX, "server_node>%s>storage>enclosure_id" % machine_id) primary_ip = Utility.get_config_value( PRVSNR_CONFIG_INDEX, "storage_enclosure>%s>controller>primary>ip" % enclosure_id) secondary_ip = Utility.get_config_value( PRVSNR_CONFIG_INDEX, "storage_enclosure>%s>controller>secondary>ip" % enclosure_id) cntrlr_user = Utility.get_config_value( PRVSNR_CONFIG_INDEX, "storage_enclosure>%s>controller>user" % enclosure_id) cntrlr_secret = Utility.get_config_value( PRVSNR_CONFIG_INDEX, "storage_enclosure>%s>controller>secret" % enclosure_id) cntrlr_key = Cipher.generate_key(enclosure_id, ServiceTypes.STORAGE_ENCLOSURE.value) cntrlr_passwd = Cipher.decrypt( cntrlr_key, cntrlr_secret.encode("utf-8")).decode("utf-8") # Validate BMC connectivity & storage controller accessibility if node_type.lower() not in ["virtual", "vm"]: NetworkV().validate("connectivity", [bmc_ip, primary_ip, secondary_ip]) BmcV().validate("accessible", [socket.getfqdn(), bmc_ip, bmc_user, bmc_passwd]) c_validator = ControllerV() c_validator.validate("accessible", [primary_ip, cntrlr_user, cntrlr_passwd]) c_validator.validate("accessible", [secondary_ip, cntrlr_user, cntrlr_passwd]) # Validate network fqdn reachability NetworkV().validate( "connectivity", [mgmt_public_fqdn, data_private_fqdn, data_public_fqdn]) # Validate network interface availability for i_list in [ mgmt_interfaces, data_private_interfaces, data_public_interfaces ]: self.validate_nw_cable_connection(i_list) self.validate_nw_interfaces(i_list)
NODE_TYPE = "node_type" SMART_TEST_INTERVAL = "smart_test_interval" SSPL_LOG_FILE_PATH = "sspl_log_file_path" STORAGE = "storage" STORAGE_SET_ID = "storage_set_id" STORE_TYPE = "store_type" THREADED = "threaded" TIMESTAMP_FILE_PATH = "timestamp_file_path" TRANSMIT_INTERVAL = "transmit_interval" TYPE = "type" UNITS = "units" USER = "******" USERNAME = "******" VIRTUAL_HOST = "virtual_host" TARGET_BUILD = "target_build" # Get SRVNODE and ENCLOSURE so it can be used in other files to get # server_node and enclosure specific config utility = Utility() MACHINE_ID = utility.get_machine_id() OPERATING_SYSTEM = utility.get_os() Conf.load(SSPL_CONF, "yaml:///etc/sspl.conf") global_config = Conf.get(SSPL_CONF, "SYSTEM_INFORMATION>global_config_copy_url") Conf.load(GLOBAL_CONF, global_config) SRVNODE = Conf.get(GLOBAL_CONF, f'{CLUSTER}>{SERVER_NODES}')[MACHINE_ID] ENCLOSURE = Conf.get(GLOBAL_CONF, f"{CLUSTER}>{SRVNODE}>{STORAGE}>{ENCLOSURE_ID}")
def validate(self): """Check for required packages are installed.""" # RPM dependency rpm_deps = {"cortx-sspl-test": None} # python 3rd party package dependency pip3_packages_dep = {"Flask": "1.1.1", "coverage": "5.5"} if not self.coverage_enabled: pip3_packages_dep.pop("coverage") # Validate pip3 python pkg with required version. for pkg, version in pip3_packages_dep.items(): installed_pkg = None uninstalled_pkg = False try: pkg_req = Requirement.parse(f"{pkg}=={version}") installed_pkg = working_set.find(pkg_req) except VersionConflict: cmd = f'pip3 uninstall -y {pkg}' _, err, ret = SimpleProcess(cmd).run() if ret: raise TestException( "Failed to uninstall the pip3 pkg: %s(v%s), " "due to an Error: %s" % (pkg, version, err)) uninstalled_pkg = True except Exception as err: raise TestException("Failed at verification of pip3 pkg: %s, " "due to an Error: %s" % (pkg, err)) if not installed_pkg or uninstalled_pkg: cmd = f'pip3 install {pkg}=={version}' _, err, ret = SimpleProcess(cmd).run() if ret: raise TestException( "Failed to install the pip3 pkg: %s(v%s), " "due to an Error: %s" % (pkg, version, err)) logger.info(f"Ensured Package Dependency: {pkg}(v{version}).") # Validate rpm dependencies pkg_validator = PkgV() pkg_validator.validate_rpm_pkgs(host=socket.getfqdn(), pkgs=rpm_deps, skip_version_check=True) # Load global, sspl and test configs Conf.load(SSPL_CONFIG_INDEX, sspl_config_path) Conf.load(SSPL_TEST_CONFIG_INDEX, sspl_test_config_path) # Take copy of supplied config passed to sspl_test and load it with open(self.sspl_test_gc_copy_file, "w") as f: f.write("") self.sspl_test_gc_copy_url = "yaml://%s" % self.sspl_test_gc_copy_file Conf.load(SSPL_TEST_GLOBAL_CONFIG, self.sspl_test_gc_copy_url) Conf.load("global_config", self.sspl_test_gc_url) Conf.copy("global_config", SSPL_TEST_GLOBAL_CONFIG) # Validate input configs machine_id = Utility.get_machine_id() self.node_type = Conf.get(SSPL_TEST_GLOBAL_CONFIG, "server_node>%s>type" % machine_id) enclosure_id = Conf.get( SSPL_TEST_GLOBAL_CONFIG, "server_node>%s>storage>enclosure_id" % machine_id) self.enclosure_type = Conf.get( SSPL_TEST_GLOBAL_CONFIG, "storage_enclosure>%s>type" % enclosure_id)