我正在使用$(Build.ArtifactStagingDirectory)
keystoneclient api $(Build.BinariesDirectory)
和python绑定
将现有用户添加到具有特定角色的项目的方式是什么。
答案 0 :(得分:2)
您可以将用户添加到具有以下角色的项目中:
from keystoneauth1.identity import v3
from keystoneauth1 import session
from keystoneclient.v3 import client
# Admin credentials
AUTH_URL = 'http://192.0.0.10:35357/v3'
USER_ID = 'abd78a0b166e47eb8fe40381853f3d90'
PASSWORD = 'password'
PROJECT_ID = '5a56b817ec7342a9a6c0eea26f591621'
auth = v3.Password(auth_url=AUTH_URL, user_id=USER_ID, password=PASSWORD, project_id=PROJECT_ID)
sess = session.Session(auth=auth)
keystone = client.Client(session=sess)
# User, role and project details
ROLE_ID = '7836dac8513745a6be2c9cf5df4640c9'
USER_ID = '7b96131d69b141be8d8d6749ef0e0168'
PROJECT_ID = '121088df9f364c8a92541f969c971b3e'
keystone.roles.grant(ROLE_ID, USER_ID, PROJECT_ID)