Networking Driver

This component is in charge of configuring the network in the hypervisors. The purpose of this guide is to describe how to create a new network manager driver.

Driver Configuration and Description

To enable a new network manager driver, the first requirement is to make a new directory with the name of the driver in /var/lib/one/remotes/vnm/<name> with these files:

  • pre: This driver should perform all the network related actions required before the Virtual Machine starts in a Host.
  • post: This driver should perform all the network related actions required after the Virtual Machine starts (actions which typically require the knowledge of the tap interface the Virtual Machine is connected to).
  • clean: If any clean-up should be performed after the Virtual Machine shuts down, it should be placed here.
  • vnet_create: Virtual Network is being added to OpenNebula, do driver initialization.
  • vnet_delete: Virtual Network is being removed from OpenNebula, do a clean-up.

Virtual Machine actions and their relation with Network actions:

  • Deploy: pre and post
  • Shutdown: clean
  • Cancel: clean
  • Save: clean
  • Restore: pre and post
  • Migrate: pre (target Host), clean (source Host), post (target Host)
  • Attach Nic: pre and post
  • Detach Nic: clean

After that you need to define the bridging technology used by the driver at /etc/one/oned.conf. OpenNebula supports two different technologies, Linux Bridge and Open vSwitch. See the examples below:

VN_MAD_CONF = [
    NAME = "ovswitch_vxlan"
    BRIDGE_TYPE = "openvswitch"
]

VN_MAD_CONF = [
    NAME = "bridge"
    BRIDGE_TYPE = "linux"
]

VN_MAD_CONF = [
    NAME = "custom"
    BRIDGE_TYPE = "none"
]

Driver Customization

Default driver actions support the execution of hooks after the main action is successfully executed. In order to create an action hook you need to place your custom configuration scripts in the corresponding action.d directory (pre.d, post.d, clean.d), inside the target networking driver directory. Files found in that directory will be run in alphabetical order, excluding the ones oneadmin cannot run due to lack of permissions. If the main action fails the hooks won’t be run. If a hook fails the corresponding network actions will be consider as a FAILURE and the VM will change its state accordingly. Note that the scripts will receive the same information as the main action through stdin.

For example, this is the directory tree of the bridge driver synced to a virtualization node with some custom scripts:

root@ubuntu1804-local-6ee11-2:/var/tmp/one/vnm/bridge# tree ./
./
├── clean
├── clean.d
│   ├── 01_del_fdb
│   ├── 02_del_routes
├── post
├── post.d
│   ├── 01_add_fdb
│   ├── 02_add_routes
├── pre
├── pre.d
│   ├── 01_update_router
└── update_sg

Driver Parameters

All three driver actions receive the XML VM template encoded in base64 format by stdin and the deploy-id of the Virtual Machine as parameter, e.g.: one-17.

The clean action doesn’t require deploy-id

The 802.1Q Driver

Driver Files

The code can be enhanced and modified by changing the following files in the Front-end:

  • /var/lib/one/remotes/vnm/802.1Q/post
  • /var/lib/one/remotes/vnm/802.1Q/vlan_tag_driver.rb
  • /var/lib/one/remotes/vnm/802.1Q/clean
  • /var/lib/one/remotes/vnm/802.1Q/pre

Driver Actions

ActionDescription
PreCreates a VLAN-tagged interface in the Host and a attaches it to a dynamically created bridge.
PostN/A
CleanIt doesn’t do anything. The VLAN-tagged interface and bridge are kept in the Host to speed up future VMs
vnet_createIt doesn’t do anything.
vnet_deleteIt doesn’t do anything.

The VXLAN Driver

Driver Files

The code can be enhanced and modified by changing the following files in the Front-end:

  • /var/lib/one/remotes/vnm/vxlan/vxlan_driver.rb
  • /var/lib/one/remotes/vnm/vxlan/post
  • /var/lib/one/remotes/vnm/vxlan/clean
  • /var/lib/one/remotes/vnm/vxlan/pre

Driver Actions

ActionDescription
PreCreates a VXLAN interface through PHYDEV, creates a bridge (if needed) and attaches the vxlan device.
PostWhen the VM is associated to a security group, the corresponding iptables rules are applied.
CleanIt doesn’t do anything. The VXLAN interface and bridge are kept in the Host to speed up future VMs
vnet_createIt doesn’t do anything.
vnet_deleteIt doesn’t do anything.

The Open vSwitch Driver

The code can be enhanced and modified by changing the following files in the Front-end: * /var/lib/one/remotes/vnm/ovswitch/OpenvSwitch.rb * /var/lib/one/remotes/vnm/ovswitch/post * /var/lib/one/remotes/vnm/ovswitch/clean * /var/lib/one/remotes/vnm/ovswitch/pre

Driver Actions

ActionDescription
PreN/A
PostPerforms the appropriate Open vSwitch commands to tag the virtual tap interface.
CleanIt doesn’t do anything. The virtual tap interfaces will be automatically discarded when the VM is shut down.
vnet_createIt doesn’t do anything.
vnet_deleteIt doesn’t do anything.

The Dummy Driver

The code can be enhanced and modified by changing the following files in the Front-end:

  • /var/lib/one/remotes/vnm/dummy/post
  • /var/lib/one/remotes/vnm/dummy/clean
  • /var/lib/one/remotes/vnm/dummy/pre

Driver Actions

ActionDescription
PreNothing is done. Just pass the arguments to the corresponding hooks.
PostNothing is done. Just pass the arguments to the corresponding hooks.
CleanNothing is done. Just pass the arguments to the corresponding hooks.
vnet_createIt doesn’t do anything.
vnet_deleteIt doesn’t do anything.

The Bridge Driver

The code can be enhanced and modified by changing the following files in the Front-end:

  • /var/lib/one/remotes/vnm/bridge/post
  • /var/lib/one/remotes/vnm/bridge/clean
  • /var/lib/one/remotes/vnm/bridge/pre

Driver Actions

ActionDescription
PreCreates the bridge if it doesn’t exist.
PostN/A
CleanRemove the bridge if it’s empty.
vnet_createIt doesn’t do anything.
vnet_deleteIt doesn’t do anything.

The FW Driver

The code can be enhanced and modified by changing the following files in the Front-end:

  • /var/lib/one/remotes/vnm/fw/post
  • /var/lib/one/remotes/vnm/fw/clean
  • /var/lib/one/remotes/vnm/fw/pre

It performs the same action as the Bridge driver but adds extra iptables rules to implement the security groups of the VM.

The Elastic Driver

The code can be enhanced and modified by changing the following files in the Front-end:

  • /var/lib/one/remotes/vnm/elastic/post
  • /var/lib/one/remotes/vnm/elastic/clean
  • /var/lib/one/remotes/vnm/elastic/pre

Driver Actions

ActionDescription
PreCreates the bridge if it doesn’t exist. Setup forward rules
PostAssign elastic IPs to the target Host
CleanRemove the bridge if it’s empty. Unassigns elastic IPs
vnet_createIt doesn’t do anything.
vnet_deleteIt doesn’t do anything.