diff options
| author | Jenkins <jenkins@review.openstack.org> | 2012-02-18 02:17:05 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2012-02-18 02:17:05 +0000 |
| commit | 86148ed2918334ca9a0be20f0dd4e2a4bddfc898 (patch) | |
| tree | 5cf69581a6a1532cb64bc7bb96a8006ec5c6ea43 /nova/tests | |
| parent | ecf49105e11fc112574490203bdef9f8f62a0b6a (diff) | |
| parent | 0e1ceb4d753f2b4cd3b6aaee5e3f68caaf424c57 (diff) | |
Merge "Setting access ip values on server create."
Diffstat (limited to 'nova/tests')
| -rw-r--r-- | nova/tests/test_compute.py | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/nova/tests/test_compute.py b/nova/tests/test_compute.py index 48f16d7b4..582846c91 100644 --- a/nova/tests/test_compute.py +++ b/nova/tests/test_compute.py @@ -192,7 +192,7 @@ class BaseTestCase(test.TestCase): class ComputeTestCase(BaseTestCase): def setUp(self): - def fake_get_nw_info(cls, ctxt, instance): + def fake_get_nw_info(cls, ctxt, instance, *args, **kwargs): self.assertTrue(ctxt.is_admin) return fake_network.fake_get_instance_nw_info(self.stubs, 1, 1, spectacular=True) @@ -200,6 +200,8 @@ class ComputeTestCase(BaseTestCase): super(ComputeTestCase, self).setUp() self.stubs.Set(nova.network.API, 'get_instance_nw_info', fake_get_nw_info) + self.stubs.Set(nova.network.API, 'allocate_for_instance', + fake_get_nw_info) def test_wrap_instance_fault(self): inst_uuid = "fake_uuid" @@ -271,6 +273,35 @@ class ComputeTestCase(BaseTestCase): finally: db.instance_destroy(self.context, instance['id']) + def test_default_access_ip(self): + self.flags(default_access_ip_network_name='test1', stub_network=False) + instance = self._create_fake_instance() + + try: + self.compute.run_instance(self.context, instance['uuid'], + is_first_time=True) + instances = db.instance_get_all(context.get_admin_context()) + instance = instances[0] + + self.assertEqual(instance.access_ip_v4, '192.168.1.100') + self.assertEqual(instance.access_ip_v6, '2001:db8:0:1::1') + finally: + db.instance_destroy(self.context, instance['id']) + + def test_no_default_access_ip(self): + instance = self._create_fake_instance() + + try: + self.compute.run_instance(self.context, instance['uuid'], + is_first_time=True) + instances = db.instance_get_all(context.get_admin_context()) + instance = instances[0] + + self.assertFalse(instance.access_ip_v4) + self.assertFalse(instance.access_ip_v6) + finally: + db.instance_destroy(self.context, instance['id']) + def _assert_state(self, state_dict): """assert the instance is in the state defined by state_dict""" instances = db.instance_get_all(context.get_admin_context()) |
