def test_create_overcloudrc(self): stack = mock.MagicMock() stack.stack_name = 'teststack' stack.to_dict.return_value = { 'outputs': [{'output_key': 'KeystoneURL', 'output_value': 'http://foo.com:8000/'}, {'output_key': 'KeystoneAdminVip', 'output_value': 'fd00::1'}] } tempdir = tempfile.mkdtemp() rcfile = os.path.join(tempdir, 'teststackrc') try: utils.create_overcloudrc(stack=stack, no_proxy='127.0.0.1', config_directory=tempdir) rc = open(rcfile, 'rt').read() self.assertIn('export OS_AUTH_URL=http://foo.com:8000/', rc) self.assertIn('export no_proxy=127.0.0.1,foo.com,[fd00::1]', rc) self.assertIn('export OS_CLOUDNAME=teststack', rc) self.assertIn('export PYTHONWARNINGS="ignore:Certificate has no, ' 'ignore:A true SSLContext object is not available"', rc) finally: if os.path.exists(rcfile): os.unlink(rcfile) os.rmdir(tempdir)
def test_create_overcloudrc(self): stack = mock.MagicMock() stack.stack_name = 'teststack' stack.to_dict.return_value = { 'outputs': [{ 'output_key': 'KeystoneURL', 'output_value': 'http://foo.com:8000/' }, { 'output_key': 'KeystoneAdminVip', 'output_value': 'fd00::1' }] } tempdir = tempfile.mkdtemp() rcfile = os.path.join(tempdir, 'teststackrc') try: utils.create_overcloudrc(stack=stack, no_proxy='127.0.0.1', config_directory=tempdir) rc = open(rcfile, 'rt').read() self.assertIn('export OS_AUTH_URL=http://foo.com:8000/', rc) self.assertIn('export no_proxy=127.0.0.1,foo.com,[fd00::1]', rc) self.assertIn('export OS_CLOUDNAME=teststack', rc) self.assertIn( 'export PYTHONWARNINGS="ignore:Certificate has no, ' 'ignore:A true SSLContext object is not available"', rc) finally: if os.path.exists(rcfile): os.unlink(rcfile) os.rmdir(tempdir)
def test_create_overcloudrc(self): stack = mock.MagicMock() stack.stack_name = "teststack" stack.to_dict.return_value = {"outputs": [{"output_key": "KeystoneURL", "output_value": "http://foo:8000/"}]} tempdir = tempfile.mkdtemp() rcfile = os.path.join(tempdir, "teststackrc") try: utils.create_overcloudrc(stack=stack, no_proxy="127.0.0.1", config_directory=tempdir) rc = open(rcfile, "rt").read() self.assertIn("export OS_AUTH_URL=http://foo:8000/", rc) self.assertIn("export no_proxy=127.0.0.1", rc) self.assertIn("export OS_CLOUDNAME=teststack", rc) finally: if os.path.exists(rcfile): os.unlink(rcfile) os.rmdir(tempdir)
def test_create_overcloudrc(self): stack = mock.MagicMock() stack.stack_name = 'teststack' endpoint_map = {'KeystoneAdmin': {'host': 'fd00::1'}} stack.to_dict.return_value = { 'outputs': [{'output_key': 'KeystoneURL', 'output_value': 'http://foo.com:8000/'}, {'output_key': 'EndpointMap', 'output_value': endpoint_map}] } tempdir = tempfile.mkdtemp() rcfile = os.path.join(tempdir, 'teststackrc') rcfile_v3 = os.path.join(tempdir, 'teststackrc.v3') mock_clients = mock.Mock() try: utils.create_overcloudrc(clients=mock_clients, stack=stack, no_proxy='127.0.0.1', config_directory=tempdir) rc = open(rcfile, 'rt').read() self.assertIn('export OS_AUTH_URL=http://foo.com:8000/', rc) self.assertIn('export no_proxy=127.0.0.1,foo.com,[fd00::1]', rc) self.assertIn('export OS_CLOUDNAME=teststack', rc) self.assertIn('export PYTHONWARNINGS="ignore:Certificate has no, ' 'ignore:A true SSLContext object is not available"', rc) rc_v3 = open(rcfile_v3, 'rt').read() self.assertIn('export OS_USER_DOMAIN_NAME=Default', rc_v3) self.assertIn('export OS_PROJECT_DOMAIN_NAME=Default', rc_v3) self.assertIn('export OS_IDENTITY_API_VERSION=3', rc_v3) finally: if os.path.exists(rcfile): os.unlink(rcfile) if os.path.exists(rcfile_v3): os.unlink(rcfile_v3) os.rmdir(tempdir)
def take_action(self, parsed_args): self.log.debug("take_action(%s)" % parsed_args) self._validate_args(parsed_args) errors, warnings = self._predeploy_verify_capabilities(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: return if warnings > 0: self.log.error( "Configuration has %d warnings, fix them before proceeding. ", warnings) if parsed_args.validation_warnings_fatal: return else: self.log.info("SUCCESS: No warnings or errors in deploy " "configuration, proceeding.") clients = self.app.client_manager orchestration_client = clients.tripleoclient.orchestration stack = utils.get_stack(orchestration_client, 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") try: self._pre_heat_deploy() 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 True self._deploy_tripleo_heat_templates(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(orchestration_client, parsed_args.stack) utils.create_overcloudrc(stack, parsed_args.no_proxy) utils.create_tempest_deployer_input() if stack_create: self._deploy_postconfig(stack, parsed_args) overcloud_endpoint = utils.get_overcloud_endpoint(stack) print("Overcloud Endpoint: {0}".format(overcloud_endpoint)) print("Overcloud Deployed") return True except exceptions.DeploymentError as err: print("Deployment failed: ", err, file=sys.stderr) return False
def take_action(self, parsed_args): self.log.debug("take_action(%s)" % parsed_args) self._validate_args(parsed_args) errors, warnings = self._predeploy_verify_capabilities(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: return if warnings > 0: self.log.error( "Configuration has %d warnings, fix them before proceeding. ", warnings) if parsed_args.validation_warnings_fatal: return else: self.log.info("SUCCESS: No warnings or errors in deploy " "configuration, proceeding.") clients = self.app.client_manager orchestration_client = clients.tripleoclient.orchestration stack = utils.get_stack(orchestration_client, 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") try: self._pre_heat_deploy() 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.") self._deploy_tripleo_heat_templates(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(orchestration_client, parsed_args.stack) utils.create_overcloudrc(stack, parsed_args.no_proxy) utils.create_tempest_deployer_input() if stack_create: self._deploy_postconfig(stack, parsed_args) overcloud_endpoint = utils.get_overcloud_endpoint(stack) print("Overcloud Endpoint: {0}".format(overcloud_endpoint)) print("Overcloud Deployed") return True except exceptions.DeploymentError as err: print("Deployment failed: ", err, file=sys.stderr) return False
def take_action(self, parsed_args): self.log.debug("take_action(%s)" % 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) clients = self.app.client_manager orchestration_client = clients.orchestration stack = utils.get_stack(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, clients.network, stack) 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: return if warnings > 0: self.log.error( "Configuration has %d warnings, fix them before proceeding. ", warnings) if parsed_args.validation_warnings_fatal: return 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(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 # Force fetching of attributes stack.get() utils.create_overcloudrc(clients, stack, parsed_args.no_proxy) 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) print("Overcloud Endpoint: {0}".format(overcloud_endpoint)) print("Overcloud Deployed")