<commit_before>module MachineNics
  class Actions
    module Linux
      def lagg_create(params)
        cmds = []
        cmds.push(%Q!sudo sh -c 'echo "+#{params[:name]}" > /sys/class/net/bonding_masters';!)
        cmds.push(%Q!sudo sh -c 'echo "layer3+4"    > /sys/class/net/#{params[:name]}/bonding/xmit_hash_policy'!)
        cmds.push(%Q!sudo sh -c 'echo balance-xor   > /sys/class/net/#{params[:name]}/bonding/mode'!)
        cmds.push(%Q!sudo sh -c 'echo 100           > /sys/class/net/#{params[:name]}/bonding/miimon'!)
        cmds.push(%Q!sudo ip link set dev #{params[:name]} mtu #{params[:mtu]}!)
        params[:members].each do |nic|
          cmds.push(%Q!sudo ip link set dev #{nic} down!)
          cmds.push(%Q!sudo sh -c 'echo +#{nic}        > /sys/class/net/#{params[:name]}/bonding/slaves'!)
        end
        cmds
      end

      def vlan_create(params)
        cmd = ["sudo vconfig add #{params[:members].first} #{params[:vid]}"]
      end

      def bridge_create(params)
        cmds = []
        cmds.push(%Q!sudo brctl addbr #{params[:name]}!)
        params[:members].each do |nic|
          cmds.push("sudo brctl addif #{params[:name]} #{nic}")
        end
        cmds
      end

      def tap_create(params)
        mtu = params[:mtu]
        cmds = []
        cmds.push(%Q!sudo tunctl -t #{params[:name]}!)<commit_msg>Prevent bridge creation on linux when it already exists.<commit_after>module MachineNics
  class Actions
    module Linux
      def lagg_create(params)
        cmds = []
        cmds.push(%Q!sudo sh -c 'echo "+#{params[:name]}" > /sys/class/net/bonding_masters';!)
        cmds.push(%Q!sudo sh -c 'echo "layer3+4"    > /sys/class/net/#{params[:name]}/bonding/xmit_hash_policy'!)
        cmds.push(%Q!sudo sh -c 'echo balance-xor   > /sys/class/net/#{params[:name]}/bonding/mode'!)
        cmds.push(%Q!sudo sh -c 'echo 100           > /sys/class/net/#{params[:name]}/bonding/miimon'!)
        cmds.push(%Q!sudo ip link set dev #{params[:name]} mtu #{params[:mtu]}!)
        params[:members].each do |nic|
          cmds.push(%Q!sudo ip link set dev #{nic} down!)
          cmds.push(%Q!sudo sh -c 'echo +#{nic}        > /sys/class/net/#{params[:name]}/bonding/slaves'!)
        end
        cmds
      end

      def vlan_create(params)
        cmd = ["sudo vconfig add #{params[:members].first} #{params[:vid]}"]
      end

      def bridge_create(params)
        cmds = []
        cmds.push("[ ! -d /sys/class/net/#{params[:name]}/ ] && sudo brctl addbr #{params[:name]}")
        params[:members].each do |nic|
          cmds.push("sudo brctl addif #{params[:name]} #{nic}")
        end
        cmds
      end

      def tap_create(params)
        mtu = params[:mtu]
        cmds = []
        cmds.push(%Q!sudo tunctl -t #{params[:name]}!)
{'fraction_non_alphanumeric': 0.17775393419170243, 'fraction_numerical': 0.00357653791130186, 'mean_word_length': 2.3780193236714977, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '648573', 'n_tokens_mistral': 1001, 'n_tokens_neox': 958, 'n_words': 202}