def cmd(stackname, command=None, username=DEPLOY_USER, clean_output=False, concurrency=None, node=None): if command is None: utils.errcho("Please specify a command e.g. ./bldr cmd:%s,ls" % stackname) exit(1) LOG.info("Connecting to: %s", stackname) instances = _check_want_to_be_running(stackname) if not instances: return # take out the load of crap that Fabric prints mangling the useful output # of a remote command custom_settings = {} if clean_output: custom_settings['fabric.state.output'] = { 'status': False, 'running': False } custom_settings['output_prefix'] = False try: with settings(**custom_settings): return stack_all_ec2_nodes( stackname, (remote, {'command': command}), username=username, abort_on_prompts=True, concurrency=concurrency_for(stackname, concurrency), node=int(node) if node else None ) except CommandException as e: LOG.error(e) exit(2)
def create_ami(stackname, name=None): pname = core.project_name_from_stackname(stackname) msg = "this will create a new AMI for the project %r" % pname confirm(msg) amiid = bakery.create_ami(stackname, name) print(amiid) errcho('update project file with new ami %s. these changes must be merged and committed manually' % amiid)
def test_errcho(self, stderr): self.assertEqual( 'Hello, world', utils.errcho('Hello, world') ) self.assertEqual( [call('Hello, world'), call('\n')], stderr.write.call_args_list ) stderr.flush.assert_called_with()