def _validate_args(parsed_args, playbooks): """Validate Kayobe Ansible arguments.""" vault.validate_args(parsed_args) result = utils.is_readable_dir(parsed_args.config_path) if not result["result"]: LOG.error("Kayobe configuration path %s is invalid: %s", parsed_args.config_path, result["message"]) sys.exit(1) env_path = _get_kayobe_environment_path(parsed_args) if env_path: result = utils.is_readable_dir(env_path) if not result["result"]: LOG.error("Kayobe environment %s is invalid: %s", env_path, result["message"]) sys.exit(1) inventories = _get_inventories_paths(parsed_args, env_path) for inventory in inventories: result = utils.is_readable_dir(inventory) if not result["result"]: LOG.error("Kayobe inventory %s is invalid: %s", inventory, result["message"]) sys.exit(1) for playbook in playbooks: result = utils.is_readable_file(playbook) if not result["result"]: LOG.error("Kayobe playbook %s is invalid: %s", playbook, result["message"]) sys.exit(1)
def _validate_args(parsed_args, inventory_filename): """Validate Kayobe Ansible arguments.""" vault.validate_args(parsed_args) result = utils.is_readable_dir(parsed_args.kolla_config_path) if not result["result"]: LOG.error("Kolla configuration path %s is invalid: %s", parsed_args.kolla_config_path, result["message"]) sys.exit(1) inventory = _get_inventory_path(parsed_args, inventory_filename) result = utils.is_readable_dir(parsed_args.kolla_venv) if not result["result"]: # NOTE(mgoddard): Previously the inventory was a file, now it is a # directory to allow us to support inventory host_vars. Support both # formats for now. result_f = utils.is_readable_file(inventory) if not result_f["result"]: LOG.error("Kolla inventory %s is invalid: %s", inventory, result["message"]) sys.exit(1) result = utils.is_readable_dir(parsed_args.kolla_venv) if not result["result"]: LOG.error("Kolla virtualenv %s is invalid: %s", parsed_args.kolla_venv, result["message"]) sys.exit(1)
def test_validate_args_env(self): parser = argparse.ArgumentParser() vault.add_args(parser) parsed_args = parser.parse_args([]) vault.validate_args(parsed_args)