def load_sequences(): load_plugins() for plugin in Controller.get().get_all_plugins(): try: getattr(plugin, "init_sequences")() except AttributeError: LOG.debug("missing attribute: init_sequences in %s", plugin.__file__)
def load_plugins(): """ return if plugins already are loaded """ if Controller.get().get_all_plugins(): return path = "plugins" base_module = "clearstack.{0}".format(path) directory = "{0}/{1}".format(os.path.dirname( os.path.realpath(__file__)), path) rx_val = r'^[a-zA-Z]+_[0-9]{3}\.py$' files = [fd for fd in os.listdir(directory) if re.match(rx_val, fd)] for fd in sorted(files, key=_get_weight): plugin = import_module("{0}.{1}".format(base_module, fd.split(".")[0])) Controller.get().add_plugin(plugin) try: getattr(plugin, "init_config")() except AttributeError: LOG.debug("missing attribute: init_config in %s", plugin.__file__)
def main(self, argv): self.parser = self.get_base_parser() run_setup.add_arguments(self.parser) (options, args) = self.parser.parse_known_args(argv) utils.setup_debugging(options.debug) LOG.debug('Starting clearstack') if not argv or options.help: self.do_help(options) return 0 if options.gen_keys: LOG.debug('generating ssh keys') utils.generate_ssh_keys(options.gen_keys) # todo: fix # if options.allinone: # LOG.debug('testing root access') # if os.geteuid() != 0: # LOG.error("clearstack: error: you need to have root access") # sys.exit(1) """ Save user's variables, used to read/write answerfile """ variables_cmd = {k: v for (k, v) in options.__dict__.items() if v is not None and k.startswith("CONFIG_")} ansfile = AnswerFile.get() if options.gen_answer_file: LOG.debug('generating answer file') ansfile.generate(options.gen_answer_file, variables_cmd) if options.answer_file: try: LOG.debug('Reading answer file') ansfile.read(options.answer_file, variables_cmd) LOG.debug('Running all sequences') run_setup.run_all_sequences() except Exception as e: LOG.error("clearstack: {0}".format(str(e))) sys.exit(1) LOG.debug('Generating admin-openrc') run_setup.generate_admin_openrc()