Using the openstack command line interface to create a new server.

I have to create a new virtual machine. I want to use the V3 API when authentication to Keystone, which means I need to use the common client, as the keystone client is deprecated and only supports the V2.0 Identity API.

To do anything with the client, we need to set some authorization data variables. Create keystonerc with the following and source it:

  1 export OS_AUTH_URL=http://oslab.exmapletree.com:5000/v3
  2 export OS_PROJECT_NAME=Syrup
  3 export OS_PROJECT_DOMAIN_NAME=Default
  4 export OS_USER_DOMAIN_NAME=Default
  5 export OS_USERNAME=ayoung
  6 export OS_PASSWORD=yeahright

The Formatting for the output of the commands is horribly rendered here, but if you click the little white sheet of paper icon that pops up when you float your mouse cursor over the black text, you get a readable table.

Sanity Check: list servers


[ayoung@ayoung530 oslab]$ openstack server list
+--------------------------------------+-------------------------------------+---------+-----------------------------------------------------------------------------+
| ID                                   | Name                                | Status  | Networks                                                                    |
+--------------------------------------+-------------------------------------+---------+-----------------------------------------------------------------------------+
| a5f70f90-7d97-4b79-b0f0-044d8d9b4c77 | centos7.cloudlab.freeipa.org        | ACTIVE  | idm-v4-default=192.168.1.72, 10.16.19.63                                    |
| 35b116e4-fdd2-4580-bb1a-18f1f6428dd5 | mysql.cloudlab.freeipa.org          | ACTIVE  | idm-v4-default=192.168.1.70, 10.16.19.92                                    |
| a5ca7644-d703-44d7-aa95-fd107e18aefd | horizon.cloudlab.freeipa.org        | ACTIVE  | idm-v4-default=192.168.1.67, 10.16.19.24                                    |
| f7aca565-4439-4a2f-9c31-911349ce8943 | ldapqa.cloudlab.freeipa.org         | ACTIVE  | idm-v4-default=192.168.1.66, 10.16.19.100                                   |
| 2b7b5cc1-83c4-45c3-8ca3-cd4ba4b589d3 | federate.cloudlab.freeipa.org       | ACTIVE  | idm-v4-default=192.168.1.61, 10.16.18.6                                     |
| a8649175-fd18-483c-acb7-2933226fd3a6 | horizon.kerb-demo.org               | ACTIVE  | kerb-demo.org=192.168.0.5, 10.16.19.183                                     |
| 38d24fb3-0dd3-4cf0-98d6-12ea22a1d718 | openstack.kerb-demo.org             | ACTIVE  | kerb-demo.org=192.168.0.3, 10.16.19.101                                     |
| ca9a8249-1f09-4b1a-b8d4-850019b7c4e5 | ipa.kerb-demo.org                   | ACTIVE  | kerb-demo.org=192.168.0.2, 10.16.18.218                                     |
| 29d00b3b-5961-424e-b95c-9d90b3ecf9e3 | ipsilon.cloudlab.freeipa.org        | ACTIVE  | idm-v4-default=192.168.1.60, 10.16.18.207                                   |
| 028df8d8-7ce9-4f61-b36f-a080dd7c4fb8 | ipa.cloudlab.freeipa.org            | ACTIVE  | idm-v4-default=192.168.1.59, 10.16.18.31                                    |
+--------------------------------------+-------------------------------------+---------+-----------------------------------------------------------------------------+

I made a pretty significant use of the help output. To show the basic help string

openstack --help

Gives you a list of the options. To see help on a specific comming, such as the server create command we are going to work towards executing, run:

openstack help server create

A Server is a resource golem composed by stitching together resources from other services. To create this golem I am going to stitch together:

  1. A flavor
  2. An image
  3. A Security Group
  4. A Private Key
  5. A network
First, to find the flavor:

[ayoung@ayoung530 oslab]$ openstack flavor list
+----+---------------------+------+------+-----------+-------+-----------+
| ID | Name                |  RAM | Disk | Ephemeral | VCPUs | Is Public |
+----+---------------------+------+------+-----------+-------+-----------+
| 1  | m1.tiny             |  512 |    1 |         0 |     1 | True      |
| 2  | m1.small            | 2048 |   20 |         0 |     1 | True      |
| 3  | m1.medium           | 4096 |   40 |         0 |     2 | True      |
| 4  | m1.large            | 8192 |   80 |         0 |     4 | True      |
| 6  | m1.xsmall           | 1024 |   10 |         0 |     1 | True      |
| 7  | m1.small.4gb        | 4096 |   20 |         0 |     1 | True      |
| 8  | m1.small.8gb        | 8192 |   20 |         0 |     1 | True      |
| 9  | oslab.4cpu.20hd.8gb | 8192 |   20 |         0 |     4 | True      |
+----+---------------------+------+------+-----------+-------+-----------+

I think this one should taste like cherry. But, since we don’t have a cherry flavor, I guess I’ll pick m1.small.4gb as that has the 4 GB RAM I need.

To FInd an image:

[ayoung@ayoung530 oslab]$ openstack image list
+--------------------------------------+----------------------------------------------+
| ID                                   | Name                                         |
+--------------------------------------+----------------------------------------------+
| 415162df-4bec-474f-9f3b-0a79c2ed3848 | Fedora-Cloud-Base-22_Alpha-20150305          |
| b89dc25b-6f62-4001-b979-05ac14f60e9b | rhel-guest-image-7.1-20150224.0              |
| 38534e64-5d7b-43fa-b59c-aed7a262720d | CentOS-7-x86_64                              |
| bc3c35a2-cf96-4589-ad51-a8d499708128 | Fedora-Cloud-Base-20141203-21.x86_64         |
| 9ea16df1-f178-4589-b32b-0e2e32305c61 | FreeBSD 10.1                                 |
| 6ec77e6e-7ad4-4994-937d-91003fa2d6ac | rhel-6.6-latest                              |
| e61ec961-248b-4ee6-8dfa-5d5198690cab | ubuntu-12.04-precise-cloudimg                |
| 54ba6aa9-7d20-4606-baa6-f8e45a80510c | rhel-guest-image-6.6-20141222.0              |
| bee6e762-102f-467e-95a8-4a798cb5ec75 | heat-functional-tests-image                  |
| 812e129c-6bfd-41f5-afba-6817ac6a23e5 | RHEL 6.5 20140829                            |
| f2dfff20-c403-4e53-ae30-947677a223ce | Fedora 21 20141203                           |
| 473e6f30-a3f0-485b-a5e5-3c5a1f7909a5 | RHEL 6.6 20140926                            |
| b12fe824-c98a-4af5-88a6-b1e11a511724 | centos-7-cloud                               |
| 601e162f-87b4-4fc1-a0d3-1c352f3c2988 | fedora-21-atomic                             |
| 12616509-4c4f-47a5-96b1-317a99ef6bf8 | Fedora 21 Beta                               |
| 77dcb29b-3258-4955-8ca4-a5952c157a2b | RHEL6.6                                      |
| 8550a6db-517b-47ea-82f3-ec4fd48e8c09 | centos-7-x86_64                              |
+--------------------------------------+----------------------------------------------+

Although I really want a Fedora Cloud image…I guess I’ll pick fedora-21-atomic. Close enough for Government work.

[ayoung@ayoung530 oslab]$ openstack keypair list
+---------------+-------------------------------------------------+
| Name          | Fingerprint                                     |
+---------------+-------------------------------------------------+
| ayoung-pubkey | 37:81:08:b2:0e:39:78:0e:62:fb:0b:a5:f1:d7:41:fc |
+---------------+-------------------------------------------------+

That decision is tough.

[ayoung@ayoung530 oslab]$ openstack network list
+--------------------------------------+------------------------------+--------------------------------------+
| ID                                   | Name                         | Subnets                              |
+--------------------------------------+------------------------------+--------------------------------------+
| 3b799c78-ca9d-49d0-9838-b2599cc6b8d0 | kerb-demo.org                | c889bb6b-98cd-47b8-8ba0-5f2de4fe74ee |
| 63258623-1fd5-497c-b62d-e0651e03bdca | idm-v4-default               | 3227f3ea-5230-411c-89eb-b1e51298b4f9 |
| 650fc936-cc03-472d-bc32-d56f56116761 | tester1                      |                                      |
| de4300cc-8f71-46d7-bec5-c0a4ad54954d | BROKEN                       | 6c390add-108c-40d5-88af-cb5e784a9d31 |
| eb94d7e2-94be-45ee-bea0-22b9b362f04f | external                     | 3a72b7bc-623e-4887-9499-de8ba280cb2f |
+--------------------------------------+------------------------------+--------------------------------------+

Tempted to using BROKEN, but I shall refrain. I set up idm-v4-default so I know that is good.

[ayoung@ayoung530 oslab]$ openstack security group list
+--------------------------------------+---------+-------------+
| ID                                   | Name    | Description |
+--------------------------------------+---------+-------------+
| 6c13abed-81cd-4a50-82fb-4dc98b4f29fd | default | default     |
+--------------------------------------+---------+-------------+

Another tough call. OK, with all that, we have enough information to create the server:

One note, the –nic param is where you can distinguish which network to use. That param takes a series of key/value params connected by equal signs. I figured that out from the old nova command line parameters, and would jhave been hopeless lost if I hadn’t stumbled across the old how to guide.

openstack server create   --flavor m1.medium   --image "fedora-21-atomic" --key-name ayoung-pubkey    --security-group default  --nic net-id=63258623-1fd5-497c-b62d-e0651e03bdca ayoung-test

In order to ssh to the machine, we need to assign it a floating IP Address. TO find one that is unassigned:

[ayoung@ayoung530 oslab]$ openstack  ip floating list | grep None
| 943b57ea-4e52-4d05-b665-f808a5fbd887 | external | 10.16.18.61  | None           | None                                 |
| a1f5bb26-4e47-4fe7-875e-d967678364a0 | external | 10.16.18.223 | None           | None                                 |
| a419c144-dbfd-4a42-9f5e-880526683ea0 | external | 10.16.18.235 | None           | None                                 |
| a5abf332-68dc-46c5-a4f1-188b91f8dbf8 | external | 10.16.18.225 | None           | None                                 |
| b5c21c4a-3f12-4744-a426-8d073b3be3c8 | external | 10.16.18.70  | None           | None                                 |
| b67edf85-2e54-4ad1-a014-20b7370e38ba | external | 10.16.18.170 | None           | None                                 |
| c43eb490-1910-4adf-91b6-80375904e937 | external | 10.16.18.196 | None           | None                                 |
| c44a4a56-1534-4200-a227-90de85a218eb | external | 10.16.19.28  | None           | None                                 |
| e98774f9-fe6e-4608-a85d-92a5f39ef2c8 | external | 10.16.19.182 | None           | None                                 |
| f2705313-b03f-4537-a2d8-c01ff1baaee1 | external | 10.16.18.203 | None           | None                                 |

I’ll chose one at random

[ayoung@ayoung530 oslab]$ openstack  ip floating list | grep None | sort -R | head -1
| a419c144-dbfd-4a42-9f5e-880526683ea0 | external | 10.16.18.235 | None           | None                                 |

And Add it to the server:

openstack ip floating add  10.16.18.235  ayoung-test

Test it out:

[ayoung@ayoung530 oslab]$ ssh root@10.16.18.235
The authenticity of host '10.16.18.235 (10.16.18.235)' can't be established.
ECDSA key fingerprint is 2a:cd:5f:37:63:ef:7f:2d:9d:83:fd:85:76:4d:03:3c.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.16.18.235' (ECDSA) to the list of known hosts.
Please login as the user "fedora" rather than the user "root".

And log in:

[ayoung@ayoung530 oslab]$ ssh fedora@10.16.18.235
[fedora@ayoung-test ~]$ 

3 thoughts on “Using the openstack command line interface to create a new server.

  1. can i ask you something??

    i create vm fedora with openstack CLI, and i try to install application like iptraf and success. but when i run the application, the application not run

    -bash: iptraf: command not found

    and before i instal, the output is here :

    Failed to set locale, defaulting to C

    can you help me?

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.