summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
authorCerberus <matt.dietz@rackspace.com>2011-02-07 16:57:02 -0600
committerCerberus <matt.dietz@rackspace.com>2011-02-07 16:57:02 -0600
commite59c62efe5492e59fcc26b7b74f6ac2daa0caabe (patch)
treea1a5115aed9b14dafc0072824c8c95e4a52f2866 /plugins
parent2458d674807d951a6b58c28cd334cd8d097822a9 (diff)
downloadnova-e59c62efe5492e59fcc26b7b74f6ac2daa0caabe.tar.gz
nova-e59c62efe5492e59fcc26b7b74f6ac2daa0caabe.tar.xz
nova-e59c62efe5492e59fcc26b7b74f6ac2daa0caabe.zip
Added data_transfer xapi plugin
Diffstat (limited to 'plugins')
-rw-r--r--plugins/xenserver/xenapi/etc/xapi.d/plugins/data_transfer44
1 files changed, 44 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
new file mode 100644
index 000000000..d310a65d9
--- /dev/null
+++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/data_transfer
@@ -0,0 +1,44 @@
+#!/usr/bin/env python
+
+# Copyright 2010 United States Government as represented by the
+# Administrator of the National Aeronautics and Space Administration.
+# All Rights Reserved.
+#
+# Licensed under the Apache License, Version 2.0 (the "License"); you may
+# not use this file except in compliance with the License. You may obtain
+# a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
+# License for the specific language governing permissions and limitations
+# under the License.
+
+"""
+XenAPI Plugin for transfering data between host nodes
+"""
+
+import os.path
+import subprocess
+
+import XenAPIPlugin
+
+SSH_HOSTS = '/root/.ssh/known_hosts'
+DEVNULL = '/dev/null'
+KEYSCAN = '/usr/bin/ssh-keyscan'
+
+def _key_scan_and_add(host):
+ """SSH scans a remote host and writes the SSH key out to known_hosts"""
+ 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],
+ stdout=subprocess.PIPE, stderr=null).communicate()[0].strip()
+ grep = subprocess.call(['/bin/grep', '-o', '%s' % key, SSH_HOSTS],
+ stdout=null, stderr=null)
+ if grep == 1:
+ known_hosts.write(key)
+ null.close()
+ known_hosts.close()