X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=host_thread.py;fp=host_thread.py;h=e8775054f7060267a870a8d7e565f0ca98cb0a53;hb=34940a0a4c37f1c33a5bc5372032824e6157290d;hp=cae8c6053cb0b0171e7ce0d2f48ec61e2f8582ca;hpb=c4864734c010b1402d790d1e123af84d1823ce3a;p=osm%2Fopenvim.git diff --git a/host_thread.py b/host_thread.py index cae8c60..e877505 100644 --- a/host_thread.py +++ b/host_thread.py @@ -757,9 +757,14 @@ class host_thread(threading.Thread): raise paramiko.ssh_exception.SSHException("Error deleting file: " + error_msg) def copy_file(self, source, destination, perserve_time=True): - command = 'cp --no-preserve=mode ' - if perserve_time: command += '--preserve=timestamps ' - command += source + ' ' + destination + if source[0:4]=="http": + command = "wget --no-verbose -O '{dst}' '{src}' 2>'{dst_result}' || cat '{dst_result}' >&2 && rm '{dst_result}'".format( + dst=destination, src=source, dst_result=destination + ".result" ) + else: + command = 'cp --no-preserve=mode' + if perserve_time: + command += ' --preserve=timestamps' + command += " '{}' '{}'".format(source, destination) print self.name, ': command:', command (_, _, stderr) = self.ssh_conn.exec_command(command) error_msg = stderr.read() @@ -783,24 +788,29 @@ class host_thread(threading.Thread): use_incremental_out = use_incremental new_backing_file = None local_file = None + file_from_local = True #in case incremental use is not decided, take the decision depending on the image #avoid the use of incremental if this image is already incremental - qemu_remote_info = self.qemu_get_info(remote_file) + if remote_file[0:4] == "http": + file_from_local = False + if file_from_local: + qemu_remote_info = self.qemu_get_info(remote_file) if use_incremental_out==None: - use_incremental_out = not 'backing file' in qemu_remote_info + use_incremental_out = not ( file_from_local and 'backing file' in qemu_remote_info) #copy recursivelly the backing files - if 'backing file' in qemu_remote_info: + if file_from_local and 'backing file' in qemu_remote_info: new_backing_file, _, _ = self.copy_remote_file(qemu_remote_info['backing file'], True) #check if remote file is present locally if use_incremental_out and remote_file in self.localinfo['files']: local_file = self.localinfo['files'][remote_file] local_file_info = self.get_file_info(local_file) - remote_file_info = self.get_file_info(remote_file) + if file_from_local: + remote_file_info = self.get_file_info(remote_file) if local_file_info == None: local_file = None - elif local_file_info[4]!=remote_file_info[4] or local_file_info[5]!=remote_file_info[5]: + elif file_from_local and (local_file_info[4]!=remote_file_info[4] or local_file_info[5]!=remote_file_info[5]): #local copy of file not valid because date or size are different. #TODO DELETE local file if this file is not used by any active virtual machine try: