action.rb
1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
require 'json'
require 'log4r'
require 'vagrant/action/builder'
module Vagrant
module Lxd
module Action
action_root = Pathname.new(File.expand_path("../action", __FILE__))
autoload :Bootstrap, action_root.join("bootstrap")
autoload :Create, action_root.join("create")
autoload :EnsureImage, action_root.join("ensure_image")
autoload :EnsureSsh, action_root.join("ensure_ssh")
autoload :EnsureStarted, action_root.join("ensure_started")
autoload :Network, action_root.join("network")
include Vagrant::Action::Builtin
# This action boots the VM, assuming the VM is in a state that requires
# a bootup (i.e. not saved).
def self.action_up
Vagrant::Action::Builder.new.tap do |b|
b.use ConfigValidate
b.use Call, IsState, :not_created do |env, b2|
# If the VM is NOT created yet, then do the setup steps
if env[:result]
b2.use HandleBox
b2.use EnsureImage
b2.use Network
b2.use Create
b2.use action_start
b2.use Bootstrap
b2.use EnsureSsh
else
b2.use action_start
end
end
end
end
def self.action_start
Vagrant::Action::Builder.new.tap do |b|
b.use EnsureStarted
end
end
def self.action_ssh
Vagrant::Action::Builder.new.tap do |b|
b.use SSHExec
end
end
end
end
end
# vim: set et ts=2 sw=2: