CentOS 7
Sponsored Link

OpenStack Pike : Run Instances2017/09/03

 
Create and Start Virtual Machine Instance.
[1] Create a flavor (cpu, memory, disk (and others) specification) 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 |
+--------------------------------------+---------+--------+
| 68132026-60aa-4afe-8976-398b0482cfd6 | CentOS7 | active |
+--------------------------------------+---------+--------+

# show the list of network

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

+--------------------------------------+------------+--------------------------------------+
| ID                                   | Name       | Subnets                              |
+--------------------------------------+------------+--------------------------------------+
| fdb1468f-b479-4cbc-b82e-582719536cbc | sharednet1 | bd84f1db-6f15-4994-9f1c-54bbe9c79152 |
+--------------------------------------+------------+--------------------------------------+

[root@dlp ~(keystone)]#
netID=`openstack network list | grep sharednet1 | awk '{ print $2 }'`

# create a keypair

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

Enter file in which to save the key (/root/.ssh/id_rsa):
# add the public key

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

+-------------+-------------------------------------------------+
| Field       | Value                                           |
+-------------+-------------------------------------------------+
| fingerprint | b3:d6:64:1a:6f:4e:14:63:88:76:15:a4:bd:af:a6:34 |
| name        | mykey                                           |
| user_id     | 09d8dfa20e0f40eaae448d369943b195                |
+-------------+-------------------------------------------------+

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

+-------+-------------------------------------------------+
| Name  | Fingerprint                                     |
+-------+-------------------------------------------------+
| mykey | b3:d6:64:1a:6f:4e:14:63:88:76:15:a4:bd:af:a6:34 |
+-------+-------------------------------------------------+

# create and boot an instance with the key

[root@dlp ~(keystone)]#
openstack server create --flavor m1.small --image CentOS7 --security-group default --nic net-id=$netID --key-name mykey CentOS_7
+-------------------------------------+------------------------------------------------+
| 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                           | JQF2YtHUDhh3                                   |
| config_drive                        |                                                |
| created                             | 2017-09-04T08:19:03Z                           |
| flavor                              | m1.small (0)                                   |
| hostId                              |                                                |
| id                                  | 84ebd05f-971e-4d1a-9dd3-3c43a4ddf3f2           |
| image                               | CentOS7 (68132026-60aa-4afe-8976-398b0482cfd6) |
| key_name                            | mykey                                          |
| name                                | CentOS_7                                       |
| progress                            | 0                                              |
| project_id                          | 09158bee8c6441519bf3a3743d936566               |
| properties                          |                                                |
| security_groups                     | name='b8b67ada-379b-4c5f-8ac8-899e943dbbe0'    |
| status                              | BUILD                                          |
| updated                             | 2017-09-04T08:19:03Z                           |
| user_id                             | 09d8dfa20e0f40eaae448d369943b195               |
| volumes_attached                    |                                                |
+-------------------------------------+------------------------------------------------+

# show status ([BUILD] status is shown when building instance)

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

+--------------------------------------+----------+--------+-----------------------+---------+----------+
| ID                                   | Name     | Status | Networks              | Image   | Flavor   |
+--------------------------------------+----------+--------+-----------------------+---------+----------+
| 84ebd05f-971e-4d1a-9dd3-3c43a4ddf3f2 | CentOS_7 | BUILD  | sharednet1=10.0.0.202 | CentOS7 | m1.small |
+--------------------------------------+----------+--------+-----------------------+---------+----------+


# when starting noramlly, the status turns to [ACTIVE]

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

+--------------------------------------+----------+--------+-----------------------+---------+----------+
| ID                                   | Name     | Status | Networks              | Image   | Flavor   |
+--------------------------------------+----------+--------+-----------------------+---------+----------+
| 84ebd05f-971e-4d1a-9dd3-3c43a4ddf3f2 | CentOS_7 | ACTIVE | sharednet1=10.0.0.202 | CentOS7 | m1.small |
+--------------------------------------+----------+--------+-----------------------+---------+----------+
[2] Configure security settings like follows to access with SSH and ICMP.
# permit ICMP

[root@dlp ~(keystone)]#
openstack security group rule create --protocol icmp --ingress default

+-------------------+--------------------------------------+
| Field             | Value                                |
+-------------------+--------------------------------------+
| created_at        | 2017-09-04T08:20:44Z                 |
| description       |                                      |
| direction         | ingress                              |
| ether_type        | IPv4                                 |
| id                | 6ef8160e-fd04-45cd-a569-93f068d0635f |
| name              | None                                 |
| port_range_max    | None                                 |
| port_range_min    | None                                 |
| project_id        | 09158bee8c6441519bf3a3743d936566     |
| protocol          | icmp                                 |
| remote_group_id   | None                                 |
| remote_ip_prefix  | 0.0.0.0/0                            |
| revision_number   | 0                                    |
| security_group_id | b8b67ada-379b-4c5f-8ac8-899e943dbbe0 |
| updated_at        | 2017-09-04T08:20:44Z                 |
+-------------------+--------------------------------------+

# permit SSH

[root@dlp ~(keystone)]#
openstack security group rule create --protocol tcp --dst-port 22:22 default

+-------------------+--------------------------------------+
| Field             | Value                                |
+-------------------+--------------------------------------+
| created_at        | 2017-09-04T08:21:04Z                 |
| description       |                                      |
| direction         | ingress                              |
| ether_type        | IPv4                                 |
| id                | 3ec427f4-9f9f-4ece-aced-1b4b2a4e14a7 |
| name              | None                                 |
| port_range_max    | 22                                   |
| port_range_min    | 22                                   |
| project_id        | 09158bee8c6441519bf3a3743d936566     |
| protocol          | tcp                                  |
| remote_group_id   | None                                 |
| remote_ip_prefix  | 0.0.0.0/0                            |
| revision_number   | 0                                    |
| security_group_id | b8b67ada-379b-4c5f-8ac8-899e943dbbe0 |
| updated_at        | 2017-09-04T08:21:04Z                 |
+-------------------+--------------------------------------+

[root@dlp ~(keystone)]#
openstack security group rule list

+--------------+-------------+-----------+------------+--------------------------------------+-------------------+
| ID           | IP Protocol | IP Range  | Port Range | Remote Security Group                | Security Group    |
+--------------+-------------+-----------+------------+--------------------------------------+-------------------+
| 04544fda-... | None        | None      |            | None                                 | b8b67ada-379b-... |
| 0c1f30a4-... | None        | None      |            | b8b67ada-379b-4c5f-8ac8-899e943dbbe0 | b8b67ada-379b-... |
| 2c70e734-... | None        | None      |            | None                                 | b8b67ada-379b-... |
| 3ec427f4-... | tcp         | 0.0.0.0/0 | 22:22      | None                                 | b8b67ada-379b-... |
| 6ef8160e-... | icmp        | 0.0.0.0/0 |            | None                                 | b8b67ada-379b-... |
| a3745804-... | None        | None      |            | b8b67ada-379b-4c5f-8ac8-899e943dbbe0 | b8b67ada-379b-... |
+--------------+-------------+-----------+------------+--------------------------------------+-------------------+
[3] Login to instance with SSH.
[root@dlp ~(keystone)]#
openstack server list

+--------------------------------------+----------+--------+-----------------------+---------+----------+
| ID                                   | Name     | Status | Networks              | Image   | Flavor   |
+--------------------------------------+----------+--------+-----------------------+---------+----------+
| 84ebd05f-971e-4d1a-9dd3-3c43a4ddf3f2 | CentOS_7 | ACTIVE | sharednet1=10.0.0.202 | CentOS7 | m1.small |
+--------------------------------------+----------+--------+-----------------------+---------+----------+

[root@dlp ~(keystone)]#
ping 10.0.0.202 -c3

PING 10.0.0.202 (10.0.0.202) 56(84) bytes of data.
64 bytes from 10.0.0.202: icmp_seq=1 ttl=64 time=3.13 ms
64 bytes from 10.0.0.202: icmp_seq=2 ttl=64 time=0.833 ms
64 bytes from 10.0.0.202: icmp_seq=3 ttl=64 time=0.831 ms

--- 10.0.0.202 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2003ms
rtt min/avg/max/mdev = 0.831/1.600/3.136/1.086 ms

[root@dlp ~(keystone)]#
ssh centos@10.0.0.202
The authenticity of host '10.0.0.202 (10.0.0.202)' can't be established.
ECDSA key fingerprint is 94:11:48:02:fa:62:ff:9c:c4:75:8f:eb:16:62:a9:ff.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.0.0.202' (ECDSA) to the list of known hosts.
[centos@centos-7 ~]$    
# 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   | Flavor   |
+--------------------------------------+----------+--------+-----------------------+---------+----------+
| 84ebd05f-971e-4d1a-9dd3-3c43a4ddf3f2 | CentOS_7 | ACTIVE | sharednet1=10.0.0.202 | CentOS7 | m1.small |
+--------------------------------------+----------+--------+-----------------------+---------+----------+

# stop instance

[root@dlp ~(keystone)]#
openstack server stop CentOS_7

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

+--------------------------------------+----------+---------+-----------------------+---------+----------+
| ID                                   | Name     | Status  | Networks              | Image   | Flavor   |
+--------------------------------------+----------+---------+-----------------------+---------+----------+
| 84ebd05f-971e-4d1a-9dd3-3c43a4ddf3f2 | CentOS_7 | SHUTOFF | sharednet1=10.0.0.202 | CentOS7 | m1.small |
+--------------------------------------+----------+---------+-----------------------+---------+----------+

# start instance

[root@dlp ~(keystone)]#
openstack server start CentOS_7

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

+--------------------------------------+----------+--------+-----------------------+---------+----------+
| ID                                   | Name     | Status | Networks              | Image   | Flavor   |
+--------------------------------------+----------+--------+-----------------------+---------+----------+
| 84ebd05f-971e-4d1a-9dd3-3c43a4ddf3f2 | CentOS_7 | ACTIVE | sharednet1=10.0.0.202 | CentOS7 | m1.small |
+--------------------------------------+----------+--------+-----------------------+---------+----------+
[5] It's possible to access with Web browser to get VNC console.
[root@dlp ~(keystone)]#
openstack server list

+--------------------------------------+----------+--------+-----------------------+------------+
+--------------------------------------+----------+--------+-----------------------+---------+----------+
| ID                                   | Name     | Status | Networks              | Image   | Flavor   |
+--------------------------------------+----------+--------+-----------------------+---------+----------+
| 84ebd05f-971e-4d1a-9dd3-3c43a4ddf3f2 | CentOS_7 | ACTIVE | sharednet1=10.0.0.202 | CentOS7 | m1.small |
+--------------------------------------+----------+--------+-----------------------+---------+----------+

[root@dlp ~(keystone)]#
openstack console url show CentOS_7

+-------+--------------------------------------------------------------------------------+
| Field | Value                                                                          |
+-------+--------------------------------------------------------------------------------+
| type  | novnc                                                                          |
| url   | http://10.0.0.30:6080/vnc_auto.html?token=f5652854-8cce-4a0f-b22c-7bd384d03d20 |
+-------+--------------------------------------------------------------------------------+
[6] Access to the URL which was displayed by the command above.
Matched Content