© The Author(s), under exclusive license to APress Media, LLC, part of Springer Nature 2022
A. MarkelovCertified OpenStack Administrator Study Guide Certification Study Companion Serieshttps://doi.org/10.1007/978-1-4842-8804-7_3

3. OpenStack APIs

Andrey Markelov1  
(1)
Stockholm, Sweden
 

This chapter describes how to use the OpenStack CLI and dashboard. The chapter does not cover exam questions.

Using the OpenStack CLI

OpenStack comes with many client utilities. Most services have their own command-line interface (CLI) utility, which has the same name as the service itself. Some of these utilities will become obsolete because of the universal OpenStack CLI, which this book mainly uses.

You can use the packet manager to identify installed clients.
# rpm -qa | grep python.*client
python3-keystoneclient-4.4.0-1.el9s.noarch
python3-cinderclient-8.3.0-1.el9s.noarch
python3-novaclient-17.7.0-1.el9s.noarch
python-openstackclient-lang-5.8.0-1.el9s.noarch
python3-neutronclient-7.8.0-1.el9s.noarch
python3-openstackclient-5.8.0-1.el9s.noarch
python3-glanceclient-3.6.0-1.el9s.noarch
python3-barbicanclient-5.3.0-1.el9s.noarch
python3-swiftclient-3.13.1-1.el9s.noarch
python3-designateclient-4.5.0-1.el9s.noarch
python3-heatclient-2.5.1-1.el9s.noarch
python3-mistralclient-4.4.0-1.el9s.noarch
python3-troveclient-7.2.0-1.el9s.noarch
python3-ironicclient-4.11.0-1.el9s.noarch
python3-zaqarclient-2.3.0-1.el9s.noarch
python3-saharaclient-3.5.0-1.el9s.noarch
python3-octaviaclient-2.5.0-1.el9s.noarch
python3-manilaclient-3.3.0-1.el9s.noarch
python3-magnumclient-3.6.0-1.el9s.noarch
python3-aodhclient-2.4.1-1.el9s.noarch
python3-gnocchiclient-7.0.4-2.el9s.noarch
Some of the packages do not belong to OpenStack. For example, Prometheus-client or google-api-client do not. But most of the RPMs include the name of the OpenStack service in the package name. For a full list, refer to https://wiki.openstack.org/wiki/OpenStackClients. At the time of writing, only the Keystone client was marked as deprecated. Most clients have an internal help section that can be printed with the help option followed by a subcommand. The following is an example.
$ glance help image-create
usage: glance image-create [--architecture <ARCHITECTURE>]
                           [--protected [True|False]] [--name <NAME>]
...
Universal python3-openstackclient has an interactive mode. This mode is indicated by the (openstack) prompt.
$ openstack
(openstack) help
Shell commands (type help <topic>):
===================================
cmdenvironment  edit  hi       l   list  pause  r    save  shell      show
ed              help  history  li  load  py     run  set   shortcuts
Undocumented commands:
======================
EOF  eof  exit  q  quit
Application commands (type help <topic>):
=========================================
aggregate add host              object list                   volume unset
aggregate create                object save
aggregate delete                object show
...
Use the following code to get help with the keypair create subcommand.
(openstack) help keypair create
usage: keypair create [-h] [-f {html,json,json,shell,table,value,yaml,yaml}]
                      [-c COLUMN] [--max-width <integer>] [--noindent]
                      [--prefix PREFIX] [--public-key <file>]
                      <name>
Create new public key
positional arguments:
  <name>                New public key name
...

Horizon’s Architecture

I assume that you have used Horizon, OpenStack’s dashboard, since Chapter 1. For first-time OpenStack users, it is probably easier than using CLI. However, you need to know that Horizon gives access to only about 70% to 80% of its overall functions. In certain situations, you are forced to use CLI. Figure 3-1 shows the login page for the OpenStack dashboard.

But what is it?

A screenshot depicts the OpenStack dashboard login screen.

Figure 3-1

OpenStack’s dashboard login screen

Horizon is a Python project that provides a complete dashboard and an extensible framework for building new dashboards. Horizon has the Django web framework as a dependency. The dashboard aims to support all core OpenStack projects. The minimum required set of running OpenStack services comprises Keystone, Nova, Neutron, and Glance. If the Keystone endpoint for a service is configured, Horizon detects it and enables support for optional services, such as Cinder, Swift, and Heat. Horizon can also work with services that are outside the scope of the Certified OpenStack Administrator exam and this book, such as Ceilometer, Sahara, and Trove.

OpenStack’s Horizon dashboard runs under a web server, commonly Apache or NGINX. For large-scale deployments, it is recommended that you configure a caching layer in front of Horizon; for example, the memcached daemon.

You need to use a web browser with JavaScript and HTML5 support while working with Horizon, which is primarily tested and supported on the latest versions of Firefox, Chrome, and Microsoft Edge.

Tip

You can enable SSL support for the dashboard with the packstack installation tool. You need to provide the CONFIG_HORIZON_SSL=y option in the answer file for that.

Verifying the Operation of the Dashboard

When you start to work with Horizon, you should put your server IP or name in the web browser address bar and connect to port 80 or 443 in case you have SSL-enabled deployment of your Horizon server. It can be a separate server or one of the control nodes.

The dashboard’s main configuration file is /etc/openstack-dashboard/local_settings. This configuration file has many options; however, the Keystone server URL is the most important.

OPENSTACK_KEYSTONE_URL = "http://192.168.122.10:5000/v3"

Another interesting option is a session timeout defined in seconds.
SESSION_TIMEOUT=3600

In some cases, it can be beneficial to increase this parameter. For example, if you plan to upload big virtual machine images via a slow connection.

The following is another option.
ALLOWED_HOSTS = ['*', ]

This lists the IP addresses or FQDNs on which Horizon accepts connections. The default star symbol means all server IPs accept it.

Tip

Some vendors supply their own themes with the Horizon dashboard installation. If your installation has a standard look, you can delete additional packages with branded themes. For Ubuntu, use apt-get remove --auto-remove openstack-dashboard-ubuntu-theme. For the Red Hat OpenStack platform, use rpm -e openstack-dashboard-theme --nodeps.

The Horizon log file is situated in the /var/log/horizon/horizon.log file.

Creating and Managing RC Files to Authenticate with Keystone for Command-Line Use

While working in the command line, it is recommended to use run control (RC) environment files, one for each user and project combination, to set authentication parameters. You are provided an RC file if you installed OpenStack using one of the deployment tools like PackStack or DevStack.

Another way to get the RC file is to download it from the Horizon dashboard. After successful login, click the username in the upper-right corner (see Figure 3-2), and then click OpenStack RC File. It is ready to use, with only one parameter missing inside. The file does not contain your password. Table 3-1 provides some RC file configuration options.
Table 3-1

RC File Main Configuration Options

Example of Config Options

Description

OS_AUTH_URL=http://192.168.122.10:5000/v3

The Keystone service URL

OS_REGION_NAME=RegionOne

The region name

OS_USERNAME=admin

The username

OS_PASSWORD=openstack

The password in clear text

OS_PROJECT_NAME=admin

The project name

OS_USER_DOMAIN_NAME=Default

The domain name

OS_IDENTITY_API_VERSION=3

The Keystone API version

A screenshot of an OpenStack dashboard depicts how to download the R C file.

Figure 3-2

How to download the RC file using the OpenStack dashboard

Summary

This chapter described how to use OpenStack’s CLI and dashboard, which are used in all the following chapters.

The next chapter explores identity management.

Review Questions

  1. 1.
    Which of the following is OpenStack dashboard’s main configuration file?
    1. A.

      /var/www/html/openstack-dashboard/local_settings

       
    2. B.

      /etc/openstack-dashboard/local_settings

       
    3. C.

      /etc/horizon/horizon.conf

       
    4. D.

      /etc/horizon/local_settings

       
     
  2. 2.
    How do you set up a half-hour session timeout?
    1. A.

      TIMEOUT=30

       
    2. B.

      SESSION_TIMEOUT=3600

       
    3. C.

      SESSION_TIMEOUT=1800

       
    4. D.

      TIMEOUT=300

       
     

Answers

  1. 1.

    B

     
  2. 2.

    C

     
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.131.142.80