F #2045: PHYDEV support for dummy, ebtables, fw net. drivers

This commit is contained in:
Vlastimil Holer authored and Ruben S. Montero committed 2018-05-11 18:12:17 +02:00
1 parent de436a9e8d
commit 72a759bd97
13 files changed
+127 -31

No files matched your search

+1
View File
@@ -909,6 +909,7 @@ NETWORK_FILES="src/vnm_mad/remotes/lib/vnm_driver.rb \
src/vnm_mad/remotes/lib/command.rb \
src/vnm_mad/remotes/lib/vm.rb \
src/vnm_mad/remotes/lib/vlan.rb \
src/vnm_mad/remotes/lib/dummy_vlan.rb \
src/vnm_mad/remotes/lib/security_groups.rb \
src/vnm_mad/remotes/lib/security_groups_iptables.rb \
src/vnm_mad/remotes/lib/nic.rb"
+18 -2
View File
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env ruby
# -------------------------------------------------------------------------- #
# Copyright 2002-2018, OpenNebula Project, OpenNebula Systems #
@@ -16,4 +16,20 @@
# limitations under the License. #
#--------------------------------------------------------------------------- #
exit 0
$: << File.dirname(__FILE__)
$: << File.join(File.dirname(__FILE__), "..")
require 'vnmmad'
template64 = ARGV[0]
deploy_id = nil
xpath_filter = "TEMPLATE/NIC[VN_MAD='dummy']"
begin
hm = VNMMAD::DummyVLANDriver.from_base64(template64, xpath_filter, deploy_id)
hm.deactivate
rescue Exception => e
OpenNebula.log_error(e.message)
OpenNebula.log_error(e.backtrace)
exit 1
end
+12 -2
View File
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env ruby
# -------------------------------------------------------------------------- #
# Copyright 2002-2018, OpenNebula Project, OpenNebula Systems #
@@ -16,4 +16,14 @@
# limitations under the License. #
#--------------------------------------------------------------------------- #
exit 0
$: << File.dirname(__FILE__)
$: << File.join(File.dirname(__FILE__), "..")
require 'vnmmad'
template64 = ARGV[0]
deploy_id = ARGV[1]
xpath_filter = "TEMPLATE/NIC[VN_MAD='dummy']"
hm = VNMMAD::DummyVLANDriver.from_base64(template64, xpath_filter, deploy_id)
exit hm.activate
+23 -17
View File
@@ -16,7 +16,7 @@
require 'vnmmad'
class EbtablesVLAN < VNMMAD::VNMDriver
class EbtablesVLAN < VNMMAD::DummyVLANDriver
DRIVER = "ebtables"
XPATH_FILTER = "TEMPLATE/NIC[VN_MAD='ebtables']"
@@ -34,29 +34,33 @@ class EbtablesVLAN < VNMMAD::VNMDriver
# Activates ebtables rules
#
def activate
lock
def activate(pre_action=false)
if pre_action
super()
else
lock
process do |nic|
tap = nic[:tap]
if tap
iface_mac = nic[:mac]
process do |nic|
tap = nic[:tap]
if tap
iface_mac = nic[:mac]
mac = iface_mac.split(':')
mac[-1] = '00'
mac = iface_mac.split(':')
mac[-1] = '00'
net_mac = mac.join(':')
net_mac = mac.join(':')
in_rule="FORWARD -s ! #{net_mac}/ff:ff:ff:ff:ff:00 " <<
"-o #{tap} -j DROP"
out_rule="FORWARD -s ! #{iface_mac} -i #{tap} -j DROP"
in_rule="FORWARD -s ! #{net_mac}/ff:ff:ff:ff:ff:00 " <<
"-o #{tap} -j DROP"
out_rule="FORWARD -s ! #{iface_mac} -i #{tap} -j DROP"
ebtables(in_rule) if nic[:filter_mac_spoofing] =~ /yes/i
ebtables(out_rule)
ebtables(in_rule) if nic[:filter_mac_spoofing] =~ /yes/i
ebtables(out_rule)
end
end
end
unlock
unlock
end
return 0
end
@@ -88,6 +92,8 @@ class EbtablesVLAN < VNMMAD::VNMDriver
unlock
super
return 0
end
+12 -2
View File
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env ruby
# -------------------------------------------------------------------------- #
# Copyright 2002-2018, OpenNebula Project, OpenNebula Systems #
@@ -16,4 +16,14 @@
# limitations under the License. #
#--------------------------------------------------------------------------- #
exit 0
$: << File.dirname(__FILE__)
$: << File.join(File.dirname(__FILE__), "..")
require 'Ebtables'
template64 = ARGV[0]
deploy_id = ARGV[1]
xpath_filter = EbtablesVLAN::XPATH_FILTER
onevlan = EbtablesVLAN.from_base64(template64, xpath_filter, deploy_id)
onevlan.activate(pre_action=true)
+4 -1
View File
@@ -23,9 +23,12 @@ require 'vnmmad'
template64 = ARGV[0]
deploy_id = nil
xpath_filter = nil
xpath_filter = "TEMPLATE/NIC[VN_MAD='fw']"
begin
hm = VNMMAD::DummyVLANDriver.from_base64(template64, xpath_filter, deploy_id)
hm.deactivate
filter_driver = VNMMAD::VNMDriver.filter_driver(template64,
xpath_filter,
deploy_id)
+1 -1
View File
@@ -23,7 +23,7 @@ require 'vnmmad'
template64 = ARGV[0]
deploy_id = ARGV[1]
xpath_filter = nil
xpath_filter = "TEMPLATE/NIC[VN_MAD='fw']"
begin
filter_driver = VNMMAD::VNMDriver.filter_driver(template64,
+12 -2
View File
@@ -1,4 +1,4 @@
#!/bin/bash
#!/usr/bin/env ruby
# -------------------------------------------------------------------------- #
# Copyright 2002-2018, OpenNebula Project, OpenNebula Systems #
@@ -16,4 +16,14 @@
# limitations under the License. #
#--------------------------------------------------------------------------- #
exit 0
$: << File.dirname(__FILE__)
$: << File.join(File.dirname(__FILE__), "..")
require 'vnmmad'
template64 = ARGV[0]
deploy_id = ARGV[1]
xpath_filter = "TEMPLATE/NIC[VN_MAD='fw']"
hm = VNMMAD::DummyVLANDriver.from_base64(template64, xpath_filter, deploy_id)
exit hm.activate
+1 -1
View File
@@ -23,7 +23,7 @@ require 'vnmmad'
template64 = ARGV[0]
deploy_id = ARGV[1]
xpath_filter = nil
xpath_filter = "TEMPLATE/NIC[VN_MAD='fw']"
begin
filter_driver = VNMMAD::VNMDriver.filter_driver(template64,
+38
View File
@@ -0,0 +1,38 @@
# -------------------------------------------------------------------------- #
# Copyright 2002-2018, OpenNebula Project, OpenNebula Systems #
# #
# 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. #
#--------------------------------------------------------------------------- #
module VNMMAD
class DummyVLANDriver< VNMMAD::VLANDriver
def initialize(vm, xpath_filter, deploy_id = nil)
@locking = true
super(vm, xpath_filter, deploy_id)
end
def create_vlan_dev
true
end
private
def get_vlan_dev_name
@nic[:vlan_dev] = @nic[:phydev] if @nic[:phydev]
end
def validate_vlan_id
true
end
end
end
+2 -1
View File
@@ -105,7 +105,8 @@ module VNMMAD
# Delete the vlan device.
OpenNebula.exec_and_log("#{command(:ip)} link delete"\
" #{@nic[:vlan_dev]}")
" #{@nic[:vlan_dev]}") if @nic[:vlan_dev] != @nic[:phydev]
@bridges[@nic[:bridge]].delete(@nic[:vlan_dev])
# Delete the bridge.
+2 -2
View File
@@ -87,7 +87,7 @@ module VNMMAD
default_conf = CONF || {}
nic_conf = {}
if nic[:conf]
if nic[:conf] and nic[:conf].is_a? String
parse_options(nic[:conf]).each do |option, value|
case value.downcase
when 'true', 'yes'
@@ -129,7 +129,7 @@ module VNMMAD
nic_conf[option] = value
end
if nic[conf_name]
if nic[conf_name] and nic[conf_name].is_a? String
parse_options(nic[conf_name]).each do |option, value|
if value == '__delete__'
nic_conf.delete(option.strip.downcase)
+1
View File
@@ -30,6 +30,7 @@ require 'security_groups_iptables'
require 'vnm_driver'
require 'sg_driver'
require 'vlan'
require 'dummy_vlan'
require 'scripts_common'
Dir[File.expand_path('vnmmad-load.d', File.dirname(__FILE__)) + "/*.rb"].each{ |f| require f }