Sha256: 0e8cffa0af8aa5284f9762e4b19c212d28127c37bee77faddc41b1e31f8c4ed7

Contents?: true

Size: 1.82 KB

Versions: 25

Compression:

Stored size: 1.82 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
            #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 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
              #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
end

Version data entries

25 entries across 22 versions & 4 rubygems

Version Path
vagrant-aws-mkubenka-0.7.2.pre.22 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-f3fdbf414272/plugins/guests/solaris11/cap/configure_networks.rb
vagrant-aws-mkubenka-0.7.2.pre.16 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-1ee58c40e3f5/plugins/guests/solaris11/cap/configure_networks.rb
vagrant-unbundled-2.0.0.1 plugins/guests/solaris11/cap/configure_networks.rb
vagrant-unbundled-1.9.8.1 plugins/guests/solaris11/cap/configure_networks.rb
vagrant-unbundled-1.9.7.1 plugins/guests/solaris11/cap/configure_networks.rb
vagrant-aws-mkubenka-0.7.2.pre.14 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/plugins/guests/solaris11/cap/configure_networks.rb
vagrant-aws-mkubenka-0.7.2.pre.11 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/plugins/guests/solaris11/cap/configure_networks.rb
vagrant-aws-mkubenka-0.7.2.pre.10 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/plugins/guests/solaris11/cap/configure_networks.rb
vagrant-aws-mkubenka-0.7.2.pre.9 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/plugins/guests/solaris11/cap/configure_networks.rb
vagrant-unbundled-1.9.5.1 plugins/guests/solaris11/cap/configure_networks.rb
vagrant-unbundled-1.9.1.1 plugins/guests/solaris11/cap/configure_networks.rb
vagrant-compose-yaml-0.1.3 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/plugins/guests/solaris11/cap/configure_networks.rb
vagrant-compose-yaml-0.1.2 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/plugins/guests/solaris11/cap/configure_networks.rb
vagrant-compose-yaml-0.1.1 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/plugins/guests/solaris11/cap/configure_networks.rb
vagrant-compose-yaml-0.1.0 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/plugins/guests/solaris11/cap/configure_networks.rb
vagrant-unbundled-1.8.5.2 plugins/guests/solaris11/cap/configure_networks.rb
vagrant-unbundled-1.8.5.1 plugins/guests/solaris11/cap/configure_networks.rb
vagrant-unbundled-1.8.4.2 plugins/guests/solaris11/cap/configure_networks.rb
vagrant-unbundled-1.8.4.1 plugins/guests/solaris11/cap/configure_networks.rb
vagrant-unbundled-1.8.1.2 plugins/guests/solaris11/cap/configure_networks.rb