summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEwan Mellor <ewan.mellor@citrix.com>2010-07-29 00:58:33 +0100
committerEwan Mellor <ewan.mellor@citrix.com>2010-07-29 00:58:33 +0100
commit04a6a0267e7dc0f4e587e43f23b4acf0dcef52fc (patch)
tree6bcdfafed1cb2332ebd8b7c0d03b4fed4a82520e
parent9f4996e8738991a95a23cba2caa660f7002f94cd (diff)
downloadnova-04a6a0267e7dc0f4e587e43f23b4acf0dcef52fc.tar.gz
nova-04a6a0267e7dc0f4e587e43f23b4acf0dcef52fc.tar.xz
nova-04a6a0267e7dc0f4e587e43f23b4acf0dcef52fc.zip
More merges from trunk. Not everything came over the first time.
-rw-r--r--nova/auth/ldapdriver.py7
-rw-r--r--nova/auth/manager.py6
-rw-r--r--nova/compute/linux_net.py7
-rw-r--r--nova/datastore.py2
-rwxr-xr-xnova/endpoint/api.py2
-rw-r--r--nova/endpoint/cloud.py8
-rw-r--r--nova/objectstore/handler.py10
-rw-r--r--nova/process.py13
-rw-r--r--nova/tests/auth_unittest.py6
-rw-r--r--nova/tests/process_unittest.py7
-rw-r--r--setup.py2
11 files changed, 39 insertions, 31 deletions
diff --git a/nova/auth/ldapdriver.py b/nova/auth/ldapdriver.py
index 1591c88e9..055e8332b 100644
--- a/nova/auth/ldapdriver.py
+++ b/nova/auth/ldapdriver.py
@@ -120,10 +120,13 @@ class LdapDriver(object):
'(objectclass=novaKeyPair)')
return [self.__to_key_pair(uid, attr) for attr in attrs]
- def get_projects(self):
+ def get_projects(self, uid=None):
"""Retrieve list of projects"""
+ filter = '(objectclass=novaProject)'
+ if uid:
+ filter = "(&%s(member=%s))" % (filter, self.__uid_to_dn(uid))
attrs = self.__find_objects(FLAGS.ldap_project_subtree,
- '(objectclass=novaProject)')
+ filter)
return [self.__to_project(attr) for attr in attrs]
def create_user(self, name, access_key, secret_key, is_admin):
diff --git a/nova/auth/manager.py b/nova/auth/manager.py
index 66027f6c2..7307f673b 100644
--- a/nova/auth/manager.py
+++ b/nova/auth/manager.py
@@ -547,10 +547,10 @@ class AuthManager(object):
if project_dict:
return Project(**project_dict)
- def get_projects(self):
- """Retrieves list of all projects"""
+ def get_projects(self, user=None):
+ """Retrieves list of projects, optionally filtered by user"""
with self.driver() as drv:
- project_list = drv.get_projects()
+ project_list = drv.get_projects(User.safe_id(user))
if not project_list:
return []
return [Project(**project_dict) for project_dict in project_list]
diff --git a/nova/compute/linux_net.py b/nova/compute/linux_net.py
index 861ce779b..4a4b4c8a8 100644
--- a/nova/compute/linux_net.py
+++ b/nova/compute/linux_net.py
@@ -94,7 +94,7 @@ def bridge_create(net):
execute("sudo ifconfig %s up" % net['bridge_name'])
def dnsmasq_cmd(net):
- cmd = ['sudo dnsmasq',
+ cmd = ['sudo -E dnsmasq',
' --strict-order',
' --bind-interfaces',
' --conf-file=',
@@ -143,8 +143,9 @@ def start_dnsmasq(network):
if os.path.exists(lease_file):
os.unlink(lease_file)
- # FLAGFILE in env
- env = {'FLAGFILE' : FLAGS.dhcpbridge_flagfile}
+ # FLAGFILE and DNSMASQ_INTERFACE in env
+ env = {'FLAGFILE': FLAGS.dhcpbridge_flagfile,
+ 'DNSMASQ_INTERFACE': network['bridge_name']}
execute(dnsmasq_cmd(network), addl_env=env)
def stop_dnsmasq(network):
diff --git a/nova/datastore.py b/nova/datastore.py
index 660ad9d90..9c2592334 100644
--- a/nova/datastore.py
+++ b/nova/datastore.py
@@ -103,7 +103,7 @@ class BasicModel(object):
@classmethod
def _redis_name(cls):
- return cls.override_type or cls.__name__
+ return cls.override_type or cls.__name__.lower()
@classmethod
def lookup(cls, identifier):
diff --git a/nova/endpoint/api.py b/nova/endpoint/api.py
index 8915e4742..78a18b9ea 100755
--- a/nova/endpoint/api.py
+++ b/nova/endpoint/api.py
@@ -266,7 +266,7 @@ class APIRequestHandler(tornado.web.RequestHandler):
# Authenticate the request.
try:
- (user, project) = users.UserManager.instance().authenticate(
+ (user, project) = manager.AuthManager().authenticate(
access,
signature,
auth_params,
diff --git a/nova/endpoint/cloud.py b/nova/endpoint/cloud.py
index 21581ffd2..8a4edbc0b 100644
--- a/nova/endpoint/cloud.py
+++ b/nova/endpoint/cloud.py
@@ -516,8 +516,12 @@ class CloudController(object):
# get defaults from imagestore
image_id = image['imageId']
- kernel_id = image.get('kernelId', None)
- ramdisk_id = image.get('ramdiskId', None)
+ kernel_id = image.get('kernelId', FLAGS.default_kernel)
+ ramdisk_id = image.get('ramdiskId', FLAGS.default_ramdisk)
+
+ # make sure we have access to kernel and ramdisk
+ self._get_image(context, kernel_id)
+ self._get_image(context, ramdisk_id)
# API parameters overrides of defaults
kernel_id = kwargs.get('kernel_id', kernel_id)
diff --git a/nova/objectstore/handler.py b/nova/objectstore/handler.py
index 344d75f6b..b4d7e6179 100644
--- a/nova/objectstore/handler.py
+++ b/nova/objectstore/handler.py
@@ -297,12 +297,12 @@ class ImagesResource(Resource):
def render_POST(self, request):
""" update image attributes: public/private """
- image_id = self.get_argument('image_id', u'')
- operation = self.get_argument('operation', u'')
+ image_id = get_argument(request, 'image_id', u'')
+ operation = get_argument(request, 'operation', u'')
image_object = image.Image(image_id)
- if not image.is_authorized(request.context):
+ if not image_object.is_authorized(request.context):
raise exception.NotAuthorized
image_object.set_public(operation=='add')
@@ -311,10 +311,10 @@ class ImagesResource(Resource):
def render_DELETE(self, request):
""" delete a registered image """
- image_id = self.get_argument("image_id", u"")
+ image_id = get_argument(request, "image_id", u"")
image_object = image.Image(image_id)
- if not image.is_authorized(request.context):
+ if not image_object.is_authorized(request.context):
raise exception.NotAuthorized
image_object.delete()
diff --git a/nova/process.py b/nova/process.py
index 8ecef1584..d3558ed2e 100644
--- a/nova/process.py
+++ b/nova/process.py
@@ -205,12 +205,13 @@ class ProcessPool(object):
self._pool.release()
return rv
-_instance = None
-def SharedPool():
- global _instance
- if _instance is None:
- _instance = ProcessPool()
- return _instance
+class SharedPool(ProcessPool):
+ _instance = None
+ def __new__(cls, *args, **kwargs):
+ if not cls._instance:
+ cls._instance = super(SharedPool, cls).__new__(
+ cls, *args, **kwargs)
+ return cls._instance
def simple_execute(cmd, **kwargs):
return SharedPool().simple_execute(cmd, **kwargs)
diff --git a/nova/tests/auth_unittest.py b/nova/tests/auth_unittest.py
index 073ff71d2..2167c2385 100644
--- a/nova/tests/auth_unittest.py
+++ b/nova/tests/auth_unittest.py
@@ -193,9 +193,15 @@ class AuthTestCase(test.BaseTestCase):
for vpn in vpns:
vpn.destroy()
+ def test_214_can_retrieve_project_by_user(self):
+ project = self.manager.create_project('testproj2', 'test2', 'Another test project', ['test2'])
+ self.assert_(len(self.manager.get_projects()) > 1)
+ self.assertEqual(len(self.manager.get_projects('test2')), 1)
+
def test_299_can_delete_project(self):
self.manager.delete_project('testproj')
self.assertFalse(filter(lambda p: p.name == 'testproj', self.manager.get_projects()))
+ self.manager.delete_project('testproj2')
def test_999_can_delete_users(self):
self.manager.delete_user('test1')
diff --git a/nova/tests/process_unittest.py b/nova/tests/process_unittest.py
index c96bb5913..1c15b69a0 100644
--- a/nova/tests/process_unittest.py
+++ b/nova/tests/process_unittest.py
@@ -120,10 +120,3 @@ class ProcessTestCase(test.TrialTestCase):
pool2 = process.SharedPool()
self.assert_(id(pool1) == id(pool2))
- def test_shared_pool_works_as_singleton(self):
- d1 = process.simple_execute('sleep 1')
- d2 = process.simple_execute('sleep 0.005')
- # lp609749: would have failed with
- # exceptions.AssertionError: Someone released me too many times:
- # too many tokens!
- return d1
diff --git a/setup.py b/setup.py
index 127d014b1..50d5f2a3d 100644
--- a/setup.py
+++ b/setup.py
@@ -19,7 +19,7 @@
from setuptools import setup, find_packages
setup(name='nova',
- version='0.9.0',
+ version='0.9.1',
description='cloud computing fabric controller',
author='OpenStack',
author_email='nova@lists.launchpad.net',