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 create_kayobe_environment(parsed_args): """Create a new Kayobe environment.""" if not parsed_args.environment: LOG.error("You must specify an environment to create") sys.exit(1) # Ensure environments directory exists and is readable inside config path kc_environments = os.path.join(parsed_args.config_path, "environments") result = utils.is_readable_dir(kc_environments) if not result["result"]: if result["message"] == "Path does not exist": os.mkdir(kc_environments) else: LOG.error("Kayobe global environments directory %s is invalid: %s", kc_environments, result["message"]) sys.exit(1) env_path = os.path.join(kc_environments, parsed_args.environment) result = utils.is_readable_dir(env_path) if result["result"]: LOG.error("Kayobe environment directory %s already exists", env_path) sys.exit(1) else: if result["message"] == "Path does not exist": os.mkdir(env_path) else: LOG.error("Kayobe environment directory %s is invalid: %s", env_path, result["message"]) sys.exit(1) source_config_path = parsed_args.source_config_path if source_config_path: utils.copy_dir(source_config_path, env_path)
def _validate_args(parsed_args, inventory_filename): """Validate Kayobe Ansible arguments.""" 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_file(inventory) if not result["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 _validate_args(parsed_args, inventory_filename): """Validate Kayobe Ansible arguments.""" 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_file(inventory) if not result["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 _validate_args(parsed_args, playbooks): """Validate Kayobe Ansible arguments.""" 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) inventory = _get_inventory_path(parsed_args) 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, playbooks): """Validate Kayobe Ansible arguments.""" 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) inventory = _get_inventory_path(parsed_args) 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)