vagrant-vsphere 0.7.0 → 0.7.1

Sign up to get free protection for your applications and to get access to all the features.
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,11 +1,14 @@
1
- require 'vagrant'
2
-
3
- module VagrantPlugins
4
- module VSphere
5
- module Errors
6
- class VSphereError < Vagrant::Errors::VagrantError
7
- error_namespace('vsphere.errors')
8
- end
9
- end
10
- end
11
- end
1
+ require 'vagrant'
2
+
3
+ module VagrantPlugins
4
+ module VSphere
5
+ module Errors
6
+ class VSphereError < Vagrant::Errors::VagrantError
7
+ error_namespace('vsphere.errors')
8
+ end
9
+ class RsyncError < VSphereError
10
+ error_key(:rsync_error)
11
+ end
12
+ end
13
+ end
14
+ end
@@ -1,30 +1,30 @@
1
- require 'vagrant'
2
-
3
- module VagrantPlugins
4
- module VSphere
5
- class Plugin < Vagrant.plugin('2')
6
- name 'vsphere'
7
- description 'Allows Vagrant to manage machines with VMWare vSphere'
8
-
9
- config(:vsphere, :provider) do
10
- require_relative 'config'
11
- Config
12
- end
13
-
14
- provider(:vsphere) do
15
- # TODO: add logging
16
- setup_i18n
17
-
18
- # Return the provider
19
- require_relative 'provider'
20
- Provider
21
- end
22
-
23
-
24
- def self.setup_i18n
25
- I18n.load_path << File.expand_path('locales/en.yml', VSphere.source_root)
26
- I18n.reload!
27
- end
28
- end
29
- end
1
+ require 'vagrant'
2
+
3
+ module VagrantPlugins
4
+ module VSphere
5
+ class Plugin < Vagrant.plugin('2')
6
+ name 'vsphere'
7
+ description 'Allows Vagrant to manage machines with VMWare vSphere'
8
+
9
+ config(:vsphere, :provider) do
10
+ require_relative 'config'
11
+ Config
12
+ end
13
+
14
+ provider(:vsphere) do
15
+ # TODO: add logging
16
+ setup_i18n
17
+
18
+ # Return the provider
19
+ require_relative 'provider'
20
+ Provider
21
+ end
22
+
23
+
24
+ def self.setup_i18n
25
+ I18n.load_path << File.expand_path('locales/en.yml', VSphere.source_root)
26
+ I18n.reload!
27
+ end
28
+ end
29
+ end
30
30
  end
@@ -1,39 +1,39 @@
1
- require 'vagrant'
2
-
3
- module VagrantPlugins
4
- module VSphere
5
- class Provider < Vagrant.plugin('2', :provider)
6
- def initialize(machine)
7
- @machine = machine
8
- end
9
-
10
- def action(name)
11
- action_method = "action_#{name}"
12
- return Action.send(action_method) if Action.respond_to?(action_method)
13
- nil
14
- end
15
-
16
- def ssh_info
17
- env = @machine.action('get_ssh_info')
18
- env[:machine_ssh_info]
19
- end
20
-
21
- def state
22
- env = @machine.action('get_state')
23
-
24
- state_id = env[:machine_state_id]
25
-
26
- short = "vagrant_vsphere.states.short_#{state_id}"
27
- long = "vagrant_vsphere.states.long_#{state_id}"
28
-
29
- # Return the MachineState object
30
- Vagrant::MachineState.new(state_id, short, long)
31
- end
32
-
33
- def to_s
34
- id = @machine.id.nil? ? 'new' : @machine.id
35
- "vSphere (#{id})"
36
- end
37
- end
38
- end
1
+ require 'vagrant'
2
+
3
+ module VagrantPlugins
4
+ module VSphere
5
+ class Provider < Vagrant.plugin('2', :provider)
6
+ def initialize(machine)
7
+ @machine = machine
8
+ end
9
+
10
+ def action(name)
11
+ action_method = "action_#{name}"
12
+ return Action.send(action_method) if Action.respond_to?(action_method)
13
+ nil
14
+ end
15
+
16
+ def ssh_info
17
+ env = @machine.action('get_ssh_info')
18
+ env[:machine_ssh_info]
19
+ end
20
+
21
+ def state
22
+ env = @machine.action('get_state')
23
+
24
+ state_id = env[:machine_state_id]
25
+
26
+ short = "vagrant_vsphere.states.short_#{state_id}"
27
+ long = "vagrant_vsphere.states.long_#{state_id}"
28
+
29
+ # Return the MachineState object
30
+ Vagrant::MachineState.new(state_id, short, long)
31
+ end
32
+
33
+ def to_s
34
+ id = @machine.id.nil? ? 'new' : @machine.id
35
+ "vSphere (#{id})"
36
+ end
37
+ end
38
+ end
39
39
  end
@@ -1,15 +1,15 @@
1
- module VagrantPlugins
2
- module VSphere
3
- module Util
4
- module MachineHelpers
5
- def wait_for_ssh(env)
6
- env[:ui].info(I18n.t("vsphere.waiting_for_ssh"))
7
- while true
8
- break if env[:machine].communicate.ready?
9
- sleep 5
10
- end
11
- end
12
- end
13
- end
14
- end
15
- end
1
+ module VagrantPlugins
2
+ module VSphere
3
+ module Util
4
+ module MachineHelpers
5
+ def wait_for_ssh(env)
6
+ env[:ui].info(I18n.t("vsphere.waiting_for_ssh"))
7
+ while true
8
+ break if env[:machine].communicate.ready?
9
+ sleep 5
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
15
+ end
@@ -1,37 +1,37 @@
1
- require 'rbvmomi'
2
-
3
- module VagrantPlugins
4
- module VSphere
5
- module Util
6
- module VimHelpers
7
- def get_datacenter(connection, machine)
8
- connection.serviceInstance.find_datacenter(machine.provider_config.data_center_name) or fail Errors::VSphereError, :message => I18n.t('errors.missing_datacenter')
9
- end
10
-
11
- def get_vm_by_uuid(connection, machine)
12
- get_datacenter(connection, machine).vmFolder.findByUuid machine.id
13
- end
14
-
15
- def get_resource_pool(connection, machine)
16
- cr = get_datacenter(connection, machine).find_compute_resource(machine.provider_config.compute_resource_name) or fail Errors::VSphereError, :message => I18n.t('errors.missing_compute_resource')
17
- cr.resourcePool.find(machine.provider_config.resource_pool_name) or fail Errors::VSphereError, :message => I18n.t('errors.missing_resource_pool')
18
- end
19
-
20
- def get_customization_spec_info_by_name(connection, machine)
21
- name = machine.provider_config.customization_spec_name
22
- return if name.nil? || name.empty?
23
-
24
- manager = connection.serviceContent.customizationSpecManager or fail Errors::VSphereError, :message => I18n.t('errors.null_configuration_spec_manager') if manager.nil?
25
- spec = manager.GetCustomizationSpec(:name => name) or fail Errors::VSphereError, :message => I18n.t('errors.missing_configuration_spec') if spec.nil?
26
- end
27
-
28
- def get_datastore(connection, machine)
29
- name = machine.provider_config.data_store_name
30
- return if name.nil? || name.empty?
31
-
32
- get_datacenter(connection, machine).find_datastore name or fail Errors::VSphereError, :message => I18n.t('errors.missing_datastore')
33
- end
34
- end
35
- end
36
- end
37
- end
1
+ require 'rbvmomi'
2
+
3
+ module VagrantPlugins
4
+ module VSphere
5
+ module Util
6
+ module VimHelpers
7
+ def get_datacenter(connection, machine)
8
+ connection.serviceInstance.find_datacenter(machine.provider_config.data_center_name) or fail Errors::VSphereError, :message => I18n.t('vsphere.errors.missing_datacenter')
9
+ end
10
+
11
+ def get_vm_by_uuid(connection, machine)
12
+ get_datacenter(connection, machine).vmFolder.findByUuid machine.id
13
+ end
14
+
15
+ def get_resource_pool(connection, machine)
16
+ cr = get_datacenter(connection, machine).find_compute_resource(machine.provider_config.compute_resource_name) or fail Errors::VSphereError, :message => I18n.t('vsphere.errors.missing_compute_resource')
17
+ cr.resourcePool.find(machine.provider_config.resource_pool_name) or fail Errors::VSphereError, :message => I18n.t('vsphere.errors.missing_resource_pool')
18
+ end
19
+
20
+ def get_customization_spec_info_by_name(connection, machine)
21
+ name = machine.provider_config.customization_spec_name
22
+ return if name.nil? || name.empty?
23
+
24
+ manager = connection.serviceContent.customizationSpecManager or fail Errors::VSphereError, :message => I18n.t('vsphere.errors.null_configuration_spec_manager') if manager.nil?
25
+ spec = manager.GetCustomizationSpec(:name => name) or fail Errors::VSphereError, :message => I18n.t('vsphere.errors.missing_configuration_spec') if spec.nil?
26
+ end
27
+
28
+ def get_datastore(connection, machine)
29
+ name = machine.provider_config.data_store_name
30
+ return if name.nil? || name.empty?
31
+
32
+ get_datacenter(connection, machine).find_datastore name or fail Errors::VSphereError, :message => I18n.t('vsphere.errors.missing_datastore')
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
@@ -1,5 +1,5 @@
1
- module VagrantPlugins
2
- module VSphere
3
- VERSION = '0.7.0'
4
- end
5
- end
1
+ module VagrantPlugins
2
+ module VSphere
3
+ VERSION = '0.7.1'
4
+ end
5
+ end
@@ -1,18 +1,18 @@
1
- require 'pathname'
2
-
3
- require 'vSphere/plugin'
4
-
5
- module VagrantPlugins
6
- module VSphere
7
- lib_path = Pathname.new(File.expand_path('../vSphere', __FILE__))
8
- autoload :Action, lib_path.join('action')
9
- autoload :Errors, lib_path.join('errors')
10
-
11
- # This returns the path to the source of this plugin.
12
- #
13
- # @return [Pathname]
14
- def self.source_root
15
- @source_root ||= Pathname.new(File.expand_path('../../', __FILE__))
16
- end
17
- end
1
+ require 'pathname'
2
+
3
+ require 'vSphere/plugin'
4
+
5
+ module VagrantPlugins
6
+ module VSphere
7
+ lib_path = Pathname.new(File.expand_path('../vSphere', __FILE__))
8
+ autoload :Action, lib_path.join('action')
9
+ autoload :Errors, lib_path.join('errors')
10
+
11
+ # This returns the path to the source of this plugin.
12
+ #
13
+ # @return [Pathname]
14
+ def self.source_root
15
+ @source_root ||= Pathname.new(File.expand_path('../../', __FILE__))
16
+ end
17
+ end
18
18
  end
data/locales/en.yml CHANGED
@@ -1,65 +1,66 @@
1
- en:
2
- vsphere:
3
- creating_cloned_vm: |-
4
- Calling vSphere CloneVM with the following settings:
5
- vm_clone_success: |-
6
- New virtual machine successfully cloned and started
7
- destroy_vm: |-
8
- Calling vShpere Destroy
9
- power_off_vm: |-
10
- Calling vSphere PowerOff
11
- power_on_vm: |-
12
- Calling vSphere PowerOn
13
- vm_already_created: |-
14
- The VM is already created
15
- vm_not_created: |-
16
- The VM has not been created
17
- vm_not_running: |-
18
- The VM is not running
19
- waiting_for_ssh: |-
20
- Waiting for SSH to become available...
21
- rsync_folder: |-
22
- Rsyncing folder: %{hostpath} => %{guestpath}
23
- errors:
24
- missing_template: |-
25
- Configured template/source VM could not be found
26
- missing_datacenter: |-
27
- Configured data center not found
28
- missing_compute_resource: |-
29
- Configured compute resource not found
30
- missing_resource_pool: |-
31
- Configured resource pool not found
32
- null_configuration_spec_manager: |-
33
- Configuration spec manager not configured in the ServiceInstance
34
- missing_configuration_spec: |-
35
- Configured configuration spec not found
36
- missing_datastore: |-
37
- Configured data store not found
38
- rsync_error: |-
39
- There was an error when attemping to rsync a share folder.
40
- Please inspect the error message below for more info.
41
-
42
- Host path: %{hostpath}
43
- Guest path: %{guestpath}
44
- Error: %{stderr}
45
- too_many_private_networks: |-
46
- There a more private networks configured than can be assigned to the customization spec
47
- rsync_not_found: |-
48
- Warning! Folder sync disabled because the rsync binary is
49
- missing. Make sure rsync is installed and the binary can
50
- be found in PATH.
51
- config:
52
- host: |-
53
- Configuration must specify a vSphere host
54
- user: |-
55
- Configuration must specify a vSphere user
56
- password: |-
57
- Configuration must specify a vSphere password
58
- name: |-
59
- Configuration must specify a VM name
60
- template: |-
61
- Configuration must specify a template name
62
- compute_resource: |-
63
- Configuration must specify a compute resource name
64
- resource_pool: |-
65
- Configuration must specify a resource pool name
1
+ en:
2
+ vsphere:
3
+ creating_cloned_vm: |-
4
+ Calling vSphere CloneVM with the following settings:
5
+ vm_clone_success: |-
6
+ New virtual machine successfully cloned and started
7
+ destroy_vm: |-
8
+ Calling vShpere Destroy
9
+ power_off_vm: |-
10
+ Calling vSphere PowerOff
11
+ power_on_vm: |-
12
+ Calling vSphere PowerOn
13
+ vm_already_created: |-
14
+ The VM is already created
15
+ vm_not_created: |-
16
+ The VM has not been created
17
+ vm_not_running: |-
18
+ The VM is not running
19
+ waiting_for_ssh: |-
20
+ Waiting for SSH to become available...
21
+ rsync_folder: |-
22
+ Rsyncing folder: %{hostpath} => %{guestpath}
23
+
24
+ errors:
25
+ missing_template: |-
26
+ Configured template/source VM could not be found
27
+ missing_datacenter: |-
28
+ Configured data center not found
29
+ missing_compute_resource: |-
30
+ Configured compute resource not found
31
+ missing_resource_pool: |-
32
+ Configured resource pool not found
33
+ null_configuration_spec_manager: |-
34
+ Configuration spec manager not configured in the ServiceInstance
35
+ missing_configuration_spec: |-
36
+ Configured configuration spec not found
37
+ missing_datastore: |-
38
+ Configured data store not found
39
+ rsync_error: |-
40
+ There was an error when attemping to rsync a share folder.
41
+ Please inspect the error message below for more info.
42
+
43
+ Host path: %{hostpath}
44
+ Guest path: %{guestpath}
45
+ Error: %{stderr}
46
+ too_many_private_networks: |-
47
+ There a more private networks configured than can be assigned to the customization spec
48
+ rsync_not_found: |-
49
+ Warning! Folder sync disabled because the rsync binary is
50
+ missing. Make sure rsync is installed and the binary can
51
+ be found in PATH.
52
+ config:
53
+ host: |-
54
+ Configuration must specify a vSphere host
55
+ user: |-
56
+ Configuration must specify a vSphere user
57
+ password: |-
58
+ Configuration must specify a vSphere password
59
+ name: |-
60
+ Configuration must specify a VM name
61
+ template: |-
62
+ Configuration must specify a template name
63
+ compute_resource: |-
64
+ Configuration must specify a compute resource name
65
+ resource_pool: |-
66
+ Configuration must specify a resource pool name