Sha256: 758bab363696116a418160cca264385b1d354a87c2fdd2936063365046e3e08b

Contents?: true

Size: 1.4 KB

Versions: 2

Compression:

Stored size: 1.4 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]}"
            mask = "#{network[:netmask]}"
            # Convert netmask 255.255.x.y to CIDR /nn
            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.sudo("ipadm create-addr -T static -a #{network[:ip]}/#{cidr} #{device}/v4")
            elsif network[:type].to_sym == :dhcp
              machine.communicate.sudo("ipadm create-addr -T addrconf #{device}/v4")
            end
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vagrant-guests-solaris11-0.0.1a lib/vagrant-guests-solaris11/cap/configure_networks.rb
vagrant-guests-solaris11-0.0.1.dev lib/vagrant-guests-solaris11/cap/configure_networks.rb