Module: VagrantPlugins::Skytap::Action

Includes:
Vagrant::Action::Builtin
Defined in:
lib/vagrant-skytap/action.rb,
lib/vagrant-skytap/action/run_vm.rb,
lib/vagrant-skytap/action/stop_vm.rb,
lib/vagrant-skytap/action/delete_vm.rb,
lib/vagrant-skytap/action/set_up_vm.rb,
lib/vagrant-skytap/action/is_running.rb,
lib/vagrant-skytap/action/is_stopped.rb,
lib/vagrant-skytap/action/read_state.rb,
lib/vagrant-skytap/action/suspend_vm.rb,
lib/vagrant-skytap/action/is_suspended.rb,
lib/vagrant-skytap/action/set_hostname.rb,
lib/vagrant-skytap/action/read_ssh_info.rb,
lib/vagrant-skytap/action/existence_check.rb,
lib/vagrant-skytap/action/run_environment.rb,
lib/vagrant-skytap/action/timed_provision.rb,
lib/vagrant-skytap/action/update_hardware.rb,
lib/vagrant-skytap/action/stop_environment.rb,
lib/vagrant-skytap/action/store_extra_data.rb,
lib/vagrant-skytap/action/fetch_environment.rb,
lib/vagrant-skytap/action/create_environment.rb,
lib/vagrant-skytap/action/delete_environment.rb,
lib/vagrant-skytap/action/message_not_created.rb,
lib/vagrant-skytap/action/mixin_machine_index.rb,
lib/vagrant-skytap/action/suspend_environment.rb,
lib/vagrant-skytap/action/prepare_nfs_settings.rb,
lib/vagrant-skytap/action/add_vm_to_environment.rb,
lib/vagrant-skytap/action/initialize_api_client.rb,
lib/vagrant-skytap/action/prepare_nfs_valid_ids.rb,
lib/vagrant-skytap/action/message_already_created.rb,
lib/vagrant-skytap/action/message_already_running.rb,
lib/vagrant-skytap/action/message_environment_url.rb,
lib/vagrant-skytap/action/message_will_not_destroy.rb

Defined Under Namespace

Modules: MixinMachineIndex Classes: AddVmToEnvironment, CreateEnvironment, DeleteEnvironment, DeleteVm, ExistenceCheck, FetchEnvironment, InitializeAPIClient, IsRunning, IsStopped, IsSuspended, MessageAlreadyCreated, MessageAlreadyRunning, MessageEnvironmentUrl, MessageNotCreated, MessageWillNotDestroy, PrepareNFSSettings, PrepareNFSValidIds, ReadSSHInfo, ReadState, RunEnvironment, RunVm, SetHostname, SetUpVm, StopEnvironment, StopVm, StoreExtraData, SuspendEnvironment, SuspendVm, TimedProvision, UpdateHardware

Class Method Summary collapse

Class Method Details

.action_destroyObject

This action is called to terminate the remote machine.



44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
# File 'lib/vagrant-skytap/action.rb', line 44

def self.action_destroy
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use InitializeAPIClient
    b.use FetchEnvironment
    b.use Call, ExistenceCheck do |env, b1|
      case existence_state = env[:result]
      when :missing_environment, :no_vms
        b1.use MessageNotCreated
        b1.use DeleteEnvironment
        next
      when :missing_vm
        b1.use MessageNotCreated
        b1.use DeleteVm
        next
      end
      b1.use Call, DestroyConfirm do |env2, b2|
        if env2[:result]
          case existence_state
          when :one_of_many_vms
            b2.use DeleteVm
          else
            b2.use DeleteEnvironment
          end
          b2.use ProvisionerCleanup if defined?(ProvisionerCleanup)
        else
          b2.use MessageWillNotDestroy
        end
      end
    end
    b.use PrepareNFSValidIds
    b.use SyncedFolderCleanup
  end
end

.action_haltObject

This action is called to halt the remote machine.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/vagrant-skytap/action.rb', line 10

def self.action_halt
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use InitializeAPIClient
    b.use FetchEnvironment
    b.use Call, ExistenceCheck do |env1, b1|
      case result = env1[:result]
      when :missing_environment, :missing_vm, :no_vms
        b1.use MessageNotCreated
      else
        b1.use StopVm
      end
    end
  end
end

.action_prepare_bootObject



171
172
173
174
175
176
177
178
179
# File 'lib/vagrant-skytap/action.rb', line 171

def self.action_prepare_boot
  Vagrant::Action::Builder.new.tap do |b|
    b.use PrepareNFSSettings
    b.use PrepareNFSValidIds
    b.use Provision
    b.use SyncedFolderCleanup
    b.use SyncedFolders
  end
end

.action_provisionObject

This action is called when ‘vagrant provision` is called.



80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
# File 'lib/vagrant-skytap/action.rb', line 80

def self.action_provision
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use InitializeAPIClient
    b.use FetchEnvironment
    b.use Call, ExistenceCheck do |env, b1|
      case result = env[:result]
      when :missing_environment, :missing_vm, :no_vms
        b1.use MessageNotCreated
        next
      end
      b1.use Call, IsStopped do |env2, b2|
        b2.use Call, IsRunning do |env3, b3|
          unless env3[:result]
            b3.use RunVm
            b3.use WaitForCommunicator
          end
        end

        was_stopped = env2[:result]
        if was_stopped
          b2.use PrepareNFSSettings
          b2.use PrepareNFSValidIds
        end
        b2.use Provision
        if was_stopped
          b2.use SyncedFolders
        end
      end
    end
  end
end

.action_read_ssh_infoObject

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.



116
117
118
119
120
121
122
123
# File 'lib/vagrant-skytap/action.rb', line 116

def self.action_read_ssh_info
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use InitializeAPIClient
    b.use FetchEnvironment
    b.use ReadSSHInfo
  end
end

.action_read_stateObject

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.



128
129
130
131
132
133
134
135
136
# File 'lib/vagrant-skytap/action.rb', line 128

def self.action_read_state
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use InitializeAPIClient
    b.use FetchEnvironment
    #TODO:NLA Can this whole action be removed?
    b.use ReadState
  end
end

.action_reloadObject



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

def self.action_reload
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use InitializeAPIClient
    b.use FetchEnvironment
    b.use Call, ExistenceCheck do |env, b2|
      case env[:result]
      when :missing_environment, :missing_vm, :no_vms
        b2.use MessageNotCreated
      else
        b2.use action_halt
        b2.use action_up
      end
    end
  end
end

.action_resumeObject



181
182
183
184
185
# File 'lib/vagrant-skytap/action.rb', line 181

def self.action_resume
  Vagrant::Action::Builder.new.tap do |b|
    b.use action_up
  end
end

.action_sshObject

This action is called to SSH into the machine.



139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/vagrant-skytap/action.rb', line 139

def self.action_ssh
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use InitializeAPIClient
    b.use FetchEnvironment
    b.use Call, ExistenceCheck do |env1, b1|
      case result = env1[:result]
      when :missing_environment, :missing_vm, :no_vms
        b1.use MessageNotCreated
      else
        b1.use SSHExec
      end
    end
  end
end

.action_ssh_runObject



155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
# File 'lib/vagrant-skytap/action.rb', line 155

def self.action_ssh_run
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use InitializeAPIClient
    b.use FetchEnvironment
    b.use Call, ExistenceCheck do |env1, b1|
      case result = env1[:result]
      when :missing_environment, :missing_vm, :no_vms
        b1.use MessageNotCreated
      else
        b1.use SSHRun
      end
    end
  end
end

.action_suspendObject

This action is called to suspend the remote machine.



27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# File 'lib/vagrant-skytap/action.rb', line 27

def self.action_suspend
  Vagrant::Action::Builder.new.tap do |b|
    b.use ConfigValidate
    b.use InitializeAPIClient
    b.use FetchEnvironment
    b.use Call, ExistenceCheck do |env1, b1|
      case result = env1[:result]
      when :missing_environment, :missing_vm, :no_vms
        b1.use MessageNotCreated
      else
        b1.use SuspendVm
      end
    end
  end
end

.action_upObject

This action is called to bring the box up from nothing.



188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
# File 'lib/vagrant-skytap/action.rb', line 188

def self.action_up
  Vagrant::Action::Builder.new.tap do |b|
    b.use HandleBox
    b.use ConfigValidate
    b.use InitializeAPIClient
    b.use FetchEnvironment
    b.use Call, ExistenceCheck do |env, b1|
      case result = env[:result]
      when :missing_environment
        b1.use CreateEnvironment
        b1.use MessageEnvironmentUrl
      when :no_vms, :missing_vm
        b1.use AddVmToEnvironment
      else
        next
      end
      b1.use StoreExtraData
      b1.use SetUpVm
    end
    b.use Call, IsRunning do |env, b1|
      if env[:result]
        b1.use MessageAlreadyRunning
        next
      end

      b1.use Call, IsStopped do |env2, b2|
        if env2[:result]
          b2.use UpdateHardware
          b2.use SetHostname
          b2.use action_prepare_boot
        end

        b2.use RunVm
        b2.use WaitForCommunicator
      end
    end
  end
end