summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorEric Day <eday@oddments.org>2010-12-02 08:47:25 -0800
committerEric Day <eday@oddments.org>2010-12-02 08:47:25 -0800
commit1bcc4da8bbcfdfee8f5eed80e9115d51803f86e2 (patch)
treea54a08c909df2bc63beb741e3f48e69ba94d83c8 /nova/api
parent6956057ac490c788cb94fbfd0af7fe6e91a7ca96 (diff)
parentf8afbcc08b65d4d6764a6dc66c804816573ab3b4 (diff)
downloadnova-1bcc4da8bbcfdfee8f5eed80e9115d51803f86e2.tar.gz
nova-1bcc4da8bbcfdfee8f5eed80e9115d51803f86e2.tar.xz
nova-1bcc4da8bbcfdfee8f5eed80e9115d51803f86e2.zip
Merged trunk and resolved conflicts.
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/ec2/cloud.py7
-rw-r--r--nova/api/openstack/auth.py22
-rw-r--r--nova/api/openstack/faults.py2
-rw-r--r--nova/api/openstack/servers.py4
4 files changed, 19 insertions, 16 deletions
diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py
index 6c0917500..e50906ae1 100644
--- a/nova/api/ec2/cloud.py
+++ b/nova/api/ec2/cloud.py
@@ -877,8 +877,11 @@ class CloudController(object):
return True
def describe_images(self, context, image_id=None, **kwargs):
- imageSet = self.image_service.index(context, image_id)
- return {'imagesSet': imageSet}
+ # Note: image_id is a list!
+ images = self.image_service.index(context)
+ if image_id:
+ images = filter(lambda x: x['imageId'] in image_id, images)
+ return {'imagesSet': images}
def deregister_image(self, context, image_id, **kwargs):
self.image_service.deregister(context, image_id)
diff --git a/nova/api/openstack/auth.py b/nova/api/openstack/auth.py
index ff428ff70..205035915 100644
--- a/nova/api/openstack/auth.py
+++ b/nova/api/openstack/auth.py
@@ -23,10 +23,7 @@ class Context(object):
class BasicApiAuthManager(object):
""" Implements a somewhat rudimentary version of OpenStack Auth"""
- def __init__(self, host=None, db_driver=None):
- if not host:
- host = FLAGS.host
- self.host = host
+ def __init__(self, db_driver=None):
if not db_driver:
db_driver = FLAGS.db_driver
self.db = utils.import_object(db_driver)
@@ -47,7 +44,7 @@ class BasicApiAuthManager(object):
except KeyError:
return faults.Fault(webob.exc.HTTPUnauthorized())
- token, user = self._authorize_user(username, key)
+ token, user = self._authorize_user(username, key, req)
if user and token:
res = webob.Response()
res.headers['X-Auth-Token'] = token.token_hash
@@ -82,8 +79,13 @@ class BasicApiAuthManager(object):
return {'id': user.id}
return None
- def _authorize_user(self, username, key):
- """ Generates a new token and assigns it to a user """
+ def _authorize_user(self, username, key, req):
+ """Generates a new token and assigns it to a user.
+
+ username - string
+ key - string API key
+ req - webob.Request object
+ """
user = self.auth.get_user_from_access_key(key)
if user and user.name == username:
token_hash = hashlib.sha1('%s%s%f' % (username, key,
@@ -91,12 +93,10 @@ class BasicApiAuthManager(object):
token_dict = {}
token_dict['token_hash'] = token_hash
token_dict['cdn_management_url'] = ''
- token_dict['server_management_url'] = self._get_server_mgmt_url()
+ # Same as auth url, e.g. http://foo.org:8774/baz/v1.0
+ token_dict['server_management_url'] = req.url
token_dict['storage_url'] = ''
token_dict['user_id'] = user.id
token = self.db.auth_create_token(self.context, token_dict)
return token, user
return None, None
-
- def _get_server_mgmt_url(self):
- return 'https://%s/v1.0/' % self.host
diff --git a/nova/api/openstack/faults.py b/nova/api/openstack/faults.py
index e69e51439..224a7ef0b 100644
--- a/nova/api/openstack/faults.py
+++ b/nova/api/openstack/faults.py
@@ -47,7 +47,7 @@ class Fault(webob.exc.HTTPException):
"""Generate a WSGI response based on the exception passed to ctor."""
# Replace the body with fault details.
code = self.wrapped_exc.status_int
- fault_name = self._fault_names.get(code, "cloudServersFault")
+ fault_name = self._fault_names.get(code, "computeFault")
fault_data = {
fault_name: {
'code': code,
diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py
index 8242c5b44..11170bbf5 100644
--- a/nova/api/openstack/servers.py
+++ b/nova/api/openstack/servers.py
@@ -64,7 +64,7 @@ def _entity_detail(inst):
inst_dict = {}
mapped_keys = dict(status='state', imageId='image_id',
- flavorId='instance_type', name='server_name', id='id')
+ flavorId='instance_type', name='display_name', id='id')
for k, v in mapped_keys.iteritems():
inst_dict[k] = inst[v]
@@ -79,7 +79,7 @@ def _entity_detail(inst):
def _entity_inst(inst):
""" Filters all model attributes save for id and name """
- return dict(server=dict(id=inst['id'], name=inst['server_name']))
+ return dict(server=dict(id=inst['id'], name=inst['display_name']))
class Controller(wsgi.Controller):