Tabs must die.
This commit is contained in:
parent
3611ff39f4
commit
e5ce19ff11
|
@ -3,55 +3,55 @@ require "tempfile"
|
|||
require "vagrant/util/template_renderer"
|
||||
|
||||
module VagrantPlugins
|
||||
module GuestDarwin
|
||||
module Cap
|
||||
class ConfigureNetworks
|
||||
include Vagrant::Util
|
||||
module GuestDarwin
|
||||
module Cap
|
||||
class ConfigureNetworks
|
||||
include Vagrant::Util
|
||||
|
||||
def self.configure_networks(machine, networks)
|
||||
# Slightly different than other plugins, using the template to build commands
|
||||
# rather than templating the files.
|
||||
def self.configure_networks(machine, networks)
|
||||
# Slightly different than other plugins, using the template to build commands
|
||||
# rather than templating the files.
|
||||
|
||||
machine.communicate.sudo("networksetup -detectnewhardware")
|
||||
machine.communicate.sudo("networksetup -listnetworkserviceorder > /tmp/vagrant.interfaces")
|
||||
tmpints = File.join(Dir.tmpdir, File.basename("#{machine.id}.interfaces"))
|
||||
machine.communicate.download("/tmp/vagrant.interfaces",tmpints)
|
||||
machine.communicate.sudo("networksetup -detectnewhardware")
|
||||
machine.communicate.sudo("networksetup -listnetworkserviceorder > /tmp/vagrant.interfaces")
|
||||
tmpints = File.join(Dir.tmpdir, File.basename("#{machine.id}.interfaces"))
|
||||
machine.communicate.download("/tmp/vagrant.interfaces",tmpints)
|
||||
|
||||
devlist = []
|
||||
ints = IO.read(tmpints)
|
||||
ints.split(/\n\n/m).each do |i|
|
||||
if i.match(/Hardware/) and not i.match(/Ethernet/).nil?
|
||||
devmap = {}
|
||||
# Ethernet, should be 2 lines,
|
||||
# (3) Thunderbolt Ethernet
|
||||
# (Hardware Port: Thunderbolt Ethernet, Device: en1)
|
||||
devlist = []
|
||||
ints = IO.read(tmpints)
|
||||
ints.split(/\n\n/m).each do |i|
|
||||
if i.match(/Hardware/) and not i.match(/Ethernet/).nil?
|
||||
devmap = {}
|
||||
# Ethernet, should be 2 lines,
|
||||
# (3) Thunderbolt Ethernet
|
||||
# (Hardware Port: Thunderbolt Ethernet, Device: en1)
|
||||
|
||||
# multiline, should match "Thunderbolt Ethernet", "en1"
|
||||
devicearry = i.match(/\([0-9]+\) (.+)\n.*Device: (.+)\)/m)
|
||||
devmap[:interface] = devicearry[2]
|
||||
devmap[:service] = devicearry[1]
|
||||
devlist << devmap
|
||||
end
|
||||
end
|
||||
puts devlist
|
||||
# multiline, should match "Thunderbolt Ethernet", "en1"
|
||||
devicearry = i.match(/\([0-9]+\) (.+)\n.*Device: (.+)\)/m)
|
||||
devmap[:interface] = devicearry[2]
|
||||
devmap[:service] = devicearry[1]
|
||||
devlist << devmap
|
||||
end
|
||||
end
|
||||
puts devlist
|
||||
|
||||
networks.each do |network|
|
||||
intnum = network[:interface]
|
||||
puts network[:interface]
|
||||
puts network[:type]
|
||||
if network[:type].to_sym == :static
|
||||
# network seems 1 indexed - skip NAT interface (en0) also en1 because it seems to not *really* exist on virtualbox?
|
||||
command = "networksetup -setmanual \"#{devlist[intnum+1][:service]}\" #{network[:ip]} #{network[:netmask]}"
|
||||
networks.each do |network|
|
||||
intnum = network[:interface]
|
||||
puts network[:interface]
|
||||
puts network[:type]
|
||||
if network[:type].to_sym == :static
|
||||
# network seems 1 indexed - skip NAT interface (en0) also en1 because it seems to not *really* exist on virtualbox?
|
||||
command = "networksetup -setmanual \"#{devlist[intnum+1][:service]}\" #{network[:ip]} #{network[:netmask]}"
|
||||
|
||||
elsif network[:type].to_sym == :dhcp
|
||||
command = "networksetup -setdhcp \"#{devlist[intnum+1][:service]}\""
|
||||
elsif network[:type].to_sym == :dhcp
|
||||
command = "networksetup -setdhcp \"#{devlist[intnum+1][:service]}\""
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
machine.communicate.sudo(command)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
machine.communicate.sudo(command)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,25 +1,25 @@
|
|||
require "vagrant/util/retryable"
|
||||
|
||||
module VagrantPlugins
|
||||
module GuestDarwin
|
||||
module Cap
|
||||
class MountNFSFolder
|
||||
extend Vagrant::Util::Retryable
|
||||
def self.mount_nfs_folder(machine, ip, folders)
|
||||
folders.each do |name, opts|
|
||||
# Expand the guest path so we can handle things like "~/vagrant"
|
||||
expanded_guest_path = machine.guest.capability(
|
||||
:shell_expand_guest_path, opts[:guestpath])
|
||||
module GuestDarwin
|
||||
module Cap
|
||||
class MountNFSFolder
|
||||
extend Vagrant::Util::Retryable
|
||||
def self.mount_nfs_folder(machine, ip, folders)
|
||||
folders.each do |name, opts|
|
||||
# Expand the guest path so we can handle things like "~/vagrant"
|
||||
expanded_guest_path = machine.guest.capability(
|
||||
:shell_expand_guest_path, opts[:guestpath])
|
||||
|
||||
machine.communicate.sudo("if [ ! -d #{expanded_guest_path} ]; then mkdir -p #{expanded_guest_path};fi")
|
||||
machine.communicate.sudo("if [ ! -d #{expanded_guest_path} ]; then mkdir -p #{expanded_guest_path};fi")
|
||||
|
||||
mount_command = "mount -t nfs '#{ip}:#{opts[:hostpath]}' '#{expanded_guest_path}'"
|
||||
retryable(:on => Vagrant::Errors::DarwinNFSMountFailed, :tries => 10, :sleep => 5) do
|
||||
machine.communicate.sudo(mount_command, :error_class => Vagrant::Errors::DarwinNFSMountFailed)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
mount_command = "mount -t nfs '#{ip}:#{opts[:hostpath]}' '#{expanded_guest_path}'"
|
||||
retryable(:on => Vagrant::Errors::DarwinNFSMountFailed, :tries => 10, :sleep => 5) do
|
||||
machine.communicate.sudo(mount_command, :error_class => Vagrant::Errors::DarwinNFSMountFailed)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,40 +1,40 @@
|
|||
require "vagrant"
|
||||
|
||||
module VagrantPlugins
|
||||
module GuestDarwin
|
||||
class Plugin < Vagrant.plugin("2")
|
||||
name "Darwin guest"
|
||||
description "Darwin guest support."
|
||||
module GuestDarwin
|
||||
class Plugin < Vagrant.plugin("2")
|
||||
name "Darwin guest"
|
||||
description "Darwin guest support."
|
||||
|
||||
guest("darwin") do
|
||||
require File.expand_path("../guest", __FILE__)
|
||||
Guest
|
||||
end
|
||||
guest("darwin") do
|
||||
require File.expand_path("../guest", __FILE__)
|
||||
Guest
|
||||
end
|
||||
|
||||
guest_capability("darwin", "change_host_name") do
|
||||
require_relative "cap/change_host_name"
|
||||
Cap::ChangeHostName
|
||||
end
|
||||
guest_capability("darwin", "change_host_name") do
|
||||
require_relative "cap/change_host_name"
|
||||
Cap::ChangeHostName
|
||||
end
|
||||
|
||||
guest_capability("darwin", "configure_networks") do
|
||||
require_relative "cap/configure_networks"
|
||||
Cap::ConfigureNetworks
|
||||
end
|
||||
guest_capability("darwin", "configure_networks") do
|
||||
require_relative "cap/configure_networks"
|
||||
Cap::ConfigureNetworks
|
||||
end
|
||||
|
||||
guest_capability("darwin", "halt") do
|
||||
require_relative "cap/halt"
|
||||
Cap::Halt
|
||||
end
|
||||
guest_capability("darwin", "halt") do
|
||||
require_relative "cap/halt"
|
||||
Cap::Halt
|
||||
end
|
||||
|
||||
guest_capability("darwin", "mount_nfs_folder") do
|
||||
require_relative "cap/mount_nfs_folder"
|
||||
Cap::MountNFSFolder
|
||||
end
|
||||
guest_capability("darwin", "mount_nfs_folder") do
|
||||
require_relative "cap/mount_nfs_folder"
|
||||
Cap::MountNFSFolder
|
||||
end
|
||||
|
||||
guest_capability("darwin", "shell_expand_guest_path") do
|
||||
require_relative "cap/shell_expand_guest_path"
|
||||
Cap::ShellExpandGuestPath
|
||||
end
|
||||
end
|
||||
end
|
||||
guest_capability("darwin", "shell_expand_guest_path") do
|
||||
require_relative "cap/shell_expand_guest_path"
|
||||
Cap::ShellExpandGuestPath
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue