summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiana Clarke <diana.joan.clarke@gmail.com>2016-01-08 00:53:55 -0500
committerDiana Clarke <diana.joan.clarke@gmail.com>2016-01-13 22:19:38 -0500
commit88f406335ea2e76e48e7bf6331dc8a189f3698d9 (patch)
treeaed6c71df8973ec29628921dcfb86687c0c37a3b
parente75018664a8c94b2745500a7fd5c42e9b95dc5bc (diff)
downloadnova-88f406335ea2e76e48e7bf6331dc8a189f3698d9.tar.gz
Replace stubs.Set with stub_out (fakes)
As part of the ongoing effort to stop using mox, start replacing stubs.Set calls with stub_out. Limit the scope of this patch to the following fake functions: - fake_get_instance_nw_info - stub_nw_info - stub_out_instance_quota - stub_out_networking - stub_out_nw_api - stub_out_nw_api_get_instance_nw_info - set_stub_network_methods - stub_out_network_cleanup - unset_stub_network_methods Part of bp:remove-mox Change-Id: I70215fb25ef25422786b96d33c91d8f1d4760a23
-rw-r--r--nova/tests/functional/api_sample_tests/test_config_drive.py2
-rw-r--r--nova/tests/functional/api_sample_tests/test_volumes.py2
-rw-r--r--nova/tests/functional/db/test_archive.py2
-rw-r--r--nova/tests/functional/libvirt/test_numa_servers.py2
-rw-r--r--nova/tests/functional/libvirt/test_rt_servers.py4
-rw-r--r--nova/tests/functional/test_legacy_v2_compatible_wrapper.py4
-rw-r--r--nova/tests/functional/test_server_group.py2
-rw-r--r--nova/tests/functional/test_servers.py18
-rw-r--r--nova/tests/unit/api/openstack/compute/legacy_v2/test_auth.py2
-rw-r--r--nova/tests/unit/api/openstack/compute/legacy_v2/test_servers.py16
-rw-r--r--nova/tests/unit/api/openstack/compute/test_auth.py2
-rw-r--r--nova/tests/unit/api/openstack/compute/test_cloudpipe.py2
-rw-r--r--nova/tests/unit/api/openstack/compute/test_config_drive.py2
-rw-r--r--nova/tests/unit/api/openstack/compute/test_disk_config.py2
-rw-r--r--nova/tests/unit/api/openstack/compute/test_extended_availability_zone.py2
-rw-r--r--nova/tests/unit/api/openstack/compute/test_extended_ips.py2
-rw-r--r--nova/tests/unit/api/openstack/compute/test_extended_ips_mac.py2
-rw-r--r--nova/tests/unit/api/openstack/compute/test_extended_server_attributes.py2
-rw-r--r--nova/tests/unit/api/openstack/compute/test_extended_status.py2
-rw-r--r--nova/tests/unit/api/openstack/compute/test_extended_volumes.py2
-rw-r--r--nova/tests/unit/api/openstack/compute/test_flavor_disabled.py2
-rw-r--r--nova/tests/unit/api/openstack/compute/test_flavor_rxtx.py2
-rw-r--r--nova/tests/unit/api/openstack/compute/test_flavor_swap.py2
-rw-r--r--nova/tests/unit/api/openstack/compute/test_flavors.py2
-rw-r--r--nova/tests/unit/api/openstack/compute/test_floating_ips.py12
-rw-r--r--nova/tests/unit/api/openstack/compute/test_hide_server_addresses.py2
-rw-r--r--nova/tests/unit/api/openstack/compute/test_images.py2
-rw-r--r--nova/tests/unit/api/openstack/compute/test_keypairs.py2
-rw-r--r--nova/tests/unit/api/openstack/compute/test_multinic.py2
-rw-r--r--nova/tests/unit/api/openstack/compute/test_multiple_create.py4
-rw-r--r--nova/tests/unit/api/openstack/compute/test_networks.py6
-rw-r--r--nova/tests/unit/api/openstack/compute/test_neutron_security_groups.py2
-rw-r--r--nova/tests/unit/api/openstack/compute/test_security_groups.py2
-rw-r--r--nova/tests/unit/api/openstack/compute/test_server_actions.py2
-rw-r--r--nova/tests/unit/api/openstack/compute/test_server_password.py2
-rw-r--r--nova/tests/unit/api/openstack/compute/test_server_usage.py2
-rw-r--r--nova/tests/unit/api/openstack/compute/test_serversV21.py12
-rw-r--r--nova/tests/unit/api/openstack/compute/test_snapshots.py2
-rw-r--r--nova/tests/unit/api/openstack/compute/test_user_data.py2
-rw-r--r--nova/tests/unit/api/openstack/compute/test_volumes.py4
-rw-r--r--nova/tests/unit/api/openstack/fakes.py20
-rw-r--r--nova/tests/unit/compute/test_compute.py20
-rw-r--r--nova/tests/unit/compute/test_compute_mgr.py3
-rw-r--r--nova/tests/unit/compute/test_compute_utils.py4
-rw-r--r--nova/tests/unit/fake_network.py33
-rw-r--r--nova/tests/unit/network/test_manager.py4
-rw-r--r--nova/tests/unit/test_metadata.py12
-rw-r--r--nova/tests/unit/test_notifications.py4
-rw-r--r--nova/tests/unit/virt/libvirt/test_driver.py100
-rw-r--r--nova/tests/unit/virt/libvirt/test_firewall.py28
-rw-r--r--nova/tests/unit/virt/xenapi/test_xenapi.py26
51 files changed, 197 insertions, 199 deletions
diff --git a/nova/tests/functional/api_sample_tests/test_config_drive.py b/nova/tests/functional/api_sample_tests/test_config_drive.py
index bb5057f535..18901bbb76 100644
--- a/nova/tests/functional/api_sample_tests/test_config_drive.py
+++ b/nova/tests/functional/api_sample_tests/test_config_drive.py
@@ -43,7 +43,7 @@ class ConfigDriveSampleJsonTest(test_servers.ServersSampleBase):
def setUp(self):
super(ConfigDriveSampleJsonTest, self).setUp()
- fakes.stub_out_networking(self.stubs)
+ fakes.stub_out_networking(self)
fakes.stub_out_rate_limiting(self.stubs)
fake.stub_out_image_service(self)
diff --git a/nova/tests/functional/api_sample_tests/test_volumes.py b/nova/tests/functional/api_sample_tests/test_volumes.py
index ffb8cec4b6..cbadaa7466 100644
--- a/nova/tests/functional/api_sample_tests/test_volumes.py
+++ b/nova/tests/functional/api_sample_tests/test_volumes.py
@@ -146,7 +146,7 @@ class VolumesSampleJsonTest(test_servers.ServersSampleBase):
def setUp(self):
super(VolumesSampleJsonTest, self).setUp()
- fakes.stub_out_networking(self.stubs)
+ fakes.stub_out_networking(self)
fakes.stub_out_rate_limiting(self.stubs)
self.stubs.Set(cinder.API, "delete", self._stub_volume_delete)
diff --git a/nova/tests/functional/db/test_archive.py b/nova/tests/functional/db/test_archive.py
index 32dc03b971..8876676e86 100644
--- a/nova/tests/functional/db/test_archive.py
+++ b/nova/tests/functional/db/test_archive.py
@@ -53,7 +53,7 @@ class TestDatabaseArchive(test_servers.ServersTestBase):
"""
# TODO(mriedem): We should pull this up into the parent class so we
# don't have so much copy/paste in these functional tests.
- fake_network.set_stub_network_methods(self.stubs)
+ fake_network.set_stub_network_methods(self)
# Create a server
server = self._build_minimal_create_server_request()
diff --git a/nova/tests/functional/libvirt/test_numa_servers.py b/nova/tests/functional/libvirt/test_numa_servers.py
index 3aea72f04b..cd7e0e6a77 100644
--- a/nova/tests/functional/libvirt/test_numa_servers.py
+++ b/nova/tests/functional/libvirt/test_numa_servers.py
@@ -88,7 +88,7 @@ class NUMAServersTest(ServersTestBase):
def _run_build_test(self, flavor_id, filter_mock, end_status='ACTIVE'):
self.compute = self.start_service('compute', host='test_compute0')
- fake_network.set_stub_network_methods(self.stubs)
+ fake_network.set_stub_network_methods(self)
# Create server
good_server = self._build_server(flavor_id)
diff --git a/nova/tests/functional/libvirt/test_rt_servers.py b/nova/tests/functional/libvirt/test_rt_servers.py
index d4bde75bac..f7c9f51e14 100644
--- a/nova/tests/functional/libvirt/test_rt_servers.py
+++ b/nova/tests/functional/libvirt/test_rt_servers.py
@@ -96,7 +96,7 @@ class RealTimeServersTest(ServersTestBase):
with mock.patch('nova.virt.libvirt.host.Host.get_connection',
return_value=fake_connection):
self.compute = self.start_service('compute', host='test_compute0')
- fake_network.set_stub_network_methods(self.stubs)
+ fake_network.set_stub_network_methods(self)
flavor = self._create_flavor(extra_spec={
'hw:cpu_realtime': 'yes', 'hw:cpu_policy': 'dedicated'})
@@ -121,7 +121,7 @@ class RealTimeServersTest(ServersTestBase):
with mock.patch('nova.virt.libvirt.host.Host.get_connection',
return_value=fake_connection):
self.compute = self.start_service('compute', host='test_compute0')
- fake_network.set_stub_network_methods(self.stubs)
+ fake_network.set_stub_network_methods(self)
flavor = self._create_flavor(extra_spec={
'hw:cpu_realtime': 'yes',
diff --git a/nova/tests/functional/test_legacy_v2_compatible_wrapper.py b/nova/tests/functional/test_legacy_v2_compatible_wrapper.py
index 2262fecf18..2a550d09d0 100644
--- a/nova/tests/functional/test_legacy_v2_compatible_wrapper.py
+++ b/nova/tests/functional/test_legacy_v2_compatible_wrapper.py
@@ -46,7 +46,7 @@ class LegacyV2CompatibleTestBase(test_servers.ServersTestBase):
self.assertNotIn('type', response.body["keypair"])
def test_request_with_pattern_properties_check(self):
- fake_network.set_stub_network_methods(self.stubs)
+ fake_network.set_stub_network_methods(self)
server = self._build_minimal_create_server_request()
post = {'server': server}
created_server = self.api.post_server(post)
@@ -56,7 +56,7 @@ class LegacyV2CompatibleTestBase(test_servers.ServersTestBase):
self.assertEqual(response, {'a': 'b'})
def test_request_with_pattern_properties_with_avoid_metadata(self):
- fake_network.set_stub_network_methods(self.stubs)
+ fake_network.set_stub_network_methods(self)
server = self._build_minimal_create_server_request()
post = {'server': server}
created_server = self.api.post_server(post)
diff --git a/nova/tests/functional/test_server_group.py b/nova/tests/functional/test_server_group.py
index 61350c010d..f6edf9676c 100644
--- a/nova/tests/functional/test_server_group.py
+++ b/nova/tests/functional/test_server_group.py
@@ -178,7 +178,7 @@ class ServerGroupTestV2(ServerGroupTestBase):
self.compute2 = self.start_service('compute', host='host2')
self.addCleanup(self.compute.kill)
self.addCleanup(self.compute2.kill)
- fake_network.set_stub_network_methods(self.stubs)
+ fake_network.set_stub_network_methods(self)
def test_get_no_groups(self):
groups = self.api.get_server_groups()
diff --git a/nova/tests/functional/test_servers.py b/nova/tests/functional/test_servers.py
index 835cee55cf..9cd7bdda1f 100644
--- a/nova/tests/functional/test_servers.py
+++ b/nova/tests/functional/test_servers.py
@@ -105,7 +105,7 @@ class ServersTest(ServersTestBase):
def test_create_server_with_error(self):
# Create a server which will enter error state.
- fake_network.set_stub_network_methods(self.stubs)
+ fake_network.set_stub_network_methods(self)
def throw_error(*args, **kwargs):
raise exception.BuildAbortException(reason='',
@@ -127,7 +127,7 @@ class ServersTest(ServersTestBase):
def test_create_and_delete_server(self):
# Creates and deletes a server.
- fake_network.set_stub_network_methods(self.stubs)
+ fake_network.set_stub_network_methods(self)
# Create server
# Build the server data gradually, checking errors along the way
@@ -204,7 +204,7 @@ class ServersTest(ServersTestBase):
def test_deferred_delete(self):
# Creates, deletes and waits for server to be reclaimed.
self.flags(reclaim_instance_interval=1)
- fake_network.set_stub_network_methods(self.stubs)
+ fake_network.set_stub_network_methods(self)
# Create server
server = self._build_minimal_create_server_request()
@@ -240,7 +240,7 @@ class ServersTest(ServersTestBase):
def test_deferred_delete_restore(self):
# Creates, deletes and restores a server.
self.flags(reclaim_instance_interval=3600)
- fake_network.set_stub_network_methods(self.stubs)
+ fake_network.set_stub_network_methods(self)
# Create server
server = self._build_minimal_create_server_request()
@@ -273,7 +273,7 @@ class ServersTest(ServersTestBase):
def test_deferred_delete_force(self):
# Creates, deletes and force deletes a server.
self.flags(reclaim_instance_interval=3600)
- fake_network.set_stub_network_methods(self.stubs)
+ fake_network.set_stub_network_methods(self)
# Create server
server = self._build_minimal_create_server_request()
@@ -305,7 +305,7 @@ class ServersTest(ServersTestBase):
def test_create_server_with_metadata(self):
# Creates a server with metadata.
- fake_network.set_stub_network_methods(self.stubs)
+ fake_network.set_stub_network_methods(self)
# Build the server data gradually, checking errors along the way
server = self._build_minimal_create_server_request()
@@ -347,7 +347,7 @@ class ServersTest(ServersTestBase):
def test_create_and_rebuild_server(self):
# Rebuild a server with metadata.
- fake_network.set_stub_network_methods(self.stubs)
+ fake_network.set_stub_network_methods(self)
# create a server with initially has no metadata
server = self._build_minimal_create_server_request()
@@ -413,7 +413,7 @@ class ServersTest(ServersTestBase):
def test_rename_server(self):
# Test building and renaming a server.
- fake_network.set_stub_network_methods(self.stubs)
+ fake_network.set_stub_network_methods(self)
# Create a server
server = self._build_minimal_create_server_request()
@@ -470,7 +470,7 @@ class ServersTest(ServersTestBase):
def test_create_server_with_injected_files(self):
# Creates a server with injected_files.
- fake_network.set_stub_network_methods(self.stubs)
+ fake_network.set_stub_network_methods(self)
personality = []
# Inject a text file
diff --git a/nova/tests/unit/api/openstack/compute/legacy_v2/test_auth.py b/nova/tests/unit/api/openstack/compute/legacy_v2/test_auth.py
index 4dafe7923d..659540854b 100644
--- a/nova/tests/unit/api/openstack/compute/legacy_v2/test_auth.py
+++ b/nova/tests/unit/api/openstack/compute/legacy_v2/test_auth.py
@@ -25,7 +25,7 @@ class TestNoAuthMiddleware(test.NoDBTestCase):
def setUp(self):
super(TestNoAuthMiddleware, self).setUp()
fakes.stub_out_rate_limiting(self.stubs)
- fakes.stub_out_networking(self.stubs)
+ fakes.stub_out_networking(self)
def test_authorize_user(self):
req = webob.Request.blank('/v2')
diff --git a/nova/tests/unit/api/openstack/compute/legacy_v2/test_servers.py b/nova/tests/unit/api/openstack/compute/legacy_v2/test_servers.py
index f4504dcbd9..d208908e33 100644
--- a/nova/tests/unit/api/openstack/compute/legacy_v2/test_servers.py
+++ b/nova/tests/unit/api/openstack/compute/legacy_v2/test_servers.py
@@ -188,7 +188,7 @@ class ControllerTest(test.TestCase):
self.ips_controller = ips.Controller()
policy.reset()
policy.init()
- fake_network.stub_out_nw_api_get_instance_nw_info(self.stubs)
+ fake_network.stub_out_nw_api_get_instance_nw_info(self)
class ServersControllerTest(ControllerTest):
@@ -1498,7 +1498,7 @@ class ServersControllerDeleteTest(ControllerTest):
self.stubs.Set(compute_api.API, 'delete', fake_delete)
def _create_delete_request(self, uuid):
- fakes.stub_out_instance_quota(self.stubs, 0, 10)
+ fakes.stub_out_instance_quota(self, 0, 10)
req = fakes.HTTPRequest.blank('/v2/fake/servers/%s' % uuid)
req.method = 'DELETE'
return req
@@ -1531,7 +1531,7 @@ class ServersControllerDeleteTest(ControllerTest):
req, FAKE_UUID)
def test_delete_server_instance_while_building(self):
- fakes.stub_out_instance_quota(self.stubs, 0, 10)
+ fakes.stub_out_instance_quota(self, 0, 10)
request = self._create_delete_request(FAKE_UUID)
self.controller.delete(request, FAKE_UUID)
@@ -1557,7 +1557,7 @@ class ServersControllerDeleteTest(ControllerTest):
self.controller.delete(req, FAKE_UUID)
def test_delete_server_instance_while_deleting_host_down(self):
- fake_network.stub_out_network_cleanup(self.stubs)
+ fake_network.stub_out_network_cleanup(self)
req = self._create_delete_request(FAKE_UUID)
self.stubs.Set(db, 'instance_get_by_uuid',
fakes.fake_instance_get(vm_state=vm_states.ACTIVE,
@@ -1771,7 +1771,7 @@ class ServerStatusTest(test.TestCase):
def setUp(self):
super(ServerStatusTest, self).setUp()
- fakes.stub_out_nw_api(self.stubs)
+ fakes.stub_out_nw_api(self)
self.ext_mgr = extensions.ExtensionManager()
self.ext_mgr.extensions = {}
@@ -1870,7 +1870,7 @@ class ServersControllerCreateTest(test.TestCase):
self.instance_cache_by_id = {}
self.instance_cache_by_uuid = {}
- fakes.stub_out_nw_api(self.stubs)
+ fakes.stub_out_nw_api(self)
self.ext_mgr = extensions.ExtensionManager()
self.ext_mgr.extensions = {}
@@ -2851,7 +2851,7 @@ class ServersControllerCreateTest(test.TestCase):
def _do_test_create_instance_above_quota(self, resource, allowed, quota,
expected_msg):
- fakes.stub_out_instance_quota(self.stubs, allowed, quota, resource)
+ fakes.stub_out_instance_quota(self, allowed, quota, resource)
self.body['server']['flavorRef'] = 3
self.req.body = jsonutils.dump_as_bytes(self.body)
try:
@@ -3068,7 +3068,7 @@ class ServersViewBuilderTest(test.TestCase):
(None, {'label': 'private',
'ips': [dict(ip=ip) for ip in privates]})]
- fakes.stub_out_nw_api_get_instance_nw_info(self.stubs, nw_info)
+ fakes.stub_out_nw_api_get_instance_nw_info(self, nw_info)
self.uuid = db_inst['uuid']
self.view_builder = views.servers.ViewBuilder()
diff --git a/nova/tests/unit/api/openstack/compute/test_auth.py b/nova/tests/unit/api/openstack/compute/test_auth.py
index 37b140e1e2..83e495918c 100644
--- a/nova/tests/unit/api/openstack/compute/test_auth.py
+++ b/nova/tests/unit/api/openstack/compute/test_auth.py
@@ -30,7 +30,7 @@ class TestNoAuthMiddlewareV21(test.NoDBTestCase):
def setUp(self):
super(TestNoAuthMiddlewareV21, self).setUp()
fakes.stub_out_rate_limiting(self.stubs)
- fakes.stub_out_networking(self.stubs)
+ fakes.stub_out_networking(self)
self.wsgi_app = fakes.wsgi_app_v21(use_no_auth=True)
self.req_url = '/v2'
self.expected_url = "http://localhost/v2/user1_project"
diff --git a/nova/tests/unit/api/openstack/compute/test_cloudpipe.py b/nova/tests/unit/api/openstack/compute/test_cloudpipe.py
index 73835d9bd2..3bec7989a5 100644
--- a/nova/tests/unit/api/openstack/compute/test_cloudpipe.py
+++ b/nova/tests/unit/api/openstack/compute/test_cloudpipe.py
@@ -93,7 +93,7 @@ class CloudpipeTestV21(test.NoDBTestCase):
'vpn_public_port': 22}
def fake_get_nw_info_for_instance(instance):
- return fake_network.fake_get_instance_nw_info(self.stubs)
+ return fake_network.fake_get_instance_nw_info(self)
self.stubs.Set(compute_utils, "get_nw_info_for_instance",
fake_get_nw_info_for_instance)
diff --git a/nova/tests/unit/api/openstack/compute/test_config_drive.py b/nova/tests/unit/api/openstack/compute/test_config_drive.py
index f42760d61d..e49bd9eba0 100644
--- a/nova/tests/unit/api/openstack/compute/test_config_drive.py
+++ b/nova/tests/unit/api/openstack/compute/test_config_drive.py
@@ -46,7 +46,7 @@ class ConfigDriveTestV21(test.TestCase):
def setUp(self):
super(ConfigDriveTestV21, self).setUp()
- fakes.stub_out_networking(self.stubs)
+ fakes.stub_out_networking(self)
fakes.stub_out_rate_limiting(self.stubs)
fake.stub_out_image_service(self)
self._setup_wsgi()
diff --git a/nova/tests/unit/api/openstack/compute/test_disk_config.py b/nova/tests/unit/api/openstack/compute/test_disk_config.py
index f410816cad..159f835061 100644
--- a/nova/tests/unit/api/openstack/compute/test_disk_config.py
+++ b/nova/tests/unit/api/openstack/compute/test_disk_config.py
@@ -47,7 +47,7 @@ class DiskConfigTestCaseV21(test.TestCase):
self._set_up_app()
self._setup_fake_image_service()
- fakes.stub_out_nw_api(self.stubs)
+ fakes.stub_out_nw_api(self)
FAKE_INSTANCES = [
fakes.stub_instance(1,
diff --git a/nova/tests/unit/api/openstack/compute/test_extended_availability_zone.py b/nova/tests/unit/api/openstack/compute/test_extended_availability_zone.py
index a6e4ef3062..d685658b1a 100644
--- a/nova/tests/unit/api/openstack/compute/test_extended_availability_zone.py
+++ b/nova/tests/unit/api/openstack/compute/test_extended_availability_zone.py
@@ -80,7 +80,7 @@ class ExtendedAvailabilityZoneTestV21(test.TestCase):
def setUp(self):
super(ExtendedAvailabilityZoneTestV21, self).setUp()
availability_zones.reset_cache()
- fakes.stub_out_nw_api(self.stubs)
+ fakes.stub_out_nw_api(self)
self.stubs.Set(compute.api.API, 'get', fake_compute_get)
self.stubs.Set(compute.api.API, 'get_all', fake_compute_get_all)
self.stubs.Set(availability_zones, 'get_host_availability_zone',
diff --git a/nova/tests/unit/api/openstack/compute/test_extended_ips.py b/nova/tests/unit/api/openstack/compute/test_extended_ips.py
index 900c1427e6..ee53e6a420 100644
--- a/nova/tests/unit/api/openstack/compute/test_extended_ips.py
+++ b/nova/tests/unit/api/openstack/compute/test_extended_ips.py
@@ -104,7 +104,7 @@ class ExtendedIpsTestV21(test.TestCase):
def setUp(self):
super(ExtendedIpsTestV21, self).setUp()
- fakes.stub_out_nw_api(self.stubs)
+ fakes.stub_out_nw_api(self)
self.stubs.Set(compute.api.API, 'get', fake_compute_get)
self.stubs.Set(compute.api.API, 'get_all', fake_compute_get_all)
diff --git a/nova/tests/unit/api/openstack/compute/test_extended_ips_mac.py b/nova/tests/unit/api/openstack/compute/test_extended_ips_mac.py
index 4743ec4b3f..4f5be37304 100644
--- a/nova/tests/unit/api/openstack/compute/test_extended_ips_mac.py
+++ b/nova/tests/unit/api/openstack/compute/test_extended_ips_mac.py
@@ -110,7 +110,7 @@ class ExtendedIpsMacTestV21(test.TestCase):
def setUp(self):
super(ExtendedIpsMacTestV21, self).setUp()
- fakes.stub_out_nw_api(self.stubs)
+ fakes.stub_out_nw_api(self)
self.stubs.Set(compute.api.API, 'get', fake_compute_get)
self.stubs.Set(compute.api.API, 'get_all', fake_compute_get_all)
diff --git a/nova/tests/unit/api/openstack/compute/test_extended_server_attributes.py b/nova/tests/unit/api/openstack/compute/test_extended_server_attributes.py
index 6a3f6165e8..6ca36ec23b 100644
--- a/nova/tests/unit/api/openstack/compute/test_extended_server_attributes.py
+++ b/nova/tests/unit/api/openstack/compute/test_extended_server_attributes.py
@@ -73,7 +73,7 @@ class ExtendedServerAttributesTestV21(test.TestCase):
def setUp(self):
super(ExtendedServerAttributesTestV21, self).setUp()
- fakes.stub_out_nw_api(self.stubs)
+ fakes.stub_out_nw_api(self)
self.stubs.Set(compute.api.API, 'get', fake_compute_get)
self.stubs.Set(compute.api.API, 'get_all', fake_compute_get_all)
self.stubs.Set(db, 'instance_get_by_uuid', fake_compute_get)
diff --git a/nova/tests/unit/api/openstack/compute/test_extended_status.py b/nova/tests/unit/api/openstack/compute/test_extended_status.py
index a3b33373f7..776ab1294c 100644
--- a/nova/tests/unit/api/openstack/compute/test_extended_status.py
+++ b/nova/tests/unit/api/openstack/compute/test_extended_status.py
@@ -68,7 +68,7 @@ class ExtendedStatusTestV21(test.TestCase):
def setUp(self):
super(ExtendedStatusTestV21, self).setUp()
- fakes.stub_out_nw_api(self.stubs)
+ fakes.stub_out_nw_api(self)
self.stubs.Set(compute.api.API, 'get', fake_compute_get)
self.stubs.Set(compute.api.API, 'get_all', fake_compute_get_all)
self._set_flags()
diff --git a/nova/tests/unit/api/openstack/compute/test_extended_volumes.py b/nova/tests/unit/api/openstack/compute/test_extended_volumes.py
index 048fd18bea..dd7ead0498 100644
--- a/nova/tests/unit/api/openstack/compute/test_extended_volumes.py
+++ b/nova/tests/unit/api/openstack/compute/test_extended_volumes.py
@@ -96,7 +96,7 @@ class ExtendedVolumesTestV21(test.TestCase):
def setUp(self):
super(ExtendedVolumesTestV21, self).setUp()
- fakes.stub_out_nw_api(self.stubs)
+ fakes.stub_out_nw_api(self)
self.stubs.Set(compute.api.API, 'get', fake_compute_get)
self.stubs.Set(compute.api.API, 'get_all', fake_compute_get_all)
self.stubs.Set(db, 'block_device_mapping_get_all_by_instance_uuids',
diff --git a/nova/tests/unit/api/openstack/compute/test_flavor_disabled.py b/nova/tests/unit/api/openstack/compute/test_flavor_disabled.py
index 7262f2f359..59b769c66d 100644
--- a/nova/tests/unit/api/openstack/compute/test_flavor_disabled.py
+++ b/nova/tests/unit/api/openstack/compute/test_flavor_disabled.py
@@ -66,7 +66,7 @@ class FlavorDisabledTestV21(test.NoDBTestCase):
ext = ('nova.api.openstack.compute.contrib'
'.flavor_disabled.Flavor_disabled')
self.flags(osapi_compute_extension=[ext])
- fakes.stub_out_nw_api(self.stubs)
+ fakes.stub_out_nw_api(self)
self.stubs.Set(flavors, "get_all_flavors_sorted_list",
fake_get_all_flavors_sorted_list)
self.stubs.Set(flavors,
diff --git a/nova/tests/unit/api/openstack/compute/test_flavor_rxtx.py b/nova/tests/unit/api/openstack/compute/test_flavor_rxtx.py
index c2756b25ac..96fb09c18d 100644
--- a/nova/tests/unit/api/openstack/compute/test_flavor_rxtx.py
+++ b/nova/tests/unit/api/openstack/compute/test_flavor_rxtx.py
@@ -67,7 +67,7 @@ class FlavorRxtxTestV21(test.NoDBTestCase):
ext = ('nova.api.openstack.compute.contrib'
'.flavor_rxtx.Flavor_rxtx')
self.flags(osapi_compute_extension=[ext])
- fakes.stub_out_nw_api(self.stubs)
+ fakes.stub_out_nw_api(self)
self.stubs.Set(flavors, "get_all_flavors_sorted_list",
fake_get_all_flavors_sorted_list)
self.stubs.Set(flavors,
diff --git a/nova/tests/unit/api/openstack/compute/test_flavor_swap.py b/nova/tests/unit/api/openstack/compute/test_flavor_swap.py
index 65de9c6cfd..809b464d8b 100644
--- a/nova/tests/unit/api/openstack/compute/test_flavor_swap.py
+++ b/nova/tests/unit/api/openstack/compute/test_flavor_swap.py
@@ -67,7 +67,7 @@ class FlavorSwapTestV21(test.NoDBTestCase):
ext = ('nova.api.openstack.compute.contrib'
'.flavor_swap.Flavor_swap')
self.flags(osapi_compute_extension=[ext])
- fakes.stub_out_nw_api(self.stubs)
+ fakes.stub_out_nw_api(self)
self.stubs.Set(flavors, "get_all_flavors_sorted_list",
fake_get_all_flavors_sorted_list)
self.stubs.Set(flavors,
diff --git a/nova/tests/unit/api/openstack/compute/test_flavors.py b/nova/tests/unit/api/openstack/compute/test_flavors.py
index a72368f1ed..dbc5a1f898 100644
--- a/nova/tests/unit/api/openstack/compute/test_flavors.py
+++ b/nova/tests/unit/api/openstack/compute/test_flavors.py
@@ -122,7 +122,7 @@ class FlavorsTestV21(test.TestCase):
def setUp(self):
super(FlavorsTestV21, self).setUp()
self.flags(osapi_compute_extension=[])
- fakes.stub_out_networking(self.stubs)
+ fakes.stub_out_networking(self)
fakes.stub_out_rate_limiting(self.stubs)
self.stubs.Set(nova.compute.flavors, "get_all_flavors_sorted_list",
fake_get_all_flavors_sorted_list)
diff --git a/nova/tests/unit/api/openstack/compute/test_floating_ips.py b/nova/tests/unit/api/openstack/compute/test_floating_ips.py
index 65a98b4b67..4cb36b583e 100644
--- a/nova/tests/unit/api/openstack/compute/test_floating_ips.py
+++ b/nova/tests/unit/api/openstack/compute/test_floating_ips.py
@@ -100,9 +100,9 @@ def fake_instance_get(context, instance_id):
"project_id": '123'})
-def stub_nw_info(stubs):
+def stub_nw_info(test):
def get_nw_info_for_instance(instance):
- return fake_network.fake_get_instance_nw_info(stubs)
+ return fake_network.fake_get_instance_nw_info(test)
return get_nw_info_for_instance
@@ -213,9 +213,9 @@ class FloatingIpTestV21(test.TestCase):
self.stubs.Set(network.api.API, "get_instance_id_by_floating_address",
get_instance_by_floating_ip_addr)
self.stubs.Set(compute_utils, "get_nw_info_for_instance",
- stub_nw_info(self.stubs))
+ stub_nw_info(self))
- fake_network.stub_out_nw_api_get_instance_nw_info(self.stubs)
+ fake_network.stub_out_nw_api_get_instance_nw_info(self)
self.stubs.Set(db, 'instance_get',
fake_instance_get)
@@ -788,9 +788,9 @@ class ExtendedFloatingIpTestV21(test.TestCase):
self.stubs.Set(network.api.API, "get_instance_id_by_floating_address",
get_instance_by_floating_ip_addr)
self.stubs.Set(compute_utils, "get_nw_info_for_instance",
- stub_nw_info(self.stubs))
+ stub_nw_info(self))
- fake_network.stub_out_nw_api_get_instance_nw_info(self.stubs)
+ fake_network.stub_out_nw_api_get_instance_nw_info(self)
self.stubs.Set(db, 'instance_get',
fake_instance_get)
diff --git a/nova/tests/unit/api/openstack/compute/test_hide_server_addresses.py b/nova/tests/unit/api/openstack/compute/test_hide_server_addresses.py
index 32167aaab6..0532015d1d 100644
--- a/nova/tests/unit/api/openstack/compute/test_hide_server_addresses.py
+++ b/nova/tests/unit/api/openstack/compute/test_hide_server_addresses.py
@@ -49,7 +49,7 @@ class HideServerAddressesTestV21(test.TestCase):
def setUp(self):
super(HideServerAddressesTestV21, self).setUp()
- fakes.stub_out_nw_api(self.stubs)
+ fakes.stub_out_nw_api(self)
return_server = fakes.fake_instance_get()
self.stubs.Set(db, 'instance_get_by_uuid', return_server)
self._setup_wsgi()
diff --git a/nova/tests/unit/api/openstack/compute/test_images.py b/nova/tests/unit/api/openstack/compute/test_images.py
index 98c56b103c..e49cb2f623 100644
--- a/nova/tests/unit/api/openstack/compute/test_images.py
+++ b/nova/tests/unit/api/openstack/compute/test_images.py
@@ -51,7 +51,7 @@ class ImagesControllerTestV21(test.NoDBTestCase):
def setUp(self):
"""Run before each test."""
super(ImagesControllerTestV21, self).setUp()
- fakes.stub_out_networking(self.stubs)
+ fakes.stub_out_networking(self)
fakes.stub_out_rate_limiting(self.stubs)
fakes.stub_out_key_pair_funcs(self.stubs)
fakes.stub_out_compute_api_snapshot(self.stubs)
diff --git a/nova/tests/unit/api/openstack/compute/test_keypairs.py b/nova/tests/unit/api/openstack/compute/test_keypairs.py
index 008a613612..884401233f 100644
--- a/nova/tests/unit/api/openstack/compute/test_keypairs.py
+++ b/nova/tests/unit/api/openstack/compute/test_keypairs.py
@@ -79,7 +79,7 @@ class KeypairsTestV21(test.TestCase):
def setUp(self):
super(KeypairsTestV21, self).setUp()
- fakes.stub_out_networking(self.stubs)
+ fakes.stub_out_networking(self)
fakes.stub_out_rate_limiting(self.stubs)
self.stubs.Set(db, "key_pair_get_all_by_user",
diff --git a/nova/tests/unit/api/openstack/compute/test_multinic.py b/nova/tests/unit/api/openstack/compute/test_multinic.py
index b74c3c702e..76e0c4c402 100644
--- a/nova/tests/unit/api/openstack/compute/test_multinic.py
+++ b/nova/tests/unit/api/openstack/compute/test_multinic.py
@@ -60,7 +60,7 @@ class FixedIpTestV21(test.NoDBTestCase):
def setUp(self):
super(FixedIpTestV21, self).setUp()
- fakes.stub_out_networking(self.stubs)
+ fakes.stub_out_networking(self)
fakes.stub_out_rate_limiting(self.stubs)
self.stubs.Set(compute.api.API, "add_fixed_ip",
compute_api_add_fixed_ip)
diff --git a/nova/tests/unit/api/openstack/compute/test_multiple_create.py b/nova/tests/unit/api/openstack/compute/test_multiple_create.py
index a6b4ad37d4..44e9efbe48 100644
--- a/nova/tests/unit/api/openstack/compute/test_multiple_create.py
+++ b/nova/tests/unit/api/openstack/compute/test_multiple_create.py
@@ -124,7 +124,7 @@ class MultiCreateExtensionTestV21(test.TestCase):
fakes.stub_out_rate_limiting(self.stubs)
fakes.stub_out_key_pair_funcs(self.stubs)
fake.stub_out_image_service(self)
- fakes.stub_out_nw_api(self.stubs)
+ fakes.stub_out_nw_api(self)
self.stubs.Set(uuid, 'uuid4', fake_gen_uuid)
self.stubs.Set(db, 'instance_add_security_group',
return_security_group)
@@ -519,7 +519,7 @@ class MultiCreateExtensionTestV2(MultiCreateExtensionTestV21):
self.instance_cache_by_id = {}
self.instance_cache_by_uuid = {}
- fakes.stub_out_nw_api(self.stubs)
+ fakes.stub_out_nw_api(self)
self.ext_mgr = extensions_v20.ExtensionManager()
self.ext_mgr.extensions = {
diff --git a/nova/tests/unit/api/openstack/compute/test_networks.py b/nova/tests/unit/api/openstack/compute/test_networks.py
index 293c354b25..840ce9eee9 100644
--- a/nova/tests/unit/api/openstack/compute/test_networks.py
+++ b/nova/tests/unit/api/openstack/compute/test_networks.py
@@ -248,7 +248,7 @@ class NetworkCreateExceptionsTestV21(test.TestCase):
def setUp(self):
super(NetworkCreateExceptionsTestV21, self).setUp()
self._setup()
- fakes.stub_out_networking(self.stubs)
+ fakes.stub_out_networking(self)
fakes.stub_out_rate_limiting(self.stubs)
self.new_network = copy.deepcopy(NEW_NETWORK)
@@ -333,7 +333,7 @@ class NetworksTestV21(test.NoDBTestCase):
super(NetworksTestV21, self).setUp()
self.fake_network_api = FakeNetworkAPI()
self._setup()
- fakes.stub_out_networking(self.stubs)
+ fakes.stub_out_networking(self)
fakes.stub_out_rate_limiting(self.stubs)
self.new_network = copy.deepcopy(NEW_NETWORK)
self.non_admin_req = fakes.HTTPRequest.blank('')
@@ -549,7 +549,7 @@ class NetworksAssociateTestV21(test.NoDBTestCase):
super(NetworksAssociateTestV21, self).setUp()
self.fake_network_api = FakeNetworkAPI()
self._setup()
- fakes.stub_out_networking(self.stubs)
+ fakes.stub_out_networking(self)
fakes.stub_out_rate_limiting(self.stubs)
self.admin_req = fakes.HTTPRequest.blank('', use_admin_context=True)
diff --git a/nova/tests/unit/api/openstack/compute/test_neutron_security_groups.py b/nova/tests/unit/api/openstack/compute/test_neutron_security_groups.py
index 4cd9aa3dd7..c713eb4156 100644
--- a/nova/tests/unit/api/openstack/compute/test_neutron_security_groups.py
+++ b/nova/tests/unit/api/openstack/compute/test_neutron_security_groups.py
@@ -484,7 +484,7 @@ class TestNeutronSecurityGroupsOutputTest(TestNeutronSecurityGroupsTestCase):
def setUp(self):
super(TestNeutronSecurityGroupsOutputTest, self).setUp()
- fakes.stub_out_nw_api(self.stubs)
+ fakes.stub_out_nw_api(self)
self.controller = security_groups.SecurityGroupController()
self.stubs.Set(compute.api.API, 'get',
test_security_groups.fake_compute_get)
diff --git a/nova/tests/unit/api/openstack/compute/test_security_groups.py b/nova/tests/unit/api/openstack/compute/test_security_groups.py
index 7931c67005..7fcaf94e67 100644
--- a/nova/tests/unit/api/openstack/compute/test_security_groups.py
+++ b/nova/tests/unit/api/openstack/compute/test_security_groups.py
@@ -1319,7 +1319,7 @@ class SecurityGroupsOutputTestV21(test.TestCase):
def setUp(self):
super(SecurityGroupsOutputTestV21, self).setUp()
- fakes.stub_out_nw_api(self.stubs)
+ fakes.stub_out_nw_api(self)
self.stubs.Set(compute.api.API, 'get', fake_compute_get)
self.stubs.Set(compute.api.API, 'get_all', fake_compute_get_all)
self.stubs.Set(compute.api.API, 'create', fake_compute_create)
diff --git a/nova/tests/unit/api/openstack/compute/test_server_actions.py b/nova/tests/unit/api/openstack/compute/test_server_actions.py
index 126dda8bb8..b31be443d7 100644
--- a/nova/tests/unit/api/openstack/compute/test_server_actions.py
+++ b/nova/tests/unit/api/openstack/compute/test_server_actions.py
@@ -92,7 +92,7 @@ class ServerActionsControllerTestV21(test.TestCase):
self.stubs.Set(db, 'instance_update_and_get_original',
instance_update_and_get_original)
- fakes.stub_out_nw_api(self.stubs)
+ fakes.stub_out_nw_api(self)
fakes.stub_out_compute_api_snapshot(self.stubs)
fake.stub_out_image_service(self)
self.flags(allow_instance_snapshots=True,
diff --git a/nova/tests/unit/api/openstack/compute/test_server_password.py b/nova/tests/unit/api/openstack/compute/test_server_password.py
index e2e0b5b6f9..5fe64a26cf 100644
--- a/nova/tests/unit/api/openstack/compute/test_server_password.py
+++ b/nova/tests/unit/api/openstack/compute/test_server_password.py
@@ -41,7 +41,7 @@ class ServerPasswordTestV21(test.NoDBTestCase):
def setUp(self):
super(ServerPasswordTestV21, self).setUp()
- fakes.stub_out_nw_api(self.stubs)
+ fakes.stub_out_nw_api(self)
self.stubs.Set(
compute.api.API, 'get',
lambda self, ctxt, *a, **kw:
diff --git a/nova/tests/unit/api/openstack/compute/test_server_usage.py b/nova/tests/unit/api/openstack/compute/test_server_usage.py
index 535cb0fa25..ffe0ec95f5 100644
--- a/nova/tests/unit/api/openstack/compute/test_server_usage.py
+++ b/nova/tests/unit/api/openstack/compute/test_server_usage.py
@@ -63,7 +63,7 @@ class ServerUsageTestV21(test.TestCase):
def setUp(self):
super(ServerUsageTestV21, self).setUp()
- fakes.stub_out_nw_api(self.stubs)
+ fakes.stub_out_nw_api(self)
self.stubs.Set(compute.api.API, 'get', fake_compute_get)
self.stubs.Set(compute.api.API, 'get_all', fake_compute_get_all)
self.flags(
diff --git a/nova/tests/unit/api/openstack/compute/test_serversV21.py b/nova/tests/unit/api/openstack/compute/test_serversV21.py
index 88519f931a..e3a0e96e7f 100644
--- a/nova/tests/unit/api/openstack/compute/test_serversV21.py
+++ b/nova/tests/unit/api/openstack/compute/test_serversV21.py
@@ -207,7 +207,7 @@ class ControllerTest(test.TestCase):
self.ips_controller = ips.IPsController()
policy.reset()
policy.init()
- fake_network.stub_out_nw_api_get_instance_nw_info(self.stubs)
+ fake_network.stub_out_nw_api_get_instance_nw_info(self)
class ServersControllerTest(ControllerTest):
@@ -1423,7 +1423,7 @@ class ServersControllerDeleteTest(ControllerTest):
self.stubs.Set(compute_api.API, 'delete', fake_delete)
def _create_delete_request(self, uuid):
- fakes.stub_out_instance_quota(self.stubs, 0, 10)
+ fakes.stub_out_instance_quota(self, 0, 10)
req = fakes.HTTPRequestV21.blank('/fake/servers/%s' % uuid)
req.method = 'DELETE'
return req
@@ -1941,7 +1941,7 @@ class ServerStatusTest(test.TestCase):
def setUp(self):
super(ServerStatusTest, self).setUp()
- fakes.stub_out_nw_api(self.stubs)
+ fakes.stub_out_nw_api(self)
ext_info = extension_info.LoadedExtensionInfo()
self.controller = servers.ServersController(extension_info=ext_info)
@@ -2052,7 +2052,7 @@ class ServersControllerCreateTest(test.TestCase):
self.instance_cache_by_id = {}
self.instance_cache_by_uuid = {}
- fakes.stub_out_nw_api(self.stubs)
+ fakes.stub_out_nw_api(self)
ext_info = extension_info.LoadedExtensionInfo()
self.controller = servers.ServersController(extension_info=ext_info)
@@ -2772,7 +2772,7 @@ class ServersControllerCreateTest(test.TestCase):
def _do_test_create_instance_above_quota(self, resource, allowed, quota,
expected_msg):
- fakes.stub_out_instance_quota(self.stubs, allowed, quota, resource)
+ fakes.stub_out_instance_quota(self, allowed, quota, resource)
self.body['server']['flavorRef'] = 3
self.req.body = jsonutils.dump_as_bytes(self.body)
try:
@@ -3128,7 +3128,7 @@ class ServersViewBuilderTest(test.TestCase):
(None, {'label': 'private',
'ips': [dict(ip=ip) for ip in privates]})]
- fakes.stub_out_nw_api_get_instance_nw_info(self.stubs, nw_info)
+ fakes.stub_out_nw_api_get_instance_nw_info(self, nw_info)
self.uuid = db_inst['uuid']
self.view_builder = views.servers.ViewBuilderV21()
diff --git a/nova/tests/unit/api/openstack/compute/test_snapshots.py b/nova/tests/unit/api/openstack/compute/test_snapshots.py
index 698604d300..a077d0859b 100644
--- a/nova/tests/unit/api/openstack/compute/test_snapshots.py
+++ b/nova/tests/unit/api/openstack/compute/test_snapshots.py
@@ -32,7 +32,7 @@ class SnapshotApiTestV21(test.NoDBTestCase):
def setUp(self):
super(SnapshotApiTestV21, self).setUp()
- fakes.stub_out_networking(self.stubs)
+ fakes.stub_out_networking(self)
fakes.stub_out_rate_limiting(self.stubs)
self.stubs.Set(cinder.API, "create_snapshot",
fakes.stub_snapshot_create)
diff --git a/nova/tests/unit/api/openstack/compute/test_user_data.py b/nova/tests/unit/api/openstack/compute/test_user_data.py
index 24252ac316..d498e75ec6 100644
--- a/nova/tests/unit/api/openstack/compute/test_user_data.py
+++ b/nova/tests/unit/api/openstack/compute/test_user_data.py
@@ -121,7 +121,7 @@ class ServersControllerCreateTest(test.TestCase):
fakes.stub_out_rate_limiting(self.stubs)
fakes.stub_out_key_pair_funcs(self.stubs)
fake.stub_out_image_service(self)
- fakes.stub_out_nw_api(self.stubs)
+ fakes.stub_out_nw_api(self)
self.stubs.Set(uuid, 'uuid4', fake_gen_uuid)
self.stubs.Set(db, 'instance_add_security_group',
return_security_group)
diff --git a/nova/tests/unit/api/openstack/compute/test_volumes.py b/nova/tests/unit/api/openstack/compute/test_volumes.py
index ba0405ba1e..19da82b324 100644
--- a/nova/tests/unit/api/openstack/compute/test_volumes.py
+++ b/nova/tests/unit/api/openstack/compute/test_volumes.py
@@ -129,7 +129,7 @@ class BootFromVolumeTest(test.TestCase):
super(BootFromVolumeTest, self).setUp()
self.stubs.Set(compute_api.API, 'create',
self._get_fake_compute_api_create())
- fakes.stub_out_nw_api(self.stubs)
+ fakes.stub_out_nw_api(self)
self._block_device_mapping_seen = None
self._legacy_bdm_seen = True
self.flags(
@@ -224,7 +224,7 @@ class VolumeApiTestV21(test.NoDBTestCase):
def setUp(self):
super(VolumeApiTestV21, self).setUp()
- fakes.stub_out_networking(self.stubs)
+ fakes.stub_out_networking(self)
fakes.stub_out_rate_limiting(self.stubs)
self.stubs.Set(cinder.API, "delete", fakes.stub_volume_delete)
diff --git a/nova/tests/unit/api/openstack/fakes.py b/nova/tests/unit/api/openstack/fakes.py
index e466644c3b..4367b5d158 100644
--- a/nova/tests/unit/api/openstack/fakes.py
+++ b/nova/tests/unit/api/openstack/fakes.py
@@ -17,7 +17,6 @@ import datetime
import uuid
from oslo_serialization import jsonutils
-from oslo_utils import netutils
from oslo_utils import timeutils
import routes
import six
@@ -42,7 +41,6 @@ from nova import context
from nova.db.sqlalchemy import models
from nova import exception as exc
import nova.netconf
-from nova.network import api as network_api
from nova import objects
from nova.objects import base
from nova import quota
@@ -145,7 +143,7 @@ def stub_out_rate_limiting(stubs):
stubs.Set(v2_limits.RateLimitingMiddleware, '__call__', fake_wsgi)
-def stub_out_instance_quota(stubs, allowed, quota, resource='instances'):
+def stub_out_instance_quota(test, allowed, quota, resource='instances'):
def fake_reserve(context, **deltas):
requested = deltas.pop(resource, 0)
if requested > allowed:
@@ -158,13 +156,13 @@ def stub_out_instance_quota(stubs, allowed, quota, resource='instances'):
usages[resource]['reserved'] = quotas[resource] // 10
raise exc.OverQuota(overs=[resource], quotas=quotas,
usages=usages)
- stubs.Set(QUOTAS, 'reserve', fake_reserve)
+ test.stub_out('nova.quota.QUOTAS.reserve', fake_reserve)
-def stub_out_networking(stubs):
+def stub_out_networking(test):
def get_my_ip():
return '127.0.0.1'
- stubs.Set(netutils, 'get_my_ipv4', get_my_ip)
+ test.stub_out('oslo_utils.netutils.get_my_ipv4', get_my_ip)
def stub_out_compute_api_snapshot(stubs):
@@ -195,11 +193,11 @@ class stub_out_compute_api_backup(object):
return dict(id='123', status='ACTIVE', name=name, properties=props)
-def stub_out_nw_api_get_instance_nw_info(stubs, num_networks=1, func=None):
- fake_network.stub_out_nw_api_get_instance_nw_info(stubs)
+def stub_out_nw_api_get_instance_nw_info(test, num_networks=1, func=None):
+ fake_network.stub_out_nw_api_get_instance_nw_info(test)
-def stub_out_nw_api(stubs, cls=None, private=None, publics=None):
+def stub_out_nw_api(test, cls=None, private=None, publics=None):
if not private:
private = '192.168.0.3'
if not publics:
@@ -225,8 +223,8 @@ def stub_out_nw_api(stubs, cls=None, private=None, publics=None):
if cls is None:
cls = Fake
- stubs.Set(network_api, 'API', cls)
- fake_network.stub_out_nw_api_get_instance_nw_info(stubs)
+ test.stub_out('nova.network.api.API', cls)
+ fake_network.stub_out_nw_api_get_instance_nw_info(test)
class FakeToken(object):
diff --git a/nova/tests/unit/compute/test_compute.py b/nova/tests/unit/compute/test_compute.py
index 45f3268237..3cff34a2e6 100644
--- a/nova/tests/unit/compute/test_compute.py
+++ b/nova/tests/unit/compute/test_compute.py
@@ -237,7 +237,7 @@ class BaseTestCase(test.TestCase):
fake_taskapi = FakeComputeTaskAPI()
self.stubs.Set(self.compute, 'compute_task_api', fake_taskapi)
- fake_network.set_stub_network_methods(self.stubs)
+ fake_network.set_stub_network_methods(self)
fake_server_actions.stub_out_action_events(self.stubs)
def fake_get_nw_info(cls, ctxt, instance, *args, **kwargs):
@@ -248,7 +248,7 @@ class BaseTestCase(test.TestCase):
def fake_allocate_for_instance(cls, ctxt, instance, *args, **kwargs):
self.assertFalse(ctxt.is_admin)
- return fake_network.fake_get_instance_nw_info(self.stubs, 1, 1)
+ return fake_network.fake_get_instance_nw_info(self, 1, 1)
self.stubs.Set(network_api.API, 'allocate_for_instance',
fake_allocate_for_instance)
@@ -1654,7 +1654,7 @@ class ComputeTestCase(BaseTestCase):
'IPv6 pretty-printing broken on OSX, see bug 1409135')
def test_default_access_ip(self):
self.flags(default_access_ip_network_name='test1')
- fake_network.unset_stub_network_methods(self.stubs)
+ fake_network.unset_stub_network_methods(self)
instance = self._create_fake_instance_obj()
orig_update = self.compute._instance_update
@@ -2693,7 +2693,7 @@ class ComputeTestCase(BaseTestCase):
task_states.REBOOT_STARTED_HARD))
# This is a true unit test, so we don't need the network stubs.
- fake_network.unset_stub_network_methods(self.stubs)
+ fake_network.unset_stub_network_methods(self)
self.mox.StubOutWithMock(self.compute,
'_get_instance_block_device_info')
@@ -3970,7 +3970,7 @@ class ComputeTestCase(BaseTestCase):
def test_run_instance_queries_macs(self):
# run_instance should ask the driver for node mac addresses and pass
# that to the network_api in use.
- fake_network.unset_stub_network_methods(self.stubs)
+ fake_network.unset_stub_network_methods(self)
instance = self._create_fake_instance_obj()
macs = set(['01:23:45:67:89:ab'])
@@ -3982,7 +3982,7 @@ class ComputeTestCase(BaseTestCase):
requested_networks=None,
vpn=False, macs=macs,
security_groups=[], dhcp_options=None).AndReturn(
- fake_network.fake_get_instance_nw_info(self.stubs, 1, 1))
+ fake_network.fake_get_instance_nw_info(self, 1, 1))
self.mox.StubOutWithMock(self.compute.driver, "macs_for_instance")
self.compute.driver.macs_for_instance(
@@ -4034,7 +4034,7 @@ class ComputeTestCase(BaseTestCase):
mox.IgnoreArg(),
requested_networks=None).MultipleTimes()
- fake_network.unset_stub_network_methods(self.stubs)
+ fake_network.unset_stub_network_methods(self)
self.mox.ReplayAll()
@@ -5466,14 +5466,14 @@ class ComputeTestCase(BaseTestCase):
def test_pre_live_migration_works_correctly(self):
# Confirm setup_compute_volume is called when volume is mounted.
def stupid(*args, **kwargs):
- return fake_network.fake_get_instance_nw_info(self.stubs)
+ return fake_network.fake_get_instance_nw_info(self)
self.stubs.Set(self.compute.network_api,
'get_instance_nw_info', stupid)
# creating instance testdata
instance = self._create_fake_instance_obj({'host': 'dummy'})
c = context.get_admin_context()
- nw_info = fake_network.fake_get_instance_nw_info(self.stubs)
+ nw_info = fake_network.fake_get_instance_nw_info(self)
# creating mocks
self.mox.StubOutWithMock(self.compute.driver, 'pre_live_migration')
@@ -7420,7 +7420,7 @@ class ComputeAPITestCase(BaseTestCase):
def setUp(self):
def fake_get_nw_info(cls, ctxt, instance):
self.assertTrue(ctxt.is_admin)
- return fake_network.fake_get_instance_nw_info(self.stubs, 1, 1)
+ return fake_network.fake_get_instance_nw_info(self, 1, 1)
super(ComputeAPITestCase, self).setUp()
self.useFixture(fixtures.SpawnIsSynchronousFixture())
diff --git a/nova/tests/unit/compute/test_compute_mgr.py b/nova/tests/unit/compute/test_compute_mgr.py
index ddaa5bf388..cfd45ee28d 100644
--- a/nova/tests/unit/compute/test_compute_mgr.py
+++ b/nova/tests/unit/compute/test_compute_mgr.py
@@ -3961,8 +3961,7 @@ class ComputeManagerBuildInstanceTestCase(test.NoDBTestCase):
return_value=({}, instance))
@mock.patch.object(self.compute.driver, 'spawn')
@mock.patch.object(self.compute, '_build_networks_for_instance',
- return_value=fake_network.fake_get_instance_nw_info(
- self.stubs))
+ return_value=fake_network.fake_get_instance_nw_info(self))
@mock.patch.object(db, 'instance_extra_update_by_uuid')
@mock.patch.object(self.compute, '_notify_about_instance_usage')
def _check_access_ip(mock_notify, mock_extra, mock_networks,
diff --git a/nova/tests/unit/compute/test_compute_utils.py b/nova/tests/unit/compute/test_compute_utils.py
index 4142a21e77..cac60775be 100644
--- a/nova/tests/unit/compute/test_compute_utils.py
+++ b/nova/tests/unit/compute/test_compute_utils.py
@@ -401,7 +401,7 @@ class UsageInfoTestCase(test.TestCase):
def setUp(self):
def fake_get_nw_info(cls, ctxt, instance):
self.assertTrue(ctxt.is_admin)
- return fake_network.fake_get_instance_nw_info(self.stubs, 1, 1)
+ return fake_network.fake_get_instance_nw_info(self, 1, 1)
super(UsageInfoTestCase, self).setUp()
self.stubs.Set(network_api.API, 'get_instance_nw_info',
@@ -423,7 +423,7 @@ class UsageInfoTestCase(test.TestCase):
self.stubs.Set(nova.tests.unit.image.fake._FakeImageService,
'show', fake_show)
- fake_network.set_stub_network_methods(self.stubs)
+ fake_network.set_stub_network_methods(self)
fake_server_actions.stub_out_action_events(self.stubs)
def test_notify_usage_exists(self):
diff --git a/nova/tests/unit/fake_network.py b/nova/tests/unit/fake_network.py
index 248a78d830..b5131b0cec 100644
--- a/nova/tests/unit/fake_network.py
+++ b/nova/tests/unit/fake_network.py
@@ -22,7 +22,6 @@ from nova.compute import manager as compute_manager
import nova.context
from nova import db
from nova import exception
-from nova.network import api as network_api
from nova.network import manager as network_manager
from nova.network import model as network_model
from nova.network import rpcapi as network_rpcapi
@@ -285,9 +284,9 @@ def ipv4_like(ip, match_string):
return True
-def fake_get_instance_nw_info(stubs, num_networks=1, ips_per_vif=2,
+def fake_get_instance_nw_info(test, num_networks=1, ips_per_vif=2,
floating_ips_per_fixed_ip=0):
- # stubs is the self.stubs from the test
+ # test is an instance of nova.test.TestCase
# ips_per_vif is the number of ips each vif will have
# num_floating_ips is number of float ips for each fixed ip
network = network_manager.FlatManager(host=HOST)
@@ -318,8 +317,8 @@ def fake_get_instance_nw_info(stubs, num_networks=1, ips_per_vif=2,
}
return fake_info_cache
- stubs.Set(db, 'fixed_ip_get_by_instance', fixed_ips_fake)
- stubs.Set(db, 'instance_info_cache_update', update_cache_fake)
+ test.stub_out('nova.db.fixed_ip_get_by_instance', fixed_ips_fake)
+ test.stub_out('nova.db.instance_info_cache_update', update_cache_fake)
class FakeContext(nova.context.RequestContext):
def is_admin(self):
@@ -331,30 +330,30 @@ def fake_get_instance_nw_info(stubs, num_networks=1, ips_per_vif=2,
return nw_model
-def stub_out_nw_api_get_instance_nw_info(stubs, func=None,
+def stub_out_nw_api_get_instance_nw_info(test, func=None,
num_networks=1,
ips_per_vif=1,
floating_ips_per_fixed_ip=0):
def get_instance_nw_info(self, context, instance, conductor_api=None):
- return fake_get_instance_nw_info(stubs, num_networks=num_networks,
+ return fake_get_instance_nw_info(test, num_networks=num_networks,
ips_per_vif=ips_per_vif,
floating_ips_per_fixed_ip=floating_ips_per_fixed_ip)
if func is None:
func = get_instance_nw_info
- stubs.Set(network_api.API, 'get_instance_nw_info', func)
+ test.stub_out('nova.network.api.API.get_instance_nw_info', func)
-def stub_out_network_cleanup(stubs):
- stubs.Set(network_api.API, 'deallocate_for_instance',
+def stub_out_network_cleanup(test):
+ test.stub_out('nova.network.api.API.deallocate_for_instance',
lambda *args, **kwargs: None)
_real_functions = {}
-def set_stub_network_methods(stubs):
+def set_stub_network_methods(test):
global _real_functions
cm = compute_manager.ComputeManager
if not _real_functions:
@@ -368,16 +367,18 @@ def set_stub_network_methods(stubs):
def fake_async_networkinfo(*args, **kwargs):
return network_model.NetworkInfoAsyncWrapper(fake_networkinfo)
- stubs.Set(cm, '_allocate_network', fake_async_networkinfo)
- stubs.Set(cm, '_deallocate_network', lambda *args, **kwargs: None)
+ test.stub_out('nova.compute.manager.ComputeManager._allocate_network',
+ fake_async_networkinfo)
+ test.stub_out('nova.compute.manager.ComputeManager._deallocate_network',
+ lambda *args, **kwargs: None)
-def unset_stub_network_methods(stubs):
+def unset_stub_network_methods(test):
global _real_functions
if _real_functions:
- cm = compute_manager.ComputeManager
for name in _real_functions:
- stubs.Set(cm, name, _real_functions[name])
+ test.stub_out('nova.compute.manager.ComputeManager.' + name,
+ _real_functions[name])
def stub_compute_with_ips(stubs):
diff --git a/nova/tests/unit/network/test_manager.py b/nova/tests/unit/network/test_manager.py
index fe1c5097bc..6a85d83177 100644
--- a/nova/tests/unit/network/test_manager.py
+++ b/nova/tests/unit/network/test_manager.py
@@ -196,10 +196,10 @@ class FlatNetworkTestCase(test.TestCase):
def test_get_instance_nw_info_fake(self):
fake_get_instance_nw_info = fake_network.fake_get_instance_nw_info
- nw_info = fake_get_instance_nw_info(self.stubs, 0, 2)
+ nw_info = fake_get_instance_nw_info(self, 0, 2)
self.assertFalse(nw_info)
- nw_info = fake_get_instance_nw_info(self.stubs, 1, 2)
+ nw_info = fake_get_instance_nw_info(self, 1, 2)
for i, vif in enumerate(nw_info):
nid = i + 1
diff --git a/nova/tests/unit/test_metadata.py b/nova/tests/unit/test_metadata.py
index 4194106ae4..ead833eac2 100644
--- a/nova/tests/unit/test_metadata.py
+++ b/nova/tests/unit/test_metadata.py
@@ -161,7 +161,7 @@ class MetadataTestCase(test.TestCase):
self.flags(use_local=True, group='conductor')
self.keypair = fake_keypair_obj(self.instance.key_name,
self.instance.key_data)
- fake_network.stub_out_nw_api_get_instance_nw_info(self.stubs)
+ fake_network.stub_out_nw_api_get_instance_nw_info(self)
def test_can_pickle_metadata(self):
# Make sure that InstanceMetadata is possible to pickle. This is
@@ -350,7 +350,7 @@ class MetadataTestCase(test.TestCase):
base.InstanceMetadata(fake_inst_obj(self.context))
def test_local_ipv4(self):
- nw_info = fake_network.fake_get_instance_nw_info(self.stubs,
+ nw_info = fake_network.fake_get_instance_nw_info(self,
num_networks=2)
expected_local = "192.168.1.100"
md = fake_InstanceMetadata(self.stubs, self.instance,
@@ -359,7 +359,7 @@ class MetadataTestCase(test.TestCase):
self.assertEqual(expected_local, data['meta-data']['local-ipv4'])
def test_local_ipv4_from_nw_info(self):
- nw_info = fake_network.fake_get_instance_nw_info(self.stubs,
+ nw_info = fake_network.fake_get_instance_nw_info(self,
num_networks=2)
expected_local = "192.168.1.100"
md = fake_InstanceMetadata(self.stubs, self.instance,
@@ -444,7 +444,7 @@ class OpenStackMetadataTestCase(test.TestCase):
self.context = context.RequestContext('fake', 'fake')
self.instance = fake_inst_obj(self.context)
self.flags(use_local=True, group='conductor')
- fake_network.stub_out_nw_api_get_instance_nw_info(self.stubs)
+ fake_network.stub_out_nw_api_get_instance_nw_info(self)
def test_top_level_listing(self):
# request for /openstack/<version>/ should show metadata.json
@@ -717,7 +717,7 @@ class MetadataHandlerTestCase(test.TestCase):
def setUp(self):
super(MetadataHandlerTestCase, self).setUp()
- fake_network.stub_out_nw_api_get_instance_nw_info(self.stubs)
+ fake_network.stub_out_nw_api_get_instance_nw_info(self)
self.context = context.RequestContext('fake', 'fake')
self.instance = fake_inst_obj(self.context)
self.flags(use_local=True, group='conductor')
@@ -1187,7 +1187,7 @@ class MetadataHandlerTestCase(test.TestCase):
class MetadataPasswordTestCase(test.TestCase):
def setUp(self):
super(MetadataPasswordTestCase, self).setUp()
- fake_network.stub_out_nw_api_get_instance_nw_info(self.stubs)
+ fake_network.stub_out_nw_api_get_instance_nw_info(self)
self.context = context.RequestContext('fake', 'fake')
self.instance = fake_inst_obj(self.context)
self.flags(use_local=True, group='conductor')
diff --git a/nova/tests/unit/test_notifications.py b/nova/tests/unit/test_notifications.py
index 925ef1f669..ec4a4fdb80 100644
--- a/nova/tests/unit/test_notifications.py
+++ b/nova/tests/unit/test_notifications.py
@@ -45,7 +45,7 @@ class NotificationsTestCase(test.TestCase):
super(NotificationsTestCase, self).setUp()
self.fixture = self.useFixture(o_fixture.ClearRequestContext())
- self.net_info = fake_network.fake_get_instance_nw_info(self.stubs, 1,
+ self.net_info = fake_network.fake_get_instance_nw_info(self, 1,
1)
def fake_get_nw_info(cls, ctxt, instance):
@@ -54,7 +54,7 @@ class NotificationsTestCase(test.TestCase):
self.stubs.Set(network_api.API, 'get_instance_nw_info',
fake_get_nw_info)
- fake_network.set_stub_network_methods(self.stubs)
+ fake_network.set_stub_network_methods(self)
fake_notifier.stub_notifier(self.stubs)
self.addCleanup(fake_notifier.reset)
diff --git a/nova/tests/unit/virt/libvirt/test_driver.py b/nova/tests/unit/virt/libvirt/test_driver.py
index cc855422da..e91808e37d 100644
--- a/nova/tests/unit/virt/libvirt/test_driver.py
+++ b/nova/tests/unit/virt/libvirt/test_driver.py
@@ -1284,7 +1284,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
image_meta)
cfg = drvr._get_guest_config(instance_ref,
- _fake_network_info(self.stubs, 1),
+ _fake_network_info(self, 1),
image_meta, disk_info,
context=ctxt)
@@ -1366,7 +1366,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
instance_ref = objects.Instance(**self.test_instance)
image_meta = objects.ImageMeta.from_dict(self.test_image_meta)
cfg = drvr._get_guest_config(instance_ref,
- _fake_network_info(self.stubs, 1),
+ _fake_network_info(self, 1),
image_meta, {'mapping': {}})
self.assertEqual(instance_ref["uuid"], cfg.uuid)
self.assertEqual(2 * units.Mi, cfg.memory)
@@ -1391,7 +1391,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
instance_ref = objects.Instance(**self.test_instance)
image_meta = objects.ImageMeta.from_dict(self.test_image_meta)
cfg = drvr._get_guest_config(instance_ref,
- _fake_network_info(self.stubs, 1),
+ _fake_network_info(self, 1),
image_meta, {'mapping': {}})
self.assertEqual(instance_ref["uuid"], cfg.uuid)
self.assertEqual(2 * units.Mi, cfg.memory)
@@ -2420,7 +2420,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
instance_ref,
image_meta)
cfg = drvr._get_guest_config(instance_ref,
- _fake_network_info(self.stubs, 1),
+ _fake_network_info(self, 1),
image_meta, disk_info)
self.assertIsInstance(cfg.clock,
@@ -2447,7 +2447,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
instance_ref,
image_meta)
cfg = drvr._get_guest_config(instance_ref,
- _fake_network_info(self.stubs, 1),
+ _fake_network_info(self, 1),
image_meta, disk_info)
self.assertIsInstance(cfg.clock,
@@ -2487,7 +2487,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
instance_ref,
image_meta)
cfg = drvr._get_guest_config(instance_ref,
- _fake_network_info(self.stubs, 1),
+ _fake_network_info(self, 1),
image_meta, disk_info)
self.assertIsInstance(cfg.clock,
@@ -2518,7 +2518,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
instance_ref,
image_meta)
cfg = drvr._get_guest_config(instance_ref,
- _fake_network_info(self.stubs, 1),
+ _fake_network_info(self, 1),
image_meta, disk_info)
self.assertIsInstance(cfg.clock,
@@ -2547,7 +2547,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
instance_ref,
image_meta)
cfg = drvr._get_guest_config(instance_ref,
- _fake_network_info(self.stubs, 2),
+ _fake_network_info(self, 2),
image_meta, disk_info)
self.assertEqual(2, len(cfg.features))
self.assertIsInstance(cfg.features[0],
@@ -4362,7 +4362,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
image_meta)
cfg = drvr._get_guest_config(instance_ref,
- _fake_network_info(self.stubs, 1),
+ _fake_network_info(self, 1),
image_meta, disk_info)
self.assertEqual(cfg.os_cmdline, "fake_os_command_line")
@@ -4382,7 +4382,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
image_meta)
cfg = drvr._get_guest_config(instance_ref,
- _fake_network_info(self.stubs, 1),
+ _fake_network_info(self, 1),
image_meta, disk_info)
self.assertIsNone(cfg.os_cmdline)
@@ -4407,7 +4407,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
# default, so testing an empty string and None value in the
# os_command_line image property must pass
cfg = drvr._get_guest_config(instance_ref,
- _fake_network_info(self.stubs, 1),
+ _fake_network_info(self, 1),
image_meta, disk_info)
self.assertNotEqual(cfg.os_cmdline, "")
@@ -4436,7 +4436,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
cfg = drvr._get_guest_config(instance_ref,
- _fake_network_info(self.stubs, 1),
+ _fake_network_info(self, 1),
image_meta, disk_info)
self.assertEqual(cfg.os_mach_type, "vexpress-a15")
@@ -4465,7 +4465,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
cfg = drvr._get_guest_config(instance_ref,
- _fake_network_info(self.stubs, 1),
+ _fake_network_info(self, 1),
image_meta, disk_info)
self.assertEqual(cfg.os_mach_type, "virt")
@@ -4499,7 +4499,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
image_meta)
cfg = drvr._get_guest_config(instance_ref,
- _fake_network_info(self.stubs, 1),
+ _fake_network_info(self, 1),
image_meta, disk_info)
self.assertEqual(cfg.os_mach_type, "fake_machine_type")
@@ -4546,7 +4546,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
image_meta)
cfg = drvr._get_guest_config(instance_ref,
- _fake_network_info(self.stubs, 1),
+ _fake_network_info(self, 1),
image_meta, disk_info)
self.assertEqual(cfg.os_mach_type, "fake_machine_type")
@@ -4616,7 +4616,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
instance_ref,
image_meta)
conf = drvr._get_guest_config(instance_ref,
- _fake_network_info(self.stubs, 1),
+ _fake_network_info(self, 1),
image_meta, disk_info)
self.assertIsInstance(conf.cpu,
vconfig.LibvirtConfigGuestCPU)
@@ -4639,7 +4639,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
instance_ref,
image_meta)
conf = drvr._get_guest_config(instance_ref,
- _fake_network_info(self.stubs, 1),
+ _fake_network_info(self, 1),
image_meta, disk_info)
self.assertIsInstance(conf.cpu,
vconfig.LibvirtConfigGuestCPU)
@@ -4662,7 +4662,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
instance_ref,
image_meta)
conf = drvr._get_guest_config(instance_ref,
- _fake_network_info(self.stubs, 1),
+ _fake_network_info(self, 1),
image_meta, disk_info)
self.assertIsNone(conf.cpu)
@@ -4679,7 +4679,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
instance_ref,
image_meta)
conf = drvr._get_guest_config(instance_ref,
- _fake_network_info(self.stubs, 1),
+ _fake_network_info(self, 1),
image_meta, disk_info)
self.assertIsNone(conf.cpu)
@@ -4693,7 +4693,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
instance_ref,
image_meta)
conf = drvr._get_guest_config(instance_ref,
- _fake_network_info(self.stubs, 1),
+ _fake_network_info(self, 1),
image_meta, disk_info)
self.assertIsInstance(conf.cpu,
vconfig.LibvirtConfigGuestCPU)
@@ -4713,7 +4713,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
instance_ref,
image_meta)
conf = drvr._get_guest_config(instance_ref,
- _fake_network_info(self.stubs, 1),
+ _fake_network_info(self, 1),
image_meta, disk_info)
self.assertIsInstance(conf.cpu,
vconfig.LibvirtConfigGuestCPU)
@@ -4735,7 +4735,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
instance_ref,
image_meta)
conf = drvr._get_guest_config(instance_ref,
- _fake_network_info(self.stubs, 1),
+ _fake_network_info(self, 1),
image_meta, disk_info)
self.assertIsInstance(conf.cpu,
vconfig.LibvirtConfigGuestCPU)
@@ -4757,7 +4757,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
image_meta)
conf = drvr._get_guest_config(instance_ref,
- _fake_network_info(self.stubs, 1),
+ _fake_network_info(self, 1),
image_meta, disk_info)
self.assertIsInstance(conf.cpu,
vconfig.LibvirtConfigGuestCPU)
@@ -5432,7 +5432,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
mock_get_domain.assert_called_once_with(instance)
def test_multi_nic(self):
- network_info = _fake_network_info(self.stubs, 2)
+ network_info = _fake_network_info(self, 2)
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
instance_ref = objects.Instance(**self.test_instance)
image_meta = objects.ImageMeta.from_dict(self.test_image_meta)
@@ -5504,7 +5504,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
self.assertEqual(drvr._uri(), 'lxc:///')
- network_info = _fake_network_info(self.stubs, 1)
+ network_info = _fake_network_info(self, 1)
disk_info = blockinfo.get_disk_info(CONF.libvirt.virt_type,
instance_ref,
image_meta)
@@ -5561,7 +5561,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
self.flags(disk_prefix=prefix, group='libvirt')
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
- network_info = _fake_network_info(self.stubs, 1)
+ network_info = _fake_network_info(self, 1)
disk_info = blockinfo.get_disk_info(CONF.libvirt.virt_type,
instance_ref,
image_meta)
@@ -5600,7 +5600,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
instance_ref = objects.Instance(**self.test_instance)
image_meta = objects.ImageMeta.from_dict(self.test_image_meta)
- network_info = _fake_network_info(self.stubs, 1)
+ network_info = _fake_network_info(self, 1)
drv = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
disk_info = blockinfo.get_disk_info(CONF.libvirt.virt_type,
@@ -5632,7 +5632,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
def _check_xml_and_disk_bus(self, image_meta,
block_device_info, wantConfig):
instance_ref = objects.Instance(**self.test_instance)
- network_info = _fake_network_info(self.stubs, 1)
+ network_info = _fake_network_info(self, 1)
drv = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
disk_info = blockinfo.get_disk_info(CONF.libvirt.virt_type,
@@ -5663,7 +5663,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
def _check_xml_and_uuid(self, image_meta):
instance_ref = objects.Instance(**self.test_instance)
image_meta = objects.ImageMeta.from_dict(self.test_image_meta)
- network_info = _fake_network_info(self.stubs, 1)
+ network_info = _fake_network_info(self, 1)
drv = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
disk_info = blockinfo.get_disk_info(CONF.libvirt.virt_type,
@@ -5831,7 +5831,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
self.assertEqual(drvr._uri(), expected_uri)
- network_info = _fake_network_info(self.stubs, 1)
+ network_info = _fake_network_info(self, 1)
disk_info = blockinfo.get_disk_info(CONF.libvirt.virt_type,
instance_ref,
image_meta,
@@ -5897,7 +5897,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
# _fake_network_info must be called before create_fake_libvirt_mock(),
# as _fake_network_info calls importutils.import_class() and
# create_fake_libvirt_mock() mocks importutils.import_class().
- network_info = _fake_network_info(self.stubs, 1)
+ network_info = _fake_network_info(self, 1)
self.create_fake_libvirt_mock()
instance_ref = objects.Instance(**self.test_instance)
@@ -8213,7 +8213,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
# _fake_network_info must be called before create_fake_libvirt_mock(),
# as _fake_network_info calls importutils.import_class() and
# create_fake_libvirt_mock() mocks importutils.import_class().
- network_info = _fake_network_info(self.stubs, 1)
+ network_info = _fake_network_info(self, 1)
self.create_fake_libvirt_mock(getLibVersion=fake_getLibVersion,
getCapabilities=fake_getCapabilities,
getVersion=lambda: 1005001,
@@ -9348,7 +9348,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
mock_get_domain.return_value = mock_virDomain
instance = objects.Instance(**self.test_instance)
- network_info = _fake_network_info(self.stubs, 1)
+ network_info = _fake_network_info(self, 1)
drvr.resume_state_on_host_boot(self.context, instance, network_info,
block_device_info=None)
@@ -9406,7 +9406,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
self.context.auth_token = True # any non-None value will suffice
instance = objects.Instance(**self.test_instance)
instance_path = libvirt_utils.get_instance_path(instance)
- network_info = _fake_network_info(self.stubs, 1)
+ network_info = _fake_network_info(self, 1)
block_device_info = None
dummyxml = ("<domain type='kvm'><name>instance-0000000a</name>"
@@ -9606,7 +9606,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
mock_attachDevice):
instance = objects.Instance(**self.test_instance)
- network_info = _fake_network_info(self.stubs, 1)
+ network_info = _fake_network_info(self, 1)
network_info[0]['vnic_type'] = network_model.VNIC_TYPE_DIRECT
guest = libvirt_guest.Guest(FakeVirtDomain())
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
@@ -9626,7 +9626,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
mock_attachDevice):
instance = objects.Instance(**self.test_instance)
- network_info = _fake_network_info(self.stubs, 1)
+ network_info = _fake_network_info(self, 1)
network_info[0]['vnic_type'] = network_model.VNIC_TYPE_DIRECT
instance.info_cache = objects.InstanceInfoCache(
network_info=network_info)
@@ -9649,7 +9649,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
mock_has_min_version):
instance = objects.Instance(**self.test_instance)
- network_info = _fake_network_info(self.stubs, 1)
+ network_info = _fake_network_info(self, 1)
network_info[0]['vnic_type'] = network_model.VNIC_TYPE_DIRECT
instance.info_cache = objects.InstanceInfoCache(
network_info=network_info)
@@ -9674,7 +9674,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
"<target dev='vdb' bus='virtio'/></disk>"
"</devices></domain>")
instance = objects.Instance(**self.test_instance)
- network_info = _fake_network_info(self.stubs, 1)
+ network_info = _fake_network_info(self, 1)
block_device_info = None
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), False)
guest = libvirt_guest.Guest('fake_dom')
@@ -11753,7 +11753,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
self.stubs.Set(host.Host, "get_domain", lambda a, b: FakeVirtDomain())
instance = objects.Instance(**self.test_instance)
- network_info = _fake_network_info(self.stubs, 1)
+ network_info = _fake_network_info(self, 1)
drvr = libvirt_driver.LibvirtDriver(fake.FakeVirtAPI(), True)
fake_image_meta = {'id': instance['image_ref']}
@@ -11976,7 +11976,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
</cpu>
"""
- network_info = _fake_network_info(self.stubs, 1)
+ network_info = _fake_network_info(self, 1)
self.create_fake_libvirt_mock(getLibVersion=fake_getLibVersion,
getCapabilities=fake_getCapabilities,
getVersion=lambda: 1005001,
@@ -12634,7 +12634,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
image_meta)
cfg = drvr._get_guest_config(instance_ref,
- _fake_network_info(self.stubs, 1),
+ _fake_network_info(self, 1),
image_meta, disk_info)
self.assertEqual("parallels", cfg.virt_type)
self.assertEqual(instance_ref["uuid"], cfg.uuid)
@@ -12666,7 +12666,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
image_meta = objects.ImageMeta.from_dict(self.test_image_meta)
cfg = drvr._get_guest_config(instance_ref,
- _fake_network_info(self.stubs, 1),
+ _fake_network_info(self, 1),
image_meta, {'mapping': {'disk': {}}})
self.assertEqual("parallels", cfg.virt_type)
self.assertEqual(instance_ref["uuid"], cfg.uuid)
@@ -12717,7 +12717,7 @@ class LibvirtConnTestCase(test.NoDBTestCase):
driver_block_device.DriverVolumeBlockDevice, 'save'
) as mock_save:
cfg = drvr._get_guest_config(instance_ref,
- _fake_network_info(self.stubs, 1),
+ _fake_network_info(self, 1),
image_meta, disk_info, None, info)
mock_save.assert_called_once_with()
@@ -13631,11 +13631,11 @@ class LibvirtDriverTestCase(test.NoDBTestCase):
self.mox.StubOutWithMock(self.drvr, "_cleanup_resize")
self.drvr._cleanup_resize(ins_ref,
- _fake_network_info(self.stubs, 1))
+ _fake_network_info(self, 1))
self.mox.ReplayAll()
self.drvr.confirm_migration("migration_ref", ins_ref,
- _fake_network_info(self.stubs, 1))
+ _fake_network_info(self, 1))
def test_cleanup_resize_same_host(self):
CONF.set_override('policy_dirs', [], group='oslo_policy')
@@ -13656,7 +13656,7 @@ class LibvirtDriverTestCase(test.NoDBTestCase):
self.mox.ReplayAll()
self.drvr._cleanup_resize(ins_ref,
- _fake_network_info(self.stubs, 1))
+ _fake_network_info(self, 1))
def test_cleanup_resize_not_same_host(self):
CONF.set_override('policy_dirs', [], group='oslo_policy')
@@ -13693,7 +13693,7 @@ class LibvirtDriverTestCase(test.NoDBTestCase):
self.mox.ReplayAll()
self.drvr._cleanup_resize(ins_ref,
- _fake_network_info(self.stubs, 1))
+ _fake_network_info(self, 1))
def test_get_instance_disk_info_exception(self):
instance = self._create_instance()
@@ -13876,7 +13876,7 @@ class LibvirtDriverTestCase(test.NoDBTestCase):
def _test_attach_detach_interface(self, method, power_state,
expected_flags):
instance = self._create_instance()
- network_info = _fake_network_info(self.stubs, 1)
+ network_info = _fake_network_info(self, 1)
domain = FakeVirtDomain()
self.mox.StubOutWithMock(host.Host, 'get_domain')
self.mox.StubOutWithMock(self.drvr.firewall_driver,
@@ -13965,7 +13965,7 @@ class LibvirtDriverTestCase(test.NoDBTestCase):
"<source file='/test/disk.local'/>"
"<target dev='vdb' bus='virtio'/></disk>"
"</devices></domain>")
- network_info = _fake_network_info(self.stubs, 1)
+ network_info = _fake_network_info(self, 1)
self.mox.StubOutWithMock(self.drvr,
'_get_existing_domain_xml')
@@ -14077,7 +14077,7 @@ class LibvirtDriverTestCase(test.NoDBTestCase):
"<source file='/test/disk.local'/>"
"<target dev='vdb' bus='virtio'/></disk>"
"</devices></domain>")
- network_info = _fake_network_info(self.stubs, 1)
+ network_info = _fake_network_info(self, 1)
self.mox.StubOutWithMock(self.drvr,
'_get_existing_domain_xml')
diff --git a/nova/tests/unit/virt/libvirt/test_firewall.py b/nova/tests/unit/virt/libvirt/test_firewall.py
index 420a6e3541..6ab97f7adc 100644
--- a/nova/tests/unit/virt/libvirt/test_firewall.py
+++ b/nova/tests/unit/virt/libvirt/test_firewall.py
@@ -251,7 +251,7 @@ class IptablesFirewallTestCase(test.NoDBTestCase):
self.out6_rules = lines
return '', ''
- network_model = _fake_network_info(self.stubs, 1)
+ network_model = _fake_network_info(self, 1)
linux_net.iptables_manager.execute = fake_iptables_execute
@@ -315,14 +315,14 @@ class IptablesFirewallTestCase(test.NoDBTestCase):
def test_filters_for_instance_with_ip_v6(self):
self.flags(use_ipv6=True)
- network_info = _fake_network_info(self.stubs, 1)
+ network_info = _fake_network_info(self, 1)
rulesv4, rulesv6 = self.fw._filters_for_instance("fake", network_info)
self.assertEqual(len(rulesv4), 2)
self.assertEqual(len(rulesv6), 1)
def test_filters_for_instance_without_ip_v6(self):
self.flags(use_ipv6=False)
- network_info = _fake_network_info(self.stubs, 1)
+ network_info = _fake_network_info(self, 1)
rulesv4, rulesv6 = self.fw._filters_for_instance("fake", network_info)
self.assertEqual(len(rulesv4), 2)
self.assertEqual(len(rulesv6), 0)
@@ -338,7 +338,7 @@ class IptablesFirewallTestCase(test.NoDBTestCase):
networks_count = 5
instance_ref = self._create_instance_ref()
instance_ref.security_groups = objects.SecurityGroupList()
- network_info = _fake_network_info(self.stubs, networks_count,
+ network_info = _fake_network_info(self, networks_count,
ipv4_addr_per_network)
network_info[0]['network']['subnets'][0]['meta']['dhcp_server'] = \
'1.1.1.1'
@@ -421,7 +421,7 @@ class IptablesFirewallTestCase(test.NoDBTestCase):
mock_secrule.return_value = objects.SecurityGroupRuleList()
- network_info = _fake_network_info(self.stubs, 1)
+ network_info = _fake_network_info(self, 1)
self.fw.setup_basic_filtering(instance_ref, network_info)
self.fw.prepare_instance_filter(instance_ref, network_info)
self.fw.apply_instance_filter(instance_ref, network_info)
@@ -445,7 +445,7 @@ class IptablesFirewallTestCase(test.NoDBTestCase):
# create a firewall via setup_basic_filtering like libvirt_conn.spawn
# should have a chain with 0 rules
- network_info = _fake_network_info(self.stubs, 1)
+ network_info = _fake_network_info(self, 1)
self.fw.setup_basic_filtering(instance_ref, network_info)
self.assertIn('provider', self.fw.iptables.ipv4['filter'].chains)
rules = [rule for rule in self.fw.iptables.ipv4['filter'].rules
@@ -588,7 +588,7 @@ class NWFilterTestCase(test.NoDBTestCase):
self.recursive_depends[instance_filter],
"Instance filter includes %s" % required_not)
- network_info = _fake_network_info(self.stubs, 1)
+ network_info = _fake_network_info(self, 1)
# since there is one (network_info) there is one vif
# pass this vif's mac to _ensure_all_called()
# to set the instance_filter properly
@@ -616,7 +616,7 @@ class NWFilterTestCase(test.NoDBTestCase):
instance_ref = self._create_instance()
self._create_security_group(instance_ref)
- network_info = _fake_network_info(self.stubs, 1)
+ network_info = _fake_network_info(self, 1)
self.fw.setup_basic_filtering(instance_ref, network_info)
original_filter_count = len(fakefilter.filters)
self.fw.unfilter_instance(instance_ref, network_info)
@@ -635,7 +635,7 @@ class NWFilterTestCase(test.NoDBTestCase):
mock_lookup.return_value = fakefilter
instance_ref = self._create_instance()
- network_info = _fake_network_info(self.stubs, 1)
+ network_info = _fake_network_info(self, 1)
self.assertRaises(fakelibvirt.libvirtError, self.fw.unfilter_instance,
instance_ref, network_info)
@@ -656,7 +656,7 @@ class NWFilterTestCase(test.NoDBTestCase):
mock_lookup.return_value = fakefilter
instance_ref = self._create_instance()
- network_info = _fake_network_info(self.stubs, 1)
+ network_info = _fake_network_info(self, 1)
self.fw.unfilter_instance(instance_ref, network_info)
self.assertEqual(2, mock_lookup.call_count)
@@ -675,7 +675,7 @@ class NWFilterTestCase(test.NoDBTestCase):
mock_lookup.return_value = fakefilter
instance_ref = self._create_instance()
- network_info = _fake_network_info(self.stubs, 1)
+ network_info = _fake_network_info(self, 1)
self.fw.unfilter_instance(instance_ref, network_info)
self.assertEqual(2, mock_lookup.call_count)
@@ -690,7 +690,7 @@ class NWFilterTestCase(test.NoDBTestCase):
instance_ref = self._create_instance()
self._create_security_group(instance_ref)
- network_info = _fake_network_info(self.stubs, 1)
+ network_info = _fake_network_info(self, 1)
self.fw.setup_basic_filtering(instance_ref, network_info)
self.fw.setup_basic_filtering(instance_ref, network_info)
@@ -706,7 +706,7 @@ class NWFilterTestCase(test.NoDBTestCase):
instance_ref = self._create_instance()
self._create_security_group(instance_ref)
- network_info = _fake_network_info(self.stubs, 1)
+ network_info = _fake_network_info(self, 1)
self.fw.setup_basic_filtering(instance_ref, network_info)
vif = network_info[0]
@@ -761,7 +761,7 @@ class NWFilterTestCase(test.NoDBTestCase):
instance_ref = self._create_instance()
self._create_security_group(instance_ref)
- network_info = _fake_network_info(self.stubs, 2)
+ network_info = _fake_network_info(self, 2)
network_info[0]['network']['subnets'][0]['meta']['dhcp_server'] = \
'1.1.1.1'
diff --git a/nova/tests/unit/virt/xenapi/test_xenapi.py b/nova/tests/unit/virt/xenapi/test_xenapi.py
index 33243c070c..0b44847b94 100644
--- a/nova/tests/unit/virt/xenapi/test_xenapi.py
+++ b/nova/tests/unit/virt/xenapi/test_xenapi.py
@@ -753,7 +753,7 @@ class XenAPIVMTestCase(stubs.XenAPITestBase):
instance = objects.Instance.get_by_id(self.context, instance_id,
expected_attrs=['flavor'])
- network_info = fake_network.fake_get_instance_nw_info(self.stubs)
+ network_info = fake_network.fake_get_instance_nw_info(self)
if empty_dns:
# NOTE(tr3buchet): this is a terrible way to do this...
network_info[0]['network']['subnets'][0]['dns'] = []
@@ -1560,7 +1560,7 @@ iface eth0 inet6 static
instance = create_instance_with_system_metadata(self.context,
instance_values)
- network_info = fake_network.fake_get_instance_nw_info(self.stubs)
+ network_info = fake_network.fake_get_instance_nw_info(self)
image_meta = {'id': IMAGE_VHD,
'disk_format': 'vhd'}
if spawn:
@@ -1588,7 +1588,7 @@ iface eth0 inet6 static
fake_destroy_kernel_ramdisk)
instance = self._create_instance(spawn=True, obj=True)
- network_info = fake_network.fake_get_instance_nw_info(self.stubs)
+ network_info = fake_network.fake_get_instance_nw_info(self)
self.conn.destroy(self.context, instance, network_info)
vm_ref = vm_utils.lookup(self.conn._session, instance['name'])
@@ -1770,7 +1770,7 @@ class XenAPIMigrateInstance(stubs.XenAPITestBase):
self.mox.StubOutWithMock(volume_utils, 'is_booted_from_volume')
conn = xenapi_conn.XenAPIDriver(fake.FakeVirtAPI(), False)
- network_info = fake_network.fake_get_instance_nw_info(self.stubs)
+ network_info = fake_network.fake_get_instance_nw_info(self)
image_meta = {'id': instance['image_ref'], 'disk_format': 'vhd'}
base = xenapi_fake.create_vdi('hurr', 'fake')
base_uuid = xenapi_fake.get_record('VDI', base)['uuid']
@@ -1812,7 +1812,7 @@ class XenAPIMigrateInstance(stubs.XenAPITestBase):
product_brand='XenServer')
conn = xenapi_conn.XenAPIDriver(fake.FakeVirtAPI(), False)
- network_info = fake_network.fake_get_instance_nw_info(self.stubs)
+ network_info = fake_network.fake_get_instance_nw_info(self)
image_meta = {'id': instance['image_ref'], 'disk_format': 'vhd'}
conn.finish_migration(self.context, self.migration, instance,
dict(base_copy='hurr', cow='durr'),
@@ -1839,7 +1839,7 @@ class XenAPIMigrateInstance(stubs.XenAPITestBase):
self.stubs.Set(stubs.FakeSessionForVMTests,
"VDI_resize_online", fake_vdi_resize)
conn = xenapi_conn.XenAPIDriver(fake.FakeVirtAPI(), False)
- network_info = fake_network.fake_get_instance_nw_info(self.stubs)
+ network_info = fake_network.fake_get_instance_nw_info(self)
image_meta = {'id': instance['image_ref'], 'disk_format': 'vhd'}
conn.finish_migration(self.context, self.migration, instance,
dict(base_copy='hurr', cow='durr'),
@@ -1855,7 +1855,7 @@ class XenAPIMigrateInstance(stubs.XenAPITestBase):
self.stubs.Set(stubs.FakeSessionForVMTests,
"VDI_resize_online", fake_vdi_resize)
conn = xenapi_conn.XenAPIDriver(fake.FakeVirtAPI(), False)
- network_info = fake_network.fake_get_instance_nw_info(self.stubs)
+ network_info = fake_network.fake_get_instance_nw_info(self)
# Resize instance would be determined by the compute call
image_meta = {'id': instance['image_ref'], 'disk_format': 'vhd'}
conn.finish_migration(self.context, self.migration, instance,
@@ -2762,7 +2762,7 @@ class XenAPIDom0IptablesFirewallTestCase(stubs.XenAPITestBase):
instance_ref = db.instance_get(admin_ctxt, instance_ref['id'])
src_instance_ref = db.instance_get(admin_ctxt, src_instance_ref['id'])
- network_model = fake_network.fake_get_instance_nw_info(self.stubs, 1)
+ network_model = fake_network.fake_get_instance_nw_info(self, 1)
from nova.compute import utils as compute_utils # noqa
self.stubs.Set(compute_utils, 'get_nw_info_for_instance',
@@ -2785,14 +2785,14 @@ class XenAPIDom0IptablesFirewallTestCase(stubs.XenAPITestBase):
def test_filters_for_instance_with_ip_v6(self):
self.flags(use_ipv6=True)
- network_info = fake_network.fake_get_instance_nw_info(self.stubs, 1)
+ network_info = fake_network.fake_get_instance_nw_info(self, 1)
rulesv4, rulesv6 = self.fw._filters_for_instance("fake", network_info)
self.assertEqual(len(rulesv4), 2)
self.assertEqual(len(rulesv6), 1)
def test_filters_for_instance_without_ip_v6(self):
self.flags(use_ipv6=False)
- network_info = fake_network.fake_get_instance_nw_info(self.stubs, 1)
+ network_info = fake_network.fake_get_instance_nw_info(self, 1)
rulesv4, rulesv6 = self.fw._filters_for_instance("fake", network_info)
self.assertEqual(len(rulesv4), 2)
self.assertEqual(len(rulesv6), 0)
@@ -2805,7 +2805,7 @@ class XenAPIDom0IptablesFirewallTestCase(stubs.XenAPITestBase):
networks_count = 5
instance_ref = self._create_instance_ref()
_get_instance_nw_info = fake_network.fake_get_instance_nw_info
- network_info = _get_instance_nw_info(self.stubs,
+ network_info = _get_instance_nw_info(self,
networks_count,
ipv4_addr_per_network)
network_info[0]['network']['subnets'][0]['meta']['dhcp_server'] = \
@@ -2829,7 +2829,7 @@ class XenAPIDom0IptablesFirewallTestCase(stubs.XenAPITestBase):
def test_do_refresh_security_group_rules(self):
admin_ctxt = context.get_admin_context()
instance_ref = self._create_instance_ref()
- network_info = fake_network.fake_get_instance_nw_info(self.stubs, 1, 1)
+ network_info = fake_network.fake_get_instance_nw_info(self, 1, 1)
secgroup = self._create_test_security_group()
db.instance_add_security_group(admin_ctxt, instance_ref['uuid'],
secgroup['id'])
@@ -2859,7 +2859,7 @@ class XenAPIDom0IptablesFirewallTestCase(stubs.XenAPITestBase):
# peeks at how the firewall names chains
chain_name = 'inst-%s' % instance_ref['id']
- network_info = fake_network.fake_get_instance_nw_info(self.stubs, 1, 1)
+ network_info = fake_network.fake_get_instance_nw_info(self, 1, 1)
self.fw.prepare_instance_filter(instance_ref, network_info)
self.assertIn('provider', self.fw.iptables.ipv4['filter'].chains)
rules = [rule for rule in self.fw.iptables.ipv4['filter'].rules