vagrant-vsphere 0.7.0 → 0.7.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 (40) hide show
  1. data/.gitignore +8 -6
  2. data/Gemfile +10 -10
  3. data/LICENSE.txt +23 -23
  4. data/README.md +180 -175
  5. data/Rakefile +16 -16
  6. data/example_box/metadata.json +2 -2
  7. data/lib/vSphere/action.rb +172 -172
  8. data/lib/vSphere/action/clone.rb +131 -127
  9. data/lib/vSphere/action/close_vsphere.rb +23 -23
  10. data/lib/vSphere/action/connect_vsphere.rb +25 -25
  11. data/lib/vSphere/action/destroy.rb +37 -37
  12. data/lib/vSphere/action/get_ssh_info.rb +37 -37
  13. data/lib/vSphere/action/get_state.rb +45 -45
  14. data/lib/vSphere/action/is_created.rb +15 -15
  15. data/lib/vSphere/action/is_running.rb +20 -20
  16. data/lib/vSphere/action/message_already_created.rb +17 -17
  17. data/lib/vSphere/action/message_not_created.rb +17 -17
  18. data/lib/vSphere/action/message_not_running.rb +18 -18
  19. data/lib/vSphere/action/power_off.rb +27 -27
  20. data/lib/vSphere/action/power_on.rb +31 -31
  21. data/lib/vSphere/action/sync_folders.rb +94 -97
  22. data/lib/vSphere/config.rb +37 -37
  23. data/lib/vSphere/errors.rb +14 -11
  24. data/lib/vSphere/plugin.rb +29 -29
  25. data/lib/vSphere/provider.rb +38 -38
  26. data/lib/vSphere/util/machine_helpers.rb +15 -15
  27. data/lib/vSphere/util/vim_helpers.rb +37 -37
  28. data/lib/vSphere/version.rb +5 -5
  29. data/lib/vagrant-vsphere.rb +17 -17
  30. data/locales/en.yml +66 -65
  31. data/spec/action_spec.rb +116 -116
  32. data/spec/clone_spec.rb +31 -31
  33. data/spec/connect_vsphere_spec.rb +23 -23
  34. data/spec/destroy_spec.rb +30 -30
  35. data/spec/get_ssh_info_spec.rb +30 -30
  36. data/spec/get_state_spec.rb +54 -54
  37. data/spec/is_created_spec.rb +28 -28
  38. data/spec/spec_helper.rb +98 -98
  39. data/vSphere.gemspec +29 -28
  40. metadata +14 -8
@@ -1,24 +1,24 @@
1
- require 'rbvmomi'
2
-
3
- module VagrantPlugins
4
- module VSphere
5
- module Action
6
- class CloseVSphere
7
- def initialize(app, env)
8
- @app = app
9
- end
10
-
11
- def call(env)
12
- begin
13
- env[:vSphere_connection].close
14
- @app.call env
15
- rescue Exception => e
16
- puts e
17
- #raise a properly namespaced error for Vagrant
18
- raise Errors::VSphereError, :message => e.message
19
- end
20
- end
21
- end
22
- end
23
- end
1
+ require 'rbvmomi'
2
+
3
+ module VagrantPlugins
4
+ module VSphere
5
+ module Action
6
+ class CloseVSphere
7
+ def initialize(app, env)
8
+ @app = app
9
+ end
10
+
11
+ def call(env)
12
+ begin
13
+ env[:vSphere_connection].close
14
+ @app.call env
15
+ rescue Exception => e
16
+ puts e
17
+ #raise a properly namespaced error for Vagrant
18
+ raise Errors::VSphereError, :message => e.message
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
24
  end
@@ -1,25 +1,25 @@
1
- require 'rbvmomi'
2
-
3
- module VagrantPlugins
4
- module VSphere
5
- module Action
6
- class ConnectVSphere
7
- def initialize(app, env)
8
- @app = app
9
- end
10
-
11
- def call(env)
12
- config = env[:machine].provider_config
13
-
14
- begin
15
- env[:vSphere_connection] = RbVmomi::VIM.connect host: config.host, user: config.user, password: config.password, insecure: config.insecure
16
- @app.call env
17
- rescue Exception => e
18
- puts e.backtrace
19
- raise VagrantPlugins::VSphere::Errors::VSphereError, :message => e.message
20
- end
21
- end
22
- end
23
- end
24
- end
25
- end
1
+ require 'rbvmomi'
2
+
3
+ module VagrantPlugins
4
+ module VSphere
5
+ module Action
6
+ class ConnectVSphere
7
+ def initialize(app, env)
8
+ @app = app
9
+ end
10
+
11
+ def call(env)
12
+ config = env[:machine].provider_config
13
+
14
+ begin
15
+ env[:vSphere_connection] = RbVmomi::VIM.connect host: config.host, user: config.user, password: config.password, insecure: config.insecure
16
+ @app.call env
17
+ rescue Exception => e
18
+ puts e.backtrace
19
+ raise VagrantPlugins::VSphere::Errors::VSphereError, :message => e.message
20
+ end
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
@@ -1,38 +1,38 @@
1
- require 'rbvmomi'
2
- require 'i18n'
3
- require 'vSphere/util/vim_helpers'
4
-
5
- module VagrantPlugins
6
- module VSphere
7
- module Action
8
- class Destroy
9
- include Util::VimHelpers
10
-
11
- def initialize(app, env)
12
- @app = app
13
- end
14
-
15
- def call(env)
16
- destroy_vm env
17
- env[:machine].id = nil
18
-
19
- @app.call env
20
- end
21
-
22
- private
23
-
24
- def destroy_vm(env)
25
- vm = get_vm_by_uuid env[:vSphere_connection], env[:machine]
26
- return if vm.nil?
27
-
28
- begin
29
- env[:ui].info I18n.t('vsphere.destroy_vm')
30
- vm.Destroy_Task.wait_for_completion
31
- rescue Exception => e
32
- raise Errors::VSphereError, :message => e.message
33
- end
34
- end
35
- end
36
- end
37
- end
1
+ require 'rbvmomi'
2
+ require 'i18n'
3
+ require 'vSphere/util/vim_helpers'
4
+
5
+ module VagrantPlugins
6
+ module VSphere
7
+ module Action
8
+ class Destroy
9
+ include Util::VimHelpers
10
+
11
+ def initialize(app, env)
12
+ @app = app
13
+ end
14
+
15
+ def call(env)
16
+ destroy_vm env
17
+ env[:machine].id = nil
18
+
19
+ @app.call env
20
+ end
21
+
22
+ private
23
+
24
+ def destroy_vm(env)
25
+ vm = get_vm_by_uuid env[:vSphere_connection], env[:machine]
26
+ return if vm.nil?
27
+
28
+ begin
29
+ env[:ui].info I18n.t('vsphere.destroy_vm')
30
+ vm.Destroy_Task.wait_for_completion
31
+ rescue Exception => e
32
+ raise Errors::VSphereError, :message => e.message
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
38
38
  end
@@ -1,38 +1,38 @@
1
- require 'rbvmomi'
2
- require 'vSphere/util/vim_helpers'
3
-
4
- module VagrantPlugins
5
- module VSphere
6
- module Action
7
- class GetSshInfo
8
- include Util::VimHelpers
9
-
10
-
11
- def initialize(app, env)
12
- @app = app
13
- end
14
-
15
- def call(env)
16
- env[:machine_ssh_info] = get_ssh_info(env[:vSphere_connection], env[:machine])
17
-
18
- @app.call env
19
- end
20
-
21
- private
22
-
23
- def get_ssh_info(connection, machine)
24
- return nil if machine.id.nil?
25
-
26
- vm = get_vm_by_uuid connection, machine
27
-
28
- return nil if vm.nil?
29
-
30
- return {
31
- :host => vm.guest.ipAddress,
32
- :port => 22
33
- }
34
- end
35
- end
36
- end
37
- end
1
+ require 'rbvmomi'
2
+ require 'vSphere/util/vim_helpers'
3
+
4
+ module VagrantPlugins
5
+ module VSphere
6
+ module Action
7
+ class GetSshInfo
8
+ include Util::VimHelpers
9
+
10
+
11
+ def initialize(app, env)
12
+ @app = app
13
+ end
14
+
15
+ def call(env)
16
+ env[:machine_ssh_info] = get_ssh_info(env[:vSphere_connection], env[:machine])
17
+
18
+ @app.call env
19
+ end
20
+
21
+ private
22
+
23
+ def get_ssh_info(connection, machine)
24
+ return nil if machine.id.nil?
25
+
26
+ vm = get_vm_by_uuid connection, machine
27
+
28
+ return nil if vm.nil?
29
+
30
+ return {
31
+ :host => vm.guest.ipAddress,
32
+ :port => 22
33
+ }
34
+ end
35
+ end
36
+ end
37
+ end
38
38
  end
@@ -1,46 +1,46 @@
1
- require 'rbvmomi'
2
- require 'vSphere/util/vim_helpers'
3
-
4
- module VagrantPlugins
5
- module VSphere
6
- module Action
7
- class GetState
8
- include Util::VimHelpers
9
-
10
- # the three possible values of a vSphere VM's power state
11
- POWERED_ON = 'poweredOn'
12
- POWERED_OFF = 'poweredOff'
13
- SUSPENDED = 'suspended'
14
-
15
- def initialize(app, env)
16
- @app = app
17
- end
18
-
19
- def call(env)
20
- env[:machine_state_id] = get_state(env[:vSphere_connection], env[:machine])
21
-
22
- @app.call env
23
- end
24
-
25
- private
26
-
27
- def get_state(connection, machine)
28
- return :not_created if machine.id.nil?
29
-
30
- vm = get_vm_by_uuid connection, machine
31
-
32
- if vm.nil?
33
- return :not_created
34
- end
35
-
36
- if vm.runtime.powerState.eql?(POWERED_ON)
37
- :running
38
- else
39
- # If the VM is powered off or suspended, we consider it to be powered off. A power on command will either turn on or resume the VM
40
- :poweroff
41
- end
42
- end
43
- end
44
- end
45
- end
1
+ require 'rbvmomi'
2
+ require 'vSphere/util/vim_helpers'
3
+
4
+ module VagrantPlugins
5
+ module VSphere
6
+ module Action
7
+ class GetState
8
+ include Util::VimHelpers
9
+
10
+ # the three possible values of a vSphere VM's power state
11
+ POWERED_ON = 'poweredOn'
12
+ POWERED_OFF = 'poweredOff'
13
+ SUSPENDED = 'suspended'
14
+
15
+ def initialize(app, env)
16
+ @app = app
17
+ end
18
+
19
+ def call(env)
20
+ env[:machine_state_id] = get_state(env[:vSphere_connection], env[:machine])
21
+
22
+ @app.call env
23
+ end
24
+
25
+ private
26
+
27
+ def get_state(connection, machine)
28
+ return :not_created if machine.id.nil?
29
+
30
+ vm = get_vm_by_uuid connection, machine
31
+
32
+ if vm.nil?
33
+ return :not_created
34
+ end
35
+
36
+ if vm.runtime.powerState.eql?(POWERED_ON)
37
+ :running
38
+ else
39
+ # If the VM is powered off or suspended, we consider it to be powered off. A power on command will either turn on or resume the VM
40
+ :poweroff
41
+ end
42
+ end
43
+ end
44
+ end
45
+ end
46
46
  end
@@ -1,16 +1,16 @@
1
- module VagrantPlugins
2
- module VSphere
3
- module Action
4
- class IsCreated
5
- def initialize(app, env)
6
- @app = app
7
- end
8
-
9
- def call(env)
10
- env[:result] = env[:machine].state.id != :not_created
11
- @app.call env
12
- end
13
- end
14
- end
15
- end
1
+ module VagrantPlugins
2
+ module VSphere
3
+ module Action
4
+ class IsCreated
5
+ def initialize(app, env)
6
+ @app = app
7
+ end
8
+
9
+ def call(env)
10
+ env[:result] = env[:machine].state.id != :not_created
11
+ @app.call env
12
+ end
13
+ end
14
+ end
15
+ end
16
16
  end
@@ -1,20 +1,20 @@
1
- require 'vSphere/util/machine_helpers'
2
-
3
- module VagrantPlugins
4
- module VSphere
5
- module Action
6
- class IsRunning
7
- include Util::MachineHelpers
8
-
9
- def initialize(app, env)
10
- @app = app
11
- end
12
-
13
- def call(env)
14
- env[:result] = env[:machine].state.id == :running
15
- @app.call env
16
- end
17
- end
18
- end
19
- end
20
- end
1
+ require 'vSphere/util/machine_helpers'
2
+
3
+ module VagrantPlugins
4
+ module VSphere
5
+ module Action
6
+ class IsRunning
7
+ include Util::MachineHelpers
8
+
9
+ def initialize(app, env)
10
+ @app = app
11
+ end
12
+
13
+ def call(env)
14
+ env[:result] = env[:machine].state.id == :running
15
+ @app.call env
16
+ end
17
+ end
18
+ end
19
+ end
20
+ end
@@ -1,18 +1,18 @@
1
- require 'i18n'
2
-
3
- module VagrantPlugins
4
- module VSphere
5
- module Action
6
- class MessageAlreadyCreated
7
- def initialize(app, env)
8
- @app = app
9
- end
10
-
11
- def call(env)
12
- env[:ui].info I18n.t('vsphere.vm_already_created')
13
- @app.call(env)
14
- end
15
- end
16
- end
17
- end
1
+ require 'i18n'
2
+
3
+ module VagrantPlugins
4
+ module VSphere
5
+ module Action
6
+ class MessageAlreadyCreated
7
+ def initialize(app, env)
8
+ @app = app
9
+ end
10
+
11
+ def call(env)
12
+ env[:ui].info I18n.t('vsphere.vm_already_created')
13
+ @app.call(env)
14
+ end
15
+ end
16
+ end
17
+ end
18
18
  end