vmware-vra 1.0.0.rc1 → 1.0.0.rc2
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.
- checksums.yaml +4 -4
- data/lib/vra/resource.rb +8 -0
- data/lib/vra/version.rb +1 -1
- data/spec/fixtures/resource/vm_resource.json +4 -0
- data/spec/resource_spec.rb +46 -40
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9a95564d2590ee0f93b6272ef8e8386eb13d663e
|
4
|
+
data.tar.gz: 84d7e4d120acc8fb7541d4182114c207b782022d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0775d7bb8f539da6bfe3aa9be13b9c17aa6cb1264eea321f5e7e41a5b36067c1fd74e0496ab36ee3318ef1769cf5e89ab003ca10b5d8358bcbb82ef128ea8047
|
7
|
+
data.tar.gz: 53355353cc910092bbd47ed48cf56c27c4399029f4dc9701a1335f7012387012db2416bb8c955de07d5d46dab4c032f88de9966acfb7cdc466d86310747b592f
|
data/lib/vra/resource.rb
CHANGED
@@ -86,6 +86,14 @@ module Vra
|
|
86
86
|
@resource_data['catalogItem']['label']
|
87
87
|
end
|
88
88
|
|
89
|
+
def owner_ids
|
90
|
+
@resource_data['owners'].map { |x| x['ref'] }
|
91
|
+
end
|
92
|
+
|
93
|
+
def owner_names
|
94
|
+
@resource_data['owners'].map { |x| x['value'] }
|
95
|
+
end
|
96
|
+
|
89
97
|
def network_interfaces
|
90
98
|
return unless vm?
|
91
99
|
|
data/lib/vra/version.rb
CHANGED
@@ -13,6 +13,10 @@
|
|
13
13
|
"subtenantRef": "5327ddd3-1a4e-4663-9e9d-63db86ffc8af",
|
14
14
|
"subtenantLabel": "Rainpole Developers"
|
15
15
|
},
|
16
|
+
"owners": [
|
17
|
+
{"tenantName": "vsphere.local", "ref": "user1@corp.local", "type": "USER", "value": "Joe User"},
|
18
|
+
{"tenantName": "vsphere.local", "ref": "user2@corp.local", "type": "USER", "value": "Jane User"}
|
19
|
+
],
|
16
20
|
"operations": [
|
17
21
|
{
|
18
22
|
"name": "Change Lease",
|
data/spec/resource_spec.rb
CHANGED
@@ -85,59 +85,69 @@ describe Vra::Resource do
|
|
85
85
|
end
|
86
86
|
|
87
87
|
context 'when a valid VM resource instance has been created' do
|
88
|
-
|
89
|
-
@resource = Vra::Resource.new(client, data: vm_payload)
|
90
|
-
end
|
88
|
+
let(:resource) { Vra::Resource.new(client, data: vm_payload) }
|
91
89
|
|
92
90
|
describe '#name' do
|
93
91
|
it 'returns the correct name' do
|
94
|
-
expect(
|
92
|
+
expect(resource.name).to eq 'hol-dev-11'
|
95
93
|
end
|
96
94
|
end
|
97
95
|
|
98
96
|
describe '#status' do
|
99
97
|
it 'returns the correct status' do
|
100
|
-
expect(
|
98
|
+
expect(resource.status).to eq 'ACTIVE'
|
101
99
|
end
|
102
100
|
end
|
103
101
|
|
104
102
|
describe '#vm?' do
|
105
103
|
it 'returns true for the VM resource we created' do
|
106
|
-
expect(
|
104
|
+
expect(resource.vm?).to be true
|
107
105
|
end
|
108
106
|
end
|
109
107
|
|
110
108
|
describe '#tenant_id' do
|
111
109
|
it 'returns the correct tenant ID' do
|
112
|
-
expect(
|
110
|
+
expect(resource.tenant_id).to eq 'vsphere.local'
|
113
111
|
end
|
114
112
|
end
|
115
113
|
|
116
114
|
describe '#tenant_name' do
|
117
115
|
it 'returns the correct tenant name' do
|
118
|
-
expect(
|
116
|
+
expect(resource.tenant_name).to eq 'vsphere.local'
|
119
117
|
end
|
120
118
|
end
|
121
119
|
|
122
120
|
describe '#subtenant_id' do
|
123
121
|
it 'returns the correct subtenant ID' do
|
124
|
-
expect(
|
122
|
+
expect(resource.subtenant_id).to eq '5327ddd3-1a4e-4663-9e9d-63db86ffc8af'
|
125
123
|
end
|
126
124
|
end
|
127
125
|
|
128
126
|
describe '#subtenant_name' do
|
129
127
|
it 'returns the correct subtenant name' do
|
130
|
-
expect(
|
128
|
+
expect(resource.subtenant_name).to eq 'Rainpole Developers'
|
129
|
+
end
|
130
|
+
end
|
131
|
+
|
132
|
+
describe '#owner_ids' do
|
133
|
+
it 'returns the correct owner IDs' do
|
134
|
+
expect(resource.owner_ids).to eq %w(user1@corp.local user2@corp.local)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
|
138
|
+
describe '#owner_names' do
|
139
|
+
it 'returns the correct owner names' do
|
140
|
+
expect(resource.owner_names).to eq [ 'Joe User', 'Jane User' ]
|
131
141
|
end
|
132
142
|
end
|
133
143
|
|
134
144
|
describe '#network_interfaces' do
|
135
145
|
it 'returns an array of 2 elements' do
|
136
|
-
expect(
|
146
|
+
expect(resource.network_interfaces.size).to be 2
|
137
147
|
end
|
138
148
|
|
139
149
|
it 'contains the correct data' do
|
140
|
-
nic1, nic2 =
|
150
|
+
nic1, nic2 = resource.network_interfaces
|
141
151
|
|
142
152
|
expect(nic1['NETWORK_NAME']).to eq 'VM Network'
|
143
153
|
expect(nic1['NETWORK_ADDRESS']).to eq '192.168.110.200'
|
@@ -151,58 +161,58 @@ describe Vra::Resource do
|
|
151
161
|
|
152
162
|
describe '#ip_addresses' do
|
153
163
|
it 'returns the correct IP addresses' do
|
154
|
-
expect(
|
164
|
+
expect(resource.ip_addresses).to eq [ '192.168.110.200', '192.168.220.200' ]
|
155
165
|
end
|
156
166
|
|
157
167
|
it 'returns nil if there are no network interfaces' do
|
158
|
-
allow(
|
159
|
-
expect(
|
168
|
+
allow(resource).to receive(:network_interfaces).and_return nil
|
169
|
+
expect(resource.ip_addresses).to be_nil
|
160
170
|
end
|
161
171
|
end
|
162
172
|
|
163
173
|
describe '#actions' do
|
164
174
|
it 'does not call #fetch_resource_data' do
|
165
|
-
expect(
|
166
|
-
|
175
|
+
expect(resource).not_to receive(:fetch_resource_data)
|
176
|
+
resource.actions
|
167
177
|
end
|
168
178
|
end
|
169
179
|
|
170
180
|
describe '#action_id_by_name' do
|
171
181
|
it 'returns the correct action ID for the destroy action' do
|
172
|
-
expect(
|
182
|
+
expect(resource.action_id_by_name('Destroy')).to eq 'ace8ba42-e724-48d8-9614-9b3a62b5a464'
|
173
183
|
end
|
174
184
|
|
175
185
|
it 'returns nil if there are no resource operations' do
|
176
|
-
allow(
|
177
|
-
expect(
|
186
|
+
allow(resource).to receive(:actions).and_return nil
|
187
|
+
expect(resource.action_id_by_name('Destroy')).to be_nil
|
178
188
|
end
|
179
189
|
|
180
190
|
it 'returns nil if there are actions, but none with the right name' do
|
181
|
-
allow(
|
182
|
-
expect(
|
191
|
+
allow(resource).to receive(:actions).and_return([ { 'name' => 'some action' }, { 'name' => 'another action' } ])
|
192
|
+
expect(resource.action_id_by_name('Destroy')).to be_nil
|
183
193
|
end
|
184
194
|
end
|
185
195
|
|
186
196
|
describe '#destroy' do
|
187
197
|
context 'when the destroy action is available' do
|
188
198
|
it 'calls gets the action ID and submits the request' do
|
189
|
-
expect(
|
190
|
-
expect(
|
191
|
-
|
199
|
+
expect(resource).to receive(:action_id_by_name).with('Destroy').and_return('action-123')
|
200
|
+
expect(resource).to receive(:submit_action_request).with('action-123')
|
201
|
+
resource.destroy
|
192
202
|
end
|
193
203
|
end
|
194
204
|
|
195
205
|
context 'when the destroy action is not available' do
|
196
206
|
it 'raises an exception' do
|
197
|
-
allow(
|
198
|
-
expect {
|
207
|
+
allow(resource).to receive(:action_id_by_name).and_return nil
|
208
|
+
expect { resource.destroy }.to raise_error(Vra::Exception::NotFound)
|
199
209
|
end
|
200
210
|
end
|
201
211
|
end
|
202
212
|
|
203
213
|
describe '#submit_action_request' do
|
204
214
|
before do
|
205
|
-
allow(
|
215
|
+
allow(resource).to receive(:action_request_payload).and_return({})
|
206
216
|
response = double('response', code: 200, headers: { location: '/requests/request-12345' })
|
207
217
|
allow(client).to receive(:http_post).with('/catalog-service/api/consumer/requests', '{}').and_return(response)
|
208
218
|
end
|
@@ -210,36 +220,32 @@ describe Vra::Resource do
|
|
210
220
|
it 'calls http_post' do
|
211
221
|
expect(client).to receive(:http_post).with('/catalog-service/api/consumer/requests', '{}')
|
212
222
|
|
213
|
-
|
223
|
+
resource.submit_action_request('action-123')
|
214
224
|
end
|
215
225
|
|
216
226
|
it 'returns a Vra::Request object' do
|
217
|
-
expect(
|
227
|
+
expect(resource.submit_action_request('action-123')).to be_an_instance_of(Vra::Request)
|
218
228
|
end
|
219
229
|
end
|
220
230
|
end
|
221
231
|
|
222
232
|
context 'when a valid VM resource instance with no operations is created' do
|
223
|
-
|
224
|
-
@resource = Vra::Resource.new(client, data: vm_payload_no_ops)
|
225
|
-
end
|
233
|
+
let(:resource) { Vra::Resource.new(client, data: vm_payload_no_ops) }
|
226
234
|
|
227
235
|
describe '#actions' do
|
228
236
|
it 'calls #fetch_resource_data' do
|
229
|
-
expect(
|
230
|
-
|
237
|
+
expect(resource).to receive(:fetch_resource_data)
|
238
|
+
resource.actions
|
231
239
|
end
|
232
240
|
end
|
233
241
|
end
|
234
242
|
|
235
243
|
context 'when a valid non-VM resource instance has been created' do
|
236
|
-
|
237
|
-
@resource = Vra::Resource.new(client, data: non_vm_payload)
|
238
|
-
end
|
244
|
+
let(:resource) { Vra::Resource.new(client, data: non_vm_payload) }
|
239
245
|
|
240
246
|
it 'returns nil for network_interfaces and ip_addresses' do
|
241
|
-
expect(
|
242
|
-
expect(
|
247
|
+
expect(resource.network_interfaces).to be_nil
|
248
|
+
expect(resource.ip_addresses).to be_nil
|
243
249
|
end
|
244
250
|
end
|
245
251
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vmware-vra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.rc2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Leff
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-07-
|
11
|
+
date: 2015-07-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|