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

M #: catch iptables version command exceptions (#2223)

This commit is contained in:
Christian González 2022-07-06 15:16:49 +02:00 committed by GitHub
parent 89ce359739
commit 8103c4bceb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -38,14 +38,17 @@ module VNMMAD
:ipset => 'sudo -n ipset'
}
# Adjust :ip[6]tables commands to work with legacy version
stdout = Open3.capture3('sudo iptables --version')[0]
regex = /.*v(?<version>\d+.\d+.\d+)/
iptables_version = Gem::Version.new(stdout.match(regex)[:version])
# Adjust :ip[6]tables commands to work with legacy versions
begin
stdout = Open3.capture3('sudo iptables --version')[0]
regex = /.*v(?<version>\d+.\d+.\d+)/
iptables_version = Gem::Version.new(stdout.match(regex)[:version])
if Gem::Version.new('1.6.1') > iptables_version
COMMANDS[:iptables] = 'sudo -n iptables -w 3'
COMMANDS[:ip6tables] = 'sudo -n ip6tables -w 3'
if Gem::Version.new('1.6.1') > iptables_version
COMMANDS[:iptables] = 'sudo -n iptables -w 3'
COMMANDS[:ip6tables] = 'sudo -n ip6tables -w 3'
end
rescue StandardError
end
# Represents an Array of commands to be executed by the networking