CentOS 7
Sponsored Link

OpenStack Rocky : Run Instances
2018/08/31
 
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 |
+--------------------------------------+---------+--------+
| 05269b20-9625-46b6-8377-3893c70906bd | CentOS7 | active |
+--------------------------------------+---------+--------+

# show network list

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

+--------------------------------------+------------+--------------------------------------+
| ID                                   | Name       | Subnets                              |
+--------------------------------------+------------+--------------------------------------+
| eaaf7e9b-a448-4827-b07c-e0c75dd2410c | sharednet1 | d3e3dca6-218a-405a-b115-70d5a257620e |
+--------------------------------------+------------+--------------------------------------+

# create a security group for instances

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

+-----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field           | Value                                                                                                                                                 |
+-----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
| created_at      | 2018-08-31T03:44:23Z                                                                                                                                  |
| description     | secgroup01                                                                                                                                            |
| id              | 504974ac-4389-4474-bd6b-499cad7de9a4                                                                                                                  |
| name            | secgroup01                                                                                                                                            |
| project_id      | 9c0848a6869b433f8c18c75a868ee8e0                                                                                                                      |
| revision_number | 1                                                                                                                                                     |
| rules           | created_at='2018-08-31T03:44:23Z', direction='egress', ethertype='IPv6', id='05ebbd23-a11a-4c7d-9e94-313b41224b1b', updated_at='2018-08-31T03:44:23Z' |
|                 | created_at='2018-08-31T03:44:23Z', direction='egress', ethertype='IPv4', id='5ebaa40e-1420-4831-802a-97233ab8afee', updated_at='2018-08-31T03:44:23Z' |
| tags            | []                                                                                                                                                    |
| updated_at      | 2018-08-31T03:44:23Z                                                                                                                                  |
+-----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+

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

+--------------------------------------+------------+------------------------+----------------------------------+------+
| ID                                   | Name       | Description            | Project                          | Tags |
+--------------------------------------+------------+------------------------+----------------------------------+------+
| 504974ac-4389-4474-bd6b-499cad7de9a4 | secgroup01 | secgroup01             | 9c0848a6869b433f8c18c75a868ee8e0 | []   |
| f4ecd970-95f3-4147-a532-2a41b7041dce | default    | Default security group | 9c0848a6869b433f8c18c75a868ee8e0 | []   |
+--------------------------------------+------------+------------------------+----------------------------------+------+

# 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 | 74:04:ac:87:65:b0:1b:11:45:a1:ae:42:69:0d:1b:d5 |
| name        | mykey                                           |
| user_id     | 30089f6b629745c697ec11038c34d5df                |
+-------------+-------------------------------------------------+

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

+-------+-------------------------------------------------+
| Name  | Fingerprint                                     |
+-------+-------------------------------------------------+
| mykey | 74:04:ac:87:65:b0:1b:11:45:a1:ae:42:69:0d:1b:d5 |
+-------+-------------------------------------------------+

[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                   | VK93X24Ug2g7                                   |
| config_drive                |                                                |
| created                     | 2018-08-31T03:47:53Z                           |
| flavor                      | m1.small (0)                                   |
| hostId                      |                                                |
| id                          | e07e180f-3622-43f0-8477-01baf16e5267           |
| image                       | CentOS7 (05269b20-9625-46b6-8377-3893c70906bd) |
| key_name                    | mykey                                          |
| name                        | CentOS_7                                       |
| progress                    | 0                                              |
| project_id                  | 9c0848a6869b433f8c18c75a868ee8e0               |
| properties                  |                                                |
| security_groups             | name='504974ac-4389-4474-bd6b-499cad7de9a4'    |
| status                      | BUILD                                          |
| updated                     | 2018-08-31T03:47:53Z                           |
| user_id                     | 30089f6b629745c697ec11038c34d5df               |
| volumes_attached            |                                                |
+-----------------------------+------------------------------------------------+

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

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

+--------------------------------------+----------+--------+----------+---------+----------+
| ID                                   | Name     | Status | Networks | Image   | Flavor   |
+--------------------------------------+----------+--------+----------+---------+----------+
| e07e180f-3622-43f0-8477-01baf16e5267 | CentOS_7 | BUILD  |          | CentOS7 | m1.small |
+--------------------------------------+----------+--------+----------+---------+----------+

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

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

+--------------------------------------+----------+--------+-----------------------+---------+----------+
| ID                                   | Name     | Status | Networks              | Image   | Flavor   |
+--------------------------------------+----------+--------+-----------------------+---------+----------+
| e07e180f-3622-43f0-8477-01baf16e5267 | CentOS_7 | ACTIVE | sharednet1=10.0.0.228 | 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-08-31T03:48:51Z                 |
| description       |                                      |
| direction         | ingress                              |
| ether_type        | IPv4                                 |
| id                | db32dac3-ee3e-420f-b89e-00156753d68a |
| name              | None                                 |
| port_range_max    | None                                 |
| port_range_min    | None                                 |
| project_id        | 9c0848a6869b433f8c18c75a868ee8e0     |
| protocol          | icmp                                 |
| remote_group_id   | None                                 |
| remote_ip_prefix  | 0.0.0.0/0                            |
| revision_number   | 0                                    |
| security_group_id | 504974ac-4389-4474-bd6b-499cad7de9a4 |
| updated_at        | 2018-08-31T03:48:51Z                 |
+-------------------+--------------------------------------+

# permit SSH

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

+-------------------+--------------------------------------+
| Field             | Value                                |
+-------------------+--------------------------------------+
| created_at        | 2018-08-31T03:49:06Z                 |
| description       |                                      |
| direction         | ingress                              |
| ether_type        | IPv4                                 |
| id                | 9ef85819-9fbc-4f4e-ada3-d085e3935b14 |
| name              | None                                 |
| port_range_max    | 22                                   |
| port_range_min    | 22                                   |
| project_id        | 9c0848a6869b433f8c18c75a868ee8e0     |
| protocol          | tcp                                  |
| remote_group_id   | None                                 |
| remote_ip_prefix  | 0.0.0.0/0                            |
| revision_number   | 0                                    |
| security_group_id | 504974ac-4389-4474-bd6b-499cad7de9a4 |
| updated_at        | 2018-08-31T03:49:06Z                 |
+-------------------+--------------------------------------+

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

+--------------------------------------+-------------+-----------+------------+--------------------------------------+--------------------------------------+
| ID                                   | IP Protocol | IP Range  | Port Range | Remote Security Group                | Security Group                       |
+--------------------------------------+-------------+-----------+------------+--------------------------------------+--------------------------------------+
| 05ebbd23-a11a-4c7d-9e94-313b41224b1b | None        | None      |            | None                                 | 504974ac-4389-4474-bd6b-499cad7de9a4 |
| 15c8a42c-3b5a-46f0-b743-3143ac46139e | None        | None      |            | f4ecd970-95f3-4147-a532-2a41b7041dce | f4ecd970-95f3-4147-a532-2a41b7041dce |
| 438565b4-d366-42db-b841-00bab90a6819 | None        | None      |            | None                                 | f4ecd970-95f3-4147-a532-2a41b7041dce |
| 5ebaa40e-1420-4831-802a-97233ab8afee | None        | None      |            | None                                 | 504974ac-4389-4474-bd6b-499cad7de9a4 |
| 9ef85819-9fbc-4f4e-ada3-d085e3935b14 | tcp         | 0.0.0.0/0 | 22:22      | None                                 | 504974ac-4389-4474-bd6b-499cad7de9a4 |
| db32dac3-ee3e-420f-b89e-00156753d68a | icmp        | 0.0.0.0/0 |            | None                                 | 504974ac-4389-4474-bd6b-499cad7de9a4 |
| f92e2d9d-a148-4385-a663-2be35da77ec0 | None        | None      |            | f4ecd970-95f3-4147-a532-2a41b7041dce | f4ecd970-95f3-4147-a532-2a41b7041dce |
| faccd4ae-b26a-4631-92a7-643d07686b21 | None        | None      |            | None                                 | f4ecd970-95f3-4147-a532-2a41b7041dce |
+--------------------------------------+-------------+-----------+------------+--------------------------------------+--------------------------------------+
[3] Login to the instance with SSH.
[cent@dlp ~(keystone)]$
openstack server list

+--------------------------------------+----------+--------+-----------------------+---------+----------+
| ID                                   | Name     | Status | Networks              | Image   | Flavor   |
+--------------------------------------+----------+--------+-----------------------+---------+----------+
| e07e180f-3622-43f0-8477-01baf16e5267 | CentOS_7 | ACTIVE | sharednet1=10.0.0.228 | CentOS7 | m1.small |
+--------------------------------------+----------+--------+-----------------------+---------+----------+

[cent@dlp ~(keystone)]$
ping 10.0.0.228 -c3

PING 10.0.0.228 (10.0.0.228) 56(84) bytes of data.
64 bytes from 10.0.0.228: icmp_seq=1 ttl=64 time=5.12 ms
64 bytes from 10.0.0.228: icmp_seq=2 ttl=64 time=1.04 ms
64 bytes from 10.0.0.228: icmp_seq=3 ttl=64 time=1.58 ms

--- 10.0.0.228 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 1.049/2.588/5.127/1.809 ms

[cent@dlp ~(keystone)]$
ssh centos@10.0.0.228
The authenticity of host '10.0.0.228 (10.0.0.228)' can't be established.
ECDSA key fingerprint is SHA256:a6aknOruK4Or1IjIZbgYgp+IswyON5L7gjQtGpG0SVw.
ECDSA key fingerprint is MD5:1f:b0:09:b7:eb:3b:54:ff:3f:e2:9d:b3:46:20:08:e7.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.0.0.228' (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   |
+--------------------------------------+----------+--------+-----------------------+---------+----------+
| e07e180f-3622-43f0-8477-01baf16e5267 | CentOS_7 | ACTIVE | sharednet1=10.0.0.228 | 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   |
+--------------------------------------+----------+---------+-----------------------+---------+----------+
| e07e180f-3622-43f0-8477-01baf16e5267 | CentOS_7 | SHUTOFF | sharednet1=10.0.0.228 | 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   |
+--------------------------------------+----------+--------+-----------------------+---------+----------+
| e07e180f-3622-43f0-8477-01baf16e5267 | CentOS_7 | ACTIVE | sharednet1=10.0.0.228 | 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   |
+--------------------------------------+----------+--------+-----------------------+---------+----------+
| e07e180f-3622-43f0-8477-01baf16e5267 | CentOS_7 | ACTIVE | sharednet1=10.0.0.228 | 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=d526c701-c3f5-4c24-8396-de53b15d9b3d |
+-------+--------------------------------------------------------------------------------+
[6] Access to the URL which was displayed by the command above.
Matched Content
 
Tweet