From fcf358cacd8f993faaf64310307956686a7d330b Mon Sep 17 00:00:00 2001 From: Ken Pepple Date: Thu, 7 Apr 2011 11:12:14 -0700 Subject: moved -manage instance list command to -manage vm list to avoid lazy match conflict with instance_types --- bin/nova-manage | 85 +++++++++++++++++++++++++++------------------------------ 1 file changed, 40 insertions(+), 45 deletions(-) diff --git a/bin/nova-manage b/bin/nova-manage index 6789efba8..bd3f9f50d 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -570,6 +570,45 @@ class NetworkCommands(object): class VmCommands(object): """Class for mangaging VM 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')) + + 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'], + 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']) + def live_migration(self, ec2_id, dest): """Migrates a running instance to a new machine. @@ -725,49 +764,6 @@ 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')) - - 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'], - 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""" @@ -1054,8 +1050,7 @@ CATEGORIES = [ ('volume', VolumeCommands), ('instance_type', InstanceTypeCommands), ('image', ImageCommands), - ('flavor', InstanceTypeCommands), - ('instance', InstanceCommands)] + ('flavor', InstanceTypeCommands)] def lazy_match(name, key_value_tuples): -- cgit From ce5e102d0097f1b3f2322dc0d1ac1d0e5dea7f0a Mon Sep 17 00:00:00 2001 From: Ken Pepple Date: Thu, 7 Apr 2011 11:22:31 -0700 Subject: removed unused instance parameter from vm list ... as it is unused. added parameters to docstring for vm list. --- bin/nova-manage | 8 ++++++-- doc/source/man/novamanage.rst | 10 ++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/bin/nova-manage b/bin/nova-manage index bd3f9f50d..6903c16c9 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -570,8 +570,12 @@ class NetworkCommands(object): class VmCommands(object): """Class for mangaging VM instances.""" - def list(self, host=None, instance=None): - """Show a list of all instances""" + def list(self, host=None): + """Show a list of all instances + + :param host: show all instance on specified host. + :param instance: show specificed instance. + """ print "%-10s %-15s %-10s %-10s %-19s %-12s %-12s %-12s" \ " %-10s %-10s %-10s %-5s" % ( _('instance'), diff --git a/doc/source/man/novamanage.rst b/doc/source/man/novamanage.rst index 1d8446f08..b7688f0d8 100644 --- a/doc/source/man/novamanage.rst +++ b/doc/source/man/novamanage.rst @@ -240,6 +240,16 @@ Nova Images Converts all images in directory from the old (Bexar) format to the new format. +Nova VM +~~~~~~~~~~~ + +``nova-manage vm list [host]`` + Show a list of all instances. Accepts optional hostname (to show only instances on specific host). + +``nova-manage live-migration `` + Live migrate instance from current host to destination host. Requires instance id (which comes from euca-describe-instance) and destination host name. + + FILES ======== -- cgit From 11b76108dbd8a540da151141f5208de9358cf38b Mon Sep 17 00:00:00 2001 From: Ken Pepple Date: Thu, 7 Apr 2011 11:25:44 -0700 Subject: added -manage vm [list|live-migration] to man page --- doc/source/man/novamanage.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/source/man/novamanage.rst b/doc/source/man/novamanage.rst index b7688f0d8..9c54f3608 100644 --- a/doc/source/man/novamanage.rst +++ b/doc/source/man/novamanage.rst @@ -247,7 +247,7 @@ Nova VM Show a list of all instances. Accepts optional hostname (to show only instances on specific host). ``nova-manage live-migration `` - Live migrate instance from current host to destination host. Requires instance id (which comes from euca-describe-instance) and destination host name. + Live migrate instance from current host to destination host. Requires instance id (which comes from euca-describe-instance) and destination host name (which can be found from nova-manage service list). FILES -- cgit From 5ea0991db9526969f100f3361661731aaf4d24d5 Mon Sep 17 00:00:00 2001 From: Brian Lamar Date: Fri, 8 Apr 2011 15:22:15 -0400 Subject: Fixes bug which hangs nova-compute when terminating an instance when using libvirt backend. --- nova/virt/libvirt_conn.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py index b949e6c92..51a0a3380 100644 --- a/nova/virt/libvirt_conn.py +++ b/nova/virt/libvirt_conn.py @@ -325,12 +325,13 @@ class LibvirtConnection(driver.ComputeDriver): state = self.get_info(instance['name'])['state'] db.instance_set_state(context.get_admin_context(), instance['id'], state) - if state == power_state.SHUTDOWN: + if state == power_state.SHUTOFF: break - except Exception: + except Exception as ex: + LOG.debug(ex) db.instance_set_state(context.get_admin_context(), instance['id'], - power_state.SHUTDOWN) + power_state.SHUTOFF) break self.firewall_driver.unfilter_instance(instance) -- cgit From a1c40feb0cd592829b63df1cf19109bc322f81a7 Mon Sep 17 00:00:00 2001 From: Brian Lamar Date: Fri, 8 Apr 2011 15:54:17 -0400 Subject: Added error message to exception logging. --- nova/virt/libvirt_conn.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py index 51a0a3380..bfa9ff688 100644 --- a/nova/virt/libvirt_conn.py +++ b/nova/virt/libvirt_conn.py @@ -328,7 +328,9 @@ class LibvirtConnection(driver.ComputeDriver): if state == power_state.SHUTOFF: break except Exception as ex: - LOG.debug(ex) + msg = _("Error encountered when destroying instance '%(id)s': " + "%(ex)s") % locals().update({"id": instance["id"]}) + LOG.debug(msg) db.instance_set_state(context.get_admin_context(), instance['id'], power_state.SHUTOFF) -- cgit From 5632baa79da2164457f75a240c5c497027c49fca Mon Sep 17 00:00:00 2001 From: Ken Pepple Date: Fri, 8 Apr 2011 14:36:27 -0700 Subject: pep8 --- bin/nova-manage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/nova-manage b/bin/nova-manage index ab35e2c74..adc631318 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -572,7 +572,7 @@ class VmCommands(object): def list(self, host=None): """Show a list of all instances - + :param host: show all instance on specified host. :param instance: show specificed instance. """ -- cgit From 79ebe165f255037b0d5eaad7afe81b51cf85ed63 Mon Sep 17 00:00:00 2001 From: Brian Lamar Date: Sat, 9 Apr 2011 11:08:47 -0400 Subject: Fixed log message gaffe. --- nova/virt/libvirt_conn.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/virt/libvirt_conn.py b/nova/virt/libvirt_conn.py index bfa9ff688..9c665ab15 100644 --- a/nova/virt/libvirt_conn.py +++ b/nova/virt/libvirt_conn.py @@ -329,7 +329,7 @@ class LibvirtConnection(driver.ComputeDriver): break except Exception as ex: msg = _("Error encountered when destroying instance '%(id)s': " - "%(ex)s") % locals().update({"id": instance["id"]}) + "%(ex)s") % {"id": instance["id"], "ex": ex} LOG.debug(msg) db.instance_set_state(context.get_admin_context(), instance['id'], -- cgit