From ba73d32d694a6fbbf180f39bfd5dc38ad33677a4 Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Fri, 25 Feb 2011 13:01:32 -0800 Subject: [PATCH 01/29] add a caching layer to the has_role call to increase performance --- nova/auth/manager.py | 58 ++++++++++++++++++++++++++++++++------------ nova/flags.py | 2 ++ 2 files changed, 45 insertions(+), 15 deletions(-) diff --git a/nova/auth/manager.py b/nova/auth/manager.py index 450ab803..90673479 100644 --- a/nova/auth/manager.py +++ b/nova/auth/manager.py @@ -214,6 +214,13 @@ class AuthManager(object): if driver or not getattr(self, 'driver', None): self.driver = utils.import_class(driver or FLAGS.auth_driver) + if FLAGS.memcached_servers: + import memcache + else: + from nova import fakememcache as memcache + self.mc = memcache.Client(FLAGS.memcached_servers, + debug=0) + def authenticate(self, access, signature, params, verb='GET', server_string='127.0.0.1:8773', path='/', check_type='ec2', headers=None): @@ -351,6 +358,25 @@ class AuthManager(object): if self.has_role(user, role): return True + def _build_mc_key(self, user, role, project=None): + return "rolecache-%s-%s-%s" % (User.safe_id(user), role, + (Project.safe_id(project) if project else 'None')) + + def _clear_mc_key(self, user, role, project=None): + # (anthony) it would be better to delete the key + self.mc.set(self._build_mc_key(user, role, project), None) + + def _has_role(self, user, role, project=None): + with self.driver() as drv: + mc_key = self._build_mc_key(user, role, project) + rslt = self.mc.get(mc_key) + if rslt == None: + rslt = drv.has_role(user, role, project) + self.mc.set(mc_key, rslt) + return rslt + else: + return rslt + def has_role(self, user, role, project=None): """Checks existence of role for user @@ -374,24 +400,24 @@ class AuthManager(object): @rtype: bool @return: True if the user has the role. """ - with self.driver() as drv: - if role == 'projectmanager': - if not project: - raise exception.Error(_("Must specify project")) - return self.is_project_manager(user, project) + if role == 'projectmanager': + if not project: + raise exception.Error(_("Must specify project")) + return self.is_project_manager(user, project) - global_role = drv.has_role(User.safe_id(user), - role, - None) - if not global_role: - return global_role + global_role = self._has_role(User.safe_id(user), + role, + None) - if not project or role in FLAGS.global_roles: - return global_role + if not global_role: + return global_role - return drv.has_role(User.safe_id(user), - role, - Project.safe_id(project)) + if not project or role in FLAGS.global_roles: + return global_role + + return self._has_role(User.safe_id(user), + role, + Project.safe_id(project)) def add_role(self, user, role, project=None): """Adds role for user @@ -423,6 +449,7 @@ class AuthManager(object): LOG.audit(_("Adding sitewide role %(role)s to user %(uid)s") % locals()) with self.driver() as drv: + self._clear_mc_key(uid, role, pid) drv.add_role(uid, role, pid) def remove_role(self, user, role, project=None): @@ -451,6 +478,7 @@ class AuthManager(object): LOG.audit(_("Removing sitewide role %(role)s" " from user %(uid)s") % locals()) with self.driver() as drv: + self._clear_mc_key(uid, role, pid) drv.remove_role(uid, role, pid) @staticmethod diff --git a/nova/flags.py b/nova/flags.py index 8cf199b2..f885de29 100644 --- a/nova/flags.py +++ b/nova/flags.py @@ -354,3 +354,5 @@ DEFINE_string('host', socket.gethostname(), DEFINE_string('node_availability_zone', 'nova', 'availability zone of this node') +DEFINE_list('memcached_servers', None, + 'Memcached servers or None for in process cache.') From f9ef50657527936e56915a6e972b424c6f11746e Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Fri, 25 Feb 2011 16:41:48 -0800 Subject: [PATCH 02/29] only create auth connection if cache misses --- nova/auth/manager.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/nova/auth/manager.py b/nova/auth/manager.py index 90673479..511bc3a6 100644 --- a/nova/auth/manager.py +++ b/nova/auth/manager.py @@ -367,15 +367,15 @@ class AuthManager(object): self.mc.set(self._build_mc_key(user, role, project), None) def _has_role(self, user, role, project=None): - with self.driver() as drv: - mc_key = self._build_mc_key(user, role, project) - rslt = self.mc.get(mc_key) - if rslt == None: + mc_key = self._build_mc_key(user, role, project) + rslt = self.mc.get(mc_key) + if rslt == None: + with self.driver() as drv: rslt = drv.has_role(user, role, project) self.mc.set(mc_key, rslt) return rslt - else: - return rslt + else: + return rslt def has_role(self, user, role, project=None): """Checks existence of role for user From 6ac8a9158f9e41a11921227e4403a5a63f266434 Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Fri, 25 Feb 2011 17:18:41 -0800 Subject: [PATCH 03/29] force memcache key to be str --- nova/auth/manager.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nova/auth/manager.py b/nova/auth/manager.py index 511bc3a6..84c8a6cb 100644 --- a/nova/auth/manager.py +++ b/nova/auth/manager.py @@ -359,8 +359,8 @@ class AuthManager(object): return True def _build_mc_key(self, user, role, project=None): - return "rolecache-%s-%s-%s" % (User.safe_id(user), role, - (Project.safe_id(project) if project else 'None')) + return str("rolecache-%s-%s-%s" % (User.safe_id(user), role, + (Project.safe_id(project) if project else 'None'))) def _clear_mc_key(self, user, role, project=None): # (anthony) it would be better to delete the key From 9aa2d409932f8e5fd2296255133fc1a274945762 Mon Sep 17 00:00:00 2001 From: Kevin Bringard Date: Mon, 28 Mar 2011 07:33:57 -0600 Subject: [PATCH 04/29] Updated Authors file --- Authors | 1 + 1 file changed, 1 insertion(+) diff --git a/Authors b/Authors index 09759ddc..298ba8e8 100644 --- a/Authors +++ b/Authors @@ -40,6 +40,7 @@ Joshua McKenty Justin Santa Barbara Kei Masumoto Ken Pepple +Kevin Bringard Kevin L. Mitchell Koji Iida Lorin Hochstein From ff183cff2a595fc5a3296430505e75c21ef7f1d1 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Tue, 5 Apr 2011 12:56:25 -0700 Subject: [PATCH 07/29] fixed comment --- nova/auth/manager.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/auth/manager.py b/nova/auth/manager.py index 12ded120..f2451702 100644 --- a/nova/auth/manager.py +++ b/nova/auth/manager.py @@ -372,7 +372,7 @@ class AuthManager(object): (Project.safe_id(project) if project else 'None'))) def _clear_mc_key(self, user, role, project=None): - # (anthony) it would be better to delete the key + # NOTE(anthony): it would be better to delete the key self.mc.set(self._build_mc_key(user, role, project), None) def _has_role(self, user, role, project=None): From 8c82e513817a548d9af0389168d9b76ea0cfd9b5 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Tue, 5 Apr 2011 15:58:19 -0700 Subject: [PATCH 08/29] remove -None for user roles --- nova/auth/manager.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/nova/auth/manager.py b/nova/auth/manager.py index f2451702..3de2ceff 100644 --- a/nova/auth/manager.py +++ b/nova/auth/manager.py @@ -368,8 +368,10 @@ class AuthManager(object): return True def _build_mc_key(self, user, role, project=None): - return str("rolecache-%s-%s-%s" % (User.safe_id(user), role, - (Project.safe_id(project) if project else 'None'))) + role_key = str("rolecache-%s-%s" % (User.safe_id(user), role)) + if project: + return "%s-%s" % (role_key, Project.safe_id(project)) + return role_key def _clear_mc_key(self, user, role, project=None): # NOTE(anthony): it would be better to delete the key From d7e5ac2be911d3a8e3229a75dc77deb316c506b3 Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Mon, 18 Apr 2011 22:02:54 -0400 Subject: [PATCH 09/29] Implement get_host_ip_addr in the libvirt compute driver. --- nova/tests/test_virt.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/nova/tests/test_virt.py b/nova/tests/test_virt.py index aeaea91c..d9780148 100644 --- a/nova/tests/test_virt.py +++ b/nova/tests/test_virt.py @@ -18,6 +18,7 @@ import eventlet import mox import os import re +import socket import sys from xml.etree.ElementTree import fromstring as xml_to_tree @@ -549,6 +550,17 @@ class LibvirtConnTestCase(test.TestCase): db.volume_destroy(self.context, volume_ref['id']) db.instance_destroy(self.context, instance_ref['id']) + def test_get_host_ip_addr(self): + + def getHostname(): + return socket.gethostname() + + self.create_fake_libvirt_mock(getHostname=getHostname) + self.mox.ReplayAll() + conn = libvirt_conn.LibvirtConnection(False) + ip = conn.get_host_ip_addr() + self.assertTrue(ip is not None) + def tearDown(self): self.manager.delete_project(self.project) self.manager.delete_user(self.user) From 04000346f19f75cd2e55a335d66b1f6391943275 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jason=20K=C3=B6lker?= Date: Tue, 19 Apr 2011 15:52:32 -0500 Subject: [PATCH 10/29] add support for git checking and a default of failing if the history can't be read --- nova/tests/test_misc.py | 51 ++++++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 18 deletions(-) diff --git a/nova/tests/test_misc.py b/nova/tests/test_misc.py index 4e17e1ce..ad62b48b 100644 --- a/nova/tests/test_misc.py +++ b/nova/tests/test_misc.py @@ -29,11 +29,12 @@ from nova.utils import parse_mailmap, str_dict_replace class ProjectTestCase(test.TestCase): def test_authors_up_to_date(self): topdir = os.path.normpath(os.path.dirname(__file__) + '/../../') + missing = set() + contributors = set() + mailmap = parse_mailmap(os.path.join(topdir, '.mailmap')) + authors_file = open(os.path.join(topdir, 'Authors'), 'r').read() + if os.path.exists(os.path.join(topdir, '.bzr')): - contributors = set() - - mailmap = parse_mailmap(os.path.join(topdir, '.mailmap')) - import bzrlib.workingtree tree = bzrlib.workingtree.WorkingTree.open(topdir) tree.lock_read() @@ -47,23 +48,37 @@ class ProjectTestCase(test.TestCase): for r in revs: for author in r.get_apparent_authors(): email = author.split(' ')[-1] - contributors.add(str_dict_replace(email, mailmap)) - - authors_file = open(os.path.join(topdir, 'Authors'), - 'r').read() - - missing = set() - for contributor in contributors: - if contributor == 'nova-core': - continue - if not contributor in authors_file: - missing.add(contributor) - - self.assertTrue(len(missing) == 0, - '%r not listed in Authors' % missing) + contributors.add(str_dict_replace(email, + mailmap)) finally: tree.unlock() + elif os.path.exists(os.path.join(topdir, '.git')): + import git + repo = git.Repo(topdir) + for commit in repo.head.commit.iter_parents(): + email = commit.author.email + if email is None: + email = commit.author.name + if 'nova-core' in email: + continue + if email.split(' ')[-1] == '<>': + email = email.split(' ')[-2] + email = '<' + email + '>' + contributors.add(str_dict_replace(email, mailmap)) + + else: + self.assertTrue(False, 'Cannot read commit history') + + for contributor in contributors: + if contributor == 'nova-core': + continue + if not contributor in authors_file: + missing.add(contributor) + + self.assertTrue(len(missing) == 0, + '%r not listed in Authors' % missing) + class LockTestCase(test.TestCase): def test_synchronized_wrapped_function_metadata(self): From 8991268596fc24c433b96a218da39dfa01848438 Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Wed, 20 Apr 2011 13:37:21 -0700 Subject: [PATCH 11/29] fix display of vpn instance id and add output rule so it can be tested from network host --- bin/nova-manage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/nova-manage b/bin/nova-manage index b2308bc0..55e275e7 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -151,7 +151,7 @@ class VpnCommands(object): state = 'up' print address, print vpn['host'], - print vpn['ec2_id'], + print ec2utils.id_to_ec2_id(vpn['id']), print vpn['state_description'], print state else: From 6aa3e4618a2767926013d56087a4ce721a275e97 Mon Sep 17 00:00:00 2001 From: Alex Meade Date: Thu, 21 Apr 2011 14:12:54 -0400 Subject: [PATCH 12/29] Modified instance status for shutdown power state in OS api --- Authors | 1 + 1 file changed, 1 insertion(+) diff --git a/Authors b/Authors index ce280749..d3ba23fb 100644 --- a/Authors +++ b/Authors @@ -1,3 +1,4 @@ +Alex Meade Andy Smith Andy Southgate Anne Gentle From 5590a640a64d0ceabffb9657984092cc46d957fa Mon Sep 17 00:00:00 2001 From: Vishvananda Ishaya Date: Thu, 21 Apr 2011 23:45:02 -0700 Subject: [PATCH 13/29] Fixes per review --- nova/auth/manager.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/nova/auth/manager.py b/nova/auth/manager.py index 3de2ceff..4d4bdbce 100644 --- a/nova/auth/manager.py +++ b/nova/auth/manager.py @@ -368,10 +368,10 @@ class AuthManager(object): return True def _build_mc_key(self, user, role, project=None): - role_key = str("rolecache-%s-%s" % (User.safe_id(user), role)) + key_parts = ['rolecache', User.safe_id(user), str(role)] if project: - return "%s-%s" % (role_key, Project.safe_id(project)) - return role_key + key_parts.append(Project.safe_id(project)) + return '-'.join(key_parts) def _clear_mc_key(self, user, role, project=None): # NOTE(anthony): it would be better to delete the key @@ -380,7 +380,7 @@ class AuthManager(object): def _has_role(self, user, role, project=None): mc_key = self._build_mc_key(user, role, project) rslt = self.mc.get(mc_key) - if rslt == None: + if rslt is None: with self.driver() as drv: rslt = drv.has_role(user, role, project) self.mc.set(mc_key, rslt) From 79a4cc37643a6458e66af6484a72a70b3699ced9 Mon Sep 17 00:00:00 2001 From: Todd Willey Date: Tue, 26 Apr 2011 18:55:13 -0400 Subject: [PATCH 14/29] Let nova-mange limit project list by user. --- bin/nova-manage | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/bin/nova-manage b/bin/nova-manage index c8230670..820b10e2 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -385,10 +385,10 @@ class ProjectCommands(object): with open(filename, 'w') as f: f.write(rc) - def list(self): + def list(self, username=None): """Lists all projects - arguments: """ - for project in self.manager.get_projects(): + arguments: [username]""" + for project in self.manager.get_projects(username): print project.name def quota(self, project_id, key=None, value=None): From 2ba6ad424923f68b7e6c9132d1a6e611ba840587 Mon Sep 17 00:00:00 2001 From: Alex Meade Date: Wed, 27 Apr 2011 00:53:07 -0400 Subject: [PATCH 15/29] Added myself to authors file --- Authors | 1 + 1 file changed, 1 insertion(+) diff --git a/Authors b/Authors index eccf38a4..cef2c761 100644 --- a/Authors +++ b/Authors @@ -1,3 +1,4 @@ +Alex Meade Andy Smith Andy Southgate Anne Gentle From ef381873f6ab13eaff91c40e6a02521338292e5a Mon Sep 17 00:00:00 2001 From: Brian Waldon Date: Wed, 27 Apr 2011 14:03:05 -0700 Subject: [PATCH 16/29] further cleanup of nova/exceptions.py --- nova/auth/manager.py | 6 ++++-- nova/tests/test_instance_types.py | 6 +++--- nova/tests/test_scheduler.py | 10 +++------- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/nova/auth/manager.py b/nova/auth/manager.py index b719a0db..72566717 100644 --- a/nova/auth/manager.py +++ b/nova/auth/manager.py @@ -303,7 +303,8 @@ class AuthManager(object): LOG.debug('signature: %s', signature) if signature != expected_signature: LOG.audit(_("Invalid signature for user %s"), user.name) - raise exception.NotAuthorized(_('Signature does not match')) + raise exception.InvalidSignature(signature=signature, + user=user) elif check_type == 'ec2': # NOTE(vish): hmac can't handle unicode, so encode ensures that # secret isn't unicode @@ -314,7 +315,8 @@ class AuthManager(object): LOG.debug('signature: %s', signature) if signature != expected_signature: LOG.audit(_("Invalid signature for user %s"), user.name) - raise exception.NotAuthorized(_('Signature does not match')) + raise exception.InvalidSignature(signature=signature, + user=user) return (user, project) def get_access_key(self, user, project): diff --git a/nova/tests/test_instance_types.py b/nova/tests/test_instance_types.py index dd7d0737..ef271518 100644 --- a/nova/tests/test_instance_types.py +++ b/nova/tests/test_instance_types.py @@ -75,13 +75,13 @@ class InstanceTypeTestCase(test.TestCase): def test_invalid_create_args_should_fail(self): """Ensures that instance type creation fails with invalid args""" self.assertRaises( - exception.InvalidInputException, + exception.InvalidInput, instance_types.create, self.name, 0, 1, 120, self.flavorid) self.assertRaises( - exception.InvalidInputException, + exception.InvalidInput, instance_types.create, self.name, 256, -1, 120, self.flavorid) self.assertRaises( - exception.InvalidInputException, + exception.InvalidInput, instance_types.create, self.name, 256, 1, "aa", self.flavorid) def test_non_existant_inst_type_shouldnt_delete(self): diff --git a/nova/tests/test_scheduler.py b/nova/tests/test_scheduler.py index efd12f93..968ef9d6 100644 --- a/nova/tests/test_scheduler.py +++ b/nova/tests/test_scheduler.py @@ -768,14 +768,10 @@ class SimpleDriverTestCase(test.TestCase): s_ref = self._create_compute_service(host='somewhere', memory_mb_used=12) - try: - self.scheduler.driver._live_migration_dest_check(self.context, - i_ref, - 'somewhere') - except exception.NotEmpty, e: - c = (e.message.find('Unable to migrate') >= 0) + self.assertRaises(exception.MigrationError, + self.scheduler.driver._live_migration_dest_check, + self.context, i_ref, 'somewhere') - self.assertTrue(c) db.instance_destroy(self.context, instance_id) db.service_destroy(self.context, s_ref['id']) From 732a237fdc365a3dc3e5aaebf385235fd5e006be Mon Sep 17 00:00:00 2001 From: Ken Pepple Date: Wed, 27 Apr 2011 20:33:55 -0700 Subject: [PATCH 17/29] added nova version output to usage printout for nova-manage --- bin/nova-manage | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bin/nova-manage b/bin/nova-manage index c8230670..898255fb 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -82,6 +82,7 @@ from nova import log as logging from nova import quota from nova import rpc from nova import utils +from nova import version from nova.api.ec2 import ec2utils from nova.auth import manager from nova.cloudpipe import pipelib @@ -1091,6 +1092,8 @@ def main(): script_name = argv.pop(0) if len(argv) < 1: + print _("\nOpenStack Nova version: %s (%s)\n") %\ + (version.version_string(), version.version_string_with_vcs()) print script_name + " category action []" print _("Available categories:") for k, _v in CATEGORIES: From f6ac541ad798e2c61acb2fee1d754be1cf3a15fe Mon Sep 17 00:00:00 2001 From: Ken Pepple Date: Thu, 28 Apr 2011 10:26:43 -0700 Subject: [PATCH 18/29] added version list command to nova-manage --- bin/nova-manage | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/bin/nova-manage b/bin/nova-manage index 898255fb..ad2960d1 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -759,6 +759,16 @@ class DbCommands(object): print migration.db_version() +class VersionCommands(object): + """Class for managing the database.""" + + def __init__(self): + pass + + def list(self): + print _("%s (%s)") %\ + (version.version_string(), version.version_string_with_vcs()) + class VolumeCommands(object): """Methods for dealing with a cloud in an odd state""" @@ -1050,7 +1060,8 @@ CATEGORIES = [ ('volume', VolumeCommands), ('instance_type', InstanceTypeCommands), ('image', ImageCommands), - ('flavor', InstanceTypeCommands)] + ('flavor', InstanceTypeCommands), + ('version', VersionCommands)] def lazy_match(name, key_value_tuples): From 0927299ac1301699c2915b48bb076d1eac7b84a1 Mon Sep 17 00:00:00 2001 From: Ken Pepple Date: Thu, 28 Apr 2011 12:49:07 -0700 Subject: [PATCH 19/29] fixed docstring per jsb --- bin/nova-manage | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/nova-manage b/bin/nova-manage index ad2960d1..d2d81e5a 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -760,7 +760,7 @@ class DbCommands(object): class VersionCommands(object): - """Class for managing the database.""" + """Class for exposing the codebase version.""" def __init__(self): pass From d97c349cbd0b15e3c86650943f07b06f13ca704f Mon Sep 17 00:00:00 2001 From: Ken Pepple Date: Thu, 28 Apr 2011 12:49:48 -0700 Subject: [PATCH 20/29] pep8 --- bin/nova-manage | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/nova-manage b/bin/nova-manage index d2d81e5a..8122e674 100755 --- a/bin/nova-manage +++ b/bin/nova-manage @@ -769,6 +769,7 @@ class VersionCommands(object): print _("%s (%s)") %\ (version.version_string(), version.version_string_with_vcs()) + class VolumeCommands(object): """Methods for dealing with a cloud in an odd state""" From 1ac621a37910cd83536e0839d7a74ecca0ad5ccc Mon Sep 17 00:00:00 2001 From: Yuriy Taraday Date: Fri, 29 Apr 2011 13:20:31 +0400 Subject: [PATCH 21/29] Changed test_cloud and fake virt driver to show out the fix. --- 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 c45bdd12..f271c03f 100644 --- a/nova/tests/test_cloud.py +++ b/nova/tests/test_cloud.py @@ -290,7 +290,7 @@ class CloudTestCase(test.TestCase): instance_id = rv['instancesSet'][0]['instanceId'] output = self.cloud.get_console_output(context=self.context, instance_id=[instance_id]) - self.assertEquals(b64decode(output['output']), 'FAKE CONSOLE OUTPUT') + self.assertEquals(b64decode(output['output']), 'FAKE CONSOLE?OUTPUT') # TODO(soren): We need this until we can stop polling in the rpc code # for unit tests. greenthread.sleep(0.3) From cb694435080f83e6dd223c69cbe39586c6901559 Mon Sep 17 00:00:00 2001 From: Eldar Nugaev Date: Sun, 1 May 2011 01:01:01 -0700 Subject: [PATCH 22/29] Added checking ip_v6 flag and test for it --- nova/tests/test_virt.py | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/nova/tests/test_virt.py b/nova/tests/test_virt.py index 462cf5aa..b8a2b5c7 100644 --- a/nova/tests/test_virt.py +++ b/nova/tests/test_virt.py @@ -44,7 +44,7 @@ def _concurrency(wait, done, target): done.send() -def _create_network_info(count=1): +def _create_network_info(count=1, ipv6=True): fake = 'fake' fake_ip = '0.0.0.0/0' fake_ip_2 = '0.0.0.1/0' @@ -55,8 +55,11 @@ def _create_network_info(count=1): 'cidr': fake_ip, 'cidr_v6': fake_ip} mapping = {'mac': fake, - 'ips': [{'ip': fake_ip}, {'ip': fake_ip}], - 'ip6s': [{'ip': fake_ip}, {'ip': fake_ip_2}, {'ip': fake_ip_3}]} + '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)] @@ -825,12 +828,20 @@ class IptablesFirewallTestCase(test.TestCase): "TCP port 80/81 acceptance rule wasn't added") db.instance_destroy(admin_ctxt, instance_ref['id']) - def test_filters_for_instance(self): - network_info = _create_network_info() + def test_filters_for_instance_with_ip_v6(self): + self.flags(use_ipv6=True) + network_info = _create_network_info(ipv6=FLAGS.use_ipv6) 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(ipv6=FLAGS.use_ipv6) + rulesv4, rulesv6 = self.fw._filters_for_instance("fake", network_info) + self.assertEquals(len(rulesv4), 2) + self.assertEquals(len(rulesv6), 0) + def multinic_iptables_test(self): ipv4_rules_per_network = 2 ipv6_rules_per_network = 3 From e7071f190d51759f71d2ca156f2d63f1e9ae0ed1 Mon Sep 17 00:00:00 2001 From: Eldar Nugaev Date: Sun, 1 May 2011 20:43:06 -0700 Subject: [PATCH 23/29] small changes in libvirt tests --- nova/tests/test_virt.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/nova/tests/test_virt.py b/nova/tests/test_virt.py index b8a2b5c7..47432bae 100644 --- a/nova/tests/test_virt.py +++ b/nova/tests/test_virt.py @@ -44,7 +44,9 @@ def _concurrency(wait, done, target): done.send() -def _create_network_info(count=1, ipv6=True): +def _create_network_info(count=1, ipv6=None): + if ipv6 is None: + ipv6 = FLAGS.use_ipv6 fake = 'fake' fake_ip = '0.0.0.0/0' fake_ip_2 = '0.0.0.1/0' @@ -830,14 +832,14 @@ class IptablesFirewallTestCase(test.TestCase): def test_filters_for_instance_with_ip_v6(self): self.flags(use_ipv6=True) - network_info = _create_network_info(ipv6=FLAGS.use_ipv6) + network_info = _create_network_info() 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(ipv6=FLAGS.use_ipv6) + network_info = _create_network_info() rulesv4, rulesv6 = self.fw._filters_for_instance("fake", network_info) self.assertEquals(len(rulesv4), 2) self.assertEquals(len(rulesv6), 0) From b9d6d497aac62c3aeeab58bbaf2e2002177c9b72 Mon Sep 17 00:00:00 2001 From: Dan Prince Date: Mon, 2 May 2011 10:17:51 -0400 Subject: [PATCH 24/29] Use my_ip for libvirt version of get_host_ip_addr. --- nova/tests/test_virt.py | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/nova/tests/test_virt.py b/nova/tests/test_virt.py index 462cf5aa..9305de4c 100644 --- a/nova/tests/test_virt.py +++ b/nova/tests/test_virt.py @@ -641,6 +641,11 @@ class LibvirtConnTestCase(test.TestCase): self.assertTrue(count) + def test_get_host_ip_addr(self): + conn = libvirt_conn.LibvirtConnection(False) + ip = conn.get_host_ip_addr() + self.assertEquals(ip, FLAGS.my_ip) + def tearDown(self): self.manager.delete_project(self.project) self.manager.delete_user(self.user) From 324f2cf4b9b9122b5aa969c3746faf4869b9a066 Mon Sep 17 00:00:00 2001 From: Yuriy Taraday Date: Tue, 3 May 2011 11:05:45 +0400 Subject: [PATCH 25/29] Moved reencoding logic to compute manager and cloud EC2 API. --- nova/tests/test_cloud.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/nova/tests/test_cloud.py b/nova/tests/test_cloud.py index f271c03f..311adfd5 100644 --- a/nova/tests/test_cloud.py +++ b/nova/tests/test_cloud.py @@ -290,7 +290,8 @@ class CloudTestCase(test.TestCase): instance_id = rv['instancesSet'][0]['instanceId'] output = self.cloud.get_console_output(context=self.context, instance_id=[instance_id]) - self.assertEquals(b64decode(output['output']), 'FAKE CONSOLE?OUTPUT') + self.assertEquals(b64decode(output['output']).decode('utf-8'), + u'FAKE CONSOLE\ufffdOUTPUT') # TODO(soren): We need this until we can stop polling in the rpc code # for unit tests. greenthread.sleep(0.3) From a99caae5352e6da81b2854eeefad97e95e216873 Mon Sep 17 00:00:00 2001 From: Soren Hansen Date: Wed, 4 May 2011 23:09:06 +0200 Subject: [PATCH 26/29] It's ok if there's no commit history. Otherwise the test suite in the tarball will fail. --- nova/tests/test_misc.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nova/tests/test_misc.py b/nova/tests/test_misc.py index ad62b48b..cf8f4c05 100644 --- a/nova/tests/test_misc.py +++ b/nova/tests/test_misc.py @@ -68,7 +68,7 @@ class ProjectTestCase(test.TestCase): contributors.add(str_dict_replace(email, mailmap)) else: - self.assertTrue(False, 'Cannot read commit history') + return for contributor in contributors: if contributor == 'nova-core': From e45823d51b53e92a7195f69bbb156b77483fd932 Mon Sep 17 00:00:00 2001 From: Yuriy Taraday Date: Thu, 5 May 2011 07:50:58 +0400 Subject: [PATCH 27/29] Moved all reencoding to compute manager to satisfy both Direct API and internal cloud call. --- nova/tests/test_cloud.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/nova/tests/test_cloud.py b/nova/tests/test_cloud.py index 311adfd5..f271c03f 100644 --- a/nova/tests/test_cloud.py +++ b/nova/tests/test_cloud.py @@ -290,8 +290,7 @@ class CloudTestCase(test.TestCase): instance_id = rv['instancesSet'][0]['instanceId'] output = self.cloud.get_console_output(context=self.context, instance_id=[instance_id]) - self.assertEquals(b64decode(output['output']).decode('utf-8'), - u'FAKE CONSOLE\ufffdOUTPUT') + self.assertEquals(b64decode(output['output']), 'FAKE CONSOLE?OUTPUT') # TODO(soren): We need this until we can stop polling in the rpc code # for unit tests. greenthread.sleep(0.3) From 09e06a341f7deb04c0d6997eef9bd2d16d1e801d Mon Sep 17 00:00:00 2001 From: William Wolf Date: Thu, 5 May 2011 15:38:45 -0400 Subject: [PATCH 28/29] added self to authors --- Authors | 1 + 1 file changed, 1 insertion(+) diff --git a/Authors b/Authors index 1cdeeff9..8adcde4d 100644 --- a/Authors +++ b/Authors @@ -78,6 +78,7 @@ Trey Morris Tushar Patil Vasiliy Shlykov Vishvananda Ishaya +William Wolf Yoshiaki Tamura Youcef Laribi Zhixue Wu From f8d1ccd787b96b60ad887fbf8696258924b773fe Mon Sep 17 00:00:00 2001 From: Yuriy Taraday Date: Fri, 6 May 2011 06:50:48 +0400 Subject: [PATCH 29/29] Added myself to Authors file. --- Authors | 1 + 1 file changed, 1 insertion(+) diff --git a/Authors b/Authors index 1cdeeff9..8a1571a0 100644 --- a/Authors +++ b/Authors @@ -80,4 +80,5 @@ Vasiliy Shlykov Vishvananda Ishaya Yoshiaki Tamura Youcef Laribi +Yuriy Taraday Zhixue Wu