vagrant-vsphere 0.6.0 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -5
- data/Gemfile +9 -9
- data/LICENSE.txt +23 -23
- data/README.md +175 -164
- data/Rakefile +16 -16
- data/example_box/metadata.json +2 -2
- data/lib/vSphere/action/clone.rb +127 -83
- data/lib/vSphere/action/close_vsphere.rb +23 -23
- data/lib/vSphere/action/connect_vsphere.rb +25 -25
- data/lib/vSphere/action/destroy.rb +37 -37
- data/lib/vSphere/action/get_ssh_info.rb +37 -37
- data/lib/vSphere/action/get_state.rb +45 -45
- data/lib/vSphere/action/is_created.rb +15 -15
- data/lib/vSphere/action/is_running.rb +20 -20
- data/lib/vSphere/action/message_already_created.rb +17 -17
- data/lib/vSphere/action/message_not_created.rb +17 -17
- data/lib/vSphere/action/message_not_running.rb +18 -18
- data/lib/vSphere/action/power_off.rb +27 -27
- data/lib/vSphere/action/power_on.rb +31 -31
- data/lib/vSphere/action/sync_folders.rb +97 -81
- data/lib/vSphere/action.rb +172 -172
- data/lib/vSphere/config.rb +37 -37
- data/lib/vSphere/errors.rb +10 -10
- data/lib/vSphere/plugin.rb +29 -29
- data/lib/vSphere/provider.rb +38 -38
- data/lib/vSphere/util/machine_helpers.rb +15 -15
- data/lib/vSphere/util/vim_helpers.rb +36 -36
- data/lib/vSphere/version.rb +4 -4
- data/lib/vagrant-vsphere.rb +17 -17
- data/locales/en.yml +65 -65
- data/spec/action_spec.rb +116 -116
- data/spec/clone_spec.rb +31 -31
- data/spec/connect_vsphere_spec.rb +23 -23
- data/spec/destroy_spec.rb +30 -30
- data/spec/get_ssh_info_spec.rb +30 -30
- data/spec/get_state_spec.rb +54 -54
- data/spec/is_created_spec.rb +28 -28
- data/spec/spec_helper.rb +98 -97
- data/vSphere.gemspec +27 -27
- metadata +21 -5
- checksums.yaml +0 -15
@@ -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
|
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
37
|
end
|
data/lib/vSphere/version.rb
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
module VagrantPlugins
|
2
|
-
module VSphere
|
3
|
-
VERSION = '0.
|
4
|
-
end
|
1
|
+
module VagrantPlugins
|
2
|
+
module VSphere
|
3
|
+
VERSION = '0.7.0'
|
4
|
+
end
|
5
5
|
end
|
data/lib/vagrant-vsphere.rb
CHANGED
@@ -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,65 @@
|
|
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
|
+
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
|
data/spec/action_spec.rb
CHANGED
@@ -1,116 +1,116 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'vagrant'
|
3
|
-
|
4
|
-
describe VagrantPlugins::VSphere::Action do
|
5
|
-
def run(action)
|
6
|
-
Vagrant::Action::Runner.new.run described_class.send("action_#{action}"), @env
|
7
|
-
end
|
8
|
-
|
9
|
-
before :each do
|
10
|
-
@machine.stub(:id).and_return(EXISTING_UUID)
|
11
|
-
end
|
12
|
-
|
13
|
-
describe 'up' do
|
14
|
-
def run_up
|
15
|
-
run :up
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'should connect to vSphere' do
|
19
|
-
VagrantPlugins::VSphere::Action::ConnectVSphere.any_instance.should_receive(:call)
|
20
|
-
|
21
|
-
run_up
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'should check if the VM exits' do
|
25
|
-
VagrantPlugins::VSphere::Action::IsCreated.any_instance.should_receive(:call)
|
26
|
-
|
27
|
-
run_up
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'should create the VM when the VM does already not exist' do
|
31
|
-
@machine.state.stub(:id).and_return(:not_created)
|
32
|
-
|
33
|
-
VagrantPlugins::VSphere::Action::Clone.any_instance.should_receive(:call)
|
34
|
-
|
35
|
-
run_up
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'should not create the VM when the VM already exists' do
|
39
|
-
@machine.state.stub(:id).and_return(:running)
|
40
|
-
|
41
|
-
VagrantPlugins::VSphere::Action::Clone.any_instance.should_not_receive(:call)
|
42
|
-
|
43
|
-
run_up
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
describe 'destroy' do
|
48
|
-
def run_destroy
|
49
|
-
run :destroy
|
50
|
-
end
|
51
|
-
|
52
|
-
it 'should connect to vSphere' do
|
53
|
-
VagrantPlugins::VSphere::Action::ConnectVSphere.any_instance.should_receive(:call)
|
54
|
-
|
55
|
-
run_destroy
|
56
|
-
end
|
57
|
-
|
58
|
-
it 'should power off the VM' do
|
59
|
-
VagrantPlugins::VSphere::Action::PowerOff.any_instance.should_receive(:call)
|
60
|
-
|
61
|
-
run_destroy
|
62
|
-
end
|
63
|
-
|
64
|
-
it 'should destroy the VM' do
|
65
|
-
VagrantPlugins::VSphere::Action::Destroy.any_instance.should_receive(:call)
|
66
|
-
|
67
|
-
run_destroy
|
68
|
-
end
|
69
|
-
end
|
70
|
-
|
71
|
-
describe 'halt' do
|
72
|
-
it 'should power off the VM' do
|
73
|
-
@machine.state.stub(:id).and_return(:running)
|
74
|
-
|
75
|
-
VagrantPlugins::VSphere::Action::PowerOff.any_instance.should_receive(:call)
|
76
|
-
|
77
|
-
run :halt
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
describe 'get state' do
|
82
|
-
def run_get_state
|
83
|
-
run :get_state
|
84
|
-
end
|
85
|
-
|
86
|
-
it 'should connect to vSphere' do
|
87
|
-
VagrantPlugins::VSphere::Action::ConnectVSphere.any_instance.should_receive(:call)
|
88
|
-
|
89
|
-
run_get_state
|
90
|
-
end
|
91
|
-
|
92
|
-
it 'should get the power state' do
|
93
|
-
VagrantPlugins::VSphere::Action::GetState.any_instance.should_receive(:call)
|
94
|
-
|
95
|
-
run_get_state
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
describe 'get ssh info' do
|
100
|
-
def run_get_ssh_info
|
101
|
-
run :get_ssh_info
|
102
|
-
end
|
103
|
-
|
104
|
-
it 'should connect to vSphere' do
|
105
|
-
VagrantPlugins::VSphere::Action::ConnectVSphere.any_instance.should_receive(:call)
|
106
|
-
|
107
|
-
run_get_ssh_info
|
108
|
-
end
|
109
|
-
|
110
|
-
it 'should get the power state' do
|
111
|
-
VagrantPlugins::VSphere::Action::GetSshInfo.any_instance.should_receive(:call)
|
112
|
-
|
113
|
-
run_get_ssh_info
|
114
|
-
end
|
115
|
-
end
|
116
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
require 'vagrant'
|
3
|
+
|
4
|
+
describe VagrantPlugins::VSphere::Action do
|
5
|
+
def run(action)
|
6
|
+
Vagrant::Action::Runner.new.run described_class.send("action_#{action}"), @env
|
7
|
+
end
|
8
|
+
|
9
|
+
before :each do
|
10
|
+
@machine.stub(:id).and_return(EXISTING_UUID)
|
11
|
+
end
|
12
|
+
|
13
|
+
describe 'up' do
|
14
|
+
def run_up
|
15
|
+
run :up
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'should connect to vSphere' do
|
19
|
+
VagrantPlugins::VSphere::Action::ConnectVSphere.any_instance.should_receive(:call)
|
20
|
+
|
21
|
+
run_up
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should check if the VM exits' do
|
25
|
+
VagrantPlugins::VSphere::Action::IsCreated.any_instance.should_receive(:call)
|
26
|
+
|
27
|
+
run_up
|
28
|
+
end
|
29
|
+
|
30
|
+
it 'should create the VM when the VM does already not exist' do
|
31
|
+
@machine.state.stub(:id).and_return(:not_created)
|
32
|
+
|
33
|
+
VagrantPlugins::VSphere::Action::Clone.any_instance.should_receive(:call)
|
34
|
+
|
35
|
+
run_up
|
36
|
+
end
|
37
|
+
|
38
|
+
it 'should not create the VM when the VM already exists' do
|
39
|
+
@machine.state.stub(:id).and_return(:running)
|
40
|
+
|
41
|
+
VagrantPlugins::VSphere::Action::Clone.any_instance.should_not_receive(:call)
|
42
|
+
|
43
|
+
run_up
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
describe 'destroy' do
|
48
|
+
def run_destroy
|
49
|
+
run :destroy
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'should connect to vSphere' do
|
53
|
+
VagrantPlugins::VSphere::Action::ConnectVSphere.any_instance.should_receive(:call)
|
54
|
+
|
55
|
+
run_destroy
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'should power off the VM' do
|
59
|
+
VagrantPlugins::VSphere::Action::PowerOff.any_instance.should_receive(:call)
|
60
|
+
|
61
|
+
run_destroy
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'should destroy the VM' do
|
65
|
+
VagrantPlugins::VSphere::Action::Destroy.any_instance.should_receive(:call)
|
66
|
+
|
67
|
+
run_destroy
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
describe 'halt' do
|
72
|
+
it 'should power off the VM' do
|
73
|
+
@machine.state.stub(:id).and_return(:running)
|
74
|
+
|
75
|
+
VagrantPlugins::VSphere::Action::PowerOff.any_instance.should_receive(:call)
|
76
|
+
|
77
|
+
run :halt
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
describe 'get state' do
|
82
|
+
def run_get_state
|
83
|
+
run :get_state
|
84
|
+
end
|
85
|
+
|
86
|
+
it 'should connect to vSphere' do
|
87
|
+
VagrantPlugins::VSphere::Action::ConnectVSphere.any_instance.should_receive(:call)
|
88
|
+
|
89
|
+
run_get_state
|
90
|
+
end
|
91
|
+
|
92
|
+
it 'should get the power state' do
|
93
|
+
VagrantPlugins::VSphere::Action::GetState.any_instance.should_receive(:call)
|
94
|
+
|
95
|
+
run_get_state
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
describe 'get ssh info' do
|
100
|
+
def run_get_ssh_info
|
101
|
+
run :get_ssh_info
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'should connect to vSphere' do
|
105
|
+
VagrantPlugins::VSphere::Action::ConnectVSphere.any_instance.should_receive(:call)
|
106
|
+
|
107
|
+
run_get_ssh_info
|
108
|
+
end
|
109
|
+
|
110
|
+
it 'should get the power state' do
|
111
|
+
VagrantPlugins::VSphere::Action::GetSshInfo.any_instance.should_receive(:call)
|
112
|
+
|
113
|
+
run_get_ssh_info
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
data/spec/clone_spec.rb
CHANGED
@@ -1,32 +1,32 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe VagrantPlugins::VSphere::Action::Clone do
|
4
|
-
before :each do
|
5
|
-
@env[:vSphere_connection] = @vim
|
6
|
-
end
|
7
|
-
|
8
|
-
it 'should create a CloneVM task' do
|
9
|
-
call
|
10
|
-
@template.should have_received(:CloneVM_Task).with({
|
11
|
-
:folder => @data_center,
|
12
|
-
:name => NAME,
|
13
|
-
:spec => {}
|
14
|
-
})
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'should set the machine id to be the new UUID' do
|
18
|
-
call
|
19
|
-
@machine.should have_received(:id=).with(NEW_UUID)
|
20
|
-
end
|
21
|
-
|
22
|
-
it 'should call the next item in the middleware stack' do
|
23
|
-
call
|
24
|
-
@app.should have_received :call
|
25
|
-
end
|
26
|
-
|
27
|
-
it 'should set static IP when given config spec' do
|
28
|
-
@machine.provider_config.stub(:customization_spec_name).and_return('spec')
|
29
|
-
call
|
30
|
-
@ip.should have_received(:ipAddress=).with('0.0.0.0')
|
31
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe VagrantPlugins::VSphere::Action::Clone do
|
4
|
+
before :each do
|
5
|
+
@env[:vSphere_connection] = @vim
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'should create a CloneVM task' do
|
9
|
+
call
|
10
|
+
@template.should have_received(:CloneVM_Task).with({
|
11
|
+
:folder => @data_center,
|
12
|
+
:name => NAME,
|
13
|
+
:spec => {}
|
14
|
+
})
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should set the machine id to be the new UUID' do
|
18
|
+
call
|
19
|
+
@machine.should have_received(:id=).with(NEW_UUID)
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should call the next item in the middleware stack' do
|
23
|
+
call
|
24
|
+
@app.should have_received :call
|
25
|
+
end
|
26
|
+
|
27
|
+
it 'should set static IP when given config spec' do
|
28
|
+
@machine.provider_config.stub(:customization_spec_name).and_return('spec')
|
29
|
+
call
|
30
|
+
@ip.should have_received(:ipAddress=).with('0.0.0.0')
|
31
|
+
end
|
32
32
|
end
|
@@ -1,24 +1,24 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe VagrantPlugins::VSphere::Action::ConnectVSphere do
|
4
|
-
before :each do
|
5
|
-
described_class.new(@app, @env).call(@env)
|
6
|
-
end
|
7
|
-
|
8
|
-
it 'should connect to vSphere' do
|
9
|
-
VIM.should have_received(:connect).with({
|
10
|
-
:host => @env[:machine].provider_config.host,
|
11
|
-
:user => @env[:machine].provider_config.user,
|
12
|
-
:password => @env[:machine].provider_config.password,
|
13
|
-
:insecure => @env[:machine].provider_config.insecure,
|
14
|
-
})
|
15
|
-
end
|
16
|
-
|
17
|
-
it 'should add the vSphere connection to the environment' do
|
18
|
-
@env[:vSphere_connection].should be @vim
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'should call the next item in the middleware stack' do
|
22
|
-
@app.should have_received :call
|
23
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe VagrantPlugins::VSphere::Action::ConnectVSphere do
|
4
|
+
before :each do
|
5
|
+
described_class.new(@app, @env).call(@env)
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'should connect to vSphere' do
|
9
|
+
VIM.should have_received(:connect).with({
|
10
|
+
:host => @env[:machine].provider_config.host,
|
11
|
+
:user => @env[:machine].provider_config.user,
|
12
|
+
:password => @env[:machine].provider_config.password,
|
13
|
+
:insecure => @env[:machine].provider_config.insecure,
|
14
|
+
})
|
15
|
+
end
|
16
|
+
|
17
|
+
it 'should add the vSphere connection to the environment' do
|
18
|
+
@env[:vSphere_connection].should be @vim
|
19
|
+
end
|
20
|
+
|
21
|
+
it 'should call the next item in the middleware stack' do
|
22
|
+
@app.should have_received :call
|
23
|
+
end
|
24
24
|
end
|
data/spec/destroy_spec.rb
CHANGED
@@ -1,31 +1,31 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe VagrantPlugins::VSphere::Action::Destroy do
|
4
|
-
before :each do
|
5
|
-
@env[:vSphere_connection] = @vim
|
6
|
-
end
|
7
|
-
|
8
|
-
it 'should set the machine id to nil' do
|
9
|
-
@env[:machine].stub(:id).and_return(MISSING_UUID)
|
10
|
-
|
11
|
-
call
|
12
|
-
|
13
|
-
@env[:machine].should have_received(:id=).with(nil)
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'should not create a Destroy task if VM is not found' do
|
17
|
-
@env[:machine].stub(:id).and_return(MISSING_UUID)
|
18
|
-
|
19
|
-
call
|
20
|
-
|
21
|
-
@vm.should_not have_received :Destroy_Task
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'should create a VM Destroy task if the VM exists' do
|
25
|
-
@env[:machine].stub(:id).and_return(EXISTING_UUID)
|
26
|
-
|
27
|
-
call
|
28
|
-
|
29
|
-
@vm.should have_received :Destroy_Task
|
30
|
-
end
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe VagrantPlugins::VSphere::Action::Destroy do
|
4
|
+
before :each do
|
5
|
+
@env[:vSphere_connection] = @vim
|
6
|
+
end
|
7
|
+
|
8
|
+
it 'should set the machine id to nil' do
|
9
|
+
@env[:machine].stub(:id).and_return(MISSING_UUID)
|
10
|
+
|
11
|
+
call
|
12
|
+
|
13
|
+
@env[:machine].should have_received(:id=).with(nil)
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should not create a Destroy task if VM is not found' do
|
17
|
+
@env[:machine].stub(:id).and_return(MISSING_UUID)
|
18
|
+
|
19
|
+
call
|
20
|
+
|
21
|
+
@vm.should_not have_received :Destroy_Task
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should create a VM Destroy task if the VM exists' do
|
25
|
+
@env[:machine].stub(:id).and_return(EXISTING_UUID)
|
26
|
+
|
27
|
+
call
|
28
|
+
|
29
|
+
@vm.should have_received :Destroy_Task
|
30
|
+
end
|
31
31
|
end
|