CentOS 7
Sponsored Link

OpenStack Queens : Run Instances
2018/03/05
 
Create and Start Virtual Machine Instance.
[1] Login with a user and create a config for authentication of Keystyone. The username or password in the config are just the one you added in keystone like here. Next Create and run an instance.
[cent@dlp ~]$
vi ~/keystonerc
export OS_PROJECT_DOMAIN_NAME=default
export OS_USER_DOMAIN_NAME=default
export OS_PROJECT_NAME=hiroshima
export OS_USERNAME=serverworld
export OS_PASSWORD=userpassword
export OS_AUTH_URL=http://10.0.0.30:5000/v3
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2
export PS1='[\u@\h \W(keystone)]\$ '
[cent@dlp ~]$
chmod 600 ~/keystonerc

[cent@dlp ~]$
source ~/keystonerc

[cent@dlp ~(keystone)]$
echo "source ~/keystonerc " >> ~/.bash_profile
# show flavor list

[cent@dlp ~(keystone)]$
openstack flavor list

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

# show image list

[cent@dlp ~(keystone)]$
openstack image list

+--------------------------------------+---------+--------+
| ID                                   | Name    | Status |
+--------------------------------------+---------+--------+
| 88551fbc-ce7e-4719-a67a-dd7cad478019 | CentOS7 | active |
+--------------------------------------+---------+--------+

# show network list

[cent@dlp ~(keystone)]$
openstack network list

+--------------------------------------+------------+--------------------------------------+
| ID                                   | Name       | Subnets                              |
+--------------------------------------+------------+--------------------------------------+
| 535194ec-9acd-4132-bfe7-0979d908f145 | sharednet1 | d3c17a00-d3ff-4bf2-8d98-03cd6b95c57a |
+--------------------------------------+------------+--------------------------------------+

# create a security group for instances

[cent@dlp ~(keystone)]$
openstack security group create secgroup01

+-----------------+------------------------------------------------------------+
| Field           | Value                                                      |
+-----------------+------------------------------------------------------------+
| created_at      | 2018-03-07T02:46:41Z                                       |
| description     | secgroup01                                                 |
| id              | 531679bf-6f46-40ca-805a-328da125198b                       |
| name            | secgroup01                                                 |
| project_id      | a3c3e533531c48c48dcd643d13d307e5                           |
| revision_number | 2                                                          |
| rules           | created_at='2018-03-07T02:46:41Z', direction='egress',...' |
|                 | created_at='2018-03-07T02:46:41Z', direction='egress',...' |
| updated_at      | 2018-03-07T02:46:41Z                                       |
+-----------------+------------------------------------------------------------+

[cent@dlp ~(keystone)]$
openstack security group list

+--------------+------------+------------------------+----------------------------------+
| ID           | Name       | Description            | Project                          |
+--------------+------------+------------------------+----------------------------------+
| 531679bf-... | secgroup01 | secgroup01             | a3c3e533531c48c48dcd643d13d307e5 |
| f074c601-... | default    | Default security group | a3c3e533531c48c48dcd643d13d307e5 |
+--------------+------------+------------------------+----------------------------------+

# create a SSH keypair for connecting to instances

[cent@dlp ~(keystone)]$
ssh-keygen -q -N ""

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

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

+-------------+-------------------------------------------------+
| Field       | Value                                           |
+-------------+-------------------------------------------------+
| fingerprint | 36:fe:4c:e4:7f:a3:27:1a:f7:a3:4f:fa:b9:a6:16:92 |
| name        | mykey                                           |
| user_id     | a1ecf467167542bdb615ba4311f4bf0a                |
+-------------+-------------------------------------------------+

[cent@dlp ~(keystone)]$
openstack keypair list

+-------+-------------------------------------------------+
| Name  | Fingerprint                                     |
+-------+-------------------------------------------------+
| mykey | 36:fe:4c:e4:7f:a3:27:1a:f7:a3:4f:fa:b9:a6:16:92 |
+-------+-------------------------------------------------+

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

# create and boot an instance

[cent@dlp ~(keystone)]$
openstack server create --flavor m1.small --image CentOS7 --security-group secgroup01 --nic net-id=$netID --key-name mykey CentOS_7
+-----------------------------+------------------------------------------------+
| Field                       | Value                                          |
+-----------------------------+------------------------------------------------+
| OS-DCF:diskConfig           | MANUAL                                         |
| OS-EXT-AZ:availability_zone |                                                |
| 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                   | 7zEPamrpKwTN                                   |
| config_drive                |                                                |
| created                     | 2018-03-07T02:52:05Z                           |
| flavor                      | m1.small (0)                                   |
| hostId                      |                                                |
| id                          | a4974dee-7791-4dec-81d9-d348ee7e1ebd           |
| image                       | CentOS7 (88551fbc-ce7e-4719-a67a-dd7cad478019) |
| key_name                    | mykey                                          |
| name                        | CentOS_7                                       |
| progress                    | 0                                              |
| project_id                  | a3c3e533531c48c48dcd643d13d307e5               |
| properties                  |                                                |
| security_groups             | name='531679bf-6f46-40ca-805a-328da125198b'    |
| status                      | BUILD                                          |
| updated                     | 2018-03-07T02:52:05Z                           |
| user_id                     | a1ecf467167542bdb615ba4311f4bf0a               |
| volumes_attached            |                                                |
+-----------------------------+------------------------------------------------+

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

[cent@dlp ~(keystone)]$
openstack server list

+--------------------------------------+----------+--------+-----------------------+---------+----------+
| ID                                   | Name     | Status | Networks              | Image   | Flavor   |
+--------------------------------------+----------+--------+-----------------------+---------+----------+
| a4974dee-7791-4dec-81d9-d348ee7e1ebd | CentOS_7 | BUILD  | sharednet1=10.0.0.202 | CentOS7 | m1.small |
+--------------------------------------+----------+--------+-----------------------+---------+----------+

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

[cent@dlp ~(keystone)]$
openstack server list

+--------------------------------------+----------+--------+-----------------------+---------+----------+
| ID                                   | Name     | Status | Networks              | Image   | Flavor   |
+--------------------------------------+----------+--------+-----------------------+---------+----------+
| a4974dee-7791-4dec-81d9-d348ee7e1ebd | CentOS_7 | ACTIVE | sharednet1=10.0.0.202 | CentOS7 | m1.small |
+--------------------------------------+----------+--------+-----------------------+---------+----------+
[2] Configure security settings for the security group you created above to access with SSH and ICMP.
# permit ICMP

[cent@dlp ~(keystone)]$
openstack security group rule create --protocol icmp --ingress secgroup01

+-------------------+--------------------------------------+
| Field             | Value                                |
+-------------------+--------------------------------------+
| created_at        | 2018-03-07T03:41:24Z                 |
| description       |                                      |
| direction         | ingress                              |
| ether_type        | IPv4                                 |
| id                | fcd9c723-99f3-4b34-9621-46bdc4a78fd3 |
| name              | None                                 |
| port_range_max    | None                                 |
| port_range_min    | None                                 |
| project_id        | a3c3e533531c48c48dcd643d13d307e5     |
| protocol          | icmp                                 |
| remote_group_id   | None                                 |
| remote_ip_prefix  | 0.0.0.0/0                            |
| revision_number   | 0                                    |
| security_group_id | 531679bf-6f46-40ca-805a-328da125198b |
| updated_at        | 2018-03-07T03:41:24Z                 |
+-------------------+--------------------------------------+

# permit SSH

[cent@dlp ~(keystone)]$
openstack security group rule create --protocol tcp --dst-port 22:22 secgroup01

+-------------------+--------------------------------------+
| Field             | Value                                |
+-------------------+--------------------------------------+
| created_at        | 2018-03-07T03:41:41Z                 |
| description       |                                      |
| direction         | ingress                              |
| ether_type        | IPv4                                 |
| id                | a80efaec-1f24-423f-ba99-c90b4c5b9046 |
| name              | None                                 |
| port_range_max    | 22                                   |
| port_range_min    | 22                                   |
| project_id        | a3c3e533531c48c48dcd643d13d307e5     |
| protocol          | tcp                                  |
| remote_group_id   | None                                 |
| remote_ip_prefix  | 0.0.0.0/0                            |
| revision_number   | 0                                    |
| security_group_id | 531679bf-6f46-40ca-805a-328da125198b |
| updated_at        | 2018-03-07T03:41:41Z                 |
+-------------------+--------------------------------------+

[cent@dlp ~(keystone)]$
openstack security group rule list

+--------------+-------------+-----------+------------+-----------------------------+---------------------+
| ID           | IP Protocol | IP Range  | Port Range | Remote Security Group       | Security Group      |
+--------------+-------------+-----------+------------+-----------------------------+---------------------+
| 073e7f63-... | None        | None      |            | f074c601-6177-4bd8-bcac-... | f074c601-6177-43... |
| 4ae961ff-... | None        | None      |            | None                        | 531679bf-6f46-41... |
| 4d1df410-... | None        | None      |            | None                        | f074c601-6177-43... |
| a80efaec-... | tcp         | 0.0.0.0/0 | 22:22      | None                        | 531679bf-6f46-41... |
| da9cdf72-... | None        | None      |            | f074c601-6177-4bd8-bcac-... | f074c601-6177-43... |
| e2d26251-... | None        | None      |            | None                        | f074c601-6177-43... |
| e6f25123-... | None        | None      |            | None                        | 531679bf-6f46-41... |
| fcd9c723-... | icmp        | 0.0.0.0/0 |            | None                        | 531679bf-6f46-41... |
+--------------+-------------+-----------+------------+-----------------------------+---------------------+
[3] Login to the instance with SSH.
[cent@dlp ~(keystone)]$
openstack server list

+--------------------------------------+----------+--------+-----------------------+---------+----------+
| ID                                   | Name     | Status | Networks              | Image   | Flavor   |
+--------------------------------------+----------+--------+-----------------------+---------+----------+
| a4974dee-7791-4dec-81d9-d348ee7e1ebd | CentOS_7 | ACTIVE | sharednet1=10.0.0.202 | CentOS7 | m1.small |
+--------------------------------------+----------+--------+-----------------------+---------+----------+

[cent@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.94 ms
64 bytes from 10.0.0.202: icmp_seq=2 ttl=64 time=1.24 ms
64 bytes from 10.0.0.202: icmp_seq=3 ttl=64 time=1.21 ms

--- 10.0.0.202 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 1.214/2.134/3.948/1.283 ms

[cent@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 SHA256:xHIBEd/rhh5IPJGv7rXS/VmbM+4i2FJMA6UWPA0UUT8.
ECDSA key fingerprint is MD5:5b:01:d5:5a:40:c5:1a:d7:05:40:f6:96:0a:db:52:6d.
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.
[cent@dlp ~(keystone)]$
openstack server list

+--------------------------------------+----------+--------+-----------------------+---------+----------+
| ID                                   | Name     | Status | Networks              | Image   | Flavor   |
+--------------------------------------+----------+--------+-----------------------+---------+----------+
| a4974dee-7791-4dec-81d9-d348ee7e1ebd | CentOS_7 | ACTIVE | sharednet1=10.0.0.202 | CentOS7 | m1.small |
+--------------------------------------+----------+--------+-----------------------+---------+----------+

# stop instance

[cent@dlp ~(keystone)]$
openstack server stop CentOS_7

[cent@dlp ~(keystone)]$
openstack server list

+--------------------------------------+----------+---------+-----------------------+---------+----------+
| ID                                   | Name     | Status  | Networks              | Image   | Flavor   |
+--------------------------------------+----------+---------+-----------------------+---------+----------+
| a4974dee-7791-4dec-81d9-d348ee7e1ebd | CentOS_7 | SHUTOFF | sharednet1=10.0.0.202 | CentOS7 | m1.small |
+--------------------------------------+----------+---------+-----------------------+---------+----------+

# start instance

[cent@dlp ~(keystone)]$
openstack server start CentOS_7

[cent@dlp ~(keystone)]$
openstack server list

+--------------------------------------+----------+--------+-----------------------+---------+----------+
| ID                                   | Name     | Status | Networks              | Image   | Flavor   |
+--------------------------------------+----------+--------+-----------------------+---------+----------+
| a4974dee-7791-4dec-81d9-d348ee7e1ebd | CentOS_7 | ACTIVE | sharednet1=10.0.0.202 | CentOS7 | m1.small |
+--------------------------------------+----------+--------+-----------------------+---------+----------+
[5] It's possible to access with Web browser to get VNC console.
[cent@dlp ~(keystone)]$
openstack server list

+--------------------------------------+----------+--------+-----------------------+---------+----------+
| ID                                   | Name     | Status | Networks              | Image   | Flavor   |
+--------------------------------------+----------+--------+-----------------------+---------+----------+
| a4974dee-7791-4dec-81d9-d348ee7e1ebd | CentOS_7 | ACTIVE | sharednet1=10.0.0.202 | CentOS7 | m1.small |
+--------------------------------------+----------+--------+-----------------------+---------+----------+

[cent@dlp ~(keystone)]$
openstack console url show CentOS_7

+-------+--------------------------------------------------------------------------------+
| Field | Value                                                                          |
+-------+--------------------------------------------------------------------------------+
| type  | novnc                                                                          |
| url   | http://10.0.0.30:6080/vnc_auto.html?token=37a06156-b9d7-469d-932d-ac88a9fae1ea |
+-------+--------------------------------------------------------------------------------+
[6] Access to the URL which was displayed by the command above.
Matched Content
 
Tweet