diff --git a/include/VirtualNetwork.h b/include/VirtualNetwork.h index 1c66c5d8b9..179e9fa5c6 100644 --- a/include/VirtualNetwork.h +++ b/include/VirtualNetwork.h @@ -457,6 +457,11 @@ private: // Binded physical attributes // ------------------------------------------------------------------------- + /** + * Name of the vn mad + */ + string vn_mad; + /** * Name of the bridge this VNW binds to */ diff --git a/share/etc/oned.conf b/share/etc/oned.conf index 827742dbc4..b11839860d 100644 --- a/share/etc/oned.conf +++ b/share/etc/oned.conf @@ -886,11 +886,13 @@ IMAGE_RESTRICTED_ATTR = "SOURCE" # Normal VNets do not have restricted attributes. #******************************************************************************* +VNET_RESTRICTED_ATTR = "VN_MAD" VNET_RESTRICTED_ATTR = "PHYDEV" VNET_RESTRICTED_ATTR = "VLAN_ID" VNET_RESTRICTED_ATTR = "VLAN" VNET_RESTRICTED_ATTR = "BRIDGE" +VNET_RESTRICTED_ATTR = "AR/VN_MAD" VNET_RESTRICTED_ATTR = "AR/PHYDEV" VNET_RESTRICTED_ATTR = "AR/VLAN_ID" VNET_RESTRICTED_ATTR = "AR/VLAN" diff --git a/src/mad/ruby/DriverExecHelper.rb b/src/mad/ruby/DriverExecHelper.rb index c86f4f45db..54ba8148d9 100644 --- a/src/mad/ruby/DriverExecHelper.rb +++ b/src/mad/ruby/DriverExecHelper.rb @@ -61,12 +61,13 @@ module DriverExecHelper # @param [String, Symbol] action name of the action # @param [String] parameters arguments for the script # @param [String, nil] default_name alternative name for the script + # @param [String, ''] subdirectory of the action # @return [String] command line needed to execute the action - def action_command_line(action, parameters, default_name=nil) + def action_command_line(action, parameters, default_name=nil, subdirectory='') if action_is_local? action - script_path=@local_scripts_path + script_path=File.join(@local_scripts_path, subdirectory) else - script_path=@remote_scripts_path + script_path=File.join(@remote_scripts_path, subdirectory) end File.join(script_path, action_script_name(action, default_name))+ diff --git a/src/sunstone/public/app/tabs/vnets-tab/form-panels/create.js b/src/sunstone/public/app/tabs/vnets-tab/form-panels/create.js index 7d8ad1c9b0..6ba5f81d2d 100644 --- a/src/sunstone/public/app/tabs/vnets-tab/form-panels/create.js +++ b/src/sunstone/public/app/tabs/vnets-tab/form-panels/create.js @@ -142,11 +142,21 @@ define(function(require) { $("#vnetCreateARTab #vnetCreateARTabUpdate", context).hide(); + $('#vn_mad_from_host', context).change(function() { + if ($(this).prop('checked')) { + $('select#network_mode,label[for="network_mode"]', context).prop('wizard_field_disabled', true); + } else { + $('select#network_mode,label[for="network_mode"]', context).prop('wizard_field_disabled', false); + } + }); + $('#network_mode', context).change(function() { $('input,select#vlan,label[for!="network_mode"]', $(this).parent()).hide(); $('input', $(this).parent()).val(""); switch ($(this).val()) { case "default": + $('input#vn_mad_from_host,label[for="vn_mad_from_host"]', context).show(); + $('input#vn_mad,label[for="vn_mad"]', context).hide().prop('wizard_field_disabled', true); $('input#bridge,label[for="bridge"]', context).show().prop('wizard_field_disabled', false); $('input#phydev,label[for="phydev"]', context).hide().prop('wizard_field_disabled', true); $('select#vlan,label[for="vlan"]', context).hide().prop('wizard_field_disabled', true); @@ -157,8 +167,11 @@ define(function(require) { $('input#phydev', context).removeAttr('required'); $('input#bridge', context).attr('required', ''); + $('input#vn_mad', context).removeAttr('required'); break; case "802.1Q": + $('input#vn_mad_from_host,label[for="vn_mad_from_host"]', context).show(); + $('input#vn_mad,label[for="vn_mad"]', context).hide().prop('wizard_field_disabled', true); $('input#bridge,label[for="bridge"]', context).show().prop('wizard_field_disabled', false); $('input#phydev,label[for="phydev"]', context).show().prop('wizard_field_disabled', false); $('select#vlan,label[for="vlan"]', context).show().prop('wizard_field_disabled', false); @@ -169,8 +182,11 @@ define(function(require) { $('input#phydev', context).removeAttr('required'); $('input#bridge', context).removeAttr('required'); + $('input#vn_mad', context).removeAttr('required'); break; case "vxlan": + $('input#vn_mad_from_host,label[for="vn_mad_from_host"]', context).show(); + $('input#vn_mad,label[for="vn_mad"]', context).hide().prop('wizard_field_disabled', true); $('input#bridge,label[for="bridge"]', context).show().prop('wizard_field_disabled', false); $('input#phydev,label[for="phydev"]', context).show().prop('wizard_field_disabled', false); $('select#vlan,label[for="vlan"]', context).show().prop('wizard_field_disabled', false); @@ -181,8 +197,11 @@ define(function(require) { $('input#phydev', context).removeAttr('required'); $('input#bridge', context).removeAttr('required'); + $('input#vn_mad', context).removeAttr('required'); break; case "ebtables": + $('input#vn_mad_from_host,label[for="vn_mad_from_host"]', context).show(); + $('input#vn_mad,label[for="vn_mad"]', context).hide().prop('wizard_field_disabled', true); $('input#bridge,label[for="bridge"]', context).show().prop('wizard_field_disabled', false); $('input#phydev,label[for="phydev"]', context).hide().prop('wizard_field_disabled', true); $('select#vlan,label[for="vlan"]', context).show().prop('wizard_field_disabled', false); @@ -193,8 +212,11 @@ define(function(require) { $('input#phydev', context).removeAttr('required'); $('input#bridge', context).attr('required', ''); + $('input#vn_mad', context).removeAttr('required'); break; case "openvswitch": + $('input#vn_mad_from_host,label[for="vn_mad_from_host"]', context).show(); + $('input#vn_mad,label[for="vn_mad"]', context).hide().prop('wizard_field_disabled', true); $('input#bridge,label[for="bridge"]', context).show().prop('wizard_field_disabled', false); $('input#phydev,label[for="phydev"]', context).hide().prop('wizard_field_disabled', true); $('select#vlan,label[for="vlan"]', context).show().prop('wizard_field_disabled', false); @@ -205,8 +227,11 @@ define(function(require) { $('input#phydev', context).removeAttr('required'); $('input#bridge', context).attr('required', ''); + $('input#vn_mad', context).removeAttr('required'); break; case "vmware": + $('input#vn_mad_from_host,label[for="vn_mad_from_host"]', context).show(); + $('input#vn_mad,label[for="vn_mad"]', context).hide().prop('wizard_field_disabled', true); $('input#bridge,label[for="bridge"]', context).show(); $('input#phydev,label[for="phydev"]', context).hide(); $('select#vlan,label[for="vlan"]', context).show(); @@ -217,6 +242,22 @@ define(function(require) { $('input#phydev', context).removeAttr('required'); $('input#bridge', context).attr('required', ''); + $('input#vn_mad', context).removeAttr('required'); + break; + case "custom": + $('input#vn_mad_from_host,label[for="vn_mad_from_host"]', context).hide(); + $('input#vn_mad,label[for="vn_mad"]', context).show().prop('wizard_field_disabled', false); + $('input#bridge,label[for="bridge"]', context).show().prop('wizard_field_disabled', false); + $('input#phydev,label[for="phydev"]', context).show().prop('wizard_field_disabled', false); + $('select#vlan,label[for="vlan"]', context).show().prop('wizard_field_disabled', false); + $('input#vlan_id,label[for="vlan_id"]', context).show().prop('wizard_field_disabled', false); + $('input#ip_spoofing,label[for="ip_spoofing"]', context).show().prop('wizard_field_disabled', false); + $('input#mac_spoofing,label[for="mac_spoofing"]', context).show().prop('wizard_field_disabled', false); + $('input#mtu,label[for="mtu"]', context).show().prop('wizard_field_disabled', false); + + $('input#phydev', context).removeAttr('required'); + $('input#bridge', context).removeAttr('required'); + $('input#vn_mad', context).attr('required', ''); break; } @@ -353,6 +394,8 @@ define(function(require) { // Show all network mode inputs, and make them not required. This will change // if a different network model is selected + $('input#vn_mad_from_host,label[for="vn_mad_from_host"]', context).show(); + $('input#vn_mad,label[for="vn_mad"]', context).show().prop('wizard_field_disabled', false).removeAttr('required'); $('input#bridge,label[for="bridge"]', context).show().prop('wizard_field_disabled', false).removeAttr('required'); $('input#phydev,label[for="phydev"]', context).show().prop('wizard_field_disabled', false).removeAttr('required'); $('select#vlan,label[for="vlan"]', context).show().prop('wizard_field_disabled', false).removeAttr('required'); diff --git a/src/vmm_mad/exec/one_vmm_exec.rb b/src/vmm_mad/exec/one_vmm_exec.rb index c11ad08f16..ab574a5026 100755 --- a/src/vmm_mad/exec/one_vmm_exec.rb +++ b/src/vmm_mad/exec/one_vmm_exec.rb @@ -46,7 +46,6 @@ class VmmAction # List of xpaths required by the VNM driver actions XPATH_LIST = %w( ID DEPLOY_ID - TEMPLATE/NIC TEMPLATE/SECURITY_GROUP_RULE HISTORY_RECORDS/HISTORY/HOSTNAME ) @@ -89,33 +88,59 @@ class VmmAction @data[:vm] = Base64.encode64(vm_template).delete("\n") # VM data for VNM - vm_template_xml = REXML::Document.new(vm_template).root - vm_vnm_xml = REXML::Document.new('').root - - XPATH_LIST.each do |xpath| - elements = vm_template_xml.elements.each(xpath) do |element| - add_element_to_path(vm_vnm_xml, element, xpath) - end - end + vnm_src_drivers, vm_vnm_src_xml = prepare_vnm_drivers_xml(vm_template, @data[:net_drv]) # Initialize streams and vnm @ssh_src = @vmm.get_ssh_stream(action, @data[:host], @id) - @vnm_src = VirtualNetworkDriver.new(@data[:net_drv], + @vnm_src = VirtualNetworkDriver.new(vnm_src_drivers, :local_actions => @vmm.options[:local_actions], - :message => vm_vnm_xml.to_s, + :message => vm_vnm_src_xml.to_s, :ssh_stream => @ssh_src) if @data[:dest_host] and !@data[:dest_host].empty? + vnm_dst_drivers, vm_vnm_dst_xml = prepare_vnm_drivers_xml(vm_template, @data[:dest_driver]) + @ssh_dst = @vmm.get_ssh_stream(action, @data[:dest_host], @id) - @vnm_dst = VirtualNetworkDriver.new(@data[:dest_driver], + @vnm_dst = VirtualNetworkDriver.new(vnm_dst_drivers, :local_actions => @vmm.options[:local_actions], - :message => vm_vnm_xml.to_s, + :message => vm_vnm_dst_xml.to_s, :ssh_stream => @ssh_dst) end @tm = TransferManagerDriver.new(nil) end + #Prepares the list of drivers executed on the host and the xml that will be sent to the network drivers + # @param[String] The template of the VM. + # @param[String] The host networking driver. + # @return[Array] Returns a list of network drivers and the associated xml template. + def prepare_vnm_drivers_xml(vm_template, host_vn_driver) + vm_template_xml = REXML::Document.new(vm_template).root + vm_vnm_xml = REXML::Document.new('').root + vnm_drivers = [] + + XPATH_LIST.each do |xpath| + vm_template_xml.elements.each(xpath) do |element| + add_element_to_path(vm_vnm_xml, element, xpath) + end + end + + vm_template_xml.elements.each("TEMPLATE/NIC") do |element| + vn_mad = element.get_text("VN_MAD").to_s + + if vn_mad.empty? + vn_mad = host_vn_driver + e = element.add_element("VN_MAD") + e.add_text(REXML::CData.new(vn_mad)) + end + + vnm_drivers << vn_mad unless vnm_drivers.include?(vn_mad) + add_element_to_path(vm_vnm_xml, element, "TEMPLATE/NIC") + end + + return vnm_drivers, vm_vnm_xml + end + #Execute a set of steps defined with # - :driver :vmm or :vnm to execute the step # - :action for the step diff --git a/src/vnm/AddressRange.cc b/src/vnm/AddressRange.cc index 5a33574f78..f04e412ee3 100644 --- a/src/vnm/AddressRange.cc +++ b/src/vnm/AddressRange.cc @@ -814,11 +814,17 @@ void AddressRange::set_vnet(VectorAttribute *nic, const vector &inherit) { nic->replace("AR_ID", id); + string vn_mad = attr->vector_value("VN_MAD"); string bridge = attr->vector_value("BRIDGE"); string vlan = attr->vector_value("VLAN"); string vlanid = attr->vector_value("VLAN_ID"); string phydev = attr->vector_value("PHYDEV"); + if (!vn_mad.empty()) + { + nic->replace("VN_MAD", vn_mad); + } + if (!bridge.empty()) { nic->replace("BRIDGE", bridge); diff --git a/src/vnm/VirtualNetwork.cc b/src/vnm/VirtualNetwork.cc index 17f9d9e6e2..f5440eeca9 100644 --- a/src/vnm/VirtualNetwork.cc +++ b/src/vnm/VirtualNetwork.cc @@ -124,6 +124,12 @@ int VirtualNetwork::insert(SqlDB * db, string& error_str) goto error_name; } + // ------------ VN_MAD -------------------- + + erase_template_attribute("VN_MAD", vn_mad); + + add_template_attribute("VN_MAD", vn_mad); + // ------------ PHYDEV -------------------- erase_template_attribute("PHYDEV", phydev); @@ -262,12 +268,17 @@ int VirtualNetwork::post_update_template(string& error) /* ---------------------------------------------------------------------- */ /* Update Configuration Attributes (class & template) */ + /* - VN_MAD */ /* - PHYDEV */ /* - VLAN_ID */ /* - VLAN */ /* - BRIDGE */ /* - SECURITY_GROUPS */ /* ---------------------------------------------------------------------- */ + erase_template_attribute("VN_MAD", vn_mad); + + add_template_attribute("VN_MAD", vn_mad); + erase_template_attribute("PHYDEV", phydev); add_template_attribute("PHYDEV", phydev); @@ -446,6 +457,15 @@ string& VirtualNetwork::to_xml_extended(string& xml, bool extended, os << ""; } + if (!vn_mad.empty()) + { + os << ""; + } + else + { + os << ""; + } + if (!phydev.empty()) { os << "" << one_util::escape_xml(phydev) << ""; @@ -503,6 +523,7 @@ int VirtualNetwork::from_xml(const string &xml_str) // Permissions rc += perms_from_xml(); + xpath(vn_mad, "/VNET/VN_MAD", ""); xpath(phydev, "/VNET/PHYDEV", ""); xpath(vlan_id,"/VNET/VLAN_ID",""); xpath(parent_vid,"/VNET/PARENT_NETWORK_ID",-1); @@ -589,6 +610,11 @@ int VirtualNetwork::nic_attribute( nic->replace("VLAN", "NO"); } + if (!vn_mad.empty()) + { + nic->replace("VN_MAD", vn_mad); + } + if (!phydev.empty()) { nic->replace("PHYDEV", phydev); diff --git a/src/vnm_mad/one_vnm.rb b/src/vnm_mad/one_vnm.rb index 519c3edeb2..f3539f0088 100644 --- a/src/vnm_mad/one_vnm.rb +++ b/src/vnm_mad/one_vnm.rb @@ -26,15 +26,16 @@ class VirtualNetworkDriver # @param [String] name of the vnet driver to use, as listed in remotes/vnet # @option ops [String] :ssh_stream to be used for command execution # @option ops [String] :message from ONE - def initialize(directory, options={}) + def initialize(vnm_drivers, options={}) + @vnm_drivers = vnm_drivers - @options = options - @ssh_stream = options[:ssh_stream] - @message = options[:message] + @options = options + @ssh_stream = options[:ssh_stream] + @message = options[:message] - @vm_encoded = Base64.encode64(@message).delete("\n") + @vm_encoded = Base64.encode64(@message).delete("\n") - initialize_helper("vnm/#{directory}", options) + initialize_helper("vnm", options) end # Calls remotes or local action checking the action name and @@ -54,24 +55,34 @@ class VirtualNetworkDriver cmd_params = "#{@vm_encoded}" cmd_params << " #{options[:parameters]}" if options[:parameters] - cmd = action_command_line(aname, cmd_params) + result = RESULT[:success] + infos = "" - if action_is_local?(aname) - execution = LocalCommand.run(cmd, log_method(id)) - elsif @ssh_stream != nil - if options[:stdin] - cmdin = "cat << EOT | #{cmd}" - stdin = "#{options[:stdin]}\nEOT\n" + @vnm_drivers.each do |subdirectory| + cmd = action_command_line(aname, cmd_params, nil, subdirectory) + + if action_is_local?(aname) + execution = LocalCommand.run(cmd, log_method(id)) + elsif @ssh_stream != nil + if options[:stdin] + cmdin = "cat << EOT | #{cmd}" + stdin = "#{options[:stdin]}\nEOT\n" + else + cmdin = cmd + stdin = nil + end + + execution = @ssh_stream.run(cmdin, stdin, cmd) else - cmdin = cmd - stdin = nil + return RESULT[:failure], "Network action #{aname} needs a ssh stream." end - execution = @ssh_stream.run(cmdin, stdin, cmd) - else - return RESULT[:failure], "Network action #{aname} needs a ssh stream." + result, info = get_info_from_execution(execution) + infos <<= info + + return [result, infos] if DriverExecHelper.failed?(result) end - return get_info_from_execution(execution) + return [result, infos] end end diff --git a/src/vnm_mad/remotes/802.1Q/clean b/src/vnm_mad/remotes/802.1Q/clean index 27431030f2..bb16012805 100755 --- a/src/vnm_mad/remotes/802.1Q/clean +++ b/src/vnm_mad/remotes/802.1Q/clean @@ -19,15 +19,20 @@ $: << File.dirname(__FILE__) $: << File.join(File.dirname(__FILE__), "..") -require 'vnmmad' require 'vlan_tag_driver' -template64 = ARGV[0] +template64 = ARGV[0] +deploy_id = nil +hypervisor = nil +xpath_filter = VLANTagDriver::XPATH_FILTER begin hm = VLANTagDriver.from_base64(template64) hm.deactivate - filter_driver = VNMMAD::VNMDriver.filter_driver(template64) + filter_driver = VNMMAD::VNMDriver.filter_driver(template64, + deploy_id, + hypervisor, + xpath_filter) filter_driver.deactivate rescue Exception => e OpenNebula.log_error(e.message) diff --git a/src/vnm_mad/remotes/802.1Q/post b/src/vnm_mad/remotes/802.1Q/post deleted file mode 120000 index e0046b5997..0000000000 --- a/src/vnm_mad/remotes/802.1Q/post +++ /dev/null @@ -1 +0,0 @@ -../fw/post \ No newline at end of file diff --git a/src/vnm_mad/remotes/802.1Q/post b/src/vnm_mad/remotes/802.1Q/post new file mode 100755 index 0000000000..e4339dcf99 --- /dev/null +++ b/src/vnm_mad/remotes/802.1Q/post @@ -0,0 +1,39 @@ +#!/usr/bin/env ruby + +# -------------------------------------------------------------------------- # +# Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- # + +$: << File.dirname(__FILE__) +$: << File.join(File.dirname(__FILE__), "..") + +require 'vlan_tag_driver' + +template64 = ARGV[0] +deploy_id = ARGV[1] +hypervisor = nil +xpath_filter = VLANTagDriver::XPATH_FILTER + +begin + filter_driver = VNMMAD::VNMDriver.filter_driver(template64, + deploy_id, + hypervisor, + xpath_filter) + filter_driver.activate +rescue Exception => e + OpenNebula.log_error(e.message) + OpenNebula.log_error(e.backtrace) + exit 1 +end diff --git a/src/vnm_mad/remotes/802.1Q/vlan_tag_driver.rb b/src/vnm_mad/remotes/802.1Q/vlan_tag_driver.rb index 284323793e..87e43e21e8 100644 --- a/src/vnm_mad/remotes/802.1Q/vlan_tag_driver.rb +++ b/src/vnm_mad/remotes/802.1Q/vlan_tag_driver.rb @@ -27,7 +27,7 @@ class VLANTagDriver < VNMMAD::VLANDriver # DRIVER name and XPATH for relevant NICs DRIVER = "802.1Q" - XPATH_FILTER = "TEMPLATE/NIC[VLAN='YES']" + XPATH_FILTER = "TEMPLATE/NIC[VN_MAD='802.1Q']" ############################################################################ # Create driver device operations are locked diff --git a/src/vnm_mad/remotes/ebtables/Ebtables.rb b/src/vnm_mad/remotes/ebtables/Ebtables.rb index 7a5089c33b..f2fa328350 100644 --- a/src/vnm_mad/remotes/ebtables/Ebtables.rb +++ b/src/vnm_mad/remotes/ebtables/Ebtables.rb @@ -17,9 +17,9 @@ require 'vnmmad' class EbtablesVLAN < VNMMAD::VNMDriver - DRIVER = "ebtables" - XPATH_FILTER = "TEMPLATE/NIC[VLAN='YES']" + DRIVER = "ebtables" + XPATH_FILTER = "TEMPLATE/NIC[VN_MAD='ebtables']" def initialize(vm, deploy_id = nil, hypervisor = nil) super(vm,XPATH_FILTER,deploy_id,hypervisor) diff --git a/src/vnm_mad/remotes/ebtables/clean b/src/vnm_mad/remotes/ebtables/clean index 3e29a2beee..865cc46157 100755 --- a/src/vnm_mad/remotes/ebtables/clean +++ b/src/vnm_mad/remotes/ebtables/clean @@ -21,10 +21,22 @@ $: << File.join(File.dirname(__FILE__), "..") require 'Ebtables' -template64 = ARGV[0] +template64 = ARGV[0] +deploy_id = nil +hypervisor = nil +xpath_filter = EbtablesVLAN::XPATH_FILTER onevlan = EbtablesVLAN.from_base64(template64) onevlan.deactivate -filter_driver = VNMMAD::VNMDriver.filter_driver(template64) -filter_driver.deactivate +begin + filter_driver = VNMMAD::VNMDriver.filter_driver(template64, + deploy_id, + hypervisor, + xpath_filter) + filter_driver.deactivate +rescue Exception => e + OpenNebula.log_error(e.message) + OpenNebula.log_error(e.backtrace) + exit 1 +end diff --git a/src/vnm_mad/remotes/ebtables/post b/src/vnm_mad/remotes/ebtables/post index ec3003574c..e77de4921b 100755 --- a/src/vnm_mad/remotes/ebtables/post +++ b/src/vnm_mad/remotes/ebtables/post @@ -21,14 +21,19 @@ $: << File.join(File.dirname(__FILE__), "..") require 'Ebtables' -template64 = ARGV[0] -deploy_id = ARGV[1] +template64 = ARGV[0] +deploy_id = ARGV[1] +hypervisor = nil +xpath_filter = EbtablesVLAN::XPATH_FILTER onevlan = EbtablesVLAN.from_base64(template64, deploy_id) onevlan.activate begin - filter_driver = VNMMAD::VNMDriver.filter_driver(template64, deploy_id) + filter_driver = VNMMAD::VNMDriver.filter_driver(template64, + deploy_id, + hypervisor, + xpath_filter) filter_driver.activate rescue Exception => e OpenNebula.log_error(e.message) diff --git a/src/vnm_mad/remotes/lib/sg_driver.rb b/src/vnm_mad/remotes/lib/sg_driver.rb index 7a9487bc26..eb9c5af58b 100644 --- a/src/vnm_mad/remotes/lib/sg_driver.rb +++ b/src/vnm_mad/remotes/lib/sg_driver.rb @@ -25,7 +25,11 @@ module VNMMAD XPATH_FILTER = "TEMPLATE/NIC" # Creates a new SG driver and scans SG Rules - def initialize(vm, deploy_id = nil, hypervisor = nil) + def initialize(vm, deploy_id = nil, hypervisor = nil, xpath_filter = nil) + if xpath_filter + XPATH_FILTER.replace xpath_filter + end + super(vm, XPATH_FILTER, deploy_id, hypervisor) @locking = true @commands = VNMNetwork::Commands.new diff --git a/src/vnm_mad/remotes/ovswitch/OpenvSwitch.rb b/src/vnm_mad/remotes/ovswitch/OpenvSwitch.rb index b5028e0882..bae6d4a173 100644 --- a/src/vnm_mad/remotes/ovswitch/OpenvSwitch.rb +++ b/src/vnm_mad/remotes/ovswitch/OpenvSwitch.rb @@ -17,14 +17,13 @@ require 'vnmmad' class OpenvSwitchVLAN < VNMMAD::VNMDriver - DRIVER = "ovswitch" + DRIVER = "ovswitch" + XPATH_FILTER = "TEMPLATE/NIC[VN_MAD='ovswitch']" FIREWALL_PARAMS = [:black_ports_tcp, :black_ports_udp, :icmp] - XPATH_FILTER = "TEMPLATE/NIC" - def initialize(vm, deploy_id = nil, hypervisor = nil) super(vm,XPATH_FILTER,deploy_id,hypervisor) @locking = false diff --git a/src/vnm_mad/remotes/vmware/VMware.rb b/src/vnm_mad/remotes/vmware/VMware.rb index f03d9a3102..8987dddc7e 100644 --- a/src/vnm_mad/remotes/vmware/VMware.rb +++ b/src/vnm_mad/remotes/vmware/VMware.rb @@ -37,9 +37,9 @@ require 'CommandManager' require 'vnmmad' class OpenNebulaVMware < VNMMAD::VNMDriver - DRIVER = "vmware" - XPATH_FILTER = "TEMPLATE/NIC" + DRIVER = "vmware" + XPATH_FILTER = "TEMPLATE/NIC[VN_MAD='vmware']" VCLI_CMD = "/sbin/esxcfg-vswitch" def initialize(vm, deploy_id = nil, hypervisor = nil) diff --git a/src/vnm_mad/remotes/vxlan/clean b/src/vnm_mad/remotes/vxlan/clean index 26bf254ce6..faebc8deb6 100755 --- a/src/vnm_mad/remotes/vxlan/clean +++ b/src/vnm_mad/remotes/vxlan/clean @@ -19,15 +19,20 @@ $: << File.dirname(__FILE__) $: << File.join(File.dirname(__FILE__), "..") -require 'vnmmad' require 'vxlan_driver' -template64 = ARGV[0] +template64 = ARGV[0] +deploy_id = nil +hypervisor = nil +xpath_filter = VXLANDriver::XPATH_FILTER begin hm = VXLANDriver.from_base64(template64) hm.deactivate - filter_driver = VNMMAD::VNMDriver.filter_driver(template64) + filter_driver = VNMMAD::VNMDriver.filter_driver(template64, + deploy_id, + hypervisor, + xpath_filter) filter_driver.deactivate rescue Exception => e OpenNebula.log_error(e.message) diff --git a/src/vnm_mad/remotes/vxlan/post b/src/vnm_mad/remotes/vxlan/post deleted file mode 120000 index e0046b5997..0000000000 --- a/src/vnm_mad/remotes/vxlan/post +++ /dev/null @@ -1 +0,0 @@ -../fw/post \ No newline at end of file diff --git a/src/vnm_mad/remotes/vxlan/post b/src/vnm_mad/remotes/vxlan/post new file mode 100755 index 0000000000..67992fc634 --- /dev/null +++ b/src/vnm_mad/remotes/vxlan/post @@ -0,0 +1,39 @@ +#!/usr/bin/env ruby + +# -------------------------------------------------------------------------- # +# Copyright 2002-2015, OpenNebula Project (OpenNebula.org), C12G Labs # +# # +# Licensed under the Apache License, Version 2.0 (the "License"); you may # +# not use this file except in compliance with the License. You may obtain # +# a copy of the License at # +# # +# http://www.apache.org/licenses/LICENSE-2.0 # +# # +# Unless required by applicable law or agreed to in writing, software # +# distributed under the License is distributed on an "AS IS" BASIS, # +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +# See the License for the specific language governing permissions and # +# limitations under the License. # +#--------------------------------------------------------------------------- # + +$: << File.dirname(__FILE__) +$: << File.join(File.dirname(__FILE__), "..") + +require 'vxlan_driver' + +template64 = ARGV[0] +deploy_id = ARGV[1] +hypervisor = nil +xpath_filter = VXLANDriver::XPATH_FILTER + +begin + filter_driver = VNMMAD::VNMDriver.filter_driver(template64, + deploy_id, + hypervisor, + xpath_filter) + filter_driver.activate +rescue Exception => e + OpenNebula.log_error(e.message) + OpenNebula.log_error(e.backtrace) + exit 1 +end diff --git a/src/vnm_mad/remotes/vxlan/vxlan_driver.rb b/src/vnm_mad/remotes/vxlan/vxlan_driver.rb index b28957df2b..e2cb04d66c 100644 --- a/src/vnm_mad/remotes/vxlan/vxlan_driver.rb +++ b/src/vnm_mad/remotes/vxlan/vxlan_driver.rb @@ -27,7 +27,7 @@ class VXLANDriver < VNMMAD::VLANDriver # DRIVER name and XPATH for relevant NICs DRIVER = "vxlan" - XPATH_FILTER = "TEMPLATE/NIC[VLAN='YES']" + XPATH_FILTER = "TEMPLATE/NIC[VN_MAD='vxlan']" ############################################################################ # Create driver device operations are locked