summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorAlex Meade <alex.meade@rackspace.com>2011-08-15 09:57:55 -0400
committerAlex Meade <alex.meade@rackspace.com>2011-08-15 09:57:55 -0400
commitfaa7239eea756bfd337a7d9c3e0ebb63cbbe58a2 (patch)
tree0490f073f346abaaaccc94eb627ab651c05bb845 /nova/api
parenta1dc7e0dbcff7130adb0274e6628ce30d1ac83c1 (diff)
parent1fe628fbe1f9964ac4536ce1c859d84d9cd8cb08 (diff)
downloadnova-faa7239eea756bfd337a7d9c3e0ebb63cbbe58a2.tar.gz
nova-faa7239eea756bfd337a7d9c3e0ebb63cbbe58a2.tar.xz
nova-faa7239eea756bfd337a7d9c3e0ebb63cbbe58a2.zip
merged trunk
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/ec2/__init__.py4
-rw-r--r--nova/api/openstack/create_instance_helper.py4
-rw-r--r--nova/api/openstack/servers.py29
3 files changed, 25 insertions, 12 deletions
diff --git a/nova/api/ec2/__init__.py b/nova/api/ec2/__init__.py
index 8b6e47cfb..96df97393 100644
--- a/nova/api/ec2/__init__.py
+++ b/nova/api/ec2/__init__.py
@@ -358,6 +358,10 @@ class Executor(wsgi.Application):
LOG.debug(_('InvalidParameterValue raised: %s'), unicode(ex),
context=context)
return self._error(req, context, type(ex).__name__, unicode(ex))
+ except exception.InvalidPortRange as ex:
+ LOG.debug(_('InvalidPortRange raised: %s'), unicode(ex),
+ context=context)
+ return self._error(req, context, type(ex).__name__, unicode(ex))
except Exception as ex:
extra = {'environment': req.environ}
LOG.exception(_('Unexpected error raised: %s'), unicode(ex),
diff --git a/nova/api/openstack/create_instance_helper.py b/nova/api/openstack/create_instance_helper.py
index 1425521a9..4e1da549e 100644
--- a/nova/api/openstack/create_instance_helper.py
+++ b/nova/api/openstack/create_instance_helper.py
@@ -122,6 +122,7 @@ class CreateInstanceHelper(object):
raise exc.HTTPBadRequest(explanation=msg)
zone_blob = server_dict.get('blob')
+ availability_zone = server_dict.get('availability_zone')
name = server_dict['name']
self._validate_server_name(name)
name = name.strip()
@@ -161,7 +162,8 @@ class CreateInstanceHelper(object):
zone_blob=zone_blob,
reservation_id=reservation_id,
min_count=min_count,
- max_count=max_count))
+ max_count=max_count,
+ availability_zone=availability_zone))
except quota.QuotaError as error:
self._handle_quota_error(error)
except exception.ImageNotFound as error:
diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py
index fec319d8e..49903d503 100644
--- a/nova/api/openstack/servers.py
+++ b/nova/api/openstack/servers.py
@@ -163,7 +163,7 @@ class Controller(object):
@scheduler_api.redirect_handler
def update(self, req, id, body):
- """ Updates the server name or password """
+ """Update server name then pass on to version-specific controller"""
if len(req.body) == 0:
raise exc.HTTPUnprocessableEntity()
@@ -178,17 +178,15 @@ class Controller(object):
self.helper._validate_server_name(name)
update_dict['display_name'] = name.strip()
- self._parse_update(ctxt, id, body, update_dict)
-
try:
self.compute_api.update(ctxt, id, **update_dict)
except exception.NotFound:
raise exc.HTTPNotFound()
- return exc.HTTPNoContent()
+ return self._update(ctxt, req, id, body)
- def _parse_update(self, context, id, inst_dict, update_dict):
- pass
+ def _update(self, context, req, id, inst_dict):
+ return exc.HTTPNotImplemented()
@scheduler_api.redirect_handler
def action(self, req, id, body):
@@ -210,11 +208,15 @@ class Controller(object):
}
self.actions.update(admin_actions)
- for key in self.actions.keys():
- if key in body:
+ for key in body:
+ if key in self.actions:
return self.actions[key](body, req, id)
+ else:
+ msg = _("There is no such server action: %s") % (key,)
+ raise exc.HTTPBadRequest(explanation=msg)
- raise exc.HTTPNotImplemented()
+ msg = _("Invalid request body")
+ raise exc.HTTPBadRequest(explanation=msg)
def _action_create_backup(self, input_dict, req, instance_id):
"""Backup a server instance.
@@ -568,10 +570,11 @@ class ControllerV10(Controller):
def _limit_items(self, items, req):
return common.limited(items, req)
- def _parse_update(self, context, server_id, inst_dict, update_dict):
+ def _update(self, context, req, id, inst_dict):
if 'adminPass' in inst_dict['server']:
- self.compute_api.set_admin_password(context, server_id,
+ self.compute_api.set_admin_password(context, id,
inst_dict['server']['adminPass'])
+ return exc.HTTPNoContent()
def _action_resize(self, input_dict, req, id):
""" Resizes a given instance to the flavor size requested """
@@ -695,6 +698,10 @@ class ControllerV11(Controller):
LOG.info(msg)
raise exc.HTTPBadRequest(explanation=msg)
+ def _update(self, context, req, id, inst_dict):
+ instance = self.compute_api.routing_get(context, id)
+ return self._build_view(req, instance, is_detail=True)
+
def _action_resize(self, input_dict, req, id):
""" Resizes a given instance to the flavor size requested """
try: