<commit_before># A general Vagrant system implementation for "solaris 11".
#
# Contributed by <NAME> <<EMAIL>>

module VagrantPlugins
  module GuestSolaris11
    module Cap
      class ConfigureNetworks
        def self.configure_networks(machine, networks)
          networks.each do |network|
            device = "#{machine.config.solaris11.device}#{network[:interface]}"
            su_cmd = machine.config.solaris11.suexec_cmd
            mask = "#{network[:netmask]}"
            cidr = mask.split(".").map { |e| e.to_i.to_s(2).rjust(8, "0") }.join.count("1").to_s
            #ifconfig_cmd = "#{su_cmd} /sbin/ifconfig #{device}"
            #machine.communicate.execute("#{ifconfig_cmd} plumb")
            if network[:type].to_sym == :static
              #machine.communicate.execute("#{ifconfig_cmd} inet #{network[:ip]} netmask #{network[:netmask]}")
              #machine.communicate.execute("#{ifconfig_cmd} up")
              #machine.communicate.execute("#{su_cmd} sh -c \"echo '#{network[:ip]}' > /etc/hostname.#{device}\"")
              # ipadm create-addr -T static -a local=172.16.10.15/24 net2/v4
              machine.communicate.execute("#{su_cmd} ipadm create-addr -T static -a #{network[:ip]}/#{cidr} #{device}/v4")
            elsif network[:type].to_sym == :dhcp
              #machine.communicate.execute("#{ifconfig_cmd} dhcp start")
              if machine.communicate.test("ipadm show-if -o all | grep #{device} | tr -s ' ' | cut -d ' ' -f 6  | grep '4\|6'")
                machine.communicate.execute("#{su_cmd} ipadm create-addr -T addrconf #{device}/v4")
              end
            end
          end
        end
      end
    end
  end<commit_msg>Adding condition for the ipadm command on static ip addresses. This will enable restarting solaris 11 vagrant boxes with static ip addresses.<commit_after># A general Vagrant system implementation for "solaris 11".
#
# Contributed by <NAME> <<EMAIL>>

module VagrantPlugins
  module GuestSolaris11
    module Cap
      class ConfigureNetworks
        def self.configure_networks(machine, networks)
          networks.each do |network|
            device = "#{machine.config.solaris11.device}#{network[:interface]}"
            su_cmd = machine.config.solaris11.suexec_cmd
            mask = "#{network[:netmask]}"
            cidr = mask.split(".").map { |e| e.to_i.to_s(2).rjust(8, "0") }.join.count("1").to_s
            #ifconfig_cmd = "#{su_cmd} /sbin/ifconfig #{device}"
            #machine.communicate.execute("#{ifconfig_cmd} plumb")
            if network[:type].to_sym == :static
              #machine.communicate.execute("#{ifconfig_cmd} inet #{network[:ip]} netmask #{network[:netmask]}")
              #machine.communicate.execute("#{ifconfig_cmd} up")
              #machine.communicate.execute("#{su_cmd} sh -c \"echo '#{network[:ip]}' > /etc/hostname.#{device}\"")
              # ipadm create-addr -T static -a local=172.16.10.15/24 net2/v4
              if not machine.communicate.test("ipadm | grep #{network[:ip]} | tr -s ' ' | cut -d ' ' -f 4")
                machine.communicate.execute("#{su_cmd} ipadm create-addr -T static -a #{network[:ip]}/#{cidr} #{device}/v4")
              end
            elsif network[:type].to_sym == :dhcp
              #machine.communicate.execute("#{ifconfig_cmd} dhcp start")
              if machine.communicate.test("ipadm show-if -o all | grep #{device} | tr -s ' ' | cut -d ' ' -f 6  | grep '4\|6'")
                machine.communicate.execute("#{su_cmd} ipadm create-addr -T addrconf #{device}/v4")
              end
            end
          end
        end
      end
    end
  end
{'fraction_non_alphanumeric': 0.15206611570247933, 'fraction_numerical': 0.017355371900826446, 'mean_word_length': 2.412593984962406, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 2, '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': '7583635', 'n_tokens_mistral': 1186, 'n_tokens_neox': 1145, 'n_words': 252}