As described in bug, We are proposing a new parameter --status for "nova-manage vm list" command.
Updated filter accordingly to get the vms from db by status(active,error..).
Proposing below mentioned code changes in /opt/stack/nova/nova/cmd/manage.py.
class VmCommands(object):
....
+ @args('--status', metavar='<status>', help='Vm state')
- def list(self, host=None):
+ def list(self, host=None,status=None):
"""Show a list of all instances."""
+ if status is not None:
+ filters={'vm_state': status}
+ else:
+ filters={}
+
if host is None: instances = objects.InstanceList.get_by_filters(
- context.get_admin_context(), {}, expected_attrs=['flavor'])
+ context.get_admin_context(), filters, expected_attrs=['flavor'])
with these changes "nova-manage vm list" help text dispalys as follows ,
stack@tcs:~/devstack$ nova-manage vm list -h
No handlers could be found for logger "oslo_config.cfg"
usage: nova-manage vm list [-h] [--host <host>] [--status <status>]
optional arguments:
-h, --help show this help message and exit
--host <host> Host
--status <status> Vm state
Hi,
As described in bug, We are proposing a new parameter --status for "nova-manage vm list" command.
Updated filter accordingly to get the vms from db by status( active, error.. ).
Proposing below mentioned code changes in /opt/stack/ nova/nova/ cmd/manage. py.
class VmCommands(object): status= None):
....
+ @args('--status', metavar='<status>', help='Vm state')
- def list(self, host=None):
+ def list(self, host=None,
"""Show a list of all instances."""
@@ -674,9 +676,19 @@ class VmCommands(object):
+ if status is not None: {'vm_state' : status}
instances = objects. InstanceList. get_by_ filters( get_admin_ context( ), {}, expected_ attrs=[ 'flavor' ]) get_admin_ context( ), filters, expected_ attrs=[ 'flavor' ])
+ filters=
+ else:
+ filters={}
+
if host is None:
- context.
+ context.
with these changes "nova-manage vm list" help text dispalys as follows ,
stack@tcs: ~/devstack$ nova-manage vm list -h
No handlers could be found for logger "oslo_config.cfg"
usage: nova-manage vm list [-h] [--host <host>] [--status <status>]
optional arguments:
-h, --help show this help message and exit
--host <host> Host
--status <status> Vm state
Please share your comments.