Module: VagrantPlugins::Openstack::Action
- Includes:
- Vagrant::Action::Builtin
- Defined in:
- lib/vagrant-openstack-illuin-provider/action.rb,
lib/vagrant-openstack-illuin-provider/action/resume.rb,
lib/vagrant-openstack-illuin-provider/action/message.rb,
lib/vagrant-openstack-illuin-provider/action/suspend.rb,
lib/vagrant-openstack-illuin-provider/action/provision.rb,
lib/vagrant-openstack-illuin-provider/action/wait_stop.rb,
lib/vagrant-openstack-illuin-provider/action/read_state.rb,
lib/vagrant-openstack-illuin-provider/action/stop_server.rb,
lib/vagrant-openstack-illuin-provider/action/wait_active.rb,
lib/vagrant-openstack-illuin-provider/action/create_stack.rb,
lib/vagrant-openstack-illuin-provider/action/delete_stack.rb,
lib/vagrant-openstack-illuin-provider/action/start_server.rb,
lib/vagrant-openstack-illuin-provider/action/sync_folders.rb,
lib/vagrant-openstack-illuin-provider/action/create_server.rb,
lib/vagrant-openstack-illuin-provider/action/delete_server.rb,
lib/vagrant-openstack-illuin-provider/action/read_ssh_info.rb,
lib/vagrant-openstack-illuin-provider/action/snapshot_list.rb,
lib/vagrant-openstack-illuin-provider/action/snapshot_save.rb,
lib/vagrant-openstack-illuin-provider/action/abstract_action.rb,
lib/vagrant-openstack-illuin-provider/action/snapshot_delete.rb,
lib/vagrant-openstack-illuin-provider/action/snapshot_cleanup.rb,
lib/vagrant-openstack-illuin-provider/action/snapshot_restore.rb,
lib/vagrant-openstack-illuin-provider/action/connect_openstack.rb
Defined Under Namespace
Classes: AbstractAction, ConnectOpenstack, CreateServer, CreateStack, DeleteServer, DeleteStack, InternalProvisionWrapper, Message, NoSyncFolders, ProvisionWrapper, ReadSSHInfo, ReadState, Resume, RsyncFolders, SSHInfoHolder, SnapshotCleanup, SnapshotDelete, SnapshotList, SnapshotRestore, SnapshotSave, StartServer, StopServer, Suspend, SyncFolders, WaitForServerToBeActive, WaitForServerToStop
Class Method Summary
collapse
Class Method Details
.action_destroy ⇒ Object
This action is called to destroy the remote machine.
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
|
# File 'lib/vagrant-openstack-illuin-provider/action.rb', line 12
def self.action_destroy
new_builder.tap do |b|
b.use ConfigValidate
b.use ConnectOpenstack
b.use Call, ReadState do |env, b2|
if env[:machine_state_id] == :not_created
b2.use Message, I18n.t('vagrant_openstack.not_created')
else
b2.use(ProvisionerCleanup, :before)
b2.use SnapshotCleanup if Gem::Version.new(Vagrant::VERSION) >= Gem::Version.new('1.8.0')
b2.use DeleteServer
b2.use DeleteStack
end
end
end
end
|
.action_halt ⇒ Object
156
157
158
159
160
161
162
163
164
165
166
167
168
|
# File 'lib/vagrant-openstack-illuin-provider/action.rb', line 156
def self.action_halt
new_builder.tap do |b|
b.use ConfigValidate
b.use ConnectOpenstack
b.use Call, ReadState do |env, b2|
if env[:machine_state_id] == :not_created
b2.use Message, I18n.t('vagrant_openstack.not_created')
else
b2.use StopServer
end
end
end
end
|
.action_provision ⇒ Object
This action is called when ‘vagrant provision` is called.
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/vagrant-openstack-illuin-provider/action.rb', line 30
def self.action_provision
new_builder.tap do |b|
b.use ConfigValidate
b.use ConnectOpenstack
b.use Call, ReadState do |env, b2|
if env[:machine_state_id] == :not_created
b2.use Message, I18n.t('vagrant_openstack.not_created')
else
if env[:machine].provider_config.meta_args_support
b2.use ProvisionWrapper
else
b2.use Provision
end
if env[:machine].provider_config.use_legacy_synced_folders
env[:machine].ui.warn I18n.t('vagrant_openstack.config.sync_folders_deprecated')
b2.use SyncFolders
else
b2.use SyncedFolders
end
end
end
end
end
|
.action_read_ssh_info ⇒ Object
This action is called to read the SSH info of the machine. The resulting state is expected to be put into the ‘:machine_ssh_info` key.
58
59
60
61
62
63
64
|
# File 'lib/vagrant-openstack-illuin-provider/action.rb', line 58
def self.action_read_ssh_info
new_builder.tap do |b|
b.use ConfigValidate
b.use ConnectOpenstack
b.use ReadSSHInfo
end
end
|
.action_read_state ⇒ Object
This action is called to read the state of the machine. The resulting state is expected to be put into the ‘:machine_state_id` key.
69
70
71
72
73
74
75
76
|
# File 'lib/vagrant-openstack-illuin-provider/action.rb', line 69
def self.action_read_state
new_builder.tap do |b|
b.use HandleBox
b.use ConfigValidate
b.use ConnectOpenstack
b.use ReadState
end
end
|
.action_resume ⇒ Object
This is the action that is primarily responsible for resuming suspended machines. Vm cannot be resumed when the machine_state_id is not suspended.
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
|
# File 'lib/vagrant-openstack-illuin-provider/action.rb', line 195
def self.action_resume
new_builder.tap do |b|
b.use ConfigValidate
b.use ConnectOpenstack
b.use Call, ReadState do |env, b2|
case env[:machine_state_id]
when :not_created
b2.use Message, I18n.t('vagrant_openstack.not_created')
when :suspended
b2.use Resume
else
b2.use Message, I18n.t('vagrant_openstack.not_suspended')
end
end
end
end
|
.action_snapshot_delete ⇒ Object
240
241
242
243
244
245
246
247
248
249
250
251
252
|
# File 'lib/vagrant-openstack-illuin-provider/action.rb', line 240
def self.action_snapshot_delete
new_builder.tap do |b|
b.use ConfigValidate
b.use ConnectOpenstack
b.use Call, IsState, :not_created do |env, b2|
if env[:result]
b2.use Message, I18n.t('vagrant_openstack.not_created')
else
b2.use SnapshotDelete
end
end
end
end
|
.action_snapshot_list ⇒ Object
254
255
256
257
258
259
260
261
262
263
264
265
266
|
# File 'lib/vagrant-openstack-illuin-provider/action.rb', line 254
def self.action_snapshot_list
new_builder.tap do |b|
b.use ConfigValidate
b.use ConnectOpenstack
b.use Call, IsState, :not_created do |env, b2|
if env[:result]
b2.use Message, I18n.t('vagrant_openstack.not_created')
else
b2.use SnapshotList
end
end
end
end
|
.action_snapshot_restore ⇒ Object
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
|
# File 'lib/vagrant-openstack-illuin-provider/action.rb', line 268
def self.action_snapshot_restore
new_builder.tap do |b|
b.use ConfigValidate
b.use ConnectOpenstack
b.use Call, IsState, :not_created do |env, b2|
if env[:result]
b2.use Message, I18n.t('vagrant_openstack.not_created')
next
end
b2.use SnapshotRestore
b2.use WaitForServerToBeActive
b2.use WaitForCommunicator
b2.use Call, IsEnvSet, :snapshot_delete do |env2, b3|
b3.use action_snapshot_delete if env2[:result]
end
b2.use action_provision
end
end
end
|
.action_snapshot_save ⇒ Object
292
293
294
295
296
297
298
299
300
301
302
303
304
|
# File 'lib/vagrant-openstack-illuin-provider/action.rb', line 292
def self.action_snapshot_save
new_builder.tap do |b|
b.use ConfigValidate
b.use ConnectOpenstack
b.use Call, IsState, :not_created do |env, b2|
if env[:result]
b2.use Message, I18n.t('vagrant_openstack.not_created')
else
b2.use SnapshotSave
end
end
end
end
|
.action_ssh ⇒ Object
78
79
80
81
82
83
84
85
86
87
88
89
90
|
# File 'lib/vagrant-openstack-illuin-provider/action.rb', line 78
def self.action_ssh
new_builder.tap do |b|
b.use ConfigValidate
b.use ConnectOpenstack
b.use Call, ReadState do |env, b2|
if env[:machine_state_id] == :not_created
b2.use Message, I18n.t('vagrant_openstack.not_created')
else
b2.use SSHExec
end
end
end
end
|
.action_ssh_run ⇒ Object
92
93
94
95
96
97
98
99
100
101
102
103
104
|
# File 'lib/vagrant-openstack-illuin-provider/action.rb', line 92
def self.action_ssh_run
new_builder.tap do |b|
b.use ConfigValidate
b.use ConnectOpenstack
b.use Call, ReadState do |env, b2|
if env[:machine_state_id] == :not_created
b2.use Message, I18n.t('vagrant_openstack.not_created')
else
b2.use SSHRun
end
end
end
end
|
.action_suspend ⇒ Object
This is the action that is primarily responsible for suspending the virtual machine. Vm cannot be suspended when the machine_state_id is not “active” (typically a task is ongoing)
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
|
# File 'lib/vagrant-openstack-illuin-provider/action.rb', line 173
def self.action_suspend
new_builder.tap do |b|
b.use ConfigValidate
b.use ConnectOpenstack
b.use Call, ReadState do |env, b2|
case env[:machine_state_id]
when :not_created
b2.use Message, I18n.t('vagrant_openstack.not_created')
when :suspended
b2.use Message, I18n.t('vagrant_openstack.already_suspended')
when :active
b2.use Suspend
else
b2.use Message, I18n.t('vagrant_openstack.ongoing_task')
end
end
end
end
|
.action_up ⇒ Object
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
|
# File 'lib/vagrant-openstack-illuin-provider/action.rb', line 106
def self.action_up
new_builder.tap do |b|
b.use HandleBox
b.use ConfigValidate
b.use ConnectOpenstack
b.use Call, ReadState do |env, b2|
case env[:machine_state_id]
when :not_created
ssh_disabled = env[:machine].provider_config.ssh_disabled
unless ssh_disabled
if env[:machine].provider_config.meta_args_support
b2.use ProvisionWrapper
else
b2.use Provision
end
end
if env[:machine].provider_config.use_legacy_synced_folders
env[:machine].ui.warn I18n.t('vagrant_openstack.config.sync_folders_deprecated')
b2.use SyncFolders
else
b2.use SyncedFolders
end
b2.use CreateStack
b2.use CreateServer
b2.use Message, I18n.t('vagrant_openstack.ssh_disabled_provisioning') if ssh_disabled
unless ssh_disabled
timeout = env[:machine].provider_config.ssh_timeout
unless timeout.nil?
env[:machine].ui.warn I18n.t('vagrant_openstack.config.ssh_timeout_deprecated')
env[:machine].config.vm.boot_timeout = timeout
end
b2.use WaitForCommunicator
end
when :shutoff
b2.use StartServer
when :suspended
b2.use Resume
else
b2.use Message, I18n.t('vagrant_openstack.already_created')
end
end
end
end
|
.get_ssh_info(env) ⇒ Object
69
70
71
|
# File 'lib/vagrant-openstack-illuin-provider/action/read_ssh_info.rb', line 69
def self.get_ssh_info(env)
SSHInfoHolder.instance.ssh_info[env[:machine].id.to_sym]
end
|