<s> from fabric . api import run , settings , env <EOL> import copy <EOL> from cloudferry . lib . utils import log <EOL> from cloudferry . lib . utils import utils <EOL> LOG = log . getLogger ( __name__ ) <EOL> def transfer_file_to_file ( src_cloud , <EOL> dst_cloud , <EOL> host_src , <EOL> host_dst , <EOL> path_src , <EOL> path_dst , <EOL> cfg_migrate ) : <EOL> LOG . debug ( "<STR_LIT>" ) <EOL> ssh_ip_src = src_cloud . cloud_config . cloud . ssh_host <EOL> ssh_ip_dst = dst_cloud . cloud_config . cloud . ssh_host <EOL> with settings ( host_string = ssh_ip_src , <EOL> connection_attempts = env . connection_attempts ) : <EOL> with utils . forward_agent ( cfg_migrate . key_filename ) : <EOL> with utils . up_ssh_tunnel ( host_dst , ssh_ip_dst , ssh_ip_src ) as port : <EOL> if cfg_migrate . file_compression == "<STR_LIT>" : <EOL> run ( ( "<STR_LIT>" + <EOL> "<STR_LIT>" + <EOL> "<STR_LIT>" ) % <EOL> ( host_src , path_src , port , path_dst ) ) <EOL> elif cfg_migrate . file_compression == "<STR_LIT>" : <EOL> run ( ( "<STR_LIT>" + <EOL> "<STR_LIT>" + <EOL> "<STR_LIT>" + <EOL> "<STR_LIT>" ) % <EOL> ( host_src , cfg_migrate . level_compression , <EOL> path_src , port , path_dst ) ) <EOL> def delete_file_from_rbd ( ssh_ip , file_path ) : <EOL> with settings ( host_string = ssh_ip , <EOL> connection_attempts = env . connection_attempts ) : <EOL> with utils . forward_agent ( env . key_filename ) : <EOL> run ( "<STR_LIT>" % file_path ) <EOL> def convert_to_dest ( data , source , dest ) : <EOL> d = copy . copy ( data ) <EOL> d [ dest ] = d [ '<STR_LIT>' ] [ dest ] <EOL> d [ '<STR_LIT>' ] [ source ] = d [ source ] <EOL> return d <EOL> def require_methods ( methods , obj ) : <EOL> for method in dir ( obj ) : <EOL> if method not in methods : <EOL> return False <EOL> return True <EOL> def select_boot_volume ( info ) : <EOL> for k , v in info [ utils . STORAGE_RESOURCE ] [ utils . VOLUMES_TYPE ] . iteritems ( ) : <EOL> if not ( ( v [ '<STR_LIT>' ] == <NUM_LIT:0> ) and v [ '<STR_LIT>' ] ) : <EOL> del info [ utils . STORAGE_RESOURCE ] [ utils . VOLUMES_TYPE ] [ k ] <EOL> return info </s>
