def _run_main(self, parsed_args, parsed_globals): params = parsed_args params.session = self._session validate_region(params, parsed_globals) validate_instance_name(params) validate_tags(params) validate_iam_user_arn(params) self.codedeploy = self._session.create_client( 'codedeploy', region_name=params.region, endpoint_url=parsed_globals.endpoint_url, verify=parsed_globals.verify_ssl ) self.iam = self._session.create_client( 'iam', region_name=params.region ) try: if not params.iam_user_arn: self._create_iam_user(params) self._create_access_key(params) self._create_user_policy(params) self._create_config(params) self._register_instance(params) if params.tags: self._add_tags(params) sys.stdout.write( 'Copy the on-premises configuration file named {0} to the ' 'on-premises instance, and run the following command on the ' 'on-premises instance to install and configure the AWS ' 'CodeDeploy Agent:\n' 'aws deploy install --config-file {0}\n'.format( DEFAULT_CONFIG_FILE ) ) except Exception as e: sys.stdout.flush() sys.stderr.write( 'ERROR\n' '{0}\n' 'Register the on-premises instance by following the ' 'instructions in "Configure Existing On-Premises Instances by ' 'Using AWS CodeDeploy" in the AWS CodeDeploy User ' 'Guide.\n'.format(e) )
def _run_main(self, parsed_args, parsed_globals): params = parsed_args params.session = self._session validate_region(params, parsed_globals) validate_instance_name(params) validate_tags(params) validate_iam_user_arn(params) self.codedeploy = self._session.create_client( 'codedeploy', region_name=params.region, endpoint_url=parsed_globals.endpoint_url, verify=parsed_globals.verify_ssl) self.iam = self._session.create_client('iam', region_name=params.region) try: if not params.iam_user_arn: self._create_iam_user(params) self._create_access_key(params) self._create_user_policy(params) self._create_config(params) self._register_instance(params) if params.tags: self._add_tags(params) sys.stdout.write( 'Copy the on-premises configuration file named {0} to the ' 'on-premises instance, and run the following command on the ' 'on-premises instance to install and configure the AWS ' 'CodeDeploy Agent:\n' 'aws deploy install --config-file {0}\n'.format( DEFAULT_CONFIG_FILE)) except Exception as e: sys.stdout.flush() sys.stderr.write( 'ERROR\n' '{0}\n' 'Register the on-premises instance by following the ' 'instructions in "Configure Existing On-Premises Instances by ' 'Using AWS CodeDeploy" in the AWS CodeDeploy User ' 'Guide.\n'.format(e)) return 255 return 0
def _run_main(self, parsed_args, parsed_globals): params = parsed_args params.session = self._session validate_region(params, parsed_globals) validate_instance(params) params.system.validate_administrator() try: self._uninstall_agent(params) self._delete_config_file(params) except Exception as e: sys.stdout.flush() sys.stderr.write( 'ERROR\n' '{0}\n' 'Uninstall the AWS CodeDeploy Agent on the on-premises ' 'instance by following the instructions in "Configure ' 'Existing On-Premises Instances by Using AWS CodeDeploy" in ' 'the AWS CodeDeploy User Guide.\n'.format(e))
def _run_main(self, parsed_args, parsed_globals): params = parsed_args params.session = self._session validate_region(params, parsed_globals) validate_instance(params) params.system.validate_administrator() try: self._uninstall_agent(params) self._delete_config_file(params) except Exception as e: sys.stdout.flush() sys.stderr.write( 'ERROR\n' '{0}\n' 'Uninstall the AWS CodeDeploy Agent on the on-premises ' 'instance by following the instructions in "Configure ' 'Existing On-Premises Instances by Using AWS CodeDeploy" in ' 'the AWS CodeDeploy User Guide.\n'.format(e) )
def _run_main(self, parsed_args, parsed_globals): params = parsed_args params.session = self._session validate_region(params, parsed_globals) validate_instance_name(params) self.codedeploy = self._session.create_client( 'codedeploy', region_name=params.region, endpoint_url=parsed_globals.endpoint_url, verify=parsed_globals.verify_ssl ) self.iam = self._session.create_client( 'iam', region_name=params.region ) try: self._get_instance_info(params) if params.tags: self._remove_tags(params) self._deregister_instance(params) if not params.no_delete_iam_user: self._delete_user_policy(params) self._delete_access_key(params) self._delete_iam_user(params) sys.stdout.write( 'Run the following command on the on-premises instance to ' 'uninstall the codedeploy-agent:\n' 'aws deploy uninstall\n' ) except Exception as e: sys.stdout.flush() sys.stderr.write( 'ERROR\n' '{0}\n' 'Deregister the on-premises instance by following the ' 'instructions in "Configure Existing On-Premises Instances by ' 'Using AWS CodeDeploy" in the AWS CodeDeploy User ' 'Guide.\n'.format(e) )
def _run_main(self, parsed_args, parsed_globals): params = parsed_args params.session = self._session validate_region(params, parsed_globals) validate_instance_name(params) self.codedeploy = self._session.create_client( 'codedeploy', region_name=params.region, endpoint_url=parsed_globals.endpoint_url, verify=parsed_globals.verify_ssl) self.iam = self._session.create_client('iam', region_name=params.region) try: self._get_instance_info(params) if params.tags: self._remove_tags(params) self._deregister_instance(params) if not params.no_delete_iam_user: self._delete_user_policy(params) self._delete_access_key(params) self._delete_iam_user(params) sys.stdout.write( 'Run the following command on the on-premises instance to ' 'uninstall the codedeploy-agent:\n' 'aws deploy uninstall\n') except Exception as e: sys.stdout.flush() sys.stderr.write( 'ERROR\n' '{0}\n' 'Deregister the on-premises instance by following the ' 'instructions in "Configure Existing On-Premises Instances by ' 'Using AWS CodeDeploy" in the AWS CodeDeploy User ' 'Guide.\n'.format(e)) return 255 return 0
def _run_main(self, parsed_args, parsed_globals): params = parsed_args params.session = self._session validate_region(params, parsed_globals) validate_instance(params) params.system.validate_administrator() self._validate_override_config(params) self._validate_agent_installer(params) try: self._create_config(params) self._install_agent(params) except Exception as e: sys.stdout.flush() sys.stderr.write( 'ERROR\n' '{0}\n' 'Install the AWS CodeDeploy Agent on the on-premises instance ' 'by following the instructions in "Configure Existing ' 'On-Premises Instances by Using AWS CodeDeploy" in the AWS ' 'CodeDeploy User Guide.\n'.format(e)) return 255 return 0
def test_validate_region_throws_on_no_region(self): self.globals.region = None self.session.get_config_variable.return_value = None error_msg = 'Region not specified.' with self.assertRaisesRegexp(ConfigurationError, error_msg): validate_region(self.params, self.globals)
def test_validate_region_returns_session_region(self): self.globals.region = None self.session.get_config_variable.return_value = self.region validate_region(self.params, self.globals) self.assertIn('region', self.params) self.assertEquals(self.region, self.params.region)
def test_validate_region_throws_on_no_region(self): self.globals.region = None self.session.get_config_variable.return_value = None with self.assertRaisesRegexp(RuntimeError, 'Region not specified.'): validate_region(self.params, self.globals)