summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--nova/tests/unit/conductor/tasks/test_live_migrate.py3
-rw-r--r--nova/tests/unit/conductor/test_conductor.py38
-rw-r--r--nova/tests/unit/image/test_glance.py11
-rw-r--r--nova/tests/unit/network/test_api.py29
-rw-r--r--nova/tests/unit/network/test_linux_net.py29
-rw-r--r--nova/tests/unit/network/test_manager.py210
-rw-r--r--nova/tests/unit/network/test_neutronv2.py149
-rw-r--r--nova/tests/unit/objects/test_virtual_interface.py14
8 files changed, 260 insertions, 223 deletions
diff --git a/nova/tests/unit/conductor/tasks/test_live_migrate.py b/nova/tests/unit/conductor/tasks/test_live_migrate.py
index 4d2caa14d1..c1f7cd24e5 100644
--- a/nova/tests/unit/conductor/tasks/test_live_migrate.py
+++ b/nova/tests/unit/conductor/tasks/test_live_migrate.py
@@ -24,6 +24,7 @@ from nova.scheduler import utils as scheduler_utils
from nova import servicegroup
from nova import test
from nova.tests.unit import fake_instance
+from nova.tests import uuidsentinel as uuids
from nova import utils
@@ -32,7 +33,7 @@ class LiveMigrationTaskTestCase(test.NoDBTestCase):
super(LiveMigrationTaskTestCase, self).setUp()
self.context = "context"
self.instance_host = "host"
- self.instance_uuid = "uuid"
+ self.instance_uuid = uuids.instance
self.instance_image = "image_ref"
db_instance = fake_instance.fake_db_instance(
host=self.instance_host,
diff --git a/nova/tests/unit/conductor/test_conductor.py b/nova/tests/unit/conductor/test_conductor.py
index 19feca2fe7..58c68bf647 100644
--- a/nova/tests/unit/conductor/test_conductor.py
+++ b/nova/tests/unit/conductor/test_conductor.py
@@ -46,6 +46,7 @@ from nova.scheduler import client as scheduler_client
from nova.scheduler import utils as scheduler_utils
from nova import test
from nova.tests import fixtures
+from nova.tests.unit.api.openstack import fakes
from nova.tests.unit import cast_as_call
from nova.tests.unit.compute import test_compute
from nova.tests.unit import fake_instance
@@ -53,6 +54,7 @@ from nova.tests.unit import fake_notifier
from nova.tests.unit import fake_request_spec
from nova.tests.unit import fake_server_actions
from nova.tests.unit import fake_utils
+from nova.tests import uuidsentinel as uuids
from nova import utils
@@ -67,8 +69,8 @@ class FakeContext(context.RequestContext):
class _BaseTestCase(object):
def setUp(self):
super(_BaseTestCase, self).setUp()
- self.user_id = 'fake'
- self.project_id = 'fake'
+ self.user_id = fakes.FAKE_USER_ID
+ self.project_id = fakes.FAKE_PROJECT_ID
self.context = FakeContext(self.user_id, self.project_id)
fake_notifier.stub_notifier(self.stubs)
@@ -280,8 +282,8 @@ class ConductorImportTest(test.NoDBTestCase):
class _BaseTaskTestCase(object):
def setUp(self):
super(_BaseTaskTestCase, self).setUp()
- self.user_id = 'fake'
- self.project_id = 'fake'
+ self.user_id = fakes.FAKE_USER_ID
+ self.project_id = fakes.FAKE_PROJECT_ID
self.context = FakeContext(self.user_id, self.project_id)
fake_server_actions.stub_out_action_events(self.stubs)
@@ -1245,7 +1247,7 @@ class ConductorTaskTestCase(_BaseTaskTestCase, test_compute.BaseTestCase):
@mock.patch.object(live_migrate.LiveMigrationTask, 'execute')
def _test_migrate_server_deals_with_expected_exceptions(self, ex,
mock_execute, mock_set):
- instance = fake_instance.fake_db_instance(uuid='uuid',
+ instance = fake_instance.fake_db_instance(uuid=uuids.instance,
vm_state=vm_states.ACTIVE)
inst_obj = objects.Instance._from_db_object(
self.context, objects.Instance(), instance, [])
@@ -1266,7 +1268,7 @@ class ConductorTaskTestCase(_BaseTaskTestCase, test_compute.BaseTestCase):
ex, self._build_request_spec(inst_obj))
def test_migrate_server_deals_with_invalidcpuinfo_exception(self):
- instance = fake_instance.fake_db_instance(uuid='uuid',
+ instance = fake_instance.fake_db_instance(uuid=uuids.instance,
vm_state=vm_states.ACTIVE)
inst_obj = objects.Instance._from_db_object(
self.context, objects.Instance(), instance, [])
@@ -1370,8 +1372,8 @@ class ConductorTaskTestCase(_BaseTaskTestCase, test_compute.BaseTestCase):
instance_type_id=flavor['id'],
vm_state=vm_states.ACTIVE,
system_metadata={},
- uuid='fake',
- user_id='fake')
+ uuid=uuids.instance,
+ user_id=fakes.FAKE_USER_ID)
request_spec = dict(instance_type=dict(extra_specs=dict()),
instance_properties=dict())
filter_props = dict(context=None)
@@ -1421,8 +1423,8 @@ class ConductorTaskTestCase(_BaseTaskTestCase, test_compute.BaseTestCase):
vm_state=vm_states.STOPPED,
instance_type_id=flavor['id'],
system_metadata={},
- uuid='fake',
- user_id='fake')
+ uuid=uuids.instance,
+ user_id=fakes.FAKE_USER_ID)
image = 'fake-image'
request_spec = dict(instance_type=dict(extra_specs=dict()),
instance_properties=dict(),
@@ -1463,8 +1465,8 @@ class ConductorTaskTestCase(_BaseTaskTestCase, test_compute.BaseTestCase):
vm_state=vm_states.STOPPED,
instance_type_id=flavor['id'],
system_metadata={},
- uuid='fake',
- user_id='fake')
+ uuid=uuids.instance,
+ user_id=fakes.FAKE_USER_ID)
request_spec = dict(instance_type=dict(extra_specs=dict()),
instance_properties=dict())
filter_props = dict(context=None)
@@ -1507,8 +1509,8 @@ class ConductorTaskTestCase(_BaseTaskTestCase, test_compute.BaseTestCase):
vm_state=vm_states.STOPPED,
instance_type_id=flavor['id'],
system_metadata={},
- uuid='fake',
- user_id='fake')
+ uuid=uuids.instance,
+ user_id=fakes.FAKE_USER_ID)
request_spec = dict(instance_type=dict(extra_specs=dict()),
instance_properties=dict())
filter_props = dict(context=None)
@@ -1550,8 +1552,8 @@ class ConductorTaskTestCase(_BaseTaskTestCase, test_compute.BaseTestCase):
vm_state=vm_states.STOPPED,
instance_type_id=flavor['id'],
system_metadata={},
- uuid='fake',
- user_id='fake')
+ uuid=uuids.instance,
+ user_id=fakes.FAKE_USER_ID)
image = 'fake-image'
request_spec = dict(instance_type=dict(),
instance_properties=dict(),
@@ -1605,8 +1607,8 @@ class ConductorTaskTestCase(_BaseTaskTestCase, test_compute.BaseTestCase):
vm_state=vm_states.STOPPED,
instance_type_id=flavor['id'],
system_metadata={},
- uuid='fake',
- user_id='fake')
+ uuid=uuids.instance,
+ user_id=fakes.FAKE_USER_ID)
request_spec = dict(instance_type=dict(extra_specs=dict()),
instance_properties=dict())
diff --git a/nova/tests/unit/image/test_glance.py b/nova/tests/unit/image/test_glance.py
index 58d8bb6056..85c794f4c0 100644
--- a/nova/tests/unit/image/test_glance.py
+++ b/nova/tests/unit/image/test_glance.py
@@ -29,6 +29,7 @@ from nova import context
from nova import exception
from nova.image import glance
from nova import test
+from nova.tests import uuidsentinel as uuids
CONF = nova.conf.CONF
NOW_GLANCE_FORMAT = "2010-10-11T10:30:22.000000"
@@ -724,7 +725,7 @@ class TestDownloadSignatureVerification(test.NoDBTestCase):
'properties': {
'img_signature': 'signature',
'img_signature_hash_method': 'SHA-224',
- 'img_signature_certificate_uuid': 'uuid',
+ 'img_signature_certificate_uuid': uuids.img_sig_cert_uuid,
'img_signature_key_type': 'RSA-PSS',
}
}
@@ -745,7 +746,9 @@ class TestDownloadSignatureVerification(test.NoDBTestCase):
res = self.service.download(context=None, image_id=None,
data=None, dst_path=None)
self.assertEqual(self.fake_img_data, res)
- mock_get_verifier.assert_called_once_with(None, 'uuid', 'SHA-224',
+ mock_get_verifier.assert_called_once_with(None,
+ uuids.img_sig_cert_uuid,
+ 'SHA-224',
'signature', 'RSA-PSS')
mock_log.info.assert_called_once_with(mock.ANY, mock.ANY)
@@ -765,7 +768,9 @@ class TestDownloadSignatureVerification(test.NoDBTestCase):
mock_open.return_value = mock_dest
self.service.download(context=None, image_id=None,
data=None, dst_path=fake_path)
- mock_get_verifier.assert_called_once_with(None, 'uuid', 'SHA-224',
+ mock_get_verifier.assert_called_once_with(None,
+ uuids.img_sig_cert_uuid,
+ 'SHA-224',
'signature', 'RSA-PSS')
mock_log.info.assert_called_once_with(mock.ANY, mock.ANY)
self.assertEqual(len(self.fake_img_data), mock_dest.write.call_count)
diff --git a/nova/tests/unit/network/test_api.py b/nova/tests/unit/network/test_api.py
index c6a30be7dc..4877a34aed 100644
--- a/nova/tests/unit/network/test_api.py
+++ b/nova/tests/unit/network/test_api.py
@@ -35,9 +35,11 @@ from nova import objects
from nova.objects import fields
from nova import policy
from nova import test
+from nova.tests.unit.api.openstack import fakes
from nova.tests.unit import fake_instance
from nova.tests.unit.objects import test_fixed_ip
from nova.tests.unit.objects import test_virtual_interface
+from nova.tests import uuidsentinel as uuids
FAKE_UUID = 'a47ae74e-ab08-547f-9eee-ffd23fc46c16'
@@ -46,7 +48,7 @@ fake_info_cache = {
'updated_at': None,
'deleted_at': None,
'deleted': False,
- 'instance_uuid': 'fake-uuid',
+ 'instance_uuid': uuids.instance,
'network_info': '[]',
}
@@ -90,7 +92,7 @@ class ApiTestCase(test.TestCase):
super(ApiTestCase, self).setUp()
self.network_api = network.API()
self.context = context.RequestContext('fake-user',
- 'fake-project')
+ fakes.FAKE_PROJECT_ID)
@mock.patch('nova.objects.NetworkList.get_all')
def test_get_all(self, mock_get_all):
@@ -120,7 +122,7 @@ class ApiTestCase(test.TestCase):
def test_get(self, mock_get):
mock_get.return_value = mock.sentinel.get_by_uuid
self.assertEqual(mock.sentinel.get_by_uuid,
- self.network_api.get(self.context, 'fake-uuid'))
+ self.network_api.get(self.context, uuids.instance))
@mock.patch('nova.objects.Network.get_by_id')
@mock.patch('nova.db.virtual_interface_get_by_instance')
@@ -130,15 +132,15 @@ class ApiTestCase(test.TestCase):
dict(test_virtual_interface.fake_vif,
network_id=123)]
mock_get_by_id.return_value = objects.Network()
- mock_get_by_id.return_value.uuid = mock.sentinel.network_uuid
- instance = objects.Instance(uuid=mock.sentinel.inst_uuid)
+ mock_get_by_id.return_value.uuid = uuids.network_1
+ instance = objects.Instance(uuid=uuids.instance)
vifs = self.network_api.get_vifs_by_instance(self.context,
instance)
self.assertEqual(1, len(vifs))
self.assertEqual(123, vifs[0].network_id)
- self.assertEqual(str(mock.sentinel.network_uuid), vifs[0].net_uuid)
+ self.assertEqual(uuids.network_1, vifs[0].net_uuid)
mock_get_by_instance.assert_called_once_with(
- self.context, str(mock.sentinel.inst_uuid))
+ self.context, uuids.instance)
mock_get_by_id.assert_called_once_with(self.context, 123,
project_only='allow_none')
@@ -149,11 +151,11 @@ class ApiTestCase(test.TestCase):
mock_get_by_address.return_value = dict(
test_virtual_interface.fake_vif, network_id=123)
mock_get_by_id.return_value = objects.Network(
- uuid=mock.sentinel.network_uuid)
+ uuid=uuids.network_1)
vif = self.network_api.get_vif_by_mac_address(self.context,
mock.sentinel.mac)
self.assertEqual(123, vif.network_id)
- self.assertEqual(str(mock.sentinel.network_uuid), vif.net_uuid)
+ self.assertEqual(uuids.network_1, vif.net_uuid)
mock_get_by_address.assert_called_once_with(self.context,
mock.sentinel.mac)
mock_get_by_id.assert_called_once_with(self.context, 123,
@@ -176,7 +178,8 @@ class ApiTestCase(test.TestCase):
self.mox.ReplayAll()
flavor = flavors.get_default_flavor()
flavor['rxtx_factor'] = 0
- instance = objects.Instance(id=1, uuid='uuid', project_id='project_id',
+ instance = objects.Instance(id=1, uuid=uuids.instance,
+ project_id='project_id',
host='host', system_metadata={},
flavor=flavor)
self.network_api.allocate_for_instance(
@@ -240,7 +243,7 @@ class ApiTestCase(test.TestCase):
'10.0.0.2')
def test_associate_preassociated_floating_ip(self):
- self._do_test_associate_floating_ip('orig-uuid')
+ self._do_test_associate_floating_ip(uuids.orig_uuid)
def test_associate_unassociated_floating_ip(self):
self._do_test_associate_floating_ip(None)
@@ -502,8 +505,8 @@ class ApiTestCase(test.TestCase):
@mock.patch('nova.objects.FixedIP.get_by_floating_address')
def test_get_instance_by_floating_address(self, mock_get_by_floating):
mock_get_by_floating.return_value = objects.FixedIP(
- instance_uuid = mock.sentinel.instance_uuid)
- self.assertEqual(str(mock.sentinel.instance_uuid),
+ instance_uuid = uuids.instance)
+ self.assertEqual(uuids.instance,
self.network_api.get_instance_id_by_floating_address(
self.context, mock.sentinel.floating))
mock_get_by_floating.assert_called_once_with(self.context,
diff --git a/nova/tests/unit/network/test_linux_net.py b/nova/tests/unit/network/test_linux_net.py
index 1b90d8f685..423bc64e1f 100644
--- a/nova/tests/unit/network/test_linux_net.py
+++ b/nova/tests/unit/network/test_linux_net.py
@@ -36,29 +36,30 @@ from nova.network import linux_net
from nova.network import model as network_model
from nova import objects
from nova import test
+from nova.tests import uuidsentinel as uuids
from nova import utils
CONF = nova.conf.CONF
HOST = "testhost"
-instances = {'00000000-0000-0000-0000-0000000000000000':
+instances = {uuids.instance_1:
{'id': 0,
- 'uuid': '00000000-0000-0000-0000-0000000000000000',
+ 'uuid': uuids.instance_1,
'host': 'fake_instance00',
'created_at': datetime.datetime(1955, 11, 5, 0, 0, 0),
'updated_at': datetime.datetime(1985, 10, 26, 1, 35, 0),
'hostname': 'fake_instance00'},
- '00000000-0000-0000-0000-0000000000000001':
+ uuids.instance_2:
{'id': 1,
- 'uuid': '00000000-0000-0000-0000-0000000000000001',
+ 'uuid': uuids.instance_2,
'host': 'fake_instance01',
'created_at': datetime.datetime(1955, 11, 5, 0, 0, 0),
'updated_at': datetime.datetime(1985, 10, 26, 1, 35, 0),
'hostname': 'fake_instance01'},
- '00000000-0000-0000-0000-0000000000000002':
+ uuids.instance_3:
{'id': 2,
- 'uuid': '00000000-0000-0000-0000-0000000000000002',
+ 'uuid': uuids.instance_3,
'host': 'fake_instance02',
'created_at': datetime.datetime(1955, 11, 5, 0, 0, 0),
'updated_at': datetime.datetime(1985, 10, 26, 1, 35, 0),
@@ -159,7 +160,7 @@ fixed_ips = [{'id': 0,
'leased': True,
'virtual_interface_id': 0,
'default_route': True,
- 'instance_uuid': '00000000-0000-0000-0000-0000000000000000',
+ 'instance_uuid': uuids.instance_1,
'floating_ips': []},
{'id': 1,
'network_id': 1,
@@ -169,7 +170,7 @@ fixed_ips = [{'id': 0,
'leased': True,
'virtual_interface_id': 1,
'default_route': False,
- 'instance_uuid': '00000000-0000-0000-0000-0000000000000000',
+ 'instance_uuid': uuids.instance_1,
'floating_ips': []},
{'id': 2,
'network_id': 1,
@@ -179,7 +180,7 @@ fixed_ips = [{'id': 0,
'leased': True,
'virtual_interface_id': 2,
'default_route': True,
- 'instance_uuid': '00000000-0000-0000-0000-0000000000000001',
+ 'instance_uuid': uuids.instance_2,
'floating_ips': []},
{'id': 3,
'network_id': 0,
@@ -189,7 +190,7 @@ fixed_ips = [{'id': 0,
'leased': True,
'virtual_interface_id': 3,
'default_route': False,
- 'instance_uuid': '00000000-0000-0000-0000-0000000000000001',
+ 'instance_uuid': uuids.instance_2,
'floating_ips': []},
{'id': 4,
'network_id': 0,
@@ -199,7 +200,7 @@ fixed_ips = [{'id': 0,
'leased': False,
'virtual_interface_id': 4,
'default_route': False,
- 'instance_uuid': '00000000-0000-0000-0000-0000000000000000',
+ 'instance_uuid': uuids.instance_1,
'floating_ips': []},
{'id': 5,
'network_id': 1,
@@ -209,7 +210,7 @@ fixed_ips = [{'id': 0,
'leased': False,
'virtual_interface_id': 5,
'default_route': False,
- 'instance_uuid': '00000000-0000-0000-0000-0000000000000001',
+ 'instance_uuid': uuids.instance_2,
'floating_ips': []},
{'id': 6,
'network_id': 1,
@@ -219,7 +220,7 @@ fixed_ips = [{'id': 0,
'leased': True,
'virtual_interface_id': 6,
'default_route': False,
- 'instance_uuid': '00000000-0000-0000-0000-0000000000000001',
+ 'instance_uuid': uuids.instance_2,
'floating_ips': []},
{'id': 7,
'network_id': 2,
@@ -229,7 +230,7 @@ fixed_ips = [{'id': 0,
'leased': False,
'virtual_interface_id': 7,
'default_route': False,
- 'instance_uuid': '00000000-0000-0000-0000-0000000000000002',
+ 'instance_uuid': uuids.instance_3,
'floating_ips': []}]
diff --git a/nova/tests/unit/network/test_manager.py b/nova/tests/unit/network/test_manager.py
index 90e61a50a0..b98f55409c 100644
--- a/nova/tests/unit/network/test_manager.py
+++ b/nova/tests/unit/network/test_manager.py
@@ -43,6 +43,7 @@ from nova.objects import network as network_obj
from nova.objects import virtual_interface as vif_obj
from nova import quota
from nova import test
+from nova.tests.unit.api.openstack import fakes
from nova.tests.unit import fake_instance
from nova.tests.unit import fake_ldap
from nova.tests.unit import fake_network
@@ -85,7 +86,7 @@ networks = [{'id': 0,
'dns2': '192.168.0.2',
'vlan': None,
'host': HOST,
- 'project_id': 'fake_project',
+ 'project_id': fakes.FAKE_PROJECT_ID,
'vpn_public_address': '192.168.0.2',
'vpn_public_port': '22',
'vpn_private_address': '10.0.0.2'},
@@ -108,7 +109,7 @@ networks = [{'id': 0,
'dns2': '192.168.0.2',
'vlan': None,
'host': HOST,
- 'project_id': 'fake_project',
+ 'project_id': fakes.FAKE_PROJECT_ID,
'vpn_public_address': '192.168.1.2',
'vpn_public_port': '22',
'vpn_private_address': '10.0.0.2'}]
@@ -154,9 +155,9 @@ vifs = [{'id': 0,
'deleted_at': None,
'deleted': 0,
'address': 'DE:AD:BE:EF:00:00',
- 'uuid': '00000000-0000-0000-0000-0000000000000000',
+ 'uuid': uuids.vif1_uuid,
'network_id': 0,
- 'instance_uuid': 0,
+ 'instance_uuid': uuids.instance,
'tag': 'fake-tag1'},
{'id': 1,
'created_at': None,
@@ -166,7 +167,7 @@ vifs = [{'id': 0,
'address': 'DE:AD:BE:EF:00:01',
'uuid': '00000000-0000-0000-0000-0000000000000001',
'network_id': 1,
- 'instance_uuid': 0,
+ 'instance_uuid': uuids.instance,
'tag': 'fake-tag2'},
{'id': 2,
'created_at': None,
@@ -176,7 +177,7 @@ vifs = [{'id': 0,
'address': 'DE:AD:BE:EF:00:02',
'uuid': '00000000-0000-0000-0000-0000000000000002',
'network_id': 2,
- 'instance_uuid': 0,
+ 'instance_uuid': uuids.instance,
'tag': 'fake-tag3'}]
@@ -191,7 +192,8 @@ class FlatNetworkTestCase(test.TestCase):
self.network = network_manager.FlatManager(host=HOST)
self.network.instance_dns_domain = ''
self.network.db = db
- self.context = context.RequestContext('testuser', 'testproject',
+ self.context = context.RequestContext('testuser',
+ fakes.FAKE_PROJECT_ID,
is_admin=False)
@testtools.skipIf(test_utils.is_osx(),
@@ -326,8 +328,9 @@ class FlatNetworkTestCase(test.TestCase):
self.network.validate_networks(self.context, requested_networks)
def test_validate_reserved(self):
- context_admin = context.RequestContext('testuser', 'testproject',
- is_admin=True)
+ context_admin = context.RequestContext('testuser',
+ fakes.FAKE_PROJECT_ID,
+ is_admin=True)
nets = self.network.create_networks(context_admin, 'fake',
'192.168.0.0/24', False, 1,
256, None, None, None, None, None)
@@ -337,8 +340,9 @@ class FlatNetworkTestCase(test.TestCase):
network['id']))
def test_validate_reserved_start_end(self):
- context_admin = context.RequestContext('testuser', 'testproject',
- is_admin=True)
+ context_admin = context.RequestContext('testuser',
+ fakes.FAKE_PROJECT_ID,
+ is_admin=True)
nets = self.network.create_networks(context_admin, 'fake',
'192.168.0.0/24', False, 1,
256, dhcp_server='192.168.0.11',
@@ -359,32 +363,36 @@ class FlatNetworkTestCase(test.TestCase):
network['id']))
def test_validate_reserved_start_out_of_range(self):
- context_admin = context.RequestContext('testuser', 'testproject',
- is_admin=True)
+ context_admin = context.RequestContext('testuser',
+ fakes.FAKE_PROJECT_ID,
+ is_admin=True)
self.assertRaises(exception.AddressOutOfRange,
self.network.create_networks,
context_admin, 'fake', '192.168.0.0/24', False,
1, 256, allowed_start='192.168.1.10')
def test_validate_reserved_end_invalid(self):
- context_admin = context.RequestContext('testuser', 'testproject',
- is_admin=True)
+ context_admin = context.RequestContext('testuser',
+ fakes.FAKE_PROJECT_ID,
+ is_admin=True)
self.assertRaises(exception.InvalidAddress,
self.network.create_networks,
context_admin, 'fake', '192.168.0.0/24', False,
1, 256, allowed_end='invalid')
def test_validate_cidr_invalid(self):
- context_admin = context.RequestContext('testuser', 'testproject',
- is_admin=True)
+ context_admin = context.RequestContext('testuser',
+ fakes.FAKE_PROJECT_ID,
+ is_admin=True)
self.assertRaises(exception.InvalidCidr,
self.network.create_networks,
context_admin, 'fake', 'invalid', False,
1, 256)
def test_validate_non_int_size(self):
- context_admin = context.RequestContext('testuser', 'testproject',
- is_admin=True)
+ context_admin = context.RequestContext('testuser',
+ fakes.FAKE_PROJECT_ID,
+ is_admin=True)
self.assertRaises(exception.InvalidIntValue,
self.network.create_networks,
context_admin, 'fake', '192.168.0.0/24', False,
@@ -434,11 +442,11 @@ class FlatNetworkTestCase(test.TestCase):
def test_get_instance_nw_info(self, get):
def make_ip(index):
- vif = objects.VirtualInterface(uuid=index, address=index)
- network = objects.Network(uuid=index,
+ vif = objects.VirtualInterface(uuid=uuids.vif1_uuid, address=index)
+ network = objects.Network(uuid=uuids.network_1,
bridge=index,
label=index,
- project_id=index,
+ project_id=fakes.FAKE_PROJECT_ID,
injected=False,
netmask='255.255.255.0',
dns1=None,
@@ -639,7 +647,7 @@ class FlatNetworkTestCase(test.TestCase):
def test_allocate_calculates_quota_auth(self, util_method, reserve,
get_by_uuid):
inst = objects.Instance()
- inst['uuid'] = 'nosuch'
+ inst['uuid'] = uuids.instance
get_by_uuid.return_value = inst
usages = {'fixed_ips': {'in_use': 10, 'reserved': 1}}
reserve.side_effect = exception.OverQuota(overs='testing',
@@ -648,7 +656,7 @@ class FlatNetworkTestCase(test.TestCase):
util_method.return_value = ('foo', 'bar')
self.assertRaises(exception.FixedIpLimitExceeded,
self.network.allocate_fixed_ip,
- self.context, 123, {'uuid': 'nosuch'})
+ self.context, 123, {'uuid': uuids.instance})
util_method.assert_called_once_with(self.context, inst)
@mock.patch('nova.objects.fixed_ip.FixedIP.get_by_address')
@@ -656,8 +664,8 @@ class FlatNetworkTestCase(test.TestCase):
@mock.patch('nova.objects.quotas.ids_from_instance')
def test_deallocate_calculates_quota_auth(self, util_method, reserve,
get_by_address):
- inst = objects.Instance(uuid='fake-uuid')
- fip = objects.FixedIP(instance_uuid='fake-uuid',
+ inst = objects.Instance(uuid=uuids.instance)
+ fip = objects.FixedIP(instance_uuid=uuids.instance,
virtual_interface_id=1)
get_by_address.return_value = fip
util_method.return_value = ('foo', 'bar')
@@ -679,7 +687,7 @@ class FlatNetworkTestCase(test.TestCase):
self.assertRaises(test.TestingException,
self.network.allocate_fixed_ip,
self.context, instance.uuid,
- {'cidr': '24', 'id': 1, 'uuid': 'nosuch'},
+ {'cidr': '24', 'id': 1, 'uuid': uuids.instance},
address=netaddr.IPAddress('1.2.3.4'))
mock_associate.assert_called_once_with(self.context,
'1.2.3.4',
@@ -701,7 +709,7 @@ class FlatNetworkTestCase(test.TestCase):
mock_instance_get):
address = netaddr.IPAddress('1.2.3.4')
- fip = objects.FixedIP(instance_uuid='fake-uuid',
+ fip = objects.FixedIP(instance_uuid=uuids.instance,
address=address,
virtual_interface_id=1)
mock_fixedip_associate.return_value = fip
@@ -711,7 +719,7 @@ class FlatNetworkTestCase(test.TestCase):
mock_instance_get.return_value = instance
mock_vif_get.return_value = vif_obj.VirtualInterface(
- instance_uuid='fake-uuid', id=1)
+ instance_uuid=uuids.instance, id=1)
with test.nested(
mock.patch.object(self.network, '_setup_network_on_host'),
@@ -723,7 +731,8 @@ class FlatNetworkTestCase(test.TestCase):
self.assertRaises(test.TestingException,
self.network.allocate_fixed_ip,
self.context, instance.uuid,
- {'cidr': '24', 'id': 1, 'uuid': 'nosuch'},
+ {'cidr': '24', 'id': 1,
+ 'uuid': uuids.instance},
address=address)
mock_dns_manager.delete_entry.assert_has_calls([
@@ -747,10 +756,10 @@ class FlatNetworkTestCase(test.TestCase):
mock_instance_get):
address = netaddr.IPAddress('1.2.3.4')
- fip = objects.FixedIP(instance_uuid='fake-uuid',
+ fip = objects.FixedIP(instance_uuid=uuids.instance,
address=address,
virtual_interface_id=1000)
- net = {'cidr': '24', 'id': 1, 'uuid': 'nosuch'}
+ net = {'cidr': '24', 'id': 1, 'uuid': uuids.instance}
instance = objects.Instance(context=self.context)
instance.create()
@@ -759,7 +768,7 @@ class FlatNetworkTestCase(test.TestCase):
address='00:00:00:00:00:00',
instance_uuid=instance.uuid,
network_id=net['id'],
- uuid='nosuch')
+ uuid=uuids.instance)
mock_fixedip_associate.return_value = fip
mock_add.return_value = vif
mock_instance_get.return_value = instance
@@ -811,10 +820,12 @@ class FlatDHCPNetworkTestCase(test.TestCase):
self.flags(use_local=True, group='conductor')
self.network = network_manager.FlatDHCPManager(host=HOST)
self.network.db = db
- self.context = context.RequestContext('testuser', 'testproject',
+ self.context = context.RequestContext('testuser',
+ fakes.FAKE_PROJECT_ID,
is_admin=False)
- self.context_admin = context.RequestContext('testuser', 'testproject',
- is_admin=True)
+ self.context_admin = context.RequestContext('testuser',
+ fakes.FAKE_PROJECT_ID,
+ is_admin=True)
@mock.patch('nova.objects.fixed_ip.FixedIP.get_by_id')
@mock.patch('nova.objects.floating_ip.FloatingIPList.get_by_host')
@@ -836,7 +847,8 @@ class FlatDHCPNetworkTestCase(test.TestCase):
fake_apply.count += 1
fake_apply.count = 0
- ctxt = context.RequestContext('testuser', 'testproject', is_admin=True)
+ ctxt = context.RequestContext('testuser', fakes.FAKE_PROJECT_ID,
+ is_admin=True)
float1 = objects.FloatingIP(address='1.2.3.4', fixed_ip_id=1)
float2 = objects.FloatingIP(address='1.2.3.5', fixed_ip_id=2)
float1._context = ctxt
@@ -859,10 +871,12 @@ class VlanNetworkTestCase(test.TestCase):
self.useFixture(test.SampleNetworks())
self.network = network_manager.VlanManager(host=HOST)
self.network.db = db
- self.context = context.RequestContext('testuser', 'testproject',
+ self.context = context.RequestContext('testuser',
+ fakes.FAKE_PROJECT_ID,
is_admin=False)
- self.context_admin = context.RequestContext('testuser', 'testproject',
- is_admin=True)
+ self.context_admin = context.RequestContext('testuser',
+ fakes.FAKE_PROJECT_ID,
+ is_admin=True)
def test_quota_driver_type(self):
self.assertEqual(objects.QuotasNoOp,
@@ -946,8 +960,8 @@ class VlanNetworkTestCase(test.TestCase):
def test_allocate_fixed_ip_return_none(self, mock_get,
mock_associate, mock_get_uuid, mock_add, mock_trigger,
mock_validate, mock_setup):
- net = {'cidr': '24', 'id': 1, 'uuid': 'nosuch'}
- fip = objects.FixedIP(instance_uuid='fake-uuid',
+ net = {'cidr': '24', 'id': 1, 'uuid': uuids.instance}
+ fip = objects.FixedIP(instance_uuid=uuids.instance,
address=netaddr.IPAddress('1.2.3.4'),
virtual_interface_id=1)
@@ -959,7 +973,7 @@ class VlanNetworkTestCase(test.TestCase):
address='00:00:00:00:00:00',
instance_uuid=instance.uuid,
network_id=net['id'],
- uuid='nosuch')
+ uuid=uuids.instance)
mock_associate.return_value = fip
mock_add.return_value = vif
mock_get.return_value = None
@@ -982,7 +996,7 @@ class VlanNetworkTestCase(test.TestCase):
self.assertRaises(test.TestingException,
self.network.allocate_fixed_ip,
self.context, instance.uuid,
- {'cidr': '24', 'id': 1, 'uuid': 'nosuch'},
+ {'cidr': '24', 'id': 1, 'uuid': uuids.instance},
address=netaddr.IPAddress('1.2.3.4'))
mock_associate.assert_called_once_with(self.context,
'1.2.3.4',
@@ -1001,7 +1015,7 @@ class VlanNetworkTestCase(test.TestCase):
self.assertRaises(test.TestingException,
self.network.allocate_fixed_ip,
self.context, instance.uuid,
- {'cidr': '24', 'id': 1, 'uuid': 'nosuch',
+ {'cidr': '24', 'id': 1, 'uuid': uuids.instance,
'vpn_private_address': netaddr.IPAddress('1.2.3.4')
}, vpn=1)
mock_associate.assert_called_once_with(self.context,
@@ -1185,7 +1199,7 @@ class VlanNetworkTestCase(test.TestCase):
self.network.validate_networks(self.context, requested_networks)
def test_floating_ip_owned_by_project(self):
- ctxt = context.RequestContext('testuser', 'testproject',
+ ctxt = context.RequestContext('testuser', fakes.FAKE_PROJECT_ID,
is_admin=False)
# raises because floating_ip project_id is None
@@ -1198,7 +1212,7 @@ class VlanNetworkTestCase(test.TestCase):
# raises because floating_ip project_id is not equal to ctxt project_id
floating_ip = objects.FloatingIP(address='10.0.0.1',
- project_id=ctxt.project_id + '1')
+ project_id=uuids.non_existent_uuid)
self.assertRaises(exception.Forbidden,
self.network._floating_ip_owned_by_project,
ctxt,
@@ -1219,11 +1233,11 @@ class VlanNetworkTestCase(test.TestCase):
# does not raise (ctxt is admin)
floating_ip = objects.FloatingIP(address='10.0.0.1',
- project_id='testproject')
+ project_id=fakes.FAKE_PROJECT_ID)
self.network._floating_ip_owned_by_project(ctxt, floating_ip)
def test_allocate_floating_ip(self):
- ctxt = context.RequestContext('testuser', 'testproject',
+ ctxt = context.RequestContext('testuser', fakes.FAKE_PROJECT_ID,
is_admin=False)
self.stubs.Set(self.network, '_floating_ip_pool_exists',
@@ -1240,7 +1254,7 @@ class VlanNetworkTestCase(test.TestCase):
@mock.patch('nova.quota.QUOTAS.reserve')
@mock.patch('nova.quota.QUOTAS.commit')
def test_deallocate_floating_ip(self, mock_commit, mock_reserve):
- ctxt = context.RequestContext('testuser', 'testproject',
+ ctxt = context.RequestContext('testuser', fakes.FAKE_PROJECT_ID,
is_admin=False)
def fake1(*args, **kwargs):
@@ -1271,11 +1285,11 @@ class VlanNetworkTestCase(test.TestCase):
self.network.deallocate_floating_ip(ctxt, ctxt.project_id)
mock_commit.assert_called_once_with(ctxt, 'reserve',
- project_id='testproject')
+ project_id=fakes.FAKE_PROJECT_ID)
@mock.patch('nova.db.fixed_ip_get')
def test_associate_floating_ip(self, fixed_get):
- ctxt = context.RequestContext('testuser', 'testproject',
+ ctxt = context.RequestContext('testuser', fakes.FAKE_PROJECT_ID,
is_admin=False)
def fake1(*args, **kwargs):
@@ -1360,7 +1374,7 @@ class VlanNetworkTestCase(test.TestCase):
fixed_get.return_value = dict(test_fixed_ip.fake_fixed_ip,
address='1.2.3.4',
- instance_uuid='fake_uuid',
+ instance_uuid=uuids.instance,
network=test_network.fake_network)
# doesn't raise because we exit early if the address is the same
@@ -1478,7 +1492,7 @@ class VlanNetworkTestCase(test.TestCase):
expected_arg='fooiface')
def test_disassociate_floating_ip(self):
- ctxt = context.RequestContext('testuser', 'testproject',
+ ctxt = context.RequestContext('testuser', fakes.FAKE_PROJECT_ID,
is_admin=False)
def fake1(*args, **kwargs):
@@ -1628,7 +1642,7 @@ class VlanNetworkTestCase(test.TestCase):
net_get.return_value = dict(test_network.fake_network,
**networks[1])
- context1 = context.RequestContext('user', 'project1')
+ context1 = context.RequestContext('user', fakes.FAKE_PROJECT_ID)
context2 = context.RequestContext('user', 'project2')
float_ip = db.floating_ip_create(context1.elevated(),
@@ -1638,7 +1652,7 @@ class VlanNetworkTestCase(test.TestCase):
float_addr = float_ip['address']
instance = db.instance_create(context1,
- {'project_id': 'project1'})
+ {'project_id': fakes.FAKE_PROJECT_ID})
fix_addr = db.fixed_ip_associate_pool(context1.elevated(),
1, instance['uuid']).address
@@ -1692,10 +1706,10 @@ class VlanNetworkTestCase(test.TestCase):
return vifs[0]
self.stub_out('nova.db.virtual_interface_get', vif_get)
- context1 = context.RequestContext('user', 'project1')
+ context1 = context.RequestContext('user', fakes.FAKE_PROJECT_ID)
instance = db.instance_create(context1,
- {'project_id': 'project1'})
+ {'project_id': fakes.FAKE_PROJECT_ID})
elevated = context1.elevated()
fix_addr = db.fixed_ip_associate_pool(elevated, 1, instance['uuid'])
@@ -1733,10 +1747,10 @@ class VlanNetworkTestCase(test.TestCase):
utils, 'execute',
side_effect=processutils.ProcessExecutionError()),
) as (_vif_get, _execute):
- context1 = context.RequestContext('user', 'project1')
+ context1 = context.RequestContext('user', fakes.FAKE_PROJECT_ID)
instance = db.instance_create(context1,
- {'project_id': 'project1'})
+ {'project_id': fakes.FAKE_PROJECT_ID})
elevated = context1.elevated()
fix_addr = db.fixed_ip_associate_pool(elevated, 1,
@@ -1780,11 +1794,11 @@ class VlanNetworkTestCase(test.TestCase):
self.stubs.Set(self.network, '_teardown_network_on_host',
teardown_network_on_host)
- context1 = context.RequestContext('user', 'project1')
+ context1 = context.RequestContext('user', fakes.FAKE_PROJECT_ID)
elevated = context1.elevated()
instance = db.instance_create(context1,
- {'project_id': 'project1'})
+ {'project_id': fakes.FAKE_PROJECT_ID})
network = db.network_create_safe(elevated, networks[0])
_fix_addr = db.fixed_ip_associate_pool(elevated, 1, instance['uuid'])
@@ -1818,10 +1832,10 @@ class VlanNetworkTestCase(test.TestCase):
return None
self.stub_out('nova.db.virtual_interface_get', vif_get)
- context1 = context.RequestContext('user', 'project1')
+ context1 = context.RequestContext('user', fakes.FAKE_PROJECT_ID)
instance = db.instance_create(context1,
- {'project_id': 'project1'})
+ {'project_id': fakes.FAKE_PROJECT_ID})
elevated = context1.elevated()
fix_addr = db.fixed_ip_associate_pool(elevated, 1, instance['uuid'])
@@ -1845,10 +1859,10 @@ class VlanNetworkTestCase(test.TestCase):
# Verify IP is not deallocated if the security group refresh fails.
net_get.return_value = dict(test_network.fake_network,
**networks[1])
- context1 = context.RequestContext('user', 'project1')
+ context1 = context.RequestContext('user', fakes.FAKE_PROJECT_ID)
instance = db.instance_create(context1,
- {'project_id': 'project1'})
+ {'project_id': fakes.FAKE_PROJECT_ID})
elevated = context1.elevated()
fix_addr = objects.FixedIP.associate_pool(elevated, 1,
@@ -1908,7 +1922,9 @@ class VlanNetworkTestCase(test.TestCase):
fake_apply.count += 1
fake_apply.count = 0
- ctxt = context.RequestContext('testuser', 'testproject', is_admin=True)
+ ctxt = context.RequestContext('testuser',
+ fakes.FAKE_PROJECT_ID,
+ is_admin=True)
float1 = objects.FloatingIP(address='1.2.3.4', fixed_ip_id=1)
float2 = objects.FloatingIP(address='1.2.3.5', fixed_ip_id=2)
float1._context = ctxt
@@ -1981,7 +1997,7 @@ class CommonNetworkTestCase(test.TestCase):
instance_get):
manager = fake_network.FakeNetworkManager()
db = manager.db
- instance_get.return_value = fake_inst(uuid='ignoreduuid')
+ instance_get.return_value = fake_inst(uuid=uuids.non_existent_uuid)
db.virtual_interface_delete_by_instance = lambda _x, _y: None
ctx = context.RequestContext('igonre', 'igonre')
@@ -2527,7 +2543,7 @@ class CommonNetworkTestCase(test.TestCase):
# Add an additional network and ensure the rules get configured
new_network = {'id': 2,
- 'uuid': 'cccccccc-cccc-cccc-cccc-cccccccc',
+ 'uuid': uuids.network_1,
'label': 'test2',
'injected': False,
'multi_host': False,
@@ -2545,7 +2561,7 @@ class CommonNetworkTestCase(test.TestCase):
'dns2': '192.168.2.2',
'vlan': None,
'host': HOST,
- 'project_id': 'fake_project',
+ 'project_id': fakes.FAKE_PROJECT_ID,
'vpn_public_address': '192.168.2.2',
'vpn_public_port': '22',
'vpn_private_address': '10.0.0.2'}
@@ -2618,7 +2634,7 @@ class CommonNetworkTestCase(test.TestCase):
self.assertRaises(test.TestingException,
manager.deallocate_fixed_ip,
self.context, 'fake', 'fake',
- instance=fake_inst(uuid='ignoreduuid'))
+ instance=fake_inst(uuid=uuids.non_existent_uuid))
rollback.assert_called_once_with()
def test_fixed_cidr_out_of_range(self):
@@ -2679,13 +2695,13 @@ class AllocateTestCase(test.TestCase):
self.useFixture(test.SampleNetworks())
self.network = network_manager.VlanManager(host=HOST)
- self.user_id = 'fake'
- self.project_id = 'fake'
+ self.user_id = fakes.FAKE_USER_ID
+ self.project_id = fakes.FAKE_PROJECT_ID
self.context = context.RequestContext(self.user_id,
self.project_id,
is_admin=True)
self.user_context = context.RequestContext('testuser',
- 'testproject')
+ fakes.FAKE_PROJECT_ID)
def test_allocate_for_instance(self):
address = "10.10.10.10"
@@ -2792,7 +2808,7 @@ class FloatingIPTestCase(test.TestCase):
self.flags(log_dir=self.tempdir)
self.network = TestFloatingIPManager()
self.network.db = db
- self.project_id = 'testproject'
+ self.project_id = fakes.FAKE_PROJECT_ID
self.context = context.RequestContext('testuser', self.project_id,
is_admin=False)
@@ -2810,14 +2826,14 @@ class FloatingIPTestCase(test.TestCase):
fixed_ip = dict(test_fixed_ip.fake_fixed_ip,
network_id=None,
- instance_uuid='instance-uuid')
+ instance_uuid=uuids.instance)
network = dict(test_network.fake_network,
multi_host=True)
instance = dict(fake_instance.fake_db_instance(host='some-other-host'))
- ctxt = context.RequestContext('testuser', 'testproject',
+ ctxt = context.RequestContext('testuser', fakes.FAKE_PROJECT_ID,
is_admin=False)
self.stubs.Set(self.network,
@@ -2838,7 +2854,8 @@ class FloatingIPTestCase(test.TestCase):
self.network.network_rpcapi, '_disassociate_floating_ip')
self.network.network_rpcapi._disassociate_floating_ip(
- ctxt, 'fl_ip', mox.IgnoreArg(), 'some-other-host', 'instance-uuid')
+ ctxt, 'fl_ip', mox.IgnoreArg(), 'some-other-host',
+ uuids.instance)
self.mox.ReplayAll()
self.network.disassociate_floating_ip(ctxt, 'fl_ip', True)
@@ -2855,14 +2872,14 @@ class FloatingIPTestCase(test.TestCase):
fixed_ip = dict(test_fixed_ip.fake_fixed_ip,
network_id=None,
- instance_uuid='instance-uuid')
+ instance_uuid=uuids.instance)
network = dict(test_network.fake_network,
multi_host=True)
instance = dict(fake_instance.fake_db_instance(host='some-other-host'))
- ctxt = context.RequestContext('testuser', 'testproject',
+ ctxt = context.RequestContext('testuser', fakes.FAKE_PROJECT_ID,
is_admin=False)
self.stubs.Set(self.network,
@@ -2879,7 +2896,7 @@ class FloatingIPTestCase(test.TestCase):
self.network.network_rpcapi._associate_floating_ip(
ctxt, 'fl_ip', 'fix_ip', mox.IgnoreArg(), 'some-other-host',
- 'instance-uuid')
+ uuids.instance)
self.mox.ReplayAll()
self.network.associate_floating_ip(ctxt, 'fl_ip', 'fix_ip', True)
@@ -2896,7 +2913,7 @@ class FloatingIPTestCase(test.TestCase):
instance_id=instance_ref['id'])
def test_deallocate_floating_ip_quota_rollback(self):
- ctxt = context.RequestContext('testuser', 'testproject',
+ ctxt = context.RequestContext('testuser', fakes.FAKE_PROJECT_ID,
is_admin=False)
def fake(*args, **kwargs):
@@ -2912,13 +2929,14 @@ class FloatingIPTestCase(test.TestCase):
self.mox.StubOutWithMock(quota.QUOTAS, 'rollback')
quota.QUOTAS.reserve(self.context,
floating_ips=-1,
- project_id='testproject').AndReturn('fake-rsv')
+ project_id=fakes.FAKE_PROJECT_ID
+ ).AndReturn('fake-rsv')
self.network._floating_ip_owned_by_project(self.context,
mox.IgnoreArg())
db.floating_ip_deallocate(mox.IgnoreArg(),
mox.IgnoreArg()).AndReturn(None)
quota.QUOTAS.rollback(self.context, 'fake-rsv',
- project_id='testproject')
+ project_id=fakes.FAKE_PROJECT_ID)
self.mox.ReplayAll()
self.network.deallocate_floating_ip(self.context, '10.0.0.1')
@@ -2982,7 +3000,7 @@ class FloatingIPTestCase(test.TestCase):
floating_get.side_effect = fake_floating_ip_get_by_address
fixed_get.return_value = dict(test_fixed_ip.fake_fixed_ip,
- instance_uuid='fake_uuid',
+ instance_uuid=uuids.instance,
address='10.0.0.2',
network=test_network.fake_network)
floating_update.return_value = fake_floating_ip_get_by_address(
@@ -3028,7 +3046,7 @@ class FloatingIPTestCase(test.TestCase):
return str(floating_ip.address) == '172.24.4.23'
fixed_get.return_value = dict(test_fixed_ip.fake_fixed_ip,
- instance_uuid='fake_uuid',
+ instance_uuid=uuids.instance,
address='10.0.0.2',
network=test_network.fake_network)
floating_update.return_value = fake_floating_ip_get_by_address(
@@ -3115,7 +3133,7 @@ class FloatingIPTestCase(test.TestCase):
entryname = 'testentry'
self.network.create_public_dns_domain(self.context, domain1,
- 'testproject')
+ fakes.FAKE_PROJECT_ID)
self.network.create_public_dns_domain(self.context, domain2,
'fakeproject')
@@ -3123,7 +3141,7 @@ class FloatingIPTestCase(test.TestCase):
self.assertEqual(2, len(domains))
self.assertEqual(domain1, domains[0]['domain'])
self.assertEqual(domain2, domains[1]['domain'])
- self.assertEqual('testproject', domains[0]['project'])
+ self.assertEqual(fakes.FAKE_PROJECT_ID, domains[0]['project'])
self.assertEqual('fakeproject', domains[1]['project'])
self.network.add_dns_entry(self.context, address1, entryname,
@@ -3155,11 +3173,12 @@ class FloatingIPTestCase(test.TestCase):
self.stubs.Set(self.network, 'get_dns_domains', fake_domains)
- context_admin = context.RequestContext('testuser', 'testproject',
- is_admin=True)
+ context_admin = context.RequestContext('testuser',
+ fakes.FAKE_PROJECT_ID,
+ is_admin=True)
self.network.create_public_dns_domain(context_admin, domain1,
- 'testproject')
+ fakes.FAKE_PROJECT_ID)
self.network.create_public_dns_domain(context_admin, domain2,
'fakeproject')
@@ -3188,13 +3207,14 @@ class FloatingIPTestCase(test.TestCase):
def test_mac_conflicts(self):
# Make sure MAC collisions are retried.
self.flags(create_unique_mac_address_attempts=3)
- ctxt = context.RequestContext('testuser', 'testproject', is_admin=True)
+ ctxt = context.RequestContext('testuser', fakes.FAKE_PROJECT_ID,
+ is_admin=True)
macs = ['bb:bb:bb:bb:bb:bb', 'aa:aa:aa:aa:aa:aa']
# Create a VIF with aa:aa:aa:aa:aa:aa
crash_test_dummy_vif = {
'address': macs[1],
- 'instance_uuid': 'fake_uuid',
+ 'instance_uuid': uuids.instance,
'network_id': 123,
'uuid': 'fake_uuid',
}
@@ -3218,7 +3238,7 @@ class FloatingIPTestCase(test.TestCase):
# Attempt to add another and make sure that both MACs are consumed
# by the retry loop
- self.network._add_virtual_interface(ctxt, 'fake_uuid', 123)
+ self.network._add_virtual_interface(ctxt, uuids.instance, 123)
self.assertEqual([], macs)
def test_deallocate_client_exceptions(self):
@@ -3338,7 +3358,7 @@ class InstanceDNSTestCase(test.TestCase):
self.flags(log_dir=self.tempdir)
self.network = TestFloatingIPManager()
self.network.db = db
- self.project_id = 'testproject'
+ self.project_id = fakes.FAKE_PROJECT_ID
self.context = context.RequestContext('testuser', self.project_id,
is_admin=False)
diff --git a/nova/tests/unit/network/test_neutronv2.py b/nova/tests/unit/network/test_neutronv2.py
index d7d4648e72..5a53f82e32 100644
--- a/nova/tests/unit/network/test_neutronv2.py
+++ b/nova/tests/unit/network/test_neutronv2.py
@@ -46,6 +46,7 @@ from nova.pci import whitelist as pci_whitelist
from nova import policy
from nova import test
from nova.tests.unit import fake_instance
+from nova.tests import uuidsentinel as uuids
CONF = cfg.CONF
@@ -60,7 +61,7 @@ fake_info_cache = {
'updated_at': None,
'deleted_at': None,
'deleted': False,
- 'instance_uuid': 'fake-uuid',
+ 'instance_uuid': uuids.instance,
'network_info': '[]',
}
@@ -261,14 +262,14 @@ class TestNeutronv2Base(test.TestCase):
'device_id': self.instance2['uuid'],
'tenant_id': self.tenant_id,
'device_owner': 'compute:nova',
- 'id': 'my_portid1',
+ 'id': uuids.portid_1,
'binding:vnic_type': model.VNIC_TYPE_NORMAL,
'status': 'DOWN',
'admin_state_up': True,
'fixed_ips': [{'ip_address': self.port_address,
'subnet_id': 'my_subid1'}],
'mac_address': 'my_mac1', }]
- self.float_data1 = [{'port_id': 'my_portid1',
+ self.float_data1 = [{'port_id': uuids.portid_1,
'fixed_ip_address': self.port_address,
'floating_ip_address': '172.0.1.2'}]
self.dhcp_port_data1 = [{'fixed_ips': [{'ip_address': '10.0.1.9',
@@ -284,7 +285,7 @@ class TestNeutronv2Base(test.TestCase):
'admin_state_up': True,
'status': 'ACTIVE',
'device_owner': 'compute:nova',
- 'id': 'my_portid2',
+ 'id': uuids.portid_2,
'binding:vnic_type': model.VNIC_TYPE_NORMAL,
'fixed_ips':
[{'ip_address': self.port_address2,
@@ -292,7 +293,7 @@ class TestNeutronv2Base(test.TestCase):
'mac_address': 'my_mac2', })
self.float_data2 = []
self.float_data2.append(self.float_data1[0])
- self.float_data2.append({'port_id': 'my_portid2',
+ self.float_data2.append({'port_id': uuids.portid_2,
'fixed_ip_address': '10.0.2.2',
'floating_ip_address': '172.0.2.2'})
self.port_data3 = [{'network_id': 'my_netid1',
@@ -301,7 +302,7 @@ class TestNeutronv2Base(test.TestCase):
'status': 'DOWN',
'admin_state_up': True,
'device_owner': 'compute:nova',
- 'id': 'my_portid3',
+ 'id': uuids.portid_3,
'binding:vnic_type': model.VNIC_TYPE_NORMAL,
'fixed_ips': [], # no fixed ip
'mac_address': 'my_mac3', }]
@@ -435,10 +436,10 @@ class TestNeutronv2Base(test.TestCase):
if 'requested_networks' in kwargs:
for request in kwargs['requested_networks']:
if request.port_id:
- if request.port_id == 'my_portid3':
+ if request.port_id == uuids.portid_3:
self.moxed_client.show_port(request.port_id
).AndReturn(
- {'port': {'id': 'my_portid3',
+ {'port': {'id': uuids.portid_3,
'network_id': 'my_netid1',
'tenant_id': self.tenant_id,
'mac_address': 'my_mac1',
@@ -451,14 +452,14 @@ class TestNeutronv2Base(test.TestCase):
request.network_id = 'my_netid1'
if macs is not None:
macs.discard('my_mac1')
- elif request.port_id == 'invalid_id':
+ elif request.port_id == uuids.non_existent_uuid:
PortNotFound = exceptions.PortNotFoundClient(
status_code=404)
self.moxed_client.show_port(request.port_id
).AndRaise(PortNotFound)
else:
self.moxed_client.show_port(request.port_id).AndReturn(
- {'port': {'id': 'my_portid1',
+ {'port': {'id': uuids.portid_1,
'network_id': 'my_netid1',
'tenant_id': self.tenant_id,
'mac_address': 'my_mac1',
@@ -618,7 +619,8 @@ class TestNeutronv2Base(test.TestCase):
nw_inf.fixed_ips()[index].floating_ip_addresses()[0])
self.assertEqual('my_netname%s' % id_suffix,
nw_inf[index]['network']['label'])
- self.assertEqual('my_portid%s' % id_suffix, nw_inf[index]['id'])
+ self.assertEqual(getattr(uuids, 'portid_%s' % id_suffix),
+ nw_inf[index]['id'])
self.assertEqual('my_mac%s' % id_suffix, nw_inf[index]['address'])
self.assertEqual('10.0.%s.0/24' % id_suffix,
nw_inf[index]['network']['subnets'][0]['cidr'])
@@ -941,7 +943,7 @@ class TestNeutronv2(TestNeutronv2Base):
id_suffix = 3
self.assertEqual(0, len(nw_inf.fixed_ips()))
self.assertEqual('my_netname1', nw_inf[0]['network']['label'])
- self.assertEqual('my_portid%s' % id_suffix, nw_inf[0]['id'])
+ self.assertEqual(uuids.portid_3, nw_inf[0]['id'])
self.assertEqual('my_mac%s' % id_suffix, nw_inf[0]['address'])
self.assertEqual(0, len(nw_inf[0]['network']['subnets']))
@@ -1005,7 +1007,7 @@ class TestNeutronv2(TestNeutronv2Base):
self._returned_nw_info = self.port_data1
result = self._allocate_for_instance(
requested_networks=objects.NetworkRequestList(
- objects=[objects.NetworkRequest(port_id='my_portid1')]))
+ objects=[objects.NetworkRequest(port_id=uuids.portid_1)]))
self.assertEqual(self.port_data1, result)
@mock.patch('nova.network.neutronv2.api.API._unbind_ports')
@@ -1018,7 +1020,7 @@ class TestNeutronv2(TestNeutronv2Base):
requested_networks = objects.NetworkRequestList(
objects = [
objects.NetworkRequest(network_id=self.nets2[1]['id']),
- objects.NetworkRequest(port_id='my_portid1')])
+ objects.NetworkRequest(port_id=uuids.portid_1)])
api = self._stub_allocate_for_instance(
net_idx=2, requested_networks=requested_networks,
macs=set(['my_mac1']),
@@ -1066,7 +1068,7 @@ class TestNeutronv2(TestNeutronv2Base):
def test_allocate_for_instance_mac_conflicting_requested_port(self):
# specify only first and last network
requested_networks = objects.NetworkRequestList(
- objects=[objects.NetworkRequest(port_id='my_portid1')])
+ objects=[objects.NetworkRequest(port_id=uuids.portid_1)])
api = self._stub_allocate_for_instance(
net_idx=1, requested_networks=requested_networks,
macs=set(['unknown:mac']),
@@ -1113,7 +1115,8 @@ class TestNeutronv2(TestNeutronv2Base):
def test_allocate_for_instance_with_invalid_network_id(self):
requested_networks = objects.NetworkRequestList(
- objects=[objects.NetworkRequest(network_id='invalid_id')])
+ objects=[objects.NetworkRequest(
+ network_id=uuids.non_existent_uuid)])
api = self._stub_allocate_for_instance(net_idx=9,
requested_networks=requested_networks,
_break='post_list_networks')
@@ -1132,7 +1135,7 @@ class TestNeutronv2(TestNeutronv2Base):
def test_allocate_for_instance_with_requested_networks_with_port(self):
requested_networks = objects.NetworkRequestList(
- objects=[objects.NetworkRequest(port_id='my_portid1')])
+ objects=[objects.NetworkRequest(port_id=uuids.portid_1)])
self._allocate_for_instance(net_idx=1,
requested_networks=requested_networks)
@@ -1294,7 +1297,7 @@ class TestNeutronv2(TestNeutronv2Base):
def test_allocate_for_instance_port_in_use(self):
# If a port is already in use, an exception should be raised.
requested_networks = objects.NetworkRequestList(
- objects=[objects.NetworkRequest(port_id='my_portid1')])
+ objects=[objects.NetworkRequest(port_id=uuids.portid_1)])
api = self._stub_allocate_for_instance(
requested_networks=requested_networks,
_break='pre_list_networks',
@@ -1306,7 +1309,7 @@ class TestNeutronv2(TestNeutronv2Base):
def test_allocate_for_instance_port_not_found(self):
# If a port is not found, an exception should be raised.
requested_networks = objects.NetworkRequestList(
- objects=[objects.NetworkRequest(port_id='invalid_id')])
+ objects=[objects.NetworkRequest(port_id=uuids.non_existent_uuid)])
api = self._stub_allocate_for_instance(
requested_networks=requested_networks,
_break='pre_list_networks')
@@ -1317,7 +1320,7 @@ class TestNeutronv2(TestNeutronv2Base):
def test_allocate_for_instance_port_invalid_tenantid(self):
self.tenant_id = 'invalid_id'
requested_networks = objects.NetworkRequestList(
- objects=[objects.NetworkRequest(port_id='my_portid1')])
+ objects=[objects.NetworkRequest(port_id=uuids.portid_1)])
api = self._stub_allocate_for_instance(
requested_networks=requested_networks,
_break='pre_list_networks')
@@ -1433,7 +1436,7 @@ class TestNeutronv2(TestNeutronv2Base):
requested = objects.NetworkRequestList(
objects=[objects.NetworkRequest(network_id='fake-net',
address='1.2.3.4',
- port_id='fake-port')])
+ port_id=uuids.portid_5)])
# Test to deallocate in one port env.
self._deallocate_for_instance(1, requested_networks=requested)
@@ -1443,7 +1446,7 @@ class TestNeutronv2(TestNeutronv2Base):
requested = objects.NetworkRequestList(
objects=[objects.NetworkRequest(network_id='fake-net',
address='1.2.3.4',
- port_id='fake-port')])
+ port_id=uuids.portid_6)])
# Test to deallocate in one port env.
self._deallocate_for_instance(2, requested_networks=requested)
@@ -1683,7 +1686,7 @@ class TestNeutronv2(TestNeutronv2Base):
requested_networks = objects.NetworkRequestList(
objects=[objects.NetworkRequest(
network_id='my_netid1',
- port_id='3123-ad34-bc43-32332ca33e')])
+ port_id=uuids.portid_1)])
PortNotFound = exceptions.PortNotFoundClient()
self.moxed_client.show_port(requested_networks[0].port_id).AndRaise(
@@ -1699,7 +1702,7 @@ class TestNeutronv2(TestNeutronv2Base):
def test_validate_networks_port_show_raises_non404(self):
# Verify that the correct exception is thrown when a non existent
# port is passed to validate_networks.
- fake_port_id = '3123-ad34-bc43-32332ca33e'
+ fake_port_id = uuids.portid_1
requested_networks = objects.NetworkRequestList(
objects=[objects.NetworkRequest(
@@ -2326,7 +2329,7 @@ class TestNeutronv2(TestNeutronv2Base):
self.moxed_client.list_floatingips(floating_ip_address=address).\
AndReturn({'floatingips': [self.fip_associated]})
self.moxed_client.update_floatingip(
- fip_id, {'floatingip': {'port_id': 'my_portid1',
+ fip_id, {'floatingip': {'port_id': uuids.portid_1,
'fixed_ip_address': new_fixed_address}})
self.moxed_client.show_port(self.fip_associated['port_id']).\
AndReturn({'port': self.port_data2[1]})
@@ -2394,7 +2397,7 @@ class TestNeutronv2(TestNeutronv2Base):
}
port = self.port_data1[0]
port['fixed_ips'] = [{'subnet_id': 'my_subid1'}]
- self.moxed_client.update_port('my_portid1',
+ self.moxed_client.update_port(uuids.portid_1,
MyComparator(port_req_body)).AndReturn({'port': port})
self.mox.ReplayAll()
@@ -2420,7 +2423,7 @@ class TestNeutronv2(TestNeutronv2Base):
}
port = self.port_data1[0]
port['fixed_ips'] = []
- self.moxed_client.update_port('my_portid1',
+ self.moxed_client.update_port(uuids.portid_1,
MyComparator(port_req_body)).AndReturn({'port': port})
self.mox.ReplayAll()
@@ -2612,7 +2615,7 @@ class TestNeutronv2(TestNeutronv2Base):
fake_inst = objects.Instance()
fake_inst.project_id = 'fake'
- fake_inst.uuid = 'uuid'
+ fake_inst.uuid = uuids.instance
fake_inst.info_cache = objects.InstanceInfoCache()
fake_inst.info_cache.network_info = model.NetworkInfo()
fake_ports = [
@@ -2708,7 +2711,7 @@ class TestNeutronv2(TestNeutronv2Base):
neutronapi.get_client(mox.IgnoreArg(), admin=True).MultipleTimes(
).AndReturn(self.moxed_client)
self.moxed_client.list_ports(
- tenant_id='fake', device_id='uuid').AndReturn(
+ tenant_id='fake', device_id=uuids.instance).AndReturn(
{'ports': fake_ports})
self.mox.StubOutWithMock(api, '_get_floating_ips_by_fixed_and_port')
@@ -2728,7 +2731,7 @@ class TestNeutronv2(TestNeutronv2Base):
self.mox.ReplayAll()
neutronapi.get_client('fake')
fake_inst.info_cache = objects.InstanceInfoCache.new(
- self.context, 'fake-uuid')
+ self.context, uuids.instance)
fake_inst.info_cache.network_info = model.NetworkInfo.hydrate([])
nw_infos = api._build_network_info_model(
self.context, fake_inst,
@@ -2798,7 +2801,7 @@ class TestNeutronv2(TestNeutronv2Base):
fake_inst = objects.Instance()
fake_inst.project_id = 'fake'
- fake_inst.uuid = 'uuid'
+ fake_inst.uuid = uuids.instance
fake_inst.info_cache = objects.InstanceInfoCache()
fake_inst.info_cache.network_info = model.NetworkInfo()
fake_ports = [
@@ -2819,7 +2822,7 @@ class TestNeutronv2(TestNeutronv2Base):
neutronapi.get_client(mox.IgnoreArg(), admin=True).MultipleTimes(
).AndReturn(self.moxed_client)
self.moxed_client.list_ports(
- tenant_id='fake', device_id='uuid').AndReturn(
+ tenant_id='fake', device_id=uuids.instance).AndReturn(
{'ports': fake_ports})
mock_gather_port_ids_and_networks.return_value = ([], [])
@@ -2936,12 +2939,12 @@ class TestNeutronv2(TestNeutronv2Base):
self.mox.ResetAll()
requested_networks = objects.NetworkRequestList(
objects = [
- objects.NetworkRequest(port_id='my_portid1'),
+ objects.NetworkRequest(port_id=uuids.portid_1),
objects.NetworkRequest(network_id='net1'),
- objects.NetworkRequest(port_id='my_portid2'),
- objects.NetworkRequest(port_id='my_portid3'),
- objects.NetworkRequest(port_id='my_portid4'),
- objects.NetworkRequest(port_id='my_portid5')])
+ objects.NetworkRequest(port_id=uuids.portid_2),
+ objects.NetworkRequest(port_id=uuids.portid_3),
+ objects.NetworkRequest(port_id=uuids.portid_4),
+ objects.NetworkRequest(port_id=uuids.portid_5)])
pci_requests = objects.InstancePCIRequests(requests=[])
mock_get_port_vnic_info.side_effect = [
(model.VNIC_TYPE_DIRECT, 'phynet1'),
@@ -3426,27 +3429,27 @@ class TestNeutronv2WithMock(test.TestCase):
api = neutronapi.API()
with mock.patch.object(client.Client, 'show_network') as mock_show:
mock_show.return_value = {
- 'network': {'id': 'fake-uuid', 'name': 'fake-network'}
+ 'network': {'id': uuids.instance, 'name': 'fake-network'}
}
- net_obj = api.get(self.context, 'fake-uuid')
+ net_obj = api.get(self.context, uuids.instance)
self.assertEqual('fake-network', net_obj.label)
self.assertEqual('fake-network', net_obj.name)
- self.assertEqual('fake-uuid', net_obj.uuid)
+ self.assertEqual(uuids.instance, net_obj.uuid)
def test_get_all_networks(self):
api = neutronapi.API()
with mock.patch.object(client.Client, 'list_networks') as mock_list:
mock_list.return_value = {
'networks': [
- {'id': 'fake-uuid1', 'name': 'fake-network1'},
- {'id': 'fake-uuid2', 'name': 'fake-network2'},
+ {'id': uuids.network_1, 'name': 'fake-network1'},
+ {'id': uuids.network_2, 'name': 'fake-network2'},
]}
net_objs = api.get_all(self.context)
self.assertIsInstance(net_objs, objects.NetworkList)
self.assertEqual(2, len(net_objs))
- self.assertEqual(('fake-uuid1', 'fake-network1'),
+ self.assertEqual((uuids.network_1, 'fake-network1'),
(net_objs[0].uuid, net_objs[0].name))
- self.assertEqual(('fake-uuid2', 'fake-network2'),
+ self.assertEqual((uuids.network_2, 'fake-network2'),
(net_objs[1].uuid, net_objs[1].name))
@mock.patch.object(neutronapi.API, "_refresh_neutron_extensions_cache")
@@ -3615,9 +3618,9 @@ class TestNeutronv2WithMock(test.TestCase):
uuid='inst-1')
mock_has_pbe.return_value = False
nw_req = objects.NetworkRequestList(
- objects = [objects.NetworkRequest(port_id='fake-port1'),
- objects.NetworkRequest(port_id='fake-port2'),
- objects.NetworkRequest(port_id='fail-port')])
+ objects = [objects.NetworkRequest(port_id=uuids.portid_1),
+ objects.NetworkRequest(port_id=uuids.portid_2),
+ objects.NetworkRequest(port_id=uuids.fail_port_id)])
mock_avail_nets.return_value = [{'id': 'net-1',
'subnets': ['subnet1']}]
@@ -3626,7 +3629,7 @@ class TestNeutronv2WithMock(test.TestCase):
requested_networks=nw_req)
mock_unbind.assert_called_once_with(mock.sentinel.ctx,
- ['fake-port1', 'fake-port2'],
+ [uuids.portid_1, uuids.portid_2],
mock.ANY,
mock.ANY)
@@ -3675,24 +3678,26 @@ class TestNeutronv2WithMock(test.TestCase):
mock_nc = mock.Mock()
mock_ntrn.return_value = mock_nc
mock_nc.list_ports.return_value = {'ports': [
- {'id': 'port-1'}, {'id': 'port-2'}, {'id': 'port-3'}
+ {'id': uuids.portid_1}, {'id': uuids.portid_2},
+ {'id': uuids.portid_3}
]}
nw_req = objects.NetworkRequestList(
objects = [objects.NetworkRequest(network_id='net-1',
address='192.168.0.3',
- port_id='port-1',
- pci_request_id='pci-1')])
- mock_gppids.return_value = ['port-3']
+ port_id=uuids.portid_1,
+ pci_request_id=uuids.pci_1)])
+ mock_gppids.return_value = [uuids.portid_3]
self.api.deallocate_for_instance(mock.sentinel.ctx, mock_inst,
requested_networks=nw_req)
mock_unbind.assert_called_once_with(mock.sentinel.ctx,
- set(['port-1', 'port-3']),
+ set([uuids.portid_1,
+ uuids.portid_3]),
mock.ANY)
mock_deletep.assert_called_once_with(mock_nc,
mock_inst,
- set(['port-2']),
+ set([uuids.portid_2]),
raise_if_fail=True)
@mock.patch('nova.network.neutronv2.api.API.get_instance_nw_info')
@@ -3738,7 +3743,7 @@ class TestNeutronv2WithMock(test.TestCase):
uuid='inst-1')
mock_avail_nets.return_value = [{'id': 'net-1',
'subnets': ['subnet1']}]
- mock_nc.create_port.return_value = {'port': {'id': 'fake_id',
+ mock_nc.create_port.return_value = {'port': {'id': uuids.portid_1,
'tenant_id': mock_inst.project_id,
'binding:vif_type': 'binding_failed'}}
@@ -3746,7 +3751,7 @@ class TestNeutronv2WithMock(test.TestCase):
self.api.allocate_for_instance,
mock.sentinel.ctx,
mock_inst)
- mock_nc.delete_port.assert_called_once_with('fake_id')
+ mock_nc.delete_port.assert_called_once_with(uuids.portid_1)
@mock.patch('nova.network.neutronv2.api.API._show_port')
@mock.patch('nova.network.neutronv2.api.API._has_port_binding_extension')
@@ -3764,7 +3769,7 @@ class TestNeutronv2WithMock(test.TestCase):
'tenant_id': mock_inst.project_id,
'binding:vif_type': 'binding_failed'}
nw_req = objects.NetworkRequestList(
- objects = [objects.NetworkRequest(port_id='fake_id')])
+ objects = [objects.NetworkRequest(port_id=uuids.portid_1)])
self.assertRaises(exception.PortBindingFailed,
self.api.allocate_for_instance,
@@ -4129,7 +4134,7 @@ class TestNeutronv2NeutronHostnameDNS(TestNeutronv2Base):
# The port's dns_name attribute should be set by the port update
# request in allocate_for_instance
requested_networks = objects.NetworkRequestList(
- objects=[objects.NetworkRequest(port_id='my_portid1')])
+ objects=[objects.NetworkRequest(port_id=uuids.portid_1)])
self._allocate_for_instance(net_idx=1, dns_extension=True,
requested_networks=requested_networks)
@@ -4138,7 +4143,7 @@ class TestNeutronv2NeutronHostnameDNS(TestNeutronv2Base):
# request in allocate_for_instance. The port's dns_name was preset by
# the user with a value equal to the instance's hostname
requested_networks = objects.NetworkRequestList(
- objects=[objects.NetworkRequest(port_id='my_portid1')])
+ objects=[objects.NetworkRequest(port_id=uuids.portid_1)])
self._allocate_for_instance(net_idx=1, dns_extension=True,
requested_networks=requested_networks,
_dns_name='test-instance')
@@ -4147,7 +4152,7 @@ class TestNeutronv2NeutronHostnameDNS(TestNeutronv2Base):
# If a pre-existing port has dns_name set, an exception should be
# raised if dns_name is not equal to the instance's hostname
requested_networks = objects.NetworkRequestList(
- objects=[objects.NetworkRequest(port_id='my_portid1')])
+ objects=[objects.NetworkRequest(port_id=uuids.portid_1)])
api = self._stub_allocate_for_instance(
requested_networks=requested_networks,
dns_extension=True,
@@ -4170,7 +4175,7 @@ class TestNeutronv2NeutronHostnameDNSPortbinding(TestNeutronv2Base):
# The port's dns_name attribute should be set by the port update
# request in allocate_for_instance
requested_networks = objects.NetworkRequestList(
- objects=[objects.NetworkRequest(port_id='my_portid1')])
+ objects=[objects.NetworkRequest(port_id=uuids.portid_1)])
self._allocate_for_instance(net_idx=1, dns_extension=True,
portbinding=True,
bind_host_id=self.instance.get('host'),
@@ -4190,7 +4195,7 @@ class TestNeutronv2NeutronHostnameDNSPortbinding(TestNeutronv2Base):
# port binding extension is enabled and the port's network has a
# non-blank dns_domain attribute
requested_networks = objects.NetworkRequestList(
- objects=[objects.NetworkRequest(port_id='my_portid1')])
+ objects=[objects.NetworkRequest(port_id=uuids.portid_1)])
self._allocate_for_instance(net_idx=11, dns_extension=True,
portbinding=True,
bind_host_id=self.instance.get('host'),
@@ -4321,7 +4326,7 @@ class TestNeutronPortSecurity(test.NoDBTestCase):
objects.NetworkRequest(network_id='net2')])
instance = objects.Instance(
- project_id=1, availability_zone='nova', uuid='uuid1')
+ project_id=1, availability_zone='nova', uuid=uuids.instance)
secgroups = ['default'] # Nova API provides the 'default'
mock_process_requested_networks.return_value = [
@@ -4341,13 +4346,13 @@ class TestNeutronPortSecurity(test.NoDBTestCase):
mock.ANY, instance,
u'net1', {'port':
{'device_owner': u'compute:nova',
- 'device_id': 'uuid1'}},
+ 'device_id': uuids.instance}},
None, [], None, None),
mock.call(
mock.ANY, instance,
u'net2', {'port':
{'device_owner': u'compute:nova',
- 'device_id': 'uuid1'}},
+ 'device_id': uuids.instance}},
None, [], None, None)])
@mock.patch.object(neutronapi.API, 'get_instance_nw_info')
@@ -4380,7 +4385,7 @@ class TestNeutronPortSecurity(test.NoDBTestCase):
objects.NetworkRequest(network_id='net2')])
instance = objects.Instance(
- project_id=1, availability_zone='nova', uuid='uuid1')
+ project_id=1, availability_zone='nova', uuid=uuids.instance)
secgroups = ['default', 'secgrp1', 'secgrp2']
mock_process_requested_networks.return_value = [
@@ -4401,13 +4406,13 @@ class TestNeutronPortSecurity(test.NoDBTestCase):
mock.ANY, instance,
u'net1', {'port':
{'device_owner': u'compute:nova',
- 'device_id': 'uuid1'}},
+ 'device_id': uuids.instance}},
None, ['secgrp-uuid1', 'secgrp-uuid2'], None, None),
mock.call(
mock.ANY, instance,
u'net2', {'port':
{'device_owner': u'compute:nova',
- 'device_id': 'uuid1'}},
+ 'device_id': uuids.instance}},
None, ['secgrp-uuid1', 'secgrp-uuid2'], None, None)])
@mock.patch.object(neutronapi.API, 'get_instance_nw_info')
@@ -4440,7 +4445,7 @@ class TestNeutronPortSecurity(test.NoDBTestCase):
objects.NetworkRequest(network_id='net2')])
instance = objects.Instance(
- project_id=1, availability_zone='nova', uuid='uuid1')
+ project_id=1, availability_zone='nova', uuid=uuids.instance)
secgroups = ['default'] # Nova API provides the 'default'
mock_process_requested_networks.return_value = [
@@ -4460,13 +4465,13 @@ class TestNeutronPortSecurity(test.NoDBTestCase):
mock.ANY, instance,
u'net1', {'port':
{'device_owner': u'compute:nova',
- 'device_id': 'uuid1'}},
+ 'device_id': uuids.instance}},
None, [], None, None),
mock.call(
mock.ANY, instance,
u'net2', {'port':
{'device_owner': u'compute:nova',
- 'device_id': 'uuid1'}},
+ 'device_id': uuids.instance}},
None, [], None, None)])
@mock.patch.object(neutronapi.API, 'get_instance_nw_info')
@@ -4499,7 +4504,7 @@ class TestNeutronPortSecurity(test.NoDBTestCase):
objects.NetworkRequest(network_id='net2')])
instance = objects.Instance(
- project_id=1, availability_zone='nova', uuid='uuid1')
+ project_id=1, availability_zone='nova', uuid=uuids.instance)
secgroups = ['default', 'secgrp1', 'secgrp2']
mock_process_requested_networks.return_value = [
diff --git a/nova/tests/unit/objects/test_virtual_interface.py b/nova/tests/unit/objects/test_virtual_interface.py
index 806a6e7fc7..d35d92faaf 100644
--- a/nova/tests/unit/objects/test_virtual_interface.py
+++ b/nova/tests/unit/objects/test_virtual_interface.py
@@ -17,7 +17,7 @@ import mock
from nova import db
from nova.objects import virtual_interface as vif_obj
from nova.tests.unit.objects import test_objects
-
+from nova.tests import uuidsentinel as uuids
fake_vif = {
'created_at': None,
@@ -27,8 +27,8 @@ fake_vif = {
'id': 1,
'address': '00:00:00:00:00:00',
'network_id': 123,
- 'instance_uuid': 'fake-uuid',
- 'uuid': 'fake-uuid-2',
+ 'instance_uuid': uuids.instance,
+ 'uuid': uuids.uuid,
'tag': 'fake-tag',
}
@@ -71,8 +71,8 @@ class _TestVirtualInterface(object):
vif = vif_obj.VirtualInterface(context=self.context)
vif.address = '00:00:00:00:00:00'
vif.network_id = 123
- vif.instance_uuid = 'fake-uuid'
- vif.uuid = 'fake-uuid-2'
+ vif.instance_uuid = uuids.instance
+ vif.uuid = uuids.uuid
vif.tag = 'fake-tag'
with mock.patch.object(db, 'virtual_interface_create') as create:
@@ -94,8 +94,8 @@ class _TestVirtualInterface(object):
vif = vif_obj.VirtualInterface(context=self.context)
vif.address = '00:00:00:00:00:00'
vif.network_id = 123
- vif.instance_uuid = 'fake-uuid'
- vif.uuid = 'fake-uuid-2'
+ vif.instance_uuid = uuids.instance
+ vif.uuid = uuids.uuid
vif.tag = 'fake-tag'
primitive = vif.obj_to_primitive(target_version='1.0')