How to add and delete network cards dynamically in OpenStack
In the process of project implementation, there is often a need to add and delete network cards. For example, an instance that runs a database initially has only one network card, which is shared by database service and backup. Later, in order to improve performance and compliance, it is necessary to add a network card for backup. For a long time, the Horizon interface only supports configuring NICs for instance during deployment. Adding and removing NICs afterwards can only be done on the command line. This operation is demonstrated below.
Add a network card
We now have an instance "C1" and a vlan111 network card with an IP of 17.17.111.5.
There are currently two vlan networks "vlan111" and "vlan112".
Execute the command nova interface-attach to add a "vlan112" network card to "C1", and the assigned IP is 17.17.112.9.
In the console of instance, you can see that the new Nic is eth2, but the IP is not obtained.
The reason for this is that there is no configuration of eth2 in the current operating system. Edit / etc/network/interfaces to add eth2.
Then execute ifup eth2 to enable the network card, and this time the IP of 17.17.112.9 is obtained.
Delete the network card
The following shows how to delete a network card. The commands used are:
Nova interface-detach
Used to specify the instance.
Is to delete the port corresponding to the Nic.
You can view port information through neutron port-list.
For example, we want to delete the network card whose IP is 17.17.111.5.
In the instance console, you can see that eth0 is gone, leaving only eth2.
Operate in horizon
Horizon added the operation of adding and removing network cards in the Newton version. "Attach Interface" and "Detach Interface" can be seen in the operation list of instance.
To add a network card, simply select the network to which the network card belongs in the drop-down list.
Delete the network card is also very simple, directly select the corresponding port of the network card.
GUI always follows CLI, and we expect horizon to add more practical operations in the new version.
After reading the above, do you have any further understanding of how to dynamically add and delete network cards in OpenStack? If you want to know more knowledge or related content, please follow the industry information channel, thank you for your support.