OpenStack CLI Guide 1 1. OpenStack CLI Guide Table of Contents Overview of CLIs
OpenStack CLI Guide 1 1. OpenStack CLI Guide Table of Contents Overview of CLIs ............................................................................................................. 1 Getting Credentials for a CLI ........................................................................................... 2 Checking the version of a CLI .......................................................................................... 4 Get Help for a CLI ........................................................................................................... 4 Install OpenStack nova CLI .............................................................................................. 4 Command List for nova Client ......................................................................................... 5 OpenStack Nova CLI Guide ............................................................................................. 8 Get Command, Parameter, and Subcommand Help ................................................. 8 List Instances, Images, and Flavors .......................................................................... 8 Launch a New Instance ........................................................................................... 9 Change Server Configuration ................................................................................. 13 Stop and Start an Instance .................................................................................... 15 Rebooting an instance ........................................................................................... 15 Manage Security Groups ....................................................................................... 15 Manage Floating IP Addresses ............................................................................... 19 Manage Images .................................................................................................... 21 Manage Volumes .................................................................................................. 21 Terminate an Instance ........................................................................................... 21 Get an Instance Console ........................................................................................ 22 Usage statistics ...................................................................................................... 22 Install OpenStack glance CLI .......................................................................................... 24 Command List for glance CLI ......................................................................................... 25 OpenStack Glance CLI Guide ......................................................................................... 26 Getting Command, Parameter, and Subcommand Help ......................................... 27 List Images ............................................................................................................ 27 Add a New Image ................................................................................................. 27 Managing Images .................................................................................................. 28 Install OpenStack keystone CLI ...................................................................................... 28 Command List for keystone CLI ..................................................................................... 29 Install OpenStack swift CLI ............................................................................................ 31 Command List for swift CLI ........................................................................................... 31 Install OpenStack quantum CLI ...................................................................................... 32 Command List for quantum CLI ..................................................................................... 33 OpenStack Quantum CLI Guide ..................................................................................... 34 Overview ............................................................................................................... 34 Each OpenStack project has a Command-Line-Interface (CLI) that interacts with the service's REST API. Overview of CLIs The CLIs are open-source Python clients used to run commands to make API calls. For example, each nova client command runs cURL commands that embed API v2 requests. You can run the CLI from a desktop machine or remote system. For example, to use the OpenStack CLI Guide 2 Compute API from the command-line, install the nova client. A common openstack CLI is in development also. To install a client on a Mac OS X or Linux system, you can use easy_install or pip or install the package from your Linux distribution. Using pip is recommended because it is easy and it ensures that you get the latest version of the nova client from the Python Package Index. Also, it lets you update the package later on. Here are the CLIs for use with OpenStack clouds: • glance - Enables interaction with images, such as adding and setting permissions on images. • keystone - Controls and creates users, tenants, roles, endpoints, and credentials. • nova - Enables you to launch servers, set security groups, control IP addresses on servers, control volumes and snapshot images. • quantum - Offers network configuration for guest servers. • swift - Provides access to a swift installation for adhoc processing, to gather statistics, list items, update metadata, upload, download and delete files stored by the object storage service. Getting Credentials for a CLI Before you can issue commands with a command-line-interface, you must ensure that your environment contains the necessary variables so that you can prove to the CLI who you are and what credentials you have to issue the commands. Procedure 1.1. To authenticate a user to interact with CLIs 1. Set environment variables You can either edit your bash profile to add and set environment variables or use an openrc file downloaded from an OpenStack Dashboard. Either edit your .bash_profile file: $ nano ~/.bash_profile Add the following lines to the bash profile. Edit the values for the OS_USERNAME, OS_PASSWORD, and OS_TENANT_NAME variables: export OS_USERNAME=username export OS_PASSWORD=password export OS_TENANT_NAME=tenant export OS_AUTH_URL=https://identity.api.rackspacecloud.com/v2.0/ #an example, insert your endpoint here export NOVACLIENT_DEBUG=1 export NOVA_VERSION=2 Or download an openrc file from the OpenStack Dashboard: #!/bin/bash OpenStack CLI Guide 3 # With the addition of Keystone, to use an openstack cloud you should # authenticate against keystone, which returns a **Token** and **Service # Catalog**. The catalog contains the endpoint for all services the # user/tenant has access to - including nova, glance, keystone, swift. # # *NOTE*: Using the 2.0 *auth api* does not mean that compute api is 2.0. We # will use the 1.1 *compute api* export OS_AUTH_URL=http://10.0.100.102:5000/v2.0 # With the addition of Keystone we have standardized on the term **tenant** # as the entity that owns the resources. export OS_TENANT_ID=feacce5a1fc347f88cfc0dee838429d6 export OS_TENANT_NAME=tenant # In addition to the owning entity (tenant), openstack stores the entity # performing the action as the **user**. export OS_USERNAME=username # With Keystone you pass the keystone password. echo "Please enter your OpenStack Password: " read -s OS_PASSWORD_INPUT export OS_PASSWORD=$OS_PASSWORD_INPUT Source the file: source openrc.sh Enter your OpenStack password when prompted. The following table describes the environment variables: Table 1.1. Client Environment Variables Environment Variable Description OS_USERNAME Your OpenStack username. OS_PASSWORD Your OpenStack user password. OS_TENANT_ID Your tenant ID, usually provided with your username. OS_TENANT_NAME Your tenant name, usually provided with your username. OS_AUTH_URL The endpoint for the Identity Service (keystone), which the nova client uses for authentication. Include the trailing forward slash (/) in the URL. Otherwise, you receive a 404 error. NOVACLIENT_DEBUG Set to 1 to show the underlying cURL commands with embedded API requests in the command responses. Otherwise, omit this variable. NOVA_VERSION The version of the API. Set to 2. After you set the variables, save the file. 2. Set permissions on and source the bash profile Because the bash profile contains a password, set permissions on it so other people cannot read it: $ chmod 600 ~/.bash_profile To source the variables to make them available in your current shell, run the following command: OpenStack CLI Guide 4 $ source ~/.bash_profile Checking the version of a CLI Search for the version number. $pip freeze | grep python- python-glanceclient==0.4.0 python-keystoneclient==0.1.2 -e git+https://github.com/openstack/python-novaclient. git@077cc0bf22e378c4c4b970f2331a695e440a939f#egg=python_novaclient-dev python-quantumclient==0.1.1 python-swiftclient==1.1.1 You can also use the yolk -l command to see what version of the CLI you have installed. $yolk -l | grep python-novaclient python-novaclient - 2.6.10.27 - active development (/Users/your.name/src/ cloud-servers/src/src/python-novaclient) python-novaclient - 2012.1 - non-active Get Help for a CLI For any of the OpenStack CLI, you can get documentation from the command-line with the help command. For example, to get help for glance client commands, run the following command: $ glance help Depending on your user credentials, you may not have permissions to use every command that is listed. The glance client was written for use with recent development versions of OpenStack. To get help for a specific command, type the command name after the help parameter, as follows: $ glance help command_name Install OpenStack nova CLI This example walks through installing the nova client. Before you use a command-line client, you must configure environment variables for authentication. Procedure 1.2. To install the nova client: 1. Install Python Install Python 2.6 or later. Currently, the nova client does not support Python 3. 2. Install the nova client package Choose one of the following methods to install the nova client package. • Recommended method: pip OpenStack CLI Guide 5 Install pip through the package manager for your system: System Command Mac OS X $ sudo easy_install pip Ubuntu 11.10 and earlier $ aptitude install python-pip Ubuntu 12.04 There is a packaged version so you can use dpkg or aptitude to install python- novaclient. $ aptitude install python-novaclient RHEL, CentOS, or Fedora: $ yum install python-pip Run the following command to install the nova client package: $ sudo pip install python-novaclient Note Version values of python-novaclient on the Ubuntu distribution are different from the services versions, such as 2.6.10 instead of 2012.1. • easy_install Run the following command to install the nova client package: $ sudo easy_install python-novaclient 3. Test the nova client To verify that you can talk to the API server, run the following commands: $ nova credentials $ nova image-list The first command authenticates, and the second command returns a list of images. Command List for nova Client absolute-limits Print a list of absolute limits for a user actions Retrieve server actions. add-fixed-ip Add new IP address to network. add-floating-ip Add a floating IP address to a server. add-secgroup Add a Security Group to a server. aggregate-add-host Add the host to the specified aggregate. aggregate-create Create a new aggregate with the specified details. aggregate-delete Delete the aggregate by its id. aggregate-details Show details of the specified aggregate. aggregate-list Print a list of all aggregates. aggregate-remove-host Remove the specified host from the specified aggregate. aggregate-set-metadata Update the metadata associated with the aggregate. OpenStack CLI Guide 6 aggregate-update Update the aggregate's name and optionally availability zone. boot Boot a new server. cloudpipe-create Create a cloudpipe instance for the given project cloudpipe-list Print a list of all cloudpipe instances. console-log Get console log output of a server. credentials Show user credentials returned from auth delete Immediately shut down and delete a server. diagnostics Retrieve server diagnostics. dns-create Create a DNS entry for domain, name and ip. dns-create-private-domain Create the specified DNS domain. dns-create-public-domain Create the specified DNS domain. dns-delete Delete the specified DNS entry. dns-delete-domain Delete the specified DNS domain. dns-domains Print a list of available dns domains. dns-list List current DNS entries for domain and ip or domain and name. endpoints Discover endpoints that get returned from the uploads/Litterature/ cli-guide.pdf
Documents similaires
-
12
-
0
-
0
Licence et utilisation
Gratuit pour un usage personnel Attribution requise- Détails
- Publié le Jul 04, 2021
- Catégorie Literature / Litté...
- Langue French
- Taille du fichier 0.1593MB