diff --git a/install.sh b/install.sh index 60736ec669..6c9907c2fd 100755 --- a/install.sh +++ b/install.sh @@ -947,7 +947,7 @@ NETWORK_FILES="src/vnm_mad/remotes/lib/vnm_driver.rb \ NETWORK_8021Q_FILES="src/vnm_mad/remotes/802.1Q/clean \ src/vnm_mad/remotes/802.1Q/post \ src/vnm_mad/remotes/802.1Q/pre \ - src/vnm_mad/remotes/802.1Q/HostManaged.rb" + src/vnm_mad/remotes/802.1Q/vlan_driver.rb" NETWORK_DUMMY_FILES="src/vnm_mad/remotes/dummy/clean \ src/vnm_mad/remotes/dummy/post \ diff --git a/src/vnm_mad/remotes/802.1Q/pre b/src/vnm_mad/remotes/802.1Q/pre index a3be35cc4d..656fca6415 100755 --- a/src/vnm_mad/remotes/802.1Q/pre +++ b/src/vnm_mad/remotes/802.1Q/pre @@ -19,7 +19,7 @@ $: << File.dirname(__FILE__) $: << File.join(File.dirname(__FILE__), "..") -require 'HostManaged' +require 'vlan_driver' -hm = OpenNebulaHM.from_base64(ARGV[0]) +hm = VLANDriver.from_base64(ARGV[0]) exit hm.activate diff --git a/src/vnm_mad/remotes/802.1Q/HostManaged.rb b/src/vnm_mad/remotes/802.1Q/vlan_driver.rb similarity index 72% rename from src/vnm_mad/remotes/802.1Q/HostManaged.rb rename to src/vnm_mad/remotes/802.1Q/vlan_driver.rb index f33ce912a8..3dfbd7b949 100644 --- a/src/vnm_mad/remotes/802.1Q/HostManaged.rb +++ b/src/vnm_mad/remotes/802.1Q/vlan_driver.rb @@ -16,13 +16,24 @@ require 'vnmmad' -class OpenNebulaHM < VNMMAD::VNMDriver - DRIVER = "802.1Q" +################################################################################ +# This driver tag VM traffic with a VLAN_ID using 802.1Q protocol. Features: +# - Creates a bridge and bind phisycal device if not present +# - Creates a tagged interface for the VM dev.vlan_id +# +# Once activated the VM will be attached to this bridge +################################################################################ +class VLANDriver < VNMMAD::VNMDriver + # DRIVER name and XPATH for relevant NICs + DRIVER = "802.1Q" XPATH_FILTER = "TEMPLATE/NIC[VLAN='YES']" + ############################################################################ + # Creatges the driver device operations are not locked + ############################################################################ def initialize(vm, deploy_id = nil, hypervisor = nil) - super(vm,XPATH_FILTER,deploy_id,hypervisor) + super(vm, XPATH_FILTER, deploy_id, hypervisor) @locking = false lock @@ -30,6 +41,9 @@ class OpenNebulaHM < VNMMAD::VNMDriver unlock end + ############################################################################ + # Activate the driver and creates bridges and tags devices as needed. + ############################################################################ def activate lock @@ -67,6 +81,12 @@ class OpenNebulaHM < VNMMAD::VNMDriver return 0 end + ############################################################################ + # Private interface, methods to manage bridges and VLAN tags through the + # brctl and ip commands + ############################################################################ + private + def bridge_exists?(bridge) @bridges.keys.include? bridge end