|
39 | 39 | from nova.i18n import _ |
40 | 40 | from nova import objects |
41 | 41 | from nova.objects import base as obj_base |
| 42 | +from nova.objects import fields |
42 | 43 | from nova.objects import migration as migration_obj |
43 | 44 | from nova.pci import manager as pci_manager |
44 | 45 | from nova.pci import request as pci_request |
@@ -191,9 +192,10 @@ def rebuild_claim(self, context, instance, nodename, allocations, |
191 | 192 | limits=None, image_meta=None, migration=None): |
192 | 193 | """Create a claim for a rebuild operation.""" |
193 | 194 | instance_type = instance.flavor |
194 | | - return self._move_claim(context, instance, instance_type, nodename, |
195 | | - migration, allocations, move_type='evacuation', |
196 | | - limits=limits, image_meta=image_meta) |
| 195 | + return self._move_claim( |
| 196 | + context, instance, instance_type, nodename, migration, allocations, |
| 197 | + move_type=fields.MigrationType.EVACUATION, |
| 198 | + image_meta=image_meta, limits=limits) |
197 | 199 |
|
198 | 200 | @utils.synchronized(COMPUTE_RESOURCE_SEMAPHORE, fair=True) |
199 | 201 | def resize_claim(self, context, instance, instance_type, nodename, |
@@ -225,9 +227,11 @@ def live_migration_claim(self, context, instance, nodename, migration, |
225 | 227 | # Flavor and image cannot change during a live migration. |
226 | 228 | instance_type = instance.flavor |
227 | 229 | image_meta = instance.image_meta |
228 | | - return self._move_claim(context, instance, instance_type, nodename, |
229 | | - migration, allocs, move_type='live-migration', |
230 | | - image_meta=image_meta, limits=limits) |
| 230 | + return self._move_claim( |
| 231 | + context, instance, instance_type, nodename, migration, allocs, |
| 232 | + move_type=fields.MigrationType.LIVE_MIGRATION, |
| 233 | + image_meta=image_meta, limits=limits, |
| 234 | + ) |
231 | 235 |
|
232 | 236 | def _move_claim(self, context, instance, new_instance_type, nodename, |
233 | 237 | migration, allocations, move_type=None, |
@@ -293,7 +297,7 @@ def _move_claim(self, context, instance, new_instance_type, nodename, |
293 | 297 | # migration to avoid stepping on that code's toes. Ideally, |
294 | 298 | # MoveClaim/this method would be used for all live migration resource |
295 | 299 | # claims. |
296 | | - if self.pci_tracker and migration.migration_type != 'live-migration': |
| 300 | + if self.pci_tracker and not migration.is_live_migration: |
297 | 301 | # NOTE(jaypipes): ComputeNode.pci_device_pools is set below |
298 | 302 | # in _update_usage_from_instance(). |
299 | 303 | claimed_pci_devices_objs = self.pci_tracker.claim_instance( |
@@ -369,7 +373,7 @@ def _claim_existing_migration(self, migration, nodename): |
369 | 373 | # NOTE(artom) Migration objects for live migrations are created with |
370 | 374 | # status 'accepted' by the conductor in live_migrate_instance() and do |
371 | 375 | # not have a 'pre-migrating' status. |
372 | | - if migration.migration_type != 'live-migration': |
| 376 | + if not migration.is_live_migration: |
373 | 377 | migration.status = 'pre-migrating' |
374 | 378 | migration.save() |
375 | 379 |
|
@@ -1637,8 +1641,7 @@ def _verify_resources(self, resources): |
1637 | 1641 |
|
1638 | 1642 | def _get_instance_type(self, instance, prefix, migration): |
1639 | 1643 | """Get the instance type from instance.""" |
1640 | | - stashed_flavors = migration.migration_type in ('resize',) |
1641 | | - if stashed_flavors: |
| 1644 | + if migration.is_resize: |
1642 | 1645 | return getattr(instance, '%sflavor' % prefix) |
1643 | 1646 | else: |
1644 | 1647 | # NOTE(ndipanov): Certain migration types (all but resize) |
|
0 commit comments