Merge "Clean up ComputeManager._get_instance_nw_info"
This commit is contained in:
@@ -840,8 +840,8 @@ class ComputeManager(manager.Manager):
|
||||
{'instance_host': instance.host,
|
||||
'our_host': our_host}, instance=instance)
|
||||
try:
|
||||
network_info = self._get_instance_nw_info(context,
|
||||
instance)
|
||||
network_info = self.network_api.get_instance_nw_info(
|
||||
context, instance)
|
||||
bdi = self._get_instance_block_device_info(context,
|
||||
instance)
|
||||
destroy_disks = not (self._is_instance_storage_shared(
|
||||
@@ -1374,10 +1374,6 @@ class ComputeManager(manager.Manager):
|
||||
"""This call passes straight through to the virtualization driver."""
|
||||
return self.driver.refresh_provider_fw_rules()
|
||||
|
||||
def _get_instance_nw_info(self, context, instance):
|
||||
"""Get a list of dictionaries of network data of an instance."""
|
||||
return self.network_api.get_instance_nw_info(context, instance)
|
||||
|
||||
def _await_block_device_map_created(self, context, vol_id):
|
||||
# TODO(yamahata): creating volume simultaneously
|
||||
# reduces creation time?
|
||||
@@ -1833,7 +1829,7 @@ class ComputeManager(manager.Manager):
|
||||
# network resource need setup on the new host.
|
||||
self.network_api.setup_instance_network_on_host(
|
||||
context, instance, instance.host)
|
||||
return self._get_instance_nw_info(context, instance)
|
||||
return self.network_api.get_instance_nw_info(context, instance)
|
||||
|
||||
if not self.is_neutron_security_groups:
|
||||
security_groups = []
|
||||
@@ -2820,7 +2816,7 @@ class ComputeManager(manager.Manager):
|
||||
do_stop_instance()
|
||||
|
||||
def _power_on(self, context, instance):
|
||||
network_info = self._get_instance_nw_info(context, instance)
|
||||
network_info = self.network_api.get_instance_nw_info(context, instance)
|
||||
block_device_info = self._get_instance_block_device_info(context,
|
||||
instance)
|
||||
self.driver.power_on(context, instance,
|
||||
@@ -3142,7 +3138,7 @@ class ComputeManager(manager.Manager):
|
||||
block_device_info = self._get_instance_block_device_info(context,
|
||||
instance)
|
||||
|
||||
network_info = self._get_instance_nw_info(context, instance)
|
||||
network_info = self.network_api.get_instance_nw_info(context, instance)
|
||||
|
||||
self._notify_about_instance_usage(context, instance, "reboot.start")
|
||||
|
||||
@@ -3503,7 +3499,7 @@ class ComputeManager(manager.Manager):
|
||||
admin_password = (rescue_password if rescue_password else
|
||||
utils.generate_password())
|
||||
|
||||
network_info = self._get_instance_nw_info(context, instance)
|
||||
network_info = self.network_api.get_instance_nw_info(context, instance)
|
||||
|
||||
rescue_image_meta = self._get_rescue_image(context, instance,
|
||||
rescue_image_ref)
|
||||
@@ -3549,7 +3545,7 @@ class ComputeManager(manager.Manager):
|
||||
context = context.elevated()
|
||||
LOG.info(_LI('Unrescuing'), context=context, instance=instance)
|
||||
|
||||
network_info = self._get_instance_nw_info(context, instance)
|
||||
network_info = self.network_api.get_instance_nw_info(context, instance)
|
||||
self._notify_about_instance_usage(context, instance,
|
||||
"unrescue.start", network_info=network_info)
|
||||
with self._error_out_instance_on_exception(context, instance):
|
||||
@@ -3676,7 +3672,8 @@ class ComputeManager(manager.Manager):
|
||||
self.network_api.setup_networks_on_host(context, instance,
|
||||
migration.source_compute, teardown=True)
|
||||
|
||||
network_info = self._get_instance_nw_info(context, instance)
|
||||
network_info = self.network_api.get_instance_nw_info(context,
|
||||
instance)
|
||||
self.driver.confirm_migration(migration, instance,
|
||||
network_info)
|
||||
|
||||
@@ -3745,7 +3742,8 @@ class ComputeManager(manager.Manager):
|
||||
instance,
|
||||
migration_p)
|
||||
|
||||
network_info = self._get_instance_nw_info(context, instance)
|
||||
network_info = self.network_api.get_instance_nw_info(context,
|
||||
instance)
|
||||
bdms = objects.BlockDeviceMappingList.get_by_instance_uuid(
|
||||
context, instance.uuid)
|
||||
block_device_info = self._get_instance_block_device_info(
|
||||
@@ -3787,7 +3785,8 @@ class ComputeManager(manager.Manager):
|
||||
|
||||
with self._error_out_instance_on_exception(context, instance,
|
||||
quotas=quotas):
|
||||
network_info = self._get_instance_nw_info(context, instance)
|
||||
network_info = self.network_api.get_instance_nw_info(context,
|
||||
instance)
|
||||
|
||||
self._notify_about_instance_usage(
|
||||
context, instance, "resize.revert.start")
|
||||
@@ -4009,7 +4008,8 @@ class ComputeManager(manager.Manager):
|
||||
instance_type = objects.Flavor.get_by_id(
|
||||
context, migration['new_instance_type_id'])
|
||||
|
||||
network_info = self._get_instance_nw_info(context, instance)
|
||||
network_info = self.network_api.get_instance_nw_info(context,
|
||||
instance)
|
||||
|
||||
migration.status = 'migrating'
|
||||
with migration.obj_as_admin():
|
||||
@@ -4101,7 +4101,7 @@ class ComputeManager(manager.Manager):
|
||||
instance,
|
||||
migration_p)
|
||||
|
||||
network_info = self._get_instance_nw_info(context, instance)
|
||||
network_info = self.network_api.get_instance_nw_info(context, instance)
|
||||
|
||||
instance.task_state = task_states.RESIZE_FINISH
|
||||
instance.save(expected_task_state=task_states.RESIZE_MIGRATED)
|
||||
@@ -4343,7 +4343,7 @@ class ComputeManager(manager.Manager):
|
||||
LOG.info(_LI('Resuming'), context=context, instance=instance)
|
||||
|
||||
self._notify_about_instance_usage(context, instance, 'resume.start')
|
||||
network_info = self._get_instance_nw_info(context, instance)
|
||||
network_info = self.network_api.get_instance_nw_info(context, instance)
|
||||
block_device_info = self._get_instance_block_device_info(
|
||||
context, instance)
|
||||
|
||||
@@ -4439,7 +4439,7 @@ class ComputeManager(manager.Manager):
|
||||
|
||||
self.network_api.cleanup_instance_network_on_host(context, instance,
|
||||
instance.host)
|
||||
network_info = self._get_instance_nw_info(context, instance)
|
||||
network_info = self.network_api.get_instance_nw_info(context, instance)
|
||||
block_device_info = self._get_instance_block_device_info(context,
|
||||
instance)
|
||||
self.driver.destroy(context, instance, network_info,
|
||||
@@ -4519,7 +4519,7 @@ class ComputeManager(manager.Manager):
|
||||
|
||||
self.network_api.setup_instance_network_on_host(context, instance,
|
||||
self.host)
|
||||
network_info = self._get_instance_nw_info(context, instance)
|
||||
network_info = self.network_api.get_instance_nw_info(context, instance)
|
||||
try:
|
||||
with rt.instance_claim(context, instance, limits):
|
||||
self.driver.spawn(context, instance, image, injected_files=[],
|
||||
@@ -4560,7 +4560,7 @@ class ComputeManager(manager.Manager):
|
||||
@wrap_instance_fault
|
||||
def inject_network_info(self, context, instance):
|
||||
"""Inject network info, but don't return the info."""
|
||||
network_info = self._get_instance_nw_info(context, instance)
|
||||
network_info = self.network_api.get_instance_nw_info(context, instance)
|
||||
self._inject_network_info(context, instance, network_info)
|
||||
|
||||
@object_compat
|
||||
@@ -5197,7 +5197,7 @@ class ComputeManager(manager.Manager):
|
||||
block_device_info = self._get_instance_block_device_info(
|
||||
context, instance, refresh_conn_info=True)
|
||||
|
||||
network_info = self._get_instance_nw_info(context, instance)
|
||||
network_info = self.network_api.get_instance_nw_info(context, instance)
|
||||
self._notify_about_instance_usage(
|
||||
context, instance, "live_migration.pre.start",
|
||||
network_info=network_info)
|
||||
@@ -5361,7 +5361,7 @@ class ComputeManager(manager.Manager):
|
||||
# Releasing vlan.
|
||||
# (not necessary in current implementation?)
|
||||
|
||||
network_info = self._get_instance_nw_info(ctxt, instance)
|
||||
network_info = self.network_api.get_instance_nw_info(ctxt, instance)
|
||||
|
||||
self._notify_about_instance_usage(ctxt, instance,
|
||||
"live_migration._post.start",
|
||||
@@ -5466,7 +5466,7 @@ class ComputeManager(manager.Manager):
|
||||
instance,
|
||||
migration)
|
||||
|
||||
network_info = self._get_instance_nw_info(context, instance)
|
||||
network_info = self.network_api.get_instance_nw_info(context, instance)
|
||||
self._notify_about_instance_usage(
|
||||
context, instance, "live_migration.post.dest.start",
|
||||
network_info=network_info)
|
||||
@@ -5555,7 +5555,7 @@ class ComputeManager(manager.Manager):
|
||||
:param context: security context
|
||||
:param instance: a nova.objects.instance.Instance object sent over rpc
|
||||
"""
|
||||
network_info = self._get_instance_nw_info(context, instance)
|
||||
network_info = self.network_api.get_instance_nw_info(context, instance)
|
||||
self._notify_about_instance_usage(
|
||||
context, instance, "live_migration.rollback.dest.start",
|
||||
network_info=network_info)
|
||||
@@ -5654,7 +5654,7 @@ class ComputeManager(manager.Manager):
|
||||
try:
|
||||
# Call to network API to get instance info.. this will
|
||||
# force an update to the instance's info_cache
|
||||
self._get_instance_nw_info(context, instance)
|
||||
self.network_api.get_instance_nw_info(context, instance)
|
||||
LOG.debug('Updated the network info_cache for instance',
|
||||
instance=instance)
|
||||
except exception.InstanceNotFound:
|
||||
|
||||
@@ -254,8 +254,7 @@ class BaseTestCase(test.TestCase):
|
||||
fake_server_actions.stub_out_action_events(self.stubs)
|
||||
|
||||
def fake_get_nw_info(cls, ctxt, instance, *args, **kwargs):
|
||||
self.assertTrue(ctxt.is_admin)
|
||||
return fake_network.fake_get_instance_nw_info(self.stubs, 1, 1)
|
||||
return network_model.NetworkInfo()
|
||||
|
||||
self.stubs.Set(network_api.API, 'get_instance_nw_info',
|
||||
fake_get_nw_info)
|
||||
@@ -2593,7 +2592,8 @@ class ComputeTestCase(BaseTestCase):
|
||||
|
||||
self.mox.StubOutWithMock(self.compute,
|
||||
'_get_instance_block_device_info')
|
||||
self.mox.StubOutWithMock(self.compute, '_get_instance_nw_info')
|
||||
self.mox.StubOutWithMock(self.compute.network_api,
|
||||
'get_instance_nw_info')
|
||||
self.mox.StubOutWithMock(self.compute, '_notify_about_instance_usage')
|
||||
self.mox.StubOutWithMock(self.compute, '_instance_update')
|
||||
self.mox.StubOutWithMock(db, 'instance_update_and_get_original')
|
||||
@@ -2649,9 +2649,8 @@ class ComputeTestCase(BaseTestCase):
|
||||
|
||||
self.compute._get_instance_block_device_info(
|
||||
econtext, instance).AndReturn(fake_block_dev_info)
|
||||
self.compute._get_instance_nw_info(econtext,
|
||||
instance).AndReturn(
|
||||
fake_nw_model)
|
||||
self.compute.network_api.get_instance_nw_info(
|
||||
econtext, instance).AndReturn(fake_nw_model)
|
||||
self.compute._notify_about_instance_usage(econtext,
|
||||
instance,
|
||||
'reboot.start')
|
||||
@@ -4414,7 +4413,8 @@ class ComputeTestCase(BaseTestCase):
|
||||
self.mox.StubOutWithMock(network_api, 'setup_networks_on_host')
|
||||
self.mox.StubOutWithMock(network_api,
|
||||
'migrate_instance_finish')
|
||||
self.mox.StubOutWithMock(self.compute, '_get_instance_nw_info')
|
||||
self.mox.StubOutWithMock(self.compute.network_api,
|
||||
'get_instance_nw_info')
|
||||
self.mox.StubOutWithMock(self.compute,
|
||||
'_notify_about_instance_usage')
|
||||
self.mox.StubOutWithMock(self.compute.driver, 'finish_migration')
|
||||
@@ -4464,7 +4464,7 @@ class ComputeTestCase(BaseTestCase):
|
||||
mox.IsA(objects.Instance),
|
||||
mox.IsA(dict))
|
||||
|
||||
self.compute._get_instance_nw_info(
|
||||
self.compute.network_api.get_instance_nw_info(
|
||||
self.context, instance).AndReturn('fake-nwinfo1')
|
||||
|
||||
# Third save to update task state
|
||||
@@ -5421,8 +5421,8 @@ class ComputeTestCase(BaseTestCase):
|
||||
# Confirm setup_compute_volume is called when volume is mounted.
|
||||
def stupid(*args, **kwargs):
|
||||
return fake_network.fake_get_instance_nw_info(self.stubs)
|
||||
self.stubs.Set(nova.compute.manager.ComputeManager,
|
||||
'_get_instance_nw_info', stupid)
|
||||
self.stubs.Set(self.compute.network_api,
|
||||
'get_instance_nw_info', stupid)
|
||||
|
||||
# creating instance testdata
|
||||
instance = self._create_fake_instance_obj({'host': 'dummy'})
|
||||
@@ -6153,26 +6153,6 @@ class ComputeTestCase(BaseTestCase):
|
||||
val = self.compute._running_deleted_instances(admin_context)
|
||||
self.assertEqual(val, [instance1])
|
||||
|
||||
def test_get_instance_nw_info(self):
|
||||
fake_network.unset_stub_network_methods(self.stubs)
|
||||
|
||||
fake_inst = fake_instance.fake_db_instance(uuid='fake-instance')
|
||||
fake_nw_info = network_model.NetworkInfo()
|
||||
|
||||
self.mox.StubOutWithMock(self.compute.network_api,
|
||||
'get_instance_nw_info')
|
||||
|
||||
self.compute.network_api.get_instance_nw_info(self.context,
|
||||
mox.IsA(objects.Instance)).AndReturn(fake_nw_info)
|
||||
|
||||
self.mox.ReplayAll()
|
||||
|
||||
fake_inst_obj = objects.Instance._from_db_object(
|
||||
self.context, objects.Instance(), fake_inst, [])
|
||||
result = self.compute._get_instance_nw_info(self.context,
|
||||
fake_inst_obj)
|
||||
self.assertEqual(fake_nw_info, result)
|
||||
|
||||
def _heal_instance_info_cache(self, _get_instance_nw_info_raise=False):
|
||||
# Update on every call for the test
|
||||
self.flags(heal_instance_info_cache_interval=-1)
|
||||
@@ -6222,7 +6202,7 @@ class ComputeTestCase(BaseTestCase):
|
||||
fake_instance_get_all_by_host)
|
||||
self.stubs.Set(db, 'instance_get_by_uuid',
|
||||
fake_instance_get_by_uuid)
|
||||
self.stubs.Set(self.compute, '_get_instance_nw_info',
|
||||
self.stubs.Set(self.compute.network_api, 'get_instance_nw_info',
|
||||
fake_get_instance_nw_info)
|
||||
|
||||
# Make an instance appear to be still Building
|
||||
@@ -6558,8 +6538,8 @@ class ComputeTestCase(BaseTestCase):
|
||||
|
||||
self.mox.StubOutWithMock(self.compute,
|
||||
'_get_instances_on_driver')
|
||||
self.mox.StubOutWithMock(self.compute,
|
||||
'_get_instance_nw_info')
|
||||
self.mox.StubOutWithMock(self.compute.network_api,
|
||||
'get_instance_nw_info')
|
||||
self.mox.StubOutWithMock(self.compute,
|
||||
'_get_instance_block_device_info')
|
||||
self.mox.StubOutWithMock(self.compute,
|
||||
@@ -6568,9 +6548,8 @@ class ComputeTestCase(BaseTestCase):
|
||||
|
||||
self.compute._get_instances_on_driver(
|
||||
fake_context, {'deleted': False}).AndReturn(instances)
|
||||
self.compute._get_instance_nw_info(fake_context,
|
||||
evacuated_instance).AndReturn(
|
||||
'fake_network_info')
|
||||
self.compute.network_api.get_instance_nw_info(
|
||||
fake_context, evacuated_instance).AndReturn('fake_network_info')
|
||||
self.compute._get_instance_block_device_info(
|
||||
fake_context, evacuated_instance).AndReturn('fake_bdi')
|
||||
self.compute._is_instance_storage_shared(fake_context,
|
||||
@@ -6605,8 +6584,8 @@ class ComputeTestCase(BaseTestCase):
|
||||
|
||||
self.mox.StubOutWithMock(self.compute,
|
||||
'_get_instances_on_driver')
|
||||
self.mox.StubOutWithMock(self.compute,
|
||||
'_get_instance_nw_info')
|
||||
self.mox.StubOutWithMock(self.compute.network_api,
|
||||
'get_instance_nw_info')
|
||||
self.mox.StubOutWithMock(self.compute,
|
||||
'_get_instance_block_device_info')
|
||||
self.mox.StubOutWithMock(self.compute.driver,
|
||||
@@ -6619,9 +6598,8 @@ class ComputeTestCase(BaseTestCase):
|
||||
|
||||
self.compute._get_instances_on_driver(
|
||||
fake_context, {'deleted': False}).AndReturn(instances)
|
||||
self.compute._get_instance_nw_info(fake_context,
|
||||
evacuated_instance).AndReturn(
|
||||
'fake_network_info')
|
||||
self.compute.network_api.get_instance_nw_info(
|
||||
fake_context, evacuated_instance).AndReturn('fake_network_info')
|
||||
self.compute._get_instance_block_device_info(
|
||||
fake_context, evacuated_instance).AndReturn('fake_bdi')
|
||||
self.compute.driver.check_instance_shared_storage_local(fake_context,
|
||||
@@ -6661,8 +6639,8 @@ class ComputeTestCase(BaseTestCase):
|
||||
|
||||
self.mox.StubOutWithMock(self.compute,
|
||||
'_get_instances_on_driver')
|
||||
self.mox.StubOutWithMock(self.compute,
|
||||
'_get_instance_nw_info')
|
||||
self.mox.StubOutWithMock(self.compute.network_api,
|
||||
'get_instance_nw_info')
|
||||
self.mox.StubOutWithMock(self.compute,
|
||||
'_get_instance_block_device_info')
|
||||
self.mox.StubOutWithMock(self.compute.driver,
|
||||
@@ -6675,9 +6653,8 @@ class ComputeTestCase(BaseTestCase):
|
||||
|
||||
self.compute._get_instances_on_driver(
|
||||
fake_context, {'deleted': False}).AndReturn(instances)
|
||||
self.compute._get_instance_nw_info(fake_context,
|
||||
evacuated_instance).AndReturn(
|
||||
'fake_network_info')
|
||||
self.compute.network_api.get_instance_nw_info(
|
||||
fake_context, evacuated_instance).AndReturn('fake_network_info')
|
||||
self.compute._get_instance_block_device_info(
|
||||
fake_context, evacuated_instance).AndReturn('fake_bdi')
|
||||
self.compute.driver.check_instance_shared_storage_local(fake_context,
|
||||
@@ -10981,7 +10958,7 @@ class ComputeRescheduleOrErrorTestCase(BaseTestCase):
|
||||
with contextlib.nested(
|
||||
mock.patch.object(self.context, 'elevated',
|
||||
return_value=elevated_context),
|
||||
mock.patch.object(self.compute, '_get_instance_nw_info',
|
||||
mock.patch.object(self.compute.network_api, 'get_instance_nw_info',
|
||||
side_effect=error),
|
||||
mock.patch.object(self.compute,
|
||||
'_get_instance_block_device_info'),
|
||||
|
||||
@@ -535,7 +535,8 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase):
|
||||
self.mox.StubOutWithMock(self.compute, 'init_virt_events')
|
||||
self.mox.StubOutWithMock(self.compute, '_get_instances_on_driver')
|
||||
self.mox.StubOutWithMock(self.compute, '_init_instance')
|
||||
self.mox.StubOutWithMock(self.compute, '_get_instance_nw_info')
|
||||
self.mox.StubOutWithMock(self.compute.network_api,
|
||||
'get_instance_nw_info')
|
||||
|
||||
self.compute.driver.init_host(host=our_host)
|
||||
context.get_admin_context().AndReturn(self.context)
|
||||
@@ -548,9 +549,9 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase):
|
||||
# simulate failed instance
|
||||
self.compute._get_instances_on_driver(
|
||||
self.context, {'deleted': False}).AndReturn([deleted_instance])
|
||||
self.compute._get_instance_nw_info(self.context, deleted_instance
|
||||
).AndRaise(exception.InstanceNotFound(
|
||||
instance_id=deleted_instance['uuid']))
|
||||
self.compute.network_api.get_instance_nw_info(
|
||||
self.context, deleted_instance).AndRaise(
|
||||
exception.InstanceNotFound(instance_id=deleted_instance['uuid']))
|
||||
# ensure driver.destroy is called so that driver may
|
||||
# clean up any dangling files
|
||||
self.compute.driver.destroy(self.context, deleted_instance,
|
||||
@@ -1859,7 +1860,7 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase):
|
||||
with contextlib.nested(
|
||||
mock.patch.object(self.context, 'elevated',
|
||||
return_value=self.context),
|
||||
mock.patch.object(self.compute, '_get_instance_nw_info',
|
||||
mock.patch.object(self.compute.network_api, 'get_instance_nw_info',
|
||||
return_value=fake_nw_info),
|
||||
mock.patch.object(self.compute, '_get_rescue_image',
|
||||
return_value=rescue_image_meta),
|
||||
@@ -1927,7 +1928,7 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase):
|
||||
with contextlib.nested(
|
||||
mock.patch.object(self.context, 'elevated',
|
||||
return_value=self.context),
|
||||
mock.patch.object(self.compute, '_get_instance_nw_info',
|
||||
mock.patch.object(self.compute.network_api, 'get_instance_nw_info',
|
||||
return_value=fake_nw_info),
|
||||
mock.patch.object(self.compute, '_notify_about_instance_usage'),
|
||||
mock.patch.object(self.compute.driver, 'unrescue'),
|
||||
@@ -2100,14 +2101,14 @@ class ComputeManagerUnitTestCase(test.NoDBTestCase):
|
||||
mock.patch.object(self.compute, '_get_instances_on_driver',
|
||||
return_value=[instance_1,
|
||||
instance_2]),
|
||||
mock.patch.object(self.compute, '_get_instance_nw_info',
|
||||
mock.patch.object(self.compute.network_api, 'get_instance_nw_info',
|
||||
return_value=None),
|
||||
mock.patch.object(self.compute, '_get_instance_block_device_info',
|
||||
return_value={}),
|
||||
mock.patch.object(self.compute, '_is_instance_storage_shared',
|
||||
return_value=False),
|
||||
mock.patch.object(self.compute.driver, 'destroy')
|
||||
) as (_get_instances_on_driver, _get_instance_nw_info,
|
||||
) as (_get_instances_on_driver, get_instance_nw_info,
|
||||
_get_instance_block_device_info, _is_instance_storage_shared,
|
||||
destroy):
|
||||
self.compute._destroy_evacuated_instances(self.context)
|
||||
@@ -3452,7 +3453,8 @@ class ComputeManagerBuildInstanceTestCase(test.NoDBTestCase):
|
||||
system_metadata={},
|
||||
expected_attrs=['system_metadata'])
|
||||
|
||||
self.mox.StubOutWithMock(self.compute, '_get_instance_nw_info')
|
||||
self.mox.StubOutWithMock(self.compute.network_api,
|
||||
'get_instance_nw_info')
|
||||
self.mox.StubOutWithMock(self.compute, '_allocate_network')
|
||||
self.compute._allocate_network(self.context, instance,
|
||||
self.requested_networks, None, self.security_groups, None)
|
||||
@@ -3466,7 +3468,8 @@ class ComputeManagerBuildInstanceTestCase(test.NoDBTestCase):
|
||||
system_metadata=dict(network_allocated='False'),
|
||||
expected_attrs=['system_metadata'])
|
||||
|
||||
self.mox.StubOutWithMock(self.compute, '_get_instance_nw_info')
|
||||
self.mox.StubOutWithMock(self.compute.network_api,
|
||||
'get_instance_nw_info')
|
||||
self.mox.StubOutWithMock(self.compute, '_allocate_network')
|
||||
self.compute._allocate_network(self.context, instance,
|
||||
self.requested_networks, None, self.security_groups, None)
|
||||
@@ -3483,14 +3486,16 @@ class ComputeManagerBuildInstanceTestCase(test.NoDBTestCase):
|
||||
def fake_network_info():
|
||||
return network_model.NetworkInfo([{'address': '123.123.123.123'}])
|
||||
|
||||
self.mox.StubOutWithMock(self.compute, '_get_instance_nw_info')
|
||||
self.mox.StubOutWithMock(self.compute.network_api,
|
||||
'get_instance_nw_info')
|
||||
self.mox.StubOutWithMock(self.compute, '_allocate_network')
|
||||
self.mox.StubOutWithMock(self.compute.network_api,
|
||||
'setup_instance_network_on_host')
|
||||
self.compute.network_api.setup_instance_network_on_host(
|
||||
self.context, instance, instance.host)
|
||||
self.compute._get_instance_nw_info(self.context, instance).AndReturn(
|
||||
network_model.NetworkInfoAsyncWrapper(fake_network_info))
|
||||
self.compute.network_api.get_instance_nw_info(
|
||||
self.context, instance).AndReturn(
|
||||
network_model.NetworkInfoAsyncWrapper(fake_network_info))
|
||||
self.mox.ReplayAll()
|
||||
|
||||
self.compute._build_networks_for_instance(self.context, instance,
|
||||
@@ -3646,7 +3651,7 @@ class ComputeManagerMigrationTestCase(test.NoDBTestCase):
|
||||
mock.patch.object(self.migration, 'save'),
|
||||
mock.patch.object(self.migration, 'obj_as_admin',
|
||||
return_value=mock.MagicMock()),
|
||||
mock.patch.object(self.compute, '_get_instance_nw_info',
|
||||
mock.patch.object(self.compute.network_api, 'get_instance_nw_info',
|
||||
return_value=None),
|
||||
mock.patch.object(self.instance, 'save'),
|
||||
mock.patch.object(self.compute, '_notify_about_instance_usage'),
|
||||
@@ -3681,7 +3686,7 @@ class ComputeManagerMigrationTestCase(test.NoDBTestCase):
|
||||
# revert_resize() and the return value is passed to driver.destroy().
|
||||
# Otherwise we could regress this.
|
||||
|
||||
@mock.patch.object(self.compute, '_get_instance_nw_info')
|
||||
@mock.patch.object(self.compute.network_api, 'get_instance_nw_info')
|
||||
@mock.patch.object(self.compute, '_is_instance_storage_shared')
|
||||
@mock.patch.object(self.compute, 'finish_revert_resize')
|
||||
@mock.patch.object(self.compute, '_instance_update')
|
||||
@@ -3703,7 +3708,7 @@ class ComputeManagerMigrationTestCase(test.NoDBTestCase):
|
||||
_instance_update,
|
||||
finish_revert_resize,
|
||||
_is_instance_storage_shared,
|
||||
_get_instance_nw_info):
|
||||
get_instance_nw_info):
|
||||
|
||||
self.migration.source_compute = self.instance['host']
|
||||
|
||||
|
||||
@@ -352,7 +352,6 @@ def set_stub_network_methods(stubs):
|
||||
cm = compute_manager.ComputeManager
|
||||
if not _real_functions:
|
||||
_real_functions = {
|
||||
'_get_instance_nw_info': cm._get_instance_nw_info,
|
||||
'_allocate_network': cm._allocate_network,
|
||||
'_deallocate_network': cm._deallocate_network}
|
||||
|
||||
@@ -362,7 +361,6 @@ def set_stub_network_methods(stubs):
|
||||
def fake_async_networkinfo(*args, **kwargs):
|
||||
return network_model.NetworkInfoAsyncWrapper(fake_networkinfo)
|
||||
|
||||
stubs.Set(cm, '_get_instance_nw_info', fake_networkinfo)
|
||||
stubs.Set(cm, '_allocate_network', fake_async_networkinfo)
|
||||
stubs.Set(cm, '_deallocate_network', lambda *args, **kwargs: None)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user