Console Clients

This article details how to interact with the OpenStack API from console clients.

Creating Users

Before using the API, we have to create a new user and add them to the project.

In the Virtual Private Cloud menu on the left, click the Users tab.

A page will load with a list of users. Click Create user.

Enter a username and click Create.

Passwords are generated automatically, but can be changed in the user’s block by clicking Change password from the drop down menu. To view the user’s project information, expand the block by clicking the arrow.

Choose the project you’d like to add the user to from the drop down menu and click Add to project.

The user with then appear in the project’s control panel. There will be a link next to the username which can be used to access the project’s resources from an external control panel.

In the user control panel, an RC file (a script that console clients use for Identity API v3 authorization) can be downloaded from the Access tab. A separate RC file is required for each region.

Installing Software

Additional software has to be installed before we can configure our system to access projects. In this article, our installation instructions apply to Ubuntu 16.04. Commands may be different for other operating systems; instructions for Debian 7.0 and CentOS 6.5 can be found in the control panel under the Access tab.

Install the following packages:

apt update
apt install python-keystoneclient python-novaclient python-glanceclient python-neutronclient python-cinderclient python-heatclient python-openstackclient

Then run the command:

$ source rc.sh

The program will request a password. Enter the password for the user you accessed the external panel with.

We are now in the system.

Viewing Information on Available Zones

Each VPC region may contain multiple zones. Zones are sets of servers in different racks for virtualization and data storage. Servers in different zones may be connected in a local network. Resources that are available in each zone define the zone’s quotas that can be managed from the project control panel.

nova availability-zone-list

The list of available zones will look like this:

+-------+-----------+
| Name | Status |
+-------+-----------+
| ru-1a | available |
| ru-1b | available |
+-------+-----------+

Viewing Network Information

To create a virtual machine, we first need to create a network. You can view a list of available networks with the command:

$ neutron net-list

The list of available networks will look like this:

+--------------------------------------+------------------+-----------------------------------------------------+
| id | name | subnets |
+--------------------------------------+------------------+-----------------------------------------------------+
| 1c037362-487f-4103-a73b-6cba3f5532dc | nat | b7be542a-2eef-465e-aacd-34a0c83e6afa 192.168.0.0/24 |
| ab2264dd-bde8-4a97-b0da-5fea63191019 | external-network | 102a9263-2d84-4335-acfb-6583ac8e70aa |
| | | aa9e4fc4-63b0-432e-bcbd-82a613310acb |
| fce90252-7d99-4fc7-80ae-ef763d12938d | newnetwork | 5a1a68f9-b885-47b7-9c7e-6f0e08145e3b 192.168.1.0/24 |
+--------------------------------------+------------------+-----------------------------------------------------+

Each network has an identification number (in the ID column); this will have to be entered when you create a new server.

Network configurations can be activated through the GUI (for more detailed information, see here).

Creating a Server

To view a list of available OS images, we run the command:

$ glance image-list

The list will contain the images in our library as well as any images you may have uploaded from the control panel.

Supported images can be filtered by property; for example:

glance image-list --property-filter x_sel_image_owner=Selectel --property-filter x_sel_image_type=master --property-filter x_sel_image_os_arch=amd64

The resulting list will look something like this:

+--------------------------------------+---------------------------------+
| ID | Name |
+--------------------------------------+---------------------------------+
| f0000fbc-6ab3-418f-a9f7-81c845f36ad4 | CentOS 6 64-bit |
| d321a0fb-19e1-4557-a126-6ef4e6e87dba | CentOS 7 64-bit |
| 621c5f5c-a5de-49bf-b0d9-234b734a6d9b | CentOS 7.2 64-bit |
| bc103d99-5ee1-454b-b799-ce8f1503760f | Debian 7 (Wheezy) 64-bit |
| 866d2506-c89e-4315-a42a-9b0255be09df | Debian 8 (Jessie) 64-bit |
| ba7b87b9-9984-42c5-a189-893244623ac6 | Debian 8.6 (Jessie) 64-bit |
| fb83079f-ec73-4189-af3f-5d2696e3ea37 | Fedora 23 64-bit |
| 193bed39-9e70-4c35-a0b3-022525ab005c | Fedora 24 64-bit |
| 0acac5c1-8262-479d-9ad1-b2f1ad9b650f | OpenSUSE 13.1 64-bit |
| 6cce49d5-b46b-41b5-b974-384202ab12ef | Ubuntu 12.04 LTS 64-bit |
| dfbcee74-e4c5-4788-a156-4bbc6403ca17 | Ubuntu 14.04 LTS 64-bit |
| a4ce7727-f15d-4898-82a8-d32f3242ba54 | Ubuntu 14.04.5 LTS 64-bit |
| ce532860-acef-40cd-b3c7-699c22b4dfd6 | Ubuntu 16.04 LTS 64-bit |
| 2e2b6825-0846-4f64-9513-733bb4a38b0b | Windows Server 2012 R2 Standard |
+--------------------------------------+---------------------------------+

Choose the image you want and copy its ID; you will need it when creating your server.

Now create the server configuration (in OpenStack terminology, this is called a “flavor”):

$ nova --is-public False flavor-create <configuration name> auto <RAM size> <HDD space> <number of vCPUs>

It’s worth setting the hard disk space to 0 in this command. In our system, a Cinder volume is connected to the machine as a root (system) disk. We chose this solution to maximize flexibility: unlike local disks (or “instance stores” in Amazon terms), Cinder volumes can be disconnected and connected to other machines.

The auto key in this command means the server configuration ID will be generated automatically:

+------------------------------------+------+---------+----+---------+----+-----+-----------+---------+
|ID |Name |Memory,MB|Disk|Ephemeral|Swap|VCPUs|RXTX_Factor|Is_Public|
+------------------------------------+------+---------+----+---------+----+-----+-----------+---------+
|fc275dcc-f51a-48c3-b0c3-c3fdd300dd65|myflvr| 1024 | 0 | 0 | | 2 | 1.0 | True |
+------------------------------------+------+---------+----+---------+----+-----+-----------+---------+

Copy this ID as you will also need it when creating the server.

Next, create an SSH key:

$ nova keypair-add <key name> <file name>
$ chmod 600 <file name>

This command adds a private key to a file, which can be used to connect to virtual machines via SSH (the connect command in this case will look like: ssh -i <file name> <server IP address>).

If you already have a private-public key pair, you can enter the public key as an argument:

$ nova keypair-add <key_name> pub-key <path/to/public/key>

For example:

$ nova keypair-add myKey --pub-key /home/user/.ssh/id_rsa.pub

SSH keys can also be added from the control panel (from the Access tab in the project menu).

After you have chosen an image and configuration, you have to create a volume for the server.

A list of available disk (volume) types can be viewed with the command:

cinder type-list

You will be returned a list like this:

+--------------------------------------+-----------------+-------------+-----------+
| ID | Name | Description | Is_Public |
+--------------------------------------+-----------------+-------------+-----------+
| 00a8c3b9-715e-438b-845c-89fbc1e9e62b | fast.ru-1b | - | True |
| 27c66842-2b9f-4d71-a957-383ca5ee19c4 | fast.ru-1a | - | True |
| 2c9a6741-5901-40ff-ba67-4a7e70ad7563 | universal.ru-1a | - | True |
| 48f5caf9-9bc9-49ed-bdf5-0b29c544b0b0 | universal.ru-1b | - | True |
| 9c535a8c-cce1-4780-95bf-76c68b99c52f | iso | - | True |
| c7f1cda0-ebcb-4711-8f50-e13e6e4fc9eb | basic.ru-1b | - | True |
| ea11f5ad-baeb-461e-9769-47facee5dbcd | basic.ru-1a | - | True |
+--------------------------------------+-----------------+-------------+-----------+

Volumes can be either fast, basic, or universal and have to be created in the necessary zone. You can create a volume with the command:

$ cinder create --image-id <image id> --display_name <volume name> --volume-type <volume type>.<zone name> <size, GB> --availability-zone <zone name>

If a volume is successfully created, its properties will be displayed in a table:

+-------------------+--------------------------------------+
| Property | Value |
+-------------------+--------------------------------------+
| attachments | [] |
| availability_zone | ru-1a |
| bootable | false |
| created_at | 2014-10-23T11:10:15.000000 |
| description | None |
| encrypted | False |
| id | 76586803-9cfd-4f75-931d-0a4dee98e496 |
| metadata | {} |
| name | mydisk |
| size | 5 |
| snapshot_id | None |
| source_volid | None |
| status | creating |
| user_id | 6f862e43d4a84f359928948fb658d695 |
| volume_type | fast.ru-1a |
+-------------------+--------------------------------------+

To make the volume a system disk, it has to be made bootable:

cinder set-bootable <volume ID> true

Now you can create the server:

nova boot <server name> --key-name <key name> --availability-zone <zone name> --flavor <configuration ID> --nic net-id=<network ID> --block-device source=volume,id=<volume ID>,dest=volume,bootindex=0

The OpenStack platform lets you create servers from one command without creating a volume first. Unfortunately, standard console clients don’t let you give a volume name or type, which is why it will be a default volume type (fast):

$ nova boot --availability-zone <zone name> --flavor <configuration ID> --nic net-id=<network ID> --block-device id=<image ID>,source=image,dest=volume,size=<volume size>,device=vda,bootindex=0

When we created our control panel and images, we tried to make it impossible to transfer unencrypted passwords over a network. This is why our images don’t take passwords but a hash generated by the control panel.

To access a machine from the console, you can just enter your login and click Enter. SSH access is only possible using a key.

Creating Servers from Windows Images

To create a virtual machine from our Windows images, the machine must be connected to the licensing network. A list of these networks can be viewed using the command:

neutron net-list --name license_windows_2012_standard

For example:

+--------------------------------------+-------------------------------+-------------------------------------------------------+
| id | name | subnets |
+--------------------------------------+-------------------------------+-------------------------------------------------------+
| 5d8f8144-e275-4c7e-9275-6f835d8ab2d8 | license_windows_2012_standard | d142a857-1203-4227-a175-b8fab7df3fb7 172.16.100.44/30 |
| | | 4031dc7d-15a5-4351-880c-013c36469a55 172.16.90.240/30 |
+--------------------------------------+-------------------------------+-------------------------------------------------------+

When creating a server, you must set this network as its first interface. You can also assign a password using the --meta key:

nova boot <server name> --key-name <key name> --availability-zone <zone name> --flavor <configuration ID> --nic net-id=<licensing network ID> --nic net-id=<network ID> --block-device source=volume,id=<volume ID>,dest=volume,bootindex=0 --meta admin_pass=<your password>

Volume Operations

You can view a list of available disks using the command:

cinder list

To attach a volume to a server, copy the parameter ID from this table and run the command:

$ nova volume-attach <server name> <volume ID>

Assigning Floating IP Addresses

To assign a floating IP address you created in the control panel to a server:

$ nova floating-ip-associate <server name> <address>

Power Management and Rebooting

There are two types of server reboots: software (a soft or warm reboot) and hardware (by cutting off its power; a cold or hard reboot).

We enter the following to perform a soft reboot:

$ nova reboot <server name>

For a hard reboot:

$ nova reboot --hard <server name>

Power can be managed with the start and stop command:

#to turn on a specific server
$ nova start <server name>
#to turn off a specific server
$ nova stop <server name>

Network Port Operations

To create a new network:

$ neutron net-create <network name>

When the command has been executed, a table with network information will be printed in the console:

+----------------+--------------------------------------+
| Field | Value |
+----------------+--------------------------------------+
| admin_state_up | True |
| id | add73ca5-6120-43bd-bb56-d1d8d71d21ac |
| name | localnet |
| shared | False |
| status | ACTIVE |
| subnets | |
| tenant_id | d15391cc95474b1ab6bd81fb2a73bc5c |
+----------------+--------------------------------------+

A subnet can be created in this network using the following command:

$ neutron subnet-create --name 192.168.1.0/24 192.168.1.0/24 <network id>

The network ID can be taken from the previous printout.

To create a network port:

$ neutron port-create <network name>

and attach it to the server:

$ nova interface-attach --port-id <port ID> <server name>