'Set up a test role.'

def setup_test_role(self, name=None, domain_id=None):

    params = {'name': (name or data_utils.rand_name('test_role'))}
    if domain_id:
        params['domain_id'] = domain_id
    role = self.roles_client.create_role(**params)['role']
    self.addCleanup(test_utils.call_and_ignore_notfound_exc, self.roles_client.delete_role, role['id'])
    return role
