Skip to content
This repository has been archived by the owner on Jun 25, 2023. It is now read-only.

Commit

Permalink
Merge pull request #138 from strzibny/master
Browse files Browse the repository at this point in the history
Support libvirt provider
  • Loading branch information
strzibny committed Dec 3, 2015
2 parents c08a869 + a840bf7 commit 8e0410b
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 4 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
## [Unreleased][unreleased]

### Added
- vagrant: support for libvirt provider (#138)

## [0.18.0] - 2015-01-24

### Added
Expand Down
5 changes: 5 additions & 0 deletions lib/landrush/action/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module Action
module Common
SUPPORTED_PROVIDERS = {
'VagrantPlugins::ProviderVirtualBox::Provider' => :virtualbox,
'VagrantPlugins::ProviderLibvirt::Provider' => :libvirt,
'HashiCorp::VagrantVMwarefusion::Provider' => :vmware_fusion,
'VagrantPlugins::Parallels::Provider' => :parallels,
'Landrush::FakeProvider' => :fake_provider,
Expand All @@ -28,6 +29,10 @@ def virtualbox?
provider == :virtualbox
end

def libvirt?
provider == :libvirt
end

def vmware?
provider == :vmware_fusion
end
Expand Down
2 changes: 1 addition & 1 deletion lib/landrush/action/redirect_dns.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def _target_host
case provider
when :virtualbox then
'10.0.2.2'
when :vmware_fusion then
when :vmware_fusion, :libvirt then
_gateway_for_ip(machine.guest.capability(:configured_dns_servers).first)
when :parallels then
machine.provider.capability(:host_address)
Expand Down
14 changes: 11 additions & 3 deletions lib/landrush/action/setup.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,17 @@ def configure_server

def start_server
return if Server.running?

info 'starting dns server'
Server.start
# We need to avoid forking with libvirt provider since the forked process
# would try to reuse the libvirt connection and fail.
if libvirt?
require 'open3'
Kernel.puts '[landrush] Starting landrush in background...'
_stdout, stderr, status = Open3.capture3('vagrant landrush start')
Kernel.puts stderr unless status
else
info 'starting dns server'
Server.start
end
end

def setup_static_dns
Expand Down
5 changes: 5 additions & 0 deletions lib/landrush/plugin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ class Plugin < Vagrant.plugin('2')
hook.before(VagrantPlugins::ProviderVirtualBox::Action::Network, pre_boot_actions)
hook.after(Vagrant::Action::Builtin::WaitForCommunicator, post_boot_actions)

if defined?(VagrantPlugins::ProviderLibvirt)
hook.after(VagrantPlugins::ProviderLibvirt::Action::CreateNetworks, pre_boot_actions)
hook.after(VagrantPlugins::ProviderLibvirt::Action::WaitTillUp, post_boot_actions)
end

if defined?(HashiCorp::VagrantVMwarefusion)
hook.before(HashiCorp::VagrantVMwarefusion::Action::Network, pre_boot_actions)
hook.after(HashiCorp::VagrantVMwarefusion::Action::WaitForCommunicator, post_boot_actions)
Expand Down

0 comments on commit 8e0410b

Please sign in to comment.