<s> import logging <EOL> import time <EOL> from django . conf import settings <EOL> from horizon . utils . memoized import memoized <EOL> import freezer . apiclient . client <EOL> from disaster_recovery import utils <EOL> LOG = logging . getLogger ( __name__ ) <EOL> @ memoized <EOL> def client ( request ) : <EOL> """<STR_LIT>""" <EOL> api_url = _get_service_url ( request ) <EOL> ks_version = getattr ( settings , <EOL> '<STR_LIT>' , { } ) . get ( '<STR_LIT>' , <NUM_LIT> ) <EOL> insecure = getattr ( settings , '<STR_LIT>' , False ) <EOL> cacert = getattr ( settings , '<STR_LIT>' , None ) <EOL> credentials = { <EOL> '<STR_LIT>' : request . user . token . id , <EOL> '<STR_LIT>' : getattr ( settings , '<STR_LIT>' ) , <EOL> '<STR_LIT>' : api_url , <EOL> '<STR_LIT:version>' : ks_version , <EOL> '<STR_LIT>' : cacert , <EOL> '<STR_LIT>' : insecure <EOL> } <EOL> if ks_version == <NUM_LIT:3> : <EOL> credentials [ '<STR_LIT>' ] = request . user . project_name <EOL> credentials [ '<STR_LIT>' ] = request . user . domain_name or '<STR_LIT>' <EOL> return freezer . apiclient . client . Client ( ** credentials ) <EOL> @ memoized <EOL> def _get_service_url ( request ) : <EOL> """<STR_LIT>""" <EOL> hardcoded_url = getattr ( settings , '<STR_LIT>' , None ) <EOL> if hardcoded_url is not None : <EOL> LOG . warn ( '<STR_LIT>' . format ( hardcoded_url ) ) <EOL> return hardcoded_url <EOL> e_type = getattr ( settings , '<STR_LIT>' , '<STR_LIT>' ) <EOL> endpoint_type_priority = [ e_type , [ '<STR_LIT>' , '<STR_LIT>' ] , [ '<STR_LIT>' , <EOL> '<STR_LIT>' ] ] <EOL> try : <EOL> catalog = ( getattr ( request . user , "<STR_LIT>" , [ ] ) ) <EOL> for c in catalog : <EOL> if c [ '<STR_LIT:name>' ] == '<STR_LIT>' : <EOL> for endpoint_type in endpoint_type_priority : <EOL> for e in c [ '<STR_LIT>' ] : <EOL> if e [ '<STR_LIT>' ] in endpoint_type : <EOL> return e [ '<STR_LIT:url>' ] <EOL> raise ValueError ( '<STR_LIT>' <EOL> '<STR_LIT>' ) <EOL> except Exception : <EOL> LOG . warn ( '<STR_LIT>' ) <EOL> raise <EOL> class Job ( object ) : <EOL> def __init__ ( self , request ) : <EOL> self . request = request <EOL> self . client = client ( request ) <EOL> def list ( self , json = False , limit = <NUM_LIT> , offset = <NUM_LIT:0> , search = None ) : <EOL> if search : <EOL> search = { "<STR_LIT>" : [ { "<STR_LIT>" : search } , ] , } <EOL> jobs = self . client . jobs . list_all ( limit = limit , <EOL> offset = offset , <EOL> search = search ) <EOL> if json : <EOL> return jobs <EOL> return [ utils . JobObject ( <EOL> job . get ( '<STR_LIT>' ) , <EOL> job . get ( '<STR_LIT:description>' ) , <EOL> job . get ( '<STR_LIT>' , { } ) . get ( '<STR_LIT:result>' ) , <EOL> job . get ( '<STR_LIT>' , { } ) . get ( '<STR_LIT:status>' ) , <EOL> job . get ( '<STR_LIT>' ) <EOL> ) for job in jobs ] <EOL> def get ( self , job_id , json = False ) : <EOL> job = self . client . jobs . get ( job_id ) <EOL> if json : <EOL> return job <EOL> return utils . JobObject ( <EOL> job . get ( '<STR_LIT>' ) , <EOL> job . get ( '<STR_LIT:description>' ) , <EOL> job . get ( '<STR_LIT>' , { } ) . get ( '<STR_LIT:result>' ) , <EOL> job . get ( '<STR_LIT>' , { } ) . get ( '<STR_LIT>' ) , <EOL> job . get ( '<STR_LIT>' ) ) <EOL> def create ( self , job ) : <EOL> job = self . _build ( job ) <EOL> time . sleep ( <NUM_LIT:3> ) <EOL> return job <EOL> def update ( self , job_id , job ) : <EOL> scheduling = { } <EOL> try : <EOL> if job [ '<STR_LIT>' ] != '<STR_LIT>' : <EOL> utils . assign_and_remove ( job , scheduling , '<STR_LIT>' ) <EOL> else : <EOL> job . pop ( '<STR_LIT>' ) <EOL> except KeyError : <EOL> pass <EOL> try : <EOL> if job [ '<STR_LIT>' ] != '<STR_LIT>' : <EOL> utils . assign_and_remove ( job , scheduling , '<STR_LIT>' ) <EOL> else : <EOL> job . pop ( '<STR_LIT>' ) <EOL> except KeyError : <EOL> pass <EOL> try : <EOL> if job [ '<STR_LIT>' ] != '<STR_LIT>' : <EOL> utils . assign_and_remove ( job , scheduling , '<STR_LIT>' ) <EOL> else : <EOL> job . pop ( '<STR_LIT>' ) <EOL> except KeyError : <EOL> pass <EOL> job . pop ( '<STR_LIT>' , [ ] ) <EOL> job . pop ( '<STR_LIT>' , None ) <EOL> job . pop ( '<STR_LIT>' , None ) <EOL> job . pop ( '<STR_LIT>' ) <EOL> job [ '<STR_LIT>' ] = scheduling <EOL> return self . client . jobs . update ( job_id , job ) <EOL> def update_actions ( self , job_id , action_ids ) : <EOL> ids = utils . get_action_ids ( action_ids ) <EOL> job = self . get ( job_id , json = True ) <EOL> job . pop ( '<STR_LIT>' , None ) <EOL> actions = self . _get_actions_in_job ( ids ) <EOL> job [ '<STR_LIT>' ] = actions <EOL> return self . client . jobs . update ( job_id , job ) <EOL> def delete ( self , job_id ) : <EOL> return self . client . jobs . delete ( job_id ) <EOL> def actions ( self , job_id , api = False ) : <EOL> job = self . get ( job_id , json = True ) <EOL> if not job : <EOL> return [ ] <EOL> if api : <EOL> return job . get ( '<STR_LIT>' , [ ] ) <EOL> return [ utils . ActionObject ( <EOL> action_id = a . get ( '<STR_LIT>' ) , <EOL> action = a . get ( '<STR_LIT>' , { } ) . get ( '<STR_LIT:action>' ) , <EOL> backup_name = a . get ( '<STR_LIT>' , { } ) . get ( '<STR_LIT>' ) , <EOL> job_id = job_id <EOL> ) for a in job . get ( '<STR_LIT>' ) ] <EOL> def delete_action ( self , ids ) : <EOL> action_id , job_id = ids . split ( '<STR_LIT>' ) <EOL> job = self . get ( job_id , json = True ) <EOL> for action in job [ '<STR_LIT>' ] : <EOL> if action . get ( '<STR_LIT>' ) == action_id : <EOL> job . get ( '<STR_LIT>' ) . remove ( action ) <EOL> return self . client . jobs . update ( job_id , job ) <EOL> def clone ( self , job_id ) : <EOL> job = self . get ( job_id , json = True ) <EOL> job [ '<STR_LIT:description>' ] = '<STR_LIT>' . format ( job [ '<STR_LIT:description>' ] ) <EOL> job . pop ( '<STR_LIT>' , None ) <EOL> job . pop ( '<STR_LIT>' , None ) <EOL> job_id = self . client . jobs . create ( job ) <EOL> return self . stop ( job_id ) <EOL> def stop ( self , job_id ) : <EOL> return self . client . jobs . stop_job ( job_id ) <EOL> def start ( self , job_id ) : <EOL> return self . client . jobs . start_job ( job_id ) <EOL> def _build ( self , job ) : <EOL> action_ids = utils . get_action_ids ( job . pop ( '<STR_LIT>' ) ) <EOL> job = utils . create_dict ( ** job ) <EOL> clients = job . pop ( '<STR_LIT>' , [ ] ) <EOL> scheduling = { } <EOL> new_job = { } <EOL> utils . assign_and_remove ( job , scheduling , '<STR_LIT>' ) <EOL> utils . assign_and_remove ( job , scheduling , '<STR_LIT>' ) <EOL> utils . assign_and_remove ( job , scheduling , '<STR_LIT>' ) <EOL> actions = self . _get_actions_in_job ( action_ids ) <EOL> new_job [ '<STR_LIT:description>' ] = job . get ( '<STR_LIT:description>' ) <EOL> new_job [ '<STR_LIT>' ] = actions <EOL> new_job [ '<STR_LIT>' ] = scheduling <EOL> for client_id in clients : <EOL> search = client_id <EOL> client = Client ( self . request ) . list ( search = search ) <EOL> new_job [ '<STR_LIT>' ] = client [ <NUM_LIT:0> ] . id <EOL> job_id = self . client . jobs . create ( new_job ) <EOL> self . stop ( job_id ) <EOL> return True <EOL> def _get_actions_in_job ( self , action_ids ) : <EOL> actions_in_job = [ ] <EOL> for action_id in action_ids : <EOL> action = Action ( self . request ) . get ( action_id , json = True ) <EOL> a = { <EOL> '<STR_LIT>' : action [ '<STR_LIT>' ] , <EOL> '<STR_LIT>' : action [ '<STR_LIT>' ] <EOL> } <EOL> actions_in_job . append ( a ) <EOL> return actions_in_job <EOL> class Session ( object ) : <EOL> def __init__ ( self , request ) : <EOL> self . request = request <EOL> self . client = client ( request ) <EOL> def list ( self , json = False , limit = <NUM_LIT> , offset = <NUM_LIT:0> , search = None ) : <EOL> if search : <EOL> search = { "<STR_LIT>" : [ { "<STR_LIT>" : search } , ] , } <EOL> sessions = self . client . sessions . list_all ( limit = limit , <EOL> offset = offset , <EOL> search = search ) <EOL> if json : <EOL> return sessions <EOL> return [ utils . SessionObject ( <EOL> session . get ( '<STR_LIT>' ) , <EOL> session . get ( '<STR_LIT:description>' ) , <EOL> session . get ( '<STR_LIT:status>' ) , <EOL> session . get ( '<STR_LIT>' ) , <EOL> session . get ( '<STR_LIT>' , { } ) . get ( '<STR_LIT>' ) , <EOL> session . get ( '<STR_LIT>' , { } ) . get ( '<STR_LIT>' ) , <EOL> session . get ( '<STR_LIT>' , { } ) . get ( '<STR_LIT>' ) <EOL> ) for session in sessions ] <EOL> def get ( self , session_id , json = False ) : <EOL> session = self . client . sessions . get ( session_id ) <EOL> if json : <EOL> return session <EOL> return utils . SessionObject ( <EOL> session . get ( '<STR_LIT>' ) , <EOL> session . get ( '<STR_LIT:description>' ) , <EOL> session . get ( '<STR_LIT:status>' ) , <EOL> session . get ( '<STR_LIT>' ) , <EOL> session . get ( '<STR_LIT>' , { } ) . get ( '<STR_LIT>' ) , <EOL> session . get ( '<STR_LIT>' , { } ) . get ( '<STR_LIT>' ) , <EOL> session . get ( '<STR_LIT>' , { } ) . get ( '<STR_LIT>' ) ) <EOL> def create ( self , session ) : <EOL> session = self . _build ( session ) <EOL> time . sleep ( <NUM_LIT:3> ) <EOL> return session <EOL> def update ( self , session , session_id ) : <EOL> return self . client . sessions . update ( session_id , session ) <EOL> def delete ( self , session_id ) : <EOL> return self . client . sessions . delete ( session_id ) <EOL> def remove_job ( self , session_id , job_id ) : <EOL> try : <EOL> return self . client . sessions . remove_job ( session_id , job_id ) <EOL> except Exception : <EOL> pass <EOL> def add_job ( self , session_id , job_id ) : <EOL> return self . client . sessions . add_job ( session_id , job_id ) <EOL> def jobs ( self , session_id ) : <EOL> session = self . get ( session_id , json = True ) <EOL> jobs = [ ] <EOL> if session is None : <EOL> return jobs <EOL> try : <EOL> jobs = [ utils . JobsInSessionObject ( k , <EOL> session_id , <EOL> v [ '<STR_LIT>' ] , <EOL> v [ '<STR_LIT:result>' ] ) <EOL> for k , v in session [ '<STR_LIT>' ] . iteritems ( ) ] <EOL> except AttributeError as error : <EOL> LOG . error ( error . message ) <EOL> return jobs <EOL> def _build ( self , session ) : <EOL> session = utils . create_dict ( ** session ) <EOL> scheduling = { } <EOL> utils . assign_and_remove ( session , scheduling , '<STR_LIT>' ) <EOL> utils . assign_and_remove ( session , scheduling , '<STR_LIT>' ) <EOL> utils . assign_and_remove ( session , scheduling , '<STR_LIT>' ) <EOL> session [ '<STR_LIT>' ] = { } <EOL> session [ '<STR_LIT>' ] = scheduling <EOL> return self . client . sessions . create ( session ) <EOL> class Action ( object ) : <EOL> def __init__ ( self , request ) : <EOL> self . request = request <EOL> self . client = client ( request ) <EOL> def list ( self , json = False , limit = <NUM_LIT> , offset = <NUM_LIT:0> , search = None ) : <EOL> if search : <EOL> search = { "<STR_LIT>" : [ { "<STR_LIT>" : search } , ] , } <EOL> actions = self . client . actions . list ( limit = limit , <EOL> offset = offset , <EOL> search = search ) <EOL> if json : <EOL> return actions <EOL> return [ utils . ActionObjectDetail ( <EOL> action . get ( '<STR_LIT>' ) , <EOL> action [ '<STR_LIT>' ] . get ( '<STR_LIT:action>' ) , <EOL> action [ '<STR_LIT>' ] . get ( '<STR_LIT>' ) , <EOL> action [ '<STR_LIT>' ] . get ( '<STR_LIT>' ) or <EOL> action [ '<STR_LIT>' ] . get ( '<STR_LIT>' ) , <EOL> action [ '<STR_LIT>' ] . get ( '<STR_LIT>' ) , <EOL> mode = action [ '<STR_LIT>' ] . get ( '<STR_LIT>' ) <EOL> ) for action in actions ] <EOL> def get ( self , job_id , json = False ) : <EOL> action = self . client . actions . get ( job_id ) <EOL> if json : <EOL> return action <EOL> return utils . ActionObjectDetail ( <EOL> action . get ( '<STR_LIT>' ) , <EOL> action [ '<STR_LIT>' ] . get ( '<STR_LIT:action>' ) , <EOL> action [ '<STR_LIT>' ] . get ( '<STR_LIT>' ) , <EOL> action [ '<STR_LIT>' ] . get ( '<STR_LIT>' ) , <EOL> action [ '<STR_LIT>' ] . get ( '<STR_LIT>' ) ) <EOL> def create ( self , action ) : <EOL> action = self . _build ( action ) <EOL> time . sleep ( <NUM_LIT:3> ) <EOL> return action <EOL> def update ( self , action , action_id ) : <EOL> updated_action = { } <EOL> updated_action [ '<STR_LIT>' ] = utils . create_dict ( ** action ) <EOL> try : <EOL> if action [ '<STR_LIT>' ] != '<STR_LIT>' : <EOL> updated_action [ '<STR_LIT>' ] = action [ '<STR_LIT>' ] <EOL> except KeyError : <EOL> pass <EOL> try : <EOL> if action [ '<STR_LIT>' ] != '<STR_LIT>' : <EOL> updated_action [ '<STR_LIT>' ] = action [ '<STR_LIT>' ] <EOL> except KeyError : <EOL> pass <EOL> try : <EOL> if action [ '<STR_LIT>' ] != '<STR_LIT>' : <EOL> updated_action [ '<STR_LIT>' ] = action [ '<STR_LIT>' ] <EOL> except KeyError : <EOL> pass <EOL> return self . client . actions . update ( action_id , updated_action ) <EOL> def delete ( self , action_id ) : <EOL> return self . client . actions . delete ( action_id ) <EOL> def _build ( self , action ) : <EOL> """<STR_LIT>""" <EOL> action_rules = { } <EOL> utils . assign_and_remove ( action , action_rules , '<STR_LIT>' ) <EOL> utils . assign_and_remove ( action , action_rules , '<STR_LIT>' ) <EOL> utils . assign_and_remove ( action , action_rules , '<STR_LIT>' ) <EOL> action = utils . create_dict ( ** action ) <EOL> action . pop ( '<STR_LIT>' , None ) <EOL> backup_name = action . pop ( '<STR_LIT>' , None ) <EOL> action [ '<STR_LIT>' ] = backup_name . replace ( '<STR_LIT:U+0020>' , '<STR_LIT:_>' ) <EOL> action = { '<STR_LIT>' : action } <EOL> action . update ( action_rules ) <EOL> return self . client . actions . create ( action ) <EOL> class Client ( object ) : <EOL> def __init__ ( self , request ) : <EOL> self . request = request <EOL> self . client = client ( request ) <EOL> def list ( self , json = False , limit = <NUM_LIT> , offset = <NUM_LIT:0> , search = None ) : <EOL> if search : <EOL> search = { "<STR_LIT>" : [ { "<STR_LIT>" : search } , ] , } <EOL> clients = self . client . registration . list ( limit = limit , <EOL> offset = offset , <EOL> search = search ) <EOL> if json : <EOL> return clients <EOL> return [ utils . ClientObject ( <EOL> c . get ( '<STR_LIT>' , { } ) . get ( '<STR_LIT>' ) , <EOL> c . get ( '<STR_LIT>' , { } ) . get ( '<STR_LIT>' ) , <EOL> c . get ( '<STR_LIT>' ) <EOL> ) for c in clients ] <EOL> def get ( self , client_id , json = False ) : <EOL> c = self . client . registration . get ( client_id ) <EOL> if json : <EOL> return c <EOL> return utils . ClientObject ( <EOL> c . get ( '<STR_LIT>' , { } ) . get ( '<STR_LIT>' ) , <EOL> c . get ( '<STR_LIT>' , { } ) . get ( '<STR_LIT>' ) , <EOL> c . get ( '<STR_LIT>' ) ) <EOL> def delete ( self , client_id ) : <EOL> return self . client . registration . delete ( client_id ) <EOL> class Backup ( object ) : <EOL> def __init__ ( self , request ) : <EOL> self . request = request <EOL> self . client = client ( request ) <EOL> def list ( self , json = False , limit = <NUM_LIT> , offset = <NUM_LIT:0> , search = None ) : <EOL> if search : <EOL> search = { "<STR_LIT>" : [ { "<STR_LIT>" : search } , ] , } <EOL> backups = self . client . backups . list ( limit = limit , <EOL> offset = offset , <EOL> search = search ) <EOL> if json : <EOL> return backups <EOL> return [ utils . BackupObject ( <EOL> backup_id = b . get ( '<STR_LIT>' ) , <EOL> action = b . get ( '<STR_LIT>' , { } ) . get ( '<STR_LIT:action>' ) , <EOL> time_stamp = b . get ( '<STR_LIT>' , { } ) . get ( '<STR_LIT>' ) , <EOL> backup_name = b . get ( '<STR_LIT>' , { } ) . get ( '<STR_LIT>' ) , <EOL> backup_media = b . get ( '<STR_LIT>' , { } ) . get ( '<STR_LIT>' ) , <EOL> path_to_backup = b . get ( '<STR_LIT>' , { } ) . get ( '<STR_LIT>' ) , <EOL> hostname = b . get ( '<STR_LIT>' , { } ) . get ( '<STR_LIT>' ) , <EOL> container = b . get ( '<STR_LIT>' , { } ) . get ( '<STR_LIT>' ) , <EOL> level = b . get ( '<STR_LIT>' , { } ) . get ( '<STR_LIT>' ) , <EOL> curr_backup_level = b . get ( '<STR_LIT>' , { } ) . get ( <EOL> '<STR_LIT>' ) , <EOL> encrypted = b . get ( '<STR_LIT>' , { } ) . get ( '<STR_LIT>' ) , <EOL> total_broken_links = b . get ( '<STR_LIT>' , { } ) . get ( <EOL> '<STR_LIT>' ) , <EOL> excluded_files = b . get ( '<STR_LIT>' , { } ) . get ( '<STR_LIT>' ) , <EOL> storage = b . get ( '<STR_LIT>' , { } ) . get ( '<STR_LIT>' ) , <EOL> ssh_host = b . get ( '<STR_LIT>' , { } ) . get ( '<STR_LIT>' ) , <EOL> ssh_key = b . get ( '<STR_LIT>' , { } ) . get ( '<STR_LIT>' ) , <EOL> ssh_username = b . get ( '<STR_LIT>' , { } ) . get ( '<STR_LIT>' ) , <EOL> ssh_port = b . get ( '<STR_LIT>' , { } ) . get ( '<STR_LIT>' ) , <EOL> mode = b . get ( '<STR_LIT>' , { } ) . get ( '<STR_LIT>' ) , <EOL> ) for b in backups ] <EOL> def get ( self , backup_id , json = False ) : <EOL> search = { "<STR_LIT>" : [ { "<STR_LIT>" : backup_id } , ] , } <EOL> b = self . client . backups . list ( limit = <NUM_LIT:1> , search = search ) <EOL> b = b [ <NUM_LIT:0> ] <EOL> if json : <EOL> return b <EOL> return utils . BackupObject ( <EOL> backup_id = b . get ( '<STR_LIT>' ) , <EOL> action = b . get ( '<STR_LIT>' , { } ) . get ( '<STR_LIT:action>' ) , <EOL> time_stamp = b . get ( '<STR_LIT>' , { } ) . get ( '<STR_LIT>' ) , <EOL> backup_name = b . get ( '<STR_LIT>' , { } ) . get ( '<STR_LIT>' ) , <EOL> backup_media = b . get ( '<STR_LIT>' , { } ) . get ( '<STR_LIT>' ) , <EOL> path_to_backup = b . get ( '<STR_LIT>' , { } ) . get ( '<STR_LIT>' ) , <EOL> hostname = b . get ( '<STR_LIT>' , { } ) . get ( '<STR_LIT>' ) , <EOL> container = b . get ( '<STR_LIT>' , { } ) . get ( '<STR_LIT>' ) , <EOL> level = b . get ( '<STR_LIT>' , { } ) . get ( '<STR_LIT>' ) , <EOL> curr_backup_level = b . get ( '<STR_LIT>' , { } ) . get ( <EOL> '<STR_LIT>' ) , <EOL> encrypted = b . get ( '<STR_LIT>' , { } ) . get ( '<STR_LIT>' ) , <EOL> total_broken_links = b . get ( '<STR_LIT>' , { } ) . get ( <EOL> '<STR_LIT>' ) , <EOL> excluded_files = b . get ( '<STR_LIT>' , { } ) . get ( '<STR_LIT>' ) , <EOL> storage = b . get ( '<STR_LIT>' , { } ) . get ( '<STR_LIT>' ) , <EOL> ssh_host = b . get ( '<STR_LIT>' , { } ) . get ( '<STR_LIT>' ) , <EOL> ssh_key = b . get ( '<STR_LIT>' , { } ) . get ( '<STR_LIT>' ) , <EOL> ssh_username = b . get ( '<STR_LIT>' , { } ) . get ( '<STR_LIT>' ) , <EOL> ssh_port = b . get ( '<STR_LIT>' , { } ) . get ( '<STR_LIT>' ) , <EOL> mode = b . get ( '<STR_LIT>' , { } ) . get ( '<STR_LIT>' ) , <EOL> ) <EOL> def restore ( self , data ) : <EOL> backup = self . get ( data [ '<STR_LIT>' ] ) <EOL> client_id = data [ '<STR_LIT>' ] <EOL> name = "<STR_LIT>" . format ( backup . backup_name , client_id ) <EOL> iso_date = utils . timestamp_to_iso ( backup . time_stamp ) <EOL> action = { <EOL> '<STR_LIT:action>' : '<STR_LIT>' , <EOL> '<STR_LIT>' : backup . backup_name , <EOL> '<STR_LIT>' : data [ '<STR_LIT:path>' ] , <EOL> '<STR_LIT>' : backup . container , <EOL> '<STR_LIT>' : backup . hostname , <EOL> '<STR_LIT>' : backup . storage , <EOL> '<STR_LIT>' : iso_date <EOL> } <EOL> if backup . storage == '<STR_LIT>' : <EOL> action [ '<STR_LIT>' ] = backup . ssh_host <EOL> action [ '<STR_LIT>' ] = backup . ssh_key <EOL> action [ '<STR_LIT>' ] = backup . ssh_username <EOL> action [ '<STR_LIT>' ] = backup . ssh_port <EOL> action_id = Action ( self . request ) . create ( action ) <EOL> job = { <EOL> '<STR_LIT>' : [ { <EOL> '<STR_LIT>' : action_id , <EOL> '<STR_LIT>' : action <EOL> } ] , <EOL> '<STR_LIT>' : client_id , <EOL> '<STR_LIT:description>' : name , <EOL> '<STR_LIT>' : { } <EOL> } <EOL> job_id = self . client . jobs . create ( job ) <EOL> return Job ( self . request ) . start ( job_id ) </s>
