diff --git a/src/vnm_mad/remotes/ebtables/Ebtables.rb b/src/vnm_mad/remotes/ebtables/Ebtables.rb index 931bd23308..cf1f29b788 100644 --- a/src/vnm_mad/remotes/ebtables/Ebtables.rb +++ b/src/vnm_mad/remotes/ebtables/Ebtables.rb @@ -62,8 +62,15 @@ class EbtablesVLAN < VNMMAD::VNMDriver def deactivate lock + attach_nic_id = @vm['TEMPLATE/NIC[ATTACH="YES"]/NIC_ID'] + process do |nic| + if attach_nic_id && attach_nic_id != nic[:nic_id] + next + end + mac = nic[:mac] + # remove 0-padding mac = mac.split(":").collect{|e| e.hex.to_s(16)}.join(":") diff --git a/src/vnm_mad/remotes/lib/fw_driver.rb b/src/vnm_mad/remotes/lib/fw_driver.rb index 513f7980ed..592b3f7f44 100644 --- a/src/vnm_mad/remotes/lib/fw_driver.rb +++ b/src/vnm_mad/remotes/lib/fw_driver.rb @@ -40,7 +40,7 @@ module VNMMAD lock vm_id = @vm['ID'] - + process do |nic| #:white_ports_tcp => iptables_range #:white_ports_udp => iptables_range @@ -93,8 +93,15 @@ module VNMMAD def deactivate lock - vm_id = @vm['ID'] + vm_id = @vm['ID'] + + attach_nic_id = @vm['TEMPLATE/NIC[ATTACH="YES"]/NIC_ID'] + process do |nic| + if attach_nic_id && attach_nic_id != nic[:nic_id] + next + end + chain = "one-#{vm_id}-#{nic[:network_id]}" iptables_out = `#{command(:iptables)} -n -v --line-numbers -L FORWARD` if m = iptables_out.match(/.*#{chain}.*/) @@ -196,4 +203,4 @@ module VNMMAD "#{command(:iptables)} #{rule}" end end -end \ No newline at end of file +end diff --git a/src/vnm_mad/remotes/lib/sg_driver.rb b/src/vnm_mad/remotes/lib/sg_driver.rb index bf2efea5f4..9a87b0ccbb 100644 --- a/src/vnm_mad/remotes/lib/sg_driver.rb +++ b/src/vnm_mad/remotes/lib/sg_driver.rb @@ -23,7 +23,7 @@ module VNMMAD DRIVER = "sg" XPATH_FILTER = "TEMPLATE/NIC" - + # Creates a new SG driver and scans SG Rules def initialize(vm, deploy_id = nil, hypervisor = nil) super(vm, XPATH_FILTER, deploy_id, hypervisor) @@ -48,7 +48,7 @@ module VNMMAD @security_group_rules = rules end - # Activate the rules, bootstrap iptables chains and set filter rules for + # Activate the rules, bootstrap iptables chains and set filter rules for # each VM NIC def activate deactivate @@ -68,7 +68,7 @@ module VNMMAD sg_ids.each do |sg_id| rules = @security_group_rules[sg_id] - sg = SGIPTables::SecurityGroupIPTables.new(@vm, nic, sg_id, + sg = SGIPTables::SecurityGroupIPTables.new(@vm, nic, sg_id, rules) begin @@ -92,7 +92,13 @@ module VNMMAD lock begin + attach_nic_id = @vm['TEMPLATE/NIC[ATTACH="YES"]/NIC_ID'] + @vm.nics.each do |nic| + if attach_nic_id && attach_nic_id != nic[:nic_id] + next + end + SGIPTables.nic_deactivate(@vm, nic) end rescue Exception => e diff --git a/src/vnm_mad/remotes/ovswitch/OpenvSwitch.rb b/src/vnm_mad/remotes/ovswitch/OpenvSwitch.rb index 8a1bd5e848..adb9e74a44 100644 --- a/src/vnm_mad/remotes/ovswitch/OpenvSwitch.rb +++ b/src/vnm_mad/remotes/ovswitch/OpenvSwitch.rb @@ -72,7 +72,13 @@ class OpenvSwitchVLAN < VNMMAD::VNMDriver def deactivate lock + attach_nic_id = @vm['TEMPLATE/NIC[ATTACH="YES"]/NIC_ID'] + process do |nic| + if attach_nic_id && attach_nic_id != nic[:nic_id] + next + end + @nic = nic # Remove flows