<s> from cloudferry . lib . os import clients <EOL> from cloudferry . lib . os . discovery import keystone <EOL> from cloudferry . lib . os . migrate import base <EOL> class CreateTenant ( base . ObjectTask ) : <EOL> default_provides = [ '<STR_LIT>' ] <EOL> def __init__ ( self , tenant , config , migration ) : <EOL> super ( CreateTenant , self ) . __init__ ( tenant ) <EOL> self . config = config <EOL> self . migration = migration <EOL> self . created_tenant = None <EOL> @ property <EOL> def dst_identity ( self ) : <EOL> cloud = self . config . clouds [ self . migration . destination ] <EOL> return clients . identity_client ( cloud ) <EOL> def migrate ( self , * args , ** kwargs ) : <EOL> source = self . src_object <EOL> dst_cloud = self . config . clouds [ self . migration . destination ] <EOL> self . created_tenant = self . dst_identity . tenants . create ( <EOL> source . name , description = source . description , <EOL> enabled = source . enabled ) <EOL> destination = keystone . Tenant . load_from_cloud ( <EOL> dst_cloud , self . created_tenant ) <EOL> return [ destination ] <EOL> def revert ( self , * args , ** kwargs ) : <EOL> if self . created_tenant is not None : <EOL> self . dst_identity . tenants . delete ( self . created_tenant ) <EOL> class TenantMigrationFlowFactory ( base . MigrationFlowFactory ) : <EOL> migrated_class = keystone . Tenant <EOL> def create_flow ( self , config , migration , obj ) : <EOL> return [ <EOL> CreateTenant ( obj , config , migration ) , <EOL> base . RememberMigration ( obj ) , <EOL> ] </s>
