Configuring an openrc.sh File
Once you have prepared your computer and installed the CLI, you need to tell the CLI which allocation, region and user account it is operating on. The CLI will read values from several environment variables to learn this information. The recommended way to set the values of these environment variables is by creating a shell script that you will execute before using the CLI.
The Horizon UI provides a mechanism for creating an openrc.sh
script
that assigns the appropriate value to each necessary variable.
You can create and download separate scripts for each of your allocations/regions,
making it easy to switch between them when using the CLI.
To generate one of these files, log in to the Horizon dashboard using your ACCESS credentials, then:
- In the upper left, select the desired allocation and region from the dropdown.
- On the left, expand the
Identity
section. - Select the
Application Credentials
item. - In the upper right, click
Create Application Credential
.
This will display the Create Application Credential dialog. Here you may fill out the first five items items, though changing the last three items is not recommended unless you are an expert user with specific needs.
- You must enter a name for the credential, and may optionally enter a description. It is a good practice to include identifying information such as your name and/or the allocation/region of the credential.
- You may enter a value for the credential's "secret" (a password or passphrase). If you do not enter one, a random one will be generated and displayed for you to see.
- You may select an expiration date and/or time for your credential. If you do not make a selection, the credential will expire after one day.
- When you are ready, click
Create Application Credential
.
Information about your new credential will now be displayed in a dialog. If desired, you can copy information from the dialog or generate an openrc.sh file containing that information. We recommend that you download the openrc.sh file, which contains the ID and secret:
- The credential ID will be included in the openrc.sh file and can be seen in the credential list.
- An automatically generated secret will only be shown to you once, in this dialog!
- Be sure to click
Download openrc file
, then clickClose
.
Before using the CLI you must execute this script from your Bash shell with the source <file_name>
command.
After sourcing the script, you can run the CLI using the openstack
command.
You do not need to source the script again between CLI commands.
If you wish to change to work with the CLI using a different allocation/region,
it is recommended that you do so in fresh shell to avoid issues with the environment variables.
Once you have an openrc.sh file set up,
test it out with a command like openstack flavor list
:
$ openstack flavor list
+------+--------------+---------+------+-----------+-------+-----------+
| ID | Name | RAM | Disk | Ephemeral | VCPUs | Is Public |
+------+--------------+---------+------+-----------+-------+-----------+
| 1 | m3.tiny | 3072 | 20 | 0 | 1 | False |
| 10 | g3.small | 15360 | 60 | 0 | 4 | False |
| 11 | g3.medium | 30720 | 60 | 0 | 8 | False |
| 12 | g3.large | 61440 | 60 | 0 | 16 | False |
| 13 | g3.xl | 128000 | 60 | 0 | 32 | False |
| 14 | r3.large | 512000 | 60 | 0 | 64 | False |
| 15 | r3.xl | 1024000 | 60 | 0 | 128 | False |
| 2 | m3.small | 6144 | 20 | 0 | 2 | False |
| 3 | m3.quad | 15360 | 20 | 0 | 4 | False |
| 3001 | p3.sev-small | 60000 | 60 | 0 | 8 | False |
| 4 | m3.medium | 30720 | 60 | 0 | 8 | False |
| 5 | m3.large | 61440 | 60 | 0 | 16 | False |
| 7 | m3.xl | 128000 | 60 | 0 | 32 | False |
| 8 | m3.2xl | 256000 | 60 | 0 | 64 | False |
| 9 | m3.3xl | 512000 | 60 | 0 | 128 | False |
+------+--------------+---------+------+-----------+-------+-----------+
The OpenStack client documentation
contains more information about configuring the CLI.
In addition to using environment variables,
you can specify most configuration values by adding options to the openstack
command.
There are also numerous additional environment variables that you can set to control the CLI.