Ubuntu 16.04
Sponsored Link

OpenStack Queens : Boot Instances2018/03/13

 
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.
ubuntu@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)\$ '
ubuntu@dlp:~$
chmod 600 ~/keystonerc

ubuntu@dlp:~$
source ~/keystonerc

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

ubuntu@dlp ~(keystone)$
openstack flavor list

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

# show image list

ubuntu@dlp ~(keystone)$
openstack image list

+--------------------------------------+------------+--------+
| ID                                   | Name       | Status |
+--------------------------------------+------------+--------+
| 217a694d-e526-4921-a018-6b1e6874ef44 | Ubuntu1604 | active |
+--------------------------------------+------------+--------+

# show network list

ubuntu@dlp ~(keystone)$
openstack network list

+--------------------------------------+------------+--------------------------------------+
| ID                                   | Name       | Subnets                              |
+--------------------------------------+------------+--------------------------------------+
| 3cce1101-fbec-4a3b-9569-8fe29575f326 | sharednet1 | b7b060a8-4f3b-4dd1-b55e-1b9847f88e7f |
+--------------------------------------+------------+--------------------------------------+

# create a security group for instances

ubuntu@dlp ~(keystone)$
openstack security group create secgroup01

+-----------------+-------------------------------------------------------------------------------+
| Field           | Value                                                                         |
+-----------------+-------------------------------------------------------------------------------+
| created_at      | 2018-03-15T03:42:03Z                                                          |
| description     | secgroup01                                                                    |
| id              | 3d27410b-7b02-4d75-99c3-c91991eaa913                                          |
| name            | secgroup01                                                                    |
| project_id      | fbfc21a54f2945cfbf47c80bff5685ec                                              |
| revision_number | 2                                                                             |
| rules           | created_at='2018-03-15T03:42:03Z', direction='egress', ethertype='IPv6', ...' |
|                 | created_at='2018-03-15T03:42:03Z', direction='egress', ethertype='IPv4', ...' |
| updated_at      | 2018-03-15T03:42:03Z                                                          |
+-----------------+-------------------------------------------------------------------------------+

ubuntu@dlp ~(keystone)$
openstack security group list

+--------------+------------+------------------------+----------------------------------+
| ID           | Name       | Description            | Project                          |
+--------------+------------+------------------------+----------------------------------+
| 3d27410b-... | secgroup01 | secgroup01             | fbfc21a54f2945cfbf47c80bff5685ec |
| ca4ce169-... | default    | Default security group | fbfc21a54f2945cfbf47c80bff5685ec |
+--------------+------------+------------------------+----------------------------------+

# create a SSH keypair for connecting to instances

ubuntu@dlp ~(keystone)$
ssh-keygen -q -N ""

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

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

+-------------+-------------------------------------------------+
| Field       | Value                                           |
+-------------+-------------------------------------------------+
| fingerprint | 7e:50:51:02:bb:3a:55:2e:7b:d9:51:2a:ec:7f:71:21 |
| name        | mykey                                           |
| user_id     | 0463e786ab6c4a579f7ab6053b5d6a84                |
+-------------+-------------------------------------------------+

ubuntu@dlp ~(keystone)$
openstack keypair list

+-------+-------------------------------------------------+
| Name  | Fingerprint                                     |
+-------+-------------------------------------------------+
| mykey | 7e:50:51:02:bb:3a:55:2e:7b:d9:51:2a:ec:7f:71:21 |
+-------+-------------------------------------------------+

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

# create and boot an instance

ubuntu@dlp ~(keystone)$
openstack server create --flavor m1.small --image Ubuntu1604 --security-group secgroup01 --nic net-id=$netID --key-name mykey Ubuntu_1604
+-----------------------------+---------------------------------------------------+
| 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                   | 48D2iigfvMpk                                      |
| config_drive                |                                                   |
| created                     | 2018-03-15T03:44:19Z                              |
| flavor                      | m1.small (0)                                      |
| hostId                      |                                                   |
| id                          | 35f5a6a6-6ff5-4154-8b5e-4cf37cd12d2b              |
| image                       | Ubuntu1604 (217a694d-e526-4921-a018-6b1e6874ef44) |
| key_name                    | mykey                                             |
| name                        | Ubuntu_1604                                       |
| progress                    | 0                                                 |
| project_id                  | fbfc21a54f2945cfbf47c80bff5685ec                  |
| properties                  |                                                   |
| security_groups             | name='3d27410b-7b02-4d75-99c3-c91991eaa913'       |
| status                      | BUILD                                             |
| updated                     | 2018-03-15T03:44:19Z                              |
| user_id                     | 0463e786ab6c4a579f7ab6053b5d6a84                  |
| volumes_attached            |                                                   |
+-----------------------------+---------------------------------------------------+

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

ubuntu@dlp ~(keystone)$
openstack server list

+--------------------------------------+-------------+--------+-----------------------+------------+----------+
| ID                                   | Name        | Status | Networks              | Image      | Flavor   |
+--------------------------------------+-------------+--------+-----------------------+------------+----------+
| 73ef6229-7bec-4834-83de-c9d5ce0dff9a | Ubuntu_1604 | BUILD  | sharednet1=10.0.0.203 | Ubuntu1604 | m1.small |
+--------------------------------------+-------------+--------+-----------------------+------------+----------+

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

ubuntu@dlp ~(keystone)$
openstack server list

+--------------------------------------+-------------+--------+-----------------------+------------+----------+
| ID                                   | Name        | Status | Networks              | Image      | Flavor   |
+--------------------------------------+-------------+--------+-----------------------+------------+----------+
| 73ef6229-7bec-4834-83de-c9d5ce0dff9a | Ubuntu_1604 | ACTIVE | sharednet1=10.0.0.203 | Ubuntu1604 | m1.small |
+--------------------------------------+-------------+--------+-----------------------+------------+----------+
[2] Configure security settings for the security group you created above to access with SSH and ICMP.
# permit ICMP

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

+-------------------+--------------------------------------+
| Field             | Value                                |
+-------------------+--------------------------------------+
| created_at        | 2018-03-15T03:49:25Z                 |
| description       |                                      |
| direction         | ingress                              |
| ether_type        | IPv4                                 |
| id                | a6c382dd-6995-41df-b7fe-faf49a2429ea |
| name              | None                                 |
| port_range_max    | None                                 |
| port_range_min    | None                                 |
| project_id        | fbfc21a54f2945cfbf47c80bff5685ec     |
| protocol          | icmp                                 |
| remote_group_id   | None                                 |
| remote_ip_prefix  | 0.0.0.0/0                            |
| revision_number   | 0                                    |
| security_group_id | 3d27410b-7b02-4d75-99c3-c91991eaa913 |
| updated_at        | 2018-03-15T03:49:25Z                 |
+-------------------+--------------------------------------+

# permit SSH

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

+-------------------+--------------------------------------+
| Field             | Value                                |
+-------------------+--------------------------------------+
| created_at        | 2018-03-15T03:49:38Z                 |
| description       |                                      |
| direction         | ingress                              |
| ether_type        | IPv4                                 |
| id                | e19830f8-22b5-41be-81b4-edcdf848f947 |
| name              | None                                 |
| port_range_max    | 22                                   |
| port_range_min    | 22                                   |
| project_id        | fbfc21a54f2945cfbf47c80bff5685ec     |
| protocol          | tcp                                  |
| remote_group_id   | None                                 |
| remote_ip_prefix  | 0.0.0.0/0                            |
| revision_number   | 0                                    |
| security_group_id | 3d27410b-7b02-4d75-99c3-c91991eaa913 |
| updated_at        | 2018-03-15T03:49:38Z                 |
+-------------------+--------------------------------------+

ubuntu@dlp ~(keystone)$
openstack security group rule list

+--------------+-------------+-----------+------------+-----------------------------+-------------------+
| ID           | IP Protocol | IP Range  | Port Range | Remote Security Group       | Security Group    |
+--------------+-------------+-----------+------------+-----------------------------+-------------------+
| 268c5a37-... | None        | None      |            | None                        | 3d27410b-7b02-... |
| 2becb989-... | None        | None      |            | ca4ce169-5dd0-465b-92a0-... | ca4ce169-5dd0-... |
| 775a876a-... | None        | None      |            | None                        | ca4ce169-5dd0-... |
| 82b4811a-... | None        | None      |            | None                        | ca4ce169-5dd0-... |
| 997d1c53-... | None        | None      |            | ca4ce169-5dd0-465b-92a0-... | ca4ce169-5dd0-... |
| a6c382dd-... | icmp        | 0.0.0.0/0 |            | None                        | 3d27410b-7b02-... |
| e19830f8-... | tcp         | 0.0.0.0/0 | 22:22      | None                        | 3d27410b-7b02-... |
| e5dbb914-... | None        | None      |            | None                        | 3d27410b-7b02-... |
+--------------+-------------+-----------+------------+-----------------------------+-------------------+
[3] Login to the instance with SSH.
ubuntu@dlp ~(keystone)$
openstack server list

+--------------------------------------+-------------+--------+-----------------------+------------+----------+
| ID                                   | Name        | Status | Networks              | Image      | Flavor   |
+--------------------------------------+-------------+--------+-----------------------+------------+----------+
| 73ef6229-7bec-4834-83de-c9d5ce0dff9a | Ubuntu_1604 | ACTIVE | sharednet1=10.0.0.203 | Ubuntu1604 | m1.small |
+--------------------------------------+-------------+--------+-----------------------+------------+----------+

ubuntu@dlp ~(keystone)$
ping 10.0.0.203 -c3

PING 10.0.0.203 (10.0.0.203) 56(84) bytes of data.
64 bytes from 10.0.0.203: icmp_seq=1 ttl=64 time=0.740 ms
64 bytes from 10.0.0.203: icmp_seq=2 ttl=64 time=0.655 ms
64 bytes from 10.0.0.203: icmp_seq=3 ttl=64 time=0.742 ms

--- 10.0.0.203 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 0.655/0.712/0.742/0.046 ms

ubuntu@dlp ~(keystone)$
ssh ubuntu@10.0.0.203
The authenticity of host '10.0.0.203 (10.0.0.203)' can't be established.
ECDSA key fingerprint is SHA256:4f1NeWiJzKb4im6gUbUW4E4jkkmknhy+1P3yCny4nDY.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.0.0.203' (ECDSA) to the list of known hosts.
Welcome to Ubuntu 16.04.4 LTS (GNU/Linux 4.4.0-116-generic x86_64)

 * Documentation:  https://help.ubuntu.com
 * Management:     https://landscape.canonical.com
 * Support:        https://ubuntu.com/advantage

0 packages can be updated.
0 updates are security updates.

Last login: Thu Mar 15 11:19:07 2018
ubuntu@ubuntu-1604:~$    
# just logined

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

+--------------------------------------+-------------+--------+-----------------------+------------+----------+
| ID                                   | Name        | Status | Networks              | Image      | Flavor   |
+--------------------------------------+-------------+--------+-----------------------+------------+----------+
| 73ef6229-7bec-4834-83de-c9d5ce0dff9a | Ubuntu_1604 | ACTIVE | sharednet1=10.0.0.203 | Ubuntu1604 | m1.small |
+--------------------------------------+-------------+--------+-----------------------+------------+----------+

# stop instance

ubuntu@dlp ~(keystone)$
openstack server stop Ubuntu_1604

ubuntu@dlp ~(keystone)$
openstack server list

+--------------------------------------+-------------+---------+-----------------------+------------+----------+
| ID                                   | Name        | Status  | Networks              | Image      | Flavor   |
+--------------------------------------+-------------+---------+-----------------------+------------+----------+
| 73ef6229-7bec-4834-83de-c9d5ce0dff9a | Ubuntu_1604 | SHUTOFF | sharednet1=10.0.0.203 | Ubuntu1604 | m1.small |
+--------------------------------------+-------------+---------+-----------------------+------------+----------+

# start instance

ubuntu@dlp ~(keystone)$
openstack server start Ubuntu_1604

ubuntu@dlp ~(keystone)$
openstack server list

+--------------------------------------+-------------+--------+-----------------------+------------+----------+
| ID                                   | Name        | Status | Networks              | Image      | Flavor   |
+--------------------------------------+-------------+--------+-----------------------+------------+----------+
| 73ef6229-7bec-4834-83de-c9d5ce0dff9a | Ubuntu_1604 | ACTIVE | sharednet1=10.0.0.203 | Ubuntu1604 | m1.small |
+--------------------------------------+-------------+--------+-----------------------+------------+----------+
[5] It's possible to access with Web browser to get VNC console.
ubuntu@dlp ~(keystone)$
openstack server list

+--------------------------------------+-------------+--------+-----------------------+------------+----------+
| ID                                   | Name        | Status | Networks              | Image      | Flavor   |
+--------------------------------------+-------------+--------+-----------------------+------------+----------+
| 73ef6229-7bec-4834-83de-c9d5ce0dff9a | Ubuntu_1604 | ACTIVE | sharednet1=10.0.0.203 | Ubuntu1604 | m1.small |
+--------------------------------------+-------------+--------+-----------------------+------------+----------+

ubuntu@dlp ~(keystone)$
openstack console url show Ubuntu_1604

+-------+--------------------------------------------------------------------------------+
| Field | Value                                                                          |
+-------+--------------------------------------------------------------------------------+
| type  | novnc                                                                          |
| url   | http://10.0.0.30:6080/vnc_auto.html?token=b066db02-c6e1-441b-81b6-febe025431eb |
+-------+--------------------------------------------------------------------------------+
[6] Access to the URL which was displayed by the command above.
Matched Content