summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Smith <dansmith@redhat.com>2017-09-05 14:50:18 -0700
committerMatt Riedemann <mriedem.os@gmail.com>2017-09-20 21:33:42 -0400
commit3bd05a197b4e36ff9b1819a8e831a50f9fc63e81 (patch)
tree9128bd1824ef8a7a3c17f9361f3c73bfd0298e8b
parentedd59ae12d11db770cf7e1b0c306be34aacd3d2b (diff)
downloadnova-3bd05a197b4e36ff9b1819a8e831a50f9fc63e81.tar.gz
Split out the core of the ironic flavor migration
This is split out to a staticmethod so we can call it externally and push the migration offline. Change-Id: Iec45e4a48d2c3893a999cb0570feb6874acca3eb (cherry picked from commit 10661dc5e2e3f2e2f37b6a86ea22f71b4b833fc9)
-rw-r--r--nova/virt/ironic/driver.py30
1 files changed, 18 insertions, 12 deletions
diff --git a/nova/virt/ironic/driver.py b/nova/virt/ironic/driver.py
index a3fd65394c..9219639206 100644
--- a/nova/virt/ironic/driver.py
+++ b/nova/virt/ironic/driver.py
@@ -509,6 +509,21 @@ class IronicDriver(virt_driver.ComputeDriver):
"""
self._refresh_hash_ring(nova_context.get_admin_context())
+ @staticmethod
+ def _pike_flavor_migration_for_node(ctx, node_rc, instance_uuid):
+ normalized_rc = obj_fields.ResourceClass.normalize_name(node_rc)
+ instance = objects.Instance.get_by_uuid(ctx, instance_uuid,
+ expected_attrs=["flavor"])
+ specs = instance.flavor.extra_specs
+ resource_key = "resources:%s" % normalized_rc
+ if resource_key in specs:
+ # The compute must have been restarted, and the instance.flavor
+ # has already been migrated
+ return False
+ specs[resource_key] = "1"
+ instance.save()
+ return True
+
def _pike_flavor_migration(self, node_uuids):
"""This code is needed in Pike to prevent problems where an operator
has already adjusted their flavors to add the custom resource class to
@@ -535,21 +550,12 @@ class IronicDriver(virt_driver.ComputeDriver):
continue
if node.instance_uuid in self._migrated_instance_uuids:
continue
- normalized_rc = obj_fields.ResourceClass.normalize_name(node_rc)
- instance = objects.Instance.get_by_uuid(ctx, node.instance_uuid,
- expected_attrs=["flavor"])
- specs = instance.flavor.extra_specs
- resource_key = "resources:%s" % normalized_rc
+ self._pike_flavor_migration_for_node(ctx, node_rc,
+ node.instance_uuid)
self._migrated_instance_uuids.add(node.instance_uuid)
- if resource_key in specs:
- # The compute must have been restarted, and the instance.flavor
- # has already been migrated
- continue
- specs[resource_key] = "1"
- instance.save()
LOG.debug("The flavor extra_specs for Ironic instance %(inst)s "
"have been updated for custom resource class '%(rc)s'.",
- {"inst": instance.uuid, "rc": node_rc})
+ {"inst": node.instance_uuid, "rc": node_rc})
return
def _get_hypervisor_type(self):