Skip to content

Instantly share code, notes, and snippets.

@alunux
Created November 8, 2018 10:18
Show Gist options
  • Save alunux/359e96b1c7ef2a77ff663af9507adfd8 to your computer and use it in GitHub Desktop.
Save alunux/359e96b1c7ef2a77ff663af9507adfd8 to your computer and use it in GitHub Desktop.
from keystoneauth1.identity import v3
from keystoneauth1 import session
from keystoneclient.v3 import client, roles, users
auth = v3.Password(
auth_url='http://HOST:5000/v3',
user_domain_name='DOMAIN',
project_domain_name='DOMAIN',
project_name='PROJECT',
username='USER',
password='PASS')
sess = session.Session(auth=auth)
keystone = client.Client(session=sess)
user_id = 'f1dc6f50802949f78c05186694c221f4'
domain_id = 'b6a2e493caab47b187bbcc529ae23c3c'
role_name = 'pengguna'
roleman = roles.RoleManager(keystone)
role = roleman.create(name=role_name, domain=domain_id)
roleman.grant(role, user=user_id, domain=domain_id)
check_role = roleman.check(role, user=user_id, domain=domain_id)
print(check_role)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment