CentOS 7
Sponsored Link

OpenStack Ocata : Run Instances2017/02/27

 
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 |
+--------------------------------------+---------+--------+
| c8f1484e-b877-4447-b6ce-f1baa6bef785 | CentOS7 | active |
+--------------------------------------+---------+--------+

# show the list of network

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

+--------------------------------------+------------+--------------------------------------+
| ID                                   | Name       | Subnets                              |
+--------------------------------------+------------+--------------------------------------+
| 20f54b04-74a2-44e3-a187-e0fa1e7289e7 | sharednet1 | 4ae2ff30-ce64-4444-a770-08f350fa5a6d |
+--------------------------------------+------------+--------------------------------------+

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

# create and boot an instance

[root@dlp ~(keystone)]#
openstack server create --flavor m1.small --image CentOS7 --security-group default --nic net-id=$netID 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                           | 4PkvwmeLorP2                                   |
| config_drive                        |                                                |
| created                             | 2017-02-28T07:47:14Z                           |
| flavor                              | m1.small (0)                                   |
| hostId                              |                                                |
| id                                  | da129ae7-dc41-4c9b-b6c3-a8e073a9bbcb           |
| image                               | CentOS7 (c8f1484e-b877-4447-b6ce-f1baa6bef785) |
| key_name                            | None                                           |
| name                                | CentOS_7                                       |
| progress                            | 0                                              |
| project_id                          | c654e2e098b14356b97b6e613775cc54               |
| properties                          |                                                |
| security_groups                     | name='default'                                 |
| status                              | BUILD                                          |
| updated                             | 2017-02-28T07:47:15Z                           |
| user_id                             | cf3c5cbcdd214707b91d322a69af038e               |
| volumes_attached                    |                                                |
+-------------------------------------+------------------------------------------------+

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

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

+--------------------------------------+----------+--------+-----------------------+------------+
| ID                                   | Name     | Status | Networks              | Image Name |
+--------------------------------------+----------+--------+-----------------------+------------+
| da129ae7-dc41-4c9b-b6c3-a8e073a9bbcb | CentOS_7 | BUILD  | sharednet1=10.0.0.201 | CentOS7    |
+--------------------------------------+----------+--------+-----------------------+------------+

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

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

+--------------------------------------+----------+--------+-----------------------+------------+
| ID                                   | Name     | Status | Networks              | Image Name |
+--------------------------------------+----------+--------+-----------------------+------------+
| da129ae7-dc41-4c9b-b6c3-a8e073a9bbcb | CentOS_7 | ACTIVE | sharednet1=10.0.0.201 | CentOS7    |
+--------------------------------------+----------+--------+-----------------------+------------+
[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-02-28T07:54:12Z                 |
| description       |                                      |
| direction         | ingress                              |
| ether_type        | IPv4                                 |
| id                | 180e4ec7-9221-42fb-bdba-382c5a06a8f4 |
| name              | None                                 |
| port_range_max    | None                                 |
| port_range_min    | None                                 |
| project_id        | c654e2e098b14356b97b6e613775cc54     |
| protocol          | icmp                                 |
| remote_group_id   | None                                 |
| remote_ip_prefix  | 0.0.0.0/0                            |
| revision_number   | 1                                    |
| security_group_id | 160e1d9e-72b9-4ed3-a434-276518f22a7b |
| updated_at        | 2017-02-28T07:54:12Z                 |
+-------------------+--------------------------------------+

# permit SSH

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

+-------------------+--------------------------------------+
| Field             | Value                                |
+-------------------+--------------------------------------+
| created_at        | 2017-02-28T07:55:14Z                 |
| description       |                                      |
| direction         | ingress                              |
| ether_type        | IPv4                                 |
| id                | 93a858de-87b5-4544-8d23-ef4f24da5f3b |
| name              | None                                 |
| port_range_max    | 22                                   |
| port_range_min    | 22                                   |
| project_id        | c654e2e098b14356b97b6e613775cc54     |
| protocol          | tcp                                  |
| remote_group_id   | None                                 |
| remote_ip_prefix  | 0.0.0.0/0                            |
| revision_number   | 1                                    |
| security_group_id | 160e1d9e-72b9-4ed3-a434-276518f22a7b |
| updated_at        | 2017-02-28T07:55:14Z                 |
+-------------------+--------------------------------------+

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

+-------------------+-------------+-----------+------------+--------------------------------------+--------------+
| ID                | IP Protocol | IP Range  | Port Range | Remote Security Group                | Security Gro |
+-------------------+-------------+-----------+------------+--------------------------------------+--------------+
| 180e4ec7-9221-... | icmp        | 0.0.0.0/0 |            | None                                 | 160e1d9e-... |
| 29b38eb3-2004-... | None        | None      |            | 160e1d9e-72b9-4ed3-a434-276518f22a7b | 160e1d9e-... |
| 93a858de-87b5-... | tcp         | 0.0.0.0/0 | 22:22      | None                                 | 160e1d9e-... |
| 9f86c90e-6357-... | None        | None      |            | None                                 | 160e1d9e-... |
| a1feacc0-c8ea-... | None        | None      |            | None                                 | 160e1d9e-... |
| f46d96c3-235a-... | None        | None      |            | 160e1d9e-72b9-4ed3-a434-276518f22a7b | 160e1d9e-... |
+-------------------+-------------+-----------+------------+--------------------------------------+--------------+
[3] Login to instance with SSH.
[root@dlp ~(keystone)]#
openstack server list

+--------------------------------------+----------+--------+-----------------------+------------+
| ID                                   | Name     | Status | Networks              | Image Name |
+--------------------------------------+----------+--------+-----------------------+------------+
| da129ae7-dc41-4c9b-b6c3-a8e073a9bbcb | CentOS_7 | ACTIVE | sharednet1=10.0.0.201 | CentOS7    |
+--------------------------------------+----------+--------+-----------------------+------------+

[root@dlp ~(keystone)]#
ping 10.0.0.201

PING 10.0.0.201 (10.0.0.201) 56(84) bytes of data.
64 bytes from 10.0.0.201: icmp_seq=1 ttl=63 time=2.17 ms
64 bytes from 10.0.0.201: icmp_seq=2 ttl=64 time=0.920 ms
^C
--- 10.0.0.201 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 0.920/1.546/2.173/0.627 ms

[root@dlp ~(keystone)]#
ssh 10.0.0.201

The authenticity of host '10.0.0.201 (10.0.0.201)' can't be established.
ECDSA key fingerprint is xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.0.0.201' (ECDSA) to the list of known hosts.
root@10.0.0.201's password:   # the one you set during installation
Last login: Tue Feb 28 15:47:44 2017
[root@host-10-0-0-201 ~]#    
# just logined

[4] If you using a virtual machine image provided from internet and do not know any password for login, Add SSH key-pair to login like follows. For self-created image, if you installed [cloud-init] package and enable [cloud-init] service in it, it's possible to set SSH key-pair for it. The default user of cloud-init setting for SSH is "centos" user.
# create key-pair

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

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

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

+-------------+-------------------------------------------------+
| Field       | Value                                           |
+-------------+-------------------------------------------------+
| fingerprint | 23:a9:8c:a2:61:57:ff:77:bc:11:45:ca:ca:d7:c2:7e |
| name        | mykey                                           |
| user_id     | cf3c5cbcdd214707b91d322a69af038e                |
+-------------+-------------------------------------------------+

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

+-------+-------------------------------------------------+
| Name  | Fingerprint                                     |
+-------+-------------------------------------------------+
| mykey | 23:a9:8c:a2:61:57:ff:77:bc:11:45:ca:ca:d7:c2:7e |
+-------+-------------------------------------------------+

# run instance with key

[root@dlp ~(keystone)]#
openstack server create --flavor m1.small --image CentOS7 --security-group default --nic net-id=$netID --key-name mykey CentOS_7
[root@dlp ~(keystone)]#
openstack server list

+--------------------------------------+----------+--------+-----------------------+------------+
| ID                                   | Name     | Status | Networks              | Image Name |
+--------------------------------------+----------+--------+-----------------------+------------+
| 130c2b1b-5055-47ff-a12f-d3c4cd53534b | CentOS_7 | ACTIVE | sharednet1=10.0.0.194 | CentOS7    |
+--------------------------------------+----------+--------+-----------------------+------------+

# login with key

[root@dlp ~(keystone)]#
ssh -i mykey centos@10.0.0.194
[centos@centos-7 ~]$    
# just logined

[5] 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 |
+--------------------------------------+----------+--------+-----------------------+------------+
| 0b696343-1e50-4a1f-ad95-92f697e8551e | CentOS_7 | ACTIVE | sharednet1=10.0.0.201 | CentOS7    |
+--------------------------------------+----------+--------+-----------------------+------------+

# stop instance

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

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

+--------------------------------------+----------+---------+-----------------------+------------+
| ID                                   | Name     | Status  | Networks              | Image Name |
+--------------------------------------+----------+---------+-----------------------+------------+
| 0b696343-1e50-4a1f-ad95-92f697e8551e | CentOS_7 | SHUTOFF | sharednet1=10.0.0.201 | CentOS7    |
+--------------------------------------+----------+---------+-----------------------+------------+

# start instance

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

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

+--------------------------------------+----------+--------+-----------------------+------------+
| ID                                   | Name     | Status | Networks              | Image Name |
+--------------------------------------+----------+--------+-----------------------+------------+
| 0b696343-1e50-4a1f-ad95-92f697e8551e | CentOS_7 | ACTIVE | sharednet1=10.0.0.201 | CentOS7    |
+--------------------------------------+----------+--------+-----------------------+------------+
[6] It's possible to access with Web browser to get VNC console.
[root@dlp ~(keystone)]#
openstack server list

+--------------------------------------+----------+--------+-----------------------+------------+
| ID                                   | Name     | Status | Networks              | Image Name |
+--------------------------------------+----------+--------+-----------------------+------------+
| 0b696343-1e50-4a1f-ad95-92f697e8551e | CentOS_7 | ACTIVE | sharednet1=10.0.0.201 | CentOS7    |
+--------------------------------------+----------+--------+-----------------------+------------+

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

+-------+--------------------------------------------------------------------------------+
| Field | Value                                                                          |
+-------+--------------------------------------------------------------------------------+
| type  | novnc                                                                          |
| url   | http://10.0.0.30:6080/vnc_auto.html?token=70092084-18f8-426f-a20c-61885043a522 |
+-------+--------------------------------------------------------------------------------+
[7] Access to the URL which was displayed by the command above.
Matched Content