parent
ceb6f763df
commit
5ec73c867b
3 changed files with 24 additions and 4 deletions
2
example/Vagrantfile
vendored
2
example/Vagrantfile
vendored
|
@ -7,6 +7,8 @@ Vagrant.configure("2") do |config|
|
||||||
config.vm.box = "ubuntu-cloud"
|
config.vm.box = "ubuntu-cloud"
|
||||||
config.vm.hostname = 'ubuntu-cloud-box'
|
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.synced_folder "/tmp", "/vagrant_data"
|
||||||
|
|
||||||
config.vm.provider :lxc do |lxc|
|
config.vm.provider :lxc do |lxc|
|
||||||
|
|
|
@ -9,6 +9,7 @@ require 'vagrant-lxc/action/created'
|
||||||
require 'vagrant-lxc/action/destroy'
|
require 'vagrant-lxc/action/destroy'
|
||||||
require 'vagrant-lxc/action/handle_box_metadata'
|
require 'vagrant-lxc/action/handle_box_metadata'
|
||||||
require 'vagrant-lxc/action/is_running'
|
require 'vagrant-lxc/action/is_running'
|
||||||
|
require 'vagrant-lxc/action/network'
|
||||||
require 'vagrant-lxc/action/share_folders'
|
require 'vagrant-lxc/action/share_folders'
|
||||||
|
|
||||||
module Vagrant
|
module Vagrant
|
||||||
|
@ -192,10 +193,6 @@ module Vagrant
|
||||||
# TODO: Check if our requirements are met.
|
# TODO: Check if our requirements are met.
|
||||||
class CheckLXC < BaseAction; end
|
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
|
# TODO: Implement port forwarding with rinetd
|
||||||
class ForwardPorts < BaseAction; end
|
class ForwardPorts < BaseAction; end
|
||||||
|
|
||||||
|
|
21
lib/vagrant-lxc/action/network.rb
Normal file
21
lib/vagrant-lxc/action/network.rb
Normal 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
|
Loading…
Reference in a new issue