コード例 #1
0
 def __init__(self, args: dict):
     """Initialize post install command"""
     from files.opt.seagate.sspl.setup.sspl_post_install import (
         SSPLPostInstall)
     super().__init__(args)
     self.post_install = SSPLPostInstall()
     logger.info("%s - Init done" % self.name)
コード例 #2
0
    def validate(self):
        """Validate test command arguments."""
        if not self.args.config:
            msg = "%s - Argument validation failure. %s" % (
                self.name, "Global config is required.")
            logger.error(msg)
            raise SetupError(errno.EINVAL, msg)
        if not self.args.plan:
            msg = "%s - Argument validation failure. Test plan is needed" % (
                self.name)
            logger.error(msg)
            raise SetupError(errno.EINVAL, msg)
        result = PkgV().validate("rpms", "sspl-test")
        if result == -1:
            msg = "'sspl-test' rpm pkg not found."
            logger.error(msg)
            raise SetupError(1, msg)

        # Service restart is required for coverage.
        # Hence it can be enabled only with test plans
        # which are present in TEST_REQ_SERVICE_RESTART list.
        if self.args.coverage and self.args.plan[
                0] not in TEST_REQ_SERVICE_RESTART:
            msg = "Code coverage can not be enabled for %s test plan." \
                % self.args.plan[0]
            logger.error(msg)
            raise SetupError(errno.EINVAL,
                             "%s - Argument validation failure. %s", self.name,
                             msg)
        logger.info("%s - Validation done" % self.name)
コード例 #3
0
 def process(self):
     """Setup and run SSPL test"""
     from files.opt.seagate.sspl.setup.sspl_test import SSPLTestCmd
     sspl_test = SSPLTestCmd(self.args)
     sspl_test.validate()
     sspl_test.process()
     logger.info("%s - Process done" % self.name)
コード例 #4
0
 def process(self):
     logger.info(f"Nothing to be done for {self.name}.")
     if self.level == 'node':
         # No action needed
         pass
     elif self.level == 'cluster':
         # No action needed
         pass
コード例 #5
0
 def process(self):
     try:
         if os.path.exists(file_store_config_path):
             os.remove(file_store_config_path)
         shutil.copyfile(
             "%s/conf/sspl.conf.%s.yaml" % (SSPL_BASE_DIR, self.product),
             file_store_config_path)
         logger.info("%s - Process done" % self.name)
     except OSError as e:
         logger.error(f"Failed in Cleanup. ERROR: {e}")
コード例 #6
0
 def validate(self):
     """Validate init command arguments."""
     if not self.args.config:
         msg = "%s - Argument validation failure. %s" % (
             self.name, "Global config is required.")
         logger.error(msg)
         raise SetupError(errno.EINVAL, msg)
     # Validate config inputs
     Conf.load(PRVSNR_CONFIG_INDEX, self.args.config[0])
     self.sspl_init.validate()
     logger.info("%s - validation done" % self.name)
コード例 #7
0
 def process(self):
     args = ' '.join(self._args.args)
     manifest_support_bundle = "%s/%s %s" % (self._script_dir, self.script,
                                             args)
     _, error, rc = SimpleProcess(manifest_support_bundle).run(
         realtime_output=True)
     if rc != 0:
         msg = "%s - validation failure. %s" % (self.name, error)
         logger.error(msg)
         raise SetupError(rc, msg)
     logger.info("%s - Process done" % self.name)
コード例 #8
0
 def validate(self):
     # Validate config inputs
     from framework.utils.utility import Utility
     Conf.load(GLOBAL_CONFIG_INDEX, global_config_path)
     self.product = Utility.get_config_value(GLOBAL_CONFIG_INDEX,
                                             "cortx>release>product")
     if self.product is None:
         msg = "%s - validation failure. %s" % (
             self.name,
             "'Product' name is required to restore suitable configs.")
         logger.error(msg)
         raise SetupError(errno.EINVAL, msg)
     logger.info("%s - Validation done" % self.name)
コード例 #9
0
 def validate(self):
     # Common validator classes to check Cortx/system wide validator
     if not os.path.exists(self.SSPL_CONFIGURED):
         error = "SSPL is not configured. Run provisioner scripts in %s" % (
             self._script_dir)
         syslog.openlog(logoption=syslog.LOG_PID,
                        facility=syslog.LOG_LOCAL3)
         syslog.syslog(syslog.LOG_ERR, error)
         logger.error(error)
         raise SetupError(1, "%s - validation failure. %s", self.name,
                          error)
     # Validate required services are running
     retry = 3
     while retry > 0:
         try:
             ServiceV().validate('isrunning', self.services)
         except VError:
             retry -= 1
             time.sleep(5)
         else:
             break
     ServiceV().validate('isrunning', self.services)
     logger.info("%s - Validation done" % self.name)
コード例 #10
0
 def process(self):
     """Cleanup sspl config and log files."""
     from files.opt.seagate.sspl.setup.sspl_cleanup import SSPLCleanup
     sspl_cleanup = SSPLCleanup(self.args.args)
     sspl_cleanup.process(self.product)
     logger.info("%s - Process done" % self.name)
コード例 #11
0
 def process(self):
     from files.opt.seagate.sspl.setup.sspl_reset import Reset
     Reset().process()
     logger.info("%s - Process done" % self.name)
コード例 #12
0
    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)
コード例 #13
0
 def process(self):
     """Configure SSPL for prepare stage."""
     self.copy_input_config()
     self.prepare.process()
     logger.info("%s - Process done" % self.name)
コード例 #14
0
 def __init__(self, args):
     super().__init__(args)
     logger.info("%s - Init done" % self.name)
コード例 #15
0
    def cleanup_log_and_config():
        """--pre-factory cleanup : Cleanup logs, config files and
        undo everything whatever was done in post-install Mini-Provisioner
        Interface."""
        Conf.load(SSPL_CONFIG_INDEX, sspl_config_path)
        sspl_log_file_path = Utility.get_config_value(
            SSPL_CONFIG_INDEX, "SYSTEM_INFORMATION>sspl_log_file_path")
        iem_log_file_path = Utility.get_config_value(
            SSPL_CONFIG_INDEX, "IEMSENSOR>log_file_path")
        message_types = [
            Utility.get_config_value(SSPL_CONFIG_INDEX, "INGRESSPROCESSOR>message_type"),
            Utility.get_config_value(SSPL_CONFIG_INDEX, "EGRESSPROCESSOR>message_type")]

        # Directories and file which needs to deleted.
        directories = [
            f'/var/{PRODUCT_FAMILY}/sspl', f'/var/{PRODUCT_FAMILY}/iem/',
            f'/var/log/{PRODUCT_FAMILY}/sspl/', f'/var/log/{PRODUCT_FAMILY}/iem/',
            '/etc/sspl-ll/', f'{PRODUCT_BASE_DIR}/iem/iec_mapping']

        sspl_sudoers_file = '/etc/sudoers.d/sspl'
        sspl_dbus_policy_rules = '/etc/polkit-1/rules.d/sspl-ll_dbus_policy.rules'
        sspl_dbus_policy_conf = '/etc/dbus-1/system.d/sspl-ll_dbus_policy.conf'
        sspl_service_file = '/etc/systemd/system/sspl-ll.service'
        sspl_test_backup = '/etc/sspl_tests.conf.back'
        sspl_test_file_path = '/etc/sspl_test_gc_url.yaml'
        sspl_sb_log_file_path = sspl_log_file_path.replace(
            "/sspl.log", "/sspl_support_bundle.log")
        manifest_log_file_path = sspl_log_file_path.replace(
            "/sspl.log", "/manifest.log")

        # symlinks created during post_install
        sspl_ll_cli = "/usr/bin/sspl_ll_cli"

        # Remove SSPL config other config/log files which were
        # created during post_install.
        for filepath in [
                sspl_ll_cli, sspl_test_backup, sspl_test_file_path,
                file_store_config_path, global_config_file_path,
                sspl_log_file_path, iem_log_file_path, sspl_sb_log_file_path,
                manifest_log_file_path, RSYSLOG_IEM_CONF, IEM_LOGROTATE_CONF,
                sspl_dbus_policy_conf, sspl_dbus_policy_rules,
                sspl_sudoers_file, sspl_service_file]:
            FileStore().delete(filepath)

        # Delete directories which were created during post_install.
        for directory in directories:
            FileStore().delete(directory)
        logger.info("Deleted config/log files and directories.")

        # Delete sspl-ll user
        usernames = [x[0] for x in pwd.getpwall()]
        if USER in usernames:
            _, err, rc = SimpleProcess("/usr/sbin/userdel -f %s" % USER).run()
            if rc != 0:
                logger.info("Error occurref while deleteing %s user. ERROR: %s"
                    %(USER, err))
            else:
                logger.info("Deleted %s user." % USER)

        # Delete topic
        mbadmin = MessageBusAdmin(admin_id="admin")
        try:
            mbadmin.deregister_message_type(message_types)
            logger.info("Delete kafka %s topics." % message_types)
        except MessageBusError as e:
            logger.error(f"MessageBusError occurred while deleting topic:{e}")
コード例 #16
0
 def __init__(self, args):
     from files.opt.seagate.sspl.setup.sspl_setup_init import SSPLInit
     super().__init__(args)
     self.sspl_init = SSPLInit()
     logger.info("%s - Init done" % self.name)
コード例 #17
0
 def process(self):
     """Setup SSPL configuration."""
     self.copy_input_config()
     self.sspl_config.process()
     logger.info("%s - Process done" % self.name)
コード例 #18
0
 def __init__(self, args):
     """Initialize config command."""
     from files.opt.seagate.sspl.setup.sspl_config import SSPLConfig
     super().__init__(args)
     self.sspl_config = SSPLConfig()
     logger.info("%s - Init done" % self.name)
コード例 #19
0
 def process(self):
     logger.info(f"{self.name} interface not implemented.")
コード例 #20
0
 def process(self):
     """Perform SSPL post installation."""
     self.copy_input_config(stage=self.name)
     self.post_install.process()
     logger.info("%s - Process done" % self.name)
コード例 #21
0
 def process(self):
     """Configure SSPL init."""
     self.copy_input_config()
     self.sspl_init.process()
     logger.info("%s - Process done" % self.name)
コード例 #22
0
 def __init__(self, args: dict):
     """Initialize prepare command"""
     from files.opt.seagate.sspl.setup.sspl_prepare import SSPLPrepare
     super().__init__(args)
     self.prepare = SSPLPrepare()
     logger.info("%s - Init done" % self.name)