diff options
| author | William Wolf <throughnothing@gmail.com> | 2011-08-02 10:01:17 -0400 |
|---|---|---|
| committer | William Wolf <throughnothing@gmail.com> | 2011-08-02 10:01:17 -0400 |
| commit | 3e6c9ddd98126d8152d9965b57cc84bdbdfaa8c7 (patch) | |
| tree | a5a80fa1b098c08fc0cbcbfcb192c285d426f2bb /nova/api | |
| parent | 324c95415fcd66265da62ff6280d4e7e6a4434f1 (diff) | |
| parent | 83066aa64ccba34e23063eee661375b11de2161f (diff) | |
| download | nova-3e6c9ddd98126d8152d9965b57cc84bdbdfaa8c7.tar.gz nova-3e6c9ddd98126d8152d9965b57cc84bdbdfaa8c7.tar.xz nova-3e6c9ddd98126d8152d9965b57cc84bdbdfaa8c7.zip | |
merge from trunk
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/openstack/contrib/floating_ips.py | 4 | ||||
| -rw-r--r-- | nova/api/openstack/servers.py | 40 |
2 files changed, 22 insertions, 22 deletions
diff --git a/nova/api/openstack/contrib/floating_ips.py b/nova/api/openstack/contrib/floating_ips.py index b4a211857..3d8049324 100644 --- a/nova/api/openstack/contrib/floating_ips.py +++ b/nova/api/openstack/contrib/floating_ips.py @@ -27,9 +27,9 @@ from nova.api.openstack import extensions def _translate_floating_ip_view(floating_ip): result = {'id': floating_ip['id'], 'ip': floating_ip['address']} - if 'fixed_ip' in floating_ip: + try: result['fixed_ip'] = floating_ip['fixed_ip']['address'] - else: + except (TypeError, KeyError): result['fixed_ip'] = None if 'instance' in floating_ip: result['instance_id'] = floating_ip['instance']['id'] diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index 30169d450..8d2ccc2ad 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -405,6 +405,24 @@ class Controller(object): error=item.error)) return dict(actions=actions) + def resize(self, req, instance_id, flavor_id): + """Begin the resize process with given instance/flavor.""" + context = req.environ["nova.context"] + + try: + self.compute_api.resize(context, instance_id, flavor_id) + except exception.FlavorNotFound: + msg = _("Unable to locate requested flavor.") + raise exc.HTTPBadRequest(explanation=msg) + except exception.CannotResizeToSameSize: + msg = _("Resize requires a change in size.") + raise exc.HTTPBadRequest(explanation=msg) + except exception.CannotResizeToSmallerSize: + msg = _("Resizing to a smaller size is not supported.") + raise exc.HTTPBadRequest(explanation=msg) + + return webob.Response(status_int=202) + class ControllerV10(Controller): @@ -444,16 +462,7 @@ class ControllerV10(Controller): msg = _("Resize requests require 'flavorId' attribute.") raise exc.HTTPBadRequest(explanation=msg) - try: - i_type = instance_types.get_instance_type_by_flavor_id(flavor_id) - except exception.FlavorNotFound: - msg = _("Unable to locate requested flavor.") - raise exc.HTTPBadRequest(explanation=msg) - - context = req.environ["nova.context"] - self.compute_api.resize(context, id, i_type["id"]) - - return webob.Response(status_int=202) + return self.resize(req, id, flavor_id) def _action_rebuild(self, info, request, instance_id): context = request.environ['nova.context'] @@ -568,16 +577,7 @@ class ControllerV11(Controller): msg = _("Resize requests require 'flavorRef' attribute.") raise exc.HTTPBadRequest(explanation=msg) - try: - i_type = instance_types.get_instance_type_by_flavor_id(flavor_ref) - except exception.FlavorNotFound: - msg = _("Unable to locate requested flavor.") - raise exc.HTTPBadRequest(explanation=msg) - - context = req.environ["nova.context"] - self.compute_api.resize(context, id, i_type["id"]) - - return webob.Response(status_int=202) + return self.resize(req, id, flavor_ref) def _action_rebuild(self, info, request, instance_id): context = request.environ['nova.context'] |
