vagrant-eryph 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/LICENSE +21 -0
- data/README.md +79 -0
- data/lib/vagrant-eryph/actions/connect_eryph.rb +40 -0
- data/lib/vagrant-eryph/actions/create_catlet.rb +88 -0
- data/lib/vagrant-eryph/actions/destroy_catlet.rb +33 -0
- data/lib/vagrant-eryph/actions/is_created.rb +34 -0
- data/lib/vagrant-eryph/actions/is_stopped.rb +20 -0
- data/lib/vagrant-eryph/actions/message_already_created.rb +18 -0
- data/lib/vagrant-eryph/actions/message_not_created.rb +18 -0
- data/lib/vagrant-eryph/actions/message_will_not_destroy.rb +18 -0
- data/lib/vagrant-eryph/actions/prepare_cloud_init.rb +52 -0
- data/lib/vagrant-eryph/actions/read_ssh_info.rb +20 -0
- data/lib/vagrant-eryph/actions/read_state.rb +52 -0
- data/lib/vagrant-eryph/actions/start_catlet.rb +40 -0
- data/lib/vagrant-eryph/actions/stop_catlet.rb +40 -0
- data/lib/vagrant-eryph/actions.rb +210 -0
- data/lib/vagrant-eryph/command.rb +573 -0
- data/lib/vagrant-eryph/config.rb +553 -0
- data/lib/vagrant-eryph/errors.rb +61 -0
- data/lib/vagrant-eryph/helpers/cloud_init.rb +113 -0
- data/lib/vagrant-eryph/helpers/eryph_client.rb +413 -0
- data/lib/vagrant-eryph/plugin.rb +28 -0
- data/lib/vagrant-eryph/provider.rb +142 -0
- data/lib/vagrant-eryph/version.rb +7 -0
- data/lib/vagrant-eryph.rb +8 -0
- data/vagrant-eryph.gemspec +27 -0
- metadata +165 -0
@@ -0,0 +1,210 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module VagrantPlugins
|
4
|
+
module Eryph
|
5
|
+
module Actions
|
6
|
+
include Vagrant::Action::Builtin
|
7
|
+
|
8
|
+
# This action is called to halt the remote catlet.
|
9
|
+
def self.action_halt
|
10
|
+
Vagrant::Action::Builder.new.tap do |b|
|
11
|
+
b.use ConfigValidate
|
12
|
+
b.use Call, IsCreated do |env, b2|
|
13
|
+
unless env[:result]
|
14
|
+
b2.use MessageNotCreated
|
15
|
+
next
|
16
|
+
end
|
17
|
+
|
18
|
+
b2.use ConnectEryph
|
19
|
+
b2.use StopCatlet
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
# This action is called to terminate the remote catlet.
|
25
|
+
def self.action_destroy
|
26
|
+
Vagrant::Action::Builder.new.tap do |b|
|
27
|
+
b.use Call, DestroyConfirm do |env, b2|
|
28
|
+
if env[:result]
|
29
|
+
b2.use ConfigValidate
|
30
|
+
b2.use Call, IsCreated do |env2, b3|
|
31
|
+
unless env2[:result]
|
32
|
+
b3.use MessageNotCreated
|
33
|
+
next
|
34
|
+
end
|
35
|
+
|
36
|
+
b3.use ConnectEryph
|
37
|
+
b3.use ProvisionerCleanup, :before if defined?(ProvisionerCleanup)
|
38
|
+
b3.use DestroyCatlet
|
39
|
+
end
|
40
|
+
else
|
41
|
+
b2.use MessageWillNotDestroy
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# This action is called when `vagrant provision` is called.
|
48
|
+
def self.action_provision
|
49
|
+
Vagrant::Action::Builder.new.tap do |b|
|
50
|
+
b.use ConfigValidate
|
51
|
+
b.use Call, IsCreated do |env, b2|
|
52
|
+
unless env[:result]
|
53
|
+
b2.use MessageNotCreated
|
54
|
+
next
|
55
|
+
end
|
56
|
+
|
57
|
+
b2.use Provision
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
# This action is called to read the SSH info of the machine.
|
63
|
+
def self.action_read_ssh_info
|
64
|
+
Vagrant::Action::Builder.new.tap do |b|
|
65
|
+
b.use ConfigValidate
|
66
|
+
b.use ConnectEryph
|
67
|
+
b.use ReadSSHInfo
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
# This action is called to read the state of the machine.
|
72
|
+
def self.action_read_state
|
73
|
+
Vagrant::Action::Builder.new.tap do |b|
|
74
|
+
b.use ConfigValidate
|
75
|
+
b.use ConnectEryph
|
76
|
+
b.use ReadState
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
# This action is called to SSH into the machine.
|
81
|
+
def self.action_ssh
|
82
|
+
Vagrant::Action::Builder.new.tap do |b|
|
83
|
+
b.use ConfigValidate
|
84
|
+
b.use Call, IsCreated do |env, b2|
|
85
|
+
unless env[:result]
|
86
|
+
b2.use MessageNotCreated
|
87
|
+
next
|
88
|
+
end
|
89
|
+
|
90
|
+
b2.use SSHExec
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
def self.action_ssh_run
|
96
|
+
Vagrant::Action::Builder.new.tap do |b|
|
97
|
+
b.use ConfigValidate
|
98
|
+
b.use Call, IsCreated do |env, b2|
|
99
|
+
unless env[:result]
|
100
|
+
b2.use MessageNotCreated
|
101
|
+
next
|
102
|
+
end
|
103
|
+
|
104
|
+
b2.use SSHRun
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
108
|
+
|
109
|
+
def self.action_start
|
110
|
+
Vagrant::Action::Builder.new.tap do |b|
|
111
|
+
b.use Call, IsState, :running do |env1, b1|
|
112
|
+
if env1[:result]
|
113
|
+
b1.use action_provision
|
114
|
+
next
|
115
|
+
end
|
116
|
+
|
117
|
+
b1.use Call, IsState, :stopped do |env2, b2|
|
118
|
+
if env2[:result]
|
119
|
+
b2.use action_resume
|
120
|
+
next
|
121
|
+
end
|
122
|
+
|
123
|
+
b2.use Provision
|
124
|
+
b2.use StartCatlet
|
125
|
+
b2.use WaitForCommunicator
|
126
|
+
end
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
130
|
+
|
131
|
+
def self.action_resume
|
132
|
+
Vagrant::Action::Builder.new.tap do |b|
|
133
|
+
b.use ConfigValidate
|
134
|
+
b.use ConnectEryph
|
135
|
+
b.use Call, IsCreated do |env, b2|
|
136
|
+
unless env[:result]
|
137
|
+
b2.use MessageNotCreated
|
138
|
+
next
|
139
|
+
end
|
140
|
+
|
141
|
+
b2.use StartCatlet
|
142
|
+
b2.use WaitForCommunicator
|
143
|
+
end
|
144
|
+
end
|
145
|
+
end
|
146
|
+
|
147
|
+
# This action is called to bring the catlet up from nothing.
|
148
|
+
def self.action_up
|
149
|
+
Vagrant::Action::Builder.new.tap do |b|
|
150
|
+
b.use ConfigValidate
|
151
|
+
b.use ConnectEryph
|
152
|
+
b.use Call, IsCreated do |env1, b1|
|
153
|
+
if env1[:result]
|
154
|
+
b1.use Call, IsStopped do |env2, b2|
|
155
|
+
if env2[:result]
|
156
|
+
b2.use action_start
|
157
|
+
else
|
158
|
+
b2.use MessageAlreadyCreated
|
159
|
+
end
|
160
|
+
end
|
161
|
+
else
|
162
|
+
b1.use PrepareCloudInit
|
163
|
+
b1.use CreateCatlet
|
164
|
+
b1.use action_start
|
165
|
+
end
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
def self.action_reload
|
171
|
+
Vagrant::Action::Builder.new.tap do |b|
|
172
|
+
b.use ConfigValidate
|
173
|
+
b.use ConnectEryph
|
174
|
+
b.use Call, IsCreated do |env, b2|
|
175
|
+
unless env[:result]
|
176
|
+
b2.use MessageNotCreated
|
177
|
+
next
|
178
|
+
end
|
179
|
+
|
180
|
+
b2.use action_halt
|
181
|
+
b2.use Call, WaitForState, :stopped, 120 do |env2, b3|
|
182
|
+
if env2[:result]
|
183
|
+
b3.use action_up
|
184
|
+
else
|
185
|
+
# TODO: we couldn't reach :stopped, what now?
|
186
|
+
end
|
187
|
+
end
|
188
|
+
end
|
189
|
+
end
|
190
|
+
end
|
191
|
+
|
192
|
+
# The autoload farm
|
193
|
+
action_root = Pathname.new(File.expand_path('actions', __dir__))
|
194
|
+
autoload :ConnectEryph, action_root.join('connect_eryph')
|
195
|
+
autoload :IsCreated, action_root.join('is_created')
|
196
|
+
autoload :IsStopped, action_root.join('is_stopped')
|
197
|
+
autoload :MessageAlreadyCreated, action_root.join('message_already_created')
|
198
|
+
autoload :MessageNotCreated, action_root.join('message_not_created')
|
199
|
+
autoload :MessageWillNotDestroy, action_root.join('message_will_not_destroy')
|
200
|
+
autoload :CreateCatlet, action_root.join('create_catlet')
|
201
|
+
autoload :DestroyCatlet, action_root.join('destroy_catlet')
|
202
|
+
autoload :StartCatlet, action_root.join('start_catlet')
|
203
|
+
autoload :StopCatlet, action_root.join('stop_catlet')
|
204
|
+
autoload :PrepareCloudInit, action_root.join('prepare_cloud_init')
|
205
|
+
autoload :ReadSSHInfo, action_root.join('read_ssh_info')
|
206
|
+
autoload :ReadState, action_root.join('read_state')
|
207
|
+
autoload :WaitForOperation, action_root.join('wait_for_operation')
|
208
|
+
end
|
209
|
+
end
|
210
|
+
end
|