<s> from libcloud . common . base import ConnectionUserAndKey , BaseDriver <EOL> from libcloud . backup . types import BackupTargetType <EOL> __all__ = [ <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' , <EOL> '<STR_LIT>' <EOL> ] <EOL> class BackupTarget ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , id , name , address , type , driver , extra = None ) : <EOL> """<STR_LIT>""" <EOL> self . id = str ( id ) if id else None <EOL> self . name = name <EOL> self . address = address <EOL> self . type = type <EOL> self . driver = driver <EOL> self . extra = extra or { } <EOL> def update ( self , name = None , address = None , extra = None ) : <EOL> return self . driver . update_target ( target = self , <EOL> name = name , <EOL> address = address , <EOL> extra = extra ) <EOL> def delete ( self ) : <EOL> return self . driver . delete_target ( target = self ) <EOL> def _get_numeric_id ( self ) : <EOL> target_id = self . id <EOL> if target_id . isdigit ( ) : <EOL> target_id = int ( target_id ) <EOL> return target_id <EOL> def __repr__ ( self ) : <EOL> return ( '<STR_LIT>' <EOL> '<STR_LIT>' % <EOL> ( self . id , self . name , self . address , <EOL> self . type , self . driver . name ) ) <EOL> class BackupTargetJob ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , id , status , progress , target , driver , extra = None ) : <EOL> """<STR_LIT>""" <EOL> self . id = str ( id ) if id else None <EOL> self . status = status <EOL> self . progress = progress <EOL> self . target = target <EOL> self . driver = driver <EOL> self . extra = extra or { } <EOL> def cancel ( self ) : <EOL> return self . driver . cancel_target_job ( job = self ) <EOL> def suspend ( self ) : <EOL> return self . driver . suspend_target_job ( job = self ) <EOL> def resume ( self ) : <EOL> return self . driver . resume_target_job ( job = self ) <EOL> def __repr__ ( self ) : <EOL> return ( '<STR_LIT>' <EOL> '<STR_LIT>' % <EOL> ( self . id , self . status , self . progress , <EOL> self . target . id , self . driver . name ) ) <EOL> class BackupTargetRecoveryPoint ( object ) : <EOL> """<STR_LIT>""" <EOL> def __init__ ( self , id , date , target , driver , extra = None ) : <EOL> """<STR_LIT>""" <EOL> self . id = str ( id ) if id else None <EOL> self . date = date <EOL> self . target = target <EOL> self . driver = driver <EOL> self . extra = extra or { } <EOL> def recover ( self , path = None ) : <EOL> """<STR_LIT>""" <EOL> return self . driver . recover_target ( target = self . target , <EOL> recovery_point = self , path = path ) <EOL> def recover_to ( self , recovery_target , path = None ) : <EOL> """<STR_LIT>""" <EOL> return self . driver . recover_target_out_of_place ( <EOL> target = self . target , <EOL> recovery_point = self , <EOL> recovery_target = recovery_target , <EOL> path = path ) <EOL> def __repr__ ( self ) : <EOL> return ( '<STR_LIT>' <EOL> '<STR_LIT>' % <EOL> ( self . id , self . date , <EOL> self . target . id , self . driver . name ) ) <EOL> class BackupDriver ( BaseDriver ) : <EOL> """<STR_LIT>""" <EOL> connectionCls = ConnectionUserAndKey <EOL> name = None <EOL> website = None <EOL> def __init__ ( self , key , secret = None , secure = True , host = None , port = None , <EOL> ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> super ( BackupDriver , self ) . __init__ ( key = key , secret = secret , <EOL> secure = secure , host = host , port = port , <EOL> ** kwargs ) <EOL> def get_supported_target_types ( self ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( <EOL> '<STR_LIT>' ) <EOL> def list_targets ( self ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( <EOL> '<STR_LIT>' ) <EOL> def create_target ( self , name , address , <EOL> type = BackupTargetType . VIRTUAL , extra = None ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( <EOL> '<STR_LIT>' ) <EOL> def create_target_from_node ( self , node , type = BackupTargetType . VIRTUAL , <EOL> extra = None ) : <EOL> """<STR_LIT>""" <EOL> return self . create_target ( name = node . name , <EOL> address = node . public_ips [ <NUM_LIT:0> ] , <EOL> type = type , <EOL> extra = None ) <EOL> def create_target_from_storage_container ( self , container , <EOL> type = BackupTargetType . OBJECT , <EOL> extra = None ) : <EOL> """<STR_LIT>""" <EOL> return self . create_target ( name = container . name , <EOL> address = container . get_cdn_url ( ) , <EOL> type = type , <EOL> extra = None ) <EOL> def update_target ( self , target , name , address , extra ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( <EOL> '<STR_LIT>' ) <EOL> def delete_target ( self , target ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( <EOL> '<STR_LIT>' ) <EOL> def list_recovery_points ( self , target , start_date = None , end_date = None ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( <EOL> '<STR_LIT>' ) <EOL> def recover_target ( self , target , recovery_point , path = None ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( <EOL> '<STR_LIT>' ) <EOL> def recover_target_out_of_place ( self , target , recovery_point , <EOL> recovery_target , path = None ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( <EOL> '<STR_LIT>' ) <EOL> def get_target_job ( self , target , id ) : <EOL> """<STR_LIT>""" <EOL> jobs = self . list_target_jobs ( target ) <EOL> return list ( filter ( lambda x : x . id == id , jobs ) ) [ <NUM_LIT:0> ] <EOL> def list_target_jobs ( self , target ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( <EOL> '<STR_LIT>' ) <EOL> def create_target_job ( self , target , extra = None ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( <EOL> '<STR_LIT>' ) <EOL> def resume_target_job ( self , job ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( <EOL> '<STR_LIT>' ) <EOL> def suspend_target_job ( self , job ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( <EOL> '<STR_LIT>' ) <EOL> def cancel_target_job ( self , job ) : <EOL> """<STR_LIT>""" <EOL> raise NotImplementedError ( <EOL> '<STR_LIT>' ) </s>
