def install_reqs(self): ans = input("Do you want me to try and fix that for you with the\ commands above? [yY/nN]: ") if ans.lower() == "y": process.execute_cmd(self.installation, self.args['hosts']) else: LOG.info("Fine then, have a nice day :)") sys.exit(2)
def run(self): """Execution docker-compose.""" try: cmds = self.vars['execute'] except KeyError: cmds = self.RUN if "hosts" in self.args: results = process.execute_cmd(commands=cmds, hosts=self.args['hosts'], cwd=self.execution_dir) else: results = process.execute_cmd(commands=cmds, cwd=self.execution_dir) [success_or_exit(res.exited) for res in results] return results
def main(args): """Runner main entry.""" if not args.scenario and not args.commands and not args.vars: LOG.error(missing_scenario_arg()) sys.exit(2) if args.scenario and not args.platform: args.platform = utils.guess_platform(args.scenario) if not args.commands and not args.scenario and not args.platform: success_or_exit( 1, "Couldn't figure out which platform to use. \ Please specify --platform") if not args.commands: Platform = getattr( importlib.import_module("infraform.platforms.{}".format( args.platform)), args.platform.capitalize()) platform = Platform(args=args) platform.prepare() platform.run() else: process.execute_cmd(args.commands, args.hosts)
def check_platform_avaiable(self): """Validates the platform specified is ready for use.""" results = process.execute_cmd(self.READINESS_CHECK, self.args['hosts'], warn_on_fail=True, hide_output=True) if not results or any(res.exited for res in results): LOG.error( req_exc.missing_reqs(self.installation, hosts=self.args['hosts'], failed_cmds=[ res.command for res in results if res.exited != 0 ])) self.install_reqs()
def run(self): process.execute_cmd(["chmod +x {}".format(self.scenario_f), "./{0}".format(self.scenario_f)])
def run(self): process.execute_cmd(['terraform apply'])
def prepare(self): process.execute_cmd(['terraform init'])