Search code examples
openstack

Is there a way to create openstack user/account programmatically via some Rest API?


I know we have a web based GUI and a console client to create a user or account and create instances of other openstack components. Also there is rest api that allows you to get token from keystone and authenticate with other components.

But is there a way to CREATE a user or account programmatically through some rest api or sdk and then get the endpoints or others credentials accordingly?


Solution

  • One of the primary reasons people use OpenStack is because it provides a suite of REST APIs to manage everything. It's very common for people to never interact with the web ui at all.

    Absolutely any action that you accomplish using the web interface (or the command line tools) is implemented use the REST APIs.

    User and project management is handled through the Identity API. You can find complete API documentation here:

    There are Python SDKs available for most of the services. The openstacksdk module provides a high level interface to many common OpenStack services.

    Using the openstacksdk, creating a user might look like:

    >>> import openstack
    >>> cloud = openstack.connect(cloud='mycloud')
    >>> user = cloud.create_user('example-user', domain_id='default')
    

    (This example assumes you have a cloud named mycloud defined your clouds.yaml file).