Remove after create script support from box metadata
This commit is contained in:
parent
cf2da28625
commit
3d30418e53
4 changed files with 0 additions and 53 deletions
|
@ -1,6 +1,5 @@
|
|||
require 'vagrant-lxc/action/base_action'
|
||||
|
||||
require 'vagrant-lxc/action/after_create'
|
||||
require 'vagrant-lxc/action/boot'
|
||||
require 'vagrant-lxc/action/check_created'
|
||||
require 'vagrant-lxc/action/check_running'
|
||||
|
@ -54,7 +53,6 @@ module Vagrant
|
|||
b.use ForwardPorts
|
||||
b.use SaneDefaults
|
||||
b.use Customize
|
||||
b.use AfterCreate
|
||||
b.use Boot
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,15 +0,0 @@
|
|||
module Vagrant
|
||||
module LXC
|
||||
module Action
|
||||
class AfterCreate < BaseAction
|
||||
def call(env)
|
||||
# Continue, we need the VM to be booted.
|
||||
@app.call env
|
||||
if env[:just_created] && (script = env[:machine].box.metadata['after-create-script'])
|
||||
env[:machine].provider.container.run_after_create_script script
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -55,21 +55,6 @@ module Vagrant
|
|||
@name
|
||||
end
|
||||
|
||||
def run_after_create_script(script)
|
||||
private_key = Vagrant.source_root.join('keys', 'vagrant').expand_path.to_s
|
||||
|
||||
# TODO: Gotta write somewhere that it has to be indempotent
|
||||
retryable(:tries => 5, :sleep => 2) do
|
||||
@logger.debug 'Attempt to run after-create-script from box metadata'
|
||||
execute *[
|
||||
script,
|
||||
'-r', rootfs_path.to_s,
|
||||
'-k', private_key,
|
||||
'-i', dhcp_ip
|
||||
]
|
||||
end
|
||||
end
|
||||
|
||||
def rootfs_path
|
||||
Pathname.new("#{CONTAINERS_PATH}/#{@name}/rootfs")
|
||||
end
|
||||
|
|
|
@ -100,27 +100,6 @@ describe Vagrant::LXC::Container do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'after create script execution' do
|
||||
let(:name) { 'random-container-name' }
|
||||
let(:after_create_path) { '/path/to/after/create' }
|
||||
let(:execute_cmd) { @execute_cmd }
|
||||
let(:priv_key_path) { Vagrant.source_root.join('keys', 'vagrant').expand_path.to_s }
|
||||
let(:ip) { '10.0.3.234' }
|
||||
|
||||
before do
|
||||
subject.stub(dhcp_ip: ip)
|
||||
subject.stub(:execute) { |*args| @execute_cmd = args.join(' ') }
|
||||
subject.run_after_create_script after_create_path
|
||||
end
|
||||
|
||||
it 'runs after-create-script when present passing required variables' do
|
||||
execute_cmd.should include after_create_path
|
||||
execute_cmd.should include "-r /var/lib/lxc/#{name}/rootfs"
|
||||
execute_cmd.should include "-k #{priv_key_path}"
|
||||
execute_cmd.should include "-i #{ip}"
|
||||
end
|
||||
end
|
||||
|
||||
describe 'destruction' do
|
||||
let(:name) { 'container-name' }
|
||||
|
||||
|
|
Loading…
Reference in a new issue