From f8ec1a5b9002f4a4cda5d7156c6006aac0035c33 Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Fri, 19 Aug 2011 16:12:33 -0500 Subject: initial committ --- nova/tests/test_compute.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nova/tests/test_compute.py b/nova/tests/test_compute.py index 4f5d36f14..925ac733b 100644 --- a/nova/tests/test_compute.py +++ b/nova/tests/test_compute.py @@ -35,6 +35,7 @@ from nova import rpc from nova import test from nova import utils from nova.notifier import test_notifier +from nova.tests import fake_network_info LOG = logging.getLogger('nova.tests.compute') FLAGS = flags.FLAGS @@ -133,6 +134,9 @@ class ComputeTestCase(test.TestCase): def test_create_instance_defaults_display_name(self): """Verify that an instance cannot be created without a display_name.""" + import pretty_print as pp + pp(fake_get_instance_nw_info(self.stubs, 1, 2)) + self.assertEqual(True, False) cases = [dict(), dict(display_name=None)] for instance in cases: ref = self.compute_api.create(self.context, -- cgit From 773f64af47e38f10b20399fcfaa43cc52eb1d2e6 Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Fri, 19 Aug 2011 16:41:02 -0500 Subject: added fake network info --- nova/tests/fake_network_info.py | 107 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 nova/tests/fake_network_info.py diff --git a/nova/tests/fake_network_info.py b/nova/tests/fake_network_info.py new file mode 100644 index 000000000..f5bc0368c --- /dev/null +++ b/nova/tests/fake_network_info.py @@ -0,0 +1,107 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright 2011 Rackspace +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from nova import db +from nova import test +from nova.network import manager as network_manager + + +HOST = "testhost" + + +class FakeModel(dict): + """Represent a model from the db""" + def __init__(self, *args, **kwargs): + self.update(kwargs) + + def __getattr__(self, name): + return self[name] + + +def fake_network(n): + return {'id': n, + 'label': 'test%d' % n, + 'injected': False, + 'multi_host': False, + 'cidr': '192.168.%d.0/24' % n, + 'cidr_v6': '2001:db8:0:%x::/64' % n, + 'gateway_v6': '2001:db8:0:%x::1' % n, + 'netmask_v6': '64', + 'netmask': '255.255.255.0', + 'bridge': 'fa%d' % n, + 'bridge_interface': 'fake_br%d' % n, + 'gateway': '192.168.%d.1' % n, + 'broadcast': '192.168.%d.255' % n, + 'dns1': '192.168.%d.3' % n, + 'dns2': '192.168.%d.4' % n, + 'vlan': None, + 'host': None, + 'project_id': 'fake_project', + 'vpn_public_address': '192.168.%d.2' % n} + + +def fixed_ips(num_networks, num_ips): + for network in xrange(num_networks): + for ip in xrange(num_ips): + yield {'id': network * ip, + 'network_id': network, + 'address': '192.168.%d.100' % network, + 'instance_id': 0, + 'allocated': False, + # and since network_id and vif_id happen to be equivalent + 'virtual_interface_id': network, + 'floating_ips': [FakeModel(**floating_ip)]} + + +flavor = {'id': 0, + 'rxtx_cap': 3} + + +floating_ip = {'id': 0, + 'address': '10.10.10.10', + 'fixed_ip_id': 0, + 'project_id': None, + 'auto_assigned': False} + + +def vifs(n): + for x in xrange(n): + yield {'id': x, + 'address': 'DE:AD:BE:EF:00:%2x' % x, + 'uuid': '00000000-0000-0000-0000-00000000000000%2d' % x, + 'network_id': x, + 'network': FakeModel(**fake_network(x)), + 'instance_id': 0} + + +def fake_get_instance_nw_info(stubs, n=1, ips_per_vif=2): + network = network_manager.FlatManager(host=HOST) + + def fixed_ips_fake(*args, **kwargs): + return fixed_ips() + + def virtual_interfaces_fake(*args, **kwargs): + return [vif for vif in vifs(n)] + + def instance_type_fake(*args, **kwargs): + return flavor + + stubs.Set(db, 'fixed_ip_get_by_instance', fixed_ips_fake) + stubs.Set(db, 'virtual_interface_get_by_instance', virtual_interface_fake) + stubs.Set(db, 'instance_type_get', instance_type_fake) + + nw_info = self.network.get_instance_nw_info(None, 0, 0, None) -- cgit From 608a6c3e719fffe9af6f8f7cc6d18824d0c28c36 Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Fri, 19 Aug 2011 16:42:52 -0500 Subject: typo --- nova/tests/fake_network_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/tests/fake_network_info.py b/nova/tests/fake_network_info.py index f5bc0368c..991599987 100644 --- a/nova/tests/fake_network_info.py +++ b/nova/tests/fake_network_info.py @@ -101,7 +101,7 @@ def fake_get_instance_nw_info(stubs, n=1, ips_per_vif=2): return flavor stubs.Set(db, 'fixed_ip_get_by_instance', fixed_ips_fake) - stubs.Set(db, 'virtual_interface_get_by_instance', virtual_interface_fake) + stubs.Set(db, 'virtual_interface_get_by_instance', virtual_interfaces_fake) stubs.Set(db, 'instance_type_get', instance_type_fake) nw_info = self.network.get_instance_nw_info(None, 0, 0, None) -- cgit From c4d73b638dee9dc4c1b2883affc0c00cdfc5ecb6 Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Fri, 19 Aug 2011 16:44:23 -0500 Subject: typo --- nova/tests/fake_network_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/tests/fake_network_info.py b/nova/tests/fake_network_info.py index 991599987..61b35a9d2 100644 --- a/nova/tests/fake_network_info.py +++ b/nova/tests/fake_network_info.py @@ -104,4 +104,4 @@ def fake_get_instance_nw_info(stubs, n=1, ips_per_vif=2): stubs.Set(db, 'virtual_interface_get_by_instance', virtual_interfaces_fake) stubs.Set(db, 'instance_type_get', instance_type_fake) - nw_info = self.network.get_instance_nw_info(None, 0, 0, None) + nw_info = network_manager.get_instance_nw_info(None, 0, 0, None) -- cgit From ca83ca57646ba76908e9b5e600208fe9afde78a4 Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Fri, 19 Aug 2011 16:47:10 -0500 Subject: typo --- nova/tests/fake_network_info.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nova/tests/fake_network_info.py b/nova/tests/fake_network_info.py index 61b35a9d2..1fb3584dd 100644 --- a/nova/tests/fake_network_info.py +++ b/nova/tests/fake_network_info.py @@ -18,6 +18,7 @@ from nova import db from nova import test from nova.network import manager as network_manager +from network_ HOST = "testhost" @@ -104,4 +105,4 @@ def fake_get_instance_nw_info(stubs, n=1, ips_per_vif=2): stubs.Set(db, 'virtual_interface_get_by_instance', virtual_interfaces_fake) stubs.Set(db, 'instance_type_get', instance_type_fake) - nw_info = network_manager.get_instance_nw_info(None, 0, 0, None) + nw_info = network.get_instance_nw_info(None, 0, 0, None) -- cgit From 23e163199e3b3208d7ba16049b7a93cbd59a8eaf Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Fri, 19 Aug 2011 16:48:01 -0500 Subject: typo --- nova/tests/fake_network_info.py | 1 - 1 file changed, 1 deletion(-) diff --git a/nova/tests/fake_network_info.py b/nova/tests/fake_network_info.py index 1fb3584dd..87f6b9c56 100644 --- a/nova/tests/fake_network_info.py +++ b/nova/tests/fake_network_info.py @@ -18,7 +18,6 @@ from nova import db from nova import test from nova.network import manager as network_manager -from network_ HOST = "testhost" -- cgit From 7e6451b722b1e77ccab702482d5d5ad516056825 Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Fri, 19 Aug 2011 16:58:39 -0500 Subject: typo --- nova/tests/fake_network_info.py | 1 + nova/tests/test_compute.py | 3 +-- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/nova/tests/fake_network_info.py b/nova/tests/fake_network_info.py index 87f6b9c56..3360675d6 100644 --- a/nova/tests/fake_network_info.py +++ b/nova/tests/fake_network_info.py @@ -90,6 +90,7 @@ def vifs(n): def fake_get_instance_nw_info(stubs, n=1, ips_per_vif=2): network = network_manager.FlatManager(host=HOST) + network.db = db def fixed_ips_fake(*args, **kwargs): return fixed_ips() diff --git a/nova/tests/test_compute.py b/nova/tests/test_compute.py index 925ac733b..dd65d81cc 100644 --- a/nova/tests/test_compute.py +++ b/nova/tests/test_compute.py @@ -134,8 +134,7 @@ class ComputeTestCase(test.TestCase): def test_create_instance_defaults_display_name(self): """Verify that an instance cannot be created without a display_name.""" - import pretty_print as pp - pp(fake_get_instance_nw_info(self.stubs, 1, 2)) + print fake_network_info.fake_get_instance_nw_info(self.stubs, 1, 2) self.assertEqual(True, False) cases = [dict(), dict(display_name=None)] for instance in cases: -- cgit From 429d28df87e887ef297453f3dc186c1a99ba0a7a Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Fri, 19 Aug 2011 17:00:13 -0500 Subject: typo --- nova/tests/fake_network_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/tests/fake_network_info.py b/nova/tests/fake_network_info.py index 3360675d6..d920ab1a2 100644 --- a/nova/tests/fake_network_info.py +++ b/nova/tests/fake_network_info.py @@ -93,7 +93,7 @@ def fake_get_instance_nw_info(stubs, n=1, ips_per_vif=2): network.db = db def fixed_ips_fake(*args, **kwargs): - return fixed_ips() + return fixed_ips(n, ips_per_vif) def virtual_interfaces_fake(*args, **kwargs): return [vif for vif in vifs(n)] -- cgit From 6ab9559b5f1f398cdaac4eca7bfcfcda859d8bc8 Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Fri, 19 Aug 2011 17:02:21 -0500 Subject: fixed formatting string --- nova/tests/fake_network_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/tests/fake_network_info.py b/nova/tests/fake_network_info.py index d920ab1a2..e0ff71c2c 100644 --- a/nova/tests/fake_network_info.py +++ b/nova/tests/fake_network_info.py @@ -81,7 +81,7 @@ floating_ip = {'id': 0, def vifs(n): for x in xrange(n): yield {'id': x, - 'address': 'DE:AD:BE:EF:00:%2x' % x, + 'address': 'DE:AD:BE:EF:00:%02x' % x, 'uuid': '00000000-0000-0000-0000-00000000000000%2d' % x, 'network_id': x, 'network': FakeModel(**fake_network(x)), -- cgit From 95851baea252d801cbb704e869f78162ea995ceb Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Fri, 19 Aug 2011 17:05:29 -0500 Subject: added return --- nova/tests/fake_network_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/tests/fake_network_info.py b/nova/tests/fake_network_info.py index e0ff71c2c..53785635c 100644 --- a/nova/tests/fake_network_info.py +++ b/nova/tests/fake_network_info.py @@ -105,4 +105,4 @@ def fake_get_instance_nw_info(stubs, n=1, ips_per_vif=2): stubs.Set(db, 'virtual_interface_get_by_instance', virtual_interfaces_fake) stubs.Set(db, 'instance_type_get', instance_type_fake) - nw_info = network.get_instance_nw_info(None, 0, 0, None) + return network.get_instance_nw_info(None, 0, 0, None) -- cgit From 44af602dbc6f02de44e2b844a8d53a87680b7a94 Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Fri, 19 Aug 2011 17:18:57 -0500 Subject: who cares --- nova/tests/test_compute.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/tests/test_compute.py b/nova/tests/test_compute.py index dd65d81cc..fcb86e322 100644 --- a/nova/tests/test_compute.py +++ b/nova/tests/test_compute.py @@ -134,7 +134,7 @@ class ComputeTestCase(test.TestCase): def test_create_instance_defaults_display_name(self): """Verify that an instance cannot be created without a display_name.""" - print fake_network_info.fake_get_instance_nw_info(self.stubs, 1, 2) + print fake_network_info.fake_get_instance_nw_info(self.stubs, 2, 1) self.assertEqual(True, False) cases = [dict(), dict(display_name=None)] for instance in cases: -- cgit From 32e5341af311faf9838bd5d039b2153549726a71 Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Fri, 19 Aug 2011 17:36:52 -0500 Subject: updated a maths --- nova/tests/fake_network_info.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nova/tests/fake_network_info.py b/nova/tests/fake_network_info.py index 53785635c..e73fe0442 100644 --- a/nova/tests/fake_network_info.py +++ b/nova/tests/fake_network_info.py @@ -57,7 +57,7 @@ def fake_network(n): def fixed_ips(num_networks, num_ips): for network in xrange(num_networks): for ip in xrange(num_ips): - yield {'id': network * ip, + yield {'id': network * num_ips + ip, 'network_id': network, 'address': '192.168.%d.100' % network, 'instance_id': 0, @@ -82,7 +82,7 @@ def vifs(n): for x in xrange(n): yield {'id': x, 'address': 'DE:AD:BE:EF:00:%02x' % x, - 'uuid': '00000000-0000-0000-0000-00000000000000%2d' % x, + 'uuid': '00000000-0000-0000-0000-00000000000000%02d' % x, 'network_id': x, 'network': FakeModel(**fake_network(x)), 'instance_id': 0} @@ -93,7 +93,7 @@ def fake_get_instance_nw_info(stubs, n=1, ips_per_vif=2): network.db = db def fixed_ips_fake(*args, **kwargs): - return fixed_ips(n, ips_per_vif) + return list(fixed_ips(n, ips_per_vif)) def virtual_interfaces_fake(*args, **kwargs): return [vif for vif in vifs(n)] -- cgit From 154f1fbcc7098aca210514ce9f458fb755b4b50b Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Fri, 19 Aug 2011 17:51:14 -0500 Subject: updated a maths --- nova/tests/fake_network_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/tests/fake_network_info.py b/nova/tests/fake_network_info.py index e73fe0442..0c33898cb 100644 --- a/nova/tests/fake_network_info.py +++ b/nova/tests/fake_network_info.py @@ -59,7 +59,7 @@ def fixed_ips(num_networks, num_ips): for ip in xrange(num_ips): yield {'id': network * num_ips + ip, 'network_id': network, - 'address': '192.168.%d.100' % network, + 'address': '192.168.%d.1%02d' % (network, ip), 'instance_id': 0, 'allocated': False, # and since network_id and vif_id happen to be equivalent -- cgit From 4d975772a6a488a99bec616f0118dd1ce74e9403 Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Fri, 19 Aug 2011 18:04:08 -0500 Subject: finished fake network info, removed testing shims --- nova/tests/test_compute.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/nova/tests/test_compute.py b/nova/tests/test_compute.py index fcb86e322..4f5d36f14 100644 --- a/nova/tests/test_compute.py +++ b/nova/tests/test_compute.py @@ -35,7 +35,6 @@ from nova import rpc from nova import test from nova import utils from nova.notifier import test_notifier -from nova.tests import fake_network_info LOG = logging.getLogger('nova.tests.compute') FLAGS = flags.FLAGS @@ -134,8 +133,6 @@ class ComputeTestCase(test.TestCase): def test_create_instance_defaults_display_name(self): """Verify that an instance cannot be created without a display_name.""" - print fake_network_info.fake_get_instance_nw_info(self.stubs, 2, 1) - self.assertEqual(True, False) cases = [dict(), dict(display_name=None)] for instance in cases: ref = self.compute_api.create(self.context, -- cgit From d2ea838bfad96bae172458ac6389a9f98111a7df Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Mon, 22 Aug 2011 17:46:47 -0500 Subject: update test_network test_get_instance_nw_info() --- nova/network/manager.py | 12 +++---- nova/tests/fake_network_info.py | 21 ++++++------ nova/tests/test_network.py | 71 +++++++++++++++++------------------------ 3 files changed, 48 insertions(+), 56 deletions(-) diff --git a/nova/network/manager.py b/nova/network/manager.py index 921c27e45..dcd5aad9a 100644 --- a/nova/network/manager.py +++ b/nova/network/manager.py @@ -468,17 +468,17 @@ class NetworkManager(manager.SchedulerDependentManager): # TODO(tr3buchet) eventually "enabled" should be determined def ip_dict(ip): return { - "ip": ip, - "netmask": network["netmask"], - "enabled": "1"} + 'ip': ip, + 'netmask': network['netmask'], + 'enabled': '1'} def ip6_dict(): return { - "ip": ipv6.to_global(network['cidr_v6'], + 'ip': ipv6.to_global(network['cidr_v6'], vif['address'], network['project_id']), - "netmask": network['netmask_v6'], - "enabled": "1"} + 'netmask': network['netmask_v6'], + 'enabled': '1'} network_dict = { 'bridge': network['bridge'], 'id': network['id'], diff --git a/nova/tests/fake_network_info.py b/nova/tests/fake_network_info.py index 0c33898cb..072585195 100644 --- a/nova/tests/fake_network_info.py +++ b/nova/tests/fake_network_info.py @@ -42,8 +42,8 @@ def fake_network(n): 'gateway_v6': '2001:db8:0:%x::1' % n, 'netmask_v6': '64', 'netmask': '255.255.255.0', - 'bridge': 'fa%d' % n, - 'bridge_interface': 'fake_br%d' % n, + 'bridge': 'fake_br%d' % n, + 'bridge_interface': 'fake_eth%d' % n, 'gateway': '192.168.%d.1' % n, 'broadcast': '192.168.%d.255' % n, 'dns1': '192.168.%d.3' % n, @@ -54,26 +54,29 @@ def fake_network(n): 'vpn_public_address': '192.168.%d.2' % n} -def fixed_ips(num_networks, num_ips): +def fixed_ips(num_networks, num_ips, num_floating_ips=0): for network in xrange(num_networks): for ip in xrange(num_ips): - yield {'id': network * num_ips + ip, + id = network * num_ips + ip + f_ips = [floating_ips(id).next() for i in xrange(num_floating_ips)] + yield {'id': id, 'network_id': network, 'address': '192.168.%d.1%02d' % (network, ip), 'instance_id': 0, 'allocated': False, # and since network_id and vif_id happen to be equivalent 'virtual_interface_id': network, - 'floating_ips': [FakeModel(**floating_ip)]} + 'floating_ips': [FakeModel(**ip) for ip in f_ips]} flavor = {'id': 0, 'rxtx_cap': 3} - -floating_ip = {'id': 0, - 'address': '10.10.10.10', - 'fixed_ip_id': 0, +def floating_ips(fixed_ip_id): + for i in xrange(154): + yield {'id': 0, + 'address': '10.10.10.%d' % (i + 100), + 'fixed_ip_id': fixed_ip_id, 'project_id': None, 'auto_assigned': False} diff --git a/nova/tests/test_network.py b/nova/tests/test_network.py index e5c80b6f6..7822fbc70 100644 --- a/nova/tests/test_network.py +++ b/nova/tests/test_network.py @@ -14,15 +14,14 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. +import mox from nova import db from nova import exception from nova import log as logging from nova import test from nova.network import manager as network_manager - - -import mox +from nova.tests import fake_network_info LOG = logging.getLogger('nova.tests.network') @@ -128,60 +127,50 @@ class FlatNetworkTestCase(test.TestCase): self.network.db = db def test_get_instance_nw_info(self): - self.mox.StubOutWithMock(db, 'fixed_ip_get_by_instance') - self.mox.StubOutWithMock(db, 'virtual_interface_get_by_instance') - self.mox.StubOutWithMock(db, 'instance_type_get') - - db.fixed_ip_get_by_instance(mox.IgnoreArg(), - mox.IgnoreArg()).AndReturn(fixed_ips) - db.virtual_interface_get_by_instance(mox.IgnoreArg(), - mox.IgnoreArg()).AndReturn(vifs) - db.instance_type_get(mox.IgnoreArg(), - mox.IgnoreArg()).AndReturn(flavor) - self.mox.ReplayAll() - - nw_info = self.network.get_instance_nw_info(None, 0, 0, None) + fake_get_instance_nw_info = fake_network_info.fake_get_instance_nw_info - self.assertTrue(nw_info) + nw_info = fake_get_instance_nw_info(self.stubs, 0, 2) + self.assertFalse(nw_info) - for i, nw in enumerate(nw_info): - i8 = i + 8 - check = {'bridge': 'fa%s' % i, + for i, (nw, info) in enumerate(nw_info): + check = {'bridge': 'fake_br%d' % i, 'cidr': '192.168.%s.0/24' % i, - 'cidr_v6': '2001:db%s::/64' % i8, + 'cidr_v6': '2001:db8:0:%x::/64' % i, 'id': i, 'multi_host': False, - 'injected': 'DONTCARE', - 'bridge_interface': 'fake_fa%s' % i, + 'injected': False, + 'bridge_interface': 'fake_eth%d' % i, 'vlan': None} - self.assertDictMatch(nw[0], check) + self.assertDictMatch(nw, check) - check = {'broadcast': '192.168.%s.255' % i, - 'dhcp_server': '192.168.%s.1' % i, - 'dns': 'DONTCARE', - 'gateway': '192.168.%s.1' % i, - 'gateway6': '2001:db%s::1' % i8, + check = {'broadcast': '192.168.%d.255' % i, + 'dhcp_server': '192.168.%d.1' % i, + 'dns': ['192.168.%d.3' % n, '192.168.%d.4' % n] + 'gateway': '192.168.%d.1' % i, + 'gateway6': '2001:db8:0:%x::1' % i, 'ip6s': 'DONTCARE', 'ips': 'DONTCARE', - 'label': 'test%s' % i, - 'mac': 'DE:AD:BE:EF:00:0%s' % i, - 'vif_uuid': ('00000000-0000-0000-0000-000000000000000%s' % - i), - 'rxtx_cap': 'DONTCARE', + 'label': 'test%d' % i, + 'mac': 'DE:AD:BE:EF:00:%02x' % i, + 'vif_uuid': + '00000000-0000-0000-0000-00000000000000%02d' % i, + 'rxtx_cap': 3, 'should_create_vlan': False, 'should_create_bridge': False} - self.assertDictMatch(nw[1], check) + self.assertDictMatch(info, check) check = [{'enabled': 'DONTCARE', - 'ip': '2001:db%s::dcad:beff:feef:%s' % (i8, i), + 'ip': '2001:db8::dcad:beff:feef:%s' % i, 'netmask': '64'}] - self.assertDictListMatch(nw[1]['ip6s'], check) + self.assertDictListMatch(info['ip6s'], check) - check = [{'enabled': '1', - 'ip': '192.168.%s.100' % i, - 'netmask': '255.255.255.0'}] - self.assertDictListMatch(nw[1]['ips'], check) + num_fixed_ips = len(info['ips']) + check = [{'enabled': 'DONTCARE', + 'ip': '192.168.%d.1%02d' % (i, ip_num), + 'netmask': '255.255.255.0'} + for ip_num in xrange(num_fixed_ips)] + self.assertDictListMatch(info['ips'], check) class VlanNetworkTestCase(test.TestCase): -- cgit From 158a953f98f8d4ee365cbc4936754fe7a8c89082 Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Mon, 22 Aug 2011 17:52:54 -0500 Subject: syntax --- nova/tests/test_network.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/tests/test_network.py b/nova/tests/test_network.py index 7822fbc70..91105ece3 100644 --- a/nova/tests/test_network.py +++ b/nova/tests/test_network.py @@ -146,7 +146,7 @@ class FlatNetworkTestCase(test.TestCase): check = {'broadcast': '192.168.%d.255' % i, 'dhcp_server': '192.168.%d.1' % i, - 'dns': ['192.168.%d.3' % n, '192.168.%d.4' % n] + 'dns': ['192.168.%d.3' % n, '192.168.%d.4' % n], 'gateway': '192.168.%d.1' % i, 'gateway6': '2001:db8:0:%x::1' % i, 'ip6s': 'DONTCARE', -- cgit From 01a219f7bb5fb5101bdbaa49d7e46f55d51dcfd2 Mon Sep 17 00:00:00 2001 From: Launchpad Translations on behalf of nova-core <> Date: Tue, 23 Aug 2011 05:21:47 +0000 Subject: Launchpad automatic translations update. --- po/it.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/po/it.po b/po/it.po index e166297f1..462254c46 100644 --- a/po/it.po +++ b/po/it.po @@ -14,7 +14,7 @@ msgstr "" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2011-08-22 04:48+0000\n" +"X-Launchpad-Export-Date: 2011-08-23 05:21+0000\n" "X-Generator: Launchpad (build 13697)\n" #: ../nova/scheduler/chance.py:37 ../nova/scheduler/zone.py:55 -- cgit From f95d187e7b9f6f1c3d244668cc4aec49339ed169 Mon Sep 17 00:00:00 2001 From: Launchpad Translations on behalf of nova-core <> Date: Wed, 24 Aug 2011 04:47:59 +0000 Subject: Launchpad automatic translations update. --- po/cs.po | 26 +--- po/de.po | 44 +----- po/es.po | 484 +----------------------------------------------------------- po/ja.po | 479 +---------------------------------------------------------- po/pt_BR.po | 156 +------------------- po/ru.po | 126 +--------------- po/tl.po | 13 +- po/uk.po | 42 +----- 8 files changed, 31 insertions(+), 1339 deletions(-) diff --git a/po/cs.po b/po/cs.po index 07bdf1928..561c71a4b 100644 --- a/po/cs.po +++ b/po/cs.po @@ -8,14 +8,14 @@ msgstr "" "Project-Id-Version: nova\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2011-02-21 10:03-0500\n" -"PO-Revision-Date: 2011-02-07 12:45+0000\n" -"Last-Translator: David Pravec \n" +"PO-Revision-Date: 2011-08-23 11:22+0000\n" +"Last-Translator: Thierry Carrez \n" "Language-Team: Czech \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2011-08-03 04:43+0000\n" -"X-Generator: Launchpad (build 13573)\n" +"X-Launchpad-Export-Date: 2011-08-24 04:47+0000\n" +"X-Generator: Launchpad (build 13697)\n" #: ../nova/scheduler/chance.py:37 ../nova/scheduler/zone.py:55 #: ../nova/scheduler/simple.py:75 ../nova/scheduler/simple.py:110 @@ -2789,21 +2789,3 @@ msgstr "" #, python-format msgid "Removing user %(user)s from project %(project)s" msgstr "" - -#, python-format -#~ msgid "AMQP server on %s:%d is unreachable. Trying again in %d seconds." -#~ msgstr "AMQP server na %s:%d není dosažitelný. Zkusím znovu za %d sekund." - -#, python-format -#~ msgid "" -#~ "%s\n" -#~ "Command: %s\n" -#~ "Exit code: %s\n" -#~ "Stdout: %r\n" -#~ "Stderr: %r" -#~ msgstr "" -#~ "%s\n" -#~ "Příkaz: %s\n" -#~ "Vrácená hodnota: %s\n" -#~ "Stdout: %r\n" -#~ "Stderr: %r" diff --git a/po/de.po b/po/de.po index 1f652c373..6d8c1372c 100644 --- a/po/de.po +++ b/po/de.po @@ -8,14 +8,14 @@ msgstr "" "Project-Id-Version: nova\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2011-02-21 10:03-0500\n" -"PO-Revision-Date: 2011-06-06 07:58+0000\n" -"Last-Translator: Christian Berendt \n" +"PO-Revision-Date: 2011-08-23 11:23+0000\n" +"Last-Translator: Thierry Carrez \n" "Language-Team: German \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2011-08-03 04:44+0000\n" -"X-Generator: Launchpad (build 13573)\n" +"X-Launchpad-Export-Date: 2011-08-24 04:47+0000\n" +"X-Generator: Launchpad (build 13697)\n" #: ../nova/scheduler/chance.py:37 ../nova/scheduler/zone.py:55 #: ../nova/scheduler/simple.py:75 ../nova/scheduler/simple.py:110 @@ -2798,42 +2798,6 @@ msgstr "" msgid "Removing user %(user)s from project %(project)s" msgstr "" -#, python-format -#~ msgid "" -#~ "%s\n" -#~ "Command: %s\n" -#~ "Exit code: %s\n" -#~ "Stdout: %r\n" -#~ "Stderr: %r" -#~ msgstr "" -#~ "%s\n" -#~ "Kommando: %s\n" -#~ "Exit Code: %s\n" -#~ "Stdout: %r\n" -#~ "Stderr: %r" - -#, python-format -#~ msgid "(%s) publish (key: %s) %s" -#~ msgstr "(%s) öffentlich (Schlüssel: %s) %s" - -#, python-format -#~ msgid "Getting from %s: %s" -#~ msgstr "Beziehe von %s: %s" - -#, python-format -#~ msgid "AMQP server on %s:%d is unreachable. Trying again in %d seconds." -#~ msgstr "" -#~ "Der AMQP server %s:%d ist nicht erreichbar. Erneuter Versuch in %d Sekunden." - -#, python-format -#~ msgid "volume %s: creating lv of size %sG" -#~ msgstr "Volume %s: erstelle LV mit %sG" - -#, python-format -#~ msgid "Data store %s is unreachable. Trying again in %d seconds." -#~ msgstr "" -#~ "Datastore %s ist nicht erreichbar. Versuche es erneut in %d Sekunden." - #~ msgid "Full set of FLAGS:" #~ msgstr "Alle vorhandenen FLAGS:" diff --git a/po/es.po b/po/es.po index 7371eae8c..d50269378 100644 --- a/po/es.po +++ b/po/es.po @@ -8,14 +8,14 @@ msgstr "" "Project-Id-Version: nova\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2011-02-21 10:03-0500\n" -"PO-Revision-Date: 2011-08-01 03:23+0000\n" -"Last-Translator: Juan Alfredo Salas Santillana \n" +"PO-Revision-Date: 2011-08-23 11:22+0000\n" +"Last-Translator: Thierry Carrez \n" "Language-Team: Spanish \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2011-08-03 04:44+0000\n" -"X-Generator: Launchpad (build 13573)\n" +"X-Launchpad-Export-Date: 2011-08-24 04:47+0000\n" +"X-Generator: Launchpad (build 13697)\n" #: ../nova/scheduler/chance.py:37 ../nova/scheduler/zone.py:55 #: ../nova/scheduler/simple.py:75 ../nova/scheduler/simple.py:110 @@ -2838,221 +2838,16 @@ msgstr "Agregando usuario %(user)s al proyecto %(project)s" msgid "Removing user %(user)s from project %(project)s" msgstr "Eliminando el usuario %(user)s del proyecto %(project)s" -#, python-format -#~ msgid "" -#~ "%s\n" -#~ "Command: %s\n" -#~ "Exit code: %s\n" -#~ "Stdout: %r\n" -#~ "Stderr: %r" -#~ msgstr "" -#~ "%s\n" -#~ "Comando: %s\n" -#~ "Código de salida: %s\n" -#~ "Stdout: %s\n" -#~ "Stderr: %r" - -#, python-format -#~ msgid "(%s) publish (key: %s) %s" -#~ msgstr "(%s) públicar (clave: %s) %s" - -#, python-format -#~ msgid "AMQP server on %s:%d is unreachable. Trying again in %d seconds." -#~ msgstr "" -#~ "El servidor AMQP en %s:%d no se puede alcanzar. Se reintentará en %d " -#~ "segundos." - -#, python-format -#~ msgid "Binding %s to %s with key %s" -#~ msgstr "Asociando %s a %s con clave %s" - -#, python-format -#~ msgid "Getting from %s: %s" -#~ msgstr "Obteniendo desde %s: %s" - -#, python-format -#~ msgid "Starting %s node" -#~ msgstr "Inciando nodo %s" - -#, python-format -#~ msgid "Data store %s is unreachable. Trying again in %d seconds." -#~ msgstr "" -#~ "El almacen de datos %s es inalcanzable. Reintentandolo en %d segundos." - #, python-format #~ msgid "Serving %s" #~ msgstr "Sirviendo %s" -#, python-format -#~ msgid "Couldn't get IP, using 127.0.0.1 %s" -#~ msgstr "No puedo obtener IP, usando 127.0.0.1 %s" - -#, python-format -#~ msgid "" -#~ "Access key %s has had %d failed authentications and will be locked out for " -#~ "%d minutes." -#~ msgstr "" -#~ "La clave de acceso %s ha tenido %d fallos de autenticación y se bloqueará " -#~ "por %d minutos." - -#, python-format -#~ msgid "arg: %s\t\tval: %s" -#~ msgstr "arg: %s \t \t val: %s" - -#, python-format -#~ msgid "Authenticated Request For %s:%s)" -#~ msgstr "Solicitud de autenticación para %s:%s" - -#, python-format -#~ msgid "Adding role %s to user %s for project %s" -#~ msgstr "Añadiendo rol %s al usuario %s para el proyecto %s" - -#, python-format -#~ msgid "Removing role %s from user %s for project %s" -#~ msgstr "Eliminando rol %s del usuario %s para el proyecto %s" - -#, python-format -#~ msgid "Unauthorized request for controller=%s and action=%s" -#~ msgstr "Solicitud no autorizada para controller=%s y action=%s" - -#, python-format -#~ msgid "Getting x509 for user: %s on project: %s" -#~ msgstr "Obteniendo x509 para el usuario: %s en el proyecto %s" - -#, python-format -#~ msgid "Create project %s managed by %s" -#~ msgstr "Creación del proyecto %s gestionada por %s" - -#, python-format -#~ msgid "Removing user %s from project %s" -#~ msgstr "Eliminando usuario %s del proyecto %s" - -#, python-format -#~ msgid "Adding user %s to project %s" -#~ msgstr "Añadiendo usuario %s al proyecto %s" - -#, python-format -#~ msgid "Unsupported API request: controller = %s,action = %s" -#~ msgstr "Solicitud de API no soportada: controller=%s,action=%s" - -#, python-format -#~ msgid "Associate address %s to instance %s" -#~ msgstr "Asociar dirección %s a la instancia %s" - -#, python-format -#~ msgid "Attach volume %s to instacne %s at %s" -#~ msgstr "Asociar volumen %s a la instancia %s en %s" - -#, python-format -#~ msgid "Registered image %s with id %s" -#~ msgstr "Registrada imagen %s con id %s" - -#, python-format -#~ msgid "User %s is already a member of the group %s" -#~ msgstr "El usuario %s ya es miembro de el grupo %s" - -#, python-format -#~ msgid "User %s is not a member of project %s" -#~ msgstr "El usuario %s no es miembro del proyecto %s" - -#, python-format -#~ msgid "failed authorization: no project named %s (user=%s)" -#~ msgstr "" -#~ "fallo de autorización: no existe proyecto con el nombre %s (usuario=%s)" - -#, python-format -#~ msgid "Failed authorization: user %s not admin and not member of project %s" -#~ msgstr "" -#~ "Fallo de autorización: el usuario %s no es administrador y no es miembro del " -#~ "proyecto %s" - -#, python-format -#~ msgid "Created user %s (admin: %r)" -#~ msgstr "Creado usuario %s (administrador: %r)" - -#, python-format -#~ msgid "Created project %s with manager %s" -#~ msgstr "Proyecto %s creado con administrador %s" - -#, python-format -#~ msgid "Removing role %s from user %s on project %s" -#~ msgstr "Eliminando rol %s al usuario %s en el proyecto %s" - -#, python-format -#~ msgid "Adding role %s to user %s in project %s" -#~ msgstr "Añadiendo rol %s al usuario %s en el proyecto %s" - -#, python-format -#~ msgid "Remove user %s from project %s" -#~ msgstr "Eliminar usuario %s del proyecto %s" - -#, python-format -#~ msgid "Admin status set to %r for user %s" -#~ msgstr "El estado del administrador se ha fijado a %r para el usuario %s" - -#, python-format -#~ msgid "Going to try and terminate %s" -#~ msgstr "Se va a probar y terminar %s" - -#, python-format -#~ msgid "Casting to scheduler for %s/%s's instance %s" -#~ msgstr "Llamando al planificar para %s/%s insntancia %s" - -#, python-format -#~ msgid "Quota exceeeded for %s, tried to run %s instances" -#~ msgstr "Quota superada por %s, intentando lanzar %s instancias" - -#, python-format -#~ msgid "check_instance_lock: arguments: |%s| |%s| |%s|" -#~ msgstr "check_instance_lock: arguments: |%s| |%s| |%s|" - -#, python-format -#~ msgid "Input partition size not evenly divisible by sector size: %d / %d" -#~ msgstr "" -#~ "El tamaño de la partición de entrada no es divisible de forma uniforme por " -#~ "el tamaño del sector: %d / %d" - -#, python-format -#~ msgid "Bytes for local storage not evenly divisible by sector size: %d / %d" -#~ msgstr "" -#~ "Los bytes del almacenamiento local no son divisibles de forma uniforme por " -#~ "el tamaño del sector: %d / %d" - -#, python-format -#~ msgid "volume %s: creating lv of size %sG" -#~ msgstr "volumen %s: creando lv de tamaño %sG" - -#, python-format -#~ msgid "Disassociating address %s" -#~ msgstr "Desasociando la dirección %s" - -#, python-format -#~ msgid "trying to reboot a non-running instance: %s (state: %s excepted: %s)" -#~ msgstr "" -#~ "intentando reiniciar una instancia que no está en ejecución: %s (estado: %s " -#~ "esperado: %s)" - -#, python-format -#~ msgid "" -#~ "trying to snapshot a non-running instance: %s (state: %s excepted: %s)" -#~ msgstr "" -#~ "intentando crear un snapshot de una instancia que no está en ejecución: %s " -#~ "(estado: %s esperado: %s)" - -#, python-format -#~ msgid "Detach volume %s from mountpoint %s on instance %s" -#~ msgstr "Desvinculando volumen %s del punto de montaje %s en la instancia %s" - #~ msgid "unexpected exception getting connection" #~ msgstr "excepción inexperada al obtener la conexión" #~ msgid "unexpected error during update" #~ msgstr "error inesperado durante la actualización" -#, python-format -#~ msgid "Cannot get blockstats for \"%s\" on \"%s\"" -#~ msgstr "No puedo obtener estadísticas del bloque para \"%s\" en \"%s\"" - #, python-format #~ msgid "updating %s..." #~ msgstr "actualizando %s..." @@ -3061,285 +2856,14 @@ msgstr "Eliminando el usuario %(user)s del proyecto %(project)s" #~ msgid "Found instance: %s" #~ msgstr "Encontrada interfaz: %s" -#, python-format -#~ msgid "Cannot get ifstats for \"%s\" on \"%s\"" -#~ msgstr "No puedo obtener estadísticas de la interfaz para \"%s\" en \"%s\"" - -#, python-format -#~ msgid "No instance for id %s" -#~ msgstr "No hay instancia con id %s" - -#, python-format -#~ msgid "no keypair for user %s, name %s" -#~ msgstr "no hay par de claves para el usuario %s, nombre %s" - -#, python-format -#~ msgid "No service for %s, %s" -#~ msgstr "No hay servicio para %s, %s" - -#, python-format -#~ msgid "No volume for id %s" -#~ msgstr "No hay volumen para el id %s" - -#, python-format -#~ msgid "No security group named %s for project: %s" -#~ msgstr "No hay un grupo de seguridad con nombre %s para el proyecto: %s" - -#, python-format -#~ msgid "Parallax returned HTTP error %d from request for /images/detail" -#~ msgstr "" -#~ "Parallax ha devuelto un error HTTP %d para la petición para /images/detail" - -#, python-format -#~ msgid "Parallax returned HTTP error %d from request for /images" -#~ msgstr "Parallax ha devuelto un error HTTP %d a la petición para /images" - -#, python-format -#~ msgid "IP %s leased to bad mac %s vs %s" -#~ msgstr "IP %s asociada a una mac incorrecta %s vs %s" - -#, python-format -#~ msgid "Unauthorized attempt to get object %s from bucket %s" -#~ msgstr "Intento no autorizado de obtener el objeto %s en el cubo %s" - -#, python-format -#~ msgid "Getting object: %s / %s" -#~ msgstr "Obteniendo objeto: %s / %s" - -#, python-format -#~ msgid "Putting object: %s / %s" -#~ msgstr "Colocando objeto: %s / %s" - -#, python-format -#~ msgid "Unauthorized attempt to upload object %s to bucket %s" -#~ msgstr "Intento no autorizado de subir el objeto %s al cubo %s" - -#, python-format -#~ msgid "Deleting object: %s / %s" -#~ msgstr "Eliminando objeto: %s / %s" - -#, python-format -#~ msgid "Toggling publicity flag of image %s %r" -#~ msgstr "Cambiando los atributos de publicidad de la imagen %s %r" - -#, python-format -#~ msgid "Creating disk for %s by attaching disk file %s" -#~ msgstr "" -#~ "Creando disco para %s a través de la asignación del fichero de disco %s" - -#, python-format -#~ msgid "WMI job succeeded: %s, Elapsed=%s " -#~ msgstr "Trabajo WMI ha tenido exito: %s, Transcurrido=%s " - -#, python-format -#~ msgid "Created switch port %s on switch %s" -#~ msgstr "Creado puerto %s en el switch %s" - -#, python-format -#~ msgid "instance %s: deleting instance files %s" -#~ msgstr "instancia %s: eliminando los ficheros de la instancia %s" - -#, python-format -#~ msgid "Finished retreving %s -- placed in %s" -#~ msgstr "Finalizada la obtención de %s -- coloado en %s" - -#, python-format -#~ msgid "Failed to change vm state of %s to %s" -#~ msgstr "Fallo al cambiar el estado de la vm de %s a %s" - -#, python-format -#~ msgid "Successfully changed vm state of %s to %s" -#~ msgstr "Cambio de estado de la vm con éxito de %s a %s" - -#, python-format -#~ msgid "" -#~ "Got Info for vm %s: state=%s, mem=%s, num_cpu=%s, " -#~ "cpu_time=%s" -#~ msgstr "" -#~ "Obtenida información para vm %s: state=%s, mem=%s, num_cpu=%s, cpu_time=%s" - -#, python-format -#~ msgid "instance %s: ignoring error injecting data into image %s (%s)" -#~ msgstr "" -#~ "instancia %s: ignorando el error al inyectar datos en la imagen %s (%s)" - -#, python-format -#~ msgid "Contents of file %s: %r" -#~ msgstr "Contenidos del fichero %s: %r" - -#, python-format -#~ msgid "instance %s: injecting net into image %s" -#~ msgstr "instancia %s: inyectando red en la imagen %s" - -#, python-format -#~ msgid "instance %s: injecting key into image %s" -#~ msgstr "instancia %s: inyectando clave en la imagen %s" - -#, python-format -#~ msgid "data: %r, fpath: %r" -#~ msgstr "datos: %r, fpath: %r" - -#, python-format -#~ msgid "Task [%s] %s status: %s %s" -#~ msgstr "Tarea [%s] %s estado: %s %s" - -#, python-format -#~ msgid "Task [%s] %s status: success %s" -#~ msgstr "Tarea [%s] %s estado: éxito %s" - -#, python-format -#~ msgid "Calling %s %s" -#~ msgstr "Llamando %s %s" - -#, python-format -#~ msgid "%s: _db_content => %s" -#~ msgstr "%s: _db_content => %s" - -#, python-format -#~ msgid "Created VBD %s for VM %s, VDI %s." -#~ msgstr "Creado VBD %s for VM %s, VDI %s." - -#, python-format -#~ msgid "Creating VBD for VM %s, VDI %s ... " -#~ msgstr "Creando VBD para VM %s, VDI %s... " - -#, python-format -#~ msgid "Created VIF %s for VM %s, network %s." -#~ msgstr "Creado VIF %s para VM %s, red %s." - -#, python-format -#~ msgid "Creating VIF for VM %s, network %s." -#~ msgstr "Creando VIF para VM %s, red %s." - -#, python-format -#~ msgid "Created VM %s as %s." -#~ msgstr "Creada VM %s cómo %s" - -#, python-format -#~ msgid "Asking xapi to upload %s as '%s'" -#~ msgstr "Solicitando a xapi la subida de %s cómo %s'" - -#, python-format -#~ msgid "VHD %s has parent %s" -#~ msgstr "VHD %s tiene cómo padre a %s" - -#, python-format -#~ msgid "Asking xapi to fetch %s as %s" -#~ msgstr "Solicitando a xapi obtener %s cómo %s" - #, python-format #~ msgid "PV Kernel in VDI:%d" #~ msgstr "PV Kernel en VDI:%d" -#, python-format -#~ msgid "Unexpected number of VDIs (%s) found for VM %s" -#~ msgstr "Número no esperado de VDIs (%s) encontrados para VM %s" - -#, python-format -#~ msgid "Parent %s doesn't match original parent %s, waiting for coalesce..." -#~ msgstr "" -#~ "El padre %s no concuerda con el padre original %s, esperando la unión..." - -#, python-format -#~ msgid "suspend: instance not present %s" -#~ msgstr "suspendido: instancia no encontrada: %s" - -#, python-format -#~ msgid "Introduced %s as %s." -#~ msgstr "Introducido %s cómo %s." - -#, python-format -#~ msgid "resume: instance not present %s" -#~ msgstr "reanudar: instancia no encontrada %s" - -#, python-format -#~ msgid "Instance not found %s" -#~ msgstr "instancia no encontrada %s" - -#, python-format -#~ msgid "Ignoring exception %s when getting PBDs for %s" -#~ msgstr "Ignorando excepción %s al obtener PBDs de %s" - -#, python-format -#~ msgid "Unable to create VDI on SR %s for instance %s" -#~ msgstr "Inpoisble crear VDI en SR %s para la instancia %s" - -#, python-format -#~ msgid "Unable to obtain target information %s, %s" -#~ msgstr "Imposible obtener información del destino %s, %s" - -#, python-format -#~ msgid "Ignoring exception %s when forgetting SR %s" -#~ msgstr "Ignorando excepción %s al olvidar SR %s" - -#, python-format -#~ msgid "Ignoring exception %s when unplugging PBD %s" -#~ msgstr "Ignorando excepción %s al desconectar PBD %s" - -#, python-format -#~ msgid "Attach_volume: %s, %s, %s" -#~ msgstr "Attach_volume: %s, %s, %s" - -#, python-format -#~ msgid "Unable to use SR %s for instance %s" -#~ msgstr "Imposible utilizar SR %s para la instancia %s" - -#, python-format -#~ msgid "Mountpoint %s attached to instance %s" -#~ msgstr "Punto de montaje %s unido a la instancia %s" - -#, python-format -#~ msgid "Detach_volume: %s, %s" -#~ msgstr "Detach_volume: %s, %s" - -#, python-format -#~ msgid "Mountpoint %s detached from instance %s" -#~ msgstr "Punto d emontaje %s desasociado de la instancia %s" - -#, python-format -#~ msgid "Quota exceeeded for %s, tried to create %sG volume" -#~ msgstr "Quota excedida para %s, intentando crear el volumen %sG" - #, python-format #~ msgid "Volume quota exceeded. You cannot create a volume of size %s" #~ msgstr "Quota de volumen superada. No puedes crear un volumen de tamaño %s" -#, python-format -#~ msgid "instance %s: attach failed %s, removing" -#~ msgstr "instalación %s: asociación fallida %s, eliminando" - -#, python-format -#~ msgid "instance %s: attaching volume %s to %s" -#~ msgstr "instancia %s: asociando volumen %s a %s" - -#, python-format -#~ msgid "Snapshotting VM %s with label '%s'..." -#~ msgstr "Creando snapshot de la VM %s con la etiqueta '%s'..." - -#, python-format -#~ msgid "Created snapshot %s from VM %s." -#~ msgstr "Creando snapshot %s de la VM %s" - -#, python-format -#~ msgid "Unable to Snapshot %s: %s" -#~ msgstr "Incapaz de realizar snapshot %s: %s" - -#, python-format -#~ msgid "Adding sitewide role %s to user %s" -#~ msgstr "Añadiendo rol global %s al usuario %s" - -#, python-format -#~ msgid "Removing sitewide role %s from user %s" -#~ msgstr "Eliminando rol global %s del usuario %s" - -#, python-format -#~ msgid "Del: disk %s vm %s" -#~ msgstr "Del: disco %s vm %s" - -#, python-format -#~ msgid "Spawning VM %s created %s." -#~ msgstr "Iniciando VM %s creado %s." - #~ msgid "No such process" #~ msgstr "No existe el proceso" diff --git a/po/ja.po b/po/ja.po index 179302b55..8bc282ec0 100644 --- a/po/ja.po +++ b/po/ja.po @@ -8,14 +8,14 @@ msgstr "" "Project-Id-Version: nova\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2011-02-21 10:03-0500\n" -"PO-Revision-Date: 2011-05-10 10:26+0000\n" -"Last-Translator: Akira YOSHIYAMA \n" +"PO-Revision-Date: 2011-08-23 11:22+0000\n" +"Last-Translator: Thierry Carrez \n" "Language-Team: \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2011-08-03 04:44+0000\n" -"X-Generator: Launchpad (build 13573)\n" +"X-Launchpad-Export-Date: 2011-08-24 04:47+0000\n" +"X-Generator: Launchpad (build 13697)\n" #: ../nova/scheduler/chance.py:37 ../nova/scheduler/zone.py:55 #: ../nova/scheduler/simple.py:75 ../nova/scheduler/simple.py:110 @@ -2840,44 +2840,6 @@ msgstr "ユーザ %(user)s をプロジェクト %(project)s に追加します msgid "Removing user %(user)s from project %(project)s" msgstr "ユーザ %(user)s をプロジェクト %(project)s から削除します。" -#, python-format -#~ msgid "" -#~ "%s\n" -#~ "Command: %s\n" -#~ "Exit code: %s\n" -#~ "Stdout: %r\n" -#~ "Stderr: %r" -#~ msgstr "" -#~ "%s\n" -#~ "コマンド: %s\n" -#~ "終了コード: %s\n" -#~ "標準出力: %r\n" -#~ "標準エラー出力: %r" - -#, python-format -#~ msgid "(%s) publish (key: %s) %s" -#~ msgstr "(%s) パブリッシュ (key: %s) %s" - -#, python-format -#~ msgid "Binding %s to %s with key %s" -#~ msgstr "%s を %s にキー %s でバインドします。" - -#, python-format -#~ msgid "Getting from %s: %s" -#~ msgstr "%s から %s を取得" - -#, python-format -#~ msgid "AMQP server on %s:%d is unreachable. Trying again in %d seconds." -#~ msgstr "AMQPサーバ %s:%d に接続できません。 %d 秒後に再度試みます。" - -#, python-format -#~ msgid "Starting %s node" -#~ msgstr "ノード %s を開始します。" - -#, python-format -#~ msgid "Data store %s is unreachable. Trying again in %d seconds." -#~ msgstr "データストア %s に接続できません。 %d 秒後に再接続します。" - #, python-format #~ msgid "Serving %s" #~ msgstr "%s サービスの開始" @@ -2889,166 +2851,6 @@ msgstr "ユーザ %(user)s をプロジェクト %(project)s から削除しま #~ msgid "pidfile %s does not exist. Daemon not running?\n" #~ msgstr "pidfile %s が存在しません。デーモンは実行中ですか?\n" -#, python-format -#~ msgid "Couldn't get IP, using 127.0.0.1 %s" -#~ msgstr "IPを取得できません。127.0.0.1 を %s として使います。" - -#, python-format -#~ msgid "" -#~ "Access key %s has had %d failed authentications and will be locked out for " -#~ "%d minutes." -#~ msgstr "アクセスキー %s は %d 回認証に失敗したため、%d 分間ロックされます。" - -#, python-format -#~ msgid "Authenticated Request For %s:%s)" -#~ msgstr "リクエストを認証しました: %s:%s" - -#, python-format -#~ msgid "arg: %s\t\tval: %s" -#~ msgstr "引数(arg): %s\t値(val): %s" - -#, python-format -#~ msgid "Unauthorized request for controller=%s and action=%s" -#~ msgstr "許可されていないリクエスト: controller=%s, action %sです。" - -#, python-format -#~ msgid "Adding role %s to user %s for project %s" -#~ msgstr "Adding role: ロール %s をユーザ %s、プロジェクト %s に追加します。" - -#, python-format -#~ msgid "Adding sitewide role %s to user %s" -#~ msgstr "Adding sitewide role: サイトワイドのロール %s をユーザ %s に追加します。" - -#, python-format -#~ msgid "Removing role %s from user %s for project %s" -#~ msgstr "Removing role: ロール %s をユーザ %s プロジェクト %s から削除します。" - -#, python-format -#~ msgid "Removing sitewide role %s from user %s" -#~ msgstr "Removing sitewide role: サイトワイドのロール %s をユーザ %s から削除します。" - -#, python-format -#~ msgid "Getting x509 for user: %s on project: %s" -#~ msgstr "Getting X509: x509の取得: ユーザ %s, プロジェクト %s" - -#, python-format -#~ msgid "Create project %s managed by %s" -#~ msgstr "Create project: プロジェクト %s (%s により管理される)を作成します。" - -#, python-format -#~ msgid "Adding user %s to project %s" -#~ msgstr "Adding user: ユーザ %s をプロジェクト %s に追加します。" - -#, python-format -#~ msgid "Removing user %s from project %s" -#~ msgstr "Removing user: ユーザ %s をプロジェクト %s から削除します。" - -#, python-format -#~ msgid "Unsupported API request: controller = %s,action = %s" -#~ msgstr "サポートされていないAPIリクエストです。 controller = %s,action = %s" - -#, python-format -#~ msgid "Attach volume %s to instacne %s at %s" -#~ msgstr "Attach volume: ボリューム%s をインスタンス %s にデバイス %s でアタッチします。" - -#, python-format -#~ msgid "Associate address %s to instance %s" -#~ msgstr "Associate address: アドレス %s をインスタンス %s に関連付けます。" - -#, python-format -#~ msgid "Registered image %s with id %s" -#~ msgstr "Registered image: イメージ %s をid %s で登録します。" - -#, python-format -#~ msgid "User %s is already a member of the group %s" -#~ msgstr "ユーザ %s は既にグループ %s のメンバーです。" - -#, python-format -#~ msgid "failed authorization: no project named %s (user=%s)" -#~ msgstr "Failed authorization: 認証に失敗しました。プロジェクト名 %s (ユーザ = %s) は存在しません。" - -#, python-format -#~ msgid "Failed authorization: user %s not admin and not member of project %s" -#~ msgstr "" -#~ "Failed authorization: 認証に失敗しました: ユーザ %s は管理者ではなくかつプロジェクト %s のメンバーではありません。" - -#, python-format -#~ msgid "User %s is not a member of project %s" -#~ msgstr "ユーザ %s はプロジェクト %s のメンバーではありません。" - -#, python-format -#~ msgid "Adding role %s to user %s in project %s" -#~ msgstr "Adding role: ロール %s をユーザ %s (プロジェクト %s の) に追加します。" - -#, python-format -#~ msgid "Removing role %s from user %s on project %s" -#~ msgstr "Removing role: ロール %s をユーザ %s (プロジェクト %s の)から削除します。" - -#, python-format -#~ msgid "Created project %s with manager %s" -#~ msgstr "Created project: プロジェクト %s (マネージャ %s)を作成します。" - -#, python-format -#~ msgid "Remove user %s from project %s" -#~ msgstr "Remove user: ユーザ %s をプロジェクト %s から削除します。" - -#, python-format -#~ msgid "Created user %s (admin: %r)" -#~ msgstr "Created user: ユーザ %s (admin: %r) を作成しました。" - -#, python-format -#~ msgid "Admin status set to %r for user %s" -#~ msgstr "Admin status set: 管理者ステータス %r をユーザ %s に設定します。" - -#, python-format -#~ msgid "Quota exceeeded for %s, tried to run %s instances" -#~ msgstr "%s のクオータ上限を超えました。%s インスタンスを実行しようとしました。" - -#, python-format -#~ msgid "Casting to scheduler for %s/%s's instance %s" -#~ msgstr "スケジューラに対して %s/%s のインスタンス %s を送信します。" - -#, python-format -#~ msgid "Going to try and terminate %s" -#~ msgstr "%s を終了します。" - -#, python-format -#~ msgid "Input partition size not evenly divisible by sector size: %d / %d" -#~ msgstr "インプットパーティションサイズがセクターサイズで割り切れません。 %d / %d" - -#, python-format -#~ msgid "Bytes for local storage not evenly divisible by sector size: %d / %d" -#~ msgstr "ローカルストレージのバイト数がセクターサイズで割り切れません: %d / %d" - -#, python-format -#~ msgid "check_instance_lock: arguments: |%s| |%s| |%s|" -#~ msgstr "check_instance_lock: arguments: |%s| |%s| |%s|" - -#, python-format -#~ msgid "Disassociating address %s" -#~ msgstr "アドレス %s の関連付けを解除(disassociate)しています。" - -#, python-format -#~ msgid "trying to reboot a non-running instance: %s (state: %s excepted: %s)" -#~ msgstr "実行していないインスタンスの再起動を試みます。%s (状態: %s 期待する状態: %s)" - -#, python-format -#~ msgid "" -#~ "trying to snapshot a non-running instance: %s (state: %s excepted: %s)" -#~ msgstr "実行していないインスタンスのスナップショット取得を試みます。%s (状態: %s 期待する状態: %s)" - -#, python-format -#~ msgid "instance %s: attaching volume %s to %s" -#~ msgstr "attaching volume: インスタンス %s についてボリューム %s を %s にアタッチします。" - -#, python-format -#~ msgid "instance %s: attach failed %s, removing" -#~ msgstr "インスタンス %s: %sのアタッチに失敗しました。リムーブします。" - -#, python-format -#~ msgid "Detach volume %s from mountpoint %s on instance %s" -#~ msgstr "Detach volume: ボリューム %s をマウントポイント %s (インスタンス%s)からデタッチします。" - #, python-format #~ msgid "updating %s..." #~ msgstr "%s の情報の更新…" @@ -3056,14 +2858,6 @@ msgstr "ユーザ %(user)s をプロジェクト %(project)s から削除しま #~ msgid "unexpected error during update" #~ msgstr "更新の最中に予期しないエラーが発生しました。" -#, python-format -#~ msgid "Cannot get blockstats for \"%s\" on \"%s\"" -#~ msgstr "ブロックデバイス \"%s\" の統計を \"%s\" について取得できません。" - -#, python-format -#~ msgid "Cannot get ifstats for \"%s\" on \"%s\"" -#~ msgstr "インタフェース \"%s\" の統計を \"%s\" について取得できません。" - #~ msgid "unexpected exception getting connection" #~ msgstr "接続に際し予期しないエラーが発生しました。" @@ -3071,279 +2865,14 @@ msgstr "ユーザ %(user)s をプロジェクト %(project)s から削除しま #~ msgid "Found instance: %s" #~ msgstr "インスタンス %s が見つかりました。" -#, python-format -#~ msgid "No service for %s, %s" -#~ msgstr "%s, %s のserviceが存在しません。" - -#, python-format -#~ msgid "No instance for id %s" -#~ msgstr "id %s のinstanceが存在しません。" - -#, python-format -#~ msgid "no keypair for user %s, name %s" -#~ msgstr "ユーザ %s, ネーム%s に該当するキーペアが存在しません。" - -#, python-format -#~ msgid "No volume for id %s" -#~ msgstr "id %s に該当するボリュームが存在しません。" - -#, python-format -#~ msgid "No security group named %s for project: %s" -#~ msgstr "セキュリティグループ名 %s がプロジェクト %s に存在しません。" - -#, python-format -#~ msgid "Parallax returned HTTP error %d from request for /images" -#~ msgstr "Parallax がHTTPエラー%d を /images に対するリクエストに対して返しました。" - -#, python-format -#~ msgid "Parallax returned HTTP error %d from request for /images/detail" -#~ msgstr "Parallax がHTTPエラー %d を /images/detail に対するリクエストに対して返しました" - -#, python-format -#~ msgid "IP %s leased to bad mac %s vs %s" -#~ msgstr "IP %s が期待した mac %s ではなく %s にリースされました。" - -#, python-format -#~ msgid "IP %s released from bad mac %s vs %s" -#~ msgstr "IP %s がmac %s ではない mac %s への割当から開放されました。" - -#, python-format -#~ msgid "Getting object: %s / %s" -#~ msgstr "オブジェクトの取得: %s / %s" - -#, python-format -#~ msgid "Unauthorized attempt to get object %s from bucket %s" -#~ msgstr "" -#~ "Unauthorized attempt to get object: オブジェクト %s のバケット %s からの取得は許可されていません。" - -#, python-format -#~ msgid "Putting object: %s / %s" -#~ msgstr "オブジェクトの格納:: %s / %s" - -#, python-format -#~ msgid "Unauthorized attempt to upload object %s to bucket %s" -#~ msgstr "" -#~ "Unauthorized attempt to upload: オブジェクト %s のバケット %s へのアップロードは許可されていません。" - -#, python-format -#~ msgid "Deleting object: %s / %s" -#~ msgstr "オブジェクトを削除しています。: %s / %s" - -#, python-format -#~ msgid "Toggling publicity flag of image %s %r" -#~ msgstr "Toggling publicity flag: イメージ %s の公開フラグを %r に更新します。" - -#, python-format -#~ msgid "Casting to %s %s for %s" -#~ msgstr "メッセージのcast: %s %s for %s" - -#, python-format -#~ msgid "Nested received %s, %s" -#~ msgstr "ネスとした受信: %s, %s" - -#, python-format -#~ msgid "Creating disk for %s by attaching disk file %s" -#~ msgstr "%s のディスクをディスクファイル %s をアタッチして作成します。" - -#, python-format -#~ msgid "Created switch port %s on switch %s" -#~ msgstr "スイッチポート %s をスイッチ %s に作成しました。" - -#, python-format -#~ msgid "WMI job succeeded: %s, Elapsed=%s " -#~ msgstr "WMIジョブが成功しました: %s, 経過時間=%s " - -#, python-format -#~ msgid "Del: disk %s vm %s" -#~ msgstr "Del: 削除: disk %s vm %s" - -#, python-format -#~ msgid "" -#~ "Got Info for vm %s: state=%s, mem=%s, num_cpu=%s, " -#~ "cpu_time=%s" -#~ msgstr "" -#~ "vm %s の情報の取得: state=%s, mem=%s, num_cpu=%s, cpu_time=%s" - -#, python-format -#~ msgid "Successfully changed vm state of %s to %s" -#~ msgstr "vmの状態の %s から %s への変更に成功しました。" - -#, python-format -#~ msgid "Failed to change vm state of %s to %s" -#~ msgstr "VMの状態の %s から %s への変更に失敗しました。" - -#, python-format -#~ msgid "Finished retreving %s -- placed in %s" -#~ msgstr "%s を取得しました。格納先: %s" - -#, python-format -#~ msgid "instance %s: deleting instance files %s" -#~ msgstr "インスタンス %s: インスタンスファイル %s を削除しています。" - -#, python-format -#~ msgid "data: %r, fpath: %r" -#~ msgstr "データ:%r ファイルパス: %r" - -#, python-format -#~ msgid "Contents of file %s: %r" -#~ msgstr "ファイル %s の中身: %r" - -#, python-format -#~ msgid "instance %s: injecting key into image %s" -#~ msgstr "インスタンス %s にキー %s をインジェクトします。" - -#, python-format -#~ msgid "instance %s: injecting net into image %s" -#~ msgstr "インスタンス %s のネットワーク設定をイメージ %s にインジェクトします。" - -#, python-format -#~ msgid "instance %s: ignoring error injecting data into image %s (%s)" -#~ msgstr "インスタンス %s: データをイメージ %s にインジェクトする際にエラーが発生しました。(%s)" - -#, python-format -#~ msgid "Task [%s] %s status: success %s" -#~ msgstr "タスク [%s] %s ステータス: success %s" - -#, python-format -#~ msgid "Task [%s] %s status: %s %s" -#~ msgstr "タスク [%s] %s ステータス: %s %s" - -#, python-format -#~ msgid "%s: _db_content => %s" -#~ msgstr "%s: _db_content => %s" - -#, python-format -#~ msgid "Calling %s %s" -#~ msgstr "呼び出し: %s %s" - -#, python-format -#~ msgid "Created VM %s as %s." -#~ msgstr "VM %s を %s として作成しました。" - -#, python-format -#~ msgid "Creating VBD for VM %s, VDI %s ... " -#~ msgstr "VM %s, VDI %s のVBDを作成します… " - -#, python-format -#~ msgid "Created VBD %s for VM %s, VDI %s." -#~ msgstr "VBD %s を VM %s, VDI %s に対して作成しました。" - -#, python-format -#~ msgid "Creating VIF for VM %s, network %s." -#~ msgstr "VM %s, ネットワーク %s を作成します。" - -#, python-format -#~ msgid "Created VIF %s for VM %s, network %s." -#~ msgstr "VIF %s を VM %s, ネットワーク %s に作成しました。" - -#, python-format -#~ msgid "Snapshotting VM %s with label '%s'..." -#~ msgstr "VM %s のスナップショットをラベル '%s' で作成します。" - -#, python-format -#~ msgid "Created snapshot %s from VM %s." -#~ msgstr "スナップショット %s を VM %s について作成しました。" - -#, python-format -#~ msgid "Asking xapi to upload %s as '%s'" -#~ msgstr "xapiに対して %s を '%s' としてアップロードするように指示します。" - -#, python-format -#~ msgid "Asking xapi to fetch %s as %s" -#~ msgstr "xapi に対して %s を %s として取得するように指示します。" - #, python-format #~ msgid "PV Kernel in VDI:%d" #~ msgstr "VDIのPV Kernel: %d" -#, python-format -#~ msgid "VHD %s has parent %s" -#~ msgstr "VHD %s のペアレントは %s です。" - -#, python-format -#~ msgid "Parent %s doesn't match original parent %s, waiting for coalesce..." -#~ msgstr "ペアレント %s がオリジナルのペアレント %s と一致しません。合致するのを待ちます…" - -#, python-format -#~ msgid "Unexpected number of VDIs (%s) found for VM %s" -#~ msgstr "予期しない数 (%s) のVDIがVM %s に存在します。" - -#, python-format -#~ msgid "Spawning VM %s created %s." -#~ msgstr "VM %s の生成(spawning) により %s を作成しました。" - -#, python-format -#~ msgid "Unable to Snapshot %s: %s" -#~ msgstr "%s のスナップショットに失敗しました: %s" - -#, python-format -#~ msgid "suspend: instance not present %s" -#~ msgstr "suspend: インスタンス %s は存在しません。" - -#, python-format -#~ msgid "resume: instance not present %s" -#~ msgstr "resume: インスタンス %s は存在しません。" - -#, python-format -#~ msgid "Instance not found %s" -#~ msgstr "インスタンス %s が見つかりません。" - -#, python-format -#~ msgid "Introduced %s as %s." -#~ msgstr "%s を %s として introduce しました。" - -#, python-format -#~ msgid "Ignoring exception %s when getting PBDs for %s" -#~ msgstr "例外 %s が %s のPBDを取得する際に発生しましたが無視します。" - -#, python-format -#~ msgid "Ignoring exception %s when unplugging PBD %s" -#~ msgstr "例外 %s が %s のPBDをunplugする際に発生しましたが無視します。" - -#, python-format -#~ msgid "Ignoring exception %s when forgetting SR %s" -#~ msgstr "例外 %s がSR %s をforgetする際に発生しましたが無視します。" - -#, python-format -#~ msgid "Unable to obtain target information %s, %s" -#~ msgstr "ターゲットの情報を取得できません。 %s, %s" - -#, python-format -#~ msgid "Attach_volume: %s, %s, %s" -#~ msgstr "Attach_volume: ボリュームのアタッチ: %s, %s, %s" - -#, python-format -#~ msgid "Unable to create VDI on SR %s for instance %s" -#~ msgstr "SR %s にインスタンス %s のVDIを作成できません。" - -#, python-format -#~ msgid "Unable to use SR %s for instance %s" -#~ msgstr "SR %s をインスタンス %s に対して利用できません。" - -#, python-format -#~ msgid "Mountpoint %s attached to instance %s" -#~ msgstr "マウントポイント %s をインスタンス %s にアタッチしました。" - -#, python-format -#~ msgid "Detach_volume: %s, %s" -#~ msgstr "Detach_volume: ボリュームのデタッチ: %s, %s" - -#, python-format -#~ msgid "Mountpoint %s detached from instance %s" -#~ msgstr "マウントポイント %s をインスタンス %s からデタッチしました。" - -#, python-format -#~ msgid "Quota exceeeded for %s, tried to create %sG volume" -#~ msgstr "%sのクオータを超えています。サイズ %sG のボリュームの作成を行おうとしました。" - #, python-format #~ msgid "Volume quota exceeded. You cannot create a volume of size %s" #~ msgstr "ボリュームのクオータを超えています。%sの大きさのボリュームは作成できません。" -#, python-format -#~ msgid "volume %s: creating lv of size %sG" -#~ msgstr "ボリューム%sの%sGのlv (論理ボリューム) を作成します。" - #~ msgid "Wrong number of arguments." #~ msgstr "引数の数が異なります。" diff --git a/po/pt_BR.po b/po/pt_BR.po index d6d57a9b1..bff1135c6 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -8,14 +8,14 @@ msgstr "" "Project-Id-Version: nova\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2011-02-21 10:03-0500\n" -"PO-Revision-Date: 2011-07-25 17:40+0000\n" +"PO-Revision-Date: 2011-08-23 11:23+0000\n" "Last-Translator: msinhore \n" "Language-Team: Brazilian Portuguese \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2011-08-03 04:44+0000\n" -"X-Generator: Launchpad (build 13573)\n" +"X-Launchpad-Export-Date: 2011-08-24 04:47+0000\n" +"X-Generator: Launchpad (build 13697)\n" #: ../nova/scheduler/chance.py:37 ../nova/scheduler/zone.py:55 #: ../nova/scheduler/simple.py:75 ../nova/scheduler/simple.py:110 @@ -2824,47 +2824,6 @@ msgstr "" msgid "Removing user %(user)s from project %(project)s" msgstr "" -#, python-format -#~ msgid "" -#~ "%s\n" -#~ "Command: %s\n" -#~ "Exit code: %s\n" -#~ "Stdout: %r\n" -#~ "Stderr: %r" -#~ msgstr "" -#~ "%s\n" -#~ "Comando: %s\n" -#~ "Código de retorno: %s\n" -#~ "Stdout: %r\n" -#~ "Stderr: %r" - -#, python-format -#~ msgid "(%s) publish (key: %s) %s" -#~ msgstr "(%s) publicar (key: %s) %s" - -#, python-format -#~ msgid "AMQP server on %s:%d is unreachable. Trying again in %d seconds." -#~ msgstr "" -#~ "Servidor AMQP em %s:%d inatingível. Tentando novamente em %d segundos." - -#, python-format -#~ msgid "Binding %s to %s with key %s" -#~ msgstr "Atribuindo %s para %s com chave %s" - -#, python-format -#~ msgid "Getting from %s: %s" -#~ msgstr "Obtendo de %s: %s" - -#, python-format -#~ msgid "Starting %s node" -#~ msgstr "Iniciando nó %s" - -#, python-format -#~ msgid "Data store %s is unreachable. Trying again in %d seconds." -#~ msgstr "" -#~ "Repositório de dados %s não pode ser atingido. Tentando novamente em %d " -#~ "segundos." - #~ msgid "Full set of FLAGS:" #~ msgstr "Conjunto completo de FLAGS:" @@ -2876,115 +2835,6 @@ msgstr "" #~ msgid "Serving %s" #~ msgstr "Servindo %s" -#, python-format -#~ msgid "Couldn't get IP, using 127.0.0.1 %s" -#~ msgstr "Não foi possível obter IP, usando 127.0.0.1 %s" - -#, python-format -#~ msgid "" -#~ "Access key %s has had %d failed authentications and will be locked out for " -#~ "%d minutes." -#~ msgstr "" -#~ "Chave de acesso %s tem %d falhas de autenticação e vai ser bloqueada por %d " -#~ "minutos." - -#, python-format -#~ msgid "arg: %s\t\tval: %s" -#~ msgstr "argumento: %s\t\tvalor: %s" - -#, python-format -#~ msgid "Authenticated Request For %s:%s)" -#~ msgstr "Pedido de Autenticação Para: %s:%s" - -#, python-format -#~ msgid "Adding sitewide role %s to user %s" -#~ msgstr "Adicionando papel em todo site %s ao usuário %s" - -#, python-format -#~ msgid "Adding role %s to user %s for project %s" -#~ msgstr "Adicionando papel %s ao usuário %s para o projeto %s" - -#, python-format -#~ msgid "Unauthorized request for controller=%s and action=%s" -#~ msgstr "Requisição não autorizada para controlador=%s e ação=%s" - -#, python-format -#~ msgid "Removing role %s from user %s for project %s" -#~ msgstr "Removendo papel %s do usuário %s para o projeto %s" - -#, python-format -#~ msgid "Getting x509 for user: %s on project: %s" -#~ msgstr "Obtendo x509 para usuário: %s do projeto: %s" - -#, python-format -#~ msgid "Create project %s managed by %s" -#~ msgstr "Criar projeto %s gerenciado por %s" - -#, python-format -#~ msgid "Removing user %s from project %s" -#~ msgstr "Excluindo usuário %s do projeto %s" - -#, python-format -#~ msgid "Adding user %s to project %s" -#~ msgstr "Adicionando usuário %s ao projeto %s" - -#, python-format -#~ msgid "Unsupported API request: controller = %s,action = %s" -#~ msgstr "Requisição de API não suportada: controlador = %s,ação = %s" - -#, python-format -#~ msgid "Removing sitewide role %s from user %s" -#~ msgstr "Removendo papel %s em todo site do usuário %s" - -#, python-format -#~ msgid "Associate address %s to instance %s" -#~ msgstr "Atribuir endereço %s à instância %s" - -#, python-format -#~ msgid "Attach volume %s to instacne %s at %s" -#~ msgstr "Anexar volume %s para instância %s em %s" - -#, python-format -#~ msgid "Registered image %s with id %s" -#~ msgstr "Registrada imagem %s com id %s" - -#, python-format -#~ msgid "User %s is already a member of the group %s" -#~ msgstr "Usuário %s já pertence ao grupo %s" - -#, python-format -#~ msgid "User %s is not a member of project %s" -#~ msgstr "Usuário %s não é membro do projeto %s" - -#, python-format -#~ msgid "failed authorization: no project named %s (user=%s)" -#~ msgstr "falha de autorização: nenhum projeto de nome %s (usuário=%s)" - -#, python-format -#~ msgid "Failed authorization: user %s not admin and not member of project %s" -#~ msgstr "" -#~ "Falha de autorização: usuário %s não é administrador nem membro do projeto %s" - -#, python-format -#~ msgid "Created project %s with manager %s" -#~ msgstr "Criado projeto %s com gerente %s" - -#, python-format -#~ msgid "Removing role %s from user %s on project %s" -#~ msgstr "Removendo papel %s do usuário %s no projeto %s" - -#, python-format -#~ msgid "Adding role %s to user %s in project %s" -#~ msgstr "Adicionando papel %s ao usuário %s no projeto %s" - -#, python-format -#~ msgid "Remove user %s from project %s" -#~ msgstr "Remover usuário %s do projeto %s" - -#, python-format -#~ msgid "Created user %s (admin: %r)" -#~ msgstr "Criado usuário %s (administrador: %r)" - #~ msgid "No such process" #~ msgstr "Processo inexistente" diff --git a/po/ru.po b/po/ru.po index 746db964a..951571d9e 100644 --- a/po/ru.po +++ b/po/ru.po @@ -8,14 +8,14 @@ msgstr "" "Project-Id-Version: nova\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2011-02-21 10:03-0500\n" -"PO-Revision-Date: 2011-07-09 07:20+0000\n" -"Last-Translator: ilya kislicyn \n" +"PO-Revision-Date: 2011-08-23 11:22+0000\n" +"Last-Translator: Thierry Carrez \n" "Language-Team: Russian \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2011-08-03 04:44+0000\n" -"X-Generator: Launchpad (build 13573)\n" +"X-Launchpad-Export-Date: 2011-08-24 04:47+0000\n" +"X-Generator: Launchpad (build 13697)\n" #: ../nova/scheduler/chance.py:37 ../nova/scheduler/zone.py:55 #: ../nova/scheduler/simple.py:75 ../nova/scheduler/simple.py:110 @@ -2793,58 +2793,6 @@ msgstr "" #~ msgid "Starting %s" #~ msgstr "Запускается %s" -#, python-format -#~ msgid "arg: %s\t\tval: %s" -#~ msgstr "arg: %s\t\tval: %s" - -#, python-format -#~ msgid "Adding role %s to user %s for project %s" -#~ msgstr "Добавление роли %s для пользователя %s для проекта %s" - -#, python-format -#~ msgid "Removing role %s from user %s for project %s" -#~ msgstr "Удаление роли %s пользователя %s для проекта %s" - -#, python-format -#~ msgid "Create project %s managed by %s" -#~ msgstr "Создать проект %s под управлением %s" - -#, python-format -#~ msgid "Removing user %s from project %s" -#~ msgstr "Удаление пользователя %s с проекта %s" - -#, python-format -#~ msgid "Adding user %s to project %s" -#~ msgstr "Добавление пользователя %s к проекту %s" - -#, python-format -#~ msgid "User %s is already a member of the group %s" -#~ msgstr "Пользователь %s уже член группы %s" - -#, python-format -#~ msgid "User %s is not a member of project %s" -#~ msgstr "Пользователь %s не является членом группы %s" - -#, python-format -#~ msgid "Created project %s with manager %s" -#~ msgstr "Создан проект %s под управлением %s" - -#, python-format -#~ msgid "Removing role %s from user %s on project %s" -#~ msgstr "Удаление роли %s пользователя %s в проекте %s" - -#, python-format -#~ msgid "Remove user %s from project %s" -#~ msgstr "Удалить пользователя %s из проекта %s" - -#, python-format -#~ msgid "Created user %s (admin: %r)" -#~ msgstr "Создан пользователь %s (администратор: %r)" - -#, python-format -#~ msgid "Adding role %s to user %s in project %s" -#~ msgstr "Добавление роли %s для пользователя %s в проект %s" - #~ msgid "unexpected error during update" #~ msgstr "неожиданная ошибка во время обновления" @@ -2852,75 +2800,9 @@ msgstr "" #~ msgid "updating %s..." #~ msgstr "обновление %s..." -#, python-format -#~ msgid "Getting object: %s / %s" -#~ msgstr "Получение объекта: %s / %s" - -#, python-format -#~ msgid "Deleting object: %s / %s" -#~ msgstr "Удаление объекта: %s / %s" - -#, python-format -#~ msgid "%s: _db_content => %s" -#~ msgstr "%s: _db_content => %s" - -#, python-format -#~ msgid "Calling %s %s" -#~ msgstr "Звонок %s %s" - -#, python-format -#~ msgid "" -#~ "%s\n" -#~ "Command: %s\n" -#~ "Exit code: %s\n" -#~ "Stdout: %r\n" -#~ "Stderr: %r" -#~ msgstr "" -#~ "%s\n" -#~ "Команда: %s\n" -#~ "Код завершения: %s\n" -#~ "Stdout: %r\n" -#~ "Stderr: %r" - -#, python-format -#~ msgid "AMQP server on %s:%d is unreachable. Trying again in %d seconds." -#~ msgstr "AMQP сервер %s:%d недоступен. Повторная попытка через %d секунд." - -#, python-format -#~ msgid "Putting object: %s / %s" -#~ msgstr "Вставка объекта: %s / %s" - -#, python-format -#~ msgid "Starting %s node" -#~ msgstr "Запускается нода %s" - -#, python-format -#~ msgid "Data store %s is unreachable. Trying again in %d seconds." -#~ msgstr "Хранилище данных %s недоступно. Повторная попытка через %d секунд." - -#, python-format -#~ msgid "Couldn't get IP, using 127.0.0.1 %s" -#~ msgstr "Не удалось получить IP, используем 127.0.0.1 %s" - #, python-format #~ msgid "pidfile %s does not exist. Daemon not running?\n" #~ msgstr "pidfile %s не обнаружен. Демон не запущен?\n" -#, python-format -#~ msgid "Getting from %s: %s" -#~ msgstr "Получение из %s: %s" - -#, python-format -#~ msgid "" -#~ "Access key %s has had %d failed authentications and will be locked out for " -#~ "%d minutes." -#~ msgstr "" -#~ "Ключ доступа %s имеет %d неудачных попыток аутентификации и будет " -#~ "заблокирован на %d минут." - -#, python-format -#~ msgid "Authenticated Request For %s:%s)" -#~ msgstr "Запрос аутентификации для %s:%s)" - #~ msgid "Wrong number of arguments." #~ msgstr "Неверное число аргументов." diff --git a/po/tl.po b/po/tl.po index 84e9d26e6..3c7cd792f 100644 --- a/po/tl.po +++ b/po/tl.po @@ -8,14 +8,14 @@ msgstr "" "Project-Id-Version: nova\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2011-02-21 10:03-0500\n" -"PO-Revision-Date: 2011-02-17 03:24+0000\n" -"Last-Translator: John Michael Baterna \n" +"PO-Revision-Date: 2011-08-23 11:21+0000\n" +"Last-Translator: Thierry Carrez \n" "Language-Team: Tagalog \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2011-08-03 04:44+0000\n" -"X-Generator: Launchpad (build 13573)\n" +"X-Launchpad-Export-Date: 2011-08-24 04:47+0000\n" +"X-Generator: Launchpad (build 13697)\n" #: ../nova/scheduler/chance.py:37 ../nova/scheduler/zone.py:55 #: ../nova/scheduler/simple.py:75 ../nova/scheduler/simple.py:110 @@ -2789,8 +2789,3 @@ msgstr "" #, python-format msgid "Removing user %(user)s from project %(project)s" msgstr "" - -#, python-format -#~ msgid "AMQP server on %s:%d is unreachable. Trying again in %d seconds." -#~ msgstr "" -#~ "Hindi makita o maabot ang AMQP server sa %s:%d. Muling subukan sa %d segundo." diff --git a/po/uk.po b/po/uk.po index bcc53fed3..d040eaf69 100644 --- a/po/uk.po +++ b/po/uk.po @@ -8,14 +8,14 @@ msgstr "" "Project-Id-Version: nova\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2011-02-21 10:03-0500\n" -"PO-Revision-Date: 2011-02-03 22:02+0000\n" -"Last-Translator: Wladimir Rossinski \n" +"PO-Revision-Date: 2011-08-23 11:21+0000\n" +"Last-Translator: Thierry Carrez \n" "Language-Team: Ukrainian \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2011-08-03 04:44+0000\n" -"X-Generator: Launchpad (build 13573)\n" +"X-Launchpad-Export-Date: 2011-08-24 04:47+0000\n" +"X-Generator: Launchpad (build 13697)\n" #: ../nova/scheduler/chance.py:37 ../nova/scheduler/zone.py:55 #: ../nova/scheduler/simple.py:75 ../nova/scheduler/simple.py:110 @@ -2788,10 +2788,6 @@ msgstr "" msgid "Removing user %(user)s from project %(project)s" msgstr "" -#, python-format -#~ msgid "AMQP server on %s:%d is unreachable. Trying again in %d seconds." -#~ msgstr "AMQP сервер %s:%d недоступний. Спроба під'єднання через %d секунд." - #, python-format #~ msgid "Starting %s" #~ msgstr "Запускається %s" @@ -2799,33 +2795,3 @@ msgstr "" #, python-format #~ msgid "Serving %s" #~ msgstr "Обслуговування %s" - -#, python-format -#~ msgid "Couldn't get IP, using 127.0.0.1 %s" -#~ msgstr "Не вдалось отримати IP, використовуючи 127.0.0.1 %s" - -#, python-format -#~ msgid "Removing user %s from project %s" -#~ msgstr "Вилучення користувача %s з проекту %s" - -#, python-format -#~ msgid "Adding user %s to project %s" -#~ msgstr "Долучення користувача %s до проекту %s" - -#, python-format -#~ msgid "" -#~ "%s\n" -#~ "Command: %s\n" -#~ "Exit code: %s\n" -#~ "Stdout: %r\n" -#~ "Stderr: %r" -#~ msgstr "" -#~ "%s\n" -#~ "Команда: %s\n" -#~ "Код завершення: %s\n" -#~ "Stdout: %r\n" -#~ "Stderr: %r" - -#, python-format -#~ msgid "Getting from %s: %s" -#~ msgstr "Отримання з %s: %s" -- cgit From 358c346a7d01336f23b21a18f33c3213b3672f0a Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Thu, 25 Aug 2011 15:53:13 -0500 Subject: updated libvirt tests to use fake_network_info --- nova/network/manager.py | 2 +- nova/tests/fake_network_info.py | 30 ++++++++++++++++++++----- nova/tests/test_libvirt.py | 49 +++++++++++++++++++++++------------------ 3 files changed, 53 insertions(+), 28 deletions(-) diff --git a/nova/network/manager.py b/nova/network/manager.py index dcd5aad9a..9a4b09ad8 100644 --- a/nova/network/manager.py +++ b/nova/network/manager.py @@ -483,7 +483,6 @@ class NetworkManager(manager.SchedulerDependentManager): 'bridge': network['bridge'], 'id': network['id'], 'cidr': network['cidr'], - 'cidr_v6': network['cidr_v6'], 'injected': network['injected'], 'vlan': network['vlan'], 'bridge_interface': network['bridge_interface'], @@ -509,6 +508,7 @@ class NetworkManager(manager.SchedulerDependentManager): if network['cidr_v6']: info['ip6s'] = [ip6_dict()] + network_dict['cidr_v6'] = network['cidr_v6'], # TODO(tr3buchet): handle ip6 routes here as well if network['gateway_v6']: info['gateway6'] = network['gateway_v6'] diff --git a/nova/tests/fake_network_info.py b/nova/tests/fake_network_info.py index 072585195..0bf117a90 100644 --- a/nova/tests/fake_network_info.py +++ b/nova/tests/fake_network_info.py @@ -16,11 +16,13 @@ # under the License. from nova import db +from nova import flags from nova import test from nova.network import manager as network_manager HOST = "testhost" +FLAGS = flags.FLAGS class FakeModel(dict): @@ -32,15 +34,14 @@ class FakeModel(dict): return self[name] -def fake_network(n): - return {'id': n, +def fake_network(n, ipv6=None): + if ipv6 = None: + ipv6 = Flags.use_ipv6 + rval = {'id': n, 'label': 'test%d' % n, 'injected': False, 'multi_host': False, 'cidr': '192.168.%d.0/24' % n, - 'cidr_v6': '2001:db8:0:%x::/64' % n, - 'gateway_v6': '2001:db8:0:%x::1' % n, - 'netmask_v6': '64', 'netmask': '255.255.255.0', 'bridge': 'fake_br%d' % n, 'bridge_interface': 'fake_eth%d' % n, @@ -52,6 +53,10 @@ def fake_network(n): 'host': None, 'project_id': 'fake_project', 'vpn_public_address': '192.168.%d.2' % n} + if ipv6: + rval['cidr_v6'] = '2001:db8:0:%x::/64' % n + rval['gateway_v6'] = '2001:db8:0:%x::1' % n + rval['netmask_v6'] = '64' def fixed_ips(num_networks, num_ips, num_floating_ips=0): @@ -91,7 +96,22 @@ def vifs(n): 'instance_id': 0} +def ipv4_like(ip, s): + ip = ip.split('.') + s = s.split('.') + + for i, octet in enumerate(s): + if octet == '*': + continue + if octet != ip[i]: + return False + return True + + def fake_get_instance_nw_info(stubs, n=1, ips_per_vif=2): + # stubs is the self.stubs from the test + # 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) network.db = db diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py index 6a213b4f0..1b5a2d55d 100644 --- a/nova/tests/test_libvirt.py +++ b/nova/tests/test_libvirt.py @@ -36,6 +36,7 @@ from nova.api.ec2 import cloud from nova.compute import power_state from nova.virt.libvirt import connection from nova.virt.libvirt import firewall +from nova.tests import fake_network_info libvirt = None FLAGS = flags.FLAGS @@ -45,7 +46,8 @@ def _concurrency(wait, done, target): wait.wait() done.send() - +_fake_network_info = fake_network_info.fake_get_instance_nw_info +_ipv4_like = fake_network_info.ipv4_like def _create_network_info(count=1, ipv6=None): if ipv6 is None: ipv6 = FLAGS.use_ipv6 @@ -276,12 +278,12 @@ class LibvirtConnTestCase(test.TestCase): instance_ref = db.instance_create(self.context, self.test_instance) result = conn._prepare_xml_info(instance_ref, - _create_network_info(), + _fake_network_info(self.stubs, 1), False) self.assertTrue(len(result['nics']) == 1) result = conn._prepare_xml_info(instance_ref, - _create_network_info(2), + _fake_network_info(self.stubs, 2), False) self.assertTrue(len(result['nics']) == 2) @@ -406,7 +408,7 @@ class LibvirtConnTestCase(test.TestCase): def test_multi_nic(self): instance_data = dict(self.test_instance) - network_info = _create_network_info(2) + network_info = _fake_network_info(self.stubs, 2) conn = connection.LibvirtConnection(True) instance_ref = db.instance_create(self.context, instance_data) xml = conn.to_xml(instance_ref, network_info, False) @@ -416,9 +418,9 @@ class LibvirtConnTestCase(test.TestCase): parameters = interfaces[0].findall('./filterref/parameter') self.assertEquals(interfaces[0].get('type'), 'bridge') self.assertEquals(parameters[0].get('name'), 'IP') - self.assertEquals(parameters[0].get('value'), '10.11.12.13') + self.assertTrue(_ipv4_like(parameters[0].get('value'), '192.168') self.assertEquals(parameters[1].get('name'), 'DHCPSERVER') - self.assertEquals(parameters[1].get('value'), '10.0.0.1') + self.assertTrue(_ipv4_like(parameters[1].get('value'), '192.168.*.1') def _check_xml_and_container(self, instance): user_context = context.RequestContext(self.user_id, @@ -432,7 +434,7 @@ class LibvirtConnTestCase(test.TestCase): uri = conn.get_uri() self.assertEquals(uri, 'lxc:///') - network_info = _create_network_info() + network_info = _fake_network_info(self.stubs, 1) xml = conn.to_xml(instance_ref, network_info) tree = xml_to_tree(xml) @@ -503,9 +505,11 @@ class LibvirtConnTestCase(test.TestCase): common_checks = [ (lambda t: t.find('.').tag, 'domain'), (lambda t: t.find(parameter).get('name'), 'IP'), - (lambda t: t.find(parameter).get('value'), '10.11.12.13'), + (lambda t: _ipv4_like(t.find(parameter).get('value'), '192.168'), + True), (lambda t: t.findall(parameter)[1].get('name'), 'DHCPSERVER'), - (lambda t: t.findall(parameter)[1].get('value'), '10.0.0.1'), + (lambda t: _ipv4_like(t.findall(parameter)[1].get('value'), + '192.168.*.1'), True), (lambda t: t.find('./devices/serial/source').get( 'path').split('/')[1], 'console.log'), (lambda t: t.find('./memory').text, '2097152')] @@ -530,7 +534,7 @@ class LibvirtConnTestCase(test.TestCase): uri = conn.get_uri() self.assertEquals(uri, expected_uri) - network_info = _create_network_info() + network_info = _fake_network_info(self.stubs, 1) xml = conn.to_xml(instance_ref, network_info, rescue) tree = xml_to_tree(xml) for i, (check, expected_result) in enumerate(checks): @@ -645,7 +649,7 @@ class LibvirtConnTestCase(test.TestCase): self.create_fake_libvirt_mock() instance_ref = db.instance_create(self.context, self.test_instance) - network_info = _create_network_info() + network_info = _fake_network_info(self.stubs, 1) # Start test self.mox.ReplayAll() @@ -828,7 +832,7 @@ class LibvirtConnTestCase(test.TestCase): conn.firewall_driver.setattr('setup_basic_filtering', fake_none) conn.firewall_driver.setattr('prepare_instance_filter', fake_none) - network_info = _create_network_info() + network_info = _fake_network_info(self.stubs, 1) try: conn.spawn(self.context, instance, network_info) @@ -1062,7 +1066,7 @@ class IptablesFirewallTestCase(test.TestCase): from nova.network import linux_net linux_net.iptables_manager.execute = fake_iptables_execute - network_info = _create_network_info() + network_info = _fake_network_info(self.stubs, 1) self.fw.prepare_instance_filter(instance_ref, network_info) self.fw.apply_instance_filter(instance_ref, network_info) @@ -1076,7 +1080,8 @@ class IptablesFirewallTestCase(test.TestCase): instance_chain = None for rule in self.out_rules: # This is pretty crude, but it'll do for now - if '-d 10.11.12.13 -j' in rule: + # last two octets change + if re.search('-d 192.168.[0-9]{1,3}.[0-9]{1,3} -j', rule): instance_chain = rule.split(' ')[-1] break self.assertTrue(instance_chain, "The instance chain wasn't added") @@ -1112,14 +1117,14 @@ class IptablesFirewallTestCase(test.TestCase): def test_filters_for_instance_with_ip_v6(self): self.flags(use_ipv6=True) - network_info = _create_network_info() + network_info = _fake_network_info(self.stubs, 1) rulesv4, rulesv6 = self.fw._filters_for_instance("fake", network_info) self.assertEquals(len(rulesv4), 2) self.assertEquals(len(rulesv6), 3) def test_filters_for_instance_without_ip_v6(self): self.flags(use_ipv6=False) - network_info = _create_network_info() + network_info = _fake_network_info(self.stubs, 1) rulesv4, rulesv6 = self.fw._filters_for_instance("fake", network_info) self.assertEquals(len(rulesv4), 2) self.assertEquals(len(rulesv6), 0) @@ -1129,7 +1134,7 @@ class IptablesFirewallTestCase(test.TestCase): ipv6_rules_per_network = 3 networks_count = 5 instance_ref = self._create_instance_ref() - network_info = _create_network_info(networks_count) + network_info = _fake_network_info(self.stubs, networks_count) ipv4_len = len(self.fw.iptables.ipv4['filter'].rules) ipv6_len = len(self.fw.iptables.ipv6['filter'].rules) inst_ipv4, inst_ipv6 = self.fw.instance_rules(instance_ref, @@ -1169,7 +1174,7 @@ class IptablesFirewallTestCase(test.TestCase): instance_ref = self._create_instance_ref() _setup_networking(instance_ref['id'], self.test_ip) - network_info = _create_network_info() + network_info = _fake_network_info(self.stubs, 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) @@ -1190,7 +1195,7 @@ class IptablesFirewallTestCase(test.TestCase): # create a firewall via setup_basic_filtering like libvirt_conn.spawn # should have a chain with 0 rules - network_info = _create_network_info(1) + network_info = _fake_network_info(self.stubs, 1) self.fw.setup_basic_filtering(instance_ref, network_info) self.assertTrue('provider' in self.fw.iptables.ipv4['filter'].chains) rules = [rule for rule in self.fw.iptables.ipv4['filter'].rules @@ -1390,7 +1395,7 @@ class NWFilterTestCase(test.TestCase): self.security_group.id) instance = db.instance_get(self.context, inst_id) - network_info = _create_network_info() + network_info = _fake_network_info(self.stubs, 1) self.fw.setup_basic_filtering(instance, network_info) self.fw.prepare_instance_filter(instance, network_info) self.fw.apply_instance_filter(instance, network_info) @@ -1400,7 +1405,7 @@ class NWFilterTestCase(test.TestCase): def test_create_network_filters(self): instance_ref = self._create_instance() - network_info = _create_network_info(3) + network_info = _fake_network_info(self.stubs, 3) result = self.fw._create_network_filters(instance_ref, network_info, "fake") @@ -1424,7 +1429,7 @@ class NWFilterTestCase(test.TestCase): instance = db.instance_get(self.context, inst_id) _setup_networking(instance_ref['id'], self.test_ip) - network_info = _create_network_info() + network_info = _fake_network_info(self.stubs, 1) self.fw.setup_basic_filtering(instance, network_info) self.fw.prepare_instance_filter(instance, network_info) self.fw.apply_instance_filter(instance, network_info) -- cgit From 416b270374d64f976c91a3efb74dcb467bfbcc8c Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Thu, 25 Aug 2011 16:02:52 -0500 Subject: fixed a couple of syntax errors --- nova/tests/fake_network_info.py | 2 +- nova/tests/test_libvirt.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/nova/tests/fake_network_info.py b/nova/tests/fake_network_info.py index 0bf117a90..113647d7f 100644 --- a/nova/tests/fake_network_info.py +++ b/nova/tests/fake_network_info.py @@ -35,7 +35,7 @@ class FakeModel(dict): def fake_network(n, ipv6=None): - if ipv6 = None: + if ipv6 == None: ipv6 = Flags.use_ipv6 rval = {'id': n, 'label': 'test%d' % n, diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py index 1b5a2d55d..06ad7d13a 100644 --- a/nova/tests/test_libvirt.py +++ b/nova/tests/test_libvirt.py @@ -418,9 +418,9 @@ class LibvirtConnTestCase(test.TestCase): parameters = interfaces[0].findall('./filterref/parameter') self.assertEquals(interfaces[0].get('type'), 'bridge') self.assertEquals(parameters[0].get('name'), 'IP') - self.assertTrue(_ipv4_like(parameters[0].get('value'), '192.168') + self.assertTrue(_ipv4_like(parameters[0].get('value'), '192.168')) self.assertEquals(parameters[1].get('name'), 'DHCPSERVER') - self.assertTrue(_ipv4_like(parameters[1].get('value'), '192.168.*.1') + self.assertTrue(_ipv4_like(parameters[1].get('value'), '192.168.*.1')) def _check_xml_and_container(self, instance): user_context = context.RequestContext(self.user_id, -- cgit From 5daa66cb91f95ff341ce5ec762fb1060f22e587f Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Thu, 25 Aug 2011 16:10:25 -0500 Subject: typo --- nova/tests/fake_network_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/tests/fake_network_info.py b/nova/tests/fake_network_info.py index 113647d7f..295ac8a97 100644 --- a/nova/tests/fake_network_info.py +++ b/nova/tests/fake_network_info.py @@ -36,7 +36,7 @@ class FakeModel(dict): def fake_network(n, ipv6=None): if ipv6 == None: - ipv6 = Flags.use_ipv6 + ipv6 = FLAGS.use_ipv6 rval = {'id': n, 'label': 'test%d' % n, 'injected': False, -- cgit From 590e7445d937485280e60743318000d0bfc80236 Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Thu, 25 Aug 2011 16:49:09 -0500 Subject: forget a return --- nova/tests/fake_network_info.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nova/tests/fake_network_info.py b/nova/tests/fake_network_info.py index 295ac8a97..b05cf7c95 100644 --- a/nova/tests/fake_network_info.py +++ b/nova/tests/fake_network_info.py @@ -58,6 +58,8 @@ def fake_network(n, ipv6=None): rval['gateway_v6'] = '2001:db8:0:%x::1' % n rval['netmask_v6'] = '64' + return rval + def fixed_ips(num_networks, num_ips, num_floating_ips=0): for network in xrange(num_networks): -- cgit From 9df1fe10f39d4b1b4753a5c5366e68dd1efa9e77 Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Thu, 25 Aug 2011 17:04:26 -0500 Subject: altered fake network model --- nova/tests/fake_network_info.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/nova/tests/fake_network_info.py b/nova/tests/fake_network_info.py index b05cf7c95..47f9abd05 100644 --- a/nova/tests/fake_network_info.py +++ b/nova/tests/fake_network_info.py @@ -42,10 +42,13 @@ def fake_network(n, ipv6=None): 'injected': False, 'multi_host': False, 'cidr': '192.168.%d.0/24' % n, + 'cidr_v6': None, 'netmask': '255.255.255.0', + 'netmask_v6': None, 'bridge': 'fake_br%d' % n, 'bridge_interface': 'fake_eth%d' % n, 'gateway': '192.168.%d.1' % n, + 'gateway_v6': None, 'broadcast': '192.168.%d.255' % n, 'dns1': '192.168.%d.3' % n, 'dns2': '192.168.%d.4' % n, -- cgit From a7e7be67a79fab4348f68c5738656f1ac401c39a Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Fri, 26 Aug 2011 12:24:35 -0500 Subject: misplaced comma... --- nova/network/manager.py | 2 +- nova/tests/fake_network_info.py | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/nova/network/manager.py b/nova/network/manager.py index 9a4b09ad8..74e7bbf26 100644 --- a/nova/network/manager.py +++ b/nova/network/manager.py @@ -508,7 +508,7 @@ class NetworkManager(manager.SchedulerDependentManager): if network['cidr_v6']: info['ip6s'] = [ip6_dict()] - network_dict['cidr_v6'] = network['cidr_v6'], + network_dict['cidr_v6'] = network['cidr_v6'] # TODO(tr3buchet): handle ip6 routes here as well if network['gateway_v6']: info['gateway6'] = network['gateway_v6'] diff --git a/nova/tests/fake_network_info.py b/nova/tests/fake_network_info.py index 47f9abd05..81edd998b 100644 --- a/nova/tests/fake_network_info.py +++ b/nova/tests/fake_network_info.py @@ -60,6 +60,8 @@ def fake_network(n, ipv6=None): rval['cidr_v6'] = '2001:db8:0:%x::/64' % n rval['gateway_v6'] = '2001:db8:0:%x::1' % n rval['netmask_v6'] = '64' + print 'asdf %s' % rval['cidr_v6'] + print type(rval['cidr_v6']) return rval -- cgit From 79602b6d9d7f3ef9777cc0e5f7a0476e1f71ffa0 Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Fri, 26 Aug 2011 12:26:09 -0500 Subject: forgot test print statements --- nova/tests/fake_network_info.py | 2 -- 1 file changed, 2 deletions(-) diff --git a/nova/tests/fake_network_info.py b/nova/tests/fake_network_info.py index 81edd998b..47f9abd05 100644 --- a/nova/tests/fake_network_info.py +++ b/nova/tests/fake_network_info.py @@ -60,8 +60,6 @@ def fake_network(n, ipv6=None): rval['cidr_v6'] = '2001:db8:0:%x::/64' % n rval['gateway_v6'] = '2001:db8:0:%x::1' % n rval['netmask_v6'] = '64' - print 'asdf %s' % rval['cidr_v6'] - print type(rval['cidr_v6']) return rval -- cgit From 2d3c516f5943efac0ab836818a759ba9291910b4 Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Fri, 26 Aug 2011 12:28:14 -0500 Subject: added memory_mb to instance flavor test model --- nova/tests/fake_network_info.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nova/tests/fake_network_info.py b/nova/tests/fake_network_info.py index 47f9abd05..6feb1e8f8 100644 --- a/nova/tests/fake_network_info.py +++ b/nova/tests/fake_network_info.py @@ -80,7 +80,8 @@ def fixed_ips(num_networks, num_ips, num_floating_ips=0): flavor = {'id': 0, - 'rxtx_cap': 3} + 'rxtx_cap': 3, + 'memory_mb': 512} def floating_ips(fixed_ip_id): for i in xrange(154): -- cgit From f684e293b02a168e3e45d915645142229fdc7561 Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Fri, 26 Aug 2011 12:29:44 -0500 Subject: added vcpus to instance flavor test model --- nova/tests/fake_network_info.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nova/tests/fake_network_info.py b/nova/tests/fake_network_info.py index 6feb1e8f8..d89ddbe9f 100644 --- a/nova/tests/fake_network_info.py +++ b/nova/tests/fake_network_info.py @@ -81,7 +81,8 @@ def fixed_ips(num_networks, num_ips, num_floating_ips=0): flavor = {'id': 0, 'rxtx_cap': 3, - 'memory_mb': 512} + 'memory_mb': 512, + 'vcpus': 2} def floating_ips(fixed_ip_id): for i in xrange(154): -- cgit From 9f0015c727986d17a14f905a1779cc31397a071f Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Fri, 26 Aug 2011 12:33:08 -0500 Subject: updated instance type fake model --- nova/tests/fake_network_info.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/nova/tests/fake_network_info.py b/nova/tests/fake_network_info.py index d89ddbe9f..a8e36c06b 100644 --- a/nova/tests/fake_network_info.py +++ b/nova/tests/fake_network_info.py @@ -80,9 +80,14 @@ def fixed_ips(num_networks, num_ips, num_floating_ips=0): flavor = {'id': 0, - 'rxtx_cap': 3, + 'name': 'fake_flavor', 'memory_mb': 512, - 'vcpus': 2} + 'vcpus': 2, + 'local_gb': 10, + 'flavor_id': 0, + 'swap': 0, + 'rxtx_quota': 0, + 'rxtx_cap': 3} def floating_ips(fixed_ip_id): for i in xrange(154): -- cgit From 49d24725031d7ebfb1a90517bcead02c09a4ebaf Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Fri, 26 Aug 2011 12:38:20 -0500 Subject: update libvirt --- nova/virt/libvirt/firewall.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nova/virt/libvirt/firewall.py b/nova/virt/libvirt/firewall.py index c2f4f91e8..0db10c7ce 100644 --- a/nova/virt/libvirt/firewall.py +++ b/nova/virt/libvirt/firewall.py @@ -338,8 +338,8 @@ class NWFilterFirewall(FirewallDriver): 'nova-allow-dhcp-server'] if FLAGS.use_ipv6: - networks = [network for (network, _m) in network_info if - network['gateway_v6']] + networks = [network for (network, info) in network_info if + info['gateway6']] if networks: instance_secgroup_filter_children.\ -- cgit From fe74d65f7a8ccba26a03c72edbadf4b00e9a5294 Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Fri, 26 Aug 2011 13:26:33 -0500 Subject: update libvirt tests --- nova/tests/test_libvirt.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py index 06ad7d13a..02b2f0cfe 100644 --- a/nova/tests/test_libvirt.py +++ b/nova/tests/test_libvirt.py @@ -1377,9 +1377,9 @@ class NWFilterTestCase(test.TestCase): _setup_networking(instance_ref['id'], self.test_ip) - def _ensure_all_called(): + def _ensure_all_called(mac): instance_filter = 'nova-instance-%s-%s' % (instance_ref['name'], - 'fake') + mac.translate(None, ':') secgroup_filter = 'nova-secgroup-%s' % self.security_group['id'] for required in [secgroup_filter, 'allow-dhcp-server', 'no-arp-spoofing', 'no-ip-spoofing', @@ -1396,10 +1396,15 @@ class NWFilterTestCase(test.TestCase): instance = db.instance_get(self.context, inst_id) network_info = _fake_network_info(self.stubs, 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 + mac = network_info[0][1]['mac'] + self.fw.setup_basic_filtering(instance, network_info) self.fw.prepare_instance_filter(instance, network_info) self.fw.apply_instance_filter(instance, network_info) - _ensure_all_called() + _ensure_all_called(mac) self.teardown_security_group() db.instance_destroy(context.get_admin_context(), instance_ref['id']) -- cgit From 2fdf2d3fb05f58d1778671830eab111328f624fc Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Fri, 26 Aug 2011 13:28:17 -0500 Subject: forgot ) --- nova/tests/test_libvirt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py index 02b2f0cfe..ded5a99ab 100644 --- a/nova/tests/test_libvirt.py +++ b/nova/tests/test_libvirt.py @@ -1379,7 +1379,7 @@ class NWFilterTestCase(test.TestCase): def _ensure_all_called(mac): instance_filter = 'nova-instance-%s-%s' % (instance_ref['name'], - mac.translate(None, ':') + mac.translate(None, ':')) secgroup_filter = 'nova-secgroup-%s' % self.security_group['id'] for required in [secgroup_filter, 'allow-dhcp-server', 'no-arp-spoofing', 'no-ip-spoofing', -- cgit From 3ae6943354a8c22e65233bca38f38c3521b1cce4 Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Fri, 26 Aug 2011 13:32:16 -0500 Subject: updated fake values --- nova/tests/fake_network_info.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/tests/fake_network_info.py b/nova/tests/fake_network_info.py index a8e36c06b..079cf539b 100644 --- a/nova/tests/fake_network_info.py +++ b/nova/tests/fake_network_info.py @@ -81,7 +81,7 @@ def fixed_ips(num_networks, num_ips, num_floating_ips=0): flavor = {'id': 0, 'name': 'fake_flavor', - 'memory_mb': 512, + 'memory_mb': 2048, 'vcpus': 2, 'local_gb': 10, 'flavor_id': 0, -- cgit From 698e6052d70bd6da4b6b1d2cfcf096ea576c36a6 Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Fri, 26 Aug 2011 13:37:25 -0500 Subject: updated fake values --- nova/tests/test_libvirt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py index ded5a99ab..6947a70b0 100644 --- a/nova/tests/test_libvirt.py +++ b/nova/tests/test_libvirt.py @@ -1120,7 +1120,7 @@ class IptablesFirewallTestCase(test.TestCase): network_info = _fake_network_info(self.stubs, 1) rulesv4, rulesv6 = self.fw._filters_for_instance("fake", network_info) self.assertEquals(len(rulesv4), 2) - self.assertEquals(len(rulesv6), 3) + self.assertEquals(len(rulesv6), 1) def test_filters_for_instance_without_ip_v6(self): self.flags(use_ipv6=False) -- cgit From 02c501391ad9f6bb55771053418f10301e644c8f Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Fri, 26 Aug 2011 13:44:26 -0500 Subject: updated fake values --- nova/tests/test_libvirt.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py index 6947a70b0..1b09a3302 100644 --- a/nova/tests/test_libvirt.py +++ b/nova/tests/test_libvirt.py @@ -1130,11 +1130,14 @@ class IptablesFirewallTestCase(test.TestCase): self.assertEquals(len(rulesv6), 0) def test_multinic_iptables(self): - ipv4_rules_per_network = 2 - ipv6_rules_per_network = 3 + ipv4_rules_per_addr = 1 + ipv4_addr_per_network = 2 + ipv6_rules_per_addr = 1 + ipv6_addr_per_network = 1 networks_count = 5 instance_ref = self._create_instance_ref() - network_info = _fake_network_info(self.stubs, networks_count) + network_info = _fake_network_info(self.stubs, networks_count, + ipv4_addr_per_network) ipv4_len = len(self.fw.iptables.ipv4['filter'].rules) ipv6_len = len(self.fw.iptables.ipv6['filter'].rules) inst_ipv4, inst_ipv6 = self.fw.instance_rules(instance_ref, @@ -1145,9 +1148,9 @@ class IptablesFirewallTestCase(test.TestCase): ipv4_network_rules = len(ipv4) - len(inst_ipv4) - ipv4_len ipv6_network_rules = len(ipv6) - len(inst_ipv6) - ipv6_len self.assertEquals(ipv4_network_rules, - ipv4_rules_per_network * networks_count) + ipv4_rules_per_addr * ipv4_addr_per_network * networks_count) self.assertEquals(ipv6_network_rules, - ipv6_rules_per_network * networks_count) + ipv6_rules_per_addr * ipv4_addr_per_network * networks_count) def test_do_refresh_security_group_rules(self): instance_ref = self._create_instance_ref() -- cgit From adf03e7274636cd58d9c04461896a50f43934e15 Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Fri, 26 Aug 2011 13:47:54 -0500 Subject: updated fake values --- nova/tests/test_libvirt.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py index 1b09a3302..d8bc9575b 100644 --- a/nova/tests/test_libvirt.py +++ b/nova/tests/test_libvirt.py @@ -1150,7 +1150,7 @@ class IptablesFirewallTestCase(test.TestCase): self.assertEquals(ipv4_network_rules, ipv4_rules_per_addr * ipv4_addr_per_network * networks_count) self.assertEquals(ipv6_network_rules, - ipv6_rules_per_addr * ipv4_addr_per_network * networks_count) + ipv6_rules_per_addr * ipv6_addr_per_network * networks_count) def test_do_refresh_security_group_rules(self): instance_ref = self._create_instance_ref() -- cgit From 477510214e80be21a40bff6c053090793653f6a1 Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Fri, 26 Aug 2011 15:09:39 -0500 Subject: couple of pep8s --- nova/tests/fake_network_info.py | 1 + 1 file changed, 1 insertion(+) diff --git a/nova/tests/fake_network_info.py b/nova/tests/fake_network_info.py index 079cf539b..2e8cf60ec 100644 --- a/nova/tests/fake_network_info.py +++ b/nova/tests/fake_network_info.py @@ -89,6 +89,7 @@ flavor = {'id': 0, 'rxtx_quota': 0, 'rxtx_cap': 3} + def floating_ips(fixed_ip_id): for i in xrange(154): yield {'id': 0, -- cgit From d0f42b4bf6e60485c7bebe1c60dccce48a0ddcb3 Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Fri, 26 Aug 2011 16:55:52 -0500 Subject: stubbed some stuff in test_libvirt --- nova/tests/test_libvirt.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py index d8bc9575b..58e78daf4 100644 --- a/nova/tests/test_libvirt.py +++ b/nova/tests/test_libvirt.py @@ -1063,10 +1063,17 @@ class IptablesFirewallTestCase(test.TestCase): return '', '' print cmd, kwargs + def get_fixed_ips(*args, **kwargs): + ips = [] + for network, info in network_info: + ips.extend(info['ips']) + return [ip['ip'] for ip in ips] + from nova.network import linux_net linux_net.iptables_manager.execute = fake_iptables_execute network_info = _fake_network_info(self.stubs, 1) + self.stubs.Set(self.db, 'instance_get_fixed_addresses', get_fixed_ips) self.fw.prepare_instance_filter(instance_ref, network_info) self.fw.apply_instance_filter(instance_ref, network_info) -- cgit From 9737731fff7f6d4d19213b453315610bd095a0e6 Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Fri, 26 Aug 2011 17:00:06 -0500 Subject: updated libvirt test --- nova/tests/test_libvirt.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py index 58e78daf4..2ff6b3953 100644 --- a/nova/tests/test_libvirt.py +++ b/nova/tests/test_libvirt.py @@ -1073,7 +1073,7 @@ class IptablesFirewallTestCase(test.TestCase): linux_net.iptables_manager.execute = fake_iptables_execute network_info = _fake_network_info(self.stubs, 1) - self.stubs.Set(self.db, 'instance_get_fixed_addresses', get_fixed_ips) + self.stubs.Set(db, 'instance_get_fixed_addresses', get_fixed_ips) self.fw.prepare_instance_filter(instance_ref, network_info) self.fw.apply_instance_filter(instance_ref, network_info) @@ -1111,10 +1111,11 @@ class IptablesFirewallTestCase(test.TestCase): self.assertTrue(len(filter(regex.match, self.out_rules)) > 0, "ICMP Echo Request acceptance rule wasn't added") - regex = re.compile('-A .* -j ACCEPT -p tcp -m multiport ' - '--dports 80:81 -s %s' % (src_ip,)) - self.assertTrue(len(filter(regex.match, self.out_rules)) > 0, - "TCP port 80/81 acceptance rule wasn't added") + for ip in get_fixed_ips(): + regex = re.compile('-A .* -j ACCEPT -p tcp -m multiport ' + '--dports 80:81 -s %s' % ip) + self.assertTrue(len(filter(regex.match, self.out_rules)) > 0, + "TCP port 80/81 acceptance rule wasn't added") regex = re.compile('-A .* -j ACCEPT -p tcp ' '-m multiport --dports 80:81 -s 192.168.10.0/24') -- cgit From 156430b2d795833245c069f83c435a8a240556fd Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Fri, 26 Aug 2011 17:04:30 -0500 Subject: removed self.test ip and _setup_networking from libvirt --- nova/tests/test_libvirt.py | 64 +++------------------------------------------- 1 file changed, 3 insertions(+), 61 deletions(-) diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py index 2ff6b3953..fe5470a6f 100644 --- a/nova/tests/test_libvirt.py +++ b/nova/tests/test_libvirt.py @@ -41,57 +41,14 @@ from nova.tests import fake_network_info libvirt = None FLAGS = flags.FLAGS +_fake_network_info = fake_network_info.fake_get_instance_nw_info +_ipv4_like = fake_network_info.ipv4_like + def _concurrency(wait, done, target): wait.wait() done.send() -_fake_network_info = fake_network_info.fake_get_instance_nw_info -_ipv4_like = fake_network_info.ipv4_like -def _create_network_info(count=1, ipv6=None): - if ipv6 is None: - ipv6 = FLAGS.use_ipv6 - fake = 'fake' - fake_ip = '10.11.12.13' - fake_ip_2 = '0.0.0.1' - fake_ip_3 = '0.0.0.1' - fake_vlan = 100 - fake_bridge_interface = 'eth0' - network = {'bridge': fake, - 'cidr': fake_ip, - 'cidr_v6': fake_ip, - 'gateway_v6': fake, - 'vlan': fake_vlan, - 'bridge_interface': fake_bridge_interface} - mapping = {'mac': fake, - 'dhcp_server': '10.0.0.1', - 'gateway': fake, - 'gateway6': fake, - 'ips': [{'ip': fake_ip}, {'ip': fake_ip}]} - if ipv6: - mapping['ip6s'] = [{'ip': fake_ip}, - {'ip': fake_ip_2}, - {'ip': fake_ip_3}] - return [(network, mapping) for x in xrange(0, count)] - - -def _setup_networking(instance_id, ip='1.2.3.4', mac='56:12:12:12:12:12'): - ctxt = context.get_admin_context() - network_ref = db.project_get_networks(ctxt, - 'fake', - associate=True)[0] - vif = {'address': mac, - 'network_id': network_ref['id'], - 'instance_id': instance_id} - vif_ref = db.virtual_interface_create(ctxt, vif) - - fixed_ip = {'address': ip, - 'network_id': network_ref['id'], - 'virtual_interface_id': vif_ref['id']} - db.fixed_ip_create(ctxt, fixed_ip) - db.fixed_ip_update(ctxt, ip, {'allocated': True, - 'instance_id': instance_id}) - class CacheConcurrencyTestCase(test.TestCase): def setUp(self): @@ -164,7 +121,6 @@ class LibvirtConnTestCase(test.TestCase): self.context = context.get_admin_context() self.flags(instances_path='') self.call_libvirt_dependant_setup = False - self.test_ip = '10.11.12.13' test_instance = {'memory_kb': '1024000', 'basepath': '/some/path', @@ -426,7 +382,6 @@ class LibvirtConnTestCase(test.TestCase): user_context = context.RequestContext(self.user_id, self.project_id) instance_ref = db.instance_create(user_context, instance) - _setup_networking(instance_ref['id'], self.test_ip) self.flags(libvirt_type='lxc') conn = connection.LibvirtConnection(True) @@ -458,8 +413,6 @@ class LibvirtConnTestCase(test.TestCase): network_ref = db.project_get_networks(context.get_admin_context(), self.project_id)[0] - _setup_networking(instance_ref['id'], self.test_ip) - type_uri_map = {'qemu': ('qemu:///system', [(lambda t: t.find('.').get('type'), 'qemu'), (lambda t: t.find('./os/type').text, 'hvm'), @@ -925,7 +878,6 @@ class IptablesFirewallTestCase(test.TestCase): """setup_basic_rules in nwfilter calls this.""" pass self.fake_libvirt_connection = FakeLibvirtConnection() - self.test_ip = '10.11.12.13' self.fw = firewall.IptablesFirewallDriver( get_connection=lambda: self.fake_libvirt_connection) @@ -989,10 +941,6 @@ class IptablesFirewallTestCase(test.TestCase): def test_static_filters(self): instance_ref = self._create_instance_ref() src_instance_ref = self._create_instance_ref() - src_ip = '10.11.12.14' - src_mac = '56:12:12:12:12:13' - _setup_networking(instance_ref['id'], self.test_ip, src_mac) - _setup_networking(src_instance_ref['id'], src_ip) admin_ctxt = context.get_admin_context() secgroup = db.security_group_create(admin_ctxt, @@ -1184,7 +1132,6 @@ class IptablesFirewallTestCase(test.TestCase): fakefilter.nwfilterLookupByName instance_ref = self._create_instance_ref() - _setup_networking(instance_ref['id'], self.test_ip) network_info = _fake_network_info(self.stubs, 1) self.fw.setup_basic_filtering(instance_ref, network_info) self.fw.prepare_instance_filter(instance_ref, network_info) @@ -1200,7 +1147,6 @@ class IptablesFirewallTestCase(test.TestCase): def test_provider_firewall_rules(self): # setup basic instance data instance_ref = self._create_instance_ref() - _setup_networking(instance_ref['id'], self.test_ip) # FRAGILE: peeks at how the firewall names chains chain_name = 'inst-%s' % instance_ref['id'] @@ -1270,7 +1216,6 @@ class NWFilterTestCase(test.TestCase): self.fake_libvirt_connection = Mock() - self.test_ip = '10.11.12.13' self.fw = firewall.NWFilterFirewall( lambda: self.fake_libvirt_connection) @@ -1386,8 +1331,6 @@ class NWFilterTestCase(test.TestCase): instance_ref = self._create_instance() inst_id = instance_ref['id'] - _setup_networking(instance_ref['id'], self.test_ip) - def _ensure_all_called(mac): instance_filter = 'nova-instance-%s-%s' % (instance_ref['name'], mac.translate(None, ':')) @@ -1444,7 +1387,6 @@ class NWFilterTestCase(test.TestCase): instance = db.instance_get(self.context, inst_id) - _setup_networking(instance_ref['id'], self.test_ip) network_info = _fake_network_info(self.stubs, 1) self.fw.setup_basic_filtering(instance, network_info) self.fw.prepare_instance_filter(instance, network_info) -- cgit From 7be0e4cd371691253aa332c2c180be1a83f7f98b Mon Sep 17 00:00:00 2001 From: Launchpad Translations on behalf of nova-core <> Date: Thu, 1 Sep 2011 05:02:30 +0000 Subject: Launchpad automatic translations update. --- po/pt_BR.po | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/po/pt_BR.po b/po/pt_BR.po index bff1135c6..e10b0c0de 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -8,14 +8,14 @@ msgstr "" "Project-Id-Version: nova\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2011-02-21 10:03-0500\n" -"PO-Revision-Date: 2011-08-23 11:23+0000\n" -"Last-Translator: msinhore \n" +"PO-Revision-Date: 2011-09-01 04:15+0000\n" +"Last-Translator: Daniel Negri \n" "Language-Team: Brazilian Portuguese \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2011-08-24 04:47+0000\n" -"X-Generator: Launchpad (build 13697)\n" +"X-Launchpad-Export-Date: 2011-09-01 05:02+0000\n" +"X-Generator: Launchpad (build 13827)\n" #: ../nova/scheduler/chance.py:37 ../nova/scheduler/zone.py:55 #: ../nova/scheduler/simple.py:75 ../nova/scheduler/simple.py:110 @@ -708,7 +708,7 @@ msgstr "Ligação %(queue)s para %(exchange)s com chave %(routing_key)s" #: ../nova/fakerabbit.py:121 #, python-format msgid "Getting from %(queue)s: %(message)s" -msgstr "" +msgstr "Recebendo de %(queue)s: %(message)s" #: ../nova/virt/xenapi/vm_utils.py:135 ../nova/virt/hyperv.py:171 #, python-format @@ -808,7 +808,7 @@ msgstr "Kernel/Ramdisk %s destruidos" #: ../nova/virt/xenapi/vm_utils.py:361 #, python-format msgid "Asking xapi to fetch %(url)s as %(access)s" -msgstr "" +msgstr "Requisitando à xapi a busca da url %(url)s como %(access)s" #: ../nova/virt/xenapi/vm_utils.py:386 ../nova/virt/xenapi/vm_utils.py:402 #, python-format -- cgit From ab8cfda10ed12dd592ef3b06806a80b1922707c1 Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Thu, 1 Sep 2011 15:29:00 -0500 Subject: moved cidr_v6 back --- nova/network/manager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/network/manager.py b/nova/network/manager.py index 8fd176c26..b4605eea5 100644 --- a/nova/network/manager.py +++ b/nova/network/manager.py @@ -499,6 +499,7 @@ class NetworkManager(manager.SchedulerDependentManager): 'bridge': network['bridge'], 'id': network['id'], 'cidr': network['cidr'], + 'cidr_v6': network['cidr_v6'], 'injected': network['injected'], 'vlan': network['vlan'], 'bridge_interface': network['bridge_interface'], @@ -524,7 +525,6 @@ class NetworkManager(manager.SchedulerDependentManager): if network['cidr_v6']: info['ip6s'] = [ip6_dict()] - network_dict['cidr_v6'] = network['cidr_v6'] # TODO(tr3buchet): handle ip6 routes here as well if network['gateway_v6']: info['gateway6'] = network['gateway_v6'] -- cgit From 04cfb6356b920941080fbc58301b6d005d21ac5f Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Thu, 1 Sep 2011 15:50:38 -0500 Subject: renamed fake_network_info.py --- nova/tests/fake_network.py | 144 ++++++++++++++++++++++++++++++++++++++++ nova/tests/fake_network_info.py | 144 ---------------------------------------- nova/tests/test_libvirt.py | 6 +- nova/tests/test_network.py | 4 +- 4 files changed, 149 insertions(+), 149 deletions(-) create mode 100644 nova/tests/fake_network.py delete mode 100644 nova/tests/fake_network_info.py diff --git a/nova/tests/fake_network.py b/nova/tests/fake_network.py new file mode 100644 index 000000000..2e8cf60ec --- /dev/null +++ b/nova/tests/fake_network.py @@ -0,0 +1,144 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright 2011 Rackspace +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from nova import db +from nova import flags +from nova import test +from nova.network import manager as network_manager + + +HOST = "testhost" +FLAGS = flags.FLAGS + + +class FakeModel(dict): + """Represent a model from the db""" + def __init__(self, *args, **kwargs): + self.update(kwargs) + + def __getattr__(self, name): + return self[name] + + +def fake_network(n, ipv6=None): + if ipv6 == None: + ipv6 = FLAGS.use_ipv6 + rval = {'id': n, + 'label': 'test%d' % n, + 'injected': False, + 'multi_host': False, + 'cidr': '192.168.%d.0/24' % n, + 'cidr_v6': None, + 'netmask': '255.255.255.0', + 'netmask_v6': None, + 'bridge': 'fake_br%d' % n, + 'bridge_interface': 'fake_eth%d' % n, + 'gateway': '192.168.%d.1' % n, + 'gateway_v6': None, + 'broadcast': '192.168.%d.255' % n, + 'dns1': '192.168.%d.3' % n, + 'dns2': '192.168.%d.4' % n, + 'vlan': None, + 'host': None, + 'project_id': 'fake_project', + 'vpn_public_address': '192.168.%d.2' % n} + if ipv6: + rval['cidr_v6'] = '2001:db8:0:%x::/64' % n + rval['gateway_v6'] = '2001:db8:0:%x::1' % n + rval['netmask_v6'] = '64' + + return rval + + +def fixed_ips(num_networks, num_ips, num_floating_ips=0): + for network in xrange(num_networks): + for ip in xrange(num_ips): + id = network * num_ips + ip + f_ips = [floating_ips(id).next() for i in xrange(num_floating_ips)] + yield {'id': id, + 'network_id': network, + 'address': '192.168.%d.1%02d' % (network, ip), + 'instance_id': 0, + 'allocated': False, + # and since network_id and vif_id happen to be equivalent + 'virtual_interface_id': network, + 'floating_ips': [FakeModel(**ip) for ip in f_ips]} + + +flavor = {'id': 0, + 'name': 'fake_flavor', + 'memory_mb': 2048, + 'vcpus': 2, + 'local_gb': 10, + 'flavor_id': 0, + 'swap': 0, + 'rxtx_quota': 0, + 'rxtx_cap': 3} + + +def floating_ips(fixed_ip_id): + for i in xrange(154): + yield {'id': 0, + 'address': '10.10.10.%d' % (i + 100), + 'fixed_ip_id': fixed_ip_id, + 'project_id': None, + 'auto_assigned': False} + + +def vifs(n): + for x in xrange(n): + yield {'id': x, + 'address': 'DE:AD:BE:EF:00:%02x' % x, + 'uuid': '00000000-0000-0000-0000-00000000000000%02d' % x, + 'network_id': x, + 'network': FakeModel(**fake_network(x)), + 'instance_id': 0} + + +def ipv4_like(ip, s): + ip = ip.split('.') + s = s.split('.') + + for i, octet in enumerate(s): + if octet == '*': + continue + if octet != ip[i]: + return False + return True + + +def fake_get_instance_nw_info(stubs, n=1, ips_per_vif=2): + # stubs is the self.stubs from the test + # 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) + network.db = db + + def fixed_ips_fake(*args, **kwargs): + return list(fixed_ips(n, ips_per_vif)) + + def virtual_interfaces_fake(*args, **kwargs): + return [vif for vif in vifs(n)] + + def instance_type_fake(*args, **kwargs): + return flavor + + stubs.Set(db, 'fixed_ip_get_by_instance', fixed_ips_fake) + stubs.Set(db, 'virtual_interface_get_by_instance', virtual_interfaces_fake) + stubs.Set(db, 'instance_type_get', instance_type_fake) + + return network.get_instance_nw_info(None, 0, 0, None) diff --git a/nova/tests/fake_network_info.py b/nova/tests/fake_network_info.py deleted file mode 100644 index 2e8cf60ec..000000000 --- a/nova/tests/fake_network_info.py +++ /dev/null @@ -1,144 +0,0 @@ -# vim: tabstop=4 shiftwidth=4 softtabstop=4 - -# Copyright 2011 Rackspace -# All Rights Reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. - -from nova import db -from nova import flags -from nova import test -from nova.network import manager as network_manager - - -HOST = "testhost" -FLAGS = flags.FLAGS - - -class FakeModel(dict): - """Represent a model from the db""" - def __init__(self, *args, **kwargs): - self.update(kwargs) - - def __getattr__(self, name): - return self[name] - - -def fake_network(n, ipv6=None): - if ipv6 == None: - ipv6 = FLAGS.use_ipv6 - rval = {'id': n, - 'label': 'test%d' % n, - 'injected': False, - 'multi_host': False, - 'cidr': '192.168.%d.0/24' % n, - 'cidr_v6': None, - 'netmask': '255.255.255.0', - 'netmask_v6': None, - 'bridge': 'fake_br%d' % n, - 'bridge_interface': 'fake_eth%d' % n, - 'gateway': '192.168.%d.1' % n, - 'gateway_v6': None, - 'broadcast': '192.168.%d.255' % n, - 'dns1': '192.168.%d.3' % n, - 'dns2': '192.168.%d.4' % n, - 'vlan': None, - 'host': None, - 'project_id': 'fake_project', - 'vpn_public_address': '192.168.%d.2' % n} - if ipv6: - rval['cidr_v6'] = '2001:db8:0:%x::/64' % n - rval['gateway_v6'] = '2001:db8:0:%x::1' % n - rval['netmask_v6'] = '64' - - return rval - - -def fixed_ips(num_networks, num_ips, num_floating_ips=0): - for network in xrange(num_networks): - for ip in xrange(num_ips): - id = network * num_ips + ip - f_ips = [floating_ips(id).next() for i in xrange(num_floating_ips)] - yield {'id': id, - 'network_id': network, - 'address': '192.168.%d.1%02d' % (network, ip), - 'instance_id': 0, - 'allocated': False, - # and since network_id and vif_id happen to be equivalent - 'virtual_interface_id': network, - 'floating_ips': [FakeModel(**ip) for ip in f_ips]} - - -flavor = {'id': 0, - 'name': 'fake_flavor', - 'memory_mb': 2048, - 'vcpus': 2, - 'local_gb': 10, - 'flavor_id': 0, - 'swap': 0, - 'rxtx_quota': 0, - 'rxtx_cap': 3} - - -def floating_ips(fixed_ip_id): - for i in xrange(154): - yield {'id': 0, - 'address': '10.10.10.%d' % (i + 100), - 'fixed_ip_id': fixed_ip_id, - 'project_id': None, - 'auto_assigned': False} - - -def vifs(n): - for x in xrange(n): - yield {'id': x, - 'address': 'DE:AD:BE:EF:00:%02x' % x, - 'uuid': '00000000-0000-0000-0000-00000000000000%02d' % x, - 'network_id': x, - 'network': FakeModel(**fake_network(x)), - 'instance_id': 0} - - -def ipv4_like(ip, s): - ip = ip.split('.') - s = s.split('.') - - for i, octet in enumerate(s): - if octet == '*': - continue - if octet != ip[i]: - return False - return True - - -def fake_get_instance_nw_info(stubs, n=1, ips_per_vif=2): - # stubs is the self.stubs from the test - # 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) - network.db = db - - def fixed_ips_fake(*args, **kwargs): - return list(fixed_ips(n, ips_per_vif)) - - def virtual_interfaces_fake(*args, **kwargs): - return [vif for vif in vifs(n)] - - def instance_type_fake(*args, **kwargs): - return flavor - - stubs.Set(db, 'fixed_ip_get_by_instance', fixed_ips_fake) - stubs.Set(db, 'virtual_interface_get_by_instance', virtual_interfaces_fake) - stubs.Set(db, 'instance_type_get', instance_type_fake) - - return network.get_instance_nw_info(None, 0, 0, None) diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py index fe5470a6f..190e197f5 100644 --- a/nova/tests/test_libvirt.py +++ b/nova/tests/test_libvirt.py @@ -36,13 +36,13 @@ from nova.api.ec2 import cloud from nova.compute import power_state from nova.virt.libvirt import connection from nova.virt.libvirt import firewall -from nova.tests import fake_network_info +from nova.tests import fake_network libvirt = None FLAGS = flags.FLAGS -_fake_network_info = fake_network_info.fake_get_instance_nw_info -_ipv4_like = fake_network_info.ipv4_like +_fake_network_info = fake_network.fake_get_instance_nw_info +_ipv4_like = fake_network.ipv4_like def _concurrency(wait, done, target): diff --git a/nova/tests/test_network.py b/nova/tests/test_network.py index 803868cd9..a0079e120 100644 --- a/nova/tests/test_network.py +++ b/nova/tests/test_network.py @@ -22,7 +22,7 @@ from nova import exception from nova import log as logging from nova import test from nova.network import manager as network_manager -from nova.tests import fake_network_info +from nova.tests import fake_network LOG = logging.getLogger('nova.tests.network') @@ -132,7 +132,7 @@ class FlatNetworkTestCase(test.TestCase): is_admin=False) def test_get_instance_nw_info(self): - fake_get_instance_nw_info = fake_network_info.fake_get_instance_nw_info + fake_get_instance_nw_info = fake_network.fake_get_instance_nw_info nw_info = fake_get_instance_nw_info(self.stubs, 0, 2) self.assertFalse(nw_info) -- cgit From 81f3c9e0d1657783edf8f2ab7e055c5628af33ec Mon Sep 17 00:00:00 2001 From: Launchpad Translations on behalf of nova-core <> Date: Fri, 2 Sep 2011 04:53:10 +0000 Subject: Launchpad automatic translations update. --- po/pt_BR.po | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/po/pt_BR.po b/po/pt_BR.po index e10b0c0de..c4eb487d6 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -8,14 +8,14 @@ msgstr "" "Project-Id-Version: nova\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2011-02-21 10:03-0500\n" -"PO-Revision-Date: 2011-09-01 04:15+0000\n" -"Last-Translator: Daniel Negri \n" +"PO-Revision-Date: 2011-09-01 20:56+0000\n" +"Last-Translator: Robson Negreiros Bezerra \n" "Language-Team: Brazilian Portuguese \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2011-09-01 05:02+0000\n" -"X-Generator: Launchpad (build 13827)\n" +"X-Launchpad-Export-Date: 2011-09-02 04:53+0000\n" +"X-Generator: Launchpad (build 13830)\n" #: ../nova/scheduler/chance.py:37 ../nova/scheduler/zone.py:55 #: ../nova/scheduler/simple.py:75 ../nova/scheduler/simple.py:110 @@ -453,11 +453,13 @@ msgid "" "Detach volume %(volume_id)s from mountpoint %(mp)s on instance " "%(instance_id)s" msgstr "" +"Desconectando volume %(volume_id)s do ponto de montagem %(mp)s na instância " +"%(instance_id)s" #: ../nova/compute/manager.py:588 #, python-format msgid "Detaching volume from unknown instance %s" -msgstr "" +msgstr "Desconectando volume da instância desconhecida %s" #: ../nova/scheduler/simple.py:53 #, python-format -- cgit From 53f1aafc546b165cfdd74aa6620fe4c288a9359a Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Fri, 2 Sep 2011 17:28:58 -0500 Subject: alex meade issues --- nova/tests/fake_network.py | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/nova/tests/fake_network.py b/nova/tests/fake_network.py index 2e8cf60ec..36aebe6b0 100644 --- a/nova/tests/fake_network.py +++ b/nova/tests/fake_network.py @@ -34,31 +34,31 @@ class FakeModel(dict): return self[name] -def fake_network(n, ipv6=None): +def fake_network(network_id, ipv6=None): if ipv6 == None: ipv6 = FLAGS.use_ipv6 - rval = {'id': n, - 'label': 'test%d' % n, + rval = {'id': network_id, + 'label': 'test%d' % network_id, 'injected': False, 'multi_host': False, - 'cidr': '192.168.%d.0/24' % n, + 'cidr': '192.168.%d.0/24' % network_id, 'cidr_v6': None, 'netmask': '255.255.255.0', 'netmask_v6': None, - 'bridge': 'fake_br%d' % n, - 'bridge_interface': 'fake_eth%d' % n, - 'gateway': '192.168.%d.1' % n, + 'bridge': 'fake_br%d' % network_id, + 'bridge_interface': 'fake_eth%d' % network_id, + 'gateway': '192.168.%d.1' % network_id, 'gateway_v6': None, - 'broadcast': '192.168.%d.255' % n, - 'dns1': '192.168.%d.3' % n, - 'dns2': '192.168.%d.4' % n, + 'broadcast': '192.168.%d.255' % network_id, + 'dns1': '192.168.%d.3' % network_id, + 'dns2': '192.168.%d.4' % network_id, 'vlan': None, 'host': None, 'project_id': 'fake_project', - 'vpn_public_address': '192.168.%d.2' % n} + 'vpn_public_address': '192.168.%d.2' % network_id} if ipv6: - rval['cidr_v6'] = '2001:db8:0:%x::/64' % n - rval['gateway_v6'] = '2001:db8:0:%x::1' % n + rval['cidr_v6'] = '2001:db8:0:%x::/64' % network_id + rval['gateway_v6'] = '2001:db8:0:%x::1' % network_id rval['netmask_v6'] = '64' return rval @@ -109,11 +109,11 @@ def vifs(n): 'instance_id': 0} -def ipv4_like(ip, s): +def ipv4_like(ip, match_string): ip = ip.split('.') - s = s.split('.') + match_octets = match_string.split('.') - for i, octet in enumerate(s): + for i, octet in enumerate(match_octets): if octet == '*': continue if octet != ip[i]: @@ -121,7 +121,7 @@ def ipv4_like(ip, s): return True -def fake_get_instance_nw_info(stubs, n=1, ips_per_vif=2): +def fake_get_instance_nw_info(stubs, num_networks=1, ips_per_vif=2): # stubs is the self.stubs from the test # ips_per_vif is the number of ips each vif will have # num_floating_ips is number of float ips for each fixed ip @@ -129,10 +129,10 @@ def fake_get_instance_nw_info(stubs, n=1, ips_per_vif=2): network.db = db def fixed_ips_fake(*args, **kwargs): - return list(fixed_ips(n, ips_per_vif)) + return list(fixed_ips(num_networks, ips_per_vif)) def virtual_interfaces_fake(*args, **kwargs): - return [vif for vif in vifs(n)] + return [vif for vif in vifs(num_networks)] def instance_type_fake(*args, **kwargs): return flavor -- cgit From cfdc4642bfa3d96e2335079d187945b9ca4c0141 Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Fri, 2 Sep 2011 18:00:34 -0500 Subject: rick nits --- nova/tests/fake_network.py | 68 ++++++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 33 deletions(-) diff --git a/nova/tests/fake_network.py b/nova/tests/fake_network.py index 36aebe6b0..10565f83c 100644 --- a/nova/tests/fake_network.py +++ b/nova/tests/fake_network.py @@ -14,6 +14,7 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. +import itertools from nova import db from nova import flags @@ -35,48 +36,49 @@ class FakeModel(dict): def fake_network(network_id, ipv6=None): - if ipv6 == None: + if ipv6 is None: ipv6 = FLAGS.use_ipv6 - rval = {'id': network_id, - 'label': 'test%d' % network_id, - 'injected': False, - 'multi_host': False, - 'cidr': '192.168.%d.0/24' % network_id, - 'cidr_v6': None, - 'netmask': '255.255.255.0', - 'netmask_v6': None, - 'bridge': 'fake_br%d' % network_id, - 'bridge_interface': 'fake_eth%d' % network_id, - 'gateway': '192.168.%d.1' % network_id, - 'gateway_v6': None, - 'broadcast': '192.168.%d.255' % network_id, - 'dns1': '192.168.%d.3' % network_id, - 'dns2': '192.168.%d.4' % network_id, - 'vlan': None, - 'host': None, - 'project_id': 'fake_project', - 'vpn_public_address': '192.168.%d.2' % network_id} + fake_network = {'id': network_id, + 'label': 'test%d' % network_id, + 'injected': False, + 'multi_host': False, + 'cidr': '192.168.%d.0/24' % network_id, + 'cidr_v6': None, + 'netmask': '255.255.255.0', + 'netmask_v6': None, + 'bridge': 'fake_br%d' % network_id, + 'bridge_interface': 'fake_eth%d' % network_id, + 'gateway': '192.168.%d.1' % network_id, + 'gateway_v6': None, + 'broadcast': '192.168.%d.255' % network_id, + 'dns1': '192.168.%d.3' % network_id, + 'dns2': '192.168.%d.4' % network_id, + 'vlan': None, + 'host': None, + 'project_id': 'fake_project', + 'vpn_public_address': '192.168.%d.2' % network_id} if ipv6: - rval['cidr_v6'] = '2001:db8:0:%x::/64' % network_id - rval['gateway_v6'] = '2001:db8:0:%x::1' % network_id - rval['netmask_v6'] = '64' + fake_network['cidr_v6'] = '2001:db8:0:%x::/64' % network_id + fake_network['gateway_v6'] = '2001:db8:0:%x::1' % network_id + fake_network['netmask_v6'] = '64' - return rval + return fake_network def fixed_ips(num_networks, num_ips, num_floating_ips=0): - for network in xrange(num_networks): - for ip in xrange(num_ips): - id = network * num_ips + ip - f_ips = [floating_ips(id).next() for i in xrange(num_floating_ips)] - yield {'id': id, - 'network_id': network, - 'address': '192.168.%d.1%02d' % (network, ip), + for network_index in xrange(num_networks): + for ip_index in xrange(num_ips): + fixed_ip_id = network_index * num_ips + ip_index + f_ips = [FakeModel(**floating_ips(fixed_ip_id).next()) + for i in xrange(num_floating_ips)] + yield {'id': fixed_ip_id, + 'network_id': network_index, + 'address': '192.168.%d.1%02d' % (network_index, ip_index), 'instance_id': 0, 'allocated': False, # and since network_id and vif_id happen to be equivalent - 'virtual_interface_id': network, - 'floating_ips': [FakeModel(**ip) for ip in f_ips]} + 'virtual_interface_id': network_index, + 'floating_ips': f_ips} flavor = {'id': 0, -- cgit From f970ce0fbb3d4de560f73a01b508d8f0f7ac9117 Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Fri, 2 Sep 2011 18:02:41 -0500 Subject: removed unneeded import --- nova/tests/fake_network.py | 1 - 1 file changed, 1 deletion(-) diff --git a/nova/tests/fake_network.py b/nova/tests/fake_network.py index 10565f83c..73a117c33 100644 --- a/nova/tests/fake_network.py +++ b/nova/tests/fake_network.py @@ -14,7 +14,6 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -import itertools from nova import db from nova import flags -- cgit From 2abdd4c2fab39b6373a1562fb260168e515e43e9 Mon Sep 17 00:00:00 2001 From: Launchpad Translations on behalf of nova-core <> Date: Sat, 3 Sep 2011 05:50:53 +0000 Subject: Launchpad automatic translations update. --- po/pt_BR.po | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/po/pt_BR.po b/po/pt_BR.po index c4eb487d6..48a718808 100644 --- a/po/pt_BR.po +++ b/po/pt_BR.po @@ -8,13 +8,13 @@ msgstr "" "Project-Id-Version: nova\n" "Report-Msgid-Bugs-To: FULL NAME \n" "POT-Creation-Date: 2011-02-21 10:03-0500\n" -"PO-Revision-Date: 2011-09-01 20:56+0000\n" +"PO-Revision-Date: 2011-09-02 12:17+0000\n" "Last-Translator: Robson Negreiros Bezerra \n" "Language-Team: Brazilian Portuguese \n" "MIME-Version: 1.0\n" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -"X-Launchpad-Export-Date: 2011-09-02 04:53+0000\n" +"X-Launchpad-Export-Date: 2011-09-03 05:50+0000\n" "X-Generator: Launchpad (build 13830)\n" #: ../nova/scheduler/chance.py:37 ../nova/scheduler/zone.py:55 @@ -882,58 +882,59 @@ msgstr "" #: ../nova/virt/xenapi/vm_utils.py:590 #, python-format msgid "No VDIs found for VM %s" -msgstr "" +msgstr "Nenhum VDIs encontrado para MV %s" #: ../nova/virt/xenapi/vm_utils.py:594 #, python-format msgid "Unexpected number of VDIs (%(num_vdis)s) found for VM %(vm_ref)s" msgstr "" +"Número de VDIs inesperado (%(num_vdis)s) encontrado para MV %(vm_ref)s" #: ../nova/virt/xenapi/vm_utils.py:653 #: ../plugins/xenserver/xenapi/etc/xapi.d/plugins/pluginlib_nova.py:188 #, python-format msgid "Creating VBD for VDI %s ... " -msgstr "" +msgstr "Criando VBD para VDI %s ... " #: ../nova/virt/xenapi/vm_utils.py:655 #: ../plugins/xenserver/xenapi/etc/xapi.d/plugins/pluginlib_nova.py:190 #, python-format msgid "Creating VBD for VDI %s done." -msgstr "" +msgstr "O VBD para VDI %s foi criado." #: ../nova/virt/xenapi/vm_utils.py:657 #: ../plugins/xenserver/xenapi/etc/xapi.d/plugins/pluginlib_nova.py:192 #, python-format msgid "Plugging VBD %s ... " -msgstr "" +msgstr "Conectando VBD %s ... " #: ../nova/virt/xenapi/vm_utils.py:659 #: ../plugins/xenserver/xenapi/etc/xapi.d/plugins/pluginlib_nova.py:194 #, python-format msgid "Plugging VBD %s done." -msgstr "" +msgstr "O VDB %s foi conectado." #: ../nova/virt/xenapi/vm_utils.py:661 #, python-format msgid "VBD %(vbd)s plugged as %(orig_dev)s" -msgstr "" +msgstr "VBD %(vbd)s conectado como %(orig_dev)s" #: ../nova/virt/xenapi/vm_utils.py:664 #, python-format msgid "VBD %(vbd)s plugged into wrong dev, remapping to %(dev)s" -msgstr "" +msgstr "VBD %(vbd)s conectado no device errado, remapeando para %(dev)s" #: ../nova/virt/xenapi/vm_utils.py:668 #: ../plugins/xenserver/xenapi/etc/xapi.d/plugins/pluginlib_nova.py:197 #, python-format msgid "Destroying VBD for VDI %s ... " -msgstr "" +msgstr "Destruindo VBD para o VDI %s ... " #: ../nova/virt/xenapi/vm_utils.py:671 #: ../plugins/xenserver/xenapi/etc/xapi.d/plugins/pluginlib_nova.py:200 #, python-format msgid "Destroying VBD for VDI %s done." -msgstr "" +msgstr "O VBD para o VDI %s foi destruído." #: ../nova/virt/xenapi/vm_utils.py:683 #: ../plugins/xenserver/xenapi/etc/xapi.d/plugins/pluginlib_nova.py:211 @@ -954,7 +955,7 @@ msgstr "" #: ../plugins/xenserver/xenapi/etc/xapi.d/plugins/pluginlib_nova.py:223 #, python-format msgid "Ignoring XenAPI.Failure in VBD.unplug: %s" -msgstr "" +msgstr "Ignorando XenAPI.Failure em VBD.unplug: %s" #: ../nova/virt/xenapi/vm_utils.py:704 #: ../plugins/xenserver/xenapi/etc/xapi.d/plugins/pluginlib_nova.py:66 -- cgit From 80059b3e87f6ce7ab2ba18a135e5c469d2be8f88 Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Sun, 4 Sep 2011 01:19:21 -0500 Subject: correct floating ip id to increment in fake_network --- nova/tests/fake_network.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/tests/fake_network.py b/nova/tests/fake_network.py index 73a117c33..99b027cf3 100644 --- a/nova/tests/fake_network.py +++ b/nova/tests/fake_network.py @@ -93,7 +93,7 @@ flavor = {'id': 0, def floating_ips(fixed_ip_id): for i in xrange(154): - yield {'id': 0, + yield {'id': i, 'address': '10.10.10.%d' % (i + 100), 'fixed_ip_id': fixed_ip_id, 'project_id': None, -- cgit From 6b61a6be4a14444723e3728fb0fcdd77bac8fe74 Mon Sep 17 00:00:00 2001 From: Keisuke Tagami Date: Mon, 5 Sep 2011 14:45:41 +0900 Subject: Fix bug #835919 that output a option file for dnsmasq not to offer a default gateway on second vif. --- nova/db/sqlalchemy/api.py | 15 +++++++++++++ nova/network/linux_net.py | 55 +++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 68 insertions(+), 2 deletions(-) mode change 100644 => 100755 nova/db/sqlalchemy/api.py mode change 100644 => 100755 nova/network/linux_net.py diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py old mode 100644 new mode 100755 index b99667afc..aee1c2a55 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -1415,6 +1415,21 @@ def instance_get_all_by_reservation(context, reservation_id): filter_by(project_id=context.project_id).\ filter_by(deleted=False).\ all() + +@require_admin_context +def instance_get_all_by_network(context, network_id): + session = get_session() + return session.query(models.Instance).\ + options(joinedload_all('fixed_ips.floating_ips')).\ + options(joinedload('virtual_interfaces')).\ + options(joinedload('security_groups')).\ + options(joinedload_all('fixed_ips.network')).\ + options(joinedload('metadata')).\ + options(joinedload('instance_type')).\ + filter_by(deleted=can_read_deleted(context)).\ + filter_by(network_id=network_id).\ + all() + @require_context diff --git a/nova/network/linux_net.py b/nova/network/linux_net.py old mode 100644 new mode 100755 index 57c1d0c28..8d5a0bbbd --- a/nova/network/linux_net.py +++ b/nova/network/linux_net.py @@ -511,6 +511,35 @@ def get_dhcp_hosts(context, network_ref): return '\n'.join(hosts) +def get_dhcp_opts(context, network_ref): + """Get network's hosts config in dhcp-opts format.""" + # create a decision dictionary for default gateway for eache instance + default_gateway_network_node = dict() + network_id = network_ref['id'] + instance_refs = db.instance_get_all_by_network(context, network_id) + ips_ref = db.network_get_associated_fixed_ips(context, network_id) + + for instance_ref in instance_refs: + instance_id = instance_ref['id'] + # nic number is decided by from this function in xxx function + vifs = db.virtual_interface_get_by_instance(context, instance_id) + if not vifs: + continue + # offer a default gateway to the first virtual interface of instance + first_vif = vifs[0] + default_gateway_network_node[instance_id] = first_vif['network_id'] + + for fixed_ip_ref in ips_ref: + instance_id = fixed_ip_ref['instance_id'] + target_network_id = default_gateway_network_node[instance_id] + if target_network_id == fixed_ip_ref['network_id']: + hosts.append(_host_dhcp_opts(fixed_ip_ref, gw=True)) + else: + hosts.append(_host_dhcp_opts(fixed_ip_ref, gw=None)) + + return '\n'.join(hosts) + + # NOTE(ja): Sending a HUP only reloads the hostfile, so any # configuration options (like dchp-range, vlan, ...) # aren't reloaded. @@ -526,8 +555,13 @@ def update_dhcp(context, dev, network_ref): with open(conffile, 'w') as f: f.write(get_dhcp_hosts(context, network_ref)) + optsfile = _dhcp_file(dev, 'opts') + with open(optsfile, 'w') as f: + f.write(get_dhcp_opts(context, network_ref)) + # Make sure dnsmasq can actually read it (it setuid()s to "nobody") os.chmod(conffile, 0644) + os.chmod(optsfile, 0644) pid = _dnsmasq_pid_for(dev) @@ -559,6 +593,7 @@ def update_dhcp(context, dev, network_ref): '--dhcp-lease-max=%s' % len(netaddr.IPNetwork(network_ref['cidr'])), '--dhcp-hostsfile=%s' % _dhcp_file(dev, 'conf'), '--dhcp-script=%s' % FLAGS.dhcpbridge, + '--dhcp-optsfile=%s' % _dhcp_file(dev, 'opts'), '--leasefile-ro'] if FLAGS.dns_server: cmd += ['-h', '-R', '--server=%s' % FLAGS.dns_server] @@ -625,13 +660,29 @@ def _host_lease(fixed_ip_ref): instance_ref['hostname'] or '*') +def _host_dhcp_network(fixed_ip_ref): + instance_ref = fixed_ip_ref['instance'] + return 'NW-i%08d-%s' % (instance_ref['id'], + fixed_ip_ref['network_id']) + + def _host_dhcp(fixed_ip_ref): """Return a host string for an address in dhcp-host format.""" instance_ref = fixed_ip_ref['instance'] - return '%s,%s.%s,%s' % (fixed_ip_ref['virtual_interface']['address'], + return '%s,%s.%s,%s,%s' % (fixed_ip_ref['virtual_interface']['address'], instance_ref['hostname'], FLAGS.dhcp_domain, - fixed_ip_ref['address']) + fixed_ip_ref['address'], + "net:" + _host_dhcp_network(fixed_ip_ref)) + + +def _host_dhcp_opts(fixed_ip_ref, gw): + """Return a host string for an address in dhcp-host format.""" + if not gw: + return '%s,%s' % (_host_dhcp_network(fixed_ip_ref), + 3) + else: + return '' def _execute(*cmd, **kwargs): -- cgit From d6f1a31d56de84398246498d0f2676d9741cdccf Mon Sep 17 00:00:00 2001 From: Keisuke Tagami Date: Mon, 5 Sep 2011 20:23:28 +0900 Subject: implement unit test for linux_net --- nova/db/api.py | 5 + nova/network/linux_net.py | 17 ++-- nova/tests/test_linux_net.py | 232 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 247 insertions(+), 7 deletions(-) mode change 100644 => 100755 nova/db/api.py create mode 100755 nova/tests/test_linux_net.py diff --git a/nova/db/api.py b/nova/db/api.py old mode 100644 new mode 100755 index 148887635..85e9c7669 --- a/nova/db/api.py +++ b/nova/db/api.py @@ -532,6 +532,11 @@ def instance_get_all_by_reservation(context, reservation_id): return IMPL.instance_get_all_by_reservation(context, reservation_id) +def instance_get_all_by_network(context, network_id): + """Get all instances belonging to a network.""" + return IMPL.instance_get_all_by_network(context, network_id) + + def instance_get_by_fixed_ip(context, address): """Get an instance for a fixed ip by address.""" return IMPL.instance_get_by_fixed_ip(context, address) diff --git a/nova/network/linux_net.py b/nova/network/linux_net.py index 8d5a0bbbd..50d9ccf19 100755 --- a/nova/network/linux_net.py +++ b/nova/network/linux_net.py @@ -514,6 +514,7 @@ def get_dhcp_hosts(context, network_ref): def get_dhcp_opts(context, network_ref): """Get network's hosts config in dhcp-opts format.""" # create a decision dictionary for default gateway for eache instance + hosts = [] default_gateway_network_node = dict() network_id = network_ref['id'] instance_refs = db.instance_get_all_by_network(context, network_id) @@ -521,9 +522,10 @@ def get_dhcp_opts(context, network_ref): for instance_ref in instance_refs: instance_id = instance_ref['id'] - # nic number is decided by from this function in xxx function + # nic number is decided by xxx from this function in xxx function vifs = db.virtual_interface_get_by_instance(context, instance_id) - if not vifs: + if vifs == None: + default_gateway_network_node[instance_id] = None continue # offer a default gateway to the first virtual interface of instance first_vif = vifs[0] @@ -531,11 +533,12 @@ def get_dhcp_opts(context, network_ref): for fixed_ip_ref in ips_ref: instance_id = fixed_ip_ref['instance_id'] - target_network_id = default_gateway_network_node[instance_id] - if target_network_id == fixed_ip_ref['network_id']: - hosts.append(_host_dhcp_opts(fixed_ip_ref, gw=True)) - else: - hosts.append(_host_dhcp_opts(fixed_ip_ref, gw=None)) + if default_gateway_network_node.has_key(instance_id): + target_network_id = default_gateway_network_node[instance_id] + if target_network_id == fixed_ip_ref['network_id']: + hosts.append(_host_dhcp_opts(fixed_ip_ref, gw=True)) + else: + hosts.append(_host_dhcp_opts(fixed_ip_ref, gw=None)) return '\n'.join(hosts) diff --git a/nova/tests/test_linux_net.py b/nova/tests/test_linux_net.py new file mode 100755 index 000000000..3c3cdd0d9 --- /dev/null +++ b/nova/tests/test_linux_net.py @@ -0,0 +1,232 @@ +# vim: tabstop=4 shiftwidth=4 softtabstop=4 + +# Copyright 2011 NTT +# All Rights Reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); you may +# not use this file except in compliance with the License. You may obtain +# a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT +# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the +# License for the specific language governing permissions and limitations +# under the License. + +from nova import context +from nova import db +from nova import exception +from nova import log as logging +from nova import test +from nova import utils +from nova import flags +from nova.network import manager as network_manager + +import mox + +FLAGS = flags.FLAGS + +LOG = logging.getLogger('nova.tests.network') + + +HOST = "testhost" + +instances = [{'id': 0, + 'host': 'fake_instance00', + 'hostname': 'fake_instance00'}, + {'id': 1, + 'host': 'fake_instance01', + 'hostname': 'fake_instance01'}] + + +addresses = [{"address" : "10.0.0.1" }, + {"address" : "10.0.0.2" }, + {"address" : "10.0.0.3" }, + {"address" : "10.0.0.4" }] + + +networks = [{'id': 0, + 'uuid': "aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa", + 'label': 'test0', + 'injected': False, + 'multi_host': False, + 'cidr': '192.168.0.0/24', + 'cidr_v6': '2001:db8::/64', + 'gateway_v6': '2001:db8::1', + 'netmask_v6': '64', + 'netmask': '255.255.255.0', + 'bridge': 'fa0', + 'bridge_interface': 'fake_fa0', + 'gateway': '192.168.0.1', + 'broadcast': '192.168.0.255', + 'dns1': '192.168.0.1', + 'dns2': '192.168.0.2', + 'dhcp_server' : '0.0.0.0', + 'dhcp_start' : '192.168.100.1', + 'vlan': None, + 'host': None, + 'project_id': 'fake_project', + 'vpn_public_address': '192.168.0.2'}, + {'id': 1, + 'uuid': "bbbbbbbb-bbbb-bbbb-bbbb-bbbbbbbbbbbb", + 'label': 'test1', + 'injected': False, + 'multi_host': False, + 'cidr': '192.168.1.0/24', + 'cidr_v6': '2001:db9::/64', + 'gateway_v6': '2001:db9::1', + 'netmask_v6': '64', + 'netmask': '255.255.255.0', + 'bridge': 'fa1', + 'bridge_interface': 'fake_fa1', + 'gateway': '192.168.1.1', + 'broadcast': '192.168.1.255', + 'dns1': '192.168.0.1', + 'dns2': '192.168.0.2', + 'dhcp_server' : '0.0.0.0', + 'dhcp_start' : '192.168.100.1', + 'vlan': None, + 'host': None, + 'project_id': 'fake_project', + 'vpn_public_address': '192.168.1.2'}] + + +fixed_ips = [{'id': 0, + 'network_id': 0, + 'address': '192.168.0.100', + 'instance_id': 0, + 'allocated': True, + 'virtual_interface_id': 0, + 'virtual_interface' : addresses[0], + 'instance': instances[0], + 'floating_ips': []}, + {'id': 1, + 'network_id': 1, + 'address': '192.168.1.100', + 'instance_id': 0, + 'allocated': True, + 'virtual_interface_id': 1, + 'virtual_interface' : addresses[1], + 'instance': instances[0], + 'floating_ips': []}, + {'id': 2, + 'network_id': 0, + 'address': '192.168.0.101', + 'instance_id': 1, + 'allocated': True, + 'virtual_interface_id': 2, + 'virtual_interface' : addresses[2], + 'instance': instances[1], + 'floating_ips': []}, + {'id': 3, + 'network_id': 1, + 'address': '192.168.1.101', + 'instance_id': 1, + 'allocated': True, + 'virtual_interface_id': 3, + 'virtual_interface' : addresses[3], + 'instance': instances[1], + 'floating_ips': []}] + + + + +vifs = [{'id': 0, + 'address': 'DE:AD:BE:EF:00:00', + 'uuid': '00000000-0000-0000-0000-0000000000000000', + 'network_id': 0, + 'network': networks[0], + 'instance_id': 0}, + {'id': 1, + 'address': 'DE:AD:BE:EF:00:01', + 'uuid': '00000000-0000-0000-0000-0000000000000001', + 'network_id': 1, + 'network': networks[1], + 'instance_id': 0}, + {'id': 2, + 'address': 'DE:AD:BE:EF:00:02', + 'uuid': '00000000-0000-0000-0000-0000000000000002', + 'network_id': 1, + 'network': networks[1], + 'instance_id': 1}, + {'id': 3, + 'address': 'DE:AD:BE:EF:00:03', + 'uuid': '00000000-0000-0000-0000-0000000000000003', + 'network_id': 0, + 'network': networks[0], + 'instance_id': 1}] + + +class LinuxNetworkTestCase(test.TestCase): + + def setUp(self): + super(LinuxNetworkTestCase, self).setUp() + network_driver = FLAGS.network_driver + self.driver = utils.import_object(network_driver) + self.driver.db = db + + def test_update_dhcp(self): + self.mox.StubOutWithMock(db, 'network_get_associated_fixed_ips') + self.mox.StubOutWithMock(db, 'instance_get_all_by_network') + self.mox.StubOutWithMock(db, 'virtual_interface_get_by_instance') + + fixed_ips[1]['instance'] = instances[0] + db.network_get_associated_fixed_ips(mox.IgnoreArg(), + mox.IgnoreArg()).AndReturn(fixed_ips) + + db.instance_get_all_by_network(mox.IgnoreArg(), + mox.IgnoreArg()).AndReturn(instances) + db.network_get_associated_fixed_ips(mox.IgnoreArg(), + mox.IgnoreArg()).AndReturn(fixed_ips) + db.virtual_interface_get_by_instance(mox.IgnoreArg(), + mox.IgnoreArg()).AndReturn([vifs[0],vifs[1]]) + db.virtual_interface_get_by_instance(mox.IgnoreArg(), + mox.IgnoreArg()).AndReturn([vifs[2],vifs[3]]) + + self.mox.ReplayAll() + self.driver.update_dhcp(None, "eth0", networks[0]) + + + def test_get_dhcp_hosts(self): + self.mox.StubOutWithMock(db, 'network_get_associated_fixed_ips') + + fixed_ips[1]['instance'] = instances[0] + db.network_get_associated_fixed_ips(mox.IgnoreArg(), + mox.IgnoreArg()).AndReturn(fixed_ips) + + self.mox.ReplayAll() + + hosts = self.driver.get_dhcp_hosts(None, networks[0]) + + self.assertEquals(hosts, + "10.0.0.1,fake_instance00.novalocal,192.168.0.100,net:NW-i00000000-0\n" \ + "10.0.0.2,fake_instance00.novalocal,192.168.1.100,net:NW-i00000000-1\n" \ + "10.0.0.3,fake_instance01.novalocal,192.168.0.101,net:NW-i00000001-0\n" \ + "10.0.0.4,fake_instance01.novalocal,192.168.1.101,net:NW-i00000001-1") + + + def test_get_dhcp_opts(self): + self.mox.StubOutWithMock(db, 'network_get_associated_fixed_ips') + self.mox.StubOutWithMock(db, 'instance_get_all_by_network') + self.mox.StubOutWithMock(db, 'virtual_interface_get_by_instance') + + fixed_ips[1]['instance'] = instances[0] + + db.instance_get_all_by_network(mox.IgnoreArg(), + mox.IgnoreArg()).AndReturn(instances) + db.network_get_associated_fixed_ips(mox.IgnoreArg(), + mox.IgnoreArg()).AndReturn(fixed_ips) + db.virtual_interface_get_by_instance(mox.IgnoreArg(), + mox.IgnoreArg()).AndReturn([vifs[0],vifs[1]]) + db.virtual_interface_get_by_instance(mox.IgnoreArg(), + mox.IgnoreArg()).AndReturn([vifs[2],vifs[3]]) + + self.mox.ReplayAll() + + opts = self.driver.get_dhcp_opts(None, networks[0]) + self.assertEquals(opts, '\nNW-i00000000-1,3\nNW-i00000001-0,3\n') + + + -- cgit From 418923c385a34265dd33a0c2ada3aa97a5749a06 Mon Sep 17 00:00:00 2001 From: Keisuke Tagami Date: Mon, 5 Sep 2011 21:13:00 +0900 Subject: format for pep8 --- nova/db/api.py | 4 +- nova/db/sqlalchemy/api.py | 5 +- nova/network/linux_net.py | 6 +- nova/tests/test_linux_net.py | 177 ++++++++++++++++++++++++++++++++----------- 4 files changed, 141 insertions(+), 51 deletions(-) diff --git a/nova/db/api.py b/nova/db/api.py index 85e9c7669..faac13966 100755 --- a/nova/db/api.py +++ b/nova/db/api.py @@ -535,8 +535,8 @@ def instance_get_all_by_reservation(context, reservation_id): def instance_get_all_by_network(context, network_id): """Get all instances belonging to a network.""" return IMPL.instance_get_all_by_network(context, network_id) - - + + def instance_get_by_fixed_ip(context, address): """Get an instance for a fixed ip by address.""" return IMPL.instance_get_by_fixed_ip(context, address) diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index aee1c2a55..3194a5231 100755 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -1415,8 +1415,8 @@ def instance_get_all_by_reservation(context, reservation_id): filter_by(project_id=context.project_id).\ filter_by(deleted=False).\ all() - -@require_admin_context + + def instance_get_all_by_network(context, network_id): session = get_session() return session.query(models.Instance).\ @@ -1431,7 +1431,6 @@ def instance_get_all_by_network(context, network_id): all() - @require_context def instance_get_by_fixed_ip(context, address): """Return instance ref by exact match of FixedIP""" diff --git a/nova/network/linux_net.py b/nova/network/linux_net.py index 50d9ccf19..4ebc3df23 100755 --- a/nova/network/linux_net.py +++ b/nova/network/linux_net.py @@ -438,7 +438,7 @@ def ensure_vpn_forward(public_ip, port, private_ip): def ensure_floating_forward(floating_ip, fixed_ip): """Ensure floating ip forwarding rule.""" - for chain, rule in floating_forward_rules(floating_ip, fixed_ip): + for chain, rule in floating_forward_rules(floaing_ip, fixed_ip): iptables_manager.ipv4['nat'].add_rule(chain, rule) iptables_manager.apply() @@ -518,7 +518,7 @@ def get_dhcp_opts(context, network_ref): default_gateway_network_node = dict() network_id = network_ref['id'] instance_refs = db.instance_get_all_by_network(context, network_id) - ips_ref = db.network_get_associated_fixed_ips(context, network_id) + ips_ref = db.network_get_associated_fixed_ips(context, network_id) for instance_ref in instance_refs: instance_id = instance_ref['id'] @@ -533,7 +533,7 @@ def get_dhcp_opts(context, network_ref): for fixed_ip_ref in ips_ref: instance_id = fixed_ip_ref['instance_id'] - if default_gateway_network_node.has_key(instance_id): + if instance_id in default_gateway_network_node: target_network_id = default_gateway_network_node[instance_id] if target_network_id == fixed_ip_ref['network_id']: hosts.append(_host_dhcp_opts(fixed_ip_ref, gw=True)) diff --git a/nova/tests/test_linux_net.py b/nova/tests/test_linux_net.py index 3c3cdd0d9..94c53817b 100755 --- a/nova/tests/test_linux_net.py +++ b/nova/tests/test_linux_net.py @@ -41,10 +41,10 @@ instances = [{'id': 0, 'hostname': 'fake_instance01'}] -addresses = [{"address" : "10.0.0.1" }, - {"address" : "10.0.0.2" }, - {"address" : "10.0.0.3" }, - {"address" : "10.0.0.4" }] +addresses = [{"address": "10.0.0.1"}, + {"address": "10.0.0.2"}, + {"address": "10.0.0.3"}, + {"address": "10.0.0.4"}] networks = [{'id': 0, @@ -63,8 +63,8 @@ networks = [{'id': 0, 'broadcast': '192.168.0.255', 'dns1': '192.168.0.1', 'dns2': '192.168.0.2', - 'dhcp_server' : '0.0.0.0', - 'dhcp_start' : '192.168.100.1', + 'dhcp_server': '0.0.0.0', + 'dhcp_start': '192.168.100.1', 'vlan': None, 'host': None, 'project_id': 'fake_project', @@ -85,8 +85,8 @@ networks = [{'id': 0, 'broadcast': '192.168.1.255', 'dns1': '192.168.0.1', 'dns2': '192.168.0.2', - 'dhcp_server' : '0.0.0.0', - 'dhcp_start' : '192.168.100.1', + 'dhcp_server': '0.0.0.0', + 'dhcp_start': '192.168.100.1', 'vlan': None, 'host': None, 'project_id': 'fake_project', @@ -99,7 +99,7 @@ fixed_ips = [{'id': 0, 'instance_id': 0, 'allocated': True, 'virtual_interface_id': 0, - 'virtual_interface' : addresses[0], + 'virtual_interface': addresses[0], 'instance': instances[0], 'floating_ips': []}, {'id': 1, @@ -108,7 +108,7 @@ fixed_ips = [{'id': 0, 'instance_id': 0, 'allocated': True, 'virtual_interface_id': 1, - 'virtual_interface' : addresses[1], + 'virtual_interface': addresses[1], 'instance': instances[0], 'floating_ips': []}, {'id': 2, @@ -117,7 +117,7 @@ fixed_ips = [{'id': 0, 'instance_id': 1, 'allocated': True, 'virtual_interface_id': 2, - 'virtual_interface' : addresses[2], + 'virtual_interface': addresses[2], 'instance': instances[1], 'floating_ips': []}, {'id': 3, @@ -126,13 +126,11 @@ fixed_ips = [{'id': 0, 'instance_id': 1, 'allocated': True, 'virtual_interface_id': 3, - 'virtual_interface' : addresses[3], + 'virtual_interface': addresses[3], 'instance': instances[1], 'floating_ips': []}] - - vifs = [{'id': 0, 'address': 'DE:AD:BE:EF:00:00', 'uuid': '00000000-0000-0000-0000-0000000000000000', @@ -167,66 +165,159 @@ class LinuxNetworkTestCase(test.TestCase): self.driver = utils.import_object(network_driver) self.driver.db = db - def test_update_dhcp(self): + def test_update_dhcp_for_nw00(self): self.mox.StubOutWithMock(db, 'network_get_associated_fixed_ips') self.mox.StubOutWithMock(db, 'instance_get_all_by_network') self.mox.StubOutWithMock(db, 'virtual_interface_get_by_instance') - fixed_ips[1]['instance'] = instances[0] db.network_get_associated_fixed_ips(mox.IgnoreArg(), - mox.IgnoreArg()).AndReturn(fixed_ips) + mox.IgnoreArg())\ + .AndReturn([fixed_ips[0], + fixed_ips[3]]) db.instance_get_all_by_network(mox.IgnoreArg(), - mox.IgnoreArg()).AndReturn(instances) + mox.IgnoreArg())\ + .AndReturn(instances) db.network_get_associated_fixed_ips(mox.IgnoreArg(), - mox.IgnoreArg()).AndReturn(fixed_ips) + mox.IgnoreArg())\ + .AndReturn([fixed_ips[0], + fixed_ips[3]]) db.virtual_interface_get_by_instance(mox.IgnoreArg(), - mox.IgnoreArg()).AndReturn([vifs[0],vifs[1]]) + mox.IgnoreArg())\ + .AndReturn([vifs[0], vifs[1]]) db.virtual_interface_get_by_instance(mox.IgnoreArg(), - mox.IgnoreArg()).AndReturn([vifs[2],vifs[3]]) - + mox.IgnoreArg())\ + .AndReturn([vifs[2], vifs[3]]) self.mox.ReplayAll() + self.driver.update_dhcp(None, "eth0", networks[0]) + def test_update_dhcp_for_nw01(self): + self.mox.StubOutWithMock(db, 'network_get_associated_fixed_ips') + self.mox.StubOutWithMock(db, 'instance_get_all_by_network') + self.mox.StubOutWithMock(db, 'virtual_interface_get_by_instance') + + db.network_get_associated_fixed_ips(mox.IgnoreArg(), + mox.IgnoreArg())\ + .AndReturn([fixed_ips[1], + fixed_ips[2]]) - def test_get_dhcp_hosts(self): + db.instance_get_all_by_network(mox.IgnoreArg(), + mox.IgnoreArg())\ + .AndReturn(instances) + db.network_get_associated_fixed_ips(mox.IgnoreArg(), + mox.IgnoreArg())\ + .AndReturn([fixed_ips[1], + fixed_ips[2]]) + db.virtual_interface_get_by_instance(mox.IgnoreArg(), + mox.IgnoreArg())\ + .AndReturn([vifs[0], vifs[1]]) + db.virtual_interface_get_by_instance(mox.IgnoreArg(), + mox.IgnoreArg())\ + .AndReturn([vifs[2], vifs[3]]) + self.mox.ReplayAll() + + self.driver.update_dhcp(None, "eth0", networks[0]) + + def test_get_dhcp_hosts_for_nw00(self): self.mox.StubOutWithMock(db, 'network_get_associated_fixed_ips') - fixed_ips[1]['instance'] = instances[0] db.network_get_associated_fixed_ips(mox.IgnoreArg(), - mox.IgnoreArg()).AndReturn(fixed_ips) + mox.IgnoreArg())\ + .AndReturn([fixed_ips[0], + fixed_ips[3]]) + self.mox.ReplayAll() + + expected = \ + "10.0.0.1,fake_instance00.novalocal,"\ + "192.168.0.100,net:NW-i00000000-0\n"\ + "10.0.0.4,fake_instance01.novalocal,"\ + "192.168.1.101,net:NW-i00000001-1" + actual_hosts = self.driver.get_dhcp_hosts(None, networks[1]) + self.assertEquals(actual_hosts, expected) + + def test_get_dhcp_hosts_for_nw01(self): + self.mox.StubOutWithMock(db, 'network_get_associated_fixed_ips') + + db.network_get_associated_fixed_ips(mox.IgnoreArg(), + mox.IgnoreArg())\ + .AndReturn([fixed_ips[1], + fixed_ips[2]]) self.mox.ReplayAll() - hosts = self.driver.get_dhcp_hosts(None, networks[0]) - - self.assertEquals(hosts, - "10.0.0.1,fake_instance00.novalocal,192.168.0.100,net:NW-i00000000-0\n" \ - "10.0.0.2,fake_instance00.novalocal,192.168.1.100,net:NW-i00000000-1\n" \ - "10.0.0.3,fake_instance01.novalocal,192.168.0.101,net:NW-i00000001-0\n" \ - "10.0.0.4,fake_instance01.novalocal,192.168.1.101,net:NW-i00000001-1") + expected = \ + "10.0.0.2,fake_instance00.novalocal,"\ + "192.168.1.100,net:NW-i00000000-1\n"\ + "10.0.0.3,fake_instance01.novalocal,"\ + "192.168.0.101,net:NW-i00000001-0" + actual_hosts = self.driver.get_dhcp_hosts(None, networks[0]) + + self.assertEquals(actual_hosts, expected) - - def test_get_dhcp_opts(self): + def test_get_dhcp_opts_for_nw00(self): self.mox.StubOutWithMock(db, 'network_get_associated_fixed_ips') self.mox.StubOutWithMock(db, 'instance_get_all_by_network') self.mox.StubOutWithMock(db, 'virtual_interface_get_by_instance') - fixed_ips[1]['instance'] = instances[0] - db.instance_get_all_by_network(mox.IgnoreArg(), - mox.IgnoreArg()).AndReturn(instances) + mox.IgnoreArg())\ + .AndReturn(instances) db.network_get_associated_fixed_ips(mox.IgnoreArg(), - mox.IgnoreArg()).AndReturn(fixed_ips) + mox.IgnoreArg())\ + .AndReturn([fixed_ips[0], + fixed_ips[3]]) db.virtual_interface_get_by_instance(mox.IgnoreArg(), - mox.IgnoreArg()).AndReturn([vifs[0],vifs[1]]) + mox.IgnoreArg())\ + .AndReturn([vifs[0], + vifs[1]]) db.virtual_interface_get_by_instance(mox.IgnoreArg(), - mox.IgnoreArg()).AndReturn([vifs[2],vifs[3]]) + mox.IgnoreArg())\ + .AndReturn([vifs[2], + vifs[3]]) + self.mox.ReplayAll() + + expected_opts = '\n'\ + '' + actual_opts = self.driver.get_dhcp_opts(None, networks[0]) + self.assertEquals(actual_opts, expected_opts) + + def test_get_dhcp_opts_for_nw01(self): + self.mox.StubOutWithMock(db, 'network_get_associated_fixed_ips') + self.mox.StubOutWithMock(db, 'instance_get_all_by_network') + self.mox.StubOutWithMock(db, 'virtual_interface_get_by_instance') + + db.instance_get_all_by_network(mox.IgnoreArg(), + mox.IgnoreArg())\ + .AndReturn(instances) + db.network_get_associated_fixed_ips(mox.IgnoreArg(), + mox.IgnoreArg())\ + .AndReturn([fixed_ips[1], + fixed_ips[2]]) + db.virtual_interface_get_by_instance(mox.IgnoreArg(), + mox.IgnoreArg())\ + .AndReturn([vifs[0], + vifs[1]]) + db.virtual_interface_get_by_instance(mox.IgnoreArg(), + mox.IgnoreArg())\ + .AndReturn([vifs[2], + vifs[3]]) self.mox.ReplayAll() - opts = self.driver.get_dhcp_opts(None, networks[0]) - self.assertEquals(opts, '\nNW-i00000000-1,3\nNW-i00000001-0,3\n') + expected_opts = 'NW-i00000000-1,3\n'\ + 'NW-i00000001-0,3' + actual_opts = self.driver.get_dhcp_opts(None, networks[1]) + + self.assertEquals(actual_opts, expected_opts) + + def test_dhcp_opts_default_gateway_network(self): + expected = "" + actual = self.driver._host_dhcp_opts(fixed_ips[0], True) + self.assertEquals(actual, expected) - + def test_dhcp_opts_not_default_gateway_network(self): + expected = "NW-i00000000-0,3" + actual = self.driver._host_dhcp_opts(fixed_ips[0], False) + self.assertEquals(actual, expected) -- cgit From 14314701bac27ce0e913f8e0587c354819a4bd9e Mon Sep 17 00:00:00 2001 From: Keisuke Tagami Date: Mon, 5 Sep 2011 21:32:52 +0900 Subject: format for pep8 --- nova/tests/test_linux_net.py | 1 - 1 file changed, 1 deletion(-) diff --git a/nova/tests/test_linux_net.py b/nova/tests/test_linux_net.py index 94c53817b..93d9b02c9 100755 --- a/nova/tests/test_linux_net.py +++ b/nova/tests/test_linux_net.py @@ -316,7 +316,6 @@ class LinuxNetworkTestCase(test.TestCase): actual = self.driver._host_dhcp_opts(fixed_ips[0], True) self.assertEquals(actual, expected) - def test_dhcp_opts_not_default_gateway_network(self): expected = "NW-i00000000-0,3" actual = self.driver._host_dhcp_opts(fixed_ips[0], False) -- cgit From b9ef3dcaa241088e205e170ca0a236afb0ea34dd Mon Sep 17 00:00:00 2001 From: Keisuke Tagami Date: Tue, 6 Sep 2011 10:10:25 +0900 Subject: added me to Authors --- Authors | 1 + 1 file changed, 1 insertion(+) diff --git a/Authors b/Authors index b9e7a7d23..f775c6f0c 100644 --- a/Authors +++ b/Authors @@ -60,6 +60,7 @@ Joshua McKenty Justin Santa Barbara Justin Shepherd Kei Masumoto +Keisuke Tagami masumoto Ken Pepple Kevin Bringard -- cgit From b922e08a6c15eeaab1f7ec342c00673b610d0e76 Mon Sep 17 00:00:00 2001 From: Keisuke Tagami Date: Tue, 6 Sep 2011 10:14:27 +0900 Subject: correct a method to collect instances from db add interface data to test --- nova/db/api.py | 5 --- nova/db/sqlalchemy/api.py | 14 --------- nova/network/linux_net.py | 8 +++-- nova/tests/test_linux_net.py | 74 +++++++++++++++++++++++++++++--------------- 4 files changed, 54 insertions(+), 47 deletions(-) diff --git a/nova/db/api.py b/nova/db/api.py index faac13966..148887635 100755 --- a/nova/db/api.py +++ b/nova/db/api.py @@ -532,11 +532,6 @@ def instance_get_all_by_reservation(context, reservation_id): return IMPL.instance_get_all_by_reservation(context, reservation_id) -def instance_get_all_by_network(context, network_id): - """Get all instances belonging to a network.""" - return IMPL.instance_get_all_by_network(context, network_id) - - def instance_get_by_fixed_ip(context, address): """Get an instance for a fixed ip by address.""" return IMPL.instance_get_by_fixed_ip(context, address) diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index 3194a5231..b99667afc 100755 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -1417,20 +1417,6 @@ def instance_get_all_by_reservation(context, reservation_id): all() -def instance_get_all_by_network(context, network_id): - session = get_session() - return session.query(models.Instance).\ - options(joinedload_all('fixed_ips.floating_ips')).\ - options(joinedload('virtual_interfaces')).\ - options(joinedload('security_groups')).\ - options(joinedload_all('fixed_ips.network')).\ - options(joinedload('metadata')).\ - options(joinedload('instance_type')).\ - filter_by(deleted=can_read_deleted(context)).\ - filter_by(network_id=network_id).\ - all() - - @require_context def instance_get_by_fixed_ip(context, address): """Return instance ref by exact match of FixedIP""" diff --git a/nova/network/linux_net.py b/nova/network/linux_net.py index 4ebc3df23..c26e3574e 100755 --- a/nova/network/linux_net.py +++ b/nova/network/linux_net.py @@ -517,11 +517,13 @@ def get_dhcp_opts(context, network_ref): hosts = [] default_gateway_network_node = dict() network_id = network_ref['id'] - instance_refs = db.instance_get_all_by_network(context, network_id) + instance_set = set() ips_ref = db.network_get_associated_fixed_ips(context, network_id) - for instance_ref in instance_refs: - instance_id = instance_ref['id'] + for fixed_ip_ref in ips_ref: + instance_set.add(fixed_ip_ref['instance_id']) + + for instance_id in instance_set: # nic number is decided by xxx from this function in xxx function vifs = db.virtual_interface_get_by_instance(context, instance_id) if vifs == None: diff --git a/nova/tests/test_linux_net.py b/nova/tests/test_linux_net.py index 93d9b02c9..3f44fbd05 100755 --- a/nova/tests/test_linux_net.py +++ b/nova/tests/test_linux_net.py @@ -18,10 +18,10 @@ from nova import context from nova import db from nova import exception +from nova import flags from nova import log as logging from nova import test from nova import utils -from nova import flags from nova.network import manager as network_manager import mox @@ -44,7 +44,9 @@ instances = [{'id': 0, addresses = [{"address": "10.0.0.1"}, {"address": "10.0.0.2"}, {"address": "10.0.0.3"}, - {"address": "10.0.0.4"}] + {"address": "10.0.0.4"}, + {"address": "10.0.0.5"}, + {"address": "10.0.0.6"}] networks = [{'id': 0, @@ -128,6 +130,24 @@ fixed_ips = [{'id': 0, 'virtual_interface_id': 3, 'virtual_interface': addresses[3], 'instance': instances[1], + 'floating_ips': []}, + {'id': 4, + 'network_id': 0, + 'address': '192.168.0.102', + 'instance_id': 0, + 'allocated': True, + 'virtual_interface_id': 4, + 'virtual_interface': addresses[4], + 'instance': instances[0], + 'floating_ips': []}, + {'id': 5, + 'network_id': 1, + 'address': '192.168.1.102', + 'instance_id': 1, + 'allocated': True, + 'virtual_interface_id': 5, + 'virtual_interface': addresses[5], + 'instance': instances[1], 'floating_ips': []}] @@ -154,6 +174,18 @@ vifs = [{'id': 0, 'uuid': '00000000-0000-0000-0000-0000000000000003', 'network_id': 0, 'network': networks[0], + 'instance_id': 1}, + {'id': 4, + 'address': 'DE:AD:BE:EF:00:04', + 'uuid': '00000000-0000-0000-0000-0000000000000004', + 'network_id': 0, + 'network': networks[0], + 'instance_id': 0}, + {'id': 5, + 'address': 'DE:AD:BE:EF:00:05', + 'uuid': '00000000-0000-0000-0000-0000000000000005', + 'network_id': 1, + 'network': networks[1], 'instance_id': 1}] @@ -167,7 +199,6 @@ class LinuxNetworkTestCase(test.TestCase): def test_update_dhcp_for_nw00(self): self.mox.StubOutWithMock(db, 'network_get_associated_fixed_ips') - self.mox.StubOutWithMock(db, 'instance_get_all_by_network') self.mox.StubOutWithMock(db, 'virtual_interface_get_by_instance') db.network_get_associated_fixed_ips(mox.IgnoreArg(), @@ -175,9 +206,6 @@ class LinuxNetworkTestCase(test.TestCase): .AndReturn([fixed_ips[0], fixed_ips[3]]) - db.instance_get_all_by_network(mox.IgnoreArg(), - mox.IgnoreArg())\ - .AndReturn(instances) db.network_get_associated_fixed_ips(mox.IgnoreArg(), mox.IgnoreArg())\ .AndReturn([fixed_ips[0], @@ -194,7 +222,6 @@ class LinuxNetworkTestCase(test.TestCase): def test_update_dhcp_for_nw01(self): self.mox.StubOutWithMock(db, 'network_get_associated_fixed_ips') - self.mox.StubOutWithMock(db, 'instance_get_all_by_network') self.mox.StubOutWithMock(db, 'virtual_interface_get_by_instance') db.network_get_associated_fixed_ips(mox.IgnoreArg(), @@ -202,9 +229,6 @@ class LinuxNetworkTestCase(test.TestCase): .AndReturn([fixed_ips[1], fixed_ips[2]]) - db.instance_get_all_by_network(mox.IgnoreArg(), - mox.IgnoreArg())\ - .AndReturn(instances) db.network_get_associated_fixed_ips(mox.IgnoreArg(), mox.IgnoreArg())\ .AndReturn([fixed_ips[1], @@ -257,27 +281,27 @@ class LinuxNetworkTestCase(test.TestCase): def test_get_dhcp_opts_for_nw00(self): self.mox.StubOutWithMock(db, 'network_get_associated_fixed_ips') - self.mox.StubOutWithMock(db, 'instance_get_all_by_network') self.mox.StubOutWithMock(db, 'virtual_interface_get_by_instance') - db.instance_get_all_by_network(mox.IgnoreArg(), - mox.IgnoreArg())\ - .AndReturn(instances) db.network_get_associated_fixed_ips(mox.IgnoreArg(), mox.IgnoreArg())\ .AndReturn([fixed_ips[0], - fixed_ips[3]]) + fixed_ips[3], + fixed_ips[4]]) db.virtual_interface_get_by_instance(mox.IgnoreArg(), mox.IgnoreArg())\ .AndReturn([vifs[0], - vifs[1]]) + vifs[1], + vifs[4]]) db.virtual_interface_get_by_instance(mox.IgnoreArg(), mox.IgnoreArg())\ .AndReturn([vifs[2], - vifs[3]]) + vifs[3], + vifs[5]]) self.mox.ReplayAll() expected_opts = '\n'\ + '\n'\ '' actual_opts = self.driver.get_dhcp_opts(None, networks[0]) @@ -285,28 +309,28 @@ class LinuxNetworkTestCase(test.TestCase): def test_get_dhcp_opts_for_nw01(self): self.mox.StubOutWithMock(db, 'network_get_associated_fixed_ips') - self.mox.StubOutWithMock(db, 'instance_get_all_by_network') self.mox.StubOutWithMock(db, 'virtual_interface_get_by_instance') - db.instance_get_all_by_network(mox.IgnoreArg(), - mox.IgnoreArg())\ - .AndReturn(instances) db.network_get_associated_fixed_ips(mox.IgnoreArg(), mox.IgnoreArg())\ .AndReturn([fixed_ips[1], - fixed_ips[2]]) + fixed_ips[2], + fixed_ips[5]]) db.virtual_interface_get_by_instance(mox.IgnoreArg(), mox.IgnoreArg())\ .AndReturn([vifs[0], - vifs[1]]) + vifs[1], + vifs[4]]) db.virtual_interface_get_by_instance(mox.IgnoreArg(), mox.IgnoreArg())\ .AndReturn([vifs[2], - vifs[3]]) + vifs[3], + vifs[5]]) self.mox.ReplayAll() expected_opts = 'NW-i00000000-1,3\n'\ - 'NW-i00000001-0,3' + 'NW-i00000001-0,3\n'\ + 'NW-i00000002-1,3' actual_opts = self.driver.get_dhcp_opts(None, networks[1]) self.assertEquals(actual_opts, expected_opts) -- cgit From 00c3cbe8621918fdd60f9068df2a41db52a7f76f Mon Sep 17 00:00:00 2001 From: Keisuke Tagami Date: Tue, 6 Sep 2011 10:20:28 +0900 Subject: revert codes for db --- nova/db/api.py | 0 nova/db/sqlalchemy/api.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 nova/db/api.py mode change 100755 => 100644 nova/db/sqlalchemy/api.py diff --git a/nova/db/api.py b/nova/db/api.py old mode 100755 new mode 100644 diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py old mode 100755 new mode 100644 -- cgit From d4668c7351fab83930a6fe5ee8f67dabe8027b48 Mon Sep 17 00:00:00 2001 From: Keisuke Tagami Date: Tue, 6 Sep 2011 13:57:14 +0900 Subject: fix a mistaking of deletion in ensure_floating_forward --- nova/network/linux_net.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/network/linux_net.py b/nova/network/linux_net.py index c26e3574e..48438760a 100755 --- a/nova/network/linux_net.py +++ b/nova/network/linux_net.py @@ -438,7 +438,7 @@ def ensure_vpn_forward(public_ip, port, private_ip): def ensure_floating_forward(floating_ip, fixed_ip): """Ensure floating ip forwarding rule.""" - for chain, rule in floating_forward_rules(floaing_ip, fixed_ip): + for chain, rule in floating_forward_rules(floating_ip, fixed_ip): iptables_manager.ipv4['nat'].add_rule(chain, rule) iptables_manager.apply() -- cgit From 6c55199d3ec900cea771e4f8077c87efa968c2f0 Mon Sep 17 00:00:00 2001 From: Keisuke Tagami Date: Tue, 6 Sep 2011 17:20:10 +0900 Subject: fix a mistaking of dataset and expected values on small test. --- nova/tests/test_linux_net.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/nova/tests/test_linux_net.py b/nova/tests/test_linux_net.py index 3f44fbd05..be6faa07b 100755 --- a/nova/tests/test_linux_net.py +++ b/nova/tests/test_linux_net.py @@ -114,7 +114,7 @@ fixed_ips = [{'id': 0, 'instance': instances[0], 'floating_ips': []}, {'id': 2, - 'network_id': 0, + 'network_id': 1, 'address': '192.168.0.101', 'instance_id': 1, 'allocated': True, @@ -123,7 +123,7 @@ fixed_ips = [{'id': 0, 'instance': instances[1], 'floating_ips': []}, {'id': 3, - 'network_id': 1, + 'network_id': 0, 'address': '192.168.1.101', 'instance_id': 1, 'allocated': True, @@ -256,7 +256,7 @@ class LinuxNetworkTestCase(test.TestCase): "10.0.0.1,fake_instance00.novalocal,"\ "192.168.0.100,net:NW-i00000000-0\n"\ "10.0.0.4,fake_instance01.novalocal,"\ - "192.168.1.101,net:NW-i00000001-1" + "192.168.1.101,net:NW-i00000001-0" actual_hosts = self.driver.get_dhcp_hosts(None, networks[1]) self.assertEquals(actual_hosts, expected) @@ -274,7 +274,7 @@ class LinuxNetworkTestCase(test.TestCase): "10.0.0.2,fake_instance00.novalocal,"\ "192.168.1.100,net:NW-i00000000-1\n"\ "10.0.0.3,fake_instance01.novalocal,"\ - "192.168.0.101,net:NW-i00000001-0" + "192.168.0.101,net:NW-i00000001-1" actual_hosts = self.driver.get_dhcp_hosts(None, networks[0]) self.assertEquals(actual_hosts, expected) @@ -301,7 +301,7 @@ class LinuxNetworkTestCase(test.TestCase): self.mox.ReplayAll() expected_opts = '\n'\ - '\n'\ + 'NW-i00000001-0,3\n'\ '' actual_opts = self.driver.get_dhcp_opts(None, networks[0]) @@ -329,8 +329,8 @@ class LinuxNetworkTestCase(test.TestCase): self.mox.ReplayAll() expected_opts = 'NW-i00000000-1,3\n'\ - 'NW-i00000001-0,3\n'\ - 'NW-i00000002-1,3' + '\n'\ + '' actual_opts = self.driver.get_dhcp_opts(None, networks[1]) self.assertEquals(actual_opts, expected_opts) -- cgit From 27b052c1aa2b5ae191c2e2986788c152eef9c221 Mon Sep 17 00:00:00 2001 From: "Kevin L. Mitchell" Date: Tue, 6 Sep 2011 14:36:58 -0500 Subject: novaclient v1_0 has an ipgroups argument, but novaclient v1_1 doesn't --- nova/scheduler/abstract_scheduler.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/nova/scheduler/abstract_scheduler.py b/nova/scheduler/abstract_scheduler.py index 7f17b642f..be6267d3a 100644 --- a/nova/scheduler/abstract_scheduler.py +++ b/nova/scheduler/abstract_scheduler.py @@ -110,7 +110,6 @@ class AbstractScheduler(driver.Scheduler): flavor_id = instance_type['flavorid'] reservation_id = instance_properties['reservation_id'] files = kwargs['injected_files'] - ipgroup = None # Not supported in OS API ... yet child_zone = zone_info['child_zone'] child_blob = zone_info['child_blob'] zone = db.zone_get(context, child_zone) @@ -124,8 +123,9 @@ class AbstractScheduler(driver.Scheduler): except novaclient_exceptions.BadRequest, e: raise exception.NotAuthorized(_("Bad credentials attempting " "to talk to zone at %(url)s.") % locals()) - nova.servers.create(name, image_ref, flavor_id, ipgroup, meta, files, - child_blob, reservation_id=reservation_id) + nova.servers.create(name, image_ref, flavor_id, + meta=meta, files=files, zone_blob=child_blob, + reservation_id=reservation_id) def _provision_resource_from_blob(self, context, build_plan_item, instance_id, request_spec, kwargs): -- cgit From 53357516226a1c00217c742eb512b7efc0f574b2 Mon Sep 17 00:00:00 2001 From: Tushar Patil Date: Tue, 6 Sep 2011 18:01:57 -0700 Subject: Added use_single_default_gateway to switch from multiple default gateways to single default gateway --- nova/network/linux_net.py | 72 ++++++++++++++++++++------------------------ nova/tests/test_linux_net.py | 17 +++-------- 2 files changed, 38 insertions(+), 51 deletions(-) diff --git a/nova/network/linux_net.py b/nova/network/linux_net.py index 48438760a..affdde701 100755 --- a/nova/network/linux_net.py +++ b/nova/network/linux_net.py @@ -68,6 +68,9 @@ flags.DEFINE_string('linuxnet_interface_driver', 'Driver used to create ethernet devices.') flags.DEFINE_string('linuxnet_ovs_integration_bridge', 'br-int', 'Name of Open vSwitch bridge used with linuxnet') +flags.DEFINE_bool('use_single_default_gateway', + False, 'Use single default gateway. Only first nic of vm' + ' will get default gateway from dhcp server') binary_name = os.path.basename(inspect.stack()[-1][1]) @@ -513,35 +516,27 @@ def get_dhcp_hosts(context, network_ref): def get_dhcp_opts(context, network_ref): """Get network's hosts config in dhcp-opts format.""" - # create a decision dictionary for default gateway for eache instance hosts = [] - default_gateway_network_node = dict() - network_id = network_ref['id'] - instance_set = set() - ips_ref = db.network_get_associated_fixed_ips(context, network_id) - - for fixed_ip_ref in ips_ref: - instance_set.add(fixed_ip_ref['instance_id']) - - for instance_id in instance_set: - # nic number is decided by xxx from this function in xxx function - vifs = db.virtual_interface_get_by_instance(context, instance_id) - if vifs == None: - default_gateway_network_node[instance_id] = None - continue - # offer a default gateway to the first virtual interface of instance - first_vif = vifs[0] - default_gateway_network_node[instance_id] = first_vif['network_id'] - - for fixed_ip_ref in ips_ref: - instance_id = fixed_ip_ref['instance_id'] - if instance_id in default_gateway_network_node: - target_network_id = default_gateway_network_node[instance_id] - if target_network_id == fixed_ip_ref['network_id']: - hosts.append(_host_dhcp_opts(fixed_ip_ref, gw=True)) - else: - hosts.append(_host_dhcp_opts(fixed_ip_ref, gw=None)) - + ips_ref = db.network_get_associated_fixed_ips(context, network_ref['id']) + + if ips_ref: + #set of instance ids + instance_set = set([fixed_ip_ref['instance_id'] + for fixed_ip_ref in ips_ref]) + default_gw_network_node = {} + for instance_id in instance_set: + vifs = db.virtual_interface_get_by_instance(context, instance_id) + if vifs: + #offer a default gateway to the first virtual interface + default_gw_network_node[instance_id] = vifs[0]['network_id'] + + for fixed_ip_ref in ips_ref: + instance_id = fixed_ip_ref['instance_id'] + if instance_id in default_gw_network_node: + target_network_id = default_gw_network_node[instance_id] + # we don't want default gateway for this fixed ip + if target_network_id != fixed_ip_ref['network_id']: + hosts.append(_host_dhcp_opts(fixed_ip_ref)) return '\n'.join(hosts) @@ -560,13 +555,14 @@ def update_dhcp(context, dev, network_ref): with open(conffile, 'w') as f: f.write(get_dhcp_hosts(context, network_ref)) - optsfile = _dhcp_file(dev, 'opts') - with open(optsfile, 'w') as f: - f.write(get_dhcp_opts(context, network_ref)) + if FLAGS.use_single_default_gateway: + optsfile = _dhcp_file(dev, 'opts') + with open(optsfile, 'w') as f: + f.write(get_dhcp_opts(context, network_ref)) + os.chmod(optsfile, 0644) # Make sure dnsmasq can actually read it (it setuid()s to "nobody") os.chmod(conffile, 0644) - os.chmod(optsfile, 0644) pid = _dnsmasq_pid_for(dev) @@ -598,11 +594,13 @@ def update_dhcp(context, dev, network_ref): '--dhcp-lease-max=%s' % len(netaddr.IPNetwork(network_ref['cidr'])), '--dhcp-hostsfile=%s' % _dhcp_file(dev, 'conf'), '--dhcp-script=%s' % FLAGS.dhcpbridge, - '--dhcp-optsfile=%s' % _dhcp_file(dev, 'opts'), '--leasefile-ro'] if FLAGS.dns_server: cmd += ['-h', '-R', '--server=%s' % FLAGS.dns_server] + if FLAGS.use_single_default_gateway: + cmd += ['--dhcp-optsfile=%s' % _dhcp_file(dev, 'opts')] + _execute(*cmd, run_as_root=True) @@ -681,13 +679,9 @@ def _host_dhcp(fixed_ip_ref): "net:" + _host_dhcp_network(fixed_ip_ref)) -def _host_dhcp_opts(fixed_ip_ref, gw): +def _host_dhcp_opts(fixed_ip_ref): """Return a host string for an address in dhcp-host format.""" - if not gw: - return '%s,%s' % (_host_dhcp_network(fixed_ip_ref), - 3) - else: - return '' + return '%s,%s' % (_host_dhcp_network(fixed_ip_ref), 3) def _execute(*cmd, **kwargs): diff --git a/nova/tests/test_linux_net.py b/nova/tests/test_linux_net.py index be6faa07b..4c72f1e0f 100755 --- a/nova/tests/test_linux_net.py +++ b/nova/tests/test_linux_net.py @@ -23,6 +23,7 @@ from nova import log as logging from nova import test from nova import utils from nova.network import manager as network_manager +from nova.network import linux_net import mox @@ -194,6 +195,7 @@ class LinuxNetworkTestCase(test.TestCase): def setUp(self): super(LinuxNetworkTestCase, self).setUp() network_driver = FLAGS.network_driver + self.flags(use_single_default_gateway=True) self.driver = utils.import_object(network_driver) self.driver.db = db @@ -300,9 +302,7 @@ class LinuxNetworkTestCase(test.TestCase): vifs[5]]) self.mox.ReplayAll() - expected_opts = '\n'\ - 'NW-i00000001-0,3\n'\ - '' + expected_opts = 'NW-i00000001-0,3' actual_opts = self.driver.get_dhcp_opts(None, networks[0]) self.assertEquals(actual_opts, expected_opts) @@ -328,19 +328,12 @@ class LinuxNetworkTestCase(test.TestCase): vifs[5]]) self.mox.ReplayAll() - expected_opts = 'NW-i00000000-1,3\n'\ - '\n'\ - '' + expected_opts = "NW-i00000000-1,3" actual_opts = self.driver.get_dhcp_opts(None, networks[1]) self.assertEquals(actual_opts, expected_opts) - def test_dhcp_opts_default_gateway_network(self): - expected = "" - actual = self.driver._host_dhcp_opts(fixed_ips[0], True) - self.assertEquals(actual, expected) - def test_dhcp_opts_not_default_gateway_network(self): expected = "NW-i00000000-0,3" - actual = self.driver._host_dhcp_opts(fixed_ips[0], False) + actual = self.driver._host_dhcp_opts(fixed_ips[0]) self.assertEquals(actual, expected) -- cgit From c1763deb23dc6dcf7ca4f32aafde47501a87083f Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Wed, 7 Sep 2011 11:11:19 -0500 Subject: updated floating_ip generation --- nova/tests/fake_network.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/nova/tests/fake_network.py b/nova/tests/fake_network.py index 99b027cf3..19be83bc9 100644 --- a/nova/tests/fake_network.py +++ b/nova/tests/fake_network.py @@ -14,6 +14,7 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. +from itertools import islice from nova import db from nova import flags @@ -68,8 +69,8 @@ def fixed_ips(num_networks, num_ips, num_floating_ips=0): for network_index in xrange(num_networks): for ip_index in xrange(num_ips): fixed_ip_id = network_index * num_ips + ip_index - f_ips = [FakeModel(**floating_ips(fixed_ip_id).next()) - for i in xrange(num_floating_ips)] + f_ips = [FakeModel(**floating_ip_dict) for floating_ip_dict + in islice(floating_ips(fixed_ip_id), num_floating_ips)] yield {'id': fixed_ip_id, 'network_id': network_index, 'address': '192.168.%d.1%02d' % (network_index, ip_index), @@ -94,7 +95,7 @@ flavor = {'id': 0, def floating_ips(fixed_ip_id): for i in xrange(154): yield {'id': i, - 'address': '10.10.10.%d' % (i + 100), + 'address': '10.10.%d.%d' % (fixed_ip_id, i + 100), 'fixed_ip_id': fixed_ip_id, 'project_id': None, 'auto_assigned': False} -- cgit From e3cb2c82224fad59c16010c0842ebcfa1ac0dc95 Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Wed, 7 Sep 2011 12:41:16 -0500 Subject: changed the fixed_ip_generator --- nova/tests/fake_network.py | 110 +++++++++++++++++++++++++++++---------------- 1 file changed, 71 insertions(+), 39 deletions(-) diff --git a/nova/tests/fake_network.py b/nova/tests/fake_network.py index 19be83bc9..ee1a4a7c7 100644 --- a/nova/tests/fake_network.py +++ b/nova/tests/fake_network.py @@ -14,7 +14,6 @@ # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the # License for the specific language governing permissions and limitations # under the License. -from itertools import islice from nova import db from nova import flags @@ -35,6 +34,17 @@ class FakeModel(dict): return self[name] +flavor = {'id': 0, + 'name': 'fake_flavor', + 'memory_mb': 2048, + 'vcpus': 2, + 'local_gb': 10, + 'flavor_id': 0, + 'swap': 0, + 'rxtx_quota': 0, + 'rxtx_cap': 3} + + def fake_network(network_id, ipv6=None): if ipv6 is None: ipv6 = FLAGS.use_ipv6 @@ -65,42 +75,6 @@ def fake_network(network_id, ipv6=None): return fake_network -def fixed_ips(num_networks, num_ips, num_floating_ips=0): - for network_index in xrange(num_networks): - for ip_index in xrange(num_ips): - fixed_ip_id = network_index * num_ips + ip_index - f_ips = [FakeModel(**floating_ip_dict) for floating_ip_dict - in islice(floating_ips(fixed_ip_id), num_floating_ips)] - yield {'id': fixed_ip_id, - 'network_id': network_index, - 'address': '192.168.%d.1%02d' % (network_index, ip_index), - 'instance_id': 0, - 'allocated': False, - # and since network_id and vif_id happen to be equivalent - 'virtual_interface_id': network_index, - 'floating_ips': f_ips} - - -flavor = {'id': 0, - 'name': 'fake_flavor', - 'memory_mb': 2048, - 'vcpus': 2, - 'local_gb': 10, - 'flavor_id': 0, - 'swap': 0, - 'rxtx_quota': 0, - 'rxtx_cap': 3} - - -def floating_ips(fixed_ip_id): - for i in xrange(154): - yield {'id': i, - 'address': '10.10.%d.%d' % (fixed_ip_id, i + 100), - 'fixed_ip_id': fixed_ip_id, - 'project_id': None, - 'auto_assigned': False} - - def vifs(n): for x in xrange(n): yield {'id': x, @@ -111,6 +85,58 @@ def vifs(n): 'instance_id': 0} +#def fixed_ips(num_networks, num_ips, num_floating_ips=0): +# for network_index in xrange(num_networks): +# for ip_index in xrange(num_ips): +# fixed_ip_id = network_index * num_ips + ip_index +# islice = itertools.islice +# yield {'id': fixed_ip_id, +# 'network_id': network_index, +# 'address': '192.168.%d.1%02d' % (network_index, ip_index), +# 'instance_id': 0, +# 'allocated': False, +# # and since network_id and vif_id happen to be equivalent +# 'virtual_interface_id': network_index, +# 'floating_ips': f_ips} + + +def floating_ip_ids(): + for i in xrange(99): + yield i + + +def fixed_ip_ids(): + for i in xrange(99): + yield i + + +floating_ip_id = floating_ip_ids() +fixed_ip_id = fixed_ip_ids() + + +def next_fixed_ip(network_id, num_floating_ips=0): + next_id = fixed_ip_id.next() + f_ips = [FakeModel(**next_floating_ip(fixed_ip_id)) + for i in xrange(num_floating_ips)] + return {'id': next, + 'network_id': network_id, + 'address': '192.168.%d.1%02d' % (network_id, next_id), + 'instance_id': 0, + 'allocated': False, + # and since network_id and vif_id happen to be equivalent + 'virtual_interface_id': network_id, + 'floating_ips': f_ips} + + +def next_floating_ip(fixed_ip_id): + next_id = floating_ip_id.next() + return {'id': next_id, + 'address': '10.10.10.1%02d' % next_id, + 'fixed_ip_id': fixed_ip_id, + 'project_id': None, + 'auto_assigned': False} + + def ipv4_like(ip, match_string): ip = ip.split('.') match_octets = match_string.split('.') @@ -123,15 +149,21 @@ 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(stubs, num_networks=1, ips_per_vif=2, + floating_ips_per_fixed_ip=0): # stubs is the self.stubs from the test # 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) network.db = db + # reset the fixed and floating ip generators + floating_ip_id = floating_ip_ids() + fixed_ip_id = fixed_ip_ids() + def fixed_ips_fake(*args, **kwargs): - return list(fixed_ips(num_networks, ips_per_vif)) + return [next_fixed_ip(i, floating_ips_per_fixed_ip) + for i in xrange(num_networks) for j in xrange(ips_per_vif)] def virtual_interfaces_fake(*args, **kwargs): return [vif for vif in vifs(num_networks)] -- cgit From 262b5cf6e8bd577d2b08fb92e6da56f8bcdecd57 Mon Sep 17 00:00:00 2001 From: "Kevin L. Mitchell" Date: Wed, 7 Sep 2011 13:37:29 -0500 Subject: weigh_hosts() needs to return a list of hosts for the instances, not just a list of hosts --- nova/scheduler/base_scheduler.py | 16 +++++++++++-- nova/tests/scheduler/test_abstract_scheduler.py | 32 +++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/nova/scheduler/base_scheduler.py b/nova/scheduler/base_scheduler.py index 35e5af035..e9c078b81 100644 --- a/nova/scheduler/base_scheduler.py +++ b/nova/scheduler/base_scheduler.py @@ -55,5 +55,17 @@ class BaseScheduler(abstract_scheduler.AbstractScheduler): scheduling objectives """ # NOTE(sirp): The default logic is the same as the NoopCostFunction - return [dict(weight=1, hostname=hostname, capabilities=capabilities) - for hostname, capabilities in hosts] + hosts = [dict(weight=1, hostname=hostname, capabilities=capabilities) + for hostname, capabilities in hosts] + + # NOTE(Vek): What we actually need to return is enough hosts + # for all the instances! + num_instances = request_spec.get('num_instances', 1) + instances = [] + while num_instances > len(hosts): + instances.extend(hosts) + num_instances -= len(hosts) + if num_instances > 0: + instances.extend(hosts[:num_instances]) + + return instances diff --git a/nova/tests/scheduler/test_abstract_scheduler.py b/nova/tests/scheduler/test_abstract_scheduler.py index aa97e2344..f47699048 100644 --- a/nova/tests/scheduler/test_abstract_scheduler.py +++ b/nova/tests/scheduler/test_abstract_scheduler.py @@ -65,6 +65,11 @@ class FakeAbstractScheduler(abstract_scheduler.AbstractScheduler): pass +class FakeBaseScheduler(base_scheduler.BaseScheduler): + # No need to stub anything at the moment + pass + + class FakeZoneManager(zone_manager.ZoneManager): def __init__(self): self.service_states = { @@ -365,3 +370,30 @@ class AbstractSchedulerTestCase(test.TestCase): self.assertEqual(fixture._decrypt_blob(test_data), json.dumps(test_data)) + + +class BaseSchedulerTestCase(test.TestCase): + """Test case for Base Scheduler.""" + + def test_weigh_hosts(self): + """ + Try to weigh a short list of hosts and make sure enough + entries for a larger number instances are returned. + """ + + sched = FakeBaseScheduler() + + # Fake out a list of hosts + zm = FakeZoneManager() + hostlist = [(host, services['compute']) + for host, services in zm.service_states + if 'compute' in services] + + # Call weigh_hosts() + num_instances = len(hostlist) * 2 + len(hostlist) / 2 + instlist = sched.weigh_hosts('compute', + dict(num_instances=num_instances), + hostlist) + + # Should be enough entries to cover all instances + self.assertEqual(len(instlist), num_instances) -- cgit From 34baac0f11ff2084caa46a533aad411988e1541e Mon Sep 17 00:00:00 2001 From: Tushar Patil Date: Wed, 7 Sep 2011 11:41:33 -0700 Subject: Fix for LP Bug #837867 --- nova/network/manager.py | 6 ++--- nova/tests/test_network.py | 58 ++++++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 59 insertions(+), 5 deletions(-) diff --git a/nova/network/manager.py b/nova/network/manager.py index 050cec250..d1791f777 100644 --- a/nova/network/manager.py +++ b/nova/network/manager.py @@ -128,8 +128,8 @@ class RPCAllocateFixedIP(object): """Calls allocate_fixed_ip once for each network.""" green_pool = greenpool.GreenPool() - vpn = kwargs.pop('vpn') - requested_networks = kwargs.pop('requested_networks') + vpn = kwargs.get('vpn') + requested_networks = kwargs.get('requested_networks') for network in networks: address = None @@ -890,7 +890,7 @@ class FlatManager(NetworkManager): def _allocate_fixed_ips(self, context, instance_id, host, networks, **kwargs): """Calls allocate_fixed_ip once for each network.""" - requested_networks = kwargs.pop('requested_networks') + requested_networks = kwargs.get('requested_networks') for network in networks: address = None if requested_networks is not None: diff --git a/nova/tests/test_network.py b/nova/tests/test_network.py index 25ff940f0..05fca7bc5 100644 --- a/nova/tests/test_network.py +++ b/nova/tests/test_network.py @@ -58,7 +58,7 @@ networks = [{'id': 0, 'dns1': '192.168.0.1', 'dns2': '192.168.0.2', 'vlan': None, - 'host': None, + 'host': HOST, 'project_id': 'fake_project', 'vpn_public_address': '192.168.0.2'}, {'id': 1, @@ -78,7 +78,7 @@ networks = [{'id': 0, 'dns1': '192.168.0.1', 'dns2': '192.168.0.2', 'vlan': None, - 'host': None, + 'host': HOST, 'project_id': 'fake_project', 'vpn_public_address': '192.168.1.2'}] @@ -247,6 +247,34 @@ class FlatNetworkTestCase(test.TestCase): self.network.validate_networks(None, requested_networks) + def test_add_fixed_ip_instance_without_vpn_requested_networks(self): + self.mox.StubOutWithMock(db, 'network_get') + self.mox.StubOutWithMock(db, 'network_update') + self.mox.StubOutWithMock(db, 'fixed_ip_associate_pool') + self.mox.StubOutWithMock(db, 'instance_get') + self.mox.StubOutWithMock(db, + 'virtual_interface_get_by_instance_and_network') + self.mox.StubOutWithMock(db, 'fixed_ip_update') + + db.fixed_ip_update(mox.IgnoreArg(), + mox.IgnoreArg(), + mox.IgnoreArg()) + db.virtual_interface_get_by_instance_and_network(mox.IgnoreArg(), + mox.IgnoreArg(), mox.IgnoreArg()).AndReturn({'id': 0}) + + db.instance_get(mox.IgnoreArg(), + mox.IgnoreArg()).AndReturn({'security_groups': + [{'id': 0}]}) + db.fixed_ip_associate_pool(mox.IgnoreArg(), + mox.IgnoreArg(), + mox.IgnoreArg()).AndReturn('192.168.0.101') + db.network_get(mox.IgnoreArg(), + mox.IgnoreArg()).AndReturn(networks[0]) + db.network_update(mox.IgnoreArg(), mox.IgnoreArg(), mox.IgnoreArg()) + self.mox.ReplayAll() + self.network.add_fixed_ip_to_instance(self.context, 1, HOST, + networks[0]['id']) + class VlanNetworkTestCase(test.TestCase): def setUp(self): @@ -387,6 +415,32 @@ class VlanNetworkTestCase(test.TestCase): mox.IgnoreArg(), mox.IgnoreArg()) + def test_add_fixed_ip_instance_without_vpn_requested_networks(self): + self.mox.StubOutWithMock(db, 'network_get') + self.mox.StubOutWithMock(db, 'fixed_ip_associate_pool') + self.mox.StubOutWithMock(db, 'instance_get') + self.mox.StubOutWithMock(db, + 'virtual_interface_get_by_instance_and_network') + self.mox.StubOutWithMock(db, 'fixed_ip_update') + + db.fixed_ip_update(mox.IgnoreArg(), + mox.IgnoreArg(), + mox.IgnoreArg()) + db.virtual_interface_get_by_instance_and_network(mox.IgnoreArg(), + mox.IgnoreArg(), mox.IgnoreArg()).AndReturn({'id': 0}) + + db.instance_get(mox.IgnoreArg(), + mox.IgnoreArg()).AndReturn({'security_groups': + [{'id': 0}]}) + db.fixed_ip_associate_pool(mox.IgnoreArg(), + mox.IgnoreArg(), + mox.IgnoreArg()).AndReturn('192.168.0.101') + db.network_get(mox.IgnoreArg(), + mox.IgnoreArg()).AndReturn(networks[0]) + self.mox.ReplayAll() + self.network.add_fixed_ip_to_instance(self.context, 1, HOST, + networks[0]['id']) + class CommonNetworkTestCase(test.TestCase): -- cgit From 3e61268a350ba0ec43d28dfbac6e82503a174dba Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Wed, 7 Sep 2011 14:33:43 -0500 Subject: had used wrong variable --- nova/tests/fake_network.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/tests/fake_network.py b/nova/tests/fake_network.py index ee1a4a7c7..76e1b991d 100644 --- a/nova/tests/fake_network.py +++ b/nova/tests/fake_network.py @@ -116,7 +116,7 @@ fixed_ip_id = fixed_ip_ids() def next_fixed_ip(network_id, num_floating_ips=0): next_id = fixed_ip_id.next() - f_ips = [FakeModel(**next_floating_ip(fixed_ip_id)) + f_ips = [FakeModel(**next_floating_ip(next_id)) for i in xrange(num_floating_ips)] return {'id': next, 'network_id': network_id, -- cgit From 31ae07f06c71968deb67c5aa1c111fe9e14fb5d8 Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Wed, 7 Sep 2011 14:36:22 -0500 Subject: forgot _id --- nova/tests/fake_network.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/tests/fake_network.py b/nova/tests/fake_network.py index 76e1b991d..97231bfa1 100644 --- a/nova/tests/fake_network.py +++ b/nova/tests/fake_network.py @@ -118,7 +118,7 @@ def next_fixed_ip(network_id, num_floating_ips=0): next_id = fixed_ip_id.next() f_ips = [FakeModel(**next_floating_ip(next_id)) for i in xrange(num_floating_ips)] - return {'id': next, + return {'id': next_id, 'network_id': network_id, 'address': '192.168.%d.1%02d' % (network_id, next_id), 'instance_id': 0, -- cgit From a158d5721c18902b290a42bb3874b34e54dbcd7b Mon Sep 17 00:00:00 2001 From: Tushar Patil Date: Wed, 7 Sep 2011 13:10:05 -0700 Subject: exclude net tag from host_dhcp if use_single_default_gateway flag is set to false --- nova/network/linux_net.py | 17 ++++++++++++----- nova/tests/test_linux_net.py | 6 ++++++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/nova/network/linux_net.py b/nova/network/linux_net.py index affdde701..7d89b2bcc 100755 --- a/nova/network/linux_net.py +++ b/nova/network/linux_net.py @@ -672,11 +672,18 @@ def _host_dhcp_network(fixed_ip_ref): def _host_dhcp(fixed_ip_ref): """Return a host string for an address in dhcp-host format.""" instance_ref = fixed_ip_ref['instance'] - return '%s,%s.%s,%s,%s' % (fixed_ip_ref['virtual_interface']['address'], - instance_ref['hostname'], - FLAGS.dhcp_domain, - fixed_ip_ref['address'], - "net:" + _host_dhcp_network(fixed_ip_ref)) + vif = fixed_ip_ref['virtual_interface'] + if FLAGS.use_single_default_gateway: + return '%s,%s.%s,%s,%s' % (vif['address'], + instance_ref['hostname'], + FLAGS.dhcp_domain, + fixed_ip_ref['address'], + "net:" + _host_dhcp_network(fixed_ip_ref)) + else: + return '%s,%s.%s,%s' % (vif['address'], + instance_ref['hostname'], + FLAGS.dhcp_domain, + fixed_ip_ref['address']) def _host_dhcp_opts(fixed_ip_ref): diff --git a/nova/tests/test_linux_net.py b/nova/tests/test_linux_net.py index 4c72f1e0f..6d0a2b6bd 100755 --- a/nova/tests/test_linux_net.py +++ b/nova/tests/test_linux_net.py @@ -337,3 +337,9 @@ class LinuxNetworkTestCase(test.TestCase): expected = "NW-i00000000-0,3" actual = self.driver._host_dhcp_opts(fixed_ips[0]) self.assertEquals(actual, expected) + + def test_host_dhcp_without_default_gateway_network(self): + self.flags(use_single_default_gateway=False) + expected = ("10.0.0.1,fake_instance00.novalocal,192.168.0.100") + actual = self.driver._host_dhcp(fixed_ips[0]) + self.assertEquals(actual, expected) -- cgit From 4d98408d4ec605ad9a591d5166f2b8ea6e723ecb Mon Sep 17 00:00:00 2001 From: Tushar Patil Date: Wed, 7 Sep 2011 13:37:58 -0700 Subject: modified unit tests, set use_single_default_gateway flag to True whereever needed instead of setting it in the init method --- nova/tests/test_linux_net.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/nova/tests/test_linux_net.py b/nova/tests/test_linux_net.py index 6d0a2b6bd..99577b88e 100755 --- a/nova/tests/test_linux_net.py +++ b/nova/tests/test_linux_net.py @@ -195,11 +195,11 @@ class LinuxNetworkTestCase(test.TestCase): def setUp(self): super(LinuxNetworkTestCase, self).setUp() network_driver = FLAGS.network_driver - self.flags(use_single_default_gateway=True) self.driver = utils.import_object(network_driver) self.driver.db = db def test_update_dhcp_for_nw00(self): + self.flags(use_single_default_gateway=True) self.mox.StubOutWithMock(db, 'network_get_associated_fixed_ips') self.mox.StubOutWithMock(db, 'virtual_interface_get_by_instance') @@ -223,6 +223,7 @@ class LinuxNetworkTestCase(test.TestCase): self.driver.update_dhcp(None, "eth0", networks[0]) def test_update_dhcp_for_nw01(self): + self.flags(use_single_default_gateway=True) self.mox.StubOutWithMock(db, 'network_get_associated_fixed_ips') self.mox.StubOutWithMock(db, 'virtual_interface_get_by_instance') @@ -246,6 +247,7 @@ class LinuxNetworkTestCase(test.TestCase): self.driver.update_dhcp(None, "eth0", networks[0]) def test_get_dhcp_hosts_for_nw00(self): + self.flags(use_single_default_gateway=True) self.mox.StubOutWithMock(db, 'network_get_associated_fixed_ips') db.network_get_associated_fixed_ips(mox.IgnoreArg(), @@ -264,6 +266,7 @@ class LinuxNetworkTestCase(test.TestCase): self.assertEquals(actual_hosts, expected) def test_get_dhcp_hosts_for_nw01(self): + self.flags(use_single_default_gateway=True) self.mox.StubOutWithMock(db, 'network_get_associated_fixed_ips') db.network_get_associated_fixed_ips(mox.IgnoreArg(), @@ -339,7 +342,6 @@ class LinuxNetworkTestCase(test.TestCase): self.assertEquals(actual, expected) def test_host_dhcp_without_default_gateway_network(self): - self.flags(use_single_default_gateway=False) expected = ("10.0.0.1,fake_instance00.novalocal,192.168.0.100") actual = self.driver._host_dhcp(fixed_ips[0]) self.assertEquals(actual, expected) -- cgit From 591997a76a8395a72c7316207983e1225c9c4a62 Mon Sep 17 00:00:00 2001 From: "Kevin L. Mitchell" Date: Wed, 7 Sep 2011 20:40:48 +0000 Subject: fix a couple of typos in the added unit test --- nova/tests/scheduler/test_abstract_scheduler.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nova/tests/scheduler/test_abstract_scheduler.py b/nova/tests/scheduler/test_abstract_scheduler.py index f47699048..9bf128b13 100644 --- a/nova/tests/scheduler/test_abstract_scheduler.py +++ b/nova/tests/scheduler/test_abstract_scheduler.py @@ -26,6 +26,7 @@ from nova import test from nova.compute import api as compute_api from nova.scheduler import driver from nova.scheduler import abstract_scheduler +from nova.scheduler import base_scheduler from nova.scheduler import zone_manager @@ -386,7 +387,7 @@ class BaseSchedulerTestCase(test.TestCase): # Fake out a list of hosts zm = FakeZoneManager() hostlist = [(host, services['compute']) - for host, services in zm.service_states + for host, services in zm.service_states.items() if 'compute' in services] # Call weigh_hosts() -- cgit From 3334fabe55c862531e3ced21b211710857c1e087 Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Wed, 7 Sep 2011 15:48:31 -0500 Subject: removed vestige --- nova/tests/fake_network.py | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/nova/tests/fake_network.py b/nova/tests/fake_network.py index 97231bfa1..5e536a6ee 100644 --- a/nova/tests/fake_network.py +++ b/nova/tests/fake_network.py @@ -85,21 +85,6 @@ def vifs(n): 'instance_id': 0} -#def fixed_ips(num_networks, num_ips, num_floating_ips=0): -# for network_index in xrange(num_networks): -# for ip_index in xrange(num_ips): -# fixed_ip_id = network_index * num_ips + ip_index -# islice = itertools.islice -# yield {'id': fixed_ip_id, -# 'network_id': network_index, -# 'address': '192.168.%d.1%02d' % (network_index, ip_index), -# 'instance_id': 0, -# 'allocated': False, -# # and since network_id and vif_id happen to be equivalent -# 'virtual_interface_id': network_index, -# 'floating_ips': f_ips} - - def floating_ip_ids(): for i in xrange(99): yield i -- cgit From 2bed69e61aefdc8e2aa7eeb31fe9f338e912a01d Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Wed, 7 Sep 2011 16:06:35 -0500 Subject: properly handle the id resetters --- nova/tests/fake_network.py | 1 + 1 file changed, 1 insertion(+) diff --git a/nova/tests/fake_network.py b/nova/tests/fake_network.py index 5e536a6ee..1ecb99b31 100644 --- a/nova/tests/fake_network.py +++ b/nova/tests/fake_network.py @@ -143,6 +143,7 @@ def fake_get_instance_nw_info(stubs, num_networks=1, ips_per_vif=2, network.db = db # reset the fixed and floating ip generators + global floating_ip_id, fixed_ip_id floating_ip_id = floating_ip_ids() fixed_ip_id = fixed_ip_ids() -- cgit From d2b9299408f07f995fffc8b8559f52ee6adeeaad Mon Sep 17 00:00:00 2001 From: "Kevin L. Mitchell" Date: Wed, 7 Sep 2011 18:01:52 -0500 Subject: spread-first strategy --- nova/scheduler/abstract_scheduler.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nova/scheduler/abstract_scheduler.py b/nova/scheduler/abstract_scheduler.py index 7f17b642f..a81fa53cd 100644 --- a/nova/scheduler/abstract_scheduler.py +++ b/nova/scheduler/abstract_scheduler.py @@ -20,8 +20,9 @@ customize the behavior: filter_hosts() and weigh_hosts(). The default behavior is to simply select all hosts and weight them the same. """ -import operator import json +import operator +import random import M2Crypto @@ -40,6 +41,8 @@ from nova.scheduler import api from nova.scheduler import driver FLAGS = flags.FLAGS +flags.DEFINE_boolean('spread_first', False, + 'Use a spread-first zone scheduler strategy') LOG = logging.getLogger('nova.scheduler.abstract_scheduler') -- cgit From ad25b7aa2ad744607b20432d635f70cc645cc6f6 Mon Sep 17 00:00:00 2001 From: "Kevin L. Mitchell" Date: Wed, 7 Sep 2011 18:08:39 -0500 Subject: actually shuffle the weighted_hosts list... --- nova/scheduler/abstract_scheduler.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nova/scheduler/abstract_scheduler.py b/nova/scheduler/abstract_scheduler.py index a81fa53cd..b4c2bf4f1 100644 --- a/nova/scheduler/abstract_scheduler.py +++ b/nova/scheduler/abstract_scheduler.py @@ -295,6 +295,8 @@ class AbstractScheduler(driver.Scheduler): "child_zone": child_zone, "child_blob": weighting["blob"]} weighted_hosts.append(host_dict) + if FLAGS.spread_first: + random.shuffle(weighted_hosts) weighted_hosts.sort(key=operator.itemgetter('weight')) return weighted_hosts -- cgit From b6d454762d7fdf9b202d8a580dd9bfdf069a5e80 Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Wed, 7 Sep 2011 16:38:41 -0700 Subject: fix for lp844364: improve check for fixed_ip association --- nova/api/openstack/contrib/floating_ips.py | 4 +- .../api/openstack/contrib/test_floating_ips.py | 78 +++++++++++++++++++++- 2 files changed, 77 insertions(+), 5 deletions(-) diff --git a/nova/api/openstack/contrib/floating_ips.py b/nova/api/openstack/contrib/floating_ips.py index d1add8f83..9ceb5858f 100644 --- a/nova/api/openstack/contrib/floating_ips.py +++ b/nova/api/openstack/contrib/floating_ips.py @@ -107,7 +107,7 @@ class FloatingIPController(object): context = req.environ['nova.context'] floating_ip = self.network_api.get_floating_ip(context, id) - if 'fixed_ip' in floating_ip: + if floating_ip['fixed_ip']: self.network_api.disassociate_floating_ip(context, floating_ip['address']) @@ -161,7 +161,7 @@ class Floating_ips(extensions.ExtensionDescriptor): raise webob.exc.HTTPBadRequest(explanation=msg) floating_ip = self.network_api.get_floating_ip_by_ip(context, address) - if 'fixed_ip' in floating_ip: + if floating_ip['fixed_ip']: self.network_api.disassociate_floating_ip(context, address) return webob.Response(status_int=202) diff --git a/nova/tests/api/openstack/contrib/test_floating_ips.py b/nova/tests/api/openstack/contrib/test_floating_ips.py index 642f2b841..0744f0a11 100644 --- a/nova/tests/api/openstack/contrib/test_floating_ips.py +++ b/nova/tests/api/openstack/contrib/test_floating_ips.py @@ -212,11 +212,45 @@ class FloatingIpTest(test.TestCase): "fixed_ip": None} self.assertEqual(ip, expected) - def test_floating_ip_release(self): + def test_floating_ip_release_associated(self): + self.disassociated = False + + def get_floating_ip(ignore, context, id): + return {'id': 1, 'address': '10.10.10.10', + 'fixed_ip': {'id': 1}} + + def disassociate(ignore, context, floating_address): + self.disassociated = True + + self.stubs.Set(network.api.API, "get_floating_ip", + get_floating_ip) + self.stubs.Set(network.api.API, "disassociate_floating_ip", + disassociate) + req = webob.Request.blank('/v1.1/123/os-floating-ips/1') + req.method = 'DELETE' + res = req.get_response(fakes.wsgi_app()) + self.assertEqual(res.status_int, 202) + self.assertTrue(self.disassociated) + + def test_floating_ip_release_disassociated(self): + self.disassociated = False + + def fake_get_floating_ip(ignore, context, id): + return {'id': 1, 'address': '10.10.10.10', + 'fixed_ip': None} + + def fake_disassociate(ignore, context, floating_address): + self.disassociated = True + + self.stubs.Set(network.api.API, "get_floating_ip", + fake_get_floating_ip) + self.stubs.Set(network.api.API, "disassociate_floating_ip", + fake_disassociate) req = webob.Request.blank('/v1.1/123/os-floating-ips/1') req.method = 'DELETE' res = req.get_response(fakes.wsgi_app()) self.assertEqual(res.status_int, 202) + self.assertFalse(self.disassociated) def test_add_floating_ip_to_instance(self): self.stubs.Set(network.api.API, "associate_floating_ip", @@ -289,8 +323,45 @@ class FloatingIpTest(test.TestCase): self.assertEqual(resp.status_int, 202) self.assertTrue(self.disassociated) - def test_remove_floating_ip_from_instance(self): - body = dict(removeFloatingIp=dict(address='11.0.0.1')) + def test_remove_associated_floating_ip_from_instance(self): + self.disassociated = False + + def fake_get_floating_ip_by_ip(ignore, context, ip): + return {'id': 1, 'address': '10.10.10.10', + 'fixed_ip': {'id': 1}} + + def fake_disassociate(ignore, context, floating_address): + self.disassociated = True + + self.stubs.Set(network.api.API, "get_floating_ip_by_ip", + fake_get_floating_ip_by_ip) + self.stubs.Set(network.api.API, "disassociate_floating_ip", + fake_disassociate) + body = dict(removeFloatingIp=dict(address='10.10.10.10')) + req = webob.Request.blank('/v1.1/123/servers/test_inst/action') + req.method = "POST" + req.body = json.dumps(body) + req.headers["content-type"] = "application/json" + + resp = req.get_response(fakes.wsgi_app()) + self.assertEqual(resp.status_int, 202) + self.assertTrue(self.disassociated) + + def test_remove_disassociated_floating_ip_from_instance(self): + self.disassociated = False + + def fake_get_floating_ip_by_ip(ignore, context, ip): + return {'id': 1, 'address': '10.10.10.10', + 'fixed_ip': None} + + def fake_disassociate(ignore, context, floating_address): + self.disassociated = True + + self.stubs.Set(network.api.API, "get_floating_ip_by_ip", + fake_get_floating_ip_by_ip) + self.stubs.Set(network.api.API, "disassociate_floating_ip", + fake_disassociate) + body = dict(removeFloatingIp=dict(address='10.10.10.10')) req = webob.Request.blank('/v1.1/123/servers/test_inst/action') req.method = "POST" req.body = json.dumps(body) @@ -298,6 +369,7 @@ class FloatingIpTest(test.TestCase): resp = req.get_response(fakes.wsgi_app()) self.assertEqual(resp.status_int, 202) + self.assertFalse(self.disassociated) def test_bad_address_param_in_remove_floating_ip(self): body = dict(removeFloatingIp=dict(badparam='11.0.0.1')) -- cgit From b3bc07d4dcb43b6e070a136eb5532def6b623e6e Mon Sep 17 00:00:00 2001 From: Chris Behrens Date: Wed, 7 Sep 2011 20:40:47 -0700 Subject: remove the short circuit in abstract scheduler when no local hosts are available --- nova/scheduler/abstract_scheduler.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/nova/scheduler/abstract_scheduler.py b/nova/scheduler/abstract_scheduler.py index 7f17b642f..cb8db599f 100644 --- a/nova/scheduler/abstract_scheduler.py +++ b/nova/scheduler/abstract_scheduler.py @@ -269,9 +269,6 @@ class AbstractScheduler(driver.Scheduler): # Filter local hosts based on requirements ... filtered_hosts = self.filter_hosts(topic, request_spec, unfiltered_hosts) - if not filtered_hosts: - LOG.warn(_("No hosts available")) - return [] # weigh the selected hosts. # weighted_hosts = [{weight=weight, hostname=hostname, -- cgit From 5426687825cd64adf0524de2808eed1cca15f521 Mon Sep 17 00:00:00 2001 From: Chris Behrens Date: Wed, 7 Sep 2011 20:49:42 -0700 Subject: added test to cover case where no local hosts are available but child hosts are --- nova/tests/scheduler/test_abstract_scheduler.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/nova/tests/scheduler/test_abstract_scheduler.py b/nova/tests/scheduler/test_abstract_scheduler.py index aa97e2344..a65d15e43 100644 --- a/nova/tests/scheduler/test_abstract_scheduler.py +++ b/nova/tests/scheduler/test_abstract_scheduler.py @@ -365,3 +365,25 @@ class AbstractSchedulerTestCase(test.TestCase): self.assertEqual(fixture._decrypt_blob(test_data), json.dumps(test_data)) + + def test_empty_local_hosts(self): + """ + Create a nested set of FakeZones, try to build multiple instances + and ensure that a select call returns the appropriate build plan. + """ + sched = FakeAbstractScheduler() + self.stubs.Set(sched, '_call_zone_method', fake_call_zone_method) + self.stubs.Set(nova.db, 'zone_get_all', fake_zone_get_all) + + zm = FakeZoneManager() + # patch this to have no local hosts + zm.service_states = {} + sched.set_zone_manager(zm) + + fake_context = {} + build_plan = sched.select(fake_context, + {'instance_type': {'memory_mb': 512}, + 'num_instances': 4}) + + # 0 from local zones, 12 from remotes + self.assertEqual(12, len(build_plan)) -- cgit From b13ca667bdd3303bbfcd4e58cc6d773cea09661d Mon Sep 17 00:00:00 2001 From: Chris Behrens Date: Wed, 7 Sep 2011 21:48:11 -0700 Subject: catch exceptions from novaclient when talking to child zones. store them and re-raise if no other child zones return any results. If no exceptions are raised but no results are returned, raise a NotFound exception. --- nova/scheduler/api.py | 48 +++++++++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/nova/scheduler/api.py b/nova/scheduler/api.py index 55cea5f8f..a5124678d 100644 --- a/nova/scheduler/api.py +++ b/nova/scheduler/api.py @@ -103,22 +103,6 @@ def update_service_capabilities(context, service_name, host, capabilities): return rpc.fanout_cast(context, 'scheduler', kwargs) -def _wrap_method(function, self): - """Wrap method to supply self.""" - def _wrap(*args, **kwargs): - return function(self, *args, **kwargs) - return _wrap - - -def _process(func, zone): - """Worker stub for green thread pool. Give the worker - an authenticated nova client and zone info.""" - nova = novaclient.Client(zone.username, zone.password, None, - zone.api_url) - nova.authenticate() - return func(nova, zone) - - def call_zone_method(context, method_name, errors_to_ignore=None, novaclient_collection_name='zones', zones=None, *args, **kwargs): @@ -166,6 +150,28 @@ def child_zone_helper(zone_list, func): For example, if you are calling server.pause(), the list will be whatever the response from server.pause() is. One entry per child zone called.""" + + def _wrap_method(function, arg1): + """Wrap method to supply an argument.""" + def _wrap(*args, **kwargs): + return function(arg1, *args, **kwargs) + return _wrap + + def _process(func, zone): + """Worker stub for green thread pool. Give the worker + an authenticated nova client and zone info.""" + try: + nova = novaclient.Client(zone.username, zone.password, None, + zone.api_url) + nova.authenticate() + except novaclient_exceptions.BadRequest, e: + url = zone.api_url + LOG.warn(_("Failed request to zone; URL=%(url)s: %(e)s") + % locals()) + return e + else: + return func(nova, zone) + green_pool = greenpool.GreenPool() return [result for result in green_pool.imap( _wrap_method(_process, func), zone_list)] @@ -260,6 +266,8 @@ class reroute_compute(object): if not FLAGS.enable_zone_routing: raise exception.InstanceNotFound(instance_id=item_uuid) + self.item_uuid = item_uuid + zones = db.zone_get_all(context) if not zones: raise exception.InstanceNotFound(instance_id=item_uuid) @@ -342,9 +350,13 @@ class reroute_compute(object): dict {'server':{k:v}}. Others may return a list of them, like {'servers':[{k,v}]}""" reduced_response = [] + found_exception = None for zone_response in zone_responses: if not zone_response: continue + if isinstance(zone_response, BaseException): + found_exception = zone_response + continue server = zone_response.__dict__ @@ -355,7 +367,9 @@ class reroute_compute(object): reduced_response.append(dict(server=server)) if reduced_response: return reduced_response[0] # first for now. - return {} + elif found_exception: + raise found_exception + exception.InstanceNotFound(instance_id=self.item_uuid) def redirect_handler(f): -- cgit From bc84c1306e9334d4082cadee4dcb5cd14a905afe Mon Sep 17 00:00:00 2001 From: Chris Behrens Date: Wed, 7 Sep 2011 22:57:36 -0700 Subject: pep8 fix for tests/api/openstack/test_servers.py which is an issue in trunk --- nova/tests/api/openstack/test_servers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/tests/api/openstack/test_servers.py b/nova/tests/api/openstack/test_servers.py index 2ef687709..d063a60c2 100644 --- a/nova/tests/api/openstack/test_servers.py +++ b/nova/tests/api/openstack/test_servers.py @@ -3615,7 +3615,7 @@ class TestGetKernelRamdiskFromImage(test.TestCase): self.assertRaises(exception.NotFound, self._get_k_r, image_meta) def test_ami_no_ramdisk(self): - """If an ami is missing a ramdisk, return kernel ID and None for + """If an ami is missing a ramdisk, return kernel ID and None for ramdisk ID """ image_meta = {'id': 1, 'status': 'active', 'container_format': 'ami', -- cgit From be645283c85d69e2d3cf4f4eabdbb545aaf139bf Mon Sep 17 00:00:00 2001 From: Chris Behrens Date: Wed, 7 Sep 2011 23:24:07 -0700 Subject: create a new exception ZoneRequestError to use for returning errors when zone requests couldn't complete --- nova/exception.py | 7 +++++++ nova/scheduler/api.py | 5 ++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/nova/exception.py b/nova/exception.py index 95d8229b5..aa6609461 100644 --- a/nova/exception.py +++ b/nova/exception.py @@ -806,3 +806,10 @@ class CannotResizeToSmallerSize(NovaException): class ImageTooLarge(NovaException): message = _("Image is larger than instance type allows") + + +class ZoneRequestError(Error): + def __init__(self, message=None): + if message is None: + message = _("1 or more Zones could not complete the request") + super(ZoneRequestError, self).__init__(message=message) diff --git a/nova/scheduler/api.py b/nova/scheduler/api.py index a5124678d..05685fc15 100644 --- a/nova/scheduler/api.py +++ b/nova/scheduler/api.py @@ -168,7 +168,10 @@ def child_zone_helper(zone_list, func): url = zone.api_url LOG.warn(_("Failed request to zone; URL=%(url)s: %(e)s") % locals()) - return e + # This is being returned instead of raised, so that when results are + # processed in unmarshal_result() after the greenpool.imap completes, + # the exception can be raised there if no other zones had a response. + return exception.ZoneRequestError() else: return func(nova, zone) -- cgit From d1b1f301583fd67050c45f4c863733f251620a9c Mon Sep 17 00:00:00 2001 From: Chris Behrens Date: Wed, 7 Sep 2011 23:39:39 -0700 Subject: typo trying to raise InstanceNotFound when all zones returned nothing --- nova/scheduler/api.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/nova/scheduler/api.py b/nova/scheduler/api.py index 05685fc15..6081c3f02 100644 --- a/nova/scheduler/api.py +++ b/nova/scheduler/api.py @@ -168,9 +168,10 @@ def child_zone_helper(zone_list, func): url = zone.api_url LOG.warn(_("Failed request to zone; URL=%(url)s: %(e)s") % locals()) - # This is being returned instead of raised, so that when results are - # processed in unmarshal_result() after the greenpool.imap completes, - # the exception can be raised there if no other zones had a response. + # This is being returned instead of raised, so that when + # results are # processed in unmarshal_result() after the + # greenpool.imap completes, # the exception can be raised + # there if no other zones had a response. return exception.ZoneRequestError() else: return func(nova, zone) @@ -372,7 +373,7 @@ class reroute_compute(object): return reduced_response[0] # first for now. elif found_exception: raise found_exception - exception.InstanceNotFound(instance_id=self.item_uuid) + raise exception.InstanceNotFound(instance_id=self.item_uuid) def redirect_handler(f): -- cgit From be7a081976d37b84d93028673d08ab78bc9d8a73 Mon Sep 17 00:00:00 2001 From: Chris Behrens Date: Wed, 7 Sep 2011 23:45:11 -0700 Subject: comment fix --- nova/scheduler/api.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nova/scheduler/api.py b/nova/scheduler/api.py index 6081c3f02..719437b73 100644 --- a/nova/scheduler/api.py +++ b/nova/scheduler/api.py @@ -169,8 +169,8 @@ def child_zone_helper(zone_list, func): LOG.warn(_("Failed request to zone; URL=%(url)s: %(e)s") % locals()) # This is being returned instead of raised, so that when - # results are # processed in unmarshal_result() after the - # greenpool.imap completes, # the exception can be raised + # results are processed in unmarshal_result() after the + # greenpool.imap completes, the exception can be raised # there if no other zones had a response. return exception.ZoneRequestError() else: -- cgit From 973870c82445d4c1ebbd46f2ba7c3817ae5e7f87 Mon Sep 17 00:00:00 2001 From: Chris Behrens Date: Thu, 8 Sep 2011 01:09:22 -0700 Subject: added tests for failure cases talking with zones --- nova/tests/scheduler/test_scheduler.py | 102 +++++++++++++++++++++++++++++++-- 1 file changed, 97 insertions(+), 5 deletions(-) diff --git a/nova/tests/scheduler/test_scheduler.py b/nova/tests/scheduler/test_scheduler.py index a52dd041a..890348192 100644 --- a/nova/tests/scheduler/test_scheduler.py +++ b/nova/tests/scheduler/test_scheduler.py @@ -963,9 +963,14 @@ class FakeZone(object): self.password = password +ZONE_API_URL1 = "http://1.example.com" +ZONE_API_URL2 = "http://2.example.com" + + def zone_get_all(context): return [ - FakeZone(1, 'http://example.com', 'bob', 'xxx'), + FakeZone(1, ZONE_API_URL1, 'bob', 'xxx'), + FakeZone(2, ZONE_API_URL2, 'bob', 'xxx'), ] @@ -1065,7 +1070,9 @@ class ZoneRedirectTest(test.TestCase): def test_unmarshal_single_server(self): decorator = api.reroute_compute("foo") - self.assertEquals(decorator.unmarshall_result([]), {}) + decorator.item_uuid = 'fake_uuid' + self.assertRaises(exception.InstanceNotFound, + decorator.unmarshall_result, []) self.assertEquals(decorator.unmarshall_result( [FakeResource(dict(a=1, b=2)), ]), dict(server=dict(a=1, b=2))) @@ -1079,6 +1086,90 @@ class ZoneRedirectTest(test.TestCase): [FakeResource(dict(_a=1, manager=2)), ]), dict(server={})) + def test_one_zone_down_no_instances(self): + + def _fake_issue_novaclient_command(nova, zone, *args, **kwargs): + return None + + class FakeNovaClientWithFailure(object): + def __init__(self, username, password, method, api_url): + self.api_url = api_url + + def authenticate(self): + if self.api_url == ZONE_API_URL2: + raise novaclient_exceptions.BadRequest('foo') + + self.stubs.Set(api, '_issue_novaclient_command', + _fake_issue_novaclient_command) + self.stubs.Set(api.novaclient, 'Client', FakeNovaClientWithFailure) + + @api.reroute_compute("get") + def do_get(self, context, uuid): + pass + + self.assertRaises(exception.ZoneRequestError, + do_get, None, {}, FAKE_UUID) + + def test_one_zone_down_got_instance(self): + + def _fake_issue_novaclient_command(nova, zone, *args, **kwargs): + class FakeServer(object): + def __init__(self): + self.id = FAKE_UUID + self.test = '1234' + return FakeServer() + + class FakeNovaClientWithFailure(object): + def __init__(self, username, password, method, api_url): + self.api_url = api_url + + def authenticate(self): + if self.api_url == ZONE_API_URL2: + raise novaclient_exceptions.BadRequest('foo') + + self.stubs.Set(api, '_issue_novaclient_command', + _fake_issue_novaclient_command) + self.stubs.Set(api.novaclient, 'Client', FakeNovaClientWithFailure) + + @api.reroute_compute("get") + def do_get(self, context, uuid): + pass + + try: + do_get(None, {}, FAKE_UUID) + except api.RedirectResult, e: + results = e.results + self.assertIn('server', results) + self.assertEqual(results['server']['id'], FAKE_UUID) + self.assertEqual(results['server']['test'], '1234') + except Exception, e: + self.fail(_("RedirectResult should have been raised")) + else: + self.fail(_("RedirectResult should have been raised")) + + def test_zones_up_no_instances(self): + + def _fake_issue_novaclient_command(nova, zone, *args, **kwargs): + return None + + class FakeNovaClientNoFailure(object): + def __init__(self, username, password, method, api_url): + pass + + def authenticate(self): + return + + self.stubs.Set(api, '_issue_novaclient_command', + _fake_issue_novaclient_command) + self.stubs.Set(api.novaclient, 'Client', FakeNovaClientNoFailure) + + @api.reroute_compute("get") + def do_get(self, context, uuid): + pass + + self.assertRaises(exception.InstanceNotFound, + do_get, None, {}, FAKE_UUID) + class FakeServerCollection(object): def get(self, instance_id): @@ -1097,7 +1188,7 @@ class FakeEmptyServerCollection(object): class FakeNovaClient(object): - def __init__(self, collection): + def __init__(self, collection, *args, **kwargs): self.servers = collection @@ -1162,8 +1253,9 @@ class CallZoneMethodTest(test.TestCase): context = {} method = 'do_something' results = api.call_zone_method(context, method) - expected = [(1, 42)] - self.assertEqual(expected, results) + self.assertEqual(len(results), 2) + self.assertIn((1, 42), results) + self.assertIn((2, 42), results) def test_call_zone_method_not_present(self): context = {} -- cgit From 6cbbdb909443a33c2af8ddd73b861cd41201fa0b Mon Sep 17 00:00:00 2001 From: Brian Waldon Date: Thu, 8 Sep 2011 11:32:11 -0400 Subject: adding can_read_deleted back to db api --- nova/db/sqlalchemy/api.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index 523258841..1730b4ddb 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -1277,6 +1277,10 @@ def instance_get_all_by_filters(context, filters): changes_since = filters['changes-since'] query_prefix = query_prefix.\ filter(models.Instance.updated_at > changes_since) + else: + # filter out deleted instances if no changes-since filter provided + query_prefix = query_prefix.\ + filter_by(deleted=can_read_deleted(context)) if not context.is_admin: # If we're not admin context, add appropriate filter.. -- cgit From 763bf3f1282e3d9723a356d4014a9599601637eb Mon Sep 17 00:00:00 2001 From: Josh Kearney Date: Thu, 8 Sep 2011 11:43:43 -0500 Subject: Do not attempt to mount the swap VDI for file injection. --- nova/tests/api/openstack/test_servers.py | 2 +- nova/virt/xenapi/vmops.py | 13 ++++++++++--- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/nova/tests/api/openstack/test_servers.py b/nova/tests/api/openstack/test_servers.py index 2ef687709..d063a60c2 100644 --- a/nova/tests/api/openstack/test_servers.py +++ b/nova/tests/api/openstack/test_servers.py @@ -3615,7 +3615,7 @@ class TestGetKernelRamdiskFromImage(test.TestCase): self.assertRaises(exception.NotFound, self._get_k_r, image_meta) def test_ami_no_ramdisk(self): - """If an ami is missing a ramdisk, return kernel ID and None for + """If an ami is missing a ramdisk, return kernel ID and None for ramdisk ID """ image_meta = {'id': 1, 'status': 'active', 'container_format': 'ami', diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py index c5f105f40..bb53a52bc 100644 --- a/nova/virt/xenapi/vmops.py +++ b/nova/virt/xenapi/vmops.py @@ -188,9 +188,16 @@ class VMOps(object): ramdisk = VMHelper.fetch_image(context, self._session, instance, instance.ramdisk_id, instance.user_id, instance.project_id, ImageType.RAMDISK)[0] - # Create the VM ref and attach the first disk - first_vdi_ref = self._session.call_xenapi('VDI.get_by_uuid', - vdis[0]['vdi_uuid']) + + # NOTE(jk0): Since vdi_type may contain either 'os' or 'swap', we + # need to ensure that the 'swap' VDI is not chosen as the mount + # point for file injection. + first_vdi_ref = None + for vdi in vdis: + if vdi['vdi_type'] != 'swap': + # Create the VM ref and attach the first disk + first_vdi_ref = self._session.call_xenapi( + 'VDI.get_by_uuid', vdi['vdi_uuid']) vm_mode = instance.vm_mode and instance.vm_mode.lower() if vm_mode == 'pv': -- cgit From 3f6738b9f07640b0950793975cfc55e62aa3e1ad Mon Sep 17 00:00:00 2001 From: Josh Kearney Date: Thu, 8 Sep 2011 12:11:39 -0500 Subject: Use .get instead. --- nova/virt/xenapi/vmops.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py index bb53a52bc..9c138ee41 100644 --- a/nova/virt/xenapi/vmops.py +++ b/nova/virt/xenapi/vmops.py @@ -194,7 +194,7 @@ class VMOps(object): # point for file injection. first_vdi_ref = None for vdi in vdis: - if vdi['vdi_type'] != 'swap': + if vdi.get('vdi_type') != 'swap': # Create the VM ref and attach the first disk first_vdi_ref = self._session.call_xenapi( 'VDI.get_by_uuid', vdi['vdi_uuid']) -- cgit From c8a48eec1fb9f205af5cef2b882fc171bcca4d57 Mon Sep 17 00:00:00 2001 From: "Kevin L. Mitchell" Date: Thu, 8 Sep 2011 19:08:46 +0000 Subject: Add a NOTE() --- nova/scheduler/abstract_scheduler.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/nova/scheduler/abstract_scheduler.py b/nova/scheduler/abstract_scheduler.py index be6267d3a..1ba10c3a9 100644 --- a/nova/scheduler/abstract_scheduler.py +++ b/nova/scheduler/abstract_scheduler.py @@ -123,6 +123,14 @@ class AbstractScheduler(driver.Scheduler): except novaclient_exceptions.BadRequest, e: raise exception.NotAuthorized(_("Bad credentials attempting " "to talk to zone at %(url)s.") % locals()) + # NOTE(Vek): Novaclient has two different calling conventions + # for this call, depending on whether you're using + # 1.0 or 1.1 API: in 1.0, there's an ipgroups + # argument after flavor_id which isn't present in + # 1.1. To work around this, all the extra + # arguments are passed as keyword arguments + # (there's a reasonable default for ipgroups in the + # novaclient call). nova.servers.create(name, image_ref, flavor_id, meta=meta, files=files, zone_blob=child_blob, reservation_id=reservation_id) -- cgit From 4bf6508a026c62a7aa2423b1910c871ddc3f0916 Mon Sep 17 00:00:00 2001 From: Brian Waldon Date: Thu, 8 Sep 2011 15:26:44 -0400 Subject: converting fix to just address ec2; updating test --- nova/api/ec2/cloud.py | 4 +++- nova/db/sqlalchemy/api.py | 4 ---- nova/tests/test_cloud.py | 4 +--- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index 049ca6f93..4f7030a5a 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -1200,8 +1200,10 @@ class CloudController(object): instances.append(instance) else: try: + # always filter out deleted instances + search_opts['deleted'] = False instances = self.compute_api.get_all(context, - search_opts=search_opts) + search_opts=search_opts) except exception.NotFound: instances = [] for instance in instances: diff --git a/nova/db/sqlalchemy/api.py b/nova/db/sqlalchemy/api.py index 1730b4ddb..523258841 100644 --- a/nova/db/sqlalchemy/api.py +++ b/nova/db/sqlalchemy/api.py @@ -1277,10 +1277,6 @@ def instance_get_all_by_filters(context, filters): changes_since = filters['changes-since'] query_prefix = query_prefix.\ filter(models.Instance.updated_at > changes_since) - else: - # filter out deleted instances if no changes-since filter provided - query_prefix = query_prefix.\ - filter_by(deleted=can_read_deleted(context)) if not context.is_admin: # If we're not admin context, add appropriate filter.. diff --git a/nova/tests/test_cloud.py b/nova/tests/test_cloud.py index 3fe6a9b42..7fe353b3d 100644 --- a/nova/tests/test_cloud.py +++ b/nova/tests/test_cloud.py @@ -486,11 +486,9 @@ class CloudTestCase(test.TestCase): inst2 = db.instance_create(self.context, args2) db.instance_destroy(self.context, inst1.id) result = self.cloud.describe_instances(self.context) + self.assertEqual(len(result['reservationSet']), 1) result1 = result['reservationSet'][0]['instancesSet'] self.assertEqual(result1[0]['instanceId'], - ec2utils.id_to_ec2_id(inst1.id)) - result2 = result['reservationSet'][1]['instancesSet'] - self.assertEqual(result2[0]['instanceId'], ec2utils.id_to_ec2_id(inst2.id)) def _block_device_mapping_create(self, instance_id, mappings): -- cgit From fe355a10ad0a215eb5295e46e6c106221972e7ed Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Thu, 8 Sep 2011 13:18:08 -0700 Subject: make check for fixed_ip association more defensive --- nova/api/openstack/contrib/floating_ips.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nova/api/openstack/contrib/floating_ips.py b/nova/api/openstack/contrib/floating_ips.py index 9ceb5858f..d078b26c6 100644 --- a/nova/api/openstack/contrib/floating_ips.py +++ b/nova/api/openstack/contrib/floating_ips.py @@ -107,7 +107,7 @@ class FloatingIPController(object): context = req.environ['nova.context'] floating_ip = self.network_api.get_floating_ip(context, id) - if floating_ip['fixed_ip']: + if floating_ip.get('fixed_ip'): self.network_api.disassociate_floating_ip(context, floating_ip['address']) @@ -161,7 +161,7 @@ class Floating_ips(extensions.ExtensionDescriptor): raise webob.exc.HTTPBadRequest(explanation=msg) floating_ip = self.network_api.get_floating_ip_by_ip(context, address) - if floating_ip['fixed_ip']: + if floating_ip.get('fixed_ip'): self.network_api.disassociate_floating_ip(context, address) return webob.Response(status_int=202) -- cgit From aec647b3b42c4cd56a9509c2d1ac25ff12b0664e Mon Sep 17 00:00:00 2001 From: Josh Kearney Date: Thu, 8 Sep 2011 16:10:03 -0500 Subject: First pass at adding reboot_type to reboot codepath. --- nova/api/openstack/servers.py | 5 ++--- nova/compute/api.py | 5 +++-- nova/compute/manager.py | 4 ++-- nova/tests/api/openstack/test_servers.py | 2 +- nova/tests/test_compute.py | 15 ++++++++++++--- nova/tests/test_virt_drivers.py | 3 ++- nova/tests/test_vmwareapi.py | 3 ++- nova/virt/driver.py | 3 ++- nova/virt/fake.py | 2 +- nova/virt/hyperv.py | 2 +- nova/virt/vmwareapi_conn.py | 2 +- nova/virt/xenapi/vmops.py | 9 +++++++-- nova/virt/xenapi_conn.py | 4 ++-- 13 files changed, 38 insertions(+), 21 deletions(-) diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index d084ac360..f5447edc5 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -334,9 +334,8 @@ class Controller(object): LOG.exception(msg) raise exc.HTTPBadRequest(explanation=msg) try: - # TODO(gundlach): pass reboot_type, support soft reboot in - # virt driver - self.compute_api.reboot(req.environ['nova.context'], id) + self.compute_api.reboot(req.environ['nova.context'], id, + reboot_type) except Exception, e: LOG.exception(_("Error in reboot %s"), e) raise exc.HTTPUnprocessableEntity() diff --git a/nova/compute/api.py b/nova/compute/api.py index 4e2944bb7..b0ea044c5 100644 --- a/nova/compute/api.py +++ b/nova/compute/api.py @@ -1042,13 +1042,14 @@ class API(base.Base): return recv_meta @scheduler_api.reroute_compute("reboot") - def reboot(self, context, instance_id): + def reboot(self, context, instance_id, reboot_type): """Reboot the given instance.""" self.update(context, instance_id, vm_state=vm_states.ACTIVE, task_state=task_states.REBOOTING) - self._cast_compute_message('reboot_instance', context, instance_id) + self._cast_compute_message('reboot_instance', context, instance_id, + reboot_type) @scheduler_api.reroute_compute("rebuild") def rebuild(self, context, instance_id, image_href, admin_password, diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 0477db745..0be12297f 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -579,7 +579,7 @@ class ComputeManager(manager.SchedulerDependentManager): @exception.wrap_exception(notifier=notifier, publisher_id=publisher_id()) @checks_instance_lock - def reboot_instance(self, context, instance_id): + def reboot_instance(self, context, instance_id, reboot_type="SOFT"): """Reboot an instance on this host.""" LOG.audit(_("Rebooting instance %s"), instance_id, context=context) context = context.elevated() @@ -601,7 +601,7 @@ class ComputeManager(manager.SchedulerDependentManager): context=context) network_info = self._get_instance_nw_info(context, instance_ref) - self.driver.reboot(instance_ref, network_info) + self.driver.reboot(instance_ref, network_info, reboot_type) current_power_state = self._get_power_state(context, instance_ref) self._instance_update(context, diff --git a/nova/tests/api/openstack/test_servers.py b/nova/tests/api/openstack/test_servers.py index 2ef687709..d063a60c2 100644 --- a/nova/tests/api/openstack/test_servers.py +++ b/nova/tests/api/openstack/test_servers.py @@ -3615,7 +3615,7 @@ class TestGetKernelRamdiskFromImage(test.TestCase): self.assertRaises(exception.NotFound, self._get_k_r, image_meta) def test_ami_no_ramdisk(self): - """If an ami is missing a ramdisk, return kernel ID and None for + """If an ami is missing a ramdisk, return kernel ID and None for ramdisk ID """ image_meta = {'id': 1, 'status': 'active', 'container_format': 'ami', diff --git a/nova/tests/test_compute.py b/nova/tests/test_compute.py index 65fdffbd6..4d463572b 100644 --- a/nova/tests/test_compute.py +++ b/nova/tests/test_compute.py @@ -300,11 +300,20 @@ class ComputeTestCase(test.TestCase): self.compute.resume_instance(self.context, instance_id) self.compute.terminate_instance(self.context, instance_id) - def test_reboot(self): - """Ensure instance can be rebooted""" + def test_soft_reboot(self): + """Ensure instance can be soft rebooted""" instance_id = self._create_instance() + reboot_type = "SOFT" self.compute.run_instance(self.context, instance_id) - self.compute.reboot_instance(self.context, instance_id) + self.compute.reboot_instance(self.context, instance_id, reboot_type) + self.compute.terminate_instance(self.context, instance_id) + + def test_hard_reboot(self): + """Ensure instance can be hard rebooted""" + instance_id = self._create_instance() + reboot_type = "HARD" + self.compute.run_instance(self.context, instance_id) + self.compute.reboot_instance(self.context, instance_id, reboot_type) self.compute.terminate_instance(self.context, instance_id) def test_set_admin_password(self): diff --git a/nova/tests/test_virt_drivers.py b/nova/tests/test_virt_drivers.py index 480247c91..440d3401b 100644 --- a/nova/tests/test_virt_drivers.py +++ b/nova/tests/test_virt_drivers.py @@ -103,8 +103,9 @@ class _VirtDriverTestCase(test.TestCase): def test_reboot(self): instance_ref = test_utils.get_test_instance() network_info = test_utils.get_test_network_info() + reboot_type = "SOFT" self.connection.spawn(self.ctxt, instance_ref, network_info) - self.connection.reboot(instance_ref, network_info) + self.connection.reboot(instance_ref, network_info, reboot_type) @catch_notimplementederror def test_get_host_ip_addr(self): diff --git a/nova/tests/test_vmwareapi.py b/nova/tests/test_vmwareapi.py index 06daf46e8..e6da1690f 100644 --- a/nova/tests/test_vmwareapi.py +++ b/nova/tests/test_vmwareapi.py @@ -170,7 +170,8 @@ class VMWareAPIVMTestCase(test.TestCase): self._create_vm() info = self.conn.get_info(1) self._check_vm_info(info, power_state.RUNNING) - self.conn.reboot(self.instance, self.network_info) + reboot_type = "SOFT" + self.conn.reboot(self.instance, self.network_info, reboot_type) info = self.conn.get_info(1) self._check_vm_info(info, power_state.RUNNING) diff --git a/nova/virt/driver.py b/nova/virt/driver.py index d05b51bd9..301346c6b 100644 --- a/nova/virt/driver.py +++ b/nova/virt/driver.py @@ -165,12 +165,13 @@ class ComputeDriver(object): # TODO(Vek): Need to pass context in for access to auth_token raise NotImplementedError() - def reboot(self, instance, network_info): + def reboot(self, instance, network_info, reboot_type): """Reboot the specified instance. :param instance: Instance object as returned by DB layer. :param network_info: :py:meth:`~nova.network.manager.NetworkManager.get_instance_nw_info` + :param reboot_type: Either a HARD or SOFT reboot """ # TODO(Vek): Need to pass context in for access to auth_token raise NotImplementedError() diff --git a/nova/virt/fake.py b/nova/virt/fake.py index d5e2bf31b..3596d8353 100644 --- a/nova/virt/fake.py +++ b/nova/virt/fake.py @@ -103,7 +103,7 @@ class FakeConnection(driver.ComputeDriver): if not instance['name'] in self.instances: raise exception.InstanceNotRunning() - def reboot(self, instance, network_info): + def reboot(self, instance, network_info, reboot_type): pass def get_host_ip_addr(self): diff --git a/nova/virt/hyperv.py b/nova/virt/hyperv.py index 03a78db1f..76925b405 100644 --- a/nova/virt/hyperv.py +++ b/nova/virt/hyperv.py @@ -367,7 +367,7 @@ class HyperVConnection(driver.ComputeDriver): wmi_obj.Properties_.Item(prop).Value return newinst - def reboot(self, instance, network_info): + def reboot(self, instance, network_info, reboot_type): """Reboot the specified instance.""" vm = self._lookup(instance.name) if vm is None: diff --git a/nova/virt/vmwareapi_conn.py b/nova/virt/vmwareapi_conn.py index 243ee64f5..fa89a8f45 100644 --- a/nova/virt/vmwareapi_conn.py +++ b/nova/virt/vmwareapi_conn.py @@ -133,7 +133,7 @@ class VMWareESXConnection(driver.ComputeDriver): """Create snapshot from a running VM instance.""" self._vmops.snapshot(context, instance, name) - def reboot(self, instance, network_info): + def reboot(self, instance, network_info, reboot_type): """Reboot VM instance.""" self._vmops.reboot(instance, network_info) diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py index c5f105f40..b7d6a40b4 100644 --- a/nova/virt/xenapi/vmops.py +++ b/nova/virt/xenapi/vmops.py @@ -617,10 +617,15 @@ class VMOps(object): str(new_disk_size)) LOG.debug(_("Resize instance %s complete") % (instance.name)) - def reboot(self, instance): + def reboot(self, instance, reboot_type): """Reboot VM instance.""" vm_ref = self._get_vm_opaque_ref(instance) - task = self._session.call_xenapi('Async.VM.clean_reboot', vm_ref) + + if reboot_type == "HARD": + task = self._session.call_xenapi('Async.VM.hard_reboot', vm_ref) + else: + task = self._session.call_xenapi('Async.VM.clean_reboot', vm_ref) + self._session.wait_for_task(task, instance.id) def get_agent_version(self, instance, timeout=None): diff --git a/nova/virt/xenapi_conn.py b/nova/virt/xenapi_conn.py index 0d23e7689..f6dbc19f8 100644 --- a/nova/virt/xenapi_conn.py +++ b/nova/virt/xenapi_conn.py @@ -203,9 +203,9 @@ class XenAPIConnection(driver.ComputeDriver): """ Create snapshot from a running VM instance """ self._vmops.snapshot(context, instance, image_id) - def reboot(self, instance, network_info): + def reboot(self, instance, network_info, reboot_type): """Reboot VM instance""" - self._vmops.reboot(instance) + self._vmops.reboot(instance, reboot_type) def set_admin_password(self, instance, new_pass): """Set the root/admin password on the VM instance""" -- cgit From 4ffe41dffaab64c96649bfc3236e5ba6bb9d8b37 Mon Sep 17 00:00:00 2001 From: Thierry Carrez Date: Fri, 9 Sep 2011 09:27:26 +0200 Subject: Open Essex (switch version to 2012.1) --- nova/version.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/version.py b/nova/version.py index 1f8d08e8c..06810df46 100644 --- a/nova/version.py +++ b/nova/version.py @@ -22,7 +22,7 @@ except ImportError: 'revno': 0} -NOVA_VERSION = ['2011', '3'] +NOVA_VERSION = ['2012', '1'] YEAR, COUNT = NOVA_VERSION FINAL = False # This becomes true at Release Candidate time -- cgit From 7352e3e1eb7a4d29b556492a208e80439828f211 Mon Sep 17 00:00:00 2001 From: Brian Waldon Date: Fri, 9 Sep 2011 09:48:38 -0400 Subject: removing key_name and config_drive from non-detailed server entity --- nova/api/openstack/views/servers.py | 7 ++----- nova/tests/api/openstack/test_servers.py | 4 ---- 2 files changed, 2 insertions(+), 9 deletions(-) diff --git a/nova/api/openstack/views/servers.py b/nova/api/openstack/views/servers.py index ac09b5864..473dc9e7e 100644 --- a/nova/api/openstack/views/servers.py +++ b/nova/api/openstack/views/servers.py @@ -145,6 +145,8 @@ class ViewBuilderV11(ViewBuilder): response['server']['accessIPv4'] = inst.get('access_ip_v4') or "" response['server']['accessIPv6'] = inst.get('access_ip_v6') or "" + response['server']['key_name'] = inst.get('key_name', '') + response['server']['config_drive'] = inst.get('config_drive') return response @@ -185,8 +187,6 @@ class ViewBuilderV11(ViewBuilder): def _build_extra(self, response, inst): self._build_links(response, inst) response['uuid'] = inst['uuid'] - response['key_name'] = inst.get('key_name', '') - self._build_config_drive(response, inst) def _build_links(self, response, inst): href = self.generate_href(inst["id"]) @@ -205,9 +205,6 @@ class ViewBuilderV11(ViewBuilder): response["links"] = links - def _build_config_drive(self, response, inst): - response['config_drive'] = inst.get('config_drive') - def generate_href(self, server_id): """Create an url that refers to a specific server id.""" return os.path.join(self.base_url, self.project_id, diff --git a/nova/tests/api/openstack/test_servers.py b/nova/tests/api/openstack/test_servers.py index d063a60c2..f0a1c5ce5 100644 --- a/nova/tests/api/openstack/test_servers.py +++ b/nova/tests/api/openstack/test_servers.py @@ -3715,7 +3715,6 @@ class ServersViewBuilderV11Test(test.TestCase): "id": 1, "uuid": self.instance['uuid'], "name": "test_server", - "key_name": '', "links": [ { "rel": "self", @@ -3726,7 +3725,6 @@ class ServersViewBuilderV11Test(test.TestCase): "href": "http://localhost/servers/1", }, ], - "config_drive": None, } } @@ -3739,8 +3737,6 @@ class ServersViewBuilderV11Test(test.TestCase): "id": 1, "uuid": self.instance['uuid'], "name": "test_server", - "key_name": '', - "config_drive": None, "links": [ { "rel": "self", -- cgit From 9dd2d6c49a36c1834d0ef842c47d2ef400642ff2 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Fri, 9 Sep 2011 08:59:02 -0700 Subject: remove sudo from qemu-img commands --- nova/virt/libvirt/connection.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nova/virt/libvirt/connection.py b/nova/virt/libvirt/connection.py index 363a20ed0..19cef5ad7 100644 --- a/nova/virt/libvirt/connection.py +++ b/nova/virt/libvirt/connection.py @@ -1696,7 +1696,7 @@ class LibvirtConnection(driver.ComputeDriver): base = os.path.basename(info['path']) # Get image type and create empty disk image. instance_disk = os.path.join(instance_dir, base) - utils.execute('sudo', 'qemu-img', 'create', '-f', info['type'], + utils.execute('qemu-img', 'create', '-f', info['type'], instance_disk, info['local_gb']) # if image has kernel and ramdisk, just download @@ -1788,7 +1788,7 @@ class LibvirtConnection(driver.ComputeDriver): if disk_type == 'raw': size = int(os.path.getsize(path)) else: - out, err = utils.execute('sudo', 'qemu-img', 'info', path) + out, err = utils.execute('qemu-img', 'info', path) size = [i.split('(')[1].split()[0] for i in out.split('\n') if i.strip().find('virtual size') >= 0] size = int(size[0]) -- cgit From d05d4e77df0bdfd2b802186762391d7f91361701 Mon Sep 17 00:00:00 2001 From: "Kevin L. Mitchell" Date: Fri, 9 Sep 2011 14:35:38 -0500 Subject: Add comment to document why random.shuffle() works --- nova/scheduler/abstract_scheduler.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/nova/scheduler/abstract_scheduler.py b/nova/scheduler/abstract_scheduler.py index b4c2bf4f1..e4f615b94 100644 --- a/nova/scheduler/abstract_scheduler.py +++ b/nova/scheduler/abstract_scheduler.py @@ -296,6 +296,13 @@ class AbstractScheduler(driver.Scheduler): "child_blob": weighting["blob"]} weighted_hosts.append(host_dict) if FLAGS.spread_first: + # NOTE(Vek): If all the weights are unique, then the sort + # below undoes this shuffle; however, if + # several responses from several zones have the + # same weight, then this shuffle serves to + # break up the monolithic blocks and cause the + # instances to be uniformly spread across the + # zones. random.shuffle(weighted_hosts) weighted_hosts.sort(key=operator.itemgetter('weight')) return weighted_hosts -- cgit From c0700ea7bbb4d860610b71e635b8dbde19157e85 Mon Sep 17 00:00:00 2001 From: "Kevin L. Mitchell" Date: Fri, 9 Sep 2011 20:27:22 +0000 Subject: don't need random in abstract_scheduler.py anymore... --- nova/scheduler/abstract_scheduler.py | 1 - 1 file changed, 1 deletion(-) diff --git a/nova/scheduler/abstract_scheduler.py b/nova/scheduler/abstract_scheduler.py index 76329bbc6..6e8c7d715 100644 --- a/nova/scheduler/abstract_scheduler.py +++ b/nova/scheduler/abstract_scheduler.py @@ -22,7 +22,6 @@ behavior is to simply select all hosts and weight them the same. import json import operator -import random import M2Crypto -- cgit