launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #05595
[Merge] lp:~mbp/launchpad/ec2-kill into lp:launchpad
Martin Pool has proposed merging lp:~mbp/launchpad/ec2-kill into lp:launchpad with lp:~mbp/launchpad/ec2-region as a prerequisite.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~mbp/launchpad/ec2-kill/+merge/82631
* add 'ec2 kill i-123123ab'
* improve the display shown by 'ec2 list'
* make it believe in --verbose
* show the instance state and why the instance entered that state
--
https://code.launchpad.net/~mbp/launchpad/ec2-kill/+merge/82631
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~mbp/launchpad/ec2-kill into lp:launchpad.
=== modified file 'lib/devscripts/ec2test/builtins.py'
--- lib/devscripts/ec2test/builtins.py 2011-11-18 03:58:27 +0000
+++ lib/devscripts/ec2test/builtins.py 2011-11-18 03:58:29 +0000
@@ -24,6 +24,7 @@
Option,
)
from bzrlib.transport import get_transport
+from bzrlib.trace import is_verbose
from pytz import UTC
import simplejson
@@ -697,6 +698,25 @@
image.description or ''))
+class cmd_kill(EC2Command):
+ """Kill one or more running EC2 instances.
+
+ You can get the instance id from 'ec2 list'.
+ """
+
+ takes_options = [
+ region_option,
+ ]
+ takes_args = ['instance_id*']
+
+ def run(self, instance_id_list, region=None):
+ credentials = EC2Credentials.load_from_file(region_name=region)
+ account = credentials.connect('ec2 kill')
+ self.outf.write("killing %d instances: " % len(instance_id_list,))
+ account.conn.terminate_instances(instance_id_list)
+ self.outf.write("done\n")
+
+
class cmd_list(EC2Command):
"""List all your current EC2 test runs.
@@ -757,22 +777,29 @@
:param data: Launchpad-specific data.
:param verbose: Whether we want verbose output.
"""
+ description = instance.id
uptime = self.get_uptime(instance)
- if data is None:
- description = instance.id
- current_status = 'unknown '
+ if instance.state != 'running':
+ current_status = instance.state
else:
- description = data['description']
- if data['failed-yet']:
- current_status = '[FAILED]'
+ if data is None:
+ current_status = 'unknown '
else:
- current_status = '[OK] '
- output = '%s %s (up for %s)' % (description, current_status, uptime)
+ description = data['description']
+ if data['failed-yet']:
+ current_status = '[FAILED]'
+ else:
+ current_status = '[OK] '
+ output = '%-40s %-10s (up for %s) %10s' % (description, current_status, uptime,
+ instance.id)
if verbose:
url = self.get_http_url(instance)
if url is None:
url = "No web service"
output += '\n %s' % (url,)
+ if instance.state_reason:
+ output += '\n transition reason: %s' % instance.state_reason.get(
+ 'message', '')
return output
def format_summary(self, by_state):
@@ -795,7 +822,7 @@
data = self.get_ec2test_info(instance)
if data is None and not all:
continue
- print self.format_instance(instance, data, show_urls)
+ print self.format_instance(instance, data, verbose=(show_urls or is_verbose()))
print 'Summary: %s' % (self.format_summary(by_state),)