#NEWLINE# @ logging . log_task_wrapper ( LOG . info , _ ( 'Enter context: `users`' ) ) #NEWLINE# def setup( self ) : #NEWLINE# #INDENT# 'Create tenants and users, using the broker pattern.' #NEWLINE# self . context [ 'users' ] = [ ] #NEWLINE# self . context [ 'tenants' ] = { #NEWLINE# #INDENT# #NEWLINE# #UNINDENT# } #NEWLINE# threads = self . config [ 'resource_management_workers' ] #NEWLINE# LOG . debug ( ( 'Creating %(tenants)d tenants using %(threads)s threads' % { #NEWLINE# #INDENT# 'tenants' : self . config [ 'tenants' ] , #NEWLINE# 'threads' : threads , #NEWLINE# #UNINDENT# } ) ) #NEWLINE# self . context [ 'tenants' ] = self . _create_tenants ( ) #NEWLINE# if ( len ( self . context [ 'tenants' ] ) < self . config [ 'tenants' ] ) : #NEWLINE# #INDENT# raise exceptions . ContextSetupFailure ( ctx_name = self . get_name ( ) , msg = _ ( 'Failed to create the requested number of tenants.' ) ) #NEWLINE# #UNINDENT# users_num = ( self . config [ 'users_per_tenant' ] * self . config [ 'tenants' ] ) #NEWLINE# LOG . debug ( ( 'Creating %(users)d users using %(threads)s threads' % { #NEWLINE# #INDENT# 'users' : users_num , #NEWLINE# 'threads' : self , #NEWLINE# #UNINDENT# } ) ) #NEWLINE# self . context [ 'users' ] = self . _create_users ( ) #NEWLINE# if ( len ( self . context [ 'users' ] ) < users_num ) : #NEWLINE# #INDENT# raise exceptions . ContextSetupFailure ( ctx_name = self . get_name ( ) , msg = _ ( 'Failed to create the requested number of users.' ) )