To set the required environment variables for the OpenStack
command-line clients, you must create an environment file
called an OpenStack rc file, or openrc.sh
file. If your OpenStack
installation provides it, you can download the file from
the OpenStack dashboard as an administrative user or any
other user. This project-specific environment
file contains the credentials that all OpenStack services
use.
When you source the file, environment variables are set for your current shell. The variables enable the OpenStack client commands to communicate with the OpenStack services that run in the cloud.
Note | |
---|---|
Defining environment variables using an environment file is not a common practice on Microsoft Windows. Environment variables are usually defined in the Advanced tab of the System Properties dialog box. |
Log in to the OpenStack dashboard, choose the project for which you want to download the OpenStack RC file, and click
.On the API Access tab, click
and save the file. The filename will be of the form
wherePROJECT
-openrc.shPROJECT
is the name of the project for which you downloaded the file.Copy the
file to the computer from which you want to run OpenStack commands.PROJECT
-openrc.shFor example, copy the file to the computer from which you want to upload an image with a glance client command.
On any shell from which you want to run OpenStack commands, source the
file for the respective project.PROJECT
-openrc.shIn the following example, the
demo-openrc.sh
file is sourced for the demo project:$ source demo-openrc.sh
When you are prompted for an OpenStack password, enter the password for the user who downloaded the
file.PROJECT
-openrc.sh
Alternatively, you can create the
file from scratch, if for some reason you cannot download
the file from the dashboard.PROJECT
-openrc.sh
In a text editor, create a file named
file and add the following authentication information:PROJECT
-openrc.shexport OS_USERNAME=
username
export OS_PASSWORD=password
export OS_TENANT_NAME=projectName
export OS_AUTH_URL=https://identityHost:portNumber/v2.0
# The following lines can be omitted export OS_TENANT_ID=tenantIDString
export OS_REGION_NAME=regionName
The following example shows the information for a project called
admin
, where the OS username is alsoadmin
, and the identity host is located atcontroller
.On any shell from which you want to run OpenStack commands, source the
file for the respective project. In this example, you source thePROJECT
-openrc.shadmin-openrc.sh
file for theadmin
project:$ source admin-openrc.sh
Note | |
---|---|
You are not prompted for the password with this
method. The password lives in clear text format in the
|
When you run OpenStack client commands, you can override
some environment variable settings by using the options
that are listed at the end of the help output
of the various client commands. For example, you can override
the OS_PASSWORD
setting in the
file by specifying a password on a keystone command, as
follows:PROJECT
-openrc.sh
$ keystone --os-password PASSWORD
service-list
Where PASSWORD
is your password.