From 5606aa8b1e9d66c4080641d3c7fa70805f253d5a Mon Sep 17 00:00:00 2001 From: Brian Johnson Date: Wed, 31 Jul 2013 18:07:04 -0700 Subject: [PATCH] Working implementation with NFS, still some caveats: - There's a lengthy sleep in there, probably could use a back-off loop - en1 seems totally worthless on vbox, I skip it and just use the en2 it creates. --- plugins/guests/darwin/cap/change_host_name.rb | 2 +- .../guests/darwin/cap/configure_networks.rb | 9 ++++---- plugins/guests/darwin/cap/halt.rb | 2 +- plugins/guests/darwin/cap/mount_nfs_folder.rb | 22 ++++++++++--------- plugins/guests/darwin/guest.rb | 2 +- plugins/guests/darwin/plugin.rb | 2 +- 6 files changed, 21 insertions(+), 18 deletions(-) diff --git a/plugins/guests/darwin/cap/change_host_name.rb b/plugins/guests/darwin/cap/change_host_name.rb index 922bbf6da..80df9870d 100644 --- a/plugins/guests/darwin/cap/change_host_name.rb +++ b/plugins/guests/darwin/cap/change_host_name.rb @@ -1,5 +1,5 @@ module VagrantPlugins - module GuestFreeDarwin + module GuestDarwin module Cap class ChangeHostName def self.change_host_name(machine, name) diff --git a/plugins/guests/darwin/cap/configure_networks.rb b/plugins/guests/darwin/cap/configure_networks.rb index 6cb4500ee..5b37dc1b9 100644 --- a/plugins/guests/darwin/cap/configure_networks.rb +++ b/plugins/guests/darwin/cap/configure_networks.rb @@ -3,7 +3,7 @@ require "tempfile" require "vagrant/util/template_renderer" module VagrantPlugins - module GuestFreeDarwin + module GuestDarwin module Cap class ConfigureNetworks include Vagrant::Util @@ -12,6 +12,7 @@ module VagrantPlugins # Slightly different than other plugins, using the template to build commands # rather than templating the files. + machine.communicate.sudo("networksetup -detectnewhardware") devmap = {} machine.communicate.sudo("networksetup -listnetworkserviceorder > /tmp/vagrant.interfaces") tmpints = File.join(Dir.tmpdir, "#{machine.id}.interfaces") @@ -24,14 +25,14 @@ module VagrantPlugins # (Hardware Port: Thunderbolt Ethernet, Device: en1) devicearry = i.match(/Hardware Port: (.+), Device: en(.+)\)/) devmap[devicearry[2]] = devicearry[1] - puts devmap end end networks.each do |network| + if network[:type].to_sym == :static - # network seems 1 indexed - skip NAT interface (en0) - intnum = network[:interface] + # network seems 1 indexed - skip NAT interface (en0) also en1 because it seems to not *really* exist on virtualbox? + intnum = network[:interface] + 1 puts "Network - #{intnum}" command = "networksetup -setmanual \"#{devmap[intnum.to_s]}\" #{network[:ip]} #{network[:netmask]} #{network[:gateway]}" diff --git a/plugins/guests/darwin/cap/halt.rb b/plugins/guests/darwin/cap/halt.rb index edf332fc5..6575f1c93 100644 --- a/plugins/guests/darwin/cap/halt.rb +++ b/plugins/guests/darwin/cap/halt.rb @@ -1,5 +1,5 @@ module VagrantPlugins - module GuestFreeDarwin + module GuestDarwin module Cap class Halt def self.halt(machine) diff --git a/plugins/guests/darwin/cap/mount_nfs_folder.rb b/plugins/guests/darwin/cap/mount_nfs_folder.rb index ff3dd4b3b..c4be11a05 100644 --- a/plugins/guests/darwin/cap/mount_nfs_folder.rb +++ b/plugins/guests/darwin/cap/mount_nfs_folder.rb @@ -1,14 +1,16 @@ module VagrantPlugins - module GuestFreeDarwin - module Cap - class MountNFSFolder - def self.mount_nfs_folder(machine, ip, folders) - folders.each do |name, opts| - machine.communicate.sudo("mkdir -p #{opts[:guestpath]}") - machine.communicate.sudo("mount '#{ip}:#{opts[:hostpath]}' '#{opts[:guestpath]}'") - end + module GuestDarwin + module Cap + class MountNFSFolder + def self.mount_nfs_folder(machine, ip, folders) + puts "30 second nap...." + sleep(30) + folders.each do |name, opts| + machine.communicate.sudo("if [ ! -d #{opts[:guestpath]} ]; then mkdir -p #{opts[:guestpath]};fi") + machine.communicate.sudo("mount -t nfs '#{ip}:#{opts[:hostpath]}' '#{opts[:guestpath]}'") + end + end + end end - end end - end end diff --git a/plugins/guests/darwin/guest.rb b/plugins/guests/darwin/guest.rb index faea6cd77..f3bdb35b5 100644 --- a/plugins/guests/darwin/guest.rb +++ b/plugins/guests/darwin/guest.rb @@ -1,7 +1,7 @@ require 'vagrant/util/template_renderer' module VagrantPlugins - module GuestFreeDarwin + module GuestDarwin # A general Vagrant system implementation for "freebsd". # # Contributed by Kenneth Vestergaard diff --git a/plugins/guests/darwin/plugin.rb b/plugins/guests/darwin/plugin.rb index 733d3318f..5d104ed78 100644 --- a/plugins/guests/darwin/plugin.rb +++ b/plugins/guests/darwin/plugin.rb @@ -1,7 +1,7 @@ require "vagrant" module VagrantPlugins - module GuestFreeDarwin + module GuestDarwin class Plugin < Vagrant.plugin("2") name "Darwin guest" description "Darwin guest support."