Disassemble the admin – openrc. Sh

If you use the command line tool to query OpenStack cloud systems, you must obtain appropriate authentication credentials.

To obtain the cli client authentication certificate, use the OpenStack control panel to log in to the Dashboard and download the OpenStack RC file in the upper right corner.

Use this method to generate files that can be sourced in shell scripts to fill in the environment variables needed by the command line tool to know where the service endpoint and authentication information are.

Users who log in to the control panel will specify the name of the OpenRC file, for example, demo-openrc.sh. If you log in as an administrator, the file name is admin-openrc.sh.

The following uses the admin user as an example to describe the admin-openrc.sh generated.

#! /usr/bin/env bash
# To use an OpenStack cloud you need to authenticate against the Identity
# service named keystone, which returns a **Token** and **Service Catalog**.
# The catalog contains the endpoints for all services the user/tenant has
# access to - such as Compute, Image Service, Identity, Object Storage, Block
# Storage, and Networking (code-named nova, glance, keystone, swift,
# cinder, and neutron).
To use the OpenStack cloud system, you need to be authenticated by the Keystone Identity Service.
Keystone returns a token and directory of services after successful authentication.
# Compute, Image Service, Identity, Object Storage, Block Storage and Networking (code-named nova,glance, keystone, swift,cinder, and neutron)

# *NOTE*: Using the 3 *Identity API* does not necessarily mean any other
# OpenStack API is version 3. For example, your cloud provider may implement
# Image API v1.1, Block Storage API v2, and Compute API v2.0. OS_AUTH_URL is
# only for the Identity API served through keystone.
# * Note * : Using the 3.0 version of the * certified API* does not mean that any other OpenStack API is 3.0.
For example, your cloud provider might use the Image API V1.1, Block Storage API v2, and Compute API V2.0.
# OS_AUTH_URL applies only to the Identity API provided through Keystone.
exportOS_AUTH_URL = http://192.168.1.200:5000/v3# With the addition of Keystone we have standardized on the term **project**
# as the entity that owns the resources.
# In Keystone Identity Services, we have normalized the meaning of the term ** tenant ** to the entity that owns the resource.
export OS_PROJECT_ID=afeabb49b7a1491cad684fb09b563ecb
export OS_PROJECT_NAME="admin"
export OS_USER_DOMAIN_NAME="Default"
if [ -z "$OS_USER_DOMAIN_NAME" ]; then unset OS_USER_DOMAIN_NAME; fi
export OS_PROJECT_DOMAIN_ID="default"
if [ -z "$OS_PROJECT_DOMAIN_ID" ]; then unset OS_PROJECT_DOMAIN_ID; fi

# unset v2.0 items in case set
# v2.0 item, if set, is unset in the case set.
unset OS_TENANT_ID
unset OS_TENANT_NAME

# In addition to the owning entity (tenant), OpenStack stores the entity
# performing the action as the **user**.
Except for the entities (tenants) that own the resources, OpenStack operates on the entities as users ** *.
export OS_USERNAME="admin"

# With Keystone you pass the keystone password.
The Keystone password is required to use the Keystone service.
# This is a recommended approach that does not save the password in clear text. Only when you source or run a script you are prompted for a password,
# Then save the input in the environment variable OS_PASSWORD.
# This requires a manual interaction. If you need to set non-interactive operations, you can store the input directly in the script, but you must configure the security and permissions of the corresponding script file.
echo "Please enter your OpenStack Password for project $OS_PROJECT_NAME as user $OS_USERNAME:"
read -sr OS_PASSWORD_INPUT
export OS_PASSWORD=$OS_PASSWORD_INPUT

# If your configuration has multiple regions, we set that information here.
# OS_REGION_NAME is optional and only valid in certain environments.
If you have more than one domain in your configuration, set it here.
# OS_REGION_NAME is optional and only available in the appropriate environment.
export OS_REGION_NAME="RegionOne"

# Don't leave a blank variable, unset it if it was empty
Do not leave an empty variable; if it is empty, unset it
if [ -z "$OS_REGION_NAME" ]; then unset OS_REGION_NAME; fi
export OS_INTERFACE=public
export OS_IDENTITY_API_VERSION=3
Copy the code