def take_action(self, parsed_args): self.log.debug("take_action(%s)" % parsed_args) self._setup_clients(parsed_args) # Swiftclient logs things like 404s at error level, which is a problem # because we use EAFP to check for the existence of files. Turn off # most swiftclient logging to avoid cluttering up our output with # pointless tracebacks. sc_logger = logging.getLogger("swiftclient") sc_logger.setLevel(logging.CRITICAL) self._validate_args(parsed_args) # Throw warning if deprecated service is enabled and # ask user if deployment should still be continued. if parsed_args.environment_files: utils.check_deprecated_service_is_enabled( parsed_args.environment_files) stack = utils.get_stack(self.orchestration_client, parsed_args.stack) self._update_parameters(parsed_args, stack) stack_create = stack is None if stack_create: self.log.info("No stack found, will be doing a stack create") else: self.log.info("Stack found, will be doing a stack update") if parsed_args.dry_run: print("Validation Finished") return start = time.time() if not parsed_args.config_download_only: self._deploy_tripleo_heat_templates_tmpdir(stack, parsed_args) # Get a new copy of the stack after stack update/create. If it was # a create then the previous stack object would be None. stack = utils.get_stack(self.orchestration_client, parsed_args.stack) if parsed_args.update_plan_only: # If we are only updating the plan, then we either wont have a # stack yet or there wont be any changes and the following code # wont do anything. return if parsed_args.config_download: print("Deploying overcloud configuration") deployment.set_deployment_status( clients=self.clients, plan=stack.stack_name, status='DEPLOYING' ) try: if not parsed_args.config_download_only: 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=utils.playbook_verbosity(self=self) ) if parsed_args.config_download_timeout: timeout = parsed_args.config_download_timeout else: used = int((time.time() - start) // 60) timeout = parsed_args.timeout - used if timeout <= 0: raise exceptions.DeploymentError( 'Deployment timed out after %sm' % used) deployment_options = {} if parsed_args.deployment_python_interpreter: deployment_options['ansible_python_interpreter'] = \ parsed_args.deployment_python_interpreter deployment.config_download( self.log, self.clients, stack, parsed_args.overcloud_ssh_network, parsed_args.output_dir, parsed_args.override_ansible_cfg, timeout=parsed_args.overcloud_ssh_port_timeout, verbosity=utils.playbook_verbosity(self=self), deployment_options=deployment_options, in_flight_validations=parsed_args.inflight, deployment_timeout=timeout, tags=parsed_args.tags, skip_tags=parsed_args.skip_tags, limit_hosts=utils.playbook_limit_parse( limit_nodes=parsed_args.limit ) ) deployment.set_deployment_status( clients=self.clients, plan=stack.stack_name, status='DEPLOY_SUCCESS') except Exception: deployment.set_deployment_status( clients=self.clients, plan=stack.stack_name, status='DEPLOY_FAILED' ) raise # Force fetching of attributes stack.get() rcpath = deployment.create_overcloudrc(container=stack.stack_name, no_proxy=parsed_args.no_proxy) # Copy clouds.yaml to the cloud user directory user = getpwuid(os.stat(constants.CLOUD_HOME_DIR).st_uid).pw_name utils.copy_clouds_yaml(user) utils.create_tempest_deployer_input() # Run postconfig on create or force. Use force to makes sure endpoints # are created with deploy reruns and upgrades if (stack_create or parsed_args.force_postconfig and not parsed_args.skip_postconfig): self._deploy_postconfig(stack, parsed_args) overcloud_endpoint = utils.get_overcloud_endpoint(stack) horizon_url = deployment.get_horizon_url(stack=stack.stack_name) print("Overcloud Endpoint: {0}".format(overcloud_endpoint)) print("Overcloud Horizon Dashboard URL: {0}".format(horizon_url)) print("Overcloud rc file: {0}".format(rcpath)) print("Overcloud Deployed")
def take_action(self, parsed_args): self.log.debug("take_action(%s)" % parsed_args) self._setup_clients(parsed_args) # Swiftclient logs things like 404s at error level, which is a problem # because we use EAFP to check for the existence of files. Turn off # most swiftclient logging to avoid cluttering up our output with # pointless tracebacks. sc_logger = logging.getLogger("swiftclient") sc_logger.setLevel(logging.CRITICAL) self._validate_args(parsed_args) stack = utils.get_stack(self.orchestration_client, parsed_args.stack) if stack and stack.stack_status == 'IN_PROGRESS': raise exceptions.StackInProgress( "Unable to deploy as the stack '{}' status is '{}'".format( stack.stack_name, stack.stack_status)) parameters = self._update_parameters(parsed_args, stack) if not parsed_args.disable_validations: errors, warnings = self._predeploy_verify_capabilities( stack, parameters, parsed_args) if errors > 0: self.log.error( "Configuration has %d errors, fix them before " "proceeding. Ignoring these errors is likely to lead to " "a failed deploy.", errors) if parsed_args.validation_warnings_fatal or \ parsed_args.validation_errors_fatal: raise exceptions.InvalidConfiguration() if warnings > 0: self.log.error( "Configuration has %d warnings, fix them before " "proceeding.", warnings) if parsed_args.validation_warnings_fatal: raise exceptions.InvalidConfiguration() else: self.log.info("SUCCESS: No warnings or errors in deploy " "configuration, proceeding.") stack_create = stack is None if stack_create: self.log.info("No stack found, will be doing a stack create") else: self.log.info("Stack found, will be doing a stack update") if parsed_args.rhel_reg: if parsed_args.reg_method == 'satellite': sat_required_args = (parsed_args.reg_org and parsed_args.reg_sat_url and parsed_args.reg_activation_key) if not sat_required_args: raise exceptions.DeploymentError( "ERROR: In order to use satellite registration, " "you must specify --reg-org, --reg-sat-url, and " "--reg-activation-key.") else: portal_required_args = (parsed_args.reg_org and parsed_args.reg_activation_key) if not portal_required_args: raise exceptions.DeploymentError( "ERROR: In order to use portal registration, you " "must specify --reg-org, and " "--reg-activation-key.") if parsed_args.dry_run: print("Validation Finished") return self._deploy_tripleo_heat_templates_tmpdir(stack, parsed_args) # Get a new copy of the stack after stack update/create. If it was # a create then the previous stack object would be None. stack = utils.get_stack(self.orchestration_client, parsed_args.stack) if parsed_args.update_plan_only: # If we are only updating the plan, then we either wont have a # stack yet or there wont be any changes and the following code # wont do anything. return if parsed_args.config_download: print("Deploying overcloud configuration") deployment.config_download(self.log, self.clients, stack, parsed_args.templates, parsed_args.deployed_server, parsed_args.overcloud_ssh_user, parsed_args.overcloud_ssh_key, parsed_args.output_dir, verbosity=self.app_args.verbose_level) # Force fetching of attributes stack.get() overcloudrcs = deployment.overcloudrc(self.workflow_client, container=stack.stack_name, no_proxy=parsed_args.no_proxy) rcpath = utils.write_overcloudrc(stack.stack_name, overcloudrcs) utils.create_tempest_deployer_input() # Run postconfig on create or force. Use force to makes sure endpoints # are created with deploy reruns and upgrades if (stack_create or parsed_args.force_postconfig and not parsed_args.skip_postconfig): self._deploy_postconfig(stack, parsed_args) overcloud_endpoint = utils.get_overcloud_endpoint(stack) horizon_url = deployment.get_horizon_url(self.clients, stack=stack.stack_name) print("Overcloud Endpoint: {0}".format(overcloud_endpoint)) print("Overcloud Horizon Dashboard URL: {0}".format(horizon_url)) print("Overcloud rc file: {0}".format(rcpath)) print("Overcloud Deployed")
def take_action(self, parsed_args): self.log.debug("take_action(%s)" % parsed_args) self._setup_clients(parsed_args) # Swiftclient logs things like 404s at error level, which is a problem # because we use EAFP to check for the existence of files. Turn off # most swiftclient logging to avoid cluttering up our output with # pointless tracebacks. sc_logger = logging.getLogger("swiftclient") sc_logger.setLevel(logging.CRITICAL) self._validate_args(parsed_args) # Throw warning if deprecated service is enabled and # ask user if deployment should still be continued. if parsed_args.environment_files: utils.check_deprecated_service_is_enabled( parsed_args.environment_files) stack = utils.get_stack(self.orchestration_client, parsed_args.stack) if stack and stack.stack_status == 'IN_PROGRESS': raise exceptions.StackInProgress( "Unable to deploy as the stack '{}' status is '{}'".format( stack.stack_name, stack.stack_status)) self._update_parameters(parsed_args, stack) stack_create = stack is None if stack_create: self.log.info("No stack found, will be doing a stack create") else: self.log.info("Stack found, will be doing a stack update") if parsed_args.dry_run: print("Validation Finished") return start = time.time() if not parsed_args.config_download_only: self._deploy_tripleo_heat_templates_tmpdir(stack, parsed_args) # Get a new copy of the stack after stack update/create. If it was # a create then the previous stack object would be None. stack = utils.get_stack(self.orchestration_client, parsed_args.stack) if parsed_args.update_plan_only: # If we are only updating the plan, then we either wont have a # stack yet or there wont be any changes and the following code # wont do anything. return if parsed_args.config_download: print("Deploying overcloud configuration") deployment.set_deployment_status( self.clients, 'deploying', plan=stack.stack_name) try: if not parsed_args.config_download_only: deployment.get_hosts_and_enable_ssh_admin( self.log, self.clients, stack, parsed_args.overcloud_ssh_network, parsed_args.overcloud_ssh_user, parsed_args.overcloud_ssh_key) if parsed_args.config_download_timeout: timeout = parsed_args.config_download_timeout * 60 else: used = int(time.time() - start) timeout = (parsed_args.timeout * 60) - used deployment_options = {} if parsed_args.deployment_python_interpreter: deployment_options['ansible_python_interpreter'] = \ parsed_args.deployment_python_interpreter deployment.config_download( self.log, self.clients, stack, parsed_args.templates, parsed_args.overcloud_ssh_user, parsed_args.overcloud_ssh_key, parsed_args.overcloud_ssh_network, parsed_args.output_dir, parsed_args.override_ansible_cfg, timeout, verbosity=self.app_args.verbose_level, deployment_options=deployment_options, in_flight_validations=parsed_args.inflight) except Exception: deployment.set_deployment_status( self.clients, 'failed', plan=stack.stack_name) raise # Force fetching of attributes stack.get() overcloudrcs = deployment.create_overcloudrc( self.clients, container=stack.stack_name, no_proxy=parsed_args.no_proxy) # Create overcloud clouds.yaml cloud_data = deployment.create_cloudsyaml( self.clients, container=stack.stack_name) cloud_yaml_dir = os.path.join(constants.CLOUD_HOME_DIR, constants.CLOUDS_YAML_DIR) cloud_user_id = os.stat(constants.CLOUD_HOME_DIR).st_uid cloud_group_id = os.stat(constants.CLOUD_HOME_DIR).st_gid clouds_yaml.create_clouds_yaml( cloud=cloud_data, cloud_yaml_dir=cloud_yaml_dir, user_id=cloud_user_id, group_id=cloud_group_id) rcpath = utils.write_overcloudrc(stack.stack_name, overcloudrcs) utils.create_tempest_deployer_input() # Run postconfig on create or force. Use force to makes sure endpoints # are created with deploy reruns and upgrades if (stack_create or parsed_args.force_postconfig and not parsed_args.skip_postconfig): self._deploy_postconfig(stack, parsed_args) overcloud_endpoint = utils.get_overcloud_endpoint(stack) horizon_url = deployment.get_horizon_url( self.clients, stack=stack.stack_name) print("Overcloud Endpoint: {0}".format(overcloud_endpoint)) print("Overcloud Horizon Dashboard URL: {0}".format(horizon_url)) print("Overcloud rc file: {0}".format(rcpath)) print("Overcloud Deployed")