From 86fe4915eeb656abb2abb5fb3c6875a77443b105 Mon Sep 17 00:00:00 2001 From: Brian Waldon Date: Mon, 18 Jul 2011 15:09:39 -0400 Subject: fixing bad lookup --- bin/nova-manage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/nova-manage b/bin/nova-manage index b892d958a..2446309e8 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -518,7 +518,7 @@ class FixedIpCommands(object): instance = fixed_ip['instance'] hostname = instance['hostname'] host = instance['host'] - mac_address = fixed_ip['mac_address']['address'] + mac_address = fixed_ip['virtual_interface']['address'] print "%-18s\t%-15s\t%-17s\t%-15s\t%s" % ( fixed_ip['network']['cidr'], fixed_ip['address'], -- cgit From 7e204b9df840c597a137b605a0d640222a5b97b6 Mon Sep 17 00:00:00 2001 From: "matt.dietz@rackspace.com" <> Date: Tue, 19 Jul 2011 11:25:33 -0500 Subject: Beginnings of the patch --- nova/compute/manager.py | 4 +++- nova/tests/test_compute.py | 11 +++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/nova/compute/manager.py b/nova/compute/manager.py index 960dfea54..0c82b155b 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -743,6 +743,8 @@ class ComputeManager(manager.SchedulerDependentManager): raise exception.Error(_( 'Migration error: destination same as source!')) + old_instance_type = self.db.instance_type_get_by_flavor_id(context, + instance_ref['instance_type_id']) instance_type = self.db.instance_type_get_by_flavor_id(context, flavor_id) migration_ref = self.db.migration_create(context, @@ -750,7 +752,7 @@ class ComputeManager(manager.SchedulerDependentManager): 'source_compute': instance_ref['host'], 'dest_compute': FLAGS.host, 'dest_host': self.driver.get_host_ip_addr(), - 'old_flavor_id': instance_type['flavorid'], + 'old_flavor_id': old_instance_type['flavorid'], 'new_flavor_id': flavor_id, 'status': 'pre-migrating'}) diff --git a/nova/tests/test_compute.py b/nova/tests/test_compute.py index 04bb194d5..6abdd173c 100644 --- a/nova/tests/test_compute.py +++ b/nova/tests/test_compute.py @@ -519,6 +519,17 @@ class ComputeTestCase(test.TestCase): self.compute.terminate_instance(context, instance_id) + def test_finish_revert_resize(self): + """Ensure that the flavor is reverted to the original on revert""" + context = self.context.elevated() + instance_id = self._create_instance() + + self.compute.run_instance(self.context, instance_id) + + self.compute_api.finish_revert_resize(context, instance_id, 1) + + self.compute.terminate_instance(context, instance_id) + def test_get_by_flavor_id(self): type = instance_types.get_instance_type_by_flavor_id(1) self.assertEqual(type['name'], 'm1.tiny') -- cgit From 9febf1eec69708d8c54b6348e882da384d8b42a9 Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Tue, 19 Jul 2011 12:26:41 -0400 Subject: correct broken logic for lxc and uml to avoid adding vnc arguments (LP: #812553) This fixes the logic, so that lxc and uml will not get vnc arguments added to their libvirt xml. To also seems more readable to me. --- nova/virt/libvirt/connection.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/nova/virt/libvirt/connection.py b/nova/virt/libvirt/connection.py index 977bb7dfe..56aaa6c50 100644 --- a/nova/virt/libvirt/connection.py +++ b/nova/virt/libvirt/connection.py @@ -1014,8 +1014,7 @@ class LibvirtConnection(driver.ComputeDriver): 'ebs_root': ebs_root, 'volumes': block_device_mapping} - if FLAGS.vnc_enabled: - if FLAGS.libvirt_type != 'lxc' or FLAGS.libvirt_type != 'uml': + if FLAGS.vnc_enabled and FLAGS.libvirt_type not in ('lxc', 'uml'): xml_info['vncserver_host'] = FLAGS.vncserver_host xml_info['vnc_keymap'] = FLAGS.vnc_keymap if not rescue: -- cgit From d8132fd792d3316420033435a43604f7e09cfcdb Mon Sep 17 00:00:00 2001 From: Trey Morris Date: Tue, 19 Jul 2011 14:29:44 -0500 Subject: better handling of periodic network host setup --- nova/network/manager.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/nova/network/manager.py b/nova/network/manager.py index 24736f53d..33cf86e37 100644 --- a/nova/network/manager.py +++ b/nova/network/manager.py @@ -334,21 +334,21 @@ class NetworkManager(manager.SchedulerDependentManager): self.host) if host == self.host: self._on_set_network_host(context, network_id) - return host def set_network_hosts(self, context): """Set the network hosts for any networks which are unset.""" try: networks = self.db.network_get_all(context) except exception.NoNetworksFound: - # we don't care if no networks are found - pass + # no networks found, nothing to do + return for network in networks: host = network['host'] if not host: - # return so worker will only grab 1 (to help scale flatter) - return self.set_network_host(context, network['id']) + # break so worker will only grab 1 (to help scale flatter) + self.set_network_host(context, network['id']) + break def _get_networks_for_instance(self, context, instance_id, project_id): """Determine & return which networks an instance should connect to.""" -- cgit From b2637c282fba3d542c4e157e3e5e22046d28bb29 Mon Sep 17 00:00:00 2001 From: "matt.dietz@rackspace.com" <> Date: Tue, 19 Jul 2011 15:21:39 -0500 Subject: Functionality fixed and new test passing --- nova/compute/manager.py | 12 ++++++++---- nova/tests/test_compute.py | 42 +++++++++++++++++++++++++++++++++++++++++- 2 files changed, 49 insertions(+), 5 deletions(-) diff --git a/nova/compute/manager.py b/nova/compute/manager.py index b91e6b9af..eb3996d29 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -720,7 +720,8 @@ class ComputeManager(manager.SchedulerDependentManager): self.db.instance_update(context, instance_id, dict(memory_mb=instance_type['memory_mb'], vcpus=instance_type['vcpus'], - local_gb=instance_type['local_gb'])) + local_gb=instance_type['local_gb'], + instance_type_id=instance_type['id'])) self.driver.revert_resize(instance_ref) self.db.migration_update(context, migration_id, @@ -741,14 +742,14 @@ class ComputeManager(manager.SchedulerDependentManager): """ context = context.elevated() instance_ref = self.db.instance_get(context, instance_id) + if instance_ref['host'] == FLAGS.host: raise exception.Error(_( 'Migration error: destination same as source!')) - old_instance_type = self.db.instance_type_get_by_flavor_id(context, + old_instance_type = self.db.instance_type_get_by_id(context, instance_ref['instance_type_id']) - instance_type = self.db.instance_type_get_by_flavor_id(context, - flavor_id) + migration_ref = self.db.migration_create(context, {'instance_id': instance_id, 'source_compute': instance_ref['host'], @@ -768,6 +769,9 @@ class ComputeManager(manager.SchedulerDependentManager): 'migration_id': migration_ref['id'], 'instance_id': instance_id, }, }) + + instance_type = self.db.instance_type_get_by_flavor_id(context, + flavor_id) usage_info = utils.usage_from_instance(instance_ref, new_instance_type=instance_type['name'], new_instance_type_id=instance_type['id']) diff --git a/nova/tests/test_compute.py b/nova/tests/test_compute.py index d5de99956..dc3f0596d 100644 --- a/nova/tests/test_compute.py +++ b/nova/tests/test_compute.py @@ -524,9 +524,49 @@ class ComputeTestCase(test.TestCase): context = self.context.elevated() instance_id = self._create_instance() + def fake(*args, **kwargs): + pass + + self.stubs.Set(self.compute.driver, 'finish_resize', fake) + self.stubs.Set(self.compute.driver, 'revert_resize', fake) + self.stubs.Set(self.compute.network_api, 'get_instance_nw_info', fake) + self.compute.run_instance(self.context, instance_id) - self.compute_api.finish_revert_resize(context, instance_id, 1) + # Confirm the instance size before the resize starts + inst_ref = db.instance_get(context, instance_id) + instance_type_ref = db.instance_type_get_by_id(context, + inst_ref['instance_type_id']) + self.assertEqual(instance_type_ref['flavorid'], 1) + + db.instance_update(self.context, instance_id, {'host': 'foo'}) + + self.compute.prep_resize(context, instance_id, 3) + + migration_ref = db.migration_get_by_instance_and_status(context, + instance_id, 'pre-migrating') + + self.compute.resize_instance(context, instance_id, + migration_ref['id']) + self.compute.finish_resize(context, instance_id, + int(migration_ref['id']), {}) + + # Prove that the instance size is now the new size + inst_ref = db.instance_get(context, instance_id) + instance_type_ref = db.instance_type_get_by_id(context, + inst_ref['instance_type_id']) + self.assertEqual(instance_type_ref['flavorid'], 3) + + # Finally, revert and confirm the old flavor has been applied + self.compute.revert_resize(context, instance_id, + migration_ref['id']) + self.compute.finish_revert_resize(context, instance_id, + migration_ref['id']) + + inst_ref = db.instance_get(context, instance_id) + instance_type_ref = db.instance_type_get_by_id(context, + inst_ref['instance_type_id']) + self.assertEqual(instance_type_ref['flavorid'], 1) self.compute.terminate_instance(context, instance_id) -- cgit From ecb68bf77565cb01ec0ea4d28c7f1315e10b21c4 Mon Sep 17 00:00:00 2001 From: John Tran Date: Tue, 19 Jul 2011 13:49:05 -0700 Subject: network api release_floating_ip method checks if an instance associated to the floating prior to releasing. added test --- nova/network/api.py | 3 +++ nova/tests/test_cloud.py | 29 +++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/nova/network/api.py b/nova/network/api.py index 70b1099f0..f03081be4 100644 --- a/nova/network/api.py +++ b/nova/network/api.py @@ -61,6 +61,9 @@ class API(base.Base): affect_auto_assigned=False): """Removes floating ip with address from a project.""" floating_ip = self.db.floating_ip_get_by_address(context, address) + if floating_ip['fixed_ip']: + raise exception.ApiError(_('Floating ip is in use. ' + 'Disassociate it before releasing.')) if not affect_auto_assigned and floating_ip.get('auto_assigned'): return # NOTE(vish): We don't know which network host should get the ip diff --git a/nova/tests/test_cloud.py b/nova/tests/test_cloud.py index d71a03aff..557e3f89b 100644 --- a/nova/tests/test_cloud.py +++ b/nova/tests/test_cloud.py @@ -15,6 +15,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 mox from base64 import b64decode from M2Crypto import BIO @@ -131,6 +132,34 @@ class CloudTestCase(test.TestCase): allocate, self.context) + def test_release_address(self): + address = "10.10.10.10" + allocate = self.cloud.allocate_address + db.floating_ip_create(self.context, + {'address': address, + 'host': self.network.host}) + result = self.cloud.release_address(self.context, address) + self.assertEqual(result['releaseResponse'], ['Address released.']) + + def test_release_address_still_associated(self): + address = "10.10.10.10" + fixed_ip = {'instance': {'id': 1}} + floating_ip = {'id': 0, + 'address': address, + 'fixed_ip_id': 0, + 'fixed_ip': fixed_ip, + 'project_id': None, + 'auto_assigned': False} + from nova import network + network_api = network.api.API() + self.mox.StubOutWithMock(network_api.db, 'floating_ip_get_by_address') + network_api.db.floating_ip_get_by_address(mox.IgnoreArg(), + mox.IgnoreArg()).AndReturn(floating_ip) + self.mox.ReplayAll() + release = self.cloud.release_address + # ApiError: Floating ip is in use. Disassociate it before releasing. + self.assertRaises(exception.ApiError, release, self.context, address) + @test.skip_test("Skipping this pending future merge") def test_associate_disassociate_address(self): """Verifies associate runs cleanly without raising an exception""" -- cgit From 1d4a789ed370fe0cc00c292f89b96b0ffaf115ff Mon Sep 17 00:00:00 2001 From: John Tran Date: Tue, 19 Jul 2011 14:16:14 -0700 Subject: move import network to the top --- nova/tests/test_cloud.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/tests/test_cloud.py b/nova/tests/test_cloud.py index 46e0ec68c..8cdc73a66 100644 --- a/nova/tests/test_cloud.py +++ b/nova/tests/test_cloud.py @@ -30,6 +30,7 @@ from nova import db from nova import exception from nova import flags from nova import log as logging +from nova import network from nova import rpc from nova import test from nova import utils @@ -151,7 +152,6 @@ class CloudTestCase(test.TestCase): 'fixed_ip': fixed_ip, 'project_id': None, 'auto_assigned': False} - from nova import network network_api = network.api.API() self.mox.StubOutWithMock(network_api.db, 'floating_ip_get_by_address') network_api.db.floating_ip_get_by_address(mox.IgnoreArg(), -- cgit From 6a88f87c11472484f35e1116f107410c031b6838 Mon Sep 17 00:00:00 2001 From: Johannes Erdfelt Date: Wed, 20 Jul 2011 15:16:36 +0000 Subject: Fix permissions for plugins --- plugins/xenserver/xenapi/etc/xapi.d/plugins/glance | 0 plugins/xenserver/xenapi/etc/xapi.d/plugins/migration | 0 plugins/xenserver/xenapi/etc/xapi.d/plugins/objectstore | 0 plugins/xenserver/xenapi/etc/xapi.d/plugins/pluginlib_nova.py | 0 plugins/xenserver/xenapi/etc/xapi.d/plugins/xenhost | 0 5 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 plugins/xenserver/xenapi/etc/xapi.d/plugins/glance mode change 100644 => 100755 plugins/xenserver/xenapi/etc/xapi.d/plugins/migration mode change 100644 => 100755 plugins/xenserver/xenapi/etc/xapi.d/plugins/objectstore mode change 100755 => 100644 plugins/xenserver/xenapi/etc/xapi.d/plugins/pluginlib_nova.py mode change 100644 => 100755 plugins/xenserver/xenapi/etc/xapi.d/plugins/xenhost diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance b/plugins/xenserver/xenapi/etc/xapi.d/plugins/glance old mode 100644 new mode 100755 diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/migration b/plugins/xenserver/xenapi/etc/xapi.d/plugins/migration old mode 100644 new mode 100755 diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/objectstore b/plugins/xenserver/xenapi/etc/xapi.d/plugins/objectstore old mode 100644 new mode 100755 diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/pluginlib_nova.py b/plugins/xenserver/xenapi/etc/xapi.d/plugins/pluginlib_nova.py old mode 100755 new mode 100644 diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/xenhost b/plugins/xenserver/xenapi/etc/xapi.d/plugins/xenhost old mode 100644 new mode 100755 -- cgit From e65a9fe5827e0d5961e618a3163382c2ad02274c Mon Sep 17 00:00:00 2001 From: Scott Moser Date: Wed, 20 Jul 2011 12:17:44 -0400 Subject: correct indentation --- 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 56aaa6c50..4905d931a 100644 --- a/nova/virt/libvirt/connection.py +++ b/nova/virt/libvirt/connection.py @@ -1015,8 +1015,8 @@ class LibvirtConnection(driver.ComputeDriver): 'volumes': block_device_mapping} if FLAGS.vnc_enabled and FLAGS.libvirt_type not in ('lxc', 'uml'): - xml_info['vncserver_host'] = FLAGS.vncserver_host - xml_info['vnc_keymap'] = FLAGS.vnc_keymap + xml_info['vncserver_host'] = FLAGS.vncserver_host + xml_info['vnc_keymap'] = FLAGS.vnc_keymap if not rescue: if instance['kernel_id']: xml_info['kernel'] = xml_info['basepath'] + "/kernel" -- cgit From 2bf85d9151771aa4ca5c1201cadbb255db85643f Mon Sep 17 00:00:00 2001 From: Ryu Ishimoto Date: Thu, 21 Jul 2011 02:26:31 +0900 Subject: Created _get_instance_nw_info method to clean up duplicate code --- nova/compute/manager.py | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/nova/compute/manager.py b/nova/compute/manager.py index cc5cf747c..326880b1c 100644 --- a/nova/compute/manager.py +++ b/nova/compute/manager.py @@ -212,6 +212,15 @@ class ComputeManager(manager.SchedulerDependentManager): """This call passes straight through to the virtualization driver.""" return self.driver.refresh_provider_fw_rules() + def _get_instance_nw_info(self, context, instance): + """Get a list of dictionaries of network data of an instance. + Returns an empty list if stub_network flag is set.""" + network_info = [] + if not FLAGS.stub_network: + network_info = self.network_api.get_instance_nw_info(context, + instance) + return network_info + def _setup_block_device_mapping(self, context, instance_id): """setup volumes for block device mapping""" self.db.instance_set_state(context, @@ -352,10 +361,8 @@ class ComputeManager(manager.SchedulerDependentManager): {'action_str': action_str, 'instance_id': instance_id}, context=context) - network_info = None + network_info = self._get_instance_nw_info(context, instance) if not FLAGS.stub_network: - network_info = self.network_api.get_instance_nw_info(context, - instance) self.network_api.deallocate_for_instance(context, instance) volumes = instance.get('volumes') or [] @@ -412,8 +419,8 @@ class ComputeManager(manager.SchedulerDependentManager): self._update_state(context, instance_id, power_state.BUILDING) - network_info = self.network_api.get_instance_nw_info(context, - instance_ref) + network_info = self._get_instance_nw_info(context, instance_ref) + self.driver.destroy(instance_ref, network_info) image_ref = kwargs.get('image_ref') instance_ref.image_ref = image_ref @@ -451,8 +458,7 @@ class ComputeManager(manager.SchedulerDependentManager): instance_id, power_state.NOSTATE, 'rebooting') - network_info = self.network_api.get_instance_nw_info(context, - instance_ref) + network_info = self._get_instance_nw_info(context, instance_ref) self.driver.reboot(instance_ref, network_info) self._update_state(context, instance_id) @@ -643,10 +649,9 @@ class ComputeManager(manager.SchedulerDependentManager): instance_id, power_state.NOSTATE, 'rescuing') - network_info = self.network_api.get_instance_nw_info(context, - instance_ref) _update_state = lambda result: self._update_state_callback( self, context, instance_id, result) + network_info = self._get_instance_nw_info(context, instance_ref) self.driver.rescue(instance_ref, _update_state, network_info) self._update_state(context, instance_id) @@ -663,8 +668,7 @@ class ComputeManager(manager.SchedulerDependentManager): 'unrescuing') _update_state = lambda result: self._update_state_callback( self, context, instance_id, result) - network_info = self.network_api.get_instance_nw_info(context, - instance_ref) + network_info = self._get_instance_nw_info(context, instance_ref) self.driver.unrescue(instance_ref, _update_state, network_info) self._update_state(context, instance_id) @@ -680,8 +684,7 @@ class ComputeManager(manager.SchedulerDependentManager): context = context.elevated() instance_ref = self.db.instance_get(context, instance_id) - network_info = self.network_api.get_instance_nw_info(context, - instance_ref) + network_info = self._get_instance_nw_info(context, instance_ref) self.driver.destroy(instance_ref, network_info) usage_info = utils.usage_from_instance(instance_ref) notifier.notify('compute.%s' % self.host, @@ -701,8 +704,7 @@ class ComputeManager(manager.SchedulerDependentManager): instance_ref = self.db.instance_get(context, instance_id) migration_ref = self.db.migration_get(context, migration_id) - network_info = self.network_api.get_instance_nw_info(context, - instance_ref) + network_info = self._get_instance_nw_info(context, instance_ref) self.driver.destroy(instance_ref, network_info) topic = self.db.queue_get_for(context, FLAGS.compute_topic, instance_ref['host']) @@ -837,8 +839,7 @@ class ComputeManager(manager.SchedulerDependentManager): # reload the updated instance ref # FIXME(mdietz): is there reload functionality? instance = self.db.instance_get(context, instance_id) - network_info = self.network_api.get_instance_nw_info(context, - instance) + network_info = self._get_instance_nw_info(context, instance) self.driver.finish_resize(instance, disk_info, network_info) self.db.migration_update(context, migration_id, @@ -988,8 +989,7 @@ class ComputeManager(manager.SchedulerDependentManager): LOG.debug(_('instance %s: inject network info'), instance_id, context=context) instance = self.db.instance_get(context, instance_id) - network_info = self.network_api.get_instance_nw_info(context, - instance) + network_info = self._get_instance_nw_info(context, instance) LOG.debug(_("network_info to inject: |%s|"), network_info) self.driver.inject_network_info(instance, network_info) @@ -1207,8 +1207,7 @@ class ComputeManager(manager.SchedulerDependentManager): # # Retry operation is necessary because continuously request comes, # concorrent request occurs to iptables, then it complains. - network_info = self.network_api.get_instance_nw_info(context, - instance_ref) + network_info = self._get_instance_nw_info(context, instance_ref) max_retry = FLAGS.live_migration_retry_count for cnt in range(max_retry): try: -- cgit From 53506549e285ee85cb1911670a8ff24ccdd32d5c Mon Sep 17 00:00:00 2001 From: Ryu Ishimoto Date: Thu, 21 Jul 2011 02:26:58 +0900 Subject: Made the compute unit tests to pass --- nova/tests/test_compute.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/nova/tests/test_compute.py b/nova/tests/test_compute.py index 2900c594e..9d6d2da54 100644 --- a/nova/tests/test_compute.py +++ b/nova/tests/test_compute.py @@ -569,7 +569,6 @@ class ComputeTestCase(test.TestCase): self._setup_other_managers() dbmock = self.mox.CreateMock(db) volmock = self.mox.CreateMock(self.volume_manager) - netmock = self.mox.CreateMock(self.network_manager) drivermock = self.mox.CreateMock(self.compute_driver) dbmock.instance_get(c, i_ref['id']).AndReturn(i_ref) @@ -577,12 +576,11 @@ class ComputeTestCase(test.TestCase): for i in range(len(i_ref['volumes'])): vid = i_ref['volumes'][i]['id'] volmock.setup_compute_volume(c, vid).InAnyOrder('g1') - netmock.setup_compute_network(c, i_ref['id']) + drivermock.plug_vifs(i_ref, []) drivermock.ensure_filtering_rules_for_instance(i_ref) self.compute.db = dbmock self.compute.volume_manager = volmock - self.compute.network_manager = netmock self.compute.driver = drivermock self.mox.ReplayAll() @@ -597,18 +595,16 @@ class ComputeTestCase(test.TestCase): self._setup_other_managers() dbmock = self.mox.CreateMock(db) - netmock = self.mox.CreateMock(self.network_manager) drivermock = self.mox.CreateMock(self.compute_driver) dbmock.instance_get(c, i_ref['id']).AndReturn(i_ref) dbmock.instance_get_fixed_addresses(c, i_ref['id']).AndReturn('dummy') self.mox.StubOutWithMock(compute_manager.LOG, 'info') compute_manager.LOG.info(_("%s has no volume."), i_ref['hostname']) - netmock.setup_compute_network(c, i_ref['id']) + drivermock.plug_vifs(i_ref, []) drivermock.ensure_filtering_rules_for_instance(i_ref) self.compute.db = dbmock - self.compute.network_manager = netmock self.compute.driver = drivermock self.mox.ReplayAll() @@ -629,18 +625,20 @@ class ComputeTestCase(test.TestCase): dbmock = self.mox.CreateMock(db) netmock = self.mox.CreateMock(self.network_manager) volmock = self.mox.CreateMock(self.volume_manager) + drivermock = self.mox.CreateMock(self.compute_driver) dbmock.instance_get(c, i_ref['id']).AndReturn(i_ref) dbmock.instance_get_fixed_addresses(c, i_ref['id']).AndReturn('dummy') for i in range(len(i_ref['volumes'])): volmock.setup_compute_volume(c, i_ref['volumes'][i]['id']) for i in range(FLAGS.live_migration_retry_count): - netmock.setup_compute_network(c, i_ref['id']).\ + drivermock.plug_vifs(i_ref, []).\ AndRaise(exception.ProcessExecutionError()) self.compute.db = dbmock self.compute.network_manager = netmock self.compute.volume_manager = volmock + self.compute.driver = drivermock self.mox.ReplayAll() self.assertRaises(exception.ProcessExecutionError, -- cgit From cea17225c9a568e97f55287edf7510ebcfbae301 Mon Sep 17 00:00:00 2001 From: Ryu Ishimoto Date: Thu, 21 Jul 2011 02:57:52 +0900 Subject: Moved back allow_project_net_traffic to libvirt conn --- nova/virt/libvirt/connection.py | 3 +++ nova/virt/libvirt/vif.py | 3 --- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/nova/virt/libvirt/connection.py b/nova/virt/libvirt/connection.py index 3f6230e95..c2a867e30 100644 --- a/nova/virt/libvirt/connection.py +++ b/nova/virt/libvirt/connection.py @@ -96,6 +96,9 @@ flags.DEFINE_string('libvirt_uri', '', 'Override the default libvirt URI (which is dependent' ' on libvirt_type)') +flags.DEFINE_bool('allow_project_net_traffic', + True, + 'Whether to allow in project network traffic') flags.DEFINE_bool('use_cow_images', True, 'Whether to use cow images') diff --git a/nova/virt/libvirt/vif.py b/nova/virt/libvirt/vif.py index d35a3c8f6..3d9b234b8 100644 --- a/nova/virt/libvirt/vif.py +++ b/nova/virt/libvirt/vif.py @@ -25,9 +25,6 @@ from nova import utils from nova.virt.vif import VIFDriver FLAGS = flags.FLAGS -flags.DEFINE_bool('allow_project_net_traffic', - True, - 'Whether to allow in project network traffic') class LibvirtBridge(object): -- cgit From 38371fe9c073990ecf722dc3983d4d8fa968b198 Mon Sep 17 00:00:00 2001 From: Ryu Ishimoto Date: Thu, 21 Jul 2011 02:58:42 +0900 Subject: Made all but one test pass for libvirt --- nova/tests/test_libvirt.py | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/nova/tests/test_libvirt.py b/nova/tests/test_libvirt.py index f99e1713d..4878ed8d1 100644 --- a/nova/tests/test_libvirt.py +++ b/nova/tests/test_libvirt.py @@ -54,9 +54,13 @@ def _create_network_info(count=1, ipv6=None): fake_ip = '0.0.0.0/0' fake_ip_2 = '0.0.0.1/0' fake_ip_3 = '0.0.0.1/0' + fake_vlan = 100 + fake_bridge_interface = 'eth0' network = {'bridge': fake, 'cidr': fake_ip, - 'cidr_v6': fake_ip} + 'cidr_v6': fake_ip, + 'vlan': fake_vlan, + 'bridge_interface': fake_bridge_interface} mapping = {'mac': fake, 'gateway': fake, 'gateway6': fake, @@ -218,9 +222,19 @@ class LibvirtConnTestCase(test.TestCase): def setattr(self, key, val): self.__setattr__(key, val) + # A fake VIF driver + class FakeVIFDriver(object): + + def __init__(self, **kwargs): + pass + + def setattr(self, key, val): + self.__setattr__(key, val) + # Creating mocks fake = FakeLibvirtConnection() fakeip = FakeIptablesFirewallDriver + fakevif = FakeVIFDriver() # Customizing above fake if necessary for key, val in kwargs.items(): fake.__setattr__(key, val) @@ -228,6 +242,8 @@ class LibvirtConnTestCase(test.TestCase): # Inevitable mocks for connection.LibvirtConnection self.mox.StubOutWithMock(connection.utils, 'import_class') connection.utils.import_class(mox.IgnoreArg()).AndReturn(fakeip) + self.mox.StubOutWithMock(connection.utils, 'import_object') + connection.utils.import_object(mox.IgnoreArg()).AndReturn(fakevif) self.mox.StubOutWithMock(connection.LibvirtConnection, '_conn') connection.LibvirtConnection._conn = fake @@ -279,22 +295,6 @@ class LibvirtConnTestCase(test.TestCase): _create_network_info(2)) self.assertTrue(len(result['nics']) == 2) - def test_get_nic_for_xml_v4(self): - conn = connection.LibvirtConnection(True) - network, mapping = _create_network_info()[0] - self.flags(use_ipv6=False) - params = conn._get_nic_for_xml(network, mapping)['extra_params'] - self.assertTrue(params.find('PROJNETV6') == -1) - self.assertTrue(params.find('PROJMASKV6') == -1) - - def test_get_nic_for_xml_v6(self): - conn = connection.LibvirtConnection(True) - network, mapping = _create_network_info()[0] - self.flags(use_ipv6=True) - params = conn._get_nic_for_xml(network, mapping)['extra_params'] - self.assertTrue(params.find('PROJNETV6') > -1) - self.assertTrue(params.find('PROJMASKV6') > -1) - @test.skip_test("skipping libvirt tests depends on get_network_info shim") def test_xml_and_uri_no_ramdisk_no_kernel(self): instance_data = dict(self.test_instance) -- cgit From 22f6b3d99c94a4bdfb031767f86b3aee4396aa70 Mon Sep 17 00:00:00 2001 From: Ryu Ishimoto Date: Thu, 21 Jul 2011 03:20:07 +0900 Subject: Added Dan Wendlandt to Authors, and fixed failing network unit tests --- Authors | 1 + nova/tests/test_network.py | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/Authors b/Authors index 15599b0e1..32bae4f43 100644 --- a/Authors +++ b/Authors @@ -18,6 +18,7 @@ Christian Berendt Chuck Short Cory Wright Dan Prince +Dan Wendlandt Dave Walker David Pravec Dean Troyer diff --git a/nova/tests/test_network.py b/nova/tests/test_network.py index b09021e13..3ced1e5c4 100644 --- a/nova/tests/test_network.py +++ b/nova/tests/test_network.py @@ -159,7 +159,9 @@ class FlatNetworkTestCase(test.TestCase): 'cidr': '192.168.%s.0/24' % i, 'cidr_v6': '2001:db%s::/64' % i8, 'id': i, - 'injected': 'DONTCARE'} + 'injected': 'DONTCARE', + 'bridge_interface': 'fake_fa%s' % i, + 'vlan': None} self.assertDictMatch(nw[0], check) -- cgit