Rename old container references to driver

This commit is contained in:
Fabio Rehm 2013-04-05 02:23:30 -03:00
parent 082f7dc5d3
commit 514736bdd6
10 changed files with 20 additions and 20 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -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 = {

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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' }