<s> import random <EOL> from rally . plugins . openstack import scenario <EOL> from rally . task import atomic <EOL> class QuotasScenario ( scenario . OpenStackScenario ) : <EOL> """<STR_LIT>""" <EOL> @ atomic . action_timer ( "<STR_LIT>" ) <EOL> def _update_quotas ( self , component , tenant_id , max_quota = <NUM_LIT> , <EOL> quota_update_fn = None ) : <EOL> """<STR_LIT>""" <EOL> quotas = self . _generate_quota_values ( max_quota , component ) <EOL> if quota_update_fn : <EOL> return quota_update_fn ( tenant_id , ** quotas ) <EOL> return self . admin_clients ( component ) . quotas . update ( tenant_id , ** quotas ) <EOL> @ atomic . action_timer ( "<STR_LIT>" ) <EOL> def _delete_quotas ( self , component , tenant_id ) : <EOL> """<STR_LIT>""" <EOL> self . admin_clients ( component ) . quotas . delete ( tenant_id ) <EOL> def _generate_quota_values ( self , max_quota , component ) : <EOL> quotas = { } <EOL> if component == "<STR_LIT>" : <EOL> quotas = { <EOL> "<STR_LIT>" : random . randint ( - <NUM_LIT:1> , max_quota ) , <EOL> "<STR_LIT>" : random . randint ( - <NUM_LIT:1> , max_quota ) , <EOL> "<STR_LIT>" : random . randint ( - <NUM_LIT:1> , max_quota ) , <EOL> "<STR_LIT>" : random . randint ( - <NUM_LIT:1> , max_quota ) , <EOL> "<STR_LIT>" : random . randint ( - <NUM_LIT:1> , max_quota ) , <EOL> "<STR_LIT>" : random . randint ( - <NUM_LIT:1> , max_quota ) , <EOL> "<STR_LIT>" : random . randint ( - <NUM_LIT:1> , max_quota ) , <EOL> "<STR_LIT>" : random . randint ( - <NUM_LIT:1> , max_quota ) <EOL> } <EOL> elif component == "<STR_LIT>" : <EOL> quotas = { <EOL> "<STR_LIT>" : random . randint ( - <NUM_LIT:1> , max_quota ) , <EOL> "<STR_LIT>" : random . randint ( - <NUM_LIT:1> , max_quota ) , <EOL> "<STR_LIT>" : random . randint ( - <NUM_LIT:1> , max_quota ) , <EOL> } <EOL> elif component == "<STR_LIT>" : <EOL> quota = { } <EOL> for key in [ "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT:port>" , "<STR_LIT>" , "<STR_LIT>" , <EOL> "<STR_LIT>" , "<STR_LIT>" ] : <EOL> quota [ key ] = random . randint ( - <NUM_LIT:1> , max_quota ) <EOL> quotas = { "<STR_LIT:body>" : { "<STR_LIT>" : quota } } <EOL> return quotas </s>
