vmware-vra 1.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,18 @@
1
+ {
2
+ "@type": "CatalogResource",
3
+ "id": "31a7badc-6562-458d-84f3-ec58d74a6953",
4
+ "resourceTypeRef": {
5
+ "id": "Infrastructure.Service",
6
+ "label": "Not a Virtual Machine"
7
+ },
8
+ "name": "hol-dev-12",
9
+ "status": "ACTIVE",
10
+ "organization": {
11
+ "tenantRef": "vsphere.local",
12
+ "tenantLabel": "vsphere.local",
13
+ "subtenantRef": "5327ddd3-1a4e-4663-9e9d-63db86ffc8af",
14
+ "subtenantLabel": "Rainpole Developers"
15
+ },
16
+ "resourceData": {
17
+ }
18
+ }
@@ -0,0 +1,246 @@
1
+ {
2
+ "@type": "CatalogResource",
3
+ "id": "31a7badc-6562-458d-84f3-ec58d74a6953",
4
+ "resourceTypeRef": {
5
+ "id": "Infrastructure.Virtual",
6
+ "label": "Virtual Machine"
7
+ },
8
+ "name": "hol-dev-11",
9
+ "status": "ACTIVE",
10
+ "organization": {
11
+ "tenantRef": "vsphere.local",
12
+ "tenantLabel": "vsphere.local",
13
+ "subtenantRef": "5327ddd3-1a4e-4663-9e9d-63db86ffc8af",
14
+ "subtenantLabel": "Rainpole Developers"
15
+ },
16
+ "operations": [
17
+ {
18
+ "name": "Change Lease",
19
+ "description": "Change the lease for a machine. Leave empty for indefinite.",
20
+ "iconId": "machineChangeLease.png",
21
+ "type": "ACTION",
22
+ "id": "50a50fde-2c8e-4122-acad-77cca348ae23",
23
+ "extensionId": null,
24
+ "providerTypeId": "com.vmware.csp.iaas.blueprint.service",
25
+ "bindingId": "Infrastructure.Machine.Action.ChangeLease",
26
+ "hasForm": true,
27
+ "formScale": "SMALL"
28
+ },
29
+ {
30
+ "name": "Connect to Remote Console",
31
+ "description": "Infrastructure connect using remote console",
32
+ "iconId": "cafe_default_icon_genericResourceOperation",
33
+ "type": "EXTENSION",
34
+ "id": "24c98f8e-6e9b-4f4e-b4df-460a29c80e1a",
35
+ "extensionId": "csp.places.iaas.item.window.ConnectViaVmrc",
36
+ "providerTypeId": null,
37
+ "bindingId": null,
38
+ "hasForm": false,
39
+ "formScale": null
40
+ },
41
+ {
42
+ "name": "Destroy",
43
+ "description": "Destroy a virtual machine.",
44
+ "iconId": "virtualDestroy.png",
45
+ "type": "ACTION",
46
+ "id": "ace8ba42-e724-48d8-9614-9b3a62b5a464",
47
+ "extensionId": null,
48
+ "providerTypeId": "com.vmware.csp.iaas.blueprint.service",
49
+ "bindingId": "Infrastructure.Virtual.Action.Destroy",
50
+ "hasForm": false,
51
+ "formScale": null
52
+ },
53
+ {
54
+ "name": "Expire",
55
+ "description": "Expire a machine.",
56
+ "iconId": "machineExpire.png",
57
+ "type": "ACTION",
58
+ "id": "34f354b5-4f09-495d-a553-646bbdc2d4b4",
59
+ "extensionId": null,
60
+ "providerTypeId": "com.vmware.csp.iaas.blueprint.service",
61
+ "bindingId": "Infrastructure.Machine.Action.Expire",
62
+ "hasForm": false,
63
+ "formScale": null
64
+ },
65
+ {
66
+ "name": "Install Tools",
67
+ "description": "Install tools on a machine.",
68
+ "iconId": "machineInstallTools.png",
69
+ "type": "ACTION",
70
+ "id": "2798f564-ba80-4e3a-b2c9-70aa686ed6a7",
71
+ "extensionId": null,
72
+ "providerTypeId": "com.vmware.csp.iaas.blueprint.service",
73
+ "bindingId": "Infrastructure.Machine.Action.InstallTools",
74
+ "hasForm": false,
75
+ "formScale": null
76
+ },
77
+ {
78
+ "name": "Power Cycle",
79
+ "description": "Reset a machine.",
80
+ "iconId": "machineReset.png",
81
+ "type": "ACTION",
82
+ "id": "9c1c2d9a-9ccc-46fc-bb5d-36632bdb3167",
83
+ "extensionId": null,
84
+ "providerTypeId": "com.vmware.csp.iaas.blueprint.service",
85
+ "bindingId": "Infrastructure.Machine.Action.Reset",
86
+ "hasForm": false,
87
+ "formScale": null
88
+ },
89
+ {
90
+ "name": "Power Off",
91
+ "description": "Power off a machine.",
92
+ "iconId": "machinePowerOff.png",
93
+ "type": "ACTION",
94
+ "id": "a391186c-7a3c-44fc-8d3d-3f5dcc269c85",
95
+ "extensionId": null,
96
+ "providerTypeId": "com.vmware.csp.iaas.blueprint.service",
97
+ "bindingId": "Infrastructure.Machine.Action.PowerOff",
98
+ "hasForm": false,
99
+ "formScale": null
100
+ },
101
+ {
102
+ "name": "Reboot",
103
+ "description": "Reboot a machine.",
104
+ "iconId": "machineReboot.png",
105
+ "type": "ACTION",
106
+ "id": "e71a9cae-7e8b-46a4-83fa-cfa4731669e4",
107
+ "extensionId": null,
108
+ "providerTypeId": "com.vmware.csp.iaas.blueprint.service",
109
+ "bindingId": "Infrastructure.Machine.Action.Reboot",
110
+ "hasForm": false,
111
+ "formScale": null
112
+ },
113
+ {
114
+ "name": "Reconfigure",
115
+ "description": "Reconfigure a machine.",
116
+ "iconId": "machineReconfigure.png",
117
+ "type": "ACTION",
118
+ "id": "1db5df1b-cb05-495d-a577-874b97af951e",
119
+ "extensionId": null,
120
+ "providerTypeId": "com.vmware.csp.iaas.blueprint.service",
121
+ "bindingId": "Infrastructure.Machine.Action.Reconfigure",
122
+ "hasForm": true,
123
+ "formScale": "BIG"
124
+ },
125
+ {
126
+ "name": "Reprovision",
127
+ "description": "Reprovision a machine.",
128
+ "iconId": "machineReprovision.png",
129
+ "type": "ACTION",
130
+ "id": "3ba6fdd8-d36b-48aa-8314-5437441fdea4",
131
+ "extensionId": null,
132
+ "providerTypeId": "com.vmware.csp.iaas.blueprint.service",
133
+ "bindingId": "Infrastructure.Machine.Action.Reprovision",
134
+ "hasForm": true,
135
+ "formScale": "BIG"
136
+ },
137
+ {
138
+ "name": "Shutdown",
139
+ "description": "Shutdown a machine.",
140
+ "iconId": "machineShutdown.png",
141
+ "type": "ACTION",
142
+ "id": "38231238-b979-43de-8697-1d61193e09c5",
143
+ "extensionId": null,
144
+ "providerTypeId": "com.vmware.csp.iaas.blueprint.service",
145
+ "bindingId": "Infrastructure.Machine.Action.Shutdown",
146
+ "hasForm": false,
147
+ "formScale": null
148
+ },
149
+ {
150
+ "name": "Suspend",
151
+ "description": "Suspend a machine.",
152
+ "iconId": "machineSuspend.png",
153
+ "type": "ACTION",
154
+ "id": "48e64dc6-f147-4977-94f7-4acfd4599b96",
155
+ "extensionId": null,
156
+ "providerTypeId": "com.vmware.csp.iaas.blueprint.service",
157
+ "bindingId": "Infrastructure.Machine.Action.Suspend",
158
+ "hasForm": false,
159
+ "formScale": null
160
+ }
161
+ ],
162
+ "resourceData": {
163
+ "entries": [
164
+ {
165
+ "key": "Expire",
166
+ "value": {
167
+ "type": "boolean",
168
+ "value": true
169
+ }
170
+ },
171
+ {
172
+ "key": "NETWORK_LIST",
173
+ "value": {
174
+ "type": "multiple",
175
+ "elementTypeId": "COMPLEX",
176
+ "items": [
177
+ {
178
+ "type": "complex",
179
+ "componentTypeId": "com.vmware.csp.component.iaas.proxy.provider",
180
+ "componentId": null,
181
+ "classId": "dynamicops.api.model.NetworkViewModel",
182
+ "typeFilter": null,
183
+ "values": {
184
+ "entries": [
185
+ {
186
+ "key": "NETWORK_ADDRESS",
187
+ "value": {
188
+ "type": "string",
189
+ "value": "192.168.110.200"
190
+ }
191
+ },
192
+ {
193
+ "key": "NETWORK_MAC_ADDRESS",
194
+ "value": {
195
+ "type": "string",
196
+ "value": "00:50:56:ae:95:3c"
197
+ }
198
+ },
199
+ {
200
+ "key": "NETWORK_NAME",
201
+ "value": {
202
+ "type": "string",
203
+ "value": "VM Network"
204
+ }
205
+ }
206
+ ]
207
+ }
208
+ },
209
+ {
210
+ "type": "complex",
211
+ "componentTypeId": "com.vmware.csp.component.iaas.proxy.provider",
212
+ "componentId": null,
213
+ "classId": "dynamicops.api.model.NetworkViewModel",
214
+ "typeFilter": null,
215
+ "values": {
216
+ "entries": [
217
+ {
218
+ "key": "NETWORK_ADDRESS",
219
+ "value": {
220
+ "type": "string",
221
+ "value": "192.168.220.200"
222
+ }
223
+ },
224
+ {
225
+ "key": "NETWORK_MAC_ADDRESS",
226
+ "value": {
227
+ "type": "string",
228
+ "value": "00:50:56:ae:95:3d"
229
+ }
230
+ },
231
+ {
232
+ "key": "NETWORK_NAME",
233
+ "value": {
234
+ "type": "string",
235
+ "value": "Management Network"
236
+ }
237
+ }
238
+ ]
239
+ }
240
+ }
241
+ ]
242
+ }
243
+ }
244
+ ]
245
+ }
246
+ }
@@ -0,0 +1,101 @@
1
+ {
2
+ "@type": "CatalogResource",
3
+ "id": "31a7badc-6562-458d-84f3-ec58d74a6953",
4
+ "resourceTypeRef": {
5
+ "id": "Infrastructure.Virtual",
6
+ "label": "Virtual Machine"
7
+ },
8
+ "name": "hol-dev-11",
9
+ "status": "ACTIVE",
10
+ "organization": {
11
+ "tenantRef": "vsphere.local",
12
+ "tenantLabel": "vsphere.local",
13
+ "subtenantRef": "5327ddd3-1a4e-4663-9e9d-63db86ffc8af",
14
+ "subtenantLabel": "Rainpole Developers"
15
+ },
16
+ "operations": null,
17
+ "resourceData": {
18
+ "entries": [
19
+ {
20
+ "key": "Expire",
21
+ "value": {
22
+ "type": "boolean",
23
+ "value": true
24
+ }
25
+ },
26
+ {
27
+ "key": "NETWORK_LIST",
28
+ "value": {
29
+ "type": "multiple",
30
+ "elementTypeId": "COMPLEX",
31
+ "items": [
32
+ {
33
+ "type": "complex",
34
+ "componentTypeId": "com.vmware.csp.component.iaas.proxy.provider",
35
+ "componentId": null,
36
+ "classId": "dynamicops.api.model.NetworkViewModel",
37
+ "typeFilter": null,
38
+ "values": {
39
+ "entries": [
40
+ {
41
+ "key": "NETWORK_ADDRESS",
42
+ "value": {
43
+ "type": "string",
44
+ "value": "192.168.110.200"
45
+ }
46
+ },
47
+ {
48
+ "key": "NETWORK_MAC_ADDRESS",
49
+ "value": {
50
+ "type": "string",
51
+ "value": "00:50:56:ae:95:3c"
52
+ }
53
+ },
54
+ {
55
+ "key": "NETWORK_NAME",
56
+ "value": {
57
+ "type": "string",
58
+ "value": "VM Network"
59
+ }
60
+ }
61
+ ]
62
+ }
63
+ },
64
+ {
65
+ "type": "complex",
66
+ "componentTypeId": "com.vmware.csp.component.iaas.proxy.provider",
67
+ "componentId": null,
68
+ "classId": "dynamicops.api.model.NetworkViewModel",
69
+ "typeFilter": null,
70
+ "values": {
71
+ "entries": [
72
+ {
73
+ "key": "NETWORK_ADDRESS",
74
+ "value": {
75
+ "type": "string",
76
+ "value": "192.168.220.200"
77
+ }
78
+ },
79
+ {
80
+ "key": "NETWORK_MAC_ADDRESS",
81
+ "value": {
82
+ "type": "string",
83
+ "value": "00:50:56:ae:95:3d"
84
+ }
85
+ },
86
+ {
87
+ "key": "NETWORK_NAME",
88
+ "value": {
89
+ "type": "string",
90
+ "value": "Management Network"
91
+ }
92
+ }
93
+ ]
94
+ }
95
+ }
96
+ ]
97
+ }
98
+ }
99
+ ]
100
+ }
101
+ }
@@ -0,0 +1,145 @@
1
+ #
2
+ # Author:: Chef Partner Engineering (<partnereng@chef.io>)
3
+ # Copyright:: Copyright (c) 2015 Chef Software, Inc.
4
+ # License:: Apache License, Version 2.0
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require 'spec_helper'
20
+
21
+ shared_examples 'refresh_trigger_method' do |method|
22
+ it 'calls #refresh_if_needed' do
23
+ expect(request).to receive(:refresh_if_empty)
24
+ request.send(method)
25
+ end
26
+
27
+ it 'returns nil if request data is empty' do
28
+ allow(request).to receive(:refresh_if_empty)
29
+ allow(request).to receive(:request_empty?).and_return true
30
+ expect(request.send(method)).to eq nil
31
+ end
32
+ end
33
+
34
+ describe Vra::Request do
35
+ let(:client) do
36
+ Vra::Client.new(username: 'user@corp.local',
37
+ password: 'password',
38
+ tenant: 'tenant',
39
+ base_url: 'https://vra.corp.local')
40
+ end
41
+
42
+ let(:request_id) { '2c3df007-b1c4-4687-b332-310089c4851d' }
43
+
44
+ let(:in_progress_payload) do
45
+ {
46
+ 'phase' => 'IN_PROGRESS',
47
+ 'requestCompletion' => {
48
+ 'requestCompletionState' => nil,
49
+ 'completionDetails' => nil
50
+ }
51
+ }
52
+ end
53
+
54
+ let(:completed_payload) do
55
+ {
56
+ 'phase' => 'SUCCESSFUL',
57
+ 'requestCompletion' => {
58
+ 'requestCompletionState' => 'SUCCESSFUL',
59
+ 'completionDetails' => 'Request succeeded. Created test-machine.'
60
+ }
61
+ }
62
+ end
63
+
64
+ let(:request) { Vra::Request.new(client, request_id) }
65
+
66
+ describe '#initialize' do
67
+ it 'sets the id' do
68
+ expect(request.id).to eq request_id
69
+ end
70
+ end
71
+
72
+ describe '#refresh' do
73
+ it 'calls the request API endpoint' do
74
+ expect(client).to receive(:http_get!)
75
+ .with("/catalog-service/api/consumer/requests/#{request_id}")
76
+ .and_return(in_progress_payload.to_json)
77
+
78
+ request.refresh
79
+ end
80
+ end
81
+
82
+ describe '#refresh_if_empty' do
83
+ context 'request data is empty' do
84
+ it 'calls #refresh' do
85
+ expect(request).to receive(:refresh)
86
+ request.refresh_if_empty
87
+ end
88
+ end
89
+
90
+ context 'request data is not empty' do
91
+ it 'does not call #refresh' do
92
+ allow(request).to receive(:request_empty?).and_return(false)
93
+ expect(request).to_not receive(:refresh)
94
+ end
95
+ end
96
+ end
97
+
98
+ describe '#status' do
99
+ it_behaves_like 'refresh_trigger_method', :status
100
+ end
101
+
102
+ describe '#completed?' do
103
+ context 'when the request is neither successful or failed yet' do
104
+ it 'returns false' do
105
+ allow(request).to receive(:successful?).and_return(false)
106
+ allow(request).to receive(:failed?).and_return(false)
107
+ expect(request.completed?).to eq false
108
+ end
109
+ end
110
+
111
+ context 'when the request is successful' do
112
+ it 'returns true' do
113
+ allow(request).to receive(:successful?).and_return(true)
114
+ allow(request).to receive(:failed?).and_return(false)
115
+ expect(request.completed?).to eq true
116
+ end
117
+ end
118
+
119
+ context 'when the request failed' do
120
+ it 'returns true' do
121
+ allow(request).to receive(:successful?).and_return(false)
122
+ allow(request).to receive(:failed?).and_return(true)
123
+ expect(request.completed?).to eq true
124
+ end
125
+ end
126
+ end
127
+
128
+ describe '#completion_state' do
129
+ it_behaves_like 'refresh_trigger_method', :completion_state
130
+ end
131
+
132
+ describe '#completion_details' do
133
+ it_behaves_like 'refresh_trigger_method', :completion_details
134
+ end
135
+
136
+ describe '#resources' do
137
+ it 'calls the requests resources API endpoint' do
138
+ expect(client).to receive(:http_get_paginated_array!)
139
+ .with("/catalog-service/api/consumer/requests/#{request_id}/resources")
140
+ .and_return([])
141
+
142
+ request.resources
143
+ end
144
+ end
145
+ end