Openstack keystone application credentials

From here: https://docs.openstack.org/keystone/queens/user/application_credentials.html

Sample python

from keystoneauth1.identity import v3
from keystoneauth1 import session
from keystoneclient import client
import os
import pprint
auth = v3.Password(auth_url=os.environ['OS_AUTH_URL'],
          username=os.environ['OS_USERNAME'],
          password=os.environ['OS_PASSWORD'],
          project_name=os.environ['OS_PROJECT_NAME'],
          user_domain_id=os.environ['OS_USER_DOMAIN_ID'],
          project_domain_id=os.environ['OS_PROJECT_DOMAIN_ID'])
sess = session.Session(auth=auth)
ks = client.Client(session=sess)
app_cred = ks.application_credentials.create(name='testcreds')
pprint.pprint(app_cred.to_dict())

Output:

{u'description': None,
 u'expires_at': None,
 u'id': u'abcd',
 u'links': {u'self': u'http://10.10.10.10:5000/v3/users/abcd/application_credentials/xyz'},
 u'name': u'testcreds',
 u'project_id': u'abcd1234',
 u'roles': [{u'domain_id': None,
             u'id': u'abcd',
             u'name': u'admin'}],
 u'secret': u'removed',
 u'unrestricted': False}

Usage:

# env | grep OS_ | wc -l
0
# openstack --os-application-credential-name testcreds --os-application-credential-secret removed --os-auth-url http://10.10.10.10:5000/v3 --os-username admin --os-user-domain-name default --os-auth-type v3applicationcredential server list

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.