Browse files

Merge "Deallocate the network if rescheduling for Ironic"

  • Loading branch information...
2 parents 57e4e9d + 963ad71 commit d6c2a70f79fd03ef624feddee359ee1cab50d039 Jenkins committed with openstack-gerrit Jul 17, 2014
Showing with 6 additions and 5 deletions.
  1. +4 −3 nova/compute/manager.py
  2. +2 −2 nova/tests/compute/test_compute_mgr.py
View
7 nova/compute/manager.py
@@ -1911,9 +1911,10 @@ def do_build_and_run_instance(context, instance, image, request_spec,
self._set_instance_error_state(context, instance.uuid)
return
retry['exc'] = traceback.format_exception(*sys.exc_info())
- # dhcp_options are per host, so if they're set we need to
- # deallocate the networks and reallocate on the next host.
- if self.driver.dhcp_options_for_instance(instance):
+ # The MAC address for this instance is tied to the host so if
+ # we're going to reschedule we have to free the network details
+ # and reallocate on the next host.
+ if self.driver.macs_for_instance(instance):
self._cleanup_allocated_networks(context, instance,
requested_networks)
View
4 nova/tests/compute/test_compute_mgr.py
@@ -1857,7 +1857,7 @@ def test_rescheduled_exception_do_not_deallocate_network(self):
def test_rescheduled_exception_deallocate_network_if_dhcp(self):
self.mox.StubOutWithMock(self.compute, '_build_and_run_instance')
self.mox.StubOutWithMock(self.compute.driver,
- 'dhcp_options_for_instance')
+ 'macs_for_instance')
self.mox.StubOutWithMock(self.compute, '_cleanup_allocated_networks')
self.mox.StubOutWithMock(self.compute.compute_task_api,
'build_instances')
@@ -1869,7 +1869,7 @@ def test_rescheduled_exception_deallocate_network_if_dhcp(self):
self.filter_properties).AndRaise(
exception.RescheduledException(reason='',
instance_uuid=self.instance['uuid']))
- self.compute.driver.dhcp_options_for_instance(self.instance).AndReturn(
+ self.compute.driver.macs_for_instance(self.instance).AndReturn(
{'fake': 'options'})
self.compute._cleanup_allocated_networks(self.context, self.instance,
self.requested_networks)

0 comments on commit d6c2a70

Please sign in to comment.