private network with IP: check

Closes #28
This commit is contained in:
Fabio Rehm 2013-03-05 00:58:37 -03:00
parent ceb6f763df
commit 5ec73c867b
3 changed files with 24 additions and 4 deletions

2
example/Vagrantfile vendored
View file

@ -7,6 +7,8 @@ Vagrant.configure("2") do |config|
config.vm.box = "ubuntu-cloud"
config.vm.hostname = 'ubuntu-cloud-box'
config.vm.network :private_network, ip: "192.168.33.10"
config.vm.synced_folder "/tmp", "/vagrant_data"
config.vm.provider :lxc do |lxc|

View file

@ -9,6 +9,7 @@ require 'vagrant-lxc/action/created'
require 'vagrant-lxc/action/destroy'
require 'vagrant-lxc/action/handle_box_metadata'
require 'vagrant-lxc/action/is_running'
require 'vagrant-lxc/action/network'
require 'vagrant-lxc/action/share_folders'
module Vagrant
@ -192,10 +193,6 @@ module Vagrant
# TODO: Check if our requirements are met.
class CheckLXC < BaseAction; end
# TODO: Sets up all networking for the container instance. This includes
# host only networks, bridged networking, forwarded ports, etc.
class Network < BaseAction; end
# TODO: Implement port forwarding with rinetd
class ForwardPorts < BaseAction; end

View file

@ -0,0 +1,21 @@
module Vagrant
module LXC
module Action
class Network < BaseAction
def call(env)
# TODO: Validate network configuration prior to anything below
@env = env
env[:machine].config.vm.networks.each do |type, options|
# We only handle private networks
next if type != :private_network
env[:machine].provider_config.start_opts << "lxc.network.ipv4=#{options[:ip]}/24"
end
# Continue the middleware chain.
@app.call(env)
end
end
end
end
end