From a40f6041556ec09a1cb79c2b8abcec7fa70e72bf Mon Sep 17 00:00:00 2001 From: Cerberus Date: Mon, 7 Feb 2011 17:12:15 -0600 Subject: [PATCH] Some stuff --- nova/virt/xenapi_conn.py | 2 +- .../xenapi/etc/xapi.d/plugins/data_transfer | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/nova/virt/xenapi_conn.py b/nova/virt/xenapi_conn.py index acfde6caf8d3..726106b37174 100644 --- a/nova/virt/xenapi_conn.py +++ b/nova/virt/xenapi_conn.py @@ -193,7 +193,7 @@ class XenAPIConnection(object): self._vmops.power_on(instance) def transfer_disk(self, instance, dest, callback): - self._vmops.transfer_disk() + self._vmops.transfer_disk(dest) def suspend(self, instance, callback): """suspend the specified instance""" diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/data_transfer b/plugins/xenserver/xenapi/etc/xapi.d/plugins/data_transfer index d310a65d9047..cde7bb823c39 100644 --- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/data_transfer +++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/data_transfer @@ -28,10 +28,13 @@ import XenAPIPlugin SSH_HOSTS = '/root/.ssh/known_hosts' DEVNULL = '/dev/null' KEYSCAN = '/usr/bin/ssh-keyscan' +RSYNC = '/usr/bin/rsync' def _key_scan_and_add(host): """SSH scans a remote host and writes the SSH key out to known_hosts""" + # Touch the file if it doesn't yet exist open(SSH_HOSTS, 'a').close() + null = open(DEVNULL, 'w') known_hosts = open(SSH_HOSTS, 'a') key = subprocess.Popen(['/usr/bin/ssh-keyscan', '-t', 'rsa', host], @@ -42,3 +45,12 @@ def _key_scan_and_add(host): known_hosts.write(key) null.close() known_hosts.close() + +def transfer_vhd(host, vhd_path): + """Rsyncs a VHD to an adjacent host""" + _key_scan_and_add(host) + if subprocess.call([RSYNC, vhd_path, "%s:/root/" % host]) != 0: + raise Exception("Unexpected VHD transfer failure") + +if __name__ == '__main__': + XenAPIPlugin.dispatch({'transfer_vhd': transfer_vhd})