1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-21 14:50:08 +03:00

feature #863: specific xpath filters for each network driver

This commit is contained in:
Jaime Melis 2011-12-07 14:49:07 +01:00
parent 6aca0412d2
commit d69d767420
6 changed files with 18 additions and 12 deletions

View File

@ -17,8 +17,9 @@
require 'OpenNebulaNetwork'
class OpenNebulaHM < OpenNebulaNetwork
XPATH_FILTER = "TEMPLATE/NIC[VLAN='YES']"
def initialize(vm, hypervisor = nil)
super(vm,hypervisor)
super(vm,XPATH_FILTER,hypervisor)
@bridges = get_interfaces
end

View File

@ -15,8 +15,10 @@
#--------------------------------------------------------------------------- #
class OpenNebulaFirewall < OpenNebulaNetwork
XPATH_FILTER = "TEMPLATE/NIC[ICMP|WHITE_PORTS_TCP|WHITE_PORTS_UDP|" <<
"BLACK_PORTS_TCP|BLACK_PORTS_UDP]"
def initialize(vm, hypervisor = nil)
super(vm,hypervisor)
super(vm,XPATH_FILTER,hypervisor)
end
def activate
vm_id = @vm['ID']

View File

@ -45,14 +45,15 @@ COMMANDS = {
class VM
attr_accessor :nics, :vm_info
def initialize(vm_root, hypervisor)
@vm_root = vm_root
@hypervisor = hypervisor
@vm_info = Hash.new
def initialize(vm_root, xpath_filter, hypervisor)
@vm_root = vm_root
@xpath_filter = xpath_filter
@hypervisor = hypervisor
@vm_info = Hash.new
nics = Nics.new(@hypervisor)
@vm_root.elements.each("TEMPLATE/NIC[VLAN='YES']") do |nic_element|
@vm_root.elements.each(@xpath_filter) do |nic_element|
nic = nics.new_nic
nic_element.elements.each('*') do |nic_attribute|
@ -96,14 +97,14 @@ class OpenNebulaNetwork
self.new(vm_xml, hypervisor)
end
def initialize(vm_tpl, hypervisor=nil)
def initialize(vm_tpl, xpath_filter, hypervisor=nil)
if !hypervisor
@hypervisor = detect_hypervisor
else
@hypervisor = hypervisor
end
@vm = VM.new(REXML::Document.new(vm_tpl).root, @hypervisor)
@vm = VM.new(REXML::Document.new(vm_tpl).root, xpath_filter, @hypervisor)
end
def process(&block)

View File

@ -17,8 +17,9 @@
require 'OpenNebulaNetwork'
class EbtablesVLAN < OpenNebulaNetwork
XPATH_FILTER = "TEMPLATE/NIC[VLAN='YES']"
def initialize(vm, hypervisor = nil)
super(vm,hypervisor)
super(vm,XPATH_FILTER,hypervisor)
end
def ebtables(rule)

View File

@ -17,8 +17,9 @@
require 'OpenNebulaNetwork'
class OpenvSwitchVLAN < OpenNebulaNetwork
XPATH_FILTER = "TEMPLATE/NIC[VLAN='YES']"
def initialize(vm, hypervisor = nil)
super(vm,hypervisor)
super(vm,XPATH_FILTER,hypervisor)
end
def activate

View File

@ -43,7 +43,7 @@ describe 'networking' do
$capture_commands = {
/virsh.*dumpxml/ => OUTPUT[:virsh_dumpxml]
}
onevlan = OpenNebulaNetwork.new(OUTPUT[:onevm_show],"kvm")
onevlan = OpenNebulaNetwork.new(OUTPUT[:onevm_show],"TEMPLATE/NIC","kvm")
nics_expected = [{:bridge=>"br0",
:ip=>"172.16.0.100",
:mac=>"02:00:ac:10:00:64",