From 205810c3da4652fd0f5203f53299cd998ac7cf82 Mon Sep 17 00:00:00 2001 From: Christian Berendt Date: Fri, 18 Feb 2011 11:44:06 +0100 Subject: added functionality to list only fixed ip addresses of one node and added exception handling to list method # nova-manage fixed list XXXX network IP address MAC address hostname host 10.xx.xx.0/24 10.xx.xx.5 02:16:3e:3f:33:b6 i-00000547 XXXX 10.xx.xx.0/24 10.xx.xx.9 02:16:3e:14:03:d6 i-00000548 XXXX 10.xx.xx.0/24 10.xx.xx.12 02:16:3e:20:1b:e7 i-00000549 XXXX --- bin/nova-manage | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index 6d67252b8..60a00f1cf 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -439,10 +439,15 @@ class FixedIpCommands(object): def list(self, host=None): """Lists all fixed ips (optionally by host) arguments: [host]""" ctxt = context.get_admin_context() - if host == None: - fixed_ips = db.fixed_ip_get_all(ctxt) - else: - fixed_ips = db.fixed_ip_get_all_by_host(ctxt, host) + + try: + if host == None: + fixed_ips = db.fixed_ip_get_all(ctxt) + else: + fixed_ips = db.fixed_ip_get_all_by_host(ctxt, host) + except exception.NotFound as ex: + print "error: %s" % ex + sys.exit(2) print "%-18s\t%-15s\t%-17s\t%-15s\t%s" % (_('network'), _('IP address'), @@ -459,9 +464,9 @@ class FixedIpCommands(object): host = instance['host'] mac_address = instance['mac_address'] print "%-18s\t%-15s\t%-17s\t%-15s\t%s" % ( - fixed_ip['network']['cidr'], - fixed_ip['address'], - mac_address, hostname, host) + fixed_ip['network']['cidr'], + fixed_ip['address'], + mac_address, hostname, host) class FloatingIpCommands(object): -- cgit From cf8cf8287169e3e0b996db7db5a135dea88db63a Mon Sep 17 00:00:00 2001 From: Christian Berendt Date: Fri, 18 Feb 2011 12:01:50 +0100 Subject: added new class Instances to manage instances and added a new listing method into the class # nova-manage instance list instance node type state launched image kernel ramdisk project user zone index i-00000547 XXXXXXX m1.small running 2011-02-18 08:36:37 ami-a03ndz0q ami-0isqekvw testing berendt None 0 i-00000548 XXXXXXX m1.small running 2011-02-18 08:37:17 ami-a03ndz0q ami-0isqekvw testing berendt None 1 i-00000549 XXXXXXX m1.small running 2011-02-18 08:37:52 ami-a03ndz0q ami-0isqekvw testing berendt None 2 --- bin/nova-manage | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index 60a00f1cf..68847bdde 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -618,6 +618,45 @@ class DbCommands(object): print migration.db_version() +class InstanceCommands(object): + """Class for managing instances.""" + + def list(self, host=None, instance=None): + """Show a list of all instances""" + print "%-10s %-15s %-10s %-10s %-19s %-12s %-12s" \ + " %-12s %-10s %-10s %-10s %-5s" % ( + _('instance'), + _('node'), + _('type'), + _('state'), + _('launched'), + _('image'), + _('kernel'), + _('ramdisk'), + _('project'), + _('user'), + _('zone'), + _('index'), + ) + + for instance in db.instance_get_all(context.get_admin_context()): + print "%-10s %-15s %-10s %-10s %-19s %-12s %-12s %-12s" \ + " %-10s %-10s %-10s %-5d" % ( + instance['hostname'], + instance['host'], + instance['instance_type'], + instance['state_description'], + instance['launched_at'], + instance['image_id'], + instance['kernel_id'], + instance['ramdisk_id'], + instance['project_id'], + instance['user_id'], + instance['availability_zone'], + instance['launch_index'] + ) + + class VolumeCommands(object): """Methods for dealing with a cloud in an odd state""" @@ -677,7 +716,9 @@ CATEGORIES = [ ('service', ServiceCommands), ('log', LogCommands), ('db', DbCommands), - ('volume', VolumeCommands)] + ('volume', VolumeCommands) + ('instance', InstanceCommands), +] def lazy_match(name, key_value_tuples): -- cgit From 493aa34da71e7dc3c28c6a55254b6d7ed4d81b72 Mon Sep 17 00:00:00 2001 From: Christian Berendt Date: Sat, 26 Feb 2011 22:13:28 +0100 Subject: beautification... --- bin/nova-manage | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index 68847bdde..2e4e091cf 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -623,8 +623,8 @@ class InstanceCommands(object): def list(self, host=None, instance=None): """Show a list of all instances""" - print "%-10s %-15s %-10s %-10s %-19s %-12s %-12s" \ - " %-12s %-10s %-10s %-10s %-5s" % ( + print "%-10s %-15s %-10s %-10s %-19s %-12s %-12s %-12s" \ + " %-10s %-10s %-10s %-5s" % ( _('instance'), _('node'), _('type'), @@ -636,7 +636,7 @@ class InstanceCommands(object): _('project'), _('user'), _('zone'), - _('index'), + _('index') ) for instance in db.instance_get_all(context.get_admin_context()): @@ -716,8 +716,8 @@ CATEGORIES = [ ('service', ServiceCommands), ('log', LogCommands), ('db', DbCommands), - ('volume', VolumeCommands) - ('instance', InstanceCommands), + ('volume', VolumeCommands), + ('instance', InstanceCommands) ] -- cgit From f72e5b618387a7b5a06f0e5b7e68af51c6667327 Mon Sep 17 00:00:00 2001 From: Christian Berendt Date: Sun, 27 Feb 2011 00:13:05 +0100 Subject: added listing of instances running on a specific host chronos:~ # nova-manage fixed list ares network IP address MAC address hostname host 192.168.3.0/24 192.168.3.6 02:16:3e:75:d7:9a i-00000c1c ares --- bin/nova-manage | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index 2e4e091cf..12ccfa0e9 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -639,7 +639,13 @@ class InstanceCommands(object): _('index') ) - for instance in db.instance_get_all(context.get_admin_context()): + if host == None: + instances = db.instance_get_all(context.get_admin_context()) + else: + instances = db.instance_get_all_by_host( + context.get_admin_context(), host) + + for instance in instances: print "%-10s %-15s %-10s %-10s %-19s %-12s %-12s %-12s" \ " %-10s %-10s %-10s %-5d" % ( instance['hostname'], -- cgit From 8b3e35b157c688fd38d5aa0eb10ddef33653003d Mon Sep 17 00:00:00 2001 From: Christian Berendt Date: Wed, 16 Mar 2011 10:29:04 +0100 Subject: fixed pep8 errors (with version 0.5.0) --- bin/nova-manage | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) (limited to 'bin') diff --git a/bin/nova-manage b/bin/nova-manage index 44b1d9ac6..c38e25d6b 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -739,8 +739,7 @@ class InstanceCommands(object): _('project'), _('user'), _('zone'), - _('index') - ) + _('index')) if host == None: instances = db.instance_get_all(context.get_admin_context()) @@ -762,8 +761,7 @@ class InstanceCommands(object): instance['project_id'], instance['user_id'], instance['availability_zone'], - instance['launch_index'] - ) + instance['launch_index']) class VolumeCommands(object): @@ -1053,8 +1051,7 @@ CATEGORIES = [ ('instance_type', InstanceTypeCommands), ('image', ImageCommands), ('flavor', InstanceTypeCommands), - ('instance', InstanceCommands) -] + ('instance', InstanceCommands)] def lazy_match(name, key_value_tuples): -- cgit