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

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

(cherry picked from commit 8103c4bceb334a818f9c9d19ad00f6d84286c5e1)
This commit is contained in:
Christian González 2022-07-06 15:16:49 +02:00 committed by Ruben S. Montero
parent c5ff0b02a7
commit 496f2a2be4
No known key found for this signature in database
GPG Key ID: A0CEA6FA880A1D87

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