Minimum Steps To VM After DevStack
Sometimes, You just want to launch a VM and deep dive into OpenStack.
You don't really need to use it from Horizon.
This blog provides you a minimum steps to launch a VM and ssh login to VM.
Devstack Installaion
Baed on my privious Blog
http://gogosatellite.blogspot.tw/2016/06/install-openstack-ceilometer-and.html
Minimum Steps
Launch An Instance
Create Environment
source openrc demo admin
Get Image ID
stack@mitakagnocchi:~/devstack$ glance image-list
+--------------------------------------+---------------------------------+
| ID | Name |
+--------------------------------------+---------------------------------+
| 75d4ca92-7f36-49ab-ae70-6aeb3a2ec03f | cirros-0.3.3-x86_64-uec |
| 65e2060c-518e-474b-b288-cc2b5211f749 | cirros-0.3.3-x86_64-uec-kernel |
| c77fe924-5051-4939-8081-9bace82a0148 | cirros-0.3.3-x86_64-uec-ramdisk |
Get Network ID
stack@mitakagnocchi:~/devstack$ nova net-list
+--------------------------------------+---------+------+
| ID | Label | CIDR |
+--------------------------------------+---------+------+
| 4fd6554f-b3bb-4cea-b58b-45ca966652ab | private | None |
| a10c3555-bcd7-42ea-98c5-89412acdae36 | public | None |
+--------------------------------------+---------+------+
Get Flavor ID
stack@mitakagnocchi:~/devstack$ nova flavor-list
+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+
| ID | Name | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public |
+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+
| 1 | m1.tiny | 512 | 1 | 0 | | 1 | 1.0 | True |
| 2 | m1.small | 2048 | 20 | 0 | | 1 | 1.0 | True |
| 3 | m1.medium | 4096 | 40 | 0 | | 2 | 1.0 | True |
| 4 | m1.large | 8192 | 80 | 0 | | 4 | 1.0 | True |
| 5 | m1.xlarge | 16384 | 160 | 0 | | 8 | 1.0 | True |
+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+
Launch A Instance
stack@mitakagnocchi:~/devstack$ nova boot --image 75d4ca92-7f36-49ab-ae70-6aeb3a2ec03f --flavor 1 --nic net-id=4fd6554f-b3bb-4cea-b58b-45ca966652ab lala1
+--------------------------------------+----------------------------------------------------------------+
| Property | Value |
+--------------------------------------+----------------------------------------------------------------+
| OS-DCF:diskConfig | MANUAL |
| OS-EXT-AZ:availability_zone | |
| OS-EXT-SRV-ATTR:host | - |
| OS-EXT-SRV-ATTR:hostname | lala1 |
| OS-EXT-SRV-ATTR:hypervisor_hostname | - |
| OS-EXT-SRV-ATTR:instance_name | instance-00000002 |
| OS-EXT-SRV-ATTR:kernel_id | 65e2060c-518e-474b-b288-cc2b5211f749 |
| OS-EXT-SRV-ATTR:launch_index | 0 |
| OS-EXT-SRV-ATTR:ramdisk_id | c77fe924-5051-4939-8081-9bace82a0148 |
| OS-EXT-SRV-ATTR:reservation_id | r-xg7gtpwc |
nova boot --image <img-id> --flavor <flavor-id> --nic net-id=<private net-id> <instance_name>
To Check VM Status
stack@mitakagnocchi:~/devstack$ nova list
+--------------------------------------+-------+--------+------------+-------------+--------------------------------------------------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+-------+--------+------------+-------------+--------------------------------------------------------+
| 1db0600f-c30b-49a0-9d46-b501002ad8b6 | lala1 | ACTIVE | - | Running | private=fd1d:8cc0:1aa4:0:f816:3eff:fec2:d782, 10.0.0.4 |
+--------------------------------------+-------+--------+------------+-------------+--------------------------------------------------------+
Adding Floating IP
Get a floating IP first.
stack@mitakagnocchi:~/devstack$ nova floating-ip-create
+--------------------------------------+--------------+-----------+----------+--------+
| Id | IP | Server Id | Fixed IP | Pool |
+--------------------------------------+--------------+-----------+----------+--------+
| 956031a6-00d5-4f51-9046-3c90ec6df64e | 172.16.235.5 | - | - | public |
+--------------------------------------+--------------+-----------+----------+--------+
Associate a floating ip.
stack@mitakagnocchi:~/devstack$ nova add-floating-ip --fixed-address 10.0.0.4 lala1 172.16.235.5
To Check floating IP
stack@mitakagnocchi:~/devstack$ nova list
+--------------------------------------+-------+--------+------------+-------------+----------------------------------------------------------------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+-------+--------+------------+-------------+----------------------------------------------------------------------+
| 1db0600f-c30b-49a0-9d46-b501002ad8b6 | lala1 | ACTIVE | - | Running | private=fd1d:8cc0:1aa4:0:f816:3eff:fec2:d782, 10.0.0.4, 172.16.235.5 |
+--------------------------------------+-------+--------+------------+-------------+----------------------------------------------------------------------+
Release Security Group
Check Rules of Default Security Group.
stack@mitakagnocchi:~/devstack$ nova secgroup-list-rules default
+-------------+-----------+---------+----------+--------------+
| IP Protocol | From Port | To Port | IP Range | Source Group |
+-------------+-----------+---------+----------+--------------+
| | | | | default |
| | | | | default |
+-------------+-----------+---------+----------+--------------+
Free ICMP.
stack@mitakagnocchi:~/devstack$ nova secgroup-add-rule default icmp -1 -1 0.0.0.0/0
+-------------+-----------+---------+-----------+--------------+
| IP Protocol | From Port | To Port | IP Range | Source Group |
+-------------+-----------+---------+-----------+--------------+
| icmp | -1 | -1 | 0.0.0.0/0 | |
+-------------+-----------+---------+-----------+--------------+
Free TCP
stack@mitakagnocchi:~/devstack$ nova secgroup-add-rule default tcp 1 65535 0.0.0.0/0
+-------------+-----------+---------+-----------+--------------+
| IP Protocol | From Port | To Port | IP Range | Source Group |
+-------------+-----------+---------+-----------+--------------+
| tcp | 1 | 65535 | 0.0.0.0/0 | |
+-------------+-----------+---------+-----------+--------------+
Free UDP
stack@mitakagnocchi:~/devstack$ nova secgroup-add-rule default udp 1 65535 0.0.0.0/0
+-------------+-----------+---------+-----------+--------------+
| IP Protocol | From Port | To Port | IP Range | Source Group |
+-------------+-----------+---------+-----------+--------------+
| udp | 1 | 65535 | 0.0.0.0/0 | |
+-------------+-----------+---------+-----------+--------------+
Connect to VM via Floating IP
Now we can login to VM
stack@mitakagnocchi:~/devstack$ rm ../.ssh/known_hosts
stack@mitakagnocchi:~/devstack$ ssh cirros@172.16.235.5
The authenticity of host '172.16.235.5 (172.16.235.5)' can't be established.
RSA key fingerprint is 7f:ac:8d:c0:48:12:fb:57:68:9d:ec:10:02:55:fb:ce.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '172.16.235.5' (RSA) to the list of known hosts.
cirros@172.16.235.5's password:
$
Furthermore
To Internet
Modify Nameserver, you then can go to internet.
Delete a VM
nova force-delete <instance-id>
No comments:
Post a Comment