Ejemplo n.º 1
0
class ConfigCmd(Cmd):
    """Configures message bus and sspl sensor monitor state."""

    name = "config"

    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)

    @staticmethod
    def add_args(parser: str, cls: str, name: str):
        """Add Command args for parsing."""
        parsers = parser.add_parser(cls.name, help='%s' % cls.__doc__)
        parsers.add_argument('args', nargs='*', default=[], help='args')
        parsers.add_argument('--config',
                             nargs='*',
                             default=[],
                             help='Global config url')
        parsers.set_defaults(command=cls)

    def validate(self):
        """Validate config command arguments."""
        if not self.args.config:
            msg = "%s - Argument validation failure. %s" % (
                self.name, "Global config URL is required.")
            logger.error(msg)
            raise SetupError(errno.EINVAL, msg)
        # Validate config inputs
        Conf.load(PRVSNR_CONFIG_INDEX, self.args.config[0])
        self.sspl_config.validate()
        logger.info("%s - validation done" % self.name)

    def process(self):
        """Setup SSPL configuration."""
        self.copy_input_config()
        self.sspl_config.process()
        logger.info("%s - Process done" % self.name)
Ejemplo n.º 2
0
 def process(self):
     """Setup SSPL configuration"""
     from files.opt.seagate.sspl.setup.sspl_config import SSPLConfig
     sspl_config = SSPLConfig()
     sspl_config.validate()
     sspl_config.process()
Ejemplo n.º 3
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)
Ejemplo n.º 4
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()