Module: VagrantPlugins::VSphere::Action

Includes:
Vagrant::Action::Builtin
Defined in:
lib/vSphere/action.rb,
lib/vSphere/action/clone.rb,
lib/vSphere/action/resume.rb,
lib/vSphere/action/destroy.rb,
lib/vSphere/action/suspend.rb,
lib/vSphere/action/power_on.rb,
lib/vSphere/action/get_state.rb,
lib/vSphere/action/power_off.rb,
lib/vSphere/action/is_created.rb,
lib/vSphere/action/is_running.rb,
lib/vSphere/action/get_ssh_info.rb,
lib/vSphere/action/is_suspended.rb,
lib/vSphere/action/close_vsphere.rb,
lib/vSphere/action/snapshot_list.rb,
lib/vSphere/action/snapshot_save.rb,
lib/vSphere/action/connect_vsphere.rb,
lib/vSphere/action/snapshot_delete.rb,
lib/vSphere/action/snapshot_restore.rb,
lib/vSphere/action/message_not_created.rb,
lib/vSphere/action/message_not_running.rb,
lib/vSphere/action/wait_for_ip_address.rb,
lib/vSphere/action/message_not_suspended.rb,
lib/vSphere/action/message_already_created.rb

Defined Under Namespace

Classes: Clone, CloseVSphere, ConnectVSphere, Destroy, GetSshInfo, GetState, IsCreated, IsRunning, IsSuspended, MessageAlreadyCreated, MessageNotCreated, MessageNotRunning, MessageNotSuspended, PowerOff, PowerOn, Resume, SnapshotDelete, SnapshotList, SnapshotRestore, SnapshotSave, Suspend, WaitForIPAddress

Class Method Summary collapse

Class Method Details

.action_destroyObject

Vagrant commands



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/vSphere/action.rb', line 10

def self.action_destroy
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use ConnectVSphere
    b.use(ProvisionerCleanup, :before)

    b.use Call, IsRunning do |env, b2|
      if env[:result]
        if env[:force_confirm_destroy]
          b2.use PowerOff
          next
        end

        b2.use Call, GracefulHalt, :poweroff, :running do |env2, b3|
          b3.use PowerOff unless env2[:result]
        end
      end
    end
    b.use Destroy
  end
end

.action_get_ssh_infoObject



217
218
219
220
221
222
223
224
# File 'lib/vSphere/action.rb', line 217

def self.action_get_ssh_info
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use ConnectVSphere
    b.use GetSshInfo
    b.use CloseVSphere
  end
end

.action_get_stateObject

vSphere specific actions



207
208
209
210
211
212
213
214
215
# File 'lib/vSphere/action.rb', line 207

def self.action_get_state
  Vagrant::Action::Builder.new.tap do |b|
    b.use HandleBox
    b.use ConfigValidate
    b.use ConnectVSphere
    b.use GetState
    b.use CloseVSphere
  end
end

.action_haltObject



121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# File 'lib/vSphere/action.rb', line 121

def self.action_halt
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use ConnectVSphere
    b.use Call, IsCreated do |env, b2|
      unless env[:result]
        b2.use MessageNotCreated
        next
      end

      b2.use Call, IsRunning do |env2, b3|
        unless env2[:result]
          b3.use MessageNotRunning
          next
        end

        b3.use Call, GracefulHalt, :poweroff, :running do |env3, b4|
          b4.use PowerOff unless env3[:result]
        end
      end
    end
    b.use CloseVSphere
  end
end

.action_provisionObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/vSphere/action.rb', line 32

def self.action_provision
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, IsCreated do |env, b2|
      unless env[:result]
        b2.use MessageNotCreated
        next
      end

      b2.use Call, IsRunning do |env2, b3|
        unless env2[:result]
          b3.use MessageNotRunning
          next
        end

        b3.use Provision
        b3.use SyncedFolders
      end
    end
  end
end

.action_reloadObject



146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/vSphere/action.rb', line 146

def self.action_reload
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConnectVSphere
    b.use Call, IsCreated do |env, b2|
      unless env[:result]
        b2.use MessageNotCreated
        next
      end
      b2.use action_halt
      b2.use action_up
    end
  end
end

.action_resumeObject



160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
# File 'lib/vSphere/action.rb', line 160

def self.action_resume
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use ConnectVSphere
    b.use Call, IsCreated do |env, b2|
      unless env[:result]
        b2.use MessageNotCreated
        next
      end

      b2.use Call, IsSuspended do |env2, b3|
        unless env2[:result]
          b3.use MessageNotSuspended
          next
        end

        b3.use Resume
      end
    end
    b.use CloseVSphere
  end
end

.action_snapshot_deleteObject



229
230
231
232
233
234
235
236
237
238
239
240
241
242
# File 'lib/vSphere/action.rb', line 229

def self.action_snapshot_delete
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use ConnectVSphere
    b.use Call, IsCreated do |env, b2|
      if env[:result]
        b2.use SnapshotDelete
      else
        b2.use MessageNotCreated
      end
    end
    b.use CloseVSphere
  end
end

.action_snapshot_listObject



244
245
246
247
248
249
250
251
252
253
254
255
256
257
# File 'lib/vSphere/action.rb', line 244

def self.action_snapshot_list
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use ConnectVSphere
    b.use Call, IsCreated do |env, b2|
      if env[:result]
        b2.use SnapshotList
      else
        b2.use MessageNotCreated
      end
    end
    b.use CloseVSphere
  end
end

.action_snapshot_restoreObject



259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
# File 'lib/vSphere/action.rb', line 259

def self.action_snapshot_restore
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use ConnectVSphere
    b.use Call, IsCreated do |env, b2|
      unless env[:result]
        b2.use MessageNotCreated
        next
      end

      b2.use SnapshotRestore
      b2.use Call, IsEnvSet, :snapshot_delete do |env2, b3|
        # Used by vagrant push/pop
        b3.use action_snapshot_delete if env2[:result]
      end

      b2.use action_up
    end
    b.use CloseVSphere
  end
end

.action_snapshot_saveObject



281
282
283
284
285
286
287
288
289
290
291
292
293
294
# File 'lib/vSphere/action.rb', line 281

def self.action_snapshot_save
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use ConnectVSphere
    b.use Call, IsCreated do |env, b2|
      if env[:result]
        b2.use SnapshotSave
      else
        b2.use MessageNotCreated
      end
    end
    b.use CloseVSphere
  end
end

.action_sshObject



54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/vSphere/action.rb', line 54

def self.action_ssh
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, IsCreated do |env, b2|
      unless env[:result]
        b2.use MessageNotCreated
        next
      end

      b2.use Call, IsRunning do |env2, b3|
        unless env2[:result]
          b3.use MessageNotRunning
          next
        end

        b3.use SSHExec
      end
    end
  end
end

.action_ssh_runObject



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
# File 'lib/vSphere/action.rb', line 75

def self.action_ssh_run
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use Call, IsCreated do |env, b2|
      unless env[:result]
        b2.use MessageNotCreated
        next
      end

      b2.use Call, IsRunning do |env2, b3|
        unless env2[:result]
          b3.use MessageNotRunning
          next
        end

        b3.use SSHRun
      end
    end
  end
end

.action_suspendObject



183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
# File 'lib/vSphere/action.rb', line 183

def self.action_suspend
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use ConnectVSphere
    b.use Call, IsCreated do |env, b2|
      unless env[:result]
        b2.use MessageNotCreated
        next
      end

      b2.use Call, IsRunning do |env2, b3|
        unless env2[:result]
          b3.use MessageNotRunning
          next
        end

        b3.use Suspend
      end
    end
    b.use CloseVSphere
  end
end

.action_upObject



96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
# File 'lib/vSphere/action.rb', line 96

def self.action_up
  Vagrant::Action::Builder.new.tap do |b|
    b.use HandleBox
    b.use ConfigValidate
    b.use ConnectVSphere
    b.use Call, IsCreated do |env, b2|
      if env[:result]
        b2.use MessageAlreadyCreated
        next
      end

      b2.use Clone
    end
    b.use Call, IsRunning do |env, b2|
      b2.use PowerOn unless env[:result]
    end
    b.use CloseVSphere
    b.use WaitForIPAddress
    b.use WaitForCommunicator, [:running]
    b.use Provision
    b.use SyncedFolders
    b.use SetHostname
  end
end