Review feedback.

This commit is contained in:
Josh Kearney
2011-05-13 10:26:50 -05:00
parent b4357fef25
commit 60dcc66db2
2 changed files with 14 additions and 10 deletions

View File

@@ -14,7 +14,6 @@
# under the License.
import base64
import eventlet
import traceback
from webob import exc
@@ -176,9 +175,8 @@ class Controller(common.OpenstackController):
builder = self._get_view_builder(req)
server = builder.build(inst, is_detail=True)
server['server']['adminPass'] = password
# We don't want this to block
eventlet.spawn(self.compute_api.set_admin_password(
context, server['server']['id'], password))
self.compute_api.set_admin_password(context, server['server']['id'],
password)
return server
def _deserialize_create(self, request):

View File

@@ -19,6 +19,7 @@
"""Handles all requests relating to instances (guest vms)."""
import datetime
import eventlet
import re
import time
@@ -495,6 +496,15 @@ class API(base.Base):
raise exception.Error(_("Unable to find host for Instance %s")
% instance_id)
def _set_admin_password(self, context, instance_id, password):
"""Set the root/admin password for the given instance."""
host = self._find_host(context, instance_id)
rpc.cast(context,
self.db.queue_get_for(context, FLAGS.compute_topic, host),
{"method": "set_admin_password",
"args": {"instance_id": instance_id, "new_pass": password}})
def snapshot(self, context, instance_id, name):
"""Snapshot the given instance.
@@ -648,12 +658,8 @@ class API(base.Base):
def set_admin_password(self, context, instance_id, password=None):
"""Set the root/admin password for the given instance."""
host = self._find_host(context, instance_id)
rpc.cast(context,
self.db.queue_get_for(context, FLAGS.compute_topic, host),
{"method": "set_admin_password",
"args": {"instance_id": instance_id, "new_pass": password}})
eventlet.spawn_n(self._set_admin_password(context, instance_id,
password))
def inject_file(self, context, instance_id):
"""Write a file to the given instance."""