Rename old container references to driver
This commit is contained in:
parent
082f7dc5d3
commit
514736bdd6
10 changed files with 20 additions and 20 deletions
|
@ -16,7 +16,7 @@ module Vagrant
|
||||||
# require SSH access
|
# require SSH access
|
||||||
unless env[:machine].state.running?
|
unless env[:machine].state.running?
|
||||||
env[:ui].info I18n.t("vagrant.actions.vm.boot.booting")
|
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
|
raise Vagrant::Errors::VMFailedToBoot if !wait_for_boot
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ module Vagrant
|
||||||
raise Vagrant::Errors::VMPowerOffToPackage if env[:machine].provider.state.id != :stopped
|
raise Vagrant::Errors::VMPowerOffToPackage if env[:machine].provider.state.id != :stopped
|
||||||
|
|
||||||
env[:ui].info I18n.t("vagrant.actions.lxc.compressing_rootfs")
|
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
|
@app.call env
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ module Vagrant
|
||||||
|
|
||||||
target_rootfs_path = env[:machine].provider_config.target_rootfs_path
|
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[:machine].id = machine_id
|
||||||
env[:just_created] = true
|
env[:just_created] = true
|
||||||
@app.call env
|
@app.call env
|
||||||
|
|
|
@ -8,7 +8,7 @@ module Vagrant
|
||||||
|
|
||||||
def call(env)
|
def call(env)
|
||||||
env[:ui].info I18n.t("vagrant.actions.vm.destroy.destroying")
|
env[:ui].info I18n.t("vagrant.actions.vm.destroy.destroying")
|
||||||
env[:machine].provider.container.destroy
|
env[:machine].provider.driver.destroy
|
||||||
env[:machine].id = nil
|
env[:machine].id = nil
|
||||||
@app.call env
|
@app.call env
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,9 +9,9 @@ module Vagrant
|
||||||
def call(env)
|
def call(env)
|
||||||
if env[:machine].provider.state.running?
|
if env[:machine].provider.state.running?
|
||||||
env[:ui].info I18n.t("vagrant.actions.vm.halt.force")
|
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.
|
# work we can issue a lxc-stop.
|
||||||
env[:machine].provider.container.halt
|
env[:machine].provider.driver.halt
|
||||||
end
|
end
|
||||||
|
|
||||||
@app.call(env)
|
@app.call(env)
|
||||||
|
|
|
@ -29,7 +29,7 @@ module Vagrant
|
||||||
end
|
end
|
||||||
|
|
||||||
def forward_ports
|
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|
|
@env[:forwarded_ports].each do |fp|
|
||||||
message_attributes = {
|
message_attributes = {
|
||||||
|
|
|
@ -61,7 +61,7 @@ module Vagrant
|
||||||
:guest_path => data[:guestpath]))
|
:guest_path => data[:guestpath]))
|
||||||
end
|
end
|
||||||
config = @env[:machine].provider_config
|
config = @env[:machine].provider_config
|
||||||
@env[:machine].provider.container.share_folders(folders, config)
|
@env[:machine].provider.driver.share_folders(folders, config)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,7 +7,7 @@ require "vagrant-lxc/machine_state"
|
||||||
module Vagrant
|
module Vagrant
|
||||||
module LXC
|
module LXC
|
||||||
class Provider < Vagrant.plugin("2", :provider)
|
class Provider < Vagrant.plugin("2", :provider)
|
||||||
attr_reader :container
|
attr_reader :driver
|
||||||
|
|
||||||
def initialize(machine)
|
def initialize(machine)
|
||||||
@logger = Log4r::Logger.new("vagrant::provider::lxc")
|
@logger = Log4r::Logger.new("vagrant::provider::lxc")
|
||||||
|
@ -23,8 +23,8 @@ module Vagrant
|
||||||
|
|
||||||
begin
|
begin
|
||||||
@logger.debug("Instantiating the container for: #{id.inspect}")
|
@logger.debug("Instantiating the container for: #{id.inspect}")
|
||||||
@container = Driver.new(id)
|
@driver = Driver.new(id)
|
||||||
@container.validate!
|
@driver.validate!
|
||||||
rescue Driver::ContainerNotFound
|
rescue Driver::ContainerNotFound
|
||||||
# The container doesn't exist, so we probably have a stale
|
# The container doesn't exist, so we probably have a stale
|
||||||
# ID. Just clear the id out of the machine and reload it.
|
# ID. Just clear the id out of the machine and reload it.
|
||||||
|
@ -51,15 +51,15 @@ module Vagrant
|
||||||
return nil if state == :not_created
|
return nil if state == :not_created
|
||||||
|
|
||||||
{
|
{
|
||||||
:host => @container.assigned_ip,
|
:host => @driver.assigned_ip,
|
||||||
:port => @machine.config.ssh.guest_port
|
:port => @machine.config.ssh.guest_port
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def state
|
def state
|
||||||
state_id = nil
|
state_id = nil
|
||||||
state_id = :not_created if !@container.name
|
state_id = :not_created if !@driver.name
|
||||||
state_id = @container.state if !state_id
|
state_id = @driver.state if !state_id
|
||||||
state_id = :unknown if !state_id
|
state_id = :unknown if !state_id
|
||||||
LXC::MachineState.new(state_id)
|
LXC::MachineState.new(state_id)
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,8 +6,8 @@ describe Vagrant::LXC::Action::CompressRootFS do
|
||||||
let(:app) { mock(:app, call: true) }
|
let(:app) { mock(:app, call: true) }
|
||||||
let(:env) { {machine: machine, ui: stub(info: true)} }
|
let(:env) { {machine: machine, ui: stub(info: true)} }
|
||||||
let(:machine) { fire_double('Vagrant::Machine', provider: provider) }
|
let(:machine) { fire_double('Vagrant::Machine', provider: provider) }
|
||||||
let(:provider) { fire_double('Vagrant::LXC::Provider', container: container) }
|
let(:provider) { fire_double('Vagrant::LXC::Provider', driver: driver) }
|
||||||
let(:container) { fire_double('Vagrant::LXC::Driver', compress_rootfs: compressed_rootfs_path) }
|
let(:driver) { fire_double('Vagrant::LXC::Driver', compress_rootfs: compressed_rootfs_path) }
|
||||||
let(:compressed_rootfs_path) { '/path/to/rootfs.tar.gz' }
|
let(:compressed_rootfs_path) { '/path/to/rootfs.tar.gz' }
|
||||||
|
|
||||||
subject { described_class.new(app, env) }
|
subject { described_class.new(app, env) }
|
||||||
|
@ -17,8 +17,8 @@ describe Vagrant::LXC::Action::CompressRootFS do
|
||||||
subject.call(env)
|
subject.call(env)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'asks the container to compress its rootfs' do
|
it "asks the driver to compress container's rootfs" do
|
||||||
container.should have_received(:compress_rootfs)
|
driver.should have_received(:compress_rootfs)
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'sets export.temp_dir on action env' do
|
it 'sets export.temp_dir on action env' do
|
||||||
|
|
|
@ -10,8 +10,8 @@ describe Vagrant::LXC::Action::ForwardPorts do
|
||||||
let(:networks) { [[:other_config, {}], [:forwarded_port, {guest: guest_port, host: host_port}]] }
|
let(:networks) { [[:other_config, {}], [:forwarded_port, {guest: guest_port, host: host_port}]] }
|
||||||
let(:host_port) { 8080 }
|
let(:host_port) { 8080 }
|
||||||
let(:guest_port) { 80 }
|
let(:guest_port) { 80 }
|
||||||
let(:provider) { fire_double('Vagrant::LXC::Provider', container: container) }
|
let(:provider) { fire_double('Vagrant::LXC::Provider', driver: driver) }
|
||||||
let(:container) { fire_double('Vagrant::LXC::Driver', assigned_ip: container_ip) }
|
let(:driver) { fire_double('Vagrant::LXC::Driver', assigned_ip: container_ip) }
|
||||||
let(:container_ip) { '10.0.1.234' }
|
let(:container_ip) { '10.0.1.234' }
|
||||||
let(:pid) { 'a-pid' }
|
let(:pid) { 'a-pid' }
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue