def take_action(self, parsed_args): self.log.debug("take_action(%s)" % parsed_args) clients = self.app.client_manager stack = oooutils.get_stack(clients.orchestration, parsed_args.stack) stack_name = stack.stack_name # In case of update and upgrade we need to force the # update_plan_only. The heat stack update is done by the # packag_update mistral action parsed_args.update_plan_only = True # Add the update-prepare.yaml environment to set noops etc templates_dir = (parsed_args.templates or constants.TRIPLEO_HEAT_TEMPLATES) parsed_args.environment_files = oooutils.prepend_environment( parsed_args.environment_files, templates_dir, constants.UPDATE_PREPARE_ENV) # Throw deprecation warning if service is enabled and # ask user if update should still be continued. if parsed_args.environment_files: oooutils.check_deprecated_service_is_enabled( parsed_args.environment_files) super(UpdatePrepare, self).take_action(parsed_args) package_update.update(clients, container=stack_name) oooutils.get_config( clients, container=stack_name, container_config='{}-config'.format(stack.stack_name)) self.log.info("Update init on stack {0} complete.".format( parsed_args.stack))
def take_action(self, parsed_args): self.log.debug("take_action(%s)" % parsed_args) oooutils.ffwd_upgrade_operator_confirm(parsed_args.yes, self.log) clients = self.app.client_manager stack = oooutils.get_stack(clients.orchestration, parsed_args.stack) stack_name = stack.stack_name # In case of update and upgrade we need to force the # update_plan_only. The heat stack update is done by the # packag_update mistral action parsed_args.update_plan_only = True # Add the prepare environment into the args to unset noop etc templates_dir = (parsed_args.templates or constants.TRIPLEO_HEAT_TEMPLATES) if not parsed_args.environment_files: parsed_args.environment_files = [] parsed_args.environment_files = oooutils.prepend_environment( parsed_args.environment_files, templates_dir, constants.FFWD_UPGRADE_PREPARE_ENV) super(FFWDUpgradePrepare, self).take_action(parsed_args) package_update.update(clients, container=stack_name) oooutils.get_config( clients, container=stack_name, container_config='{}-config'.format(stack.stack_name)) overcloudrcs = deployment.create_overcloudrc( clients, container=stack_name) oooutils.write_overcloudrc(stack_name, overcloudrcs) # refresh stack info and enable ssh admin for Ansible-via-Mistral stack = oooutils.get_stack(clients.orchestration, parsed_args.stack) deployment.get_hosts_and_enable_ssh_admin( stack, parsed_args.overcloud_ssh_network, parsed_args.overcloud_ssh_user, self.get_key_pair(parsed_args), parsed_args.overcloud_ssh_port_timeout, verbosity=oooutils.playbook_verbosity(self=self) ) self.log.info("FFWD Upgrade Prepare on stack {0} complete.".format( parsed_args.stack))
def take_action(self, parsed_args): self.log.debug("take_action(%s)" % parsed_args) # Throw deprecation warning if service is enabled and # ask user if upgrade should still be continued. if parsed_args.environment_files: oooutils.check_deprecated_service_is_enabled( parsed_args.environment_files) clients = self.app.client_manager stack = oooutils.get_stack(clients.orchestration, parsed_args.stack) stack_name = stack.stack_name # In case of update and upgrade we need to force the # update_plan_only. The heat stack update is done by the # packag_update mistral action parsed_args.update_plan_only = True # Add the upgrade-prepare.yaml environment to set noops etc templates_dir = (parsed_args.templates or constants.TRIPLEO_HEAT_TEMPLATES) parsed_args.environment_files = oooutils.prepend_environment( parsed_args.environment_files, templates_dir, constants.UPGRADE_PREPARE_ENV) super(UpgradePrepare, self).take_action(parsed_args) package_update.update(clients, container=stack_name) oooutils.get_config(clients, container=stack_name, container_config='{}-config'.format( stack.stack_name)) overcloudrcs = deployment.create_overcloudrc(clients, container=stack_name) oooutils.write_overcloudrc(stack_name, overcloudrcs) # refresh stack info and enable ssh admin for Ansible-via-Mistral stack = oooutils.get_stack(clients.orchestration, parsed_args.stack) deployment.get_hosts_and_enable_ssh_admin( stack, parsed_args.overcloud_ssh_network, parsed_args.overcloud_ssh_user, self.get_key_pair(parsed_args), parsed_args.overcloud_ssh_port_timeout, verbosity=oooutils.playbook_verbosity(self=self)) self.log.info("Completed Overcloud Upgrade Prepare for stack " "{0}".format(stack_name))
def config_download(log, clients, stack, ssh_network=None, output_dir=None, override_ansible_cfg=None, timeout=600, verbosity=0, deployment_options=None, in_flight_validations=False, ansible_playbook_name='deploy_steps_playbook.yaml', limit_hosts=None, extra_vars=None, inventory_path=None, ssh_user='******', tags=None, skip_tags=None, deployment_timeout=None): """Run config download. :param log: Logging object :type log: Object :param clients: openstack clients :type clients: Object :param stack: Heat Stack object :type stack: Object :param ssh_network: Network named used to access the overcloud. :type ssh_network: String :param output_dir: Path to the output directory. :type output_dir: String :param override_ansible_cfg: Ansible configuration file location. :type override_ansible_cfg: String :param timeout: Ansible connection timeout in seconds. :type timeout: Integer :param verbosity: Ansible verbosity level. :type verbosity: Integer :param deployment_options: Additional deployment options. :type deployment_options: Dictionary :param in_flight_validations: Enable or Disable inflight validations. :type in_flight_validations: Boolean :param ansible_playbook_name: Name of the playbook to execute. :type ansible_playbook_name: String :param limit_hosts: String of hosts to limit the current playbook to. :type limit_hosts: String :param extra_vars: Set additional variables as a Dict or the absolute path of a JSON or YAML file type. :type extra_vars: Either a Dict or the absolute path of JSON or YAML :param inventory_path: Inventory file or path, if None is provided this function will perform a lookup :type inventory_path: String :param ssh_user: SSH user, defaults to tripleo-admin. :type ssh_user: String :param tags: Ansible inclusion tags. :type tags: String :param skip_tags: Ansible exclusion tags. :type skip_tags: String :param deployment_timeout: Deployment timeout in minutes. :type deployment_timeout: Integer """ def _log_and_print(message, logger, level='info', print_msg=True): """Print and log a given message. :param message: Message to print and log. :type message: String :param log: Logging object :type log: Object :param level: Log level. :type level: String :param print_msg: Print messages to stdout. :type print_msg: Boolean """ if print_msg: print(message) log = getattr(logger, level) log(message) if not output_dir: output_dir = DEFAULT_WORK_DIR if not deployment_options: deployment_options = dict() if not in_flight_validations: if skip_tags: skip_tags = 'opendev-validation,{}'.format(skip_tags) else: skip_tags = 'opendev-validation' with utils.TempDirs() as tmp: utils.run_ansible_playbook(playbook='cli-grant-local-access.yaml', inventory='localhost,', workdir=tmp, playbook_dir=ANSIBLE_TRIPLEO_PLAYBOOKS, verbosity=verbosity, extra_vars={ 'access_path': output_dir, 'execution_user': getpass.getuser() }) stack_work_dir = os.path.join(output_dir, stack.stack_name) context = clients.tripleoclient.create_mistral_context() _log_and_print( message='Checking for blacklisted hosts from stack: {}'.format( stack.stack_name), logger=log, print_msg=(verbosity == 0)) blacklist_show = stack.output_show('BlacklistedHostnames') blacklist_stack_output = blacklist_show.get('output', dict()) blacklist_stack_output_value = blacklist_stack_output.get('output_value') if blacklist_stack_output_value: if not limit_hosts: limit_hosts = "" limit_hosts += (':'.join( ['!{}'.format(i) for i in blacklist_stack_output_value if i])) _log_and_print(message='Retrieving configuration for stack: {}'.format( stack.stack_name), logger=log, print_msg=(verbosity == 0)) container_config = '{}-config'.format(stack.stack_name) utils.get_config(clients, container=stack.stack_name, container_config=container_config) _log_and_print(message='Downloading configuration for stack: {}'.format( stack.stack_name), logger=log, print_msg=(verbosity == 0)) download = config.DownloadConfigAction(work_dir=stack_work_dir, container_config=container_config) work_dir = download.run(context=context) _log_and_print(message='Retrieving keyfile for stack: {}'.format( stack.stack_name), logger=log, print_msg=(verbosity == 0)) key_file = utils.get_key(stack=stack.stack_name) _log_and_print(message='Generating information for stack: {}'.format( stack.stack_name), logger=log, print_msg=(verbosity == 0)) inventory_kwargs = { 'ansible_ssh_user': ssh_user, 'work_dir': work_dir, 'plan_name': stack.stack_name, 'undercloud_key_file': key_file } if ssh_network: inventory_kwargs['ssh_network'] = ssh_network python_interpreter = deployment_options.get('ansible_python_interpreter') if python_interpreter: inventory_kwargs['ansible_python_interpreter'] = python_interpreter if not inventory_path: inventory = ansible.AnsibleGenerateInventoryAction(**inventory_kwargs) inventory_path = inventory.run(context=context) _log_and_print( message='Executing deployment playbook for stack: {}'.format( stack.stack_name), logger=log, print_msg=(verbosity == 0)) if isinstance(ansible_playbook_name, list): playbooks = [ os.path.join(stack_work_dir, p) for p in ansible_playbook_name ] else: playbooks = os.path.join(stack_work_dir, ansible_playbook_name) with utils.TempDirs() as tmp: utils.run_ansible_playbook( playbook=playbooks, inventory=inventory_path, workdir=tmp, playbook_dir=work_dir, skip_tags=skip_tags, tags=tags, ansible_cfg=override_ansible_cfg, verbosity=verbosity, ssh_user=ssh_user, key=key_file, limit_hosts=limit_hosts, ansible_timeout=timeout, reproduce_command=True, extra_env_variables={ 'ANSIBLE_BECOME': True, }, extra_vars=extra_vars, timeout=deployment_timeout, ) _log_and_print( message='Overcloud configuration completed for stack: {}'.format( stack.stack_name), logger=log, print_msg=(verbosity == 0))