How to launch instance using CLI in OpenStack

Dear friends, Today we will see how to launch instance using CLI in OpenStack. We also see how to create SR-IOV network port using CLI in OpenStack. So lets start and see step by steps these process.

For more details about how to launch instance using CLI in OpenStack, Please click here

Prerequisite

  1. Image should be properly uploaded in OpenStack library.
  2. Network and Network port should be properly created.
  3. Flavour should be created according to our instance.

Image Verification

Here we need to be verify our created images using openstack image list commands. where we can find image details like:- Image ID, Image name and Image status.

[stack@undercloud (overcloudrc) ~]$ openstack image list
 +--------------------------------------+---------------+--------+
 | ID                                   | Name          | Status |
 +--------------------------------------+---------------+--------+
 | 83f34de1-9da6-4cab-b00c-a3641290a0c8 | Rhel7Genereic | active |
 +--------------------------------------+---------------+--------+
 [stack@undercloud (overcloudrc) ~]$

Network Verification

Now we need to be verify our created Network and Network ports which I have to use to launch instance for network access. You can list your created network using “openstack network list” command and you can also list down your network port using “neutron port-list” command. Like below:-

Network list

[stack@undercloud (overcloudrc) ~]$ openstack network list
 +--------------------------------------+----------------------------------------------------+--------------------------------------+
 | ID                                   | Name                                               | Subnets                              |
 +--------------------------------------+----------------------------------------------------+--------------------------------------+
 | 61099c91-8ddb-452a-8552-53feb08302fa | Net-10                                             | bd6dea3f-d317-41d4-8b4c-1cd0d8f792cf |
 | 6d0378a1-c56f-44b4-9234-408e58164911 | SRIOV-Net-20                                       | 36ea0aee-340f-482d-9dbe-f4a5f29a1143 |
 | 71652fad-4c52-460b-88d1-fd4843561947 | HA network tenant 4e076fffb06d42f09c5994a0fd781cfd | 3033653c-dc28-4961-8d1d-e0d4d3b41247 |
 +--------------------------------------+----------------------------------------------------+--------------------------------------+
 [stack@undercloud (overcloudrc) ~]$   

Network port list

[stack@undercloud (overcloudrc) ~]$ neutron port-list
 neutron CLI is deprecated and will be removed in the future. Use openstack CLI instead.
 +--------------------------------------+-------------------------------------------------+----------------------------------+-------------------+---------------------------------------------------------------------------------------+
 | id                                   | name                                            | tenant_id                        | mac_address       | fixed_ips                                                                             |
 +--------------------------------------+-------------------------------------------------+----------------------------------+-------------------+---------------------------------------------------------------------------------------+
 | 0aaaa722-22fc-47f0-adfe-d28671c80d7c |                                                 | 4e076fffb06d42f09c5994a0fd781cfd | fa:16:3e:93:79:d1 | {"subnet_id": "bd6dea3f-d317-41d4-8b4c-1cd0d8f792cf", "ip_address": "10.10.10.1"}     |
 | 1fa6d387-f35d-4cc6-a2cd-dae1a2af8a1f |                                                 | 4e076fffb06d42f09c5994a0fd781cfd | fa:16:3e:03:b2:3a | {"subnet_id": "36ea0aee-340f-482d-9dbe-f4a5f29a1143", "ip_address": "10.10.20.12"}    |
 | 1ff6c31c-543c-45d2-b6f2-63b7305a68a1 |                                                 | 4e076fffb06d42f09c5994a0fd781cfd | fa:16:3e:7f:ab:bc | {"subnet_id": "36ea0aee-340f-482d-9dbe-f4a5f29a1143", "ip_address": "10.10.20.10"}    |
 | 26dfec54-1881-4ce6-bd63-60ce1c06b174 |                                                 | 4e076fffb06d42f09c5994a0fd781cfd | fa:16:3e:6a:3f:f7 | {"subnet_id": "bd6dea3f-d317-41d4-8b4c-1cd0d8f792cf", "ip_address": "10.10.10.19"}    |
 | 34eb9196-0821-4e5e-b442-307a9a236fe7 | SRIOV-Net-Port1                                 | 4e076fffb06d42f09c5994a0fd781cfd | fa:16:3e:35:27:e8 | {"subnet_id": "36ea0aee-340f-482d-9dbe-f4a5f29a1143", "ip_address": "10.10.20.19"}    |
 | 4dc80f2a-812b-4358-84c8-16232b3f011e | HA port tenant 4e076fffb06d42f09c5994a0fd781cfd |                                  | fa:16:3e:aa:9e:2a | {"subnet_id": "3033653c-dc28-4961-8d1d-e0d4d3b41247", "ip_address": "169.254.192.5"}  |
 | 5b20e1c6-10c0-4877-ad6e-fc03f555bd64 |                                                 | 4e076fffb06d42f09c5994a0fd781cfd | fa:16:3e:9c:22:c6 | {"subnet_id": "36ea0aee-340f-482d-9dbe-f4a5f29a1143", "ip_address": "10.10.20.11"}    |
 | 6329f505-371f-45c9-9551-ede16a39e1f2 | HA port tenant 4e076fffb06d42f09c5994a0fd781cfd |                                  | fa:16:3e:2c:fa:7f | {"subnet_id": "3033653c-dc28-4961-8d1d-e0d4d3b41247", "ip_address": "169.254.192.1"}  |
 | 79a2e8ef-7487-4079-8739-760f54b7a477 | HA port tenant 4e076fffb06d42f09c5994a0fd781cfd |                                  | fa:16:3e:d6:d2:f3 | {"subnet_id": "3033653c-dc28-4961-8d1d-e0d4d3b41247", "ip_address": "169.254.192.11"} |
  | b4a08b9e-5540-45e3-8d2a-074ee0734f12 |                                                 | 4e076fffb06d42f09c5994a0fd781cfd | fa:16:3e:24:a4:fa | {"subnet_id": "bd6dea3f-d317-41d4-8b4c-1cd0d8f792cf", "ip_address": "10.10.10.12"}    |
 | b56e7400-a09b-401d-b764-f6c127d9bb3a |                                                 | 4e076fffb06d42f09c5994a0fd781cfd | fa:16:3e:55:01:b4 | {"subnet_id": "bd6dea3f-d317-41d4-8b4c-1cd0d8f792cf", "ip_address": "10.10.10.10"}    |
 | c8f47a5f-3d69-4057-9306-71ded5d10969 |                                                 | 4e076fffb06d42f09c5994a0fd781cfd | fa:16:3e:a1:31:0b | {"subnet_id": "bd6dea3f-d317-41d4-8b4c-1cd0d8f792cf", "ip_address": "10.10.10.13"}    |
 | d4848812-aa7f-4bfb-9345-d581d477edf8 |                                                 | 4e076fffb06d42f09c5994a0fd781cfd | fa:16:3e:5b:d6:79 | {"subnet_id": "bd6dea3f-d317-41d4-8b4c-1cd0d8f792cf", "ip_address": "10.10.10.11"}    |
 | edc78a21-c53a-420c-a846-aa2f2dce8ab8 |                                                 | 4e076fffb06d42f09c5994a0fd781cfd | fa:16:3e:3e:e6:9d | {"subnet_id": "36ea0aee-340f-482d-9dbe-f4a5f29a1143", "ip_address": "10.10.20.1"}     |
 +--------------------------------------+-------------------------------------------------+----------------------------------+-------------------+---------------------------------------------------------------------------------------+
 [stack@undercloud (overcloudrc) ~]$

SR-IOV network port creation

I am going to create one extra SR-IOV network ports so that I can launch instance using this network.

[stack@undercloud (overcloudrc) ~]$ neutron port-create SRIOV-Net-20 --vnic-type  direct --name SRIOV-Net-Port2
 neutron CLI is deprecated and will be removed in the future. Use openstack CLI instead.
 Created a new port:
 +-----------------------+------------------------------------------------------------------------------------+
 | Field                 | Value                                                                              |
 +-----------------------+------------------------------------------------------------------------------------+
 | admin_state_up        | True                                                                               |
 | allowed_address_pairs |                                                                                    |
 | binding:host_id       |                                                                                    |
 | binding:profile       | {}                                                                                 |
 | binding:vif_details   | {}                                                                                 |
 | binding:vif_type      | unbound                                                                            |
 | binding:vnic_type     | direct                                                                             |
 | created_at            | 2019-09-08T11:20:06Z                                                               |
 | description           |                                                                                    |
 | device_id             |                                                                                    |
 | device_owner          |                                                                                    |
 | extra_dhcp_opts       |                                                                                    |
 | fixed_ips             | {"subnet_id": "36ea0aee-340f-482d-9dbe-f4a5f29a1143", "ip_address": "10.10.20.18"} |
 | id                    | 9e0f9ff3-e49c-4993-a4c8-87d993be94a3                                               |
 | ip_allocation         | immediate                                                                          |
 | mac_address           | fa:16:3e:48:f2:29                                                                  |
 | name                  | SRIOV-Net-Port2                                                                    |
 | network_id            | 6d0378a1-c56f-44b4-9234-408e58164911                                               |
 | port_security_enabled | True                                                                               |
 | project_id            | 4e076fffb06d42f09c5994a0fd781cfd                                                   |
 | qos_policy_id         |                                                                                    |
 | revision_number       | 6                                                                                  |
 | security_groups       | 3a02de4b-6dda-4ac9-afcd-5126eacf899f                                               |
 | status                | DOWN                                                                               |
 | tags                  |                                                                                    |
 | tenant_id             | 4e076fffb06d42f09c5994a0fd781cfd                                                   |
 | updated_at            | 2019-09-08T11:20:06Z                                                               |
 +-----------------------+------------------------------------------------------------------------------------+
 [stack@undercloud (overcloudrc) ~]$

After SR-IOV port creation we can very network port.

[stack@undercloud (overcloudrc) ~]$ neutron port-list
 neutron CLI is deprecated and will be removed in the future. Use openstack CLI instead.
 +--------------------------------------+-------------------------------------------------+----------------------------------+-------------------+---------------------------------------------------------------------------------------+
 | id                                   | name                                            | tenant_id                        | mac_address       | fixed_ips                                                                             |
 +--------------------------------------+-------------------------------------------------+----------------------------------+-------------------+---------------------------------------------------------------------------------------+
 | 0aaaa722-22fc-47f0-adfe-d28671c80d7c |                                                 | 4e076fffb06d42f09c5994a0fd781cfd | fa:16:3e:93:79:d1 | {"subnet_id": "bd6dea3f-d317-41d4-8b4c-1cd0d8f792cf", "ip_address": "10.10.10.1"}     |
 | 1fa6d387-f35d-4cc6-a2cd-dae1a2af8a1f |                                                 | 4e076fffb06d42f09c5994a0fd781cfd | fa:16:3e:03:b2:3a | {"subnet_id": "36ea0aee-340f-482d-9dbe-f4a5f29a1143", "ip_address": "10.10.20.12"}    |
 | 1ff6c31c-543c-45d2-b6f2-63b7305a68a1 |                                                 | 4e076fffb06d42f09c5994a0fd781cfd | fa:16:3e:7f:ab:bc | {"subnet_id": "36ea0aee-340f-482d-9dbe-f4a5f29a1143", "ip_address": "10.10.20.10"}    |
 | 26dfec54-1881-4ce6-bd63-60ce1c06b174 |                                                 | 4e076fffb06d42f09c5994a0fd781cfd | fa:16:3e:6a:3f:f7 | {"subnet_id": "bd6dea3f-d317-41d4-8b4c-1cd0d8f792cf", "ip_address": "10.10.10.19"}    |
 | 34eb9196-0821-4e5e-b442-307a9a236fe7 | SRIOV-Net-Port1                                 | 4e076fffb06d42f09c5994a0fd781cfd | fa:16:3e:35:27:e8 | {"subnet_id": "36ea0aee-340f-482d-9dbe-f4a5f29a1143", "ip_address": "10.10.20.19"}    |
 | 4dc80f2a-812b-4358-84c8-16232b3f011e | HA port tenant 4e076fffb06d42f09c5994a0fd781cfd |                                  | fa:16:3e:aa:9e:2a | {"subnet_id": "3033653c-dc28-4961-8d1d-e0d4d3b41247", "ip_address": "169.254.192.5"}  |
 | 5b20e1c6-10c0-4877-ad6e-fc03f555bd64 |                                                 | 4e076fffb06d42f09c5994a0fd781cfd | fa:16:3e:9c:22:c6 | {"subnet_id": "36ea0aee-340f-482d-9dbe-f4a5f29a1143", "ip_address": "10.10.20.11"}    |
 | 6329f505-371f-45c9-9551-ede16a39e1f2 | HA port tenant 4e076fffb06d42f09c5994a0fd781cfd |                                  | fa:16:3e:2c:fa:7f | {"subnet_id": "3033653c-dc28-4961-8d1d-e0d4d3b41247", "ip_address": "169.254.192.1"}  |
 | 79a2e8ef-7487-4079-8739-760f54b7a477 | HA port tenant 4e076fffb06d42f09c5994a0fd781cfd |                                  | fa:16:3e:d6:d2:f3 | {"subnet_id": "3033653c-dc28-4961-8d1d-e0d4d3b41247", "ip_address": "169.254.192.11"} |
 | 9e0f9ff3-e49c-4993-a4c8-87d993be94a3 | SRIOV-Net-Port2                                 | 4e076fffb06d42f09c5994a0fd781cfd | fa:16:3e:48:f2:29 | {"subnet_id": "36ea0aee-340f-482d-9dbe-f4a5f29a1143", "ip_address": "10.10.20.18"}    |
 | b4a08b9e-5540-45e3-8d2a-074ee0734f12 |                                                 | 4e076fffb06d42f09c5994a0fd781cfd | fa:16:3e:24:a4:fa | {"subnet_id": "bd6dea3f-d317-41d4-8b4c-1cd0d8f792cf", "ip_address": "10.10.10.12"}    |
 | b56e7400-a09b-401d-b764-f6c127d9bb3a |                                                 | 4e076fffb06d42f09c5994a0fd781cfd | fa:16:3e:55:01:b4 | {"subnet_id": "bd6dea3f-d317-41d4-8b4c-1cd0d8f792cf", "ip_address": "10.10.10.10"}    |
 | c8f47a5f-3d69-4057-9306-71ded5d10969 |                                                 | 4e076fffb06d42f09c5994a0fd781cfd | fa:16:3e:a1:31:0b | {"subnet_id": "bd6dea3f-d317-41d4-8b4c-1cd0d8f792cf", "ip_address": "10.10.10.13"}    |
 | d4848812-aa7f-4bfb-9345-d581d477edf8 |                                                 | 4e076fffb06d42f09c5994a0fd781cfd | fa:16:3e:5b:d6:79 | {"subnet_id": "bd6dea3f-d317-41d4-8b4c-1cd0d8f792cf", "ip_address": "10.10.10.11"}    |
 | edc78a21-c53a-420c-a846-aa2f2dce8ab8 |                                                 | 4e076fffb06d42f09c5994a0fd781cfd | fa:16:3e:3e:e6:9d | {"subnet_id": "36ea0aee-340f-482d-9dbe-f4a5f29a1143", "ip_address": "10.10.20.1"}     |
 +--------------------------------------+-------------------------------------------------+----------------------------------+-------------------+---------------------------------------------------------------------------------------+
 [stack@undercloud (overcloudrc) ~]$

Flavours Verification

Now we need to be verify our created Flavours using “openstack flavor list” command. Like below:-

[stack@undercloud (overcloudrc) ~]$ openstack flavor list
 +--------------------------------------+---------+------+------+-----------+-------+-----------+
 | ID                                   | Name    |  RAM | Disk | Ephemeral | VCPUs | Is Public |
 +--------------------------------------+---------+------+------+-----------+-------+-----------+
 | bec4a148-1b03-47e1-a793-96a905c22ec4 | SMALL_1 | 4096 |    0 |         0 |     4 | True      |
 +--------------------------------------+---------+------+------+-----------+-------+-----------+
 [stack@undercloud (overcloudrc) ~]$

After competed these all verification now we can launch instance using CLI in OpenStack.

Launch instance using CLI in OpenStack

You can see in above output now we have competed all prerequisite to launch instance. We can use nova boot command with image, network and flavour option to launch instance. So lets start launch instance using CLI.

[stack@undercloud (overcloudrc) ~]$ nova boot --image Rhel7Genereic --flavor SMALL_1 --nic port-id=9e0f9ff3-e49c-4993-a4c8-87d993be94a3 urclouds
 +--------------------------------------+------------------------------------------------------+
 | Property                             | Value                                                |
 +--------------------------------------+------------------------------------------------------+
 | OS-DCF:diskConfig                    | MANUAL                                               |
 | OS-EXT-AZ:availability_zone          |                                                      |
 | OS-EXT-SRV-ATTR:host                 | -                                                    |
 | OS-EXT-SRV-ATTR:hostname             | urclouds                                             |
 | OS-EXT-SRV-ATTR:hypervisor_hostname  | -                                                    |
 | OS-EXT-SRV-ATTR:instance_name        |                                                      |
 | OS-EXT-SRV-ATTR:kernel_id            |                                                      |
 | OS-EXT-SRV-ATTR:launch_index         | 0                                                    |
 | OS-EXT-SRV-ATTR:ramdisk_id           |                                                      |
 | OS-EXT-SRV-ATTR:reservation_id       | r-g91vell6                                           |
 | OS-EXT-SRV-ATTR:root_device_name     | -                                                    |
 | OS-EXT-SRV-ATTR:user_data            | -                                                    |
 | OS-EXT-STS:power_state               | 0                                                    |
 | OS-EXT-STS:task_state                | scheduling                                           |
 | OS-EXT-STS:vm_state                  | building                                             |
 | OS-SRV-USG:launched_at               | -                                                    |
 | OS-SRV-USG:terminated_at             | -                                                    |
 | accessIPv4                           |                                                      |
 | accessIPv6                           |                                                      |
 | adminPass                            | B24gWUsEj5tz                                         |
 | config_drive                         |                                                      |
 | created                              | 2019-09-08T11:24:23Z                                 |
 | description                          | -                                                    |
 | flavor:disk                          | 0                                                    |
 | flavor:ephemeral                     | 0                                                    |
 | flavor:extra_specs                   | {}                                                   |
 | flavor:original_name                 | SMALL_1                                              |
 | flavor:ram                           | 4096                                                 |
 | flavor:swap                          | 0                                                    |
 | flavor:vcpus                         | 4                                                    |
 | hostId                               |                                                      |
 | host_status                          |                                                      |
 | id                                   | 0e02e8f6-bd46-40b6-a2fe-7f9daf3ba9b6                 |
 | image                                | Rhel7Genereic (83f34de1-9da6-4cab-b00c-a3641290a0c8) |
 | key_name                             | -                                                    |
 | locked                               | False                                                |
 | metadata                             | {}                                                   |
 | name                                 | urclouds                                             |
 | os-extended-volumes:volumes_attached | []                                                   |
 | progress                             | 0                                                    |
 | security_groups                      | default                                              |
 | status                               | BUILD                                                |
 | tags                                 | []                                                   |
 | tenant_id                            | 4e076fffb06d42f09c5994a0fd781cfd                     |
 | updated                              | 2019-09-08T11:24:23Z                                 |
 | user_id                              | e87f3016e1be49bab6d76fac683d64b9                     |
 +--------------------------------------+------------------------------------------------------+
 [stack@undercloud (overcloudrc) ~]$

You can see in above output we have successfully launched Instance with instance name “urclouds” using OpenStack CLI.

Verify launched instance using OpenStack Dashboard

Now we can also verify our created instance using OpenStack Dashboard. So lets start OpenStack Dashboard and see our created instance.

Launch instance

You can see in above output our created instance is up and running. Now we can go to instance console and check our instance network is working or not?

So lets verify our created instance network.

Launch Instance

We can see in above output, our created instance has been successfully created network using DHCP service, and Default Gateway is successfully reachable, that means our created instance is accessible from outside.

That’s all, you can see we have successfully launched instance using CLI in OpenStack

Leave a Reply