Ubuntu 16.04
Sponsored Link

OpenStack Newton : Boot Instances
2016/11/15
 
Create and Start Virtual Machine Instance.
[1] Specify the flavor (memory or disk) and create an instance and boot it.
# create a flavor

root@dlp ~(keystone)#
openstack flavor create --id 0 --vcpus 1 --ram 2048 --disk 10 m1.small

+----------------------------+----------+
| Field                      | Value    |
+----------------------------+----------+
| OS-FLV-DISABLED:disabled   | False    |
| OS-FLV-EXT-DATA:ephemeral  | 0        |
| disk                       | 10       |
| id                         | 0        |
| name                       | m1.small |
| os-flavor-access:is_public | True     |
| properties                 |          |
| ram                        | 2048     |
| rxtx_factor                | 1.0      |
| swap                       |          |
| vcpus                      | 1        |
+----------------------------+----------+

[root@dlp ~(keystone)]#
openstack flavor list

+----+----------+------+------+-----------+-------+-----------+
| ID | Name     |  RAM | Disk | Ephemeral | VCPUs | Is Public |
+----+----------+------+------+-----------+-------+-----------+
| 0  | m1.small | 2048 |   10 |         0 |     1 | True      |
+----+----------+------+------+-----------+-------+-----------+

# show the list of images

root@dlp ~(keystone)#
openstack image list

+--------------------------------------+------------+--------+
| ID                                   | Name       | Status |
+--------------------------------------+------------+--------+
| 7d0cf100-6017-448c-9a6b-5bcf20d93f73 | Ubuntu1604 | active |
+--------------------------------------+------------+--------+

# create and boot an instance

root@dlp ~(keystone)#
openstack server create --flavor m1.small --image Ubuntu1604 --security-group default Ubuntu_1604

+--------------------------------------+---------------------------------------+
| Field                                | Value                                 |
+--------------------------------------+---------------------------------------+
| OS-DCF:diskConfig                    | MANUAL                                |
| OS-EXT-AZ:availability_zone          |                                       |
| OS-EXT-SRV-ATTR:host                 | None                                  |
| OS-EXT-SRV-ATTR:hypervisor_hostname  | None                                  |
| OS-EXT-SRV-ATTR:instance_name        |                                       |
| OS-EXT-STS:power_state               | NOSTATE                               |
| 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                            | xJJwHb7JPhFk                          |
| config_drive                         |                                       |
| created                              | 2016-11-18T01:51:33Z                  |
| flavor                               | m1.small (0)                          |
| hostId                               |                                       |
| id                                   | 85f58053-c095-4f07-ae4a-d953ff2d6f9e  |
| image                                | Ubuntu1604 (7d0cf100-6017-448c-9a6b-  |
|                                      | 5bcf20d93f73)                         |
| key_name                             | None                                  |
| name                                 | Ubuntu_1604                           |
| os-extended-volumes:volumes_attached | []                                    |
| progress                             | 0                                     |
| project_id                           | 1b8227c2c89e4f1cbcbbb9f6060b0416      |
| properties                           |                                       |
| security_groups                      | [{u'name': u'default'}]               |
| status                               | BUILD                                 |
| updated                              | 2016-11-18T01:51:33Z                  |
| user_id                              | b48cbdf1975f4fd3987f83a100cc9162      |
+--------------------------------------+---------------------------------------+

# show status

root@dlp ~(keystone)#
openstack server list

+--------------------+-------------+--------+--------------------+------------+
| ID                 | Name        | Status | Networks           | Image Name |
+--------------------+-------------+--------+--------------------+------------+
| 85f58053-c095-4f07 | Ubuntu_1604 | BUILD  | network01=10.1.0.5 | Ubuntu1604 |
| -ae4a-d953ff2d6f9e |             |        |                    |            |
+--------------------+-------------+--------+--------------------+------------+
[2] Login to the Instance just booted.
# after few minutes later, the Status turns "ACTIVE" like follows

root@dlp ~(keystone)#
openstack server list

+--------------------+-------------+--------+--------------------+------------+
| ID                 | Name        | Status | Networks           | Image Name |
+--------------------+-------------+--------+--------------------+------------+
| 85f58053-c095-4f07 | Ubuntu_1604 | ACTIVE | network01=10.1.0.5 | Ubuntu1604 |
| -ae4a-d953ff2d6f9e |             |        |                    |            |
+--------------------+-------------+--------+--------------------+------------+

# it's OK if ICMP answer replys like follows

root@dlp ~(keystone)#
ping 10.1.0.5

PING 10.1.0.5 (10.1.0.5) 56(84) bytes of data.
64 bytes from 10.1.0.5: icmp_seq=1 ttl=64 time=0.593 ms
64 bytes from 10.1.0.5: icmp_seq=2 ttl=64 time=0.668 ms

--- 10.1.0.5 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 0.593/0.630/0.668/0.045 ms

# possible to login with SSH password auth if you allowed to access with it when configuring VM-image

root@dlp ~(keystone)#
ssh ubuntu@10.1.0.5

The authenticity of host '10.1.0.5 (10.1.0.5)' can't be established.
ECDSA key fingerprint is SHA256:NoqFVWmGttBMBLbGJpCKEXP0I3fnvSPS87R2/apPJZY.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.1.0.5' (ECDSA) to the list of known hosts.
ubuntu@10.1.0.5's password:
Welcome to Ubuntu 16.04.1 LTS (GNU/Linux 4.4.0-47-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage
Last login: Fri Nov 18 10:36:51 2016
ubuntu@ubuntu-1604:~$    
# just logined

[3] If you did not allow to access with SSH password auth or you use a VM-image provided from internet, Add SSH key-pair to login like follows.
# create key-pair

root@dlp ~(keystone)#
ssh-keygen -q -N ""

# add public key

root@dlp ~(keystone)#
openstack keypair create --public-key ~/.ssh/id_rsa.pub mykey

+-------------+-------------------------------------------------+
| Field       | Value                                           |
+-------------+-------------------------------------------------+
| fingerprint | 85:09:a8:2d:dd:4f:1d:b0:17:e8:98:36:10:9d:19:31 |
| name        | mykey                                           |
| user_id     | b48cbdf1975f4fd3987f83a100cc9162                |
+-------------+-------------------------------------------------+

root@dlp ~(keystone)#
openstack keypair list

+-------+-------------------------------------------------+
| Name  | Fingerprint                                     |
+-------+-------------------------------------------------+
| mykey | 85:09:a8:2d:dd:4f:1d:b0:17:e8:98:36:10:9d:19:31 |
+-------+-------------------------------------------------+

# run instance with key

root@dlp ~(keystone)#
openstack server create --flavor m1.small --image Ubuntu1604 --security-group default --key-name mykey Ubuntu16_04_1
root@dlp ~(keystone)#
openstack server list

+-----------------+---------------+---------+-------------------+------------+
| ID              | Name          | Status  | Networks          | Image Name |
+-----------------+---------------+---------+-------------------+------------+
| 59e49a9d-946b-4 | Ubuntu16_04_1 | ACTIVE  | network01=10.1.0. | Ubuntu1604 |
| a63-bf72-534455 |               |         | 6                 |            |
| cc84ea          |               |         |                   |            |
+-----------------+---------------+---------+-------------------+------------+

# ssh with the key and a default user (Ubuntu's default user is just "ubuntu")

root@dlp ~(keystone)#
ssh -i mykey ubuntu@10.1.0.6
ubuntu@ubuntu16-04-1:~$    
# just logined

[4] If you'd like to stop an instance, it's also possible to control with openstack command like follows.
root@dlp ~(keystone)#
openstack server list

+--------------------+-------------+--------+--------------------+------------+
| ID                 | Name        | Status | Networks           | Image Name |
+--------------------+-------------+--------+--------------------+------------+
| 85f58053-c095-4f07 | Ubuntu_1604 | ACTIVE | network01=10.1.0.5 | Ubuntu1604 |
| -ae4a-d953ff2d6f9e |             |        |                    |            |
+--------------------+-------------+--------+--------------------+------------+

# stop instance

root@dlp ~(keystone)#
openstack server stop Ubuntu_1604

root@dlp ~(keystone)#
openstack server list

+--------------------+-------------+--------+--------------------+------------+
| ID                 | Name        | Status | Networks           | Image Name |
+--------------------+-------------+--------+--------------------+------------+
| 85f58053-c095-4f07 | Ubuntu_1604 | SHUTOFF| network01=10.1.0.5 | Ubuntu1604 |
| -ae4a-d953ff2d6f9e |             |        |                    |            |
+--------------------+-------------+--------+--------------------+------------+

# start instance

root@dlp ~(keystone)#
openstack server start Ubuntu_1604

root@dlp ~(keystone)#
openstack server list

+--------------------+-------------+--------+--------------------+------------+
| ID                 | Name        | Status | Networks           | Image Name |
+--------------------+-------------+--------+--------------------+------------+
| 85f58053-c095-4f07 | Ubuntu_1604 | ACTIVE | network01=10.1.0.5 | Ubuntu1604 |
| -ae4a-d953ff2d6f9e |             |        |                    |            |
+--------------------+-------------+--------+--------------------+------------+
[5] It's possible to access with Web browser to get VNC console.
root@dlp ~(keystone)#
openstack server list

+--------------------+-------------+--------+--------------------+------------+
| ID                 | Name        | Status | Networks           | Image Name |
+--------------------+-------------+--------+--------------------+------------+
| 85f58053-c095-4f07 | Ubuntu_1604 | ACTIVE | network01=10.1.0.5 | Ubuntu1604 |
| -ae4a-d953ff2d6f9e |             |        |                    |            |
+--------------------+-------------+--------+--------------------+------------+

root@dlp ~(keystone)#
openstack console url show Ubuntu_1604

+-------+----------------------------------------------------------------------+
| Field | Value                                                                |
+-------+----------------------------------------------------------------------+
| type  | novnc                                                                |
| url   | http://10.0.0.30:6080/vnc_auto.html?token=cc1ca31e-b29c-4671-94cc-   |
|       | e8ea093b73de                                                         |
+-------+----------------------------------------------------------------------+
[6] Access to the URL which was displayed by "console url show" like follows.
Matched Content