Merge "xenapi: Adding logging for migration plugin"
This commit is contained in:
commit
07694d4ffa
@ -40,9 +40,20 @@ def _rsync_vhds(instance_uuid, host, staging_path, user="root"):
|
||||
|
||||
dest_path = '%s@%s:/images/instance%s/' % (user, host, instance_uuid)
|
||||
|
||||
rsync_cmd = "nohup /usr/bin/rsync -av -e %(ssh_cmd)s %(staging_path)s"\
|
||||
" %(dest_path)s" % locals()
|
||||
rsync_proc = utils.make_subprocess(rsync_cmd, stdout=True, stderr=True)
|
||||
rsync_cmd = "/usr/bin/rsync -av --progress -e %(ssh_cmd)s "\
|
||||
"%(staging_path)s %(dest_path)s" % locals()
|
||||
|
||||
# NOTE(hillad): rsync's progress is carriage returned, requiring
|
||||
# universal_newlines for real-time output.
|
||||
|
||||
rsync_proc = utils.make_subprocess(rsync_cmd, stdout=True, stderr=True,
|
||||
universal_newlines=True)
|
||||
while True:
|
||||
rsync_progress = rsync_proc.stdout.readline()
|
||||
if not rsync_progress:
|
||||
break
|
||||
logging.debug(rsync_progress)
|
||||
|
||||
utils.finish_subprocess(rsync_proc, rsync_cmd)
|
||||
|
||||
|
||||
|
@ -47,7 +47,8 @@ def _rename(src, dst):
|
||||
os.rename(src, dst)
|
||||
|
||||
|
||||
def make_subprocess(cmdline, stdout=False, stderr=False, stdin=False):
|
||||
def make_subprocess(cmdline, stdout=False, stderr=False, stdin=False,
|
||||
universal_newlines=False):
|
||||
"""Make a subprocess according to the given command-line string
|
||||
"""
|
||||
# NOTE(dprince): shlex python 2.4 doesn't like unicode so we
|
||||
@ -58,6 +59,7 @@ def make_subprocess(cmdline, stdout=False, stderr=False, stdin=False):
|
||||
kwargs['stdout'] = stdout and subprocess.PIPE or None
|
||||
kwargs['stderr'] = stderr and subprocess.PIPE or None
|
||||
kwargs['stdin'] = stdin and subprocess.PIPE or None
|
||||
kwargs['universal_newlines'] = universal_newlines
|
||||
args = shlex.split(cmdline)
|
||||
logging.info("Running args '%s'" % args)
|
||||
proc = subprocess.Popen(args, **kwargs)
|
||||
|
Loading…
x
Reference in New Issue
Block a user