diff options
author | Bob Ball <bob.ball@citrix.com> | 2014-04-16 13:23:45 +0100 |
---|---|---|
committer | Bob Ball <bob.ball@citrix.com> | 2014-04-22 18:06:59 +0100 |
commit | b634bf3a0b3dbccec6c3d7b26ab2a67d8eb1a6e5 (patch) | |
tree | ce6d1c2a651070f73c0012a1f32c294f9bc93c97 /plugins | |
parent | 625e48f82b5c7f1d55641b4207afd85b0b798cc2 (diff) | |
download | nova-b634bf3a0b3dbccec6c3d7b26ab2a67d8eb1a6e5.tar.gz |
XenAPI: Use local rsync rather than remote if possible
Using ssh depends on the host being set up to be able to SSH into
itself which is not a common scenario. While this is unavoidable for
the current implementation of resize across multiple hosts, if there
is a single host (i.e. a test scenario) or the resize is restricted
to the same host then we can succeed without SSH access
Dependency on Ia310e31d31aaf5c979e41c64af8223202a18e03a is because the
tests will always fail without Ia310 therefore this fix cannot be tested
without taking Ia310 as well.
Closes-bug: 1308064
Change-Id: I15802a1d97d380b1c5b74fc9f92ece2494fe789a
Diffstat (limited to 'plugins')
-rwxr-xr-x | plugins/xenserver/xenapi/etc/xapi.d/plugins/migration | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/plugins/xenserver/xenapi/etc/xapi.d/plugins/migration b/plugins/xenserver/xenapi/etc/xapi.d/plugins/migration index bf5af304a9..4ffa9d3a00 100755 --- a/plugins/xenserver/xenapi/etc/xapi.d/plugins/migration +++ b/plugins/xenserver/xenapi/etc/xapi.d/plugins/migration @@ -36,15 +36,21 @@ def move_vhds_into_sr(session, instance_uuid, sr_path, uuid_stack): def _rsync_vhds(instance_uuid, host, staging_path, user="root"): - ssh_cmd = 'ssh -o StrictHostKeyChecking=no' - if not staging_path.endswith('/'): staging_path += '/' - dest_path = '%s@%s:/images/instance%s/' % (user, host, instance_uuid) - - rsync_cmd = ["/usr/bin/rsync", "-av", "--progress", "-e", ssh_cmd, - staging_path, dest_path] + dest_path = '/images/instance%s/' % (instance_uuid) + + ip_cmd = ["/sbin/ip", "addr", "show"] + output = utils.run_command(ip_cmd) + if ' %s/' % host in output: + # If copying to localhost, don't use SSH + rsync_cmd = ["/usr/bin/rsync", "-av", "--progress", + staging_path, dest_path] + else: + ssh_cmd = 'ssh -o StrictHostKeyChecking=no' + rsync_cmd = ["/usr/bin/rsync", "-av", "--progress", "-e", ssh_cmd, + staging_path, '%s@%s:%s' % (user, host, dest_path)] # NOTE(hillad): rsync's progress is carriage returned, requiring # universal_newlines for real-time output. |