summaryrefslogtreecommitdiffstats
path: root/nova/api
diff options
context:
space:
mode:
authorBrian Waldon <brian.waldon@rackspace.com>2011-11-10 17:15:28 -0500
committerBrian Waldon <brian.waldon@rackspace.com>2011-11-11 16:51:52 -0500
commit574166045c6d4b7d8f5e2afeaa6d13aabf03bdb0 (patch)
tree6a87438297d2cc4bc3a9b9a82663567e6352790d /nova/api
parentbf7b89d577a9fbe8d25c3db2deae926d852d8bcc (diff)
Converting rescue/unrescue to use instance objects
Related to blueprint internal-uuids Change-Id: If256d9a1251e780ff044bd87e0805c9f511c05e9
Diffstat (limited to 'nova/api')
-rw-r--r--nova/api/openstack/contrib/rescue.py20
1 files changed, 15 insertions, 5 deletions
diff --git a/nova/api/openstack/contrib/rescue.py b/nova/api/openstack/contrib/rescue.py
index 4e1beb0ba..d3f38b200 100644
--- a/nova/api/openstack/contrib/rescue.py
+++ b/nova/api/openstack/contrib/rescue.py
@@ -17,12 +17,13 @@
import webob
from webob import exc
+from nova.api.openstack import extensions as exts
+from nova.api.openstack import faults
from nova import compute
+from nova import exception
from nova import flags
from nova import log as logging
from nova import utils
-from nova.api.openstack import extensions as exts
-from nova.api.openstack import faults
FLAGS = flags.FLAGS
@@ -41,24 +42,33 @@ class Rescue(exts.ExtensionDescriptor):
super(Rescue, self).__init__(ext_mgr)
self.compute_api = compute.API()
+ def _get_instance(self, context, instance_id):
+ try:
+ return self.compute_api.get(context, instance_id)
+ except exception.InstanceNotFound:
+ msg = _("Server not found")
+ raise exc.HTTPNotFound(msg)
+
@exts.wrap_errors
def _rescue(self, input_dict, req, instance_id):
"""Rescue an instance."""
context = req.environ["nova.context"]
+
if input_dict['rescue'] and 'adminPass' in input_dict['rescue']:
password = input_dict['rescue']['adminPass']
else:
password = utils.generate_password(FLAGS.password_length)
- self.compute_api.rescue(context, instance_id, rescue_password=password)
+ instance = self._get_instance(context, instance_id)
+ self.compute_api.rescue(context, instance, rescue_password=password)
return {'adminPass': password}
@exts.wrap_errors
def _unrescue(self, input_dict, req, instance_id):
"""Unrescue an instance."""
context = req.environ["nova.context"]
- self.compute_api.unrescue(context, instance_id)
-
+ instance = self._get_instance(context, instance_id)
+ self.compute_api.unrescue(context, instance)
return webob.Response(status_int=202)
def get_actions(self):