@@ -4295,23 +4295,8 @@ def finish_revert_resize(
4295
4295
'migration_uuid' : migration .uuid })
4296
4296
raise
4297
4297
4298
- if request_spec :
4299
- # NOTE(gibi): We need to re-calculate the resource provider -
4300
- # port mapping as we have to have the neutron ports allocate
4301
- # from the source compute after revert.
4302
- scheduler_utils .fill_provider_mapping_based_on_allocation (
4303
- context , self .reportclient , request_spec ,
4304
- source_allocations )
4305
- provider_mappings = self ._get_request_group_mapping (
4306
- request_spec )
4307
- else :
4308
- # NOTE(gibi): The compute RPC is pinned to be older than 5.2
4309
- # and therefore request_spec is not sent. We cannot calculate
4310
- # the provider mappings. If the instance has ports with
4311
- # resource request then the port update will fail in
4312
- # _update_port_binding_for_instance() called via
4313
- # _finish_revert_resize_network_migrate_finish() below.
4314
- provider_mappings = None
4298
+ provider_mappings = self ._fill_provider_mapping_based_on_allocs (
4299
+ context , source_allocations , request_spec )
4315
4300
4316
4301
self .network_api .setup_networks_on_host (context , instance ,
4317
4302
migration .source_compute )
@@ -4363,6 +4348,39 @@ def finish_revert_resize(
4363
4348
self .host , action = fields .NotificationAction .RESIZE_REVERT ,
4364
4349
phase = fields .NotificationPhase .END , bdms = bdms )
4365
4350
4351
+ def _fill_provider_mapping_based_on_allocs (
4352
+ self , context , allocations , request_spec ):
4353
+ """Fills and returns the request group - resource provider mapping
4354
+ based on the allocation passed in.
4355
+
4356
+ :param context: The security context
4357
+ :param allocation: allocation dict keyed by RP UUID.
4358
+ :param request_spec: The RequestSpec object associated with the
4359
+ operation
4360
+ :returns: None if the request_spec is None. Otherwise a mapping
4361
+ between RequestGroup requester_id, currently Neutron port_id,
4362
+ and a list of resource provider UUIDs providing resource for
4363
+ that RequestGroup.
4364
+ """
4365
+ if request_spec :
4366
+ # NOTE(gibi): We need to re-calculate the resource provider -
4367
+ # port mapping as we have to have the neutron ports allocate
4368
+ # from the source compute after revert.
4369
+ scheduler_utils .fill_provider_mapping_based_on_allocation (
4370
+ context , self .reportclient , request_spec , allocations )
4371
+ provider_mappings = self ._get_request_group_mapping (
4372
+ request_spec )
4373
+ else :
4374
+ # NOTE(gibi): The compute RPC is pinned to be older than 5.2
4375
+ # and therefore request_spec is not sent. We cannot calculate
4376
+ # the provider mappings. If the instance has ports with
4377
+ # resource request then the port update will fail in
4378
+ # _update_port_binding_for_instance() called via
4379
+ # _finish_revert_resize_network_migrate_finish() in
4380
+ # finish_revert_resize.
4381
+ provider_mappings = None
4382
+ return provider_mappings
4383
+
4366
4384
def _revert_allocation (self , context , instance , migration ):
4367
4385
"""Revert an allocation that is held by migration to our instance."""
4368
4386
0 commit comments