From 514736bdd637908174aeef57c8f4026392201b78 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Fri, 5 Apr 2013 02:23:30 -0300 Subject: [PATCH] Rename old container references to driver --- lib/vagrant-lxc/action/boot.rb | 2 +- lib/vagrant-lxc/action/compress_rootfs.rb | 2 +- lib/vagrant-lxc/action/create.rb | 2 +- lib/vagrant-lxc/action/destroy.rb | 2 +- lib/vagrant-lxc/action/forced_halt.rb | 4 ++-- lib/vagrant-lxc/action/forward_ports.rb | 2 +- lib/vagrant-lxc/action/share_folders.rb | 2 +- lib/vagrant-lxc/provider.rb | 12 ++++++------ spec/unit/action/compress_rootfs_spec.rb | 8 ++++---- spec/unit/action/forward_ports_spec.rb | 4 ++-- 10 files changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/vagrant-lxc/action/boot.rb b/lib/vagrant-lxc/action/boot.rb index 361ae1e..e1e8f71 100644 --- a/lib/vagrant-lxc/action/boot.rb +++ b/lib/vagrant-lxc/action/boot.rb @@ -16,7 +16,7 @@ module Vagrant # require SSH access unless env[:machine].state.running? env[:ui].info I18n.t("vagrant.actions.vm.boot.booting") - env[:machine].provider.container.start(config) + env[:machine].provider.driver.start(config) raise Vagrant::Errors::VMFailedToBoot if !wait_for_boot end diff --git a/lib/vagrant-lxc/action/compress_rootfs.rb b/lib/vagrant-lxc/action/compress_rootfs.rb index 63b7186..bbb4bb5 100644 --- a/lib/vagrant-lxc/action/compress_rootfs.rb +++ b/lib/vagrant-lxc/action/compress_rootfs.rb @@ -12,7 +12,7 @@ module Vagrant raise Vagrant::Errors::VMPowerOffToPackage if env[:machine].provider.state.id != :stopped env[:ui].info I18n.t("vagrant.actions.lxc.compressing_rootfs") - @rootfs = env['package.rootfs'] = env[:machine].provider.container.compress_rootfs + @rootfs = env['package.rootfs'] = env[:machine].provider.driver.compress_rootfs @app.call env diff --git a/lib/vagrant-lxc/action/create.rb b/lib/vagrant-lxc/action/create.rb index 5dd8d56..941f65c 100644 --- a/lib/vagrant-lxc/action/create.rb +++ b/lib/vagrant-lxc/action/create.rb @@ -12,7 +12,7 @@ module Vagrant target_rootfs_path = env[:machine].provider_config.target_rootfs_path - machine_id = env[:machine].provider.container.create(base_name, target_rootfs_path, env[:machine].box.metadata) + machine_id = env[:machine].provider.driver.create(base_name, target_rootfs_path, env[:machine].box.metadata) env[:machine].id = machine_id env[:just_created] = true @app.call env diff --git a/lib/vagrant-lxc/action/destroy.rb b/lib/vagrant-lxc/action/destroy.rb index 4c47c79..968c80b 100644 --- a/lib/vagrant-lxc/action/destroy.rb +++ b/lib/vagrant-lxc/action/destroy.rb @@ -8,7 +8,7 @@ module Vagrant def call(env) env[:ui].info I18n.t("vagrant.actions.vm.destroy.destroying") - env[:machine].provider.container.destroy + env[:machine].provider.driver.destroy env[:machine].id = nil @app.call env end diff --git a/lib/vagrant-lxc/action/forced_halt.rb b/lib/vagrant-lxc/action/forced_halt.rb index 2c2961f..b92266f 100644 --- a/lib/vagrant-lxc/action/forced_halt.rb +++ b/lib/vagrant-lxc/action/forced_halt.rb @@ -9,9 +9,9 @@ module Vagrant def call(env) if env[:machine].provider.state.running? env[:ui].info I18n.t("vagrant.actions.vm.halt.force") - # TODO: Container#halt is kinda graceful as well, if it doesn't + # TODO: Driver#halt is kinda graceful as well, if it doesn't # work we can issue a lxc-stop. - env[:machine].provider.container.halt + env[:machine].provider.driver.halt end @app.call(env) diff --git a/lib/vagrant-lxc/action/forward_ports.rb b/lib/vagrant-lxc/action/forward_ports.rb index fc4bf51..9dff4aa 100644 --- a/lib/vagrant-lxc/action/forward_ports.rb +++ b/lib/vagrant-lxc/action/forward_ports.rb @@ -29,7 +29,7 @@ module Vagrant end def forward_ports - @container_ip = @env[:machine].provider.container.assigned_ip + @container_ip = @env[:machine].provider.driver.assigned_ip @env[:forwarded_ports].each do |fp| message_attributes = { diff --git a/lib/vagrant-lxc/action/share_folders.rb b/lib/vagrant-lxc/action/share_folders.rb index 11bc96e..cfea376 100644 --- a/lib/vagrant-lxc/action/share_folders.rb +++ b/lib/vagrant-lxc/action/share_folders.rb @@ -61,7 +61,7 @@ module Vagrant :guest_path => data[:guestpath])) end config = @env[:machine].provider_config - @env[:machine].provider.container.share_folders(folders, config) + @env[:machine].provider.driver.share_folders(folders, config) end end end diff --git a/lib/vagrant-lxc/provider.rb b/lib/vagrant-lxc/provider.rb index b3f9699..ac045a0 100644 --- a/lib/vagrant-lxc/provider.rb +++ b/lib/vagrant-lxc/provider.rb @@ -7,7 +7,7 @@ require "vagrant-lxc/machine_state" module Vagrant module LXC class Provider < Vagrant.plugin("2", :provider) - attr_reader :container + attr_reader :driver def initialize(machine) @logger = Log4r::Logger.new("vagrant::provider::lxc") @@ -23,8 +23,8 @@ module Vagrant begin @logger.debug("Instantiating the container for: #{id.inspect}") - @container = Driver.new(id) - @container.validate! + @driver = Driver.new(id) + @driver.validate! rescue Driver::ContainerNotFound # The container doesn't exist, so we probably have a stale # ID. Just clear the id out of the machine and reload it. @@ -51,15 +51,15 @@ module Vagrant return nil if state == :not_created { - :host => @container.assigned_ip, + :host => @driver.assigned_ip, :port => @machine.config.ssh.guest_port } end def state state_id = nil - state_id = :not_created if !@container.name - state_id = @container.state if !state_id + state_id = :not_created if !@driver.name + state_id = @driver.state if !state_id state_id = :unknown if !state_id LXC::MachineState.new(state_id) end diff --git a/spec/unit/action/compress_rootfs_spec.rb b/spec/unit/action/compress_rootfs_spec.rb index 5ccd0ad..bedc9c5 100644 --- a/spec/unit/action/compress_rootfs_spec.rb +++ b/spec/unit/action/compress_rootfs_spec.rb @@ -6,8 +6,8 @@ describe Vagrant::LXC::Action::CompressRootFS do let(:app) { mock(:app, call: true) } let(:env) { {machine: machine, ui: stub(info: true)} } let(:machine) { fire_double('Vagrant::Machine', provider: provider) } - let(:provider) { fire_double('Vagrant::LXC::Provider', container: container) } - let(:container) { fire_double('Vagrant::LXC::Driver', compress_rootfs: compressed_rootfs_path) } + let(:provider) { fire_double('Vagrant::LXC::Provider', driver: driver) } + let(:driver) { fire_double('Vagrant::LXC::Driver', compress_rootfs: compressed_rootfs_path) } let(:compressed_rootfs_path) { '/path/to/rootfs.tar.gz' } subject { described_class.new(app, env) } @@ -17,8 +17,8 @@ describe Vagrant::LXC::Action::CompressRootFS do subject.call(env) end - it 'asks the container to compress its rootfs' do - container.should have_received(:compress_rootfs) + it "asks the driver to compress container's rootfs" do + driver.should have_received(:compress_rootfs) end it 'sets export.temp_dir on action env' do diff --git a/spec/unit/action/forward_ports_spec.rb b/spec/unit/action/forward_ports_spec.rb index 6a813db..06b74bd 100644 --- a/spec/unit/action/forward_ports_spec.rb +++ b/spec/unit/action/forward_ports_spec.rb @@ -10,8 +10,8 @@ describe Vagrant::LXC::Action::ForwardPorts do let(:networks) { [[:other_config, {}], [:forwarded_port, {guest: guest_port, host: host_port}]] } let(:host_port) { 8080 } let(:guest_port) { 80 } - let(:provider) { fire_double('Vagrant::LXC::Provider', container: container) } - let(:container) { fire_double('Vagrant::LXC::Driver', assigned_ip: container_ip) } + let(:provider) { fire_double('Vagrant::LXC::Provider', driver: driver) } + let(:driver) { fire_double('Vagrant::LXC::Driver', assigned_ip: container_ip) } let(:container_ip) { '10.0.1.234' } let(:pid) { 'a-pid' }