chef-provisioning-vsphere 0.8.2 → 0.8.3.dev

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,161 +1,161 @@
1
- require 'chef/provisioning/vsphere_driver'
2
- require_relative 'support/fake_action_handler'
3
- require_relative 'support/vsphere_helper_stub'
4
-
5
- describe ChefProvisioningVsphere::CloneSpecBuilder do
6
- let(:options) { Hash.new }
7
- let(:vm_template) { double('template') }
8
-
9
- before do
10
- allow(vm_template).to receive_message_chain(:config, :guestId)
11
- .and_return('guest')
12
- allow(vm_template).to receive_message_chain(:config, :template)
13
- .and_return(false)
14
- end
15
-
16
- subject do
17
- builder = ChefProvisioningVsphere::CloneSpecBuilder.new(
18
- ChefProvisioningVsphereStubs::VsphereHelperStub.new,
19
- ChefProvisioningVsphereStubs::FakeActionHandler.new
20
- )
21
- builder.build(vm_template, 'machine_name', options)
22
- end
23
-
24
- context 'using linked clones' do
25
- before { options[:use_linked_clone] = true }
26
-
27
- it 'sets the disk move type of the relocation spec' do
28
- expect(subject.location.diskMoveType).to be :moveChildMostDiskBacking
29
- end
30
- end
31
-
32
- context 'using linked clone on a template source' do
33
- before do
34
- options[:use_linked_clone] = true
35
- options[:host] = 'host'
36
- allow(vm_template).to receive_message_chain(:config, :template)
37
- .and_return(true)
38
- end
39
-
40
- it 'does not set the disk move type of the relocation spec' do
41
- expect(subject.location.diskMoveType).to be nil
42
- end
43
- end
44
-
45
- context 'not using linked clones' do
46
- before { options[:use_linked_clone] = false }
47
-
48
- it 'does not set the disk move type of the relocation spec' do
49
- expect(subject.location.diskMoveType).to be nil
50
- end
51
- end
52
-
53
- context 'specifying a host' do
54
- before { options[:host] = 'host' }
55
-
56
- it 'sets the host' do
57
- expect(subject.location.host).to_not be nil
58
- end
59
- end
60
-
61
- context 'not specifying a host' do
62
- it 'does not set the host' do
63
- expect(subject.location.host).to be nil
64
- end
65
- end
66
-
67
- context 'specifying a pool' do
68
- before { options[:resource_pool] = 'pool' }
69
-
70
- it 'sets the pool' do
71
- expect(subject.location.pool).to_not be nil
72
- end
73
- end
74
-
75
- context 'not specifying a pool' do
76
- it 'does not set the pool' do
77
- expect(subject.location.pool).to be nil
78
- end
79
- end
80
-
81
- context 'not specifying a pool but specifying a host on a template' do
82
- before do
83
- options[:host] = 'host'
84
- allow(vm_template).to receive_message_chain(:config, :template)
85
- .and_return(true)
86
- end
87
-
88
- it 'sets the pool to the hosts parent root pool' do
89
- expect(subject.location.pool).to be subject.location.host.parent.resourcePool
90
- end
91
- end
92
-
93
- context 'not specifying a pool or host when cloning from a template' do
94
- before do
95
- allow(vm_template).to receive_message_chain(:config, :template)
96
- .and_return(true)
97
- end
98
-
99
- it 'raises an error' do
100
- expect { subject }.to raise_error
101
- end
102
- end
103
-
104
- context 'specifying a hostname' do
105
- before do
106
- options[:customization_spec] = {
107
- ipsettings: {},
108
- hostname: hostname,
109
- domain: 'local'
110
- }
111
- end
112
-
113
- context 'alpha characters only' do
114
- let(:hostname) { 'myhost' }
115
-
116
- it 'sets the spec hostname' do
117
- expect(subject.customization.identity.hostName.name).to eq hostname
118
- end
119
- end
120
-
121
- context 'alpha numeric characters only' do
122
- let(:hostname) { 'myhost01' }
123
-
124
- it 'sets the spec hostname' do
125
- expect(subject.customization.identity.hostName.name).to eq hostname
126
- end
127
- end
128
-
129
- context 'containing a dash' do
130
- let(:hostname) { 'my-host01' }
131
-
132
- it 'sets the spec hostname' do
133
- expect(subject.customization.identity.hostName.name).to eq hostname
134
- end
135
- end
136
-
137
- context 'containing an underscore' do
138
- let(:hostname) { 'my_host' }
139
-
140
- it 'raises an error' do
141
- expect { subject }.to raise_error
142
- end
143
- end
144
-
145
- context 'starting with a dash' do
146
- let(:hostname) { '-myhost' }
147
-
148
- it 'raises an error' do
149
- expect { subject }.to raise_error
150
- end
151
- end
152
-
153
- context 'ending with a dash' do
154
- let(:hostname) { 'myhost-' }
155
-
156
- it 'raises an error' do
157
- expect { subject }.to raise_error
158
- end
159
- end
160
- end
161
- end
1
+ require 'chef/provisioning/vsphere_driver'
2
+ require_relative 'support/fake_action_handler'
3
+ require_relative 'support/vsphere_helper_stub'
4
+
5
+ describe ChefProvisioningVsphere::CloneSpecBuilder do
6
+ let(:options) { Hash.new }
7
+ let(:vm_template) { double('template') }
8
+
9
+ before do
10
+ allow(vm_template).to receive_message_chain(:config, :guestId)
11
+ .and_return('guest')
12
+ allow(vm_template).to receive_message_chain(:config, :template)
13
+ .and_return(false)
14
+ end
15
+
16
+ subject do
17
+ builder = ChefProvisioningVsphere::CloneSpecBuilder.new(
18
+ ChefProvisioningVsphereStubs::VsphereHelperStub.new,
19
+ ChefProvisioningVsphereStubs::FakeActionHandler.new
20
+ )
21
+ builder.build(vm_template, 'machine_name', options)
22
+ end
23
+
24
+ context 'using linked clones' do
25
+ before { options[:use_linked_clone] = true }
26
+
27
+ it 'sets the disk move type of the relocation spec' do
28
+ expect(subject.location.diskMoveType).to be :moveChildMostDiskBacking
29
+ end
30
+ end
31
+
32
+ context 'using linked clone on a template source' do
33
+ before do
34
+ options[:use_linked_clone] = true
35
+ options[:host] = 'host'
36
+ allow(vm_template).to receive_message_chain(:config, :template)
37
+ .and_return(true)
38
+ end
39
+
40
+ it 'does not set the disk move type of the relocation spec' do
41
+ expect(subject.location.diskMoveType).to be nil
42
+ end
43
+ end
44
+
45
+ context 'not using linked clones' do
46
+ before { options[:use_linked_clone] = false }
47
+
48
+ it 'does not set the disk move type of the relocation spec' do
49
+ expect(subject.location.diskMoveType).to be nil
50
+ end
51
+ end
52
+
53
+ context 'specifying a host' do
54
+ before { options[:host] = 'host' }
55
+
56
+ it 'sets the host' do
57
+ expect(subject.location.host).to_not be nil
58
+ end
59
+ end
60
+
61
+ context 'not specifying a host' do
62
+ it 'does not set the host' do
63
+ expect(subject.location.host).to be nil
64
+ end
65
+ end
66
+
67
+ context 'specifying a pool' do
68
+ before { options[:resource_pool] = 'pool' }
69
+
70
+ it 'sets the pool' do
71
+ expect(subject.location.pool).to_not be nil
72
+ end
73
+ end
74
+
75
+ context 'not specifying a pool' do
76
+ it 'does not set the pool' do
77
+ expect(subject.location.pool).to be nil
78
+ end
79
+ end
80
+
81
+ context 'not specifying a pool but specifying a host on a template' do
82
+ before do
83
+ options[:host] = 'host'
84
+ allow(vm_template).to receive_message_chain(:config, :template)
85
+ .and_return(true)
86
+ end
87
+
88
+ it 'sets the pool to the hosts parent root pool' do
89
+ expect(subject.location.pool).to be subject.location.host.parent.resourcePool
90
+ end
91
+ end
92
+
93
+ context 'not specifying a pool or host when cloning from a template' do
94
+ before do
95
+ allow(vm_template).to receive_message_chain(:config, :template)
96
+ .and_return(true)
97
+ end
98
+
99
+ it 'raises an error' do
100
+ expect { subject }.to raise_error
101
+ end
102
+ end
103
+
104
+ context 'specifying a hostname' do
105
+ before do
106
+ options[:customization_spec] = {
107
+ ipsettings: {},
108
+ hostname: hostname,
109
+ domain: 'local'
110
+ }
111
+ end
112
+
113
+ context 'alpha characters only' do
114
+ let(:hostname) { 'myhost' }
115
+
116
+ it 'sets the spec hostname' do
117
+ expect(subject.customization.identity.hostName.name).to eq hostname
118
+ end
119
+ end
120
+
121
+ context 'alpha numeric characters only' do
122
+ let(:hostname) { 'myhost01' }
123
+
124
+ it 'sets the spec hostname' do
125
+ expect(subject.customization.identity.hostName.name).to eq hostname
126
+ end
127
+ end
128
+
129
+ context 'containing a dash' do
130
+ let(:hostname) { 'my-host01' }
131
+
132
+ it 'sets the spec hostname' do
133
+ expect(subject.customization.identity.hostName.name).to eq hostname
134
+ end
135
+ end
136
+
137
+ context 'containing an underscore' do
138
+ let(:hostname) { 'my_host' }
139
+
140
+ it 'raises an error' do
141
+ expect { subject }.to raise_error
142
+ end
143
+ end
144
+
145
+ context 'starting with a dash' do
146
+ let(:hostname) { '-myhost' }
147
+
148
+ it 'raises an error' do
149
+ expect { subject }.to raise_error
150
+ end
151
+ end
152
+
153
+ context 'ending with a dash' do
154
+ let(:hostname) { 'myhost-' }
155
+
156
+ it 'raises an error' do
157
+ expect { subject }.to raise_error
158
+ end
159
+ end
160
+ end
161
+ end
@@ -1,7 +1,7 @@
1
- module ChefProvisioningVsphereStubs
2
- class FakeActionHandler < Chef::Provisioning::ActionHandler
3
- def puts(out)
4
-
5
- end
6
- end
7
- end
1
+ module ChefProvisioningVsphereStubs
2
+ class FakeActionHandler < Chef::Provisioning::ActionHandler
3
+ def puts(out)
4
+
5
+ end
6
+ end
7
+ end
@@ -1,52 +1,52 @@
1
- module ChefProvisioningVsphereStubs
2
- class VsphereHelperStub < ChefProvisioningVsphere::VsphereHelper
3
- def initialize
4
- end
5
-
6
- def network_device_changes(action_handler, vm_template, options)
7
- [
8
- [RbVmomi::VIM::VirtualDeviceConfigSpec.new],
9
- [RbVmomi::VIM::VirtualDeviceConfigSpec.new]
10
- ]
11
- end
12
-
13
- def find_host(host_name)
14
- RbVmomi::VIM::HostSystem.new
15
- end
16
-
17
- def find_pool(pool_name)
18
- RbVmomi::VIM::ResourcePool.new(nil, nil)
19
- end
20
-
21
- def find_datastore(datastore_name)
22
- RbVmomi::VIM::Datastore.new
23
- end
24
-
25
- def find_customization_spec(options)
26
- RbVmomi::VIM::CustomizationSpec.new
27
- end
28
-
29
- def create_delta_disk(vm_template)
30
- end
31
- end
32
- end
33
-
34
- module RbVmomi
35
- class VIM::HostSystem
36
- attr_reader :parent
37
-
38
- def parent
39
- @parent ||= RbVmomi::VIM::ComputeResource.new
40
- end
41
- end
42
- end
43
-
44
- module RbVmomi
45
- class VIM::ComputeResource
46
- attr_reader :resourcePool
47
-
48
- def resourcePool
49
- @resourcePool ||= RbVmomi::VIM::ResourcePool.new(nil, nil)
50
- end
51
- end
52
- end
1
+ module ChefProvisioningVsphereStubs
2
+ class VsphereHelperStub < ChefProvisioningVsphere::VsphereHelper
3
+ def initialize
4
+ end
5
+
6
+ def network_device_changes(action_handler, vm_template, options)
7
+ [
8
+ [RbVmomi::VIM::VirtualDeviceConfigSpec.new],
9
+ [RbVmomi::VIM::VirtualDeviceConfigSpec.new]
10
+ ]
11
+ end
12
+
13
+ def find_host(host_name)
14
+ RbVmomi::VIM::HostSystem.new
15
+ end
16
+
17
+ def find_pool(pool_name)
18
+ RbVmomi::VIM::ResourcePool.new(nil, nil)
19
+ end
20
+
21
+ def find_datastore(datastore_name)
22
+ RbVmomi::VIM::Datastore.new
23
+ end
24
+
25
+ def find_customization_spec(options)
26
+ RbVmomi::VIM::CustomizationSpec.new
27
+ end
28
+
29
+ def create_delta_disk(vm_template)
30
+ end
31
+ end
32
+ end
33
+
34
+ module RbVmomi
35
+ class VIM::HostSystem
36
+ attr_reader :parent
37
+
38
+ def parent
39
+ @parent ||= RbVmomi::VIM::ComputeResource.new
40
+ end
41
+ end
42
+ end
43
+
44
+ module RbVmomi
45
+ class VIM::ComputeResource
46
+ attr_reader :resourcePool
47
+
48
+ def resourcePool
49
+ @resourcePool ||= RbVmomi::VIM::ResourcePool.new(nil, nil)
50
+ end
51
+ end
52
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: chef-provisioning-vsphere
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.2
4
+ version: 0.8.3.dev
5
5
  platform: ruby
6
6
  authors:
7
7
  - CenturyLink Cloud
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-12 00:00:00.000000000 Z
11
+ date: 2015-10-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rbvmomi
@@ -131,9 +131,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
131
131
  version: '0'
132
132
  required_rubygems_version: !ruby/object:Gem::Requirement
133
133
  requirements:
134
- - - ">="
134
+ - - ">"
135
135
  - !ruby/object:Gem::Version
136
- version: '0'
136
+ version: 1.3.1
137
137
  requirements: []
138
138
  rubyforge_project:
139
139
  rubygems_version: 2.4.8