vmware-vra 2.7.0 → 3.0.1
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/.gitignore +3 -1
- data/CHANGELOG.md +27 -1
- data/README.md +91 -141
- data/Rakefile +1 -12
- data/lib/vra/catalog.rb +39 -8
- data/lib/vra/catalog_base.rb +62 -0
- data/lib/vra/catalog_item.rb +29 -75
- data/lib/vra/catalog_source.rb +116 -0
- data/lib/vra/catalog_type.rb +56 -0
- data/lib/vra/client.rb +72 -53
- data/lib/vra/deployment.rb +155 -0
- data/lib/vra/deployment_request.rb +117 -0
- data/lib/vra/{resources.rb → deployments.rb} +26 -17
- data/lib/vra/exceptions.rb +2 -2
- data/lib/vra/http.rb +20 -7
- data/lib/vra/request.rb +28 -36
- data/lib/vra/request_parameters.rb +12 -10
- data/lib/vra/resource.rb +33 -203
- data/lib/vra/version.rb +2 -2
- data/lib/vra.rb +15 -12
- data/spec/catalog_item_spec.rb +64 -222
- data/spec/catalog_source_spec.rb +178 -0
- data/spec/catalog_spec.rb +112 -72
- data/spec/catalog_type_spec.rb +114 -0
- data/spec/client_spec.rb +287 -228
- data/spec/deployment_request_spec.rb +192 -0
- data/spec/deployment_spec.rb +227 -0
- data/spec/deployments_spec.rb +80 -0
- data/spec/fixtures/resource/sample_catalog_item.json +18 -0
- data/spec/fixtures/resource/sample_catalog_item_2.json +18 -0
- data/spec/fixtures/resource/sample_catalog_source.json +20 -0
- data/spec/fixtures/resource/sample_catalog_type.json +49 -0
- data/spec/fixtures/resource/sample_dep_actions.json +58 -0
- data/spec/fixtures/resource/sample_dep_request.json +19 -0
- data/spec/fixtures/resource/sample_dep_resource.json +112 -0
- data/spec/fixtures/resource/sample_deployment.json +26 -0
- data/spec/fixtures/resource/sample_entitlements.json +25 -0
- data/spec/http_spec.rb +63 -61
- data/spec/request_spec.rb +62 -68
- data/spec/resource_spec.rb +71 -390
- data/spec/spec_helper.rb +10 -4
- data/vmware-vra.gemspec +2 -4
- metadata +42 -32
- data/.travis.yml +0 -14
- data/lib/vra/catalog_request.rb +0 -127
- data/lib/vra/requests.rb +0 -41
- data/spec/catalog_request_spec.rb +0 -265
- data/spec/requests_spec.rb +0 -60
- data/spec/resources_spec.rb +0 -71
@@ -0,0 +1,192 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# Author:: Ashique Saidalavi (<ashique.saidalavi@progress.com>)
|
4
|
+
# Copyright:: Copyright (c) 2022 Chef Software, Inc.
|
5
|
+
# License:: Apache License, Version 2.0
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#
|
19
|
+
|
20
|
+
require 'spec_helper'
|
21
|
+
|
22
|
+
describe Vra::DeploymentRequest do
|
23
|
+
let(:client) do
|
24
|
+
Vra::Client.new(
|
25
|
+
username: 'user@corp.local',
|
26
|
+
password: 'password',
|
27
|
+
tenant: 'tenant',
|
28
|
+
base_url: 'https://vra.corp.local'
|
29
|
+
)
|
30
|
+
end
|
31
|
+
|
32
|
+
let(:catalog_id) { 'cat-123456' }
|
33
|
+
|
34
|
+
let(:request_payload) do
|
35
|
+
{
|
36
|
+
image_mapping: 'Centos Image',
|
37
|
+
name: 'test deployment',
|
38
|
+
flavor_mapping: 'Small',
|
39
|
+
version: '1',
|
40
|
+
project_id: 'pro-123'
|
41
|
+
}
|
42
|
+
end
|
43
|
+
|
44
|
+
describe '#initialize' do
|
45
|
+
it 'should raise errors for missing arguments' do
|
46
|
+
request = described_class.new(
|
47
|
+
client,
|
48
|
+
catalog_id,
|
49
|
+
request_payload
|
50
|
+
)
|
51
|
+
|
52
|
+
expect(request.name).to eq('test deployment')
|
53
|
+
expect(request.image_mapping).to eq('Centos Image')
|
54
|
+
expect(request.flavor_mapping).to eq('Small')
|
55
|
+
expect(request.version).to eq('1')
|
56
|
+
expect(request.count).to eq(1)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
describe '#validate!' do
|
61
|
+
it 'should return error if params are missing' do
|
62
|
+
request = described_class.new(client, catalog_id)
|
63
|
+
expect { request.send(:validate!) }.to raise_error(ArgumentError)
|
64
|
+
|
65
|
+
request.image_mapping = 'Centos Image'
|
66
|
+
request.name = 'test deployment'
|
67
|
+
request.flavor_mapping = 'Small'
|
68
|
+
request.version = '1'
|
69
|
+
request.project_id = 'pro-123'
|
70
|
+
|
71
|
+
expect { request.send(:validate!) }.not_to raise_error(ArgumentError)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe '#additional parameters' do
|
76
|
+
let(:request) do
|
77
|
+
described_class.new(client, catalog_id, request_payload)
|
78
|
+
end
|
79
|
+
|
80
|
+
context 'set_parameter' do
|
81
|
+
it 'should set the parameter' do
|
82
|
+
request.set_parameter('hardware-config', 'stirng', 'Small')
|
83
|
+
|
84
|
+
expect(request.parameters).to eq({ inputs: { 'hardware-config' => 'Small' } })
|
85
|
+
expect(request.parameters[:inputs].count).to be(1)
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
context 'set_parameters' do
|
90
|
+
it 'should be able to set multiple parameters' do
|
91
|
+
request.set_parameters('test-parent', { 'param1' => { type: 'string', value: 1234 } })
|
92
|
+
|
93
|
+
expect(request.parameters)
|
94
|
+
.to eq({ inputs: { 'test-parent' => { 'inputs' => { 'param1' => 1234 } } } })
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'should set multiple parameters with different data types' do
|
98
|
+
request.set_parameters('param1', { key1: { type: 'string', value: 'data' } })
|
99
|
+
request.set_parameters('param2', { key2: { type: 'boolean', value: false } })
|
100
|
+
request.set_parameters('param3', { key3: { type: 'integer', value: 100 } })
|
101
|
+
|
102
|
+
expect(request.parameters[:inputs].count).to be 3
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
context 'delete_parameter' do
|
107
|
+
before(:each) do
|
108
|
+
request.set_parameter('hardware-config', 'string', 'small')
|
109
|
+
end
|
110
|
+
|
111
|
+
it 'should delete the existing parameter' do
|
112
|
+
expect(request.parameters[:inputs].count).to be(1)
|
113
|
+
request.delete_parameter('hardware-config')
|
114
|
+
expect(request.parameters[:inputs].count).to be(0)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
context '#hash_parameters' do
|
119
|
+
it 'should have the correct representation' do
|
120
|
+
request.set_parameters(:param1, { key1: { type: 'string', value: 'data' } })
|
121
|
+
|
122
|
+
expect(request.hash_parameters).to eq({ param1: { :key1 => 'data' } })
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
describe '#submit' do
|
128
|
+
let(:request) do
|
129
|
+
described_class.new(client, catalog_id, request_payload)
|
130
|
+
end
|
131
|
+
|
132
|
+
before(:each) do
|
133
|
+
allow(client).to receive(:authorized?).and_return(true)
|
134
|
+
end
|
135
|
+
|
136
|
+
it 'should call the validate before submit' do
|
137
|
+
expect(request).to receive(:validate!)
|
138
|
+
stub_request(:post, client.full_url('/catalog/api/items/cat-123456/request'))
|
139
|
+
.to_return(status: 200, body: '[{"deploymentId": "123"}]', headers: {})
|
140
|
+
allow(Vra::Deployment).to receive(:new)
|
141
|
+
|
142
|
+
request.submit
|
143
|
+
end
|
144
|
+
|
145
|
+
it 'should call the api to submit the deployment request' do
|
146
|
+
response = double('response', body: '[{"deploymentId": "123"}]', success?: true)
|
147
|
+
allow(client)
|
148
|
+
.to receive(:http_post)
|
149
|
+
.with(
|
150
|
+
"/catalog/api/items/#{catalog_id}/request",
|
151
|
+
{
|
152
|
+
deploymentName: 'test deployment',
|
153
|
+
projectId: 'pro-123',
|
154
|
+
version: '1',
|
155
|
+
inputs: {
|
156
|
+
count: 1,
|
157
|
+
image: 'Centos Image',
|
158
|
+
flavor: 'Small'
|
159
|
+
}
|
160
|
+
}.to_json
|
161
|
+
)
|
162
|
+
.and_return(response)
|
163
|
+
allow(Vra::Deployment).to receive(:new)
|
164
|
+
|
165
|
+
request.submit
|
166
|
+
end
|
167
|
+
|
168
|
+
it 'should return a deployment object' do
|
169
|
+
response = double('response', body: '[{"deploymentId": "123"}]', success?: true)
|
170
|
+
allow(client).to receive(:http_post).and_return(response)
|
171
|
+
allow(client)
|
172
|
+
.to receive(:get_parsed)
|
173
|
+
.and_return(JSON.parse(File.read('spec/fixtures/resource/sample_deployment.json')))
|
174
|
+
|
175
|
+
dep = request.submit
|
176
|
+
expect(dep).to be_an_instance_of(Vra::Deployment)
|
177
|
+
expect(dep.id).to eq('123')
|
178
|
+
end
|
179
|
+
|
180
|
+
it 'should handle the VRA Errors' do
|
181
|
+
allow(request).to receive(:send_request!).and_raise(Vra::Exception::HTTPError)
|
182
|
+
|
183
|
+
expect { request.submit }.to raise_error(Vra::Exception::RequestError)
|
184
|
+
end
|
185
|
+
|
186
|
+
it 'should handle the generic errors' do
|
187
|
+
allow(request).to receive(:send_request!).and_raise(ArgumentError)
|
188
|
+
|
189
|
+
expect { request.submit }.to raise_error(ArgumentError)
|
190
|
+
end
|
191
|
+
end
|
192
|
+
end
|
@@ -0,0 +1,227 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# Author:: Ashique Saidalavi (<ashique.saidalavi@progress.com>)
|
4
|
+
# Copyright:: Copyright (c) 2022 Chef Software, Inc.
|
5
|
+
# License:: Apache License, Version 2.0
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#
|
19
|
+
|
20
|
+
require 'spec_helper'
|
21
|
+
|
22
|
+
describe ::Vra::Deployment do
|
23
|
+
let(:client) do
|
24
|
+
Vra::Client.new(
|
25
|
+
username: 'user@corp.local',
|
26
|
+
password: 'password',
|
27
|
+
tenant: 'tenant',
|
28
|
+
base_url: 'https://vra.corp.local'
|
29
|
+
)
|
30
|
+
end
|
31
|
+
|
32
|
+
let(:sample_data) do
|
33
|
+
JSON.parse(File.read('spec/fixtures/resource/sample_deployment.json'))
|
34
|
+
end
|
35
|
+
|
36
|
+
let(:deployment) do
|
37
|
+
described_class.new(client, data: sample_data)
|
38
|
+
end
|
39
|
+
|
40
|
+
before(:each) do
|
41
|
+
allow(client).to receive(:authorized?).and_return(true)
|
42
|
+
end
|
43
|
+
|
44
|
+
describe '#initialize' do
|
45
|
+
let(:deployment) do
|
46
|
+
described_class.allocate
|
47
|
+
end
|
48
|
+
|
49
|
+
before(:each) do
|
50
|
+
allow(client).to receive(:get_parsed).and_return(sample_data)
|
51
|
+
end
|
52
|
+
|
53
|
+
it 'should validate the attributes' do
|
54
|
+
expect(deployment).to receive(:validate!)
|
55
|
+
|
56
|
+
deployment.send(:initialize, client, id: 'dep-123')
|
57
|
+
end
|
58
|
+
|
59
|
+
it 'should fetch data when id is passed' do
|
60
|
+
deployment.send(:initialize, client, id: 'dep-123')
|
61
|
+
|
62
|
+
expect(deployment.send(:data)).not_to be_nil
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'should set id when data is passed' do
|
66
|
+
deployment.send(:initialize, client, data: sample_data)
|
67
|
+
|
68
|
+
expect(deployment.id).to eq('dep-123')
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
describe '#refresh' do
|
73
|
+
it 'should refresh the data correctly' do
|
74
|
+
expect(client).to receive(:get_parsed).and_return(sample_data)
|
75
|
+
|
76
|
+
deployment.refresh
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'should raise an exception if record not found' do
|
80
|
+
expect(client).to receive(:get_parsed).and_raise(Vra::Exception::HTTPNotFound)
|
81
|
+
|
82
|
+
expect { deployment.refresh }.to raise_error(Vra::Exception::NotFound)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
describe '#attributes' do
|
87
|
+
it 'should have the correct attributes' do
|
88
|
+
expect(deployment.name).to eq('win-DCI')
|
89
|
+
expect(deployment.description).to eq('win-dci deployment')
|
90
|
+
expect(deployment.org_id).to eq('origin-123')
|
91
|
+
expect(deployment.blueprint_id).to eq('blueprint-123')
|
92
|
+
expect(deployment.owner).to eq('administrator')
|
93
|
+
expect(deployment.status).to eq('CREATE_SUCCESSFUL')
|
94
|
+
expect(deployment.successful?).to be_truthy
|
95
|
+
expect(deployment.completed?).to be_truthy
|
96
|
+
expect(deployment.failed?).to be_falsey
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
describe '#requests' do
|
101
|
+
let(:request_data) do
|
102
|
+
JSON.parse(File.read('spec/fixtures/resource/sample_dep_request.json'))
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'should call the api to fetch the requests' do
|
106
|
+
expect(client)
|
107
|
+
.to receive(:get_parsed)
|
108
|
+
.with('/deployment/api/deployments/dep-123/requests')
|
109
|
+
.and_return({ 'content' => [request_data] })
|
110
|
+
|
111
|
+
deployment.requests
|
112
|
+
end
|
113
|
+
|
114
|
+
it 'should return the Vra::Request object' do
|
115
|
+
stub_request(:get, client.full_url('/deployment/api/deployments/dep-123/requests'))
|
116
|
+
.to_return(status: 200, body: { 'content' => [request_data] }.to_json, headers: {})
|
117
|
+
|
118
|
+
res = deployment.requests.first
|
119
|
+
expect(res).to be_an_instance_of(Vra::Request)
|
120
|
+
end
|
121
|
+
|
122
|
+
it 'should return the correct request data' do
|
123
|
+
allow(client)
|
124
|
+
.to receive(:get_parsed)
|
125
|
+
.with('/deployment/api/deployments/dep-123/requests')
|
126
|
+
.and_return({ 'content' => [request_data] })
|
127
|
+
|
128
|
+
res = deployment.requests.first
|
129
|
+
expect(res.status).to eq('SUCCESSFUL')
|
130
|
+
expect(res.name).to eq('Create')
|
131
|
+
expect(res.requested_by).to eq('admin')
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
describe '#resources' do
|
136
|
+
let(:resource_data) do
|
137
|
+
JSON.parse(File.read('spec/fixtures/resource/sample_dep_resource.json'))
|
138
|
+
end
|
139
|
+
|
140
|
+
it 'should call the api to fetch the resources' do
|
141
|
+
expect(client)
|
142
|
+
.to receive(:get_parsed)
|
143
|
+
.with('/deployment/api/deployments/dep-123/resources')
|
144
|
+
.and_return({ 'content' => [resource_data] })
|
145
|
+
|
146
|
+
res = deployment.resources.first
|
147
|
+
expect(res).to be_an_instance_of(Vra::Resource)
|
148
|
+
end
|
149
|
+
|
150
|
+
it 'should have the correct resource data' do
|
151
|
+
expect(client).to receive(:get_parsed).and_return({ 'content' => [resource_data] })
|
152
|
+
|
153
|
+
res = deployment.resources.first
|
154
|
+
expect(res.name).to eq('Cloud_vSphere_Machine_1')
|
155
|
+
expect(res.status).to eq('SUCCESS')
|
156
|
+
expect(res.vm?).to be_truthy
|
157
|
+
expect(res.owner_names).to eq('admin')
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
describe '#actions' do
|
162
|
+
let(:actions_data) do
|
163
|
+
JSON.parse(File.read('spec/fixtures/resource/sample_dep_actions.json'))
|
164
|
+
end
|
165
|
+
|
166
|
+
def action_req(action)
|
167
|
+
{
|
168
|
+
actionId: "Deployment.#{camelize(action)}",
|
169
|
+
inputs: {},
|
170
|
+
reason: "Testing the #{action}"
|
171
|
+
}.to_json
|
172
|
+
end
|
173
|
+
|
174
|
+
def action_response(action)
|
175
|
+
{
|
176
|
+
'id' => 'req-123',
|
177
|
+
'name' => camelize(action),
|
178
|
+
'requestedBy' => 'admin',
|
179
|
+
'blueprintId' => 'blueprint-123',
|
180
|
+
'inputs' => {
|
181
|
+
'flag' => 'false',
|
182
|
+
'count' => '1',
|
183
|
+
'hardware-config' => 'Medium'
|
184
|
+
},
|
185
|
+
'status' => 'SUCCESSFUL'
|
186
|
+
}.to_json
|
187
|
+
end
|
188
|
+
|
189
|
+
def camelize(action_name)
|
190
|
+
action_name.split('_').map(&:capitalize).join
|
191
|
+
end
|
192
|
+
|
193
|
+
it 'should call the api to fetch the actions' do
|
194
|
+
expect(client)
|
195
|
+
.to receive(:get_parsed)
|
196
|
+
.with('/deployment/api/deployments/dep-123/actions')
|
197
|
+
.and_return(actions_data)
|
198
|
+
|
199
|
+
actions = deployment.actions
|
200
|
+
expect(actions).to be_an_instance_of(Array)
|
201
|
+
end
|
202
|
+
|
203
|
+
it 'should return the correct actions' do
|
204
|
+
allow(client).to receive(:get_parsed).and_return(actions_data)
|
205
|
+
|
206
|
+
action_names = deployment.actions.map { |a| a['name'] }
|
207
|
+
expect(action_names).to eq(%w[ChangeLease ChangeOwner Delete EditTags PowerOff PowerOn Update])
|
208
|
+
end
|
209
|
+
|
210
|
+
{
|
211
|
+
destroy: 'delete',
|
212
|
+
power_on: 'power_on',
|
213
|
+
power_off: 'power_off'
|
214
|
+
}.each do |method, action|
|
215
|
+
it "should perform the action: #{action} correctly" do
|
216
|
+
allow(client).to receive(:get_parsed).and_return(actions_data)
|
217
|
+
stub_request(:post, client.full_url('/deployment/api/deployments/dep-123/requests'))
|
218
|
+
.with(body: action_req(action))
|
219
|
+
.to_return(status: 200, body: action_response(action), headers: {})
|
220
|
+
|
221
|
+
action_request = deployment.send(method, "Testing the #{action}")
|
222
|
+
expect(action_request).to be_an_instance_of(Vra::Request)
|
223
|
+
expect(action_request.name).to eq(camelize(action))
|
224
|
+
end
|
225
|
+
end
|
226
|
+
end
|
227
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
#
|
3
|
+
# Author:: Ashique Saidalavi (<ashique.saidalavi@progress.com>)
|
4
|
+
# Copyright:: Copyright (c) 2022 Chef Software, Inc.
|
5
|
+
# License:: Apache License, Version 2.0
|
6
|
+
#
|
7
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
8
|
+
# you may not use this file except in compliance with the License.
|
9
|
+
# You may obtain a copy of the License at
|
10
|
+
#
|
11
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
12
|
+
#
|
13
|
+
# Unless required by applicable law or agreed to in writing, software
|
14
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
15
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
|
+
# See the License for the specific language governing permissions and
|
17
|
+
# limitations under the License.
|
18
|
+
#
|
19
|
+
|
20
|
+
require 'spec_helper'
|
21
|
+
|
22
|
+
describe ::Vra::Deployments do
|
23
|
+
let(:client) do
|
24
|
+
Vra::Client.new(
|
25
|
+
username: 'user@corp.local',
|
26
|
+
password: 'password',
|
27
|
+
tenant: 'tenant',
|
28
|
+
base_url: 'https://vra.corp.local'
|
29
|
+
)
|
30
|
+
end
|
31
|
+
|
32
|
+
let(:deployment_response) do
|
33
|
+
JSON.parse(File.read('spec/fixtures/resource/sample_deployment.json'))
|
34
|
+
end
|
35
|
+
|
36
|
+
before(:each) do
|
37
|
+
allow(client).to receive(:authorized?).and_return(true)
|
38
|
+
end
|
39
|
+
|
40
|
+
describe '#by_id' do
|
41
|
+
it 'should call the api to fetch the deployments' do
|
42
|
+
expect(client).to receive(:get_parsed).and_return(deployment_response)
|
43
|
+
|
44
|
+
described_class.by_id(client, 'dep-123')
|
45
|
+
end
|
46
|
+
|
47
|
+
it 'should return the deployment by id' do
|
48
|
+
stub_request(:get, client.full_url('/deployment/api/deployments/dep-123'))
|
49
|
+
.to_return(status: 200, body: deployment_response.to_json, headers: {})
|
50
|
+
|
51
|
+
deployment = described_class.by_id(client, 'dep-123')
|
52
|
+
expect(deployment).to be_an_instance_of(Vra::Deployment)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
describe '#all' do
|
57
|
+
it 'should call the api to fetch all deployments' do
|
58
|
+
expect(client)
|
59
|
+
.to receive(:http_get_paginated_array!)
|
60
|
+
.with('/deployment/api/deployments')
|
61
|
+
.and_return([deployment_response])
|
62
|
+
|
63
|
+
described_class.all(client)
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'should return the Vra::Deployment object' do
|
67
|
+
stub_request(:get, client.full_url('/deployment/api/deployments?$skip=0&$top=20'))
|
68
|
+
.to_return(status: 200, body: { content: [deployment_response], totalPages: 1 }.to_json, headers: {})
|
69
|
+
|
70
|
+
deployment = described_class.all(client).first
|
71
|
+
expect(deployment).to be_an_instance_of(Vra::Deployment)
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
describe 'called with client' do
|
76
|
+
it 'should return the class object' do
|
77
|
+
expect(client.deployments).to be_an_instance_of described_class
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
{
|
2
|
+
"id": "123456",
|
3
|
+
"name": "centos",
|
4
|
+
"description": "Centos Cat",
|
5
|
+
"sourceId": "source-123456",
|
6
|
+
"sourceName": "Source 123",
|
7
|
+
"type": {
|
8
|
+
"id": "com.vmw.blueprint",
|
9
|
+
"link": "/catalog/api/types/com.vmw.blueprint",
|
10
|
+
"name": "VMware Cloud Templates"
|
11
|
+
},
|
12
|
+
"createdAt": "2021-10-07T14:41:57.691449Z",
|
13
|
+
"createdBy": "administrator",
|
14
|
+
"lastUpdatedAt": "2021-11-04T00:06:45.835597Z",
|
15
|
+
"lastUpdatedBy": "administrator",
|
16
|
+
"iconId": "1495b8d9",
|
17
|
+
"bulkRequestLimit": 1
|
18
|
+
}
|
@@ -0,0 +1,18 @@
|
|
1
|
+
{
|
2
|
+
"id": "654321",
|
3
|
+
"name": "Centos-80x64",
|
4
|
+
"description": "",
|
5
|
+
"sourceId": "pro-123456",
|
6
|
+
"sourceName": "Devops",
|
7
|
+
"type": {
|
8
|
+
"id": "com.vmw.blueprint",
|
9
|
+
"link": "/catalog/api/types/com.vmw.blueprint",
|
10
|
+
"name": "VMware Cloud Templates"
|
11
|
+
},
|
12
|
+
"createdAt": "2020-09-18T17:38:50.366691Z",
|
13
|
+
"createdBy": "administrator",
|
14
|
+
"lastUpdatedAt": "2021-12-15T00:18:34.706782Z",
|
15
|
+
"lastUpdatedBy": "administrator",
|
16
|
+
"iconId": "1ab82fe1",
|
17
|
+
"bulkRequestLimit": 1
|
18
|
+
}
|
@@ -0,0 +1,20 @@
|
|
1
|
+
{
|
2
|
+
"id": "123456",
|
3
|
+
"name": "Devops",
|
4
|
+
"typeId": "com.vmw.blueprint",
|
5
|
+
"createdAt": "2020-08-19T20:16:12.160353Z",
|
6
|
+
"createdBy": "administrator",
|
7
|
+
"lastUpdatedAt": "2021-12-29T12:49:32.186116Z",
|
8
|
+
"lastUpdatedBy": "system-user",
|
9
|
+
"config": {
|
10
|
+
"sourceProjectId": "pro-123456"
|
11
|
+
},
|
12
|
+
"itemsImported": 20,
|
13
|
+
"itemsFound": 20,
|
14
|
+
"lastImportStartedAt": "2021-12-29T12:49:30.638320Z",
|
15
|
+
"lastImportCompletedAt": "2021-12-29T12:49:32.185967Z",
|
16
|
+
"lastImportErrors": [],
|
17
|
+
"projectId": "pro-123456",
|
18
|
+
"global": false,
|
19
|
+
"iconId": "1495b8d9"
|
20
|
+
}
|
@@ -0,0 +1,49 @@
|
|
1
|
+
{
|
2
|
+
"id": "com.vmw.vro.workflow",
|
3
|
+
"name": "vRealize Orchestrator Workflow",
|
4
|
+
"baseUri": "https://vra.corp.local:8080/vro",
|
5
|
+
"createdBy": "vro-gateway-test",
|
6
|
+
"createdAt": "2020-08-04T22:37:14.295973Z",
|
7
|
+
"iconId": "0616ff81-c13b-32fe-b3b9-de3c2edd85dd",
|
8
|
+
"configSchema": {
|
9
|
+
"type": "object",
|
10
|
+
"properties": {
|
11
|
+
"workflows": {
|
12
|
+
"type": "array",
|
13
|
+
"items": {
|
14
|
+
"type": "object",
|
15
|
+
"properties": {
|
16
|
+
"id": {
|
17
|
+
"type": "string"
|
18
|
+
},
|
19
|
+
"name": {
|
20
|
+
"type": "string"
|
21
|
+
},
|
22
|
+
"version": {
|
23
|
+
"type": "string"
|
24
|
+
},
|
25
|
+
"description": {
|
26
|
+
"type": "string"
|
27
|
+
},
|
28
|
+
"integration": {
|
29
|
+
"type": "object",
|
30
|
+
"properties": {
|
31
|
+
"endpointConfigurationLink": {
|
32
|
+
"type": "string"
|
33
|
+
}
|
34
|
+
},
|
35
|
+
"required": [
|
36
|
+
"endpointConfigurationLink"
|
37
|
+
]
|
38
|
+
}
|
39
|
+
},
|
40
|
+
"required": [
|
41
|
+
"name",
|
42
|
+
"id",
|
43
|
+
"version"
|
44
|
+
]
|
45
|
+
}
|
46
|
+
}
|
47
|
+
}
|
48
|
+
}
|
49
|
+
}
|
@@ -0,0 +1,58 @@
|
|
1
|
+
[
|
2
|
+
{
|
3
|
+
"id": "Deployment.ChangeLease",
|
4
|
+
"name": "ChangeLease",
|
5
|
+
"displayName": "Change Lease",
|
6
|
+
"description": "Set a deployment's expiration date",
|
7
|
+
"valid": true,
|
8
|
+
"actionType": "RESOURCE_ACTION"
|
9
|
+
},
|
10
|
+
{
|
11
|
+
"id": "Deployment.ChangeOwner",
|
12
|
+
"name": "ChangeOwner",
|
13
|
+
"displayName": "Change Owner",
|
14
|
+
"description": "Change owner of a deployment",
|
15
|
+
"valid": true,
|
16
|
+
"actionType": "RESOURCE_ACTION"
|
17
|
+
},
|
18
|
+
{
|
19
|
+
"id": "Deployment.Delete",
|
20
|
+
"name": "Delete",
|
21
|
+
"displayName": "Delete",
|
22
|
+
"description": "Delete a deployment",
|
23
|
+
"valid": true,
|
24
|
+
"actionType": "RESOURCE_ACTION"
|
25
|
+
},
|
26
|
+
{
|
27
|
+
"id": "Deployment.EditTags",
|
28
|
+
"name": "EditTags",
|
29
|
+
"displayName": "Edit Tags",
|
30
|
+
"description": "Add or remove tags from a deployment's resources",
|
31
|
+
"valid": true,
|
32
|
+
"actionType": "RESOURCE_ACTION"
|
33
|
+
},
|
34
|
+
{
|
35
|
+
"id": "Deployment.PowerOff",
|
36
|
+
"name": "PowerOff",
|
37
|
+
"displayName": "Power Off",
|
38
|
+
"description": "Power off a deployment",
|
39
|
+
"valid": true,
|
40
|
+
"actionType": "RESOURCE_ACTION"
|
41
|
+
},
|
42
|
+
{
|
43
|
+
"id": "Deployment.PowerOn",
|
44
|
+
"name": "PowerOn",
|
45
|
+
"displayName": "Power On",
|
46
|
+
"description": "Power on a deployment",
|
47
|
+
"valid": false,
|
48
|
+
"actionType": "RESOURCE_ACTION"
|
49
|
+
},
|
50
|
+
{
|
51
|
+
"id": "Deployment.Update",
|
52
|
+
"name": "Update",
|
53
|
+
"displayName": "Update",
|
54
|
+
"description": "Update a deployment",
|
55
|
+
"valid": true,
|
56
|
+
"actionType": "RESOURCE_ACTION"
|
57
|
+
}
|
58
|
+
]
|
@@ -0,0 +1,19 @@
|
|
1
|
+
{
|
2
|
+
"id": "req-123",
|
3
|
+
"name": "Create",
|
4
|
+
"requestedBy": "admin",
|
5
|
+
"blueprintId": "blueprint-123",
|
6
|
+
"inputs": {
|
7
|
+
"flag": "false",
|
8
|
+
"count": "1",
|
9
|
+
"hardware-config": "Medium"
|
10
|
+
},
|
11
|
+
"status": "SUCCESSFUL",
|
12
|
+
"details": "",
|
13
|
+
"createdAt": "2021-12-20T13:21:52.699271Z",
|
14
|
+
"updatedAt": "2021-12-20T13:31:38.725363Z",
|
15
|
+
"totalTasks": 5,
|
16
|
+
"completedTasks": 5,
|
17
|
+
"dismissed": false,
|
18
|
+
"cancelable": true
|
19
|
+
}
|