Signed-off-by: tierno <alfonso.tiernosepulveda@telefonica.com>
raise paramiko.ssh_exception.SSHException("Error deleting file: " + error_msg)
def copy_file(self, source, destination, perserve_time=True):
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()
print self.name, ': command:', command
(_, _, stderr) = self.ssh_conn.exec_command(command)
error_msg = stderr.read()
use_incremental_out = use_incremental
new_backing_file = None
local_file = None
use_incremental_out = use_incremental
new_backing_file = None
local_file = None
#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
#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:
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
#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)
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
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:
#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:
__author__="Alfonso Tierno"
__date__ ="$10-jul-2014 12:07:15$"
__author__="Alfonso Tierno"
__date__ ="$10-jul-2014 12:07:15$"
-__version__="0.4.8-r495"
+__version__="0.4.9-r5002"
version_date="Sep 2016"
database_version="0.7" #expected database schema version
version_date="Sep 2016"
database_version="0.7" #expected database schema version