Sha256: 11437348f84a446c41ffbe85c72a4c0ad59322f83c2da2962b218a302f9d1636
Contents?: true
Size: 1.37 KB
Versions: 2
Compression:
Stored size: 1.37 KB
Contents
require 'ipaddr' require 'tempfile' module VagrantPlugins module GuestVyatta module Cap class ConfigureNetworks def self.configure_networks(machine, networks) machine.communicate.tap do |comm| commands = <<-EOS WRAPPER=/opt/vyatta/sbin/vyatta-cfg-cmd-wrapper . /etc/bash_completion $WRAPPER begin EOS networks.each do |network| commands << "$WRAPPER delete interfaces ethernet eth#{network[:interface]}\n" if network[:type].to_sym == :static subnet = IPAddr.new(network[:netmask]).to_i.to_s(2).count("1") commands << "$WRAPPER set interfaces ethernet eth#{network[:interface]} address #{network[:ip]}/#{subnet}\n" elsif network[:type].to_sym == :dhcp commands << "$WRAPPER set interfaces ethernet eth#{network[:interface]} address dhcp\n" end end commands << <<-EOS $WRAPPER commit $WRAPPER save $WRAPPER end EOS temp = Tempfile.new("vagrant") temp.binmode temp.write(commands) temp.close comm.upload(temp.path, "/tmp/vagrant-configure-network") comm.sudo("sudo bash /tmp/vagrant-configure-network") comm.sudo("sudo rm /tmp/vagrant-configure-network") end end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
vagrant-vyatta-0.0.2 | lib/vagrant-vyatta/cap/configure_networks.rb |
vagrant-vyatta-0.0.1 | lib/vagrant-vyatta/cap/configure_networks.rb |