OpenStack Interface Hot Plugging

Sometimes it’s useful to dynamically add or remove interfaces to already running instances without having to recreate the instance. For example, if you want to reorganize which networks you originally spawned your instances on or perhaps if creating a service VM that acts as a router between different subnets.

In Grizzly, this was made possible. In order demonstrate this I’ve created two networks net1 and net2 as shown:

$ quantum net-list
+--------------------------------------+---------+----------------------------------------------------+
| id                                   | name    | subnets                                            |
+--------------------------------------+---------+----------------------------------------------------+
| d58e9f6b-d9af-468e-a0cb-f4eea18b6065 | net1    | 4671d053-ac63-4b0f-afe8-18d9444ad8c0 10.2.0.0/24   |
| e79f5d1a-289e-44b6-8070-943535cbbeae | net2    | e73a25ca-d211-44b4-a376-64791ea1dabe 10.3.0.0/24   |
+--------------------------------------+---------+----------------------------------------------------+

Create an instance on net1 via:

$ nova boot --image cirros-0.3.1-x86_64-uec --flavor 1 --nic net-id=d58e9f6b-d9af-468e-a0cb-f4eea18b6065 vm1

Nova list shows the running instance and it’s id:

$ nova list
+--------------------------------------+------+--------+------------+-------------+---------------+
| ID                                   | Name | Status | Task State | Power State | Networks      |
+--------------------------------------+------+--------+------------+-------------+---------------+
| 54ca2943-46e7-4e2e-b470-a015f23797c0 | vm1  | ACTIVE | None       | Running     | net1=10.2.0.3 |
+--------------------------------------+------+--------+------------+-------------+---------------+

Running ifconfig -a in the instance returns the following:

$ ifconfig -a
eth0      Link encap:Ethernet  HWaddr FA:16:3E:59:08:AC  
          inet addr:10.2.0.3  Bcast:10.2.0.255  Mask:255.255.255.0
          inet6 addr: fe80::f816:3eff:fe59:8ac/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:89 errors:0 dropped:0 overruns:0 frame:0
          TX packets:140 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:14652 (14.3 KiB)  TX bytes:14688 (14.3 KiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:46 errors:0 dropped:0 overruns:0 frame:0
          TX packets:46 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:4192 (4.0 KiB)  TX bytes:4192 (4.0 KiB)

Now if we want to attach an additional interface on net2 running the following command achieves this:

$ nova interface-attach --net-id e79f5d1a-289e-44b6-8070-943535cbbeae 54ca2943-46e7-4e2e-b470-a015f23797c0 # <-- instance id
$ ifconfig -a
eth0      Link encap:Ethernet  HWaddr FA:16:3E:59:08:AC  
          inet addr:10.2.0.3  Bcast:10.2.0.255  Mask:255.255.255.0
          inet6 addr: fe80::f816:3eff:fe59:8ac/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:144 errors:0 dropped:0 overruns:0 frame:0
          TX packets:178 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:21919 (21.4 KiB)  TX bytes:21250 (20.7 KiB)

eth1      Link encap:Ethernet  HWaddr FA:16:3E:EA:83:F5  
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:46 errors:0 dropped:0 overruns:0 frame:0
          TX packets:46 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:4192 (4.0 KiB)  TX bytes:4192 (4.0 KiB)

As you can see eth1 was added. We can also remove the interface attached to net1 (eth0) via:

$ nova interface-detach  54ca2943-46e7-4e2e-b470-a015f23797c0 d4911c36-2c8d-4dd3-a128-2d7e411ce877 # <--port-uuid

and ifconfig -a shows that it was removed:

$ ifconfig -a
eth1      Link encap:Ethernet  HWaddr FA:16:3E:EA:83:F5  
          BROADCAST MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:46 errors:0 dropped:0 overruns:0 frame:0
          TX packets:46 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0 
          RX bytes:4192 (4.0 KiB)  TX bytes:4192 (4.0 KiB)

Heads up if you are running the first RC release of Grizzly there was a bug that caused this not to work when using quantum but this was shortly by https://github.com/openstack/nova/commit/bba57e9fa63b7f55d403d9f6950c4cde425d83b0.

This entry was posted in openstack. Bookmark the permalink.

One Response to OpenStack Interface Hot Plugging

  1. Pingback: Brad Dickinson | OpenStack Community Weekly Newsletter (May 31 – June 7)

Leave a Reply

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

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=""> <strike> <strong>