summaryrefslogtreecommitdiffstats
path: root/nova/virt
diff options
context:
space:
mode:
authorChris Behrens <cbehrens@codestud.com>2011-05-25 20:31:05 +0000
committerTarmac <>2011-05-25 20:31:05 +0000
commit9ec9a8b39db2d65b7ce8d74f994cb32c49a56df8 (patch)
tree9fa99a51a97288cfddd4a4cdd040d3d7e7cf7480 /nova/virt
parenta2505ee554052ee591d1a79c2329c50b31a43dc4 (diff)
parentbd0b4b87da9e960042c3d0caf00370ef526ce8b7 (diff)
downloadnova-9ec9a8b39db2d65b7ce8d74f994cb32c49a56df8.tar.gz
nova-9ec9a8b39db2d65b7ce8d74f994cb32c49a56df8.tar.xz
nova-9ec9a8b39db2d65b7ce8d74f994cb32c49a56df8.zip
During the API create call, the API would kick off a build and then loop in a greenthread waiting for the scheduler to pick a host for the instance. After API would see a host was picked, it would cast to the compute node's set_admin_password method.
The API server really should not have to do this. The password to set should be pushed along with the build request, instead. The compute node can then set the password after it detects the instance has booted. This removes a greenthread from the API server, a loop that constantly checks the DB for the host, and finally a cast to the compute node.
Diffstat (limited to 'nova/virt')
-rw-r--r--nova/virt/xenapi/vmops.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py
index aaf5585b1..be6ef48ea 100644
--- a/nova/virt/xenapi/vmops.py
+++ b/nova/virt/xenapi/vmops.py
@@ -202,6 +202,13 @@ class VMOps(object):
for path, contents in instance.injected_files:
LOG.debug(_("Injecting file path: '%s'") % path)
self.inject_file(instance, path, contents)
+
+ def _set_admin_password():
+ admin_password = instance.admin_pass
+ if admin_password:
+ LOG.debug(_("Setting admin password"))
+ self.set_admin_password(instance, admin_password)
+
# NOTE(armando): Do we really need to do this in virt?
# NOTE(tr3buchet): not sure but wherever we do it, we need to call
# reset_network afterwards
@@ -214,6 +221,7 @@ class VMOps(object):
LOG.debug(_('Instance %s: booted'), instance_name)
timer.stop()
_inject_files()
+ _set_admin_password()
return True
except Exception, exc:
LOG.warn(exc)
@@ -458,6 +466,9 @@ class VMOps(object):
# Successful return code from password is '0'
if resp_dict['returncode'] != '0':
raise RuntimeError(resp_dict['message'])
+ db.instance_update(context.get_admin_context(),
+ instance['id'],
+ dict(admin_pass=new_pass))
return resp_dict['message']
def inject_file(self, instance, path, contents):