<s> from cloudferry . lib . base . action import action <EOL> from cloudferry . lib . utils import log <EOL> from cloudferry . lib . utils import utils as utl <EOL> LOG = log . getLogger ( __name__ ) <EOL> class CheckConfigQuotaNeutron ( action . Action ) : <EOL> """<STR_LIT>""" <EOL> def run ( self , ** kwargs ) : <EOL> src_cloud = self . src_cloud <EOL> dst_cloud = self . dst_cloud <EOL> network_src = src_cloud . resources [ utl . NETWORK_RESOURCE ] <EOL> identity_dst = dst_cloud . resources [ utl . IDENTITY_RESOURCE ] <EOL> network_dst = dst_cloud . resources [ utl . NETWORK_RESOURCE ] <EOL> search_opts_tenant = kwargs . get ( '<STR_LIT>' , { } ) <EOL> tenants_src = self . get_src_tenants ( search_opts_tenant ) <EOL> list_quotas = network_src . list_quotas ( ) <EOL> tenants_without_quotas = self . get_tenants_without_quotas ( tenants_src , <EOL> list_quotas ) <EOL> if not tenants_without_quotas : <EOL> LOG . info ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> LOG . info ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> LOG . info ( "<STR_LIT>" ) <EOL> return <EOL> LOG . info ( "<STR_LIT>" <EOL> "<STR_LIT>" ) <EOL> quot = network_src . show_quota ( tenants_without_quotas [ <NUM_LIT:0> ] ) <EOL> dst_temp_tenant = identity_dst . create_tenant ( "<STR_LIT>" ) <EOL> quot_default_dst = network_dst . show_quota ( dst_temp_tenant . id ) <EOL> is_configs_different = False <EOL> identity_dst . delete_tenant ( dst_temp_tenant ) <EOL> for item_quot , val_quot in quot . iteritems ( ) : <EOL> if val_quot != quot_default_dst [ item_quot ] : <EOL> is_configs_different = True <EOL> LOG . info ( "<STR_LIT>" <EOL> "<STR_LIT>" , item_quot , val_quot , <EOL> quot_default_dst [ item_quot ] ) <EOL> if not is_configs_different : <EOL> LOG . info ( "<STR_LIT>" ) <EOL> @ staticmethod <EOL> def get_tenants_without_quotas ( tenants_src , list_quotas ) : <EOL> tenants_ids = tenants_src . keys ( ) <EOL> quotas_ids_tenants = [ quota [ "<STR_LIT>" ] for quota in list_quotas ] <EOL> return list ( set ( tenants_ids ) - set ( quotas_ids_tenants ) ) <EOL> def get_src_tenants ( self , search_opts ) : <EOL> identity_src = self . src_cloud . resources [ utl . IDENTITY_RESOURCE ] <EOL> if search_opts . get ( '<STR_LIT>' ) : <EOL> filter_tenants_ids_list = search_opts [ '<STR_LIT>' ] <EOL> tenants = [ identity_src . keystone_client . tenants . find ( id = tnt_id ) for <EOL> tnt_id in filter_tenants_ids_list ] <EOL> else : <EOL> tenants = identity_src . get_tenants_list ( ) <EOL> tenants_dict = { tenant . id : tenant . name for tenant in tenants } <EOL> return tenants_dict </s>
