summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorCerberus <matt.dietz@rackspace.com>2011-02-07 17:12:15 -0600
committerCerberus <matt.dietz@rackspace.com>2011-02-07 17:12:15 -0600
commita40f6041556ec09a1cb79c2b8abcec7fa70e72bf (patch)
tree730c406c06d9edba93857bb5502b380407a0e457 /plugins
parente59c62efe5492e59fcc26b7b74f6ac2daa0caabe (diff)
downloadnova-a40f6041556ec09a1cb79c2b8abcec7fa70e72bf.tar.gz
nova-a40f6041556ec09a1cb79c2b8abcec7fa70e72bf.tar.xz
nova-a40f6041556ec09a1cb79c2b8abcec7fa70e72bf.zip
Some stuff
Diffstat (limited to 'plugins')
-rw-r--r--plugins/xenserver/xenapi/etc/xapi.d/plugins/data_transfer12
1 files changed, 12 insertions, 0 deletions
diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/data_transfer b/plugins/xenserver/xenapi/etc/xapi.d/plugins/data_transfer
index d310a65d9..cde7bb823 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})