From ba994baa65b05fa30d8fb9bd1fe93cc3a114151c Mon Sep 17 00:00:00 2001 From: Tarrant Date: Fri, 24 Oct 2014 13:52:06 -0700 Subject: [PATCH 1/2] Revert "guests/tinycore: error if DHCP [GH-4699]" This reverts commit 64139f2158a957998126f6cf2abcf1042f982175. --- .../guests/tinycore/cap/configure_networks.rb | 4 ---- plugins/guests/tinycore/errors.rb | 13 ------------- plugins/guests/tinycore/plugin.rb | 16 ---------------- templates/locales/guest_tinycore.yml | 8 -------- 4 files changed, 41 deletions(-) delete mode 100644 plugins/guests/tinycore/errors.rb delete mode 100644 templates/locales/guest_tinycore.yml diff --git a/plugins/guests/tinycore/cap/configure_networks.rb b/plugins/guests/tinycore/cap/configure_networks.rb index 5196dd52b..cccc0e311 100644 --- a/plugins/guests/tinycore/cap/configure_networks.rb +++ b/plugins/guests/tinycore/cap/configure_networks.rb @@ -7,10 +7,6 @@ module VagrantPlugins def self.configure_networks(machine, networks) machine.communicate.tap do |comm| networks.each do |n| - if n[:type] == :dhcp - raise Errors::NetworkStaticOnly - end - ifc = "/sbin/ifconfig eth#{n[:interface]}" broadcast = (IPAddr.new(n[:ip]) | (~ IPAddr.new(n[:netmask]))).to_s comm.sudo("#{ifc} down") diff --git a/plugins/guests/tinycore/errors.rb b/plugins/guests/tinycore/errors.rb deleted file mode 100644 index ed9e0e63c..000000000 --- a/plugins/guests/tinycore/errors.rb +++ /dev/null @@ -1,13 +0,0 @@ -module VagrantPlugins - module GuestTinyCore - module Errors - class TinyCoreError < Vagrant::Errors::VagrantError - error_namespace("vagrant_tinycore.errors") - end - - class NetworkStaticOnly < TinyCoreError - error_key(:network_static_only) - end - end - end -end diff --git a/plugins/guests/tinycore/plugin.rb b/plugins/guests/tinycore/plugin.rb index 7c72e58da..b7553fa0a 100644 --- a/plugins/guests/tinycore/plugin.rb +++ b/plugins/guests/tinycore/plugin.rb @@ -2,45 +2,29 @@ require "vagrant" module VagrantPlugins module GuestTinyCore - autoload :Errors, File.expand_path("../errors", __FILE__) - class Plugin < Vagrant.plugin("2") name "TinyCore Linux guest." description "TinyCore Linux guest support." guest("tinycore", "linux") do require File.expand_path("../guest", __FILE__) - init! Guest end guest_capability("tinycore", "configure_networks") do require_relative "cap/configure_networks" - init! Cap::ConfigureNetworks end guest_capability("tinycore", "halt") do require_relative "cap/halt" - init! Cap::Halt end guest_capability("tinycore", "rsync_install") do require_relative "cap/rsync" - init! Cap::RSync end - - protected - - def self.init! - return if defined?(@_init) - I18n.load_path << File.expand_path( - "templates/locales/guest_tinycore.yml", Vagrant.source_root) - I18n.reload! - @_init = true - end end end end diff --git a/templates/locales/guest_tinycore.yml b/templates/locales/guest_tinycore.yml deleted file mode 100644 index f794ef2cc..000000000 --- a/templates/locales/guest_tinycore.yml +++ /dev/null @@ -1,8 +0,0 @@ -en: - vagrant_tinycore: - errors: - network_static_only: |- - The TinyCore guest doesn't support DHCP for networks. Please use - a static assigned IP. If you know how to configure DHCP for - TinyCore, please open an issue on Vagrant with the steps and we'd - be happy to bring this functionality in. From 70fece7a9921223a19f28a897c44565ae4fc5495 Mon Sep 17 00:00:00 2001 From: Tarrant Date: Fri, 24 Oct 2014 13:52:35 -0700 Subject: [PATCH 2/2] Add support for DHCP on tinycore --- plugins/guests/tinycore/cap/configure_networks.rb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/plugins/guests/tinycore/cap/configure_networks.rb b/plugins/guests/tinycore/cap/configure_networks.rb index cccc0e311..3e267748a 100644 --- a/plugins/guests/tinycore/cap/configure_networks.rb +++ b/plugins/guests/tinycore/cap/configure_networks.rb @@ -7,6 +7,11 @@ module VagrantPlugins def self.configure_networks(machine, networks) machine.communicate.tap do |comm| networks.each do |n| + if n[:type] == :dhcp + comm.sudo("/sbin/udhcpc -b -i eth#{n[:interface]} -p /var/run/udhcpc.eth#{n[:interface]}.pid") + return + end + ifc = "/sbin/ifconfig eth#{n[:interface]}" broadcast = (IPAddr.new(n[:ip]) | (~ IPAddr.new(n[:netmask]))).to_s comm.sudo("#{ifc} down")