summaryrefslogtreecommitdiffstats
path: root/nova/virt
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2013-03-17 14:50:47 +0000
committerGerrit Code Review <review@openstack.org>2013-03-17 14:50:47 +0000
commit87a560400439acfeb63e94e08c6848fa6ec8243f (patch)
tree1342eec0686822336917190e8dd8e0734794f741 /nova/virt
parent9ee8c946f2cf0f541f14a25505ceaaac7c0a53cd (diff)
parentfff0f422f647b689bb9a62b1eff2203354a9f885 (diff)
Merge "Make ssh key injection work with xenapi agent"
Diffstat (limited to 'nova/virt')
-rw-r--r--nova/virt/xenapi/agent.py19
-rw-r--r--nova/virt/xenapi/vmops.py3
2 files changed, 22 insertions, 0 deletions
diff --git a/nova/virt/xenapi/agent.py b/nova/virt/xenapi/agent.py
index 1fe6dff7e..a8074e8d0 100644
--- a/nova/virt/xenapi/agent.py
+++ b/nova/virt/xenapi/agent.py
@@ -224,6 +224,25 @@ class XenAPIBasedAgent(object):
return resp['message']
+ def inject_ssh_key(self):
+ sshkey = self.instance.get('key_data')
+ if not sshkey:
+ return
+ if self.instance['os_type'] == 'windows':
+ LOG.warning(_("Skipping setting of ssh key for Windows."),
+ instance=self.instance)
+ return
+ sshkey = str(sshkey)
+ keyfile = '/root/.ssh/authorized_keys'
+ key_data = ''.join([
+ '\n',
+ '# The following ssh key was injected by Nova',
+ '\n',
+ sshkey.strip(),
+ '\n',
+ ])
+ return self.inject_file(keyfile, key_data)
+
def inject_file(self, path, contents):
LOG.debug(_('Injecting file path: %r'), path, instance=self.instance)
diff --git a/nova/virt/xenapi/vmops.py b/nova/virt/xenapi/vmops.py
index cd7311678..028b20910 100644
--- a/nova/virt/xenapi/vmops.py
+++ b/nova/virt/xenapi/vmops.py
@@ -651,6 +651,9 @@ class VMOps(object):
# instance, but skip the admin password configuration
no_agent = version is None
+ # Inject ssh key.
+ agent.inject_ssh_key()
+
# Inject files, if necessary
if injected_files:
# Inject any files, if specified