mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-26 06:50:09 +03:00
Added ebtables-flush and also ebtables-kvm to install.sh
git-svn-id: http://svn.opennebula.org/one/trunk@889 3034c82b-c49b-4eb3-8279-a7acafdc01c0
This commit is contained in:
parent
c7c2de3773
commit
455e1ab338
@ -458,7 +458,9 @@ TM_EXAMPLE_SHARE_FILES="share/examples/tm/tm_clone.sh \
|
||||
# HOOK scripts, to be installed under $SHARE_LOCATION/hooks
|
||||
#-------------------------------------------------------------------------------
|
||||
|
||||
HOOK_SHARE_FILES="share/hooks/ebtables-xen"
|
||||
HOOK_SHARE_FILES="share/hooks/ebtables-xen \
|
||||
share/hooks/ebtables-kvm \
|
||||
share/hooks/ebtables-flush"
|
||||
|
||||
#-------------------------------------------------------------------------------
|
||||
# Common Cloud Files
|
||||
|
50
share/hooks/ebtables-flush
Executable file
50
share/hooks/ebtables-flush
Executable file
@ -0,0 +1,50 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
def deactivate(rule)
|
||||
system "sudo ebtables -D #{rule}"
|
||||
end
|
||||
|
||||
def get_interfaces
|
||||
brctl_exit=`brctl show`
|
||||
brctl_exit.split("\n")[1..-1].collect{|l| l.split.last }
|
||||
end
|
||||
|
||||
RULE_TYPES={
|
||||
'INPUT' => /-i ([\w\.\-]+) /,
|
||||
'OUTPUT' => /-o ([\w\.\-]+) /
|
||||
}
|
||||
|
||||
def get_rules
|
||||
rules=Hash.new
|
||||
RULE_TYPES.each do |name, reg|
|
||||
r=Array.new
|
||||
ebtables_exit=`sudo ebtables -L #{name}`
|
||||
rules[name]=ebtables_exit.split("\n")[3..-1].collect do |l|
|
||||
line=l.strip
|
||||
m=line.match(reg)
|
||||
if m
|
||||
interface=m[1]
|
||||
{
|
||||
:interface => interface,
|
||||
:rule => line
|
||||
}
|
||||
else
|
||||
nil
|
||||
end
|
||||
end.compact
|
||||
end
|
||||
|
||||
rules
|
||||
end
|
||||
|
||||
interfaces=get_interfaces
|
||||
all_rules=get_rules
|
||||
|
||||
all_rules.each do |chain, rules|
|
||||
rules.each do |rule|
|
||||
if !interfaces.include?(rule[:interface])
|
||||
deactivate("#{chain} #{rule[:rule]}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
Loading…
x
Reference in New Issue
Block a user