diff --git a/lib/vagrant-lxc.rb b/lib/vagrant-lxc.rb index e5bc235..405c1ce 100644 --- a/lib/vagrant-lxc.rb +++ b/lib/vagrant-lxc.rb @@ -1,7 +1,8 @@ require "vagrant-lxc/version" +require "vagrant-lxc/plugin" + module Vagrant module LXC - # Your code goes here... end end diff --git a/lib/vagrant-lxc/config.rb b/lib/vagrant-lxc/config.rb new file mode 100644 index 0000000..732f9e2 --- /dev/null +++ b/lib/vagrant-lxc/config.rb @@ -0,0 +1,6 @@ +module Vagrant + module LXC + class Config < Vagrant.plugin("2", :config) + end + end +end diff --git a/lib/vagrant-lxc/plugin.rb b/lib/vagrant-lxc/plugin.rb new file mode 100644 index 0000000..178450f --- /dev/null +++ b/lib/vagrant-lxc/plugin.rb @@ -0,0 +1,23 @@ +require "vagrant" + +module Vagrant + module LXC + class Plugin < Vagrant.plugin("2") + name "Linux Containers (LXC) provider" + description <<-EOF + The LXC provider allows Vagrant to manage and control + LXC-based virtual machines. + EOF + + provider(:lxc) do + require File.expand_path("../provider", __FILE__) + Provider + end + + config(:lxc, :provider) do + require File.expand_path("../config", __FILE__) + Config + end + end + end +end diff --git a/lib/vagrant-lxc/provider.rb b/lib/vagrant-lxc/provider.rb new file mode 100644 index 0000000..ed0b9b0 --- /dev/null +++ b/lib/vagrant-lxc/provider.rb @@ -0,0 +1,24 @@ +require "vagrant-lxc/machine_state" + +require "log4r" + +module Vagrant + module LXC + # DISCUSS: VirtualBox provider has a #machine_id_changed, do we need to handle it as well? + class Provider < Vagrant.plugin("2", :provider) + def initialize(machine) + @logger = Log4r::Logger.new("vagrant::provider::lxc") + @machine = machine + end + + def state + LXC::MachineState.new(@machine) + end + + def to_s + id = @machine.id ? @machine.id : "new VM" + "LXC (#{id})" + end + end + end +end