diff options
| author | Jenkins <jenkins@review.openstack.org> | 2011-11-09 17:18:21 +0000 |
|---|---|---|
| committer | Gerrit Code Review <review@openstack.org> | 2011-11-09 17:18:21 +0000 |
| commit | 00861098508fc675ba2d90a5c34fec152ddf5c3d (patch) | |
| tree | 6b01c410de7862077d5e89f0f89a5083358dfefd /nova/api | |
| parent | 96cf15ce782c4362daea4b178f418738846bb074 (diff) | |
| parent | 8977826c949fb6d3e1de6aa4965122d01436ae5c (diff) | |
| download | nova-00861098508fc675ba2d90a5c34fec152ddf5c3d.tar.gz nova-00861098508fc675ba2d90a5c34fec152ddf5c3d.tar.xz nova-00861098508fc675ba2d90a5c34fec152ddf5c3d.zip | |
Merge "Converting reboot to use instance objects"
Diffstat (limited to 'nova/api')
| -rw-r--r-- | nova/api/ec2/cloud.py | 5 | ||||
| -rw-r--r-- | nova/api/openstack/servers.py | 14 |
2 files changed, 16 insertions, 3 deletions
diff --git a/nova/api/ec2/cloud.py b/nova/api/ec2/cloud.py index b2aa120e6..735b72cef 100644 --- a/nova/api/ec2/cloud.py +++ b/nova/api/ec2/cloud.py @@ -1458,7 +1458,10 @@ class CloudController(object): def reboot_instances(self, context, instance_id, **kwargs): """instance_id is a list of instance ids""" LOG.audit(_("Reboot instance %r"), instance_id, context=context) - self._do_instances(self.compute_api.reboot, context, instance_id) + for ec2_id in instance_id: + _instance_id = ec2utils.ec2_id_to_id(ec2_id) + instance = self.compute_api.get(context, _instance_id) + self.compute_api.reboot(context, instance, 'HARD') return True def stop_instances(self, context, instance_id, **kwargs): diff --git a/nova/api/openstack/servers.py b/nova/api/openstack/servers.py index e11d8ceb0..2a1424e46 100644 --- a/nova/api/openstack/servers.py +++ b/nova/api/openstack/servers.py @@ -142,6 +142,13 @@ class Controller(object): limited_list = self._limit_items(instance_list, req) return self._build_list(req, limited_list, is_detail=is_detail) + def _get_server(self, context, instance_uuid): + """Utility function for looking up an instance by uuid""" + try: + return self.compute_api.get(context, instance_uuid) + except exception.NotFound: + raise exc.HTTPNotFound() + def _handle_quota_error(self, error): """ Reraise quota errors as api-specific http exceptions @@ -609,9 +616,12 @@ class Controller(object): msg = _("Missing argument 'type' for reboot") LOG.exception(msg) raise exc.HTTPBadRequest(explanation=msg) + + context = req.environ['nova.context'] + instance = self._get_server(context, id) + try: - self.compute_api.reboot(req.environ['nova.context'], id, - reboot_type) + self.compute_api.reboot(context, instance, reboot_type) except Exception, e: LOG.exception(_("Error in reboot %s"), e) raise exc.HTTPUnprocessableEntity() |
