<s> from rally . common import logging <EOL> from rally . plugins . openstack import scenario <EOL> from rally . plugins . openstack . scenarios . keystone import utils as kutils <EOL> from rally . task import validation <EOL> class KeystoneBasic ( kutils . KeystoneScenario ) : <EOL> """<STR_LIT>""" <EOL> @ validation . required_openstack ( admin = True ) <EOL> @ scenario . configure ( context = { "<STR_LIT>" : [ "<STR_LIT>" ] } ) <EOL> @ logging . log_deprecated_args ( <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , [ "<STR_LIT>" ] , once = True ) <EOL> def create_user ( self , name_length = <NUM_LIT:10> , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> self . _user_create ( ** kwargs ) <EOL> @ validation . required_openstack ( admin = True ) <EOL> @ scenario . configure ( context = { "<STR_LIT>" : [ "<STR_LIT>" ] } ) <EOL> @ logging . log_deprecated_args ( <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , [ "<STR_LIT>" ] , once = True ) <EOL> def create_delete_user ( self , name_length = <NUM_LIT:10> , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> user = self . _user_create ( ** kwargs ) <EOL> self . _resource_delete ( user ) <EOL> @ validation . required_openstack ( admin = True ) <EOL> @ scenario . configure ( context = { "<STR_LIT>" : [ "<STR_LIT>" ] } ) <EOL> def create_user_set_enabled_and_delete ( self , enabled = True , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> user = self . _user_create ( enabled = enabled , ** kwargs ) <EOL> self . _update_user_enabled ( user , not enabled ) <EOL> self . _resource_delete ( user ) <EOL> @ validation . required_openstack ( admin = True ) <EOL> @ scenario . configure ( context = { "<STR_LIT>" : [ "<STR_LIT>" ] } ) <EOL> @ logging . log_deprecated_args ( <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , [ "<STR_LIT>" ] , once = True ) <EOL> def create_tenant ( self , name_length = <NUM_LIT:10> , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> self . _tenant_create ( ** kwargs ) <EOL> @ validation . number ( "<STR_LIT>" , minval = <NUM_LIT:1> ) <EOL> @ validation . required_openstack ( admin = True ) <EOL> @ scenario . configure ( context = { "<STR_LIT>" : [ "<STR_LIT>" ] } ) <EOL> @ logging . log_deprecated_args ( <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , [ "<STR_LIT>" ] , once = True ) <EOL> def create_tenant_with_users ( self , users_per_tenant , name_length = <NUM_LIT:10> , <EOL> ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> tenant = self . _tenant_create ( ** kwargs ) <EOL> self . _users_create ( tenant , users_per_tenant = users_per_tenant ) <EOL> @ validation . required_openstack ( admin = True ) <EOL> @ scenario . configure ( context = { "<STR_LIT>" : [ "<STR_LIT>" ] } ) <EOL> @ logging . log_deprecated_args ( <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , [ "<STR_LIT>" ] , once = True ) <EOL> def create_and_list_users ( self , name_length = <NUM_LIT:10> , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> self . _user_create ( ** kwargs ) <EOL> self . _list_users ( ) <EOL> @ validation . required_openstack ( admin = True ) <EOL> @ scenario . configure ( context = { "<STR_LIT>" : [ "<STR_LIT>" ] } ) <EOL> @ logging . log_deprecated_args ( <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , [ "<STR_LIT>" ] , once = True ) <EOL> def create_and_list_tenants ( self , name_length = <NUM_LIT:10> , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> self . _tenant_create ( ** kwargs ) <EOL> self . _list_tenants ( ) <EOL> @ validation . required_openstack ( admin = True , users = True ) <EOL> @ scenario . configure ( context = { "<STR_LIT>" : [ "<STR_LIT>" ] } ) <EOL> def add_and_remove_user_role ( self ) : <EOL> """<STR_LIT>""" <EOL> tenant_id = self . context [ "<STR_LIT>" ] [ "<STR_LIT:id>" ] <EOL> user_id = self . context [ "<STR_LIT:user>" ] [ "<STR_LIT:id>" ] <EOL> role = self . _role_create ( ) <EOL> self . _role_add ( user_id , role , tenant_id ) <EOL> self . _role_remove ( user_id , role , tenant_id ) <EOL> @ validation . required_openstack ( admin = True ) <EOL> @ scenario . configure ( context = { "<STR_LIT>" : [ "<STR_LIT>" ] } ) <EOL> def create_and_delete_role ( self ) : <EOL> """<STR_LIT>""" <EOL> role = self . _role_create ( ) <EOL> self . _resource_delete ( role ) <EOL> @ validation . required_openstack ( admin = True , users = True ) <EOL> @ scenario . configure ( context = { "<STR_LIT>" : [ "<STR_LIT>" ] } ) <EOL> def create_add_and_list_user_roles ( self ) : <EOL> """<STR_LIT>""" <EOL> tenant_id = self . context [ "<STR_LIT>" ] [ "<STR_LIT:id>" ] <EOL> user_id = self . context [ "<STR_LIT:user>" ] [ "<STR_LIT:id>" ] <EOL> role = self . _role_create ( ) <EOL> self . _role_add ( user_id , role , tenant_id ) <EOL> self . _list_roles_for_user ( user_id , tenant_id ) <EOL> @ validation . required_openstack ( admin = True ) <EOL> @ scenario . configure ( context = { "<STR_LIT>" : [ "<STR_LIT>" ] } ) <EOL> def get_entities ( self , service_name = "<STR_LIT>" ) : <EOL> """<STR_LIT>""" <EOL> tenant = self . _tenant_create ( ) <EOL> user = self . _user_create ( ) <EOL> role = self . _role_create ( ) <EOL> self . _get_tenant ( tenant . id ) <EOL> self . _get_user ( user . id ) <EOL> self . _get_role ( role . id ) <EOL> if service_name is None : <EOL> service = self . _service_create ( ) <EOL> else : <EOL> service = self . _get_service_by_name ( service_name ) <EOL> self . _get_service ( service . id ) <EOL> @ validation . required_openstack ( admin = True ) <EOL> @ logging . log_deprecated_args ( <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , [ "<STR_LIT:name>" ] ) <EOL> @ scenario . configure ( context = { "<STR_LIT>" : [ "<STR_LIT>" ] } ) <EOL> def create_and_delete_service ( self , name = None , service_type = None , <EOL> description = None ) : <EOL> """<STR_LIT>""" <EOL> service = self . _service_create ( service_type , description ) <EOL> self . _delete_service ( service . id ) <EOL> @ validation . required_openstack ( admin = True ) <EOL> @ scenario . configure ( context = { "<STR_LIT>" : [ "<STR_LIT>" ] } ) <EOL> @ logging . log_deprecated_args ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" , "<STR_LIT>" , [ "<STR_LIT>" ] , once = True ) <EOL> def create_update_and_delete_tenant ( self , name_length = None , ** kwargs ) : <EOL> """<STR_LIT>""" <EOL> tenant = self . _tenant_create ( ** kwargs ) <EOL> self . _update_tenant ( tenant ) <EOL> self . _resource_delete ( tenant ) <EOL> @ validation . required_openstack ( admin = True ) <EOL> @ scenario . configure ( context = { "<STR_LIT>" : [ "<STR_LIT>" ] } ) <EOL> @ logging . log_deprecated_args ( <EOL> "<STR_LIT>" <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , [ "<STR_LIT>" , "<STR_LIT>" ] , once = True ) <EOL> def create_user_update_password ( self , name_length = None , <EOL> password_length = None ) : <EOL> """<STR_LIT>""" <EOL> password = self . generate_random_name ( ) <EOL> user = self . _user_create ( ) <EOL> self . _update_user_password ( user . id , password ) <EOL> @ validation . required_openstack ( admin = True ) <EOL> @ logging . log_deprecated_args ( <EOL> "<STR_LIT>" , <EOL> "<STR_LIT>" , [ "<STR_LIT:name>" ] ) <EOL> @ scenario . configure ( context = { "<STR_LIT>" : [ "<STR_LIT>" ] } ) <EOL> def create_and_list_services ( self , name = None , service_type = None , <EOL> description = None ) : <EOL> """<STR_LIT>""" <EOL> self . _service_create ( service_type , description ) <EOL> self . _list_services ( ) <EOL> @ validation . required_openstack ( users = True ) <EOL> @ scenario . configure ( context = { "<STR_LIT>" : [ "<STR_LIT>" ] } ) <EOL> def create_and_list_ec2credentials ( self ) : <EOL> """<STR_LIT>""" <EOL> self . _create_ec2credentials ( self . context [ "<STR_LIT:user>" ] [ "<STR_LIT:id>" ] , <EOL> self . context [ "<STR_LIT>" ] [ "<STR_LIT:id>" ] ) <EOL> self . _list_ec2credentials ( self . context [ "<STR_LIT:user>" ] [ "<STR_LIT:id>" ] ) <EOL> @ validation . required_openstack ( users = True ) <EOL> @ scenario . configure ( context = { "<STR_LIT>" : [ "<STR_LIT>" ] } ) <EOL> def create_and_delete_ec2credential ( self ) : <EOL> """<STR_LIT>""" <EOL> creds = self . _create_ec2credentials ( self . context [ "<STR_LIT:user>" ] [ "<STR_LIT:id>" ] , <EOL> self . context [ "<STR_LIT>" ] [ "<STR_LIT:id>" ] ) <EOL> self . _delete_ec2credential ( self . context [ "<STR_LIT:user>" ] [ "<STR_LIT:id>" ] , creds . access ) </s>
