X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;f=host_thread.py;h=e8775054f7060267a870a8d7e565f0ca98cb0a53;hb=d9cd59644f3427709741bdf711057e069cb6ce72;hp=0aba07755e879292d708435701b24a242f7a86c4;hpb=f7aa8c4db7a57d5865d3b7767d5957fda6867198;p=osm%2Fopenvim.git diff --git a/host_thread.py b/host_thread.py index 0aba077..e877505 100644 --- a/host_thread.py +++ b/host_thread.py @@ -2,7 +2,7 @@ ## # Copyright 2015 Telefónica Investigación y Desarrollo, S.A.U. -# This file is part of openmano +# This file is part of openvim # All Rights Reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); you may @@ -40,7 +40,7 @@ import libvirt from vim_schema import localinfo_schema, hostinfo_schema import random #from logging import Logger -#import utils.auxiliary_functions as af +#import auxiliary_functions as af #TODO: insert a logging system @@ -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: