djo-vagrant-vsphere 1.6.1

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.
Files changed (49) hide show
  1. checksums.yaml +7 -0
  2. data/.bumpversion.cfg +11 -0
  3. data/.gitignore +8 -0
  4. data/.rubocop.yml +13 -0
  5. data/.rubocop_todo.yml +80 -0
  6. data/.travis.yml +11 -0
  7. data/CHANGELOG.md +250 -0
  8. data/DEVELOPMENT.md +67 -0
  9. data/Gemfile +16 -0
  10. data/LICENSE.txt +24 -0
  11. data/README.md +310 -0
  12. data/Rakefile +20 -0
  13. data/example_box/metadata.json +3 -0
  14. data/lib/vSphere/action.rb +195 -0
  15. data/lib/vSphere/action/clone.rb +239 -0
  16. data/lib/vSphere/action/close_vsphere.rb +22 -0
  17. data/lib/vSphere/action/connect_vsphere.rb +29 -0
  18. data/lib/vSphere/action/destroy.rb +41 -0
  19. data/lib/vSphere/action/get_ssh_info.rb +37 -0
  20. data/lib/vSphere/action/get_state.rb +41 -0
  21. data/lib/vSphere/action/is_created.rb +16 -0
  22. data/lib/vSphere/action/is_running.rb +16 -0
  23. data/lib/vSphere/action/message_already_created.rb +18 -0
  24. data/lib/vSphere/action/message_not_created.rb +18 -0
  25. data/lib/vSphere/action/message_not_running.rb +18 -0
  26. data/lib/vSphere/action/power_off.rb +40 -0
  27. data/lib/vSphere/action/power_on.rb +28 -0
  28. data/lib/vSphere/cap/public_address.rb +15 -0
  29. data/lib/vSphere/config.rb +60 -0
  30. data/lib/vSphere/errors.rb +11 -0
  31. data/lib/vSphere/plugin.rb +44 -0
  32. data/lib/vSphere/provider.rb +39 -0
  33. data/lib/vSphere/util/vim_helpers.rb +91 -0
  34. data/lib/vSphere/util/vm_helpers.rb +39 -0
  35. data/lib/vSphere/version.rb +5 -0
  36. data/lib/vagrant-vsphere.rb +18 -0
  37. data/locales/en.yml +64 -0
  38. data/spec/action_spec.rb +162 -0
  39. data/spec/clone_spec.rb +102 -0
  40. data/spec/connect_vsphere_spec.rb +26 -0
  41. data/spec/destroy_spec.rb +31 -0
  42. data/spec/get_ssh_info_spec.rb +31 -0
  43. data/spec/get_state_spec.rb +55 -0
  44. data/spec/is_created_spec.rb +29 -0
  45. data/spec/power_off_spec.rb +35 -0
  46. data/spec/spec_helper.rb +147 -0
  47. data/vSphere.gemspec +30 -0
  48. data/vsphere_screenshot.png +0 -0
  49. metadata +212 -0
data/Gemfile ADDED
@@ -0,0 +1,16 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gemspec
4
+
5
+ group :development do
6
+ # We depend on Vagrant for development, but we don't add it as a
7
+ # gem dependency because we expect to be installed within the
8
+ # Vagrant environment itself using `vagrant plugin`.
9
+
10
+ ruby '2.0.0'
11
+ gem 'vagrant', git: 'git://github.com/mitchellh/vagrant.git', tag: 'v1.6.4'
12
+ end
13
+
14
+ group :plugins do
15
+ gem 'vagrant-vsphere', path: '.'
16
+ end
data/LICENSE.txt ADDED
@@ -0,0 +1,24 @@
1
+ Copyright (c) 2013-2015 Regents of the University of Colorado
2
+
3
+ This software was developed by the National Snow and Ice Data Center with funding from multiple sources.
4
+
5
+ MIT License
6
+
7
+ Permission is hereby granted, free of charge, to any person obtaining
8
+ a copy of this software and associated documentation files (the
9
+ "Software"), to deal in the Software without restriction, including
10
+ without limitation the rights to use, copy, modify, merge, publish,
11
+ distribute, sublicense, and/or sell copies of the Software, and to
12
+ permit persons to whom the Software is furnished to do so, subject to
13
+ the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be
16
+ included in all copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
19
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
22
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
23
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
24
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,310 @@
1
+ [![Build Status](https://travis-ci.org/nsidc/vagrant-vsphere.svg?branch=master)](https://travis-ci.org/nsidc/vagrant-vsphere) [![Gem Version](https://badge.fury.io/rb/vagrant-vsphere.svg)](http://badge.fury.io/rb/vagrant-vsphere)
2
+
3
+ # Vagrant vSphere Provider
4
+
5
+ This is a [Vagrant](http://www.vagrantup.com) 1.6.4+ plugin that adds a
6
+ [vSphere](http://pubs.vmware.com/vsphere-50/index.jsp?topic=%2Fcom.vmware.wssdk.apiref.doc_50%2Fright-pane.html)
7
+ provider to Vagrant, allowing Vagrant to control and provision machines using
8
+ VMware. New machines are created from virtual machines or templates which must
9
+ be configured prior to using this provider.
10
+
11
+ This provider is built on top of the
12
+ [RbVmomi](https://github.com/vmware/rbvmomi) Ruby interface to the vSphere API.
13
+
14
+ ## Requirements
15
+
16
+ * Vagrant 1.6.4+
17
+ * VMware with vSphere API
18
+ * Ruby 1.9+
19
+ * libxml2, libxml2-dev, libxslt, libxslt-dev
20
+
21
+ ## Current Version
22
+ **version: 1.6.0**
23
+
24
+ vagrant-vsphere (**version: 1.6.0**) is available from
25
+ [RubyGems.org](https://rubygems.org/gems/vagrant-vsphere)
26
+
27
+ ## Installation
28
+
29
+ Install using standard Vagrant plugin method:
30
+
31
+ ```bash
32
+ vagrant plugin install vagrant-vsphere
33
+ ```
34
+
35
+ This will install the plugin from RubyGems.org.
36
+
37
+ Alternatively, you can clone this repository and build the source with `gem
38
+ build vSphere.gemspec`. After the gem is built, run the plugin install command
39
+ from the build directory.
40
+
41
+ ### Potential Installation Problems
42
+
43
+ The requirements for [Nokogiri](http://nokogiri.org/) must be installed before
44
+ the plugin can be installed. See the
45
+ [Nokogiri tutorial](http://nokogiri.org/tutorials/installing_nokogiri.html) for
46
+ detailed instructions.
47
+
48
+ The plugin forces use of Nokogiri ~> 1.5 to prevent conflicts with older
49
+ versions of system libraries, specifically zlib.
50
+
51
+ ## Usage
52
+
53
+ After installing the plugin, you must create a vSphere box. The example_box
54
+ directory contains a metadata.json file that can be used to create a dummy box
55
+ with the command:
56
+
57
+ ```bash
58
+ tar cvzf dummy.box ./metadata.json
59
+ ```
60
+
61
+ This can be installed using the standard Vagrant methods or specified in the
62
+ Vagrantfile.
63
+
64
+ After creating the dummy box, make a Vagrantfile that looks like the following:
65
+
66
+ ```ruby
67
+ Vagrant.configure("2") do |config|
68
+ config.vm.box = 'dummy'
69
+ config.vm.box_url = './example_box/dummy.box'
70
+
71
+ config.vm.provider :vsphere do |vsphere|
72
+ vsphere.host = 'HOST NAME OF YOUR VSPHERE INSTANCE'
73
+ vsphere.compute_resource_name = 'YOUR COMPUTE RESOURCE'
74
+ vsphere.resource_pool_name = 'YOUR RESOURCE POOL'
75
+ vsphere.template_name = '/PATH/TO/YOUR VM TEMPLATE'
76
+ vsphere.name = 'NEW VM NAME'
77
+ vsphere.user = 'YOUR VMWARE USER'
78
+ vsphere.password = 'YOUR VMWARE PASSWORD'
79
+ end
80
+ end
81
+ ```
82
+
83
+ And then run `vagrant up --provider=vsphere`.
84
+
85
+ ### Custom Box
86
+
87
+ The bulk of this configuration can be included as part of a custom box. See the
88
+ [Vagrant documentation](http://docs.vagrantup.com/v2/boxes.html) and the Vagrant
89
+ [AWS provider](https://github.com/mitchellh/vagrant-aws/tree/master/example_box)
90
+ for more information and an example.
91
+
92
+ ### Supported Commands
93
+
94
+ Currently the only implemented actions are `up`, `halt`, `reload`, `destroy`,
95
+ and `ssh`.
96
+
97
+ `up` supports provisioning of the new VM with the standard Vagrant provisioners.
98
+
99
+ ## Configuration
100
+
101
+ This provider has the following settings, all are required unless noted:
102
+
103
+ * `host` - IP or name for the vSphere API
104
+ * `insecure` - _Optional_ verify SSL certificate from the host
105
+ * `user` - user name for connecting to vSphere
106
+ * `password` - password for connecting to vSphere. If no value is given, or the
107
+ value is set to `:ask`, the user will be prompted to enter the password on
108
+ each invocation.
109
+ * `data_center_name` - _Optional_ datacenter containing the computed resource,
110
+ the template and where the new VM will be created, if not specified the first
111
+ datacenter found will be used
112
+ * `compute_resource_name` - _Required if cloning from template_ the name of the
113
+ host containing the resource pool for the new VM
114
+ * `resource_pool_name` - the resource pool for the new VM. If not supplied, and
115
+ cloning from a template, uses the root resource pool
116
+ * `clone_from_vm` - _Optional_ use a virtual machine instead of a template as
117
+ the source for the cloning operation
118
+ * `template_name` - the VM or VM template to clone (including the full folder path)
119
+ * `vm_base_path` - _Optional_ path to folder where new VM should be created, if
120
+ not specified template's parent folder will be used
121
+ * `name` - _Optional_ name of the new VM, if missing the name will be auto
122
+ generated
123
+ * `customization_spec_name` - _Optional_ customization spec for the new VM
124
+ * `data_store_name` - _Optional_ the datastore where the VM will be located
125
+ * `linked_clone` - _Optional_ link the cloned VM to the parent to share virtual
126
+ disks
127
+ * `proxy_host` - _Optional_ proxy host name for connecting to vSphere via proxy
128
+ * `proxy_port` - _Optional_ proxy port number for connecting to vSphere via
129
+ proxy
130
+ * `vlan` - _Optional_ vlan to connect the first NIC to
131
+ * `memory_mb` - _Optional_ Configure the amount of memory (in MB) for the new VM
132
+ * `cpu_count` - _Optional_ Configure the number of CPUs for the new VM
133
+ * `mac` - _Optional_ Used to set the mac address of the new VM
134
+ * `cpu_reservation` - _Optional_ Configure the CPU time (in MHz) to reserve for this VM
135
+ * `mem_reservation` - _Optional_ Configure the memory (in MB) to reserve for this VM
136
+ * `addressType` - _Optional_ Configure the address type of the
137
+ [vSphere Virtual Ethernet Card](https://www.vmware.com/support/developer/vc-sdk/visdk2xpubs/ReferenceGuide/vim.vm.device.VirtualEthernetCard.html)
138
+ * `custom_attribute` - _Optional_ Add a
139
+ [custom attribute](https://www.google.com/url?sa=t&rct=j&q=&esrc=s&source=web&cd=1&cad=rja&uact=8&ved=0CB4QFjAAahUKEwiWwbWX59jHAhVBC5IKHa3HAEU&url=http%3A%2F%2Fpubs.vmware.com%2Fvsphere-51%2Ftopic%2Fcom.vmware.vsphere.vcenterhost.doc%2FGUID-25244732-D473-4857-A471-579257B6D95F.html&usg=AFQjCNGTSl4cauFrflUJpBeTBb0Yv7R13g&sig2=a9he6W2qVvBSZ5lCiXnENA)
140
+ to the VM upon creation. This method takes a key/value pair,
141
+ e.g. `vsphere.custom_attribute('timestamp', Time.now.to_s)`, and may be called
142
+ multiple times to set different attributes.
143
+
144
+ ### Cloning from a VM rather than a template
145
+
146
+ To clone from an existing VM rather than a template, set `clone_from_vm` to
147
+ true. If this value is set, `compute_resource_name` and `resource_pool_name` are
148
+ not required.
149
+
150
+ ### Template_Name
151
+
152
+ * The template name includes the actual template name and the directory path
153
+ containing the template.
154
+ * **For example:** if the template is a directory called **vagrant-templates**
155
+ and the template is called **ubuntu-lucid-template** the `template_name`
156
+ setting would be:
157
+
158
+ ```
159
+ vsphere.template_name = "vagrant-templates/ubuntu-lucid-template"
160
+ ```
161
+
162
+ ![Vagrant Vsphere Screenshot](https://raw.githubusercontent.com/nsidc/vagrant-vsphere/master/vsphere_screenshot.png)
163
+
164
+ ### VM_Base_Path
165
+
166
+ * The new vagrant VM will be created in the same directory as the template it
167
+ originated from.
168
+ * To create the VM in a directory other than the one where the template was
169
+ located, include the **vm_base_path** setting.
170
+ * **For example:** if the machines will be stored in a directory called
171
+ **vagrant-machines** the `vm_base_path` would be:
172
+
173
+ ```
174
+ vsphere.vm_base_path = "vagrant-machines"
175
+ ```
176
+
177
+ ![Vagrant Vsphere Screenshot](https://raw.githubusercontent.com/nsidc/vagrant-vsphere/master/vsphere_screenshot.png)
178
+
179
+ ### Setting a static IP address
180
+
181
+ To set a static IP, add a private network to your vagrant file:
182
+
183
+ ```ruby
184
+ config.vm.network 'private_network', ip: '192.168.50.4'
185
+ ```
186
+
187
+ The IP address will only be set if a customization spec name is given. The
188
+ customization spec must have network adapter settings configured with a static
189
+ IP address(just an unused address NOT the address you want the VM to be). The
190
+ config.vm.network line will overwrite the ip in the customization spec with the one you set.
191
+ For each private network specified, there needs to be a corresponding network adapter in
192
+ the customization spec. An error will be thrown if there are more networks than
193
+ adapters.
194
+
195
+ ### Auto name generation
196
+
197
+ The name for the new VM will be automagically generated from the Vagrant machine
198
+ name, the current timestamp and a random number to allow for simultaneous
199
+ executions.
200
+
201
+ This is useful if running Vagrant from multiple directories or if multiple
202
+ machines are defined in the Vagrantfile.
203
+
204
+ ### Setting addressType for network adapter
205
+
206
+ This sets the addressType of the network adapter, for example 'Manual' to
207
+ be able to set a manual mac address.
208
+ This value may depend on the version of vSphere you use. It may be necessary
209
+ to set this in combination with the mac field, in order to set a manual
210
+ mac address. For valid values for this field see VirtualEthernetCard api
211
+ documentation of vSphere.
212
+
213
+ ```ruby
214
+ vsphere.addressType = 'Manual'
215
+ ```
216
+
217
+ ### Setting the MAC address
218
+
219
+ To set a static MAC address, add a `vsphere.mac` to your `Vagrantfile`.
220
+ In some cases you must also set `vsphere.addressType` (see above)
221
+ to make this work:
222
+
223
+ ```ruby
224
+ vsphere.mac = '00:50:56:XX:YY:ZZ'
225
+ ```
226
+
227
+ Take care to avoid using invalid or duplicate VMware MAC addresses, as this can
228
+ easily break networking.
229
+
230
+ ## Troubleshooting
231
+
232
+ ### vCenter
233
+ ESXi is not supported. Make sure to connect to a vCenter server and not directly to an ESXi host. [ESXi vs vCenter](http://www.mustbegeek.com/difference-between-vsphere-esxi-and-vcenter/)
234
+
235
+ ### Permissions
236
+ If you have permission issues:
237
+
238
+ 1. give the connecting user read only access to everything, and full permission to a specific data center. Narrow the permissions down after a VM is created.
239
+ 2. Be sure the path to the VM is correct. see the "Template_Name" screenshots above for more information.
240
+
241
+ ## Example Usage
242
+
243
+ ### FILE: Vagrantfile
244
+
245
+ ```ruby
246
+ VAGRANT_INSTANCE_NAME = "vagrant-vsphere"
247
+
248
+ Vagrant.configure("2") do |config|
249
+ config.vm.box = 'vsphere'
250
+ config.vm.box_url = 'https://vagrantcloud.com/ssx/boxes/vsphere-dummy/versions/0.0.1/providers/vsphere.box'
251
+
252
+ config.vm.hostname = VAGRANT_INSTANCE_NAME
253
+ config.vm.define VAGRANT_INSTANCE_NAME do |d|
254
+ end
255
+
256
+ config.vm.provider :vsphere do |vsphere|
257
+ vsphere.host = 'vsphere.local'
258
+ vsphere.name = VAGRANT_INSTANCE_NAME
259
+ vsphere.compute_resource_name = 'vagrant01.vsphere.local'
260
+ vsphere.resource_pool_name = 'vagrant'
261
+ vsphere.template_name = 'vagrant-templates/ubuntu14041'
262
+ vsphere.vm_base_path = "vagrant-machines"
263
+
264
+ vsphere.user = 'vagrant-user@vsphere'
265
+ vsphere.password = '***************'
266
+ vsphere.insecure = true
267
+
268
+ vsphere.custom_attribute('timestamp', Time.now.to_s)
269
+ end
270
+ end
271
+ ```
272
+
273
+ ### Vagrant Up
274
+
275
+ ```bash
276
+ vagrant up --provider=vsphere
277
+ ```
278
+ ### Vagrant SSH
279
+
280
+ ```bash
281
+ vagrant ssh
282
+ ```
283
+
284
+ ### Vagrant Destroy
285
+
286
+ ```bash
287
+ vagrant destroy
288
+ ```
289
+
290
+ ## Version History
291
+
292
+ See
293
+ [`CHANGELOG.md`](https://github.com/nsidc/vagrant-vsphere/blob/master/CHANGELOG.md).
294
+
295
+ ## Contributing
296
+
297
+ See
298
+ [`DEVELOPMENT.md`](https://github.com/nsidc/vagrant-vsphere/blob/master/DEVELOPMENT.md).
299
+
300
+ ## License
301
+
302
+ The Vagrant vSphere Provider is licensed under the MIT license. See
303
+ [LICENSE.txt][license].
304
+
305
+ [license]: https://raw.github.com/nsidc/vagrant-vsphere/master/LICENSE.txt
306
+
307
+ ## Credit
308
+
309
+ This software was developed by the National Snow and Ice Data Center with
310
+ funding from multiple sources.
data/Rakefile ADDED
@@ -0,0 +1,20 @@
1
+ require 'rubygems'
2
+ require 'bundler/setup'
3
+ require 'rspec/core/rake_task'
4
+ require 'rubocop/rake_task'
5
+
6
+ # Immediately sync all stdout so that tools like buildbot can
7
+ # immediately load in the output.
8
+ $stdout.sync = true
9
+ $stderr.sync = true
10
+
11
+ # Change to the directory of this file.
12
+ Dir.chdir(File.expand_path('../', __FILE__))
13
+
14
+ Bundler::GemHelper.install_tasks
15
+
16
+ RSpec::Core::RakeTask.new
17
+
18
+ RuboCop::RakeTask.new
19
+
20
+ task default: %w(rubocop spec)
@@ -0,0 +1,3 @@
1
+ {
2
+ "provider": "vsphere"
3
+ }
@@ -0,0 +1,195 @@
1
+ require 'vagrant'
2
+ require 'vagrant/action/builder'
3
+
4
+ module VagrantPlugins
5
+ module VSphere
6
+ module Action
7
+ include Vagrant::Action::Builtin
8
+
9
+ # Vagrant commands
10
+ def self.action_destroy
11
+ Vagrant::Action::Builder.new.tap do |b|
12
+ b.use ConfigValidate
13
+ b.use ConnectVSphere
14
+
15
+ b.use Call, IsRunning do |env, b2|
16
+ if env[:result]
17
+ if env[:force_confirm_destroy]
18
+ b2.use PowerOff
19
+ next
20
+ end
21
+
22
+ b2.use Call, GracefulHalt, :poweroff, :running do |env2, b3|
23
+ b3.use PowerOff unless env2[:result]
24
+ end
25
+ end
26
+ end
27
+ b.use Destroy
28
+ end
29
+ end
30
+
31
+ def self.action_provision
32
+ Vagrant::Action::Builder.new.tap do |b|
33
+ b.use ConfigValidate
34
+ b.use Call, IsCreated do |env, b2|
35
+ unless env[:result]
36
+ b2.use MessageNotCreated
37
+ next
38
+ end
39
+
40
+ b2.use Call, IsRunning do |env2, b3|
41
+ unless env2[:result]
42
+ b3.use MessageNotRunning
43
+ next
44
+ end
45
+
46
+ b3.use Provision
47
+ b3.use SyncedFolders
48
+ end
49
+ end
50
+ end
51
+ end
52
+
53
+ def self.action_ssh
54
+ Vagrant::Action::Builder.new.tap do |b|
55
+ b.use ConfigValidate
56
+ b.use Call, IsCreated do |env, b2|
57
+ unless env[:result]
58
+ b2.use MessageNotCreated
59
+ next
60
+ end
61
+
62
+ b2.use Call, IsRunning do |env2, b3|
63
+ unless env2[:result]
64
+ b3.use MessageNotRunning
65
+ next
66
+ end
67
+
68
+ b3.use SSHExec
69
+ end
70
+ end
71
+ end
72
+ end
73
+
74
+ def self.action_ssh_run
75
+ Vagrant::Action::Builder.new.tap do |b|
76
+ b.use ConfigValidate
77
+ b.use Call, IsCreated do |env, b2|
78
+ unless env[:result]
79
+ b2.use MessageNotCreated
80
+ next
81
+ end
82
+
83
+ b2.use Call, IsRunning do |env2, b3|
84
+ unless env2[:result]
85
+ b3.use MessageNotRunning
86
+ next
87
+ end
88
+
89
+ b3.use SSHRun
90
+ end
91
+ end
92
+ end
93
+ end
94
+
95
+ def self.action_up
96
+ Vagrant::Action::Builder.new.tap do |b|
97
+ b.use HandleBox
98
+ b.use ConfigValidate
99
+ b.use ConnectVSphere
100
+ b.use Call, IsCreated do |env, b2|
101
+ if env[:result]
102
+ b2.use MessageAlreadyCreated
103
+ next
104
+ end
105
+
106
+ b2.use Clone
107
+ end
108
+ b.use Call, IsRunning do |env, b2|
109
+ b2.use PowerOn unless env[:result]
110
+ end
111
+ b.use CloseVSphere
112
+ b.use WaitForCommunicator
113
+ b.use Provision
114
+ b.use SyncedFolders
115
+ b.use SetHostname
116
+ end
117
+ end
118
+
119
+ def self.action_halt
120
+ Vagrant::Action::Builder.new.tap do |b|
121
+ b.use ConfigValidate
122
+ b.use ConnectVSphere
123
+ b.use Call, IsCreated do |env, b2|
124
+ unless env[:result]
125
+ b2.use MessageNotCreated
126
+ next
127
+ end
128
+
129
+ b2.use Call, IsRunning do |env2, b3|
130
+ unless env2[:result]
131
+ b3.use MessageNotRunning
132
+ next
133
+ end
134
+
135
+ b3.use Call, GracefulHalt, :poweroff, :running do |env3, b4|
136
+ b4.use PowerOff unless env3[:result]
137
+ end
138
+ end
139
+ end
140
+ b.use CloseVSphere
141
+ end
142
+ end
143
+
144
+ def self.action_reload
145
+ Vagrant::Action::Builder.new.tap do |b|
146
+ b.use ConnectVSphere
147
+ b.use Call, IsCreated do |env, b2|
148
+ unless env[:result]
149
+ b2.use MessageNotCreated
150
+ next
151
+ end
152
+ b2.use action_halt
153
+ b2.use action_up
154
+ end
155
+ end
156
+ end
157
+
158
+ # vSphere specific actions
159
+ def self.action_get_state
160
+ Vagrant::Action::Builder.new.tap do |b|
161
+ b.use HandleBox
162
+ b.use ConfigValidate
163
+ b.use ConnectVSphere
164
+ b.use GetState
165
+ b.use CloseVSphere
166
+ end
167
+ end
168
+
169
+ def self.action_get_ssh_info
170
+ Vagrant::Action::Builder.new.tap do |b|
171
+ b.use ConfigValidate
172
+ b.use ConnectVSphere
173
+ b.use GetSshInfo
174
+ b.use CloseVSphere
175
+ end
176
+ end
177
+
178
+ # autoload
179
+ action_root = Pathname.new(File.expand_path('../action', __FILE__))
180
+ autoload :Clone, action_root.join('clone')
181
+ autoload :CloseVSphere, action_root.join('close_vsphere')
182
+ autoload :ConnectVSphere, action_root.join('connect_vsphere')
183
+ autoload :Destroy, action_root.join('destroy')
184
+ autoload :GetSshInfo, action_root.join('get_ssh_info')
185
+ autoload :GetState, action_root.join('get_state')
186
+ autoload :IsCreated, action_root.join('is_created')
187
+ autoload :IsRunning, action_root.join('is_running')
188
+ autoload :MessageAlreadyCreated, action_root.join('message_already_created')
189
+ autoload :MessageNotCreated, action_root.join('message_not_created')
190
+ autoload :MessageNotRunning, action_root.join('message_not_running')
191
+ autoload :PowerOff, action_root.join('power_off')
192
+ autoload :PowerOn, action_root.join('power_on')
193
+ end
194
+ end
195
+ end