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
This commit is contained in:
@@ -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)
|
||||
dest_path = '/images/instance%s/' % (instance_uuid)
|
||||
|
||||
rsync_cmd = ["/usr/bin/rsync", "-av", "--progress", "-e", ssh_cmd,
|
||||
staging_path, dest_path]
|
||||
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.
|
||||
|
||||
Reference in New Issue
Block a user