Class: VagrantPlugins::Boot2docker::Cap::ConfigureNetworks

Inherits:
Object
  • Object
show all
Defined in:
lib/vagrant-boot2docker/cap/configure_networks.rb

Class Method Summary collapse

Class Method Details

.configure_networks(machine, networks) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/vagrant-boot2docker/cap/configure_networks.rb', line 7

def self.configure_networks(machine, networks)
  machine.communicate.tap do |comm|
    networks.each do |n|
      if "0.0.0.0" != n[:ip]
       ifc = "/sbin/ifconfig eth#{n[:interface]}"
       broadcast = (IPAddr.new(n[:ip]) | (~ IPAddr.new(n[:netmask]))).to_s
       comm.sudo("#{ifc} down")
       comm.sudo("#{ifc} #{n[:ip]} netmask #{n[:netmask]} broadcast #{broadcast}")
       comm.sudo("#{ifc} up")
      end
    end
  end
end