summaryrefslogtreecommitdiff
path: root/nova/cmd
diff options
context:
space:
mode:
authorLee Yarwood <lyarwood@redhat.com>2021-01-05 15:20:44 +0000
committerLee Yarwood <lyarwood@redhat.com>2021-03-03 14:03:49 +0000
commit9a5b07d9fc000765eeb0687f374f2803a73f3b7d (patch)
tree932b1253d4605609897bfc4acad40cb2c6c9f39e /nova/cmd
parentc70cde057d20bb2c05a133e52b9ec560bd792698 (diff)
downloadnova-9a5b07d9fc000765eeb0687f374f2803a73f3b7d.tar.gz
nova-manage: Add libvirt list_unset_machine_type command
This change adds a libvirt command to list all instance UUIDs with hw_machine_type unset in their image metadata. This will be useful to operators attempting to change the [libvirt]hw_machine_type default in the future as it allows them to confirm if it is safe to change the configurable without impacting existing instances. blueprint: libvirt-default-machine-type Change-Id: I39909ace97f62e87f326d4d822d4e4c391445765
Diffstat (limited to 'nova/cmd')
-rw-r--r--nova/cmd/manage.py31
1 files changed, 31 insertions, 0 deletions
diff --git a/nova/cmd/manage.py b/nova/cmd/manage.py
index d0d9938391..73d2832c84 100644
--- a/nova/cmd/manage.py
+++ b/nova/cmd/manage.py
@@ -2718,6 +2718,37 @@ class LibvirtCommands(object):
'previous_type': ptype})
return 0
+ @action_description(
+ _("List the UUIDs of instances that do not have hw_machine_type set "
+ "in their image metadata"))
+ @args('--cell-uuid', metavar='<cell_uuid>', dest='cell_uuid',
+ required=False, help='UUID of cell from which to list instances')
+ def list_unset_machine_type(self, cell_uuid=None):
+ """List the UUIDs of instances without image_hw_machine_type set
+
+ Return codes:
+ * 0: Command completed successfully, no instances found.
+ * 1: An unexpected error happened.
+ * 2: Unable to find cell mapping.
+ * 3: Instances found without hw_machine_type set.
+ """
+ try:
+ instance_list = machine_type_utils.get_instances_without_type(
+ context.get_admin_context(), cell_uuid)
+ except exception.CellMappingNotFound as e:
+ print(str(e))
+ return 2
+ except Exception:
+ LOG.exception('Unexpected error')
+ return 1
+
+ if instance_list:
+ print('\n'.join(i.uuid for i in instance_list))
+ return 3
+ else:
+ print(_("No instances found without hw_machine_type set."))
+ return 0
+
CATEGORIES = {
'api_db': ApiDbCommands,