summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorDan Prince <dan.prince@rackspace.com>2011-09-13 15:59:45 -0400
committerDan Prince <dan.prince@rackspace.com>2011-09-13 15:59:45 -0400
commitc4e4911bc90b37afc498f05f88f1128cbeff80e0 (patch)
treeb9190e9597472b718d6b6bf4c6c35b1dfb4224ff /nova/api
parent9b12a6c5ec11fd6ef3e110e6f0574762060ac809 (diff)
parent9f39ff070b5500a0ccb9a6454995f97342254381 (diff)
downloadnova-c4e4911bc90b37afc498f05f88f1128cbeff80e0.tar.gz
nova-c4e4911bc90b37afc498f05f88f1128cbeff80e0.tar.xz
nova-c4e4911bc90b37afc498f05f88f1128cbeff80e0.zip
Merge with trunk. Still one test failure in test_images.
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/auth.py1
-rw-r--r--nova/api/ec2/cloud.py4
-rw-r--r--nova/api/openstack/contrib/floating_ips.py4
-rw-r--r--nova/api/openstack/create_instance_helper.py5
-rw-r--r--nova/api/openstack/schemas/v1.1/server.rng2
-rw-r--r--nova/api/openstack/servers.py9
-rw-r--r--nova/api/openstack/views/addresses.py1
-rw-r--r--nova/api/openstack/views/images.py15
-rw-r--r--nova/api/openstack/views/servers.py9
9 files changed, 28 insertions, 22 deletions
diff --git a/nova/api/auth.py b/nova/api/auth.py
index cd0d38b3f..f73cae01e 100644
--- a/nova/api/auth.py
+++ b/nova/api/auth.py
@@ -70,6 +70,7 @@ class KeystoneContext(wsgi.Middleware):
project_id,
roles=roles,
auth_token=auth_token,
+ strategy='keystone',
remote_address=remote_address)
req.environ['nova.context'] = ctx
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/api/openstack/contrib/floating_ips.py b/nova/api/openstack/contrib/floating_ips.py
index d1add8f83..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 'fixed_ip' in floating_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 'fixed_ip' in floating_ip:
+ if floating_ip.get('fixed_ip'):
self.network_api.disassociate_floating_ip(context, address)
return webob.Response(status_int=202)
diff --git a/nova/api/openstack/create_instance_helper.py b/nova/api/openstack/create_instance_helper.py
index 29e071609..e27ddf78b 100644
--- a/nova/api/openstack/create_instance_helper.py
+++ b/nova/api/openstack/create_instance_helper.py
@@ -92,7 +92,8 @@ class CreateInstanceHelper(object):
if str(image_href).startswith(req.application_url):
image_href = image_href.split('/').pop()
try:
- image_service, image_id = nova.image.get_image_service(image_href)
+ image_service, image_id = nova.image.get_image_service(context,
+ image_href)
kernel_id, ramdisk_id = self._get_kernel_ramdisk_from_image(
req, image_service, image_id)
images = set([str(x['id']) for x in image_service.index(context)])
@@ -282,7 +283,7 @@ class CreateInstanceHelper(object):
try:
ramdisk_id = image_meta['properties']['ramdisk_id']
except KeyError:
- raise exception.RamdiskNotFoundForImage(image_id=image_id)
+ ramdisk_id = None
return kernel_id, ramdisk_id
diff --git a/nova/api/openstack/schemas/v1.1/server.rng b/nova/api/openstack/schemas/v1.1/server.rng
index dbd169a83..ef835e408 100644
--- a/nova/api/openstack/schemas/v1.1/server.rng
+++ b/nova/api/openstack/schemas/v1.1/server.rng
@@ -1,6 +1,8 @@
<element name="server" ns="http://docs.openstack.org/compute/api/v1.1"
xmlns="http://relaxng.org/ns/structure/1.0">
<attribute name="name"> <text/> </attribute>
+ <attribute name="userId"> <text/> </attribute>
+ <attribute name="tenantId"> <text/> </attribute>
<attribute name="id"> <text/> </attribute>
<attribute name="uuid"> <text/> </attribute>
<attribute name="updated"> <text/> </attribute>
diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py
index acd2209af..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()
@@ -873,6 +872,8 @@ class ServerXMLSerializer(wsgi.XMLDictSerializer):
def _add_server_attributes(self, node, server):
node.setAttribute('id', str(server['id']))
+ node.setAttribute('userId', str(server['user_id']))
+ node.setAttribute('tenantId', str(server['tenant_id']))
node.setAttribute('uuid', str(server['uuid']))
node.setAttribute('hostId', str(server['hostId']))
node.setAttribute('name', server['name'])
@@ -1009,7 +1010,7 @@ def create_resource(version='1.0'):
"attributes": {
"server": ["id", "imageId", "name", "flavorId", "hostId",
"status", "progress", "adminPass", "flavorRef",
- "imageRef"],
+ "imageRef", "userId", "tenantId"],
"link": ["rel", "type", "href"],
},
"dict_collections": {
diff --git a/nova/api/openstack/views/addresses.py b/nova/api/openstack/views/addresses.py
index 8f07a2289..8d38bc9c3 100644
--- a/nova/api/openstack/views/addresses.py
+++ b/nova/api/openstack/views/addresses.py
@@ -88,7 +88,6 @@ class ViewBuilderV11(ViewBuilder):
try:
return interface['network']['label']
except (TypeError, KeyError) as exc:
- LOG.exception(exc)
raise TypeError
def _extract_ipv4_addresses(self, interface):
diff --git a/nova/api/openstack/views/images.py b/nova/api/openstack/views/images.py
index 20c99124b..86e8d7f3a 100644
--- a/nova/api/openstack/views/images.py
+++ b/nova/api/openstack/views/images.py
@@ -37,17 +37,18 @@ class ViewBuilder(object):
def _format_status(self, image):
"""Update the status field to standardize format."""
status_mapping = {
- 'pending': 'QUEUED',
- 'decrypting': 'PREPARING',
- 'untarring': 'SAVING',
- 'available': 'ACTIVE',
- 'killed': 'FAILED',
+ 'active': 'ACTIVE',
+ 'queued': 'SAVING',
+ 'saving': 'SAVING',
+ 'deleted': 'DELETED',
+ 'pending_delete': 'DELETED',
+ 'killed': 'ERROR',
}
try:
- image['status'] = status_mapping[image['status']].upper()
+ image['status'] = status_mapping[image['status']]
except KeyError:
- image['status'] = image['status'].upper()
+ image['status'] = 'UNKNOWN'
def _build_server(self, image, image_obj):
"""Indicates that you must use a ViewBuilder subclass."""
diff --git a/nova/api/openstack/views/servers.py b/nova/api/openstack/views/servers.py
index 3a13d15f1..473dc9e7e 100644
--- a/nova/api/openstack/views/servers.py
+++ b/nova/api/openstack/views/servers.py
@@ -66,6 +66,8 @@ class ViewBuilder(object):
inst_dict = {
'id': inst['id'],
'name': inst['display_name'],
+ 'user_id': inst.get('user_id', ''),
+ 'tenant_id': inst.get('project_id', ''),
'status': common.status_from_state(vm_state, task_state)}
# Return the metadata as a dictionary
@@ -143,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
@@ -183,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"])
@@ -203,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,