<commit_before># -------------------------------------------------------------------------- #
# Copyright 2002-2022, 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.                                             #
#--------------------------------------------------------------------------- #

require 'open3'

module VNMMAD

    # Network related commands for VN drivers
    module VNMNetwork

        # Command configuration for common network commands. This CAN be adjust
        # to local installations. Any modification requires to sync the hosts
        # with onehost sync command.
        COMMANDS = {
            :ebtables => 'sudo -n ebtables --concurrent',
            :iptables => 'sudo -n iptables -w 3 -W 20000',
            :ip6tables=> 'sudo -n ip6tables -w 3 -W 20000',
            :ip       => 'sudo -n ip',
            :ip_unpriv=> 'ip',
            :virsh    => 'virsh -c qemu:///system',
            :ovs_vsctl=> 'sudo -n ovs-vsctl',
            :ovs_ofctl=> 'sudo -n ovs-ofctl',
            :ovs_appctl=> 'sudo -n ovs-appctl',
            :lsmod    => 'lsmod',
            :ipset    => 'sudo -n ipset'
        }

        # Adjust :ip[6]tables commands to work with legacy version
        stdout = Open3.capture3('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'
        end<commit_msg>F #5890: adjust iptables version command (#2219)<commit_after># -------------------------------------------------------------------------- #
# Copyright 2002-2022, 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.                                             #
#--------------------------------------------------------------------------- #

require 'open3'

module VNMMAD

    # Network related commands for VN drivers
    module VNMNetwork

        # Command configuration for common network commands. This CAN be adjust
        # to local installations. Any modification requires to sync the hosts
        # with onehost sync command.
        COMMANDS = {
            :ebtables => 'sudo -n ebtables --concurrent',
            :iptables => 'sudo -n iptables -w 3 -W 20000',
            :ip6tables=> 'sudo -n ip6tables -w 3 -W 20000',
            :ip       => 'sudo -n ip',
            :ip_unpriv=> 'ip',
            :virsh    => 'virsh -c qemu:///system',
            :ovs_vsctl=> 'sudo -n ovs-vsctl',
            :ovs_ofctl=> 'sudo -n ovs-ofctl',
            :ovs_appctl=> 'sudo -n ovs-appctl',
            :lsmod    => 'lsmod',
            :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])

        if Gem::Version.new('1.6.1') > iptables_version
            COMMANDS[:iptables]  = 'sudo -n iptables -w 3'
            COMMANDS[:ip6tables] = 'sudo -n ip6tables -w 3'
        end
{'fraction_non_alphanumeric': 0.15183559457302473, 'fraction_numerical': 0.01675977653631285, 'mean_word_length': 1.2142226148409894, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 26, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3727486', 'n_tokens_mistral': 1285, 'n_tokens_neox': 1193, 'n_words': 410}