Sha256: d3710434decf418491d32bd4393fafd829f869627ec3db2d1c15ce146489a2e8

Contents?: true

Size: 1.43 KB

Versions: 18

Compression:

Stored size: 1.43 KB

Contents

# A general Vagrant system implementation for "solaris 11".
#
# Contributed by Jan Thomas Moldung <janth@moldung.no>

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

            if network[:type].to_sym == :static
              unless machine.communicate.test("ipadm show-if #{device}")
                machine.communicate.execute("#{su_cmd} ipadm create-ip #{device}")
              end
              if machine.communicate.test("ipadm | grep #{device}/v4")
                machine.communicate.execute("#{su_cmd} ipadm delete-addr #{device}/v4")
              end
              machine.communicate.execute("#{su_cmd} ipadm create-addr -T static -a #{network[:ip]}/#{cidr} #{device}/v4")
            elsif network[:type].to_sym == :dhcp
              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
end

Version data entries

18 entries across 18 versions & 3 rubygems

Version Path
vagrant-unbundled-2.3.6.0 plugins/guests/solaris11/cap/configure_networks.rb
tamtam-vagrant-reload-1.2.1 vendor/cache/vagrant-2092df529ae7/plugins/guests/solaris11/cap/configure_networks.rb
vagrant-unbundled-2.3.3.0 plugins/guests/solaris11/cap/configure_networks.rb
vagrant-unbundled-2.3.2.0 plugins/guests/solaris11/cap/configure_networks.rb
vagrant-unbundled-2.2.19.0 plugins/guests/solaris11/cap/configure_networks.rb
vagrant-unbundled-2.2.18.0 plugins/guests/solaris11/cap/configure_networks.rb
vagrant-unbundled-2.2.16.0 plugins/guests/solaris11/cap/configure_networks.rb
vagrant-unbundled-2.2.14.0 plugins/guests/solaris11/cap/configure_networks.rb
vagrant-aws-mkubenka-0.7.2.pre.24 vendor/bundle/ruby/2.7.0/bundler/gems/vagrant-22795b161bf6/plugins/guests/solaris11/cap/configure_networks.rb
vagrant-unbundled-2.2.10.0 plugins/guests/solaris11/cap/configure_networks.rb
vagrant-unbundled-2.2.9.0 plugins/guests/solaris11/cap/configure_networks.rb
vagrant-unbundled-2.2.8.0 plugins/guests/solaris11/cap/configure_networks.rb
vagrant-unbundled-2.2.7.0 plugins/guests/solaris11/cap/configure_networks.rb
vagrant-unbundled-2.2.6.2 plugins/guests/solaris11/cap/configure_networks.rb
vagrant-unbundled-2.2.6.1 plugins/guests/solaris11/cap/configure_networks.rb
vagrant-unbundled-2.2.6.0 plugins/guests/solaris11/cap/configure_networks.rb
vagrant-unbundled-2.2.5.0 plugins/guests/solaris11/cap/configure_networks.rb
vagrant-unbundled-2.2.4.0 plugins/guests/solaris11/cap/configure_networks.rb