Command-line
Once correctly authenticated to Keystone - we can begin creating an OpenStack virtual machine instance.
We will need a few details to create our instance, these include:
- ID of Neutron Network(s) to use
- ID of Glance image to use
- Name of Keypair to use
We can get the ID's of networks and glance images using:
[wflintstone@login1(demo) ~]$ openstack network list
+--------------------------------------+-------------+--------------------------------------+
| ID | Name | Subnets |
+--------------------------------------+-------------+--------------------------------------+
| 29946bd3-8e2a-4806-96bc-68cdbf1ef238 | internal | 0bf4bdaa-09d3-47de-a0e2-590aadcc4728 |
| e90b09bb-2d90-43d7-95f3-9f301d87a47a | bedrock-net | cbdc2308-c80a-4e33-bbec-79f015e8a80a |
| f6660ee3-f88a-4ead-880d-142ca5e7f384 | public | 90b6a3fb-3f53-4cab-844a-cf3d6d4a6cb4 |
+--------------------------------------+-------------+--------------------------------------+
Save the network ID you wish to use as a variable for later use:
$ BEDROCKNET="e90b09bb-2d90-43d7-95f3-9f301d87a47a"
We can get ID's of Glance images using:
[wflintstone@login1(demo) ~]$ openstack image list
+--------------------------------------+------------------+
| ID | Name |
+--------------------------------------+------------------+
| e53b8e97-893c-4357-aca8-098731973eb2 | clusterware-el6 |
| d372a43c-fdec-4ef5-be04-0229f48e5a59 | ubuntu-14.04 |
| ee163441-61b7-42fe-b06c-81e603c2e459 | centos.6.7-cloud |
| 43755176-d799-43e7-b3b6-b5486af087ac | centos.7.1-cloud |
| c63abffb-1828-41fe-ae52-0f106b2c1dc9 | Cirros 0.3.4 |
+--------------------------------------+------------------+
Save the image ID you wish to use as a variable for later use:
$ IMAGE="e53b8e97-893c-4357-aca8-098731973eb2"
We can get the names of Keypairs using:
[wflintstone@symphony-controller(demo) ~]$ openstack keypair list
+------------+-------------------------------------------------+
| Name | Fingerprint |
+------------+-------------------------------------------------+
| wflinstone | c4:6c:96:6f:81:73:62:91:ff:fa:1d:82:08:bd:fa:64 |
+------------+-------------------------------------------------+
- Names can be used in place of ID's if only one
internal
orpublic
etc exists in the same tenant
Creating a virtual machine
To create a basic virtual machine using the above network and image, run the following command with your own preferences:
[wflintstone@login1(demo) ~]$ openstack server create \
> --key-name wflinstone \
> --image $IMAGE \
> --nic net-id=$BEDROCKNET \
> --flavor m1.small \
> myfirstvm
+--------------------------------------+---------------------------------------------------------+
| Field | Value |
+--------------------------------------+---------------------------------------------------------+
| OS-DCF:diskConfig | MANUAL |
| OS-EXT-AZ:availability_zone | nova |
| OS-EXT-STS:power_state | 0 |
| OS-EXT-STS:task_state | scheduling |
| OS-EXT-STS:vm_state | building |
| OS-SRV-USG:launched_at | None |
| OS-SRV-USG:terminated_at | None |
| accessIPv4 | |
| accessIPv6 | |
| addresses | |
| adminPass | t4AhfihMDPyA |
| config_drive | |
| created | 2015-12-10T11:47:05Z |
| flavor | m1.small (2) |
| hostId | |
| id | 85b08a41-312e-448b-bdc3-c3bcc071312e |
| image | centos.6.7-cloud (ee163441-61b7-42fe-b06c-81e603c2e459) |
| key_name | wflinstone |
| name | myfirstvm |
| os-extended-volumes:volumes_attached | [] |
| progress | 0 |
| project_id | 06c2c75c14514ca0880e987398ec4a76 |
| properties | |
| security_groups | [{u'name': u'default'}] |
| status | BUILD |
| updated | 2015-12-10T11:47:05Z |
| user_id | d0787d82ff13403c8d20b268726392b4 |
+--------------------------------------+---------------------------------------------------------+
Obtaining access
We now have a basic virtual machine - to gain access via the OpenStack DMZ - we need to assign a Floating IP to the instance.
To view available floating IPs
[wflintstone@login1(demo) ~]$ openstack ip floating list
+--------------------------------------+--------+------------+----------+-------------+
| ID | Pool | IP | Fixed IP | Instance ID |
+--------------------------------------+--------+------------+----------+-------------+
| 1cdbee2f-1750-41bb-b97f-a89ffb210813 | public | 10.77.0.6 | None | None |
| 9257d325-5219-4bab-8b3d-378d020cdb26 | public | 10.77.0.52 | None | None |
+--------------------------------------+--------+------------+----------+-------------+
To assign floating IPs
[wflintstone@login1(demo) ~]$ openstack ip floating add 10.77.0.6 myfirstvm
[wflintstone@login1(demo) ~]$ openstack server list
+--------------------------------------+------------------+--------+----------------------------------+
| ID | Name | Status | Networks |
+--------------------------------------+------------------+--------+----------------------------------+
| 85b08a41-312e-448b-bdc3-c3bcc071312e | myfirstvm | ACTIVE | bedrock-net=10.75.0.3, 10.77.0.6 |
| 50b0cacb-9bb9-42cc-941b-4fe193871fc1 | deru-bra-menryu | ACTIVE | internal=192.168.150.103 |
| f7ab37d5-7f56-4e75-bfc0-f6469ace6979 | rogriu-prya-voda | ACTIVE | internal=192.168.150.102 |
+--------------------------------------+------------------+--------+----------------------------------+
Access to the instance can now be gained from the 10.77.0.0
floating IP address using the key-pair assigned to the virtual machine.