OpenStack provides you the opportunity to use an API for managing your OpenStack project. For this purpose, you need certain data to authenticate via the API with your OpenStack project. You can find this data in the OpenStack Horizon web interface in a .rc file named <yourusername>-open-stack-openrc.sh, and it consists of:
- AUTH_URL
- PROJECT_ID
- PROJECT_NAME
- USER_DOMAIN_NAME
- PROJECT_DOMAIN_ID
- USERNAME
- PASSWORD (via a prompt)
- REGION_NAME
When using the OpenStack command-line tools, this file suffices. However, when using the API, you need these data in this file, which you can download as follows:
Log in to the OpenStack Horizon web interface and click on your username at the top right corner > 'OpenStack RC File v3'. This will initiate a download for <username>-open-stack-openrc.sh. Save the file in a location that you can easily access.
When you open the downloaded file with a text editor, you will find the aforementioned API data there. For using the OpenStack API, you can consult OpenStack's API documentation.
Keep in mind that Project Domain Name and Project Domain ID are mentioned as optional in the API documentation, but one of them is required. In the content of the downloaded RC file, you will find the Project Domain ID after the line 'export OS_PROJECT_DOMAIN_ID='. In the example on the page mentioned above, you would modify $OS_PROJECT_DOMAIN_NAME to $OS_PROJECT_DOMAIN_ID and then provide the relevant value, as shown below (note the scrollbar):
$ curl -v -s -X POST $OS_AUTH_URL/auth/tokens?nocatalog -H "Content-Type: application/json" -d '{ "auth": { "identity": { "methods": ["password"],"password": {"user": {"domain": {"name": "'"$OS_USER_DOMAIN_NAME"'"},"name": "'"$OS_USERNAME"'", "password": "'"$OS_PASSWORD"'"} } }, "scope": { "project": { "domain": { "name": "'"$OS_PROJECT_DOMAIN_ID"'" }, "name": "'"$OS_PROJECT_NAME"'" } } }}' \ | python -m json.tool