Merge lp:~smoser/euca2ools/describe-instances.extra-fields into lp:euca2ools

Proposed by Scott Moser
Status: Merged
Merged at revision: 528
Proposed branch: lp:~smoser/euca2ools/describe-instances.extra-fields
Merge into: lp:euca2ools
Diff against target: 47 lines (+25/-2)
1 file modified
euca2ools/utils.py (+25/-2)
To merge this branch: bzr merge lp:~smoser/euca2ools/describe-instances.extra-fields
Reviewer Review Type Date Requested Status
Eucalyptus Maintainers Pending
Review via email: mp+96291@code.launchpad.net

Description of the change

include additional fields in describe-instances output

This adds some additional fields to describe-instances output.
Most immediately useful are private_ip and public_ip.

To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'euca2ools/utils.py'
2--- euca2ools/utils.py 2012-01-05 22:24:20 +0000
3+++ euca2ools/utils.py 2012-03-07 04:51:18 +0000
4@@ -70,10 +70,21 @@
5 dict[keylist[i]] = values[i]
6
7 def print_instances(instances, nil=""):
8+
9+ # I was not able to correctly identify fields with an 'xx' below the
10+ # descriptions at
11+ # http://docs.amazonwebservices.com/AWSEC2/latest/CommandLineReference/ApiReference-cmd-DescribeInstances.html
12+ # were not sufficiently detailed, even when coupled with some limited
13+ # experimentation
14+ #
15+ # Additionally, in order to get 'hypervisor', the api request version
16+ # in the make_ec2_connection method would need to be increased.
17 members=( "id", "image_id", "public_dns_name", "private_dns_name",
18 "state", "key_name", "ami_launch_index", "product_codes",
19 "instance_type", "launch_time", "placement", "kernel",
20- "ramdisk" )
21+ "ramdisk", "xx", "_monitoring", 'ip_address', 'private_ip_address',
22+ "vpc_id", "subnet_id", "root_device_type", "xx", "xx", "xx", "xx",
23+ "virtualizationType", "hypervisor", "xx", "_groupnames", "_groupids" )
24
25 for instance in instances:
26 # in old describe-instances, there was a check for 'if instance:'
27@@ -82,7 +93,19 @@
28 if not instance: continue
29 items=[ ]
30 for member in members:
31- val = getattr(instance,member,nil)
32+ # boto's "monitoring" item is blank string
33+ if member == "_monitoring":
34+ if instance.monitored:
35+ val = "monitoring-enabled"
36+ else:
37+ val = "monitoring-disabled"
38+ elif member == "_groupids":
39+ val = [x.name for x in instance.groups]
40+ elif member == "_groupnames":
41+ val = [x.id for x in instance.groups]
42+ else:
43+ val = getattr(instance,member,nil)
44+
45 # product_codes is a list
46 if val is None: val = nil
47 if hasattr(val,'__iter__'):

Subscribers

People subscribed via source and target branches