CLI Overview
The command-line interface (CLI) employs the OpenStackClient tool. This tool provides a command line client. You can access cloud services simply by running commands that make calls to the service APIs.
CLI Client Description
The OpenStackClient project is provided with a unified CLI client, so that you can make calls to desired OpenStack project APIs by running commands. Most OpenStack projects have an individual CLI client for each service. For example, the compute service is provided with the Nova CLI client. For details, see description.
Installation
Installation Description
You can install and use OpenStackClient by installing and executing the python-openstackclient plug-in. Therefore, before using the tool, ensure that python-openstackclient is running properly.
This tool can be used in all operating systems (OSs) if Python is running properly. However, the operation methods vary depending on the OS in use. The 64-bit Ubuntu 16.04 OS is recommended. The operations all use 64-bit Ubuntu 16.04 as an example.
- Update the OS.
Run the following commands to update the OS:
apt-get update
apt-get upgrade
- Install Python.
Install Python and pip based on the OS in use. Python 2.7 is supported.
Generally, Ubuntu 16.04 includes Python 2.7. If Python is not installed, perform the following steps to install it:
Run the following command to install Python:
apt-get install python
Run the following command to install Setuptools:
apt-get install python-setuptools
Run the following command to install pip:
apt-get install python-pip
(If Ubuntu supports Setuptools and pip of earlier versions, you can install them in offline mode.)
Run the following command to install Dev:
apt-get install python-dev
- Install python-openstackclient and its dependent components.
The following python-openstackclient versions are supported by default:
- python-openstackclient: 3.2.1
- python-novaclient: 6.0.2
- python-glanceclient: 2.5.0
- python-keystoneclient: 3.5.1
- python-neutronclient: 6.0.1
- python-cinderclient: 1.9.0
- python-heatclient: 1.5.1
- python-designateclient: 2.3.0
- openstacksdk: 0.9.5
- cliff: 2.2.0
- os-client-config: 1.21.1
- osc-lib: 1.1.0
-
Run the following command to install python-openstackclient using pip:
pip install python-openstackclient==3.2.1
After the installation is complete, run the following command to verify the installation:
openstack -h
Check whether the help information is displayed. The installation is successful if help information is displayed.
Other components can be installed in the same way in sequence.
Tool Configuration
- Configure OpenStackClient.
You can configure the tool either as user root or as a common user.
API calls must be made over secure networks, for example, over the VPN or tenants' Elastic Cloud Servers (ECSs), because attacks may be launched over insecure networks.
- Switch to the directory where OpenStackClient is installed and create an environment variable file, for example, novarc.
- Use a text editor to edit the environment variable file and fill in the username, password, region, IAM IP address, and port number.
An example is provided as follows:
export OS_USERNAME="user_name" export OS_USER_DOMAIN_NAME=user_domain_name #export OS_DOMAIN_NAME="domain_name" export OS_PASSWORD=password # Only change these for a different region export OS_TENANT_NAME=tenant_name export OS_PROJECT_NAME=tenant_name export OS_AUTH_URL=https://iam.example.com:443/v3 export OS_INTERFACE=public # No changes needed beyond this point export NOVA_ENDPOINT_TYPE=publicURL export OS_ENDPOINT_TYPE=publicURL export CINDER_ENDPOINT_TYPE=publicURL export OS_VOLUME_API_VERSION=2 export OS_IDENTITY_API_VERSION=3 export OS_IMAGE_API_VERSION=2
Environment variables to be configured include the username, password, IAM URL, and port number. Table 1 lists the environment variables to be configured.
Table 1 Environment variables Parameter
Description
OS_USERNAME
Specifies the username used for running commands.
This value is the username for logging in to the management console.
OS_USER_DOMAIN_NAME
Specifies the tenant name.
The value is the enterprise account used for logging in to the management console.
OS_DOMAIN_NAME
Specifies the tenant name.
OS_PASSWORD
Specifies the password used for running commands.
The value is the password used for logging in to the management console.
OS_TENANT_NAME
Specifies the tenant name used for running commands.
The value is the project name displayed on the Project List tab on the My Credential page.
OS_PROJECT_NAME
Specifies the project name used for running commands.
The value is the same as the OS_TENANT_NAME value.
OS_AUTH_URL
The parameter value is in the format of https://IAM URL:Port number/API version, for example, https://iam.example.com:443/v3.
- IAM URL: Obtain the value from Regions and Endpoints.
- Port number: 443
- API version: v3 (current)
OS_INTERFACE
Specifies the endpoint type. The value of this parameter is public.
NOVA_ENDPOINT_TYPE
Specifies the Nova endpoint type. This parameter is mandatory for running OpenStack commands. The value of this parameter is publicURL.
OS_ENDPOINT_TYPE
Specifies the OS endpoint type. This parameter is mandatory for running OpenStack commands. The value of this parameter is publicURL.
CINDER_ENDPOINT_TYPE
Specifies the Cinder endpoint type. This parameter is mandatory for running OpenStack commands. The value of this parameter is publicURL.
OS_VOLUME_API_VERSION
Specifies the Cinder API version. The value of this parameter is 2.
OS_IDENTITY_API_VERSION
Specifies the authentication API version. The value of this parameter is 3.
OS_IMAGE_API_VERISON
Specifies the Glance API version. The value of this parameter is 2.
- Run the following command to set environment variables:
source novarc
- When invoking the Keystone command lines in OpenStackClient, you need to configure OS_DOMAIN_NAME, and leave OS_TENANT_NAME and OS_PROJECT_NAME blank. To do so, run the following commands:
export OS_DOMAIN_NAME=domain_name
unset OS_TENANT_NAME
unset OS_PROJECT_NAME
When invoking commands of other services, you need to leave OS_DOMAIN_NAME blank and configure OS_TENANT_NAME and OS_PROJECT_NAME. To do so, run the following commands:
unset OS_DOMAIN_NAME
export OS_TENANT_NAME=tenant_name
export OS_PROJECT_NAME=project_name
The CLI becomes available after the tool is installed and configured.
For details about the CLI list supported by the cloud platform, see the appendix.
If you encounter any problem during installation, configuration, or use, resort to the FAQ.
Besides the OpenStack individual CLI and unified CLI, the cloud platform provides the extended CLI through plug-ins. You can install and configure the extended CLI by performing follow-up operations.
(Optional) Installing the Extended CLI
You can use the extended CLI client by running the python-openstackclient plug-in. Therefore, before using the extended CLI client, ensure that python-openstackclient is in the normal state.
Currently, plug-ins of six services are provided. For details, see plug-in list. Select the service plug-in as needed.
The plug-ins are not submitted to the pip library. Therefore, they cannot be installed using pip. You can download the source plug-in code at the GitHub website (https://github.com/Huawei?utf8=%E2%9C%93&q=OpenStackClien&type=&language=) and then run the python setup.py install command to install desired plug-ins. For details, see Readme delivered with each plug-in.
(Optional) Configuring the Extended CLI
You need to configure authentication information before using the extended CLI. After the authentication is successful, services will become available to the extended CLI. You can configure the username and password for authentication by configuring environment variables.
Import the following environment variables:
export OS_AUTH_URL=<url-to-openstack-identity> export OS_PROJECT_NAME=<project-name> export OS_USERNAME=<username> export OS_PASSWORD=<password> export OS_REGION_NAME=<region> # IP address of each service export OS_ANTIDDOS_ENDPOINT_OVERRIDE=<url-to-endpoint-of-service> export OS_AS_ENDPOINT_OVERRIDE=<url-to-endpoint-of-service> export OS_CLOUDEYE_ENDPOINT_OVERRIDE=<url-to-endpoint-of-service> export OS_VB_ENDPOINT_OVERRIDE=<url-to-endpoint-of-service> export OS_WORKSPACE_ENDPOINT_OVERRIDE=<url-to-endpoint-of-service> export OS_KM_ENDPOINT_OVERRIDE=<url-to-endpoint-of-service>
After the environment variables are configured, you can use the CLI.
Next Article: CLI Use Case
Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.