Add Second Interface to a VM – Openstack

Openstack in default spawning a virtual machine with a single Interface. If the customer need another interface, here is the to do. This command line commands will work in CP method.

  • List your Networks

root@node-175:~# neutron net-list
+————————————–+———–+——————————————————-+
| id                                   | name      | subnets                                               |
+————————————–+———–+——————————————————-+
| de53e7b0-a7de-44b2-8008-39734bb1d634 | net04     | f079aa91-d1fc-47e5-a734-542eef84a7b1 192.168.111.0/24 |
| 530e746b-ff6d-4eda-b6e2-29d605acad07 | stackbees-net | 72bced7b-ad1b-4452-915b-b7c3a707a3fd 192.168.1.0/24   |
| 8dcb3ac7-63ad-44b6-8185-bd309cd62992 | net04_ext | 5e191256-9986-4f0a-86b5-ffd94b9855ef 78.20.0.0/22     |
+————————————–+———–+——————————————————-+

  • List your Security Groups

root@node-175:~# neutron security-group-list
+————————————–+———+————-+
| id                                   | name    | description |
+————————————–+———+————-+
| 30f32a69-c9c3-4e90-a0e6-4513f55d8e15 | default | default     |
+————————————–+———+————-+

  • List your Virtual Machine (Where you are going to attach the Interface)

root@node-175:~# nova list
+————————————–+———–+——–+————+————-+———————————-+
| ID                                   | Name      | Status | Task State | Power State | Networks                         |
+————————————–+———–+——–+————+————-+———————————-+
| 3e89ba83-8ae7-42e1-9d47-b1eee93200e2 | fedora-23 | ACTIVE | –          | Running     | stackbees-net=192.168.1.2, 78.20.1.2 |
+————————————–+———–+——–+————+————-+———————————-+

  • Create a port on the stackbees-net

root@node-175:~# neutron port-create –security-group 595ce673-a709-44fc-9a1b-a975c97f67b8  stackbees-net
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     | normal                                                                             |
| device_id             |                                                                                    |
| device_owner          |                                                                                    |
| fixed_ips             | {“subnet_id”: “72bced7b-ad1b-4452-915b-b7c3a707a3fd”, “ip_address”: “192.168.1.6”} |
| id                    | a882c63f-61d4-42a8-8500-94a5e79882b1                                               |
| mac_address           | fa:16:3e:c6:c5:bf                                                                  |
| name                  |                                                                                    |
| network_id            | 530e746b-ff6d-4eda-b6e2-29d605acad07                                               |
| security_groups       | 595ce673-a709-44fc-9a1b-a975c97f67b8                                               |
| status                | DOWN                                                                               |
| tenant_id             | 77d7a1db7e9c40e0aea25306b66a1d25                                                   |
+———————–+————————————————————————————+

  • Use the IP Address to get Port UniqueID and store in a variable

root@node-175:~# PID=$(neutron port-list | awk ‘/192.168.1.6/ {print $2}’)

root@node-175:~# echo $PID
a882c63f-61d4-42a8-8500-94a5e79882b1

  • Attach this to the Virtual Machine

root@node-175:~# nova interface-attach –port-id $PID fedora-23

You have to login to the VM and manually set the interface UP using ifup.

  • Check the Port after manually enable in the OS

root@node-175:~# neutron port-show a882c63f-61d4-42a8-8500-94a5e79882b1
+———————–+————————————————————————————+
| Field                 | Value                                                                              |
+———————–+————————————————————————————+
| admin_state_up        | True                                                                               |
| allowed_address_pairs |                                                                                    |
| binding:host_id       | node-180.stackbees.cloud                                                     |
| binding:profile       | {}                                                                                 |
| binding:vif_details   | {“port_filter”: true, “ovs_hybrid_plug”: true}                                     |
| binding:vif_type      | ovs                                                                                |
| binding:vnic_type     | normal                                                                             |
| device_id             | 3e89ba83-8ae7-42e1-9d47-b1eee93200e2                                               |
| device_owner          | compute:nova                                                                       |
| extra_dhcp_opts       |                                                                                    |
| fixed_ips             | {“subnet_id”: “72bced7b-ad1b-4452-915b-b7c3a707a3fd”, “ip_address”: “192.168.1.6”} |
| id                    | a882c63f-61d4-42a8-8500-94a5e79882b1                                               |
| mac_address           | fa:16:3e:c6:c5:bf                                                                  |
| name                  |                                                                                    |
| network_id            | 530e746b-ff6d-4eda-b6e2-29d605acad07                                               |
| security_groups       | 595ce673-a709-44fc-9a1b-a975c97f67b8                                               |
| status                | ACTIVE                                                                             |
| tenant_id             | 77d7a1db7e9c40e0aea25306b66a1d25                                                   |
+———————–+————————————————————————————+

stacker has written 19 articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Humans Only. * Time limit is exhausted. Please reload the CAPTCHA.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>