vmware-vra 3.1.2 → 3.1.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/linters.yml +9 -0
- data/.markdownlint.yaml +5 -0
- data/.mdlrc +1 -0
- data/CHANGELOG.md +9 -0
- data/README.md +37 -26
- data/Rakefile +2 -2
- data/lib/vra/catalog.rb +6 -7
- data/lib/vra/catalog_base.rb +4 -4
- data/lib/vra/catalog_item.rb +12 -12
- data/lib/vra/catalog_source.rb +13 -13
- data/lib/vra/catalog_type.rb +6 -6
- data/lib/vra/client.rb +13 -13
- data/lib/vra/deployment.rb +21 -21
- data/lib/vra/deployment_request.rb +8 -9
- data/lib/vra/deployments.rb +1 -1
- data/lib/vra/http.rb +6 -6
- data/lib/vra/request.rb +6 -6
- data/lib/vra/request_parameters.rb +9 -9
- data/lib/vra/resource.rb +16 -16
- data/lib/vra/version.rb +1 -1
- data/lib/vra.rb +14 -14
- data/spec/catalog_item_spec.rb +50 -50
- data/spec/catalog_source_spec.rb +53 -53
- data/spec/catalog_spec.rb +45 -45
- data/spec/catalog_type_spec.rb +32 -32
- data/spec/client_spec.rb +202 -202
- data/spec/deployment_request_spec.rb +74 -74
- data/spec/deployment_spec.rb +70 -70
- data/spec/deployments_spec.rb +19 -19
- data/spec/http_spec.rb +59 -59
- data/spec/request_spec.rb +34 -34
- data/spec/resource_spec.rb +55 -55
- data/spec/spec_helper.rb +4 -4
- metadata +6 -6
- data/.github/ISSUE_TEMPLATE.md +0 -23
- data/.github/PULL_REQUEST_TEMPLATE.md +0 -14
- data/.github/workflows/unit.yml +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9f5265a1fb658c84986b019f01469ae9143300a5b0b36eda4825458ef28cc738
|
4
|
+
data.tar.gz: 638b354ab5cd83171f560e7eefcb53ebe4e773f3b7fc2b9ef5b7260fee5288fd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9c0e6ead2fc7eb2c8de12f87f5bcee61b7358f17061beb62f6f312521a4f29e2787d8018f22029c092aa86754c55c16918df13a457df304d48f6663d35d6f164
|
7
|
+
data.tar.gz: b425f0d3c34074720708d91ac06f6c1421e1e2020f786a02c903dbbce028df413eb16056e21995a3e34f9f5b01a3a9f93935287282d53e9607a33ffcff608e75
|
data/.markdownlint.yaml
ADDED
data/.mdlrc
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
rules "~MD036", "~MD013", "~MD024", "~MD029"
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## [3.1.3](https://github.com/test-kitchen/vmware-vra-gem/tree/v3.1.3) (2022-05-26)
|
4
|
+
|
5
|
+
- Use regular admin catalog endpoint to fetch catalog items
|
6
|
+
- Fixed the issue with multi-tenancy
|
7
|
+
- Fix chefstyle issues and optimise workflow
|
8
|
+
|
9
|
+
[Full Changelog](https://github.com/test-kitchen/vmware-vra-gem/compare/v3.1.2...v3.1.3)
|
10
|
+
|
3
11
|
|
4
12
|
## [3.1.2] (2022-03-28)
|
5
13
|
|
@@ -298,6 +306,7 @@
|
|
298
306
|
- Add support for Infrastructure.Cloud resources [\#15](https://github.com/test-kitchen/vmware-vra-gem/pull/15) ([adamleff](https://github.com/adamleff))
|
299
307
|
|
300
308
|
## [v1.4.0](https://github.com/test-kitchen/vmware-vra-gem/tree/v1.4.0) (2015-11-13)
|
309
|
+
|
301
310
|
[Full Changelog](https://github.com/test-kitchen/vmware-vra-gem/compare/v1.3.0...v1.4.0)
|
302
311
|
|
303
312
|
**Closed issues:**
|
data/README.md
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
# VMware vRA Gem
|
2
|
+
|
2
3
|
[![Gem Version](https://badge.fury.io/rb/vmware-vra.svg)](http://badge.fury.io/rb/vmware-vra)
|
3
4
|
|
4
5
|
Client gem for interacting with VMware's vRealize Automation application.
|
@@ -27,55 +28,60 @@ gem 'vmware-vra'
|
|
27
28
|
|
28
29
|
And then execute:
|
29
30
|
|
30
|
-
|
31
|
+
```shell
|
32
|
+
bundle
|
33
|
+
```
|
31
34
|
|
32
35
|
Or install it yourself as:
|
33
36
|
|
34
|
-
|
37
|
+
```shell
|
38
|
+
gem install vmware-vra
|
39
|
+
```
|
35
40
|
|
36
41
|
## Usage
|
37
42
|
|
38
43
|
First, load in the gem.
|
39
44
|
|
40
|
-
```
|
45
|
+
```shell
|
41
46
|
require 'vra'
|
42
47
|
=> true
|
43
48
|
```
|
44
49
|
|
45
50
|
Then, set up your client object. You will need to know your tenant ID from your vRA administrator.
|
46
51
|
|
47
|
-
```
|
52
|
+
```shell
|
48
53
|
client = Vra::Client.new(username: 'devmgr@corp.local', password: 'mypassword', tenant: 'mytenant', base_url: 'https://vra.corp.local', verify_ssl: true)
|
49
54
|
=> #<Vra::Client:0x000000034c0df8 ... >
|
50
55
|
```
|
51
|
-
|
56
|
+
|
57
|
+
### Catalog Types
|
52
58
|
|
53
59
|
To list all the catalog types:
|
54
60
|
|
55
|
-
```
|
61
|
+
```shell
|
56
62
|
client.catalog.all_types
|
57
63
|
=> [#<Vra::CatalogType:0x00007fcde6855370 @id="com.vmw.vro.workflow", @data={"id"=>"com.vmw.vro.workflow", ... ]
|
58
64
|
```
|
59
65
|
|
60
|
-
### Catalog Sources
|
66
|
+
### Catalog Sources
|
61
67
|
|
62
68
|
To list all the catalog sources:
|
63
69
|
|
64
|
-
```
|
70
|
+
```shell
|
65
71
|
client.catalog.all_sources
|
66
72
|
[#<Vra::CatalogSource:0x00007fcde3948c30 @id="2f5b2d5c-6dc2-4ea7-b304-cd8fea5ede0f", @data= ...]
|
67
73
|
```
|
68
74
|
|
69
75
|
And to list the sources that are entitled only:
|
70
76
|
|
71
|
-
```
|
77
|
+
```shell
|
72
78
|
client.catalog.entitled_sources(project_id)
|
73
79
|
=> [#<Vra::CatalogSource:0x00007fcde2a28c00 @id="18102dc2-9e48-487a-93a8-aafab2ecc05 ...]
|
74
80
|
```
|
75
81
|
|
76
82
|
Creating a new source can be done as follows:
|
77
83
|
|
78
|
-
```
|
84
|
+
```shell
|
79
85
|
source = Vra::CatalogSource.create(client, name: 'New source', catalog_type_id: 'com.vmw.vro.workflow', project_id: project_id)
|
80
86
|
=> #<Vra::CatalogSource:0x00007fad651f63b8 ... >
|
81
87
|
```
|
@@ -84,21 +90,21 @@ source = Vra::CatalogSource.create(client, name: 'New source', catalog_type_id:
|
|
84
90
|
|
85
91
|
To list all items in the catalog:
|
86
92
|
|
87
|
-
```
|
93
|
+
```shell
|
88
94
|
client.catalog.all_items
|
89
95
|
=> [#<Vra::CatalogItem:0x00007fe583863b28>, #<Vra::CatalogItem:0x00007fe583863ad8 ... ]
|
90
96
|
```
|
91
97
|
|
92
98
|
To only list the items in the catalog for which you are entitled to request:
|
93
99
|
|
94
|
-
```
|
100
|
+
```shell
|
95
101
|
client.catalog.entitled_items(project_id)
|
96
102
|
=> [#<Vra::CatalogItem:0x00007fe583863b28>, #<Vra::CatalogItem:0x00007fe583863ad8 ... ]
|
97
103
|
```
|
98
104
|
|
99
105
|
To retrive catalog id from catalog name:
|
100
106
|
|
101
|
-
```
|
107
|
+
```shell
|
102
108
|
client.catalog.fetch_catalog_items('centos')
|
103
109
|
=>
|
104
110
|
[#<Vra::CatalogItem:0x00007fb734110f60
|
@@ -110,9 +116,10 @@ client.catalog.fetch_catalog_items('centos')
|
|
110
116
|
```
|
111
117
|
|
112
118
|
### Requesting Deployments
|
119
|
+
|
113
120
|
When you are ready to request a deployment using a catalog, create a new deployment object:
|
114
121
|
|
115
|
-
```
|
122
|
+
```shell
|
116
123
|
request = client.catalog.request(
|
117
124
|
catalog_id,
|
118
125
|
image_mapping: 'VRA-nc-lnx-ce8.4-Docker',
|
@@ -125,16 +132,17 @@ request = client.catalog.request(
|
|
125
132
|
#<Vra::DeploymentRequest:0x00007fb7340b7438
|
126
133
|
...
|
127
134
|
```
|
135
|
+
|
128
136
|
To request a deployment from a catalog item, you can use the above method with a project ID that has a cloud template version released to the project.
|
129
137
|
|
130
138
|
The ID of the catalog item from which you are requesting the deployment should be also included, and the version of the released cloud template. If the user doesn't specify a version explicitly, the latest version will be fetched automatically and will be used for the request.
|
131
|
-
|
139
|
+
|
132
140
|
Additionally, the name of the deployment should be specified and it should be unique.
|
133
141
|
The image mapping specifies the OS image for a VM and the flavor mapping specifies the CPU count and RAM of a VM.
|
134
142
|
|
135
143
|
If your catalog blueprint item requires additional parameters to successfully submit your request, you may add them:
|
136
144
|
|
137
|
-
```
|
145
|
+
```shell
|
138
146
|
request.set_parameter('my_parameter', 'string', 'my value')
|
139
147
|
```
|
140
148
|
|
@@ -142,7 +150,7 @@ request.set_parameter('my_parameter', 'string', 'my value')
|
|
142
150
|
|
143
151
|
Now, submit your request! The client will return a new "Deployment" object you can use to query for status.
|
144
152
|
|
145
|
-
```
|
153
|
+
```shell
|
146
154
|
deployment = catalog_request.submit
|
147
155
|
=> #<Vra::Deployment:0x000000027caea0 ... >
|
148
156
|
|
@@ -152,14 +160,14 @@ deployment.status
|
|
152
160
|
|
153
161
|
You can refresh your deployment object to get the latest status:
|
154
162
|
|
155
|
-
```
|
163
|
+
```shell
|
156
164
|
deployment.refresh && deployment.status
|
157
165
|
=> "SUCCESSFUL"
|
158
166
|
```
|
159
167
|
|
160
168
|
You can also save the deployment ID for later, and create a new deployment object at your leisure to follow-up on your deployment request:
|
161
169
|
|
162
|
-
```
|
170
|
+
```shell
|
163
171
|
deployment.id
|
164
172
|
=> "aed22465-02db-481d-b55a-cefe216096a2"
|
165
173
|
|
@@ -171,9 +179,10 @@ new_deployment.status
|
|
171
179
|
```
|
172
180
|
|
173
181
|
### Deployment Resources
|
182
|
+
|
174
183
|
When the deployment request is successful, you can query the resources created as the result of your request. Assuming that the catalog item blueprint we requested only creates a single VM, we can get that resource and learn more information about it:
|
175
184
|
|
176
|
-
```
|
185
|
+
```shell
|
177
186
|
resource = deployment.resources.first
|
178
187
|
=> #<Vra::Resource:0x00000006772e68 ... >
|
179
188
|
|
@@ -189,7 +198,7 @@ resource.name
|
|
189
198
|
|
190
199
|
If you have the resource_id and the deployment object, you can fetch the resources details as follows
|
191
200
|
|
192
|
-
```
|
201
|
+
```shell
|
193
202
|
resource.id
|
194
203
|
=> "331fd10b-f2a2-40ae-86bc-1255c1ee9a6d"
|
195
204
|
|
@@ -202,10 +211,10 @@ new_resource.name
|
|
202
211
|
|
203
212
|
### Deleting a deployment from vRA
|
204
213
|
|
205
|
-
When you no longer need the VM, you can destroy the deployment which will delete all the associated resources as well.
|
214
|
+
When you no longer need the VM, you can destroy the deployment which will delete all the associated resources as well.
|
206
215
|
The method will return a request object you can query for status:
|
207
216
|
|
208
|
-
```
|
217
|
+
```shell
|
209
218
|
destroy_req = deployment.destroy
|
210
219
|
=> #<Vra::Request:0x00000006ea90d8 ... >
|
211
220
|
|
@@ -215,7 +224,7 @@ destroy_req.status
|
|
215
224
|
|
216
225
|
You can also list all resources and requests you have permission to see with these methods:
|
217
226
|
|
218
|
-
```
|
227
|
+
```shell
|
219
228
|
deployment.resources
|
220
229
|
deployment.requests
|
221
230
|
```
|
@@ -239,11 +248,13 @@ client.page_size = 100
|
|
239
248
|
To aid diagnosis of deep API issues, set the following environment variable to enable logging of all API requests. Note that this will include requests to retrieve the bearer token.
|
240
249
|
|
241
250
|
MacOS/Linux:
|
251
|
+
|
242
252
|
```ruby
|
243
253
|
export VRA_HTTP_TRACE=1
|
244
254
|
```
|
245
255
|
|
246
256
|
Windows:
|
257
|
+
|
247
258
|
```powershell
|
248
259
|
$env:VRA_HTTP_TRACE=1
|
249
260
|
```
|
@@ -259,7 +270,7 @@ License:: Apache License, Version 2.0
|
|
259
270
|
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
260
271
|
this file except in compliance with the License. You may obtain a copy of the License at
|
261
272
|
|
262
|
-
```
|
273
|
+
```text
|
263
274
|
http://www.apache.org/licenses/LICENSE-2.0
|
264
275
|
```
|
265
276
|
|
@@ -270,7 +281,7 @@ and limitations under the License.
|
|
270
281
|
|
271
282
|
## Contributing
|
272
283
|
|
273
|
-
1. Fork it ( https://github.com/[my-github-username]/vmware-vra-gem/fork )
|
284
|
+
1. Fork it ( <https://github.com/[my-github-username]/vmware-vra-gem/fork> )
|
274
285
|
2. Create your feature branch (`git checkout -b my-new-feature`)
|
275
286
|
3. Commit your changes (`git commit -am 'Add some feature'`)
|
276
287
|
4. Push to the branch (`git push origin my-new-feature`)
|
data/Rakefile
CHANGED
@@ -4,9 +4,9 @@ require "rspec/core/rake_task"
|
|
4
4
|
require "chefstyle"
|
5
5
|
require "rubocop/rake_task"
|
6
6
|
|
7
|
-
RSpec::Core::RakeTask.new(:
|
7
|
+
RSpec::Core::RakeTask.new(:test)
|
8
8
|
RuboCop::RakeTask.new do |task|
|
9
9
|
task.options << "--display-cop-names"
|
10
10
|
end
|
11
11
|
|
12
|
-
task default: %i{
|
12
|
+
task default: %i{test rubocop}
|
data/lib/vra/catalog.rb
CHANGED
@@ -15,7 +15,6 @@
|
|
15
15
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
16
16
|
# See the License for the specific language governing permissions and
|
17
17
|
# limitations under the License.
|
18
|
-
#
|
19
18
|
|
20
19
|
module Vra
|
21
20
|
class Catalog
|
@@ -38,11 +37,11 @@ module Vra
|
|
38
37
|
end
|
39
38
|
|
40
39
|
def entitled_sources(project_id)
|
41
|
-
fetch_entitlements(project_id,
|
40
|
+
fetch_entitlements(project_id, "CatalogSourceIdentifier")
|
42
41
|
end
|
43
42
|
|
44
43
|
def entitled_items(project_id)
|
45
|
-
fetch_entitlements(project_id,
|
44
|
+
fetch_entitlements(project_id, "CatalogItemIdentifier")
|
46
45
|
end
|
47
46
|
|
48
47
|
def request(*args)
|
@@ -52,7 +51,7 @@ module Vra
|
|
52
51
|
def fetch_catalog_items(catalog_name)
|
53
52
|
fetch_resources(
|
54
53
|
Vra::CatalogItem,
|
55
|
-
|
54
|
+
"/catalog/api/items",
|
56
55
|
"search=#{catalog_name}"
|
57
56
|
)
|
58
57
|
end
|
@@ -66,12 +65,12 @@ module Vra
|
|
66
65
|
end
|
67
66
|
|
68
67
|
def fetch_entitlements(project_id, type)
|
69
|
-
klass = type ==
|
68
|
+
klass = type == "CatalogSourceIdentifier" ? Vra::CatalogSource : Vra::CatalogItem
|
70
69
|
|
71
70
|
client
|
72
71
|
.get_parsed("/catalog/api/admin/entitlements?projectId=#{project_id}")
|
73
|
-
.select { |x| x[
|
74
|
-
.map! { |x| klass.new(client, data: x[
|
72
|
+
.select { |x| x["definition"]["type"] == type }
|
73
|
+
.map! { |x| klass.new(client, data: x["definition"]) }
|
75
74
|
end
|
76
75
|
end
|
77
76
|
end
|
data/lib/vra/catalog_base.rb
CHANGED
@@ -45,8 +45,8 @@ module Vra
|
|
45
45
|
attr_reader :client, :data
|
46
46
|
|
47
47
|
def validate!
|
48
|
-
raise ArgumentError,
|
49
|
-
raise ArgumentError,
|
48
|
+
raise ArgumentError, "must supply id or data hash" if @id.nil? && @data.nil?
|
49
|
+
raise ArgumentError, "must supply id or data hash, not both" if !@id.nil? && !@data.nil?
|
50
50
|
end
|
51
51
|
|
52
52
|
def entitle_params(type)
|
@@ -54,8 +54,8 @@ module Vra
|
|
54
54
|
'projectId': project_id,
|
55
55
|
'definition': {
|
56
56
|
'type': type,
|
57
|
-
'id': id
|
58
|
-
}
|
57
|
+
'id': id,
|
58
|
+
},
|
59
59
|
}
|
60
60
|
end
|
61
61
|
end
|
data/lib/vra/catalog_item.rb
CHANGED
@@ -23,7 +23,7 @@ require "vra/catalog"
|
|
23
23
|
module Vra
|
24
24
|
# Class that represents the Catalog Item
|
25
25
|
class CatalogItem < Vra::CatalogBase
|
26
|
-
INDEX_URL =
|
26
|
+
INDEX_URL = "/catalog/api/items"
|
27
27
|
|
28
28
|
attr_reader :project_id
|
29
29
|
|
@@ -35,30 +35,30 @@ module Vra
|
|
35
35
|
if @data.nil?
|
36
36
|
fetch_catalog_item
|
37
37
|
else
|
38
|
-
@id = @data[
|
38
|
+
@id = @data["id"]
|
39
39
|
end
|
40
40
|
end
|
41
41
|
|
42
42
|
def fetch_catalog_item
|
43
|
-
@data = client.get_parsed("/catalog/api/
|
43
|
+
@data = client.get_parsed("/catalog/api/items/#{id}")
|
44
44
|
rescue Vra::Exception::HTTPNotFound
|
45
45
|
raise Vra::Exception::NotFound, "catalog ID #{id} does not exist"
|
46
46
|
end
|
47
47
|
|
48
48
|
def name
|
49
|
-
data[
|
49
|
+
data["name"]
|
50
50
|
end
|
51
51
|
|
52
52
|
def description
|
53
|
-
data[
|
53
|
+
data["description"]
|
54
54
|
end
|
55
55
|
|
56
56
|
def source_id
|
57
|
-
data[
|
57
|
+
data["sourceId"]
|
58
58
|
end
|
59
59
|
|
60
60
|
def source_name
|
61
|
-
data[
|
61
|
+
data["sourceName"]
|
62
62
|
end
|
63
63
|
|
64
64
|
def source
|
@@ -66,21 +66,21 @@ module Vra
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def type
|
69
|
-
@type ||= Vra::CatalogType.new(client, data: data[
|
69
|
+
@type ||= Vra::CatalogType.new(client, data: data["type"])
|
70
70
|
end
|
71
71
|
|
72
72
|
def icon_id
|
73
|
-
data[
|
73
|
+
data["iconId"]
|
74
74
|
end
|
75
75
|
|
76
76
|
def versions
|
77
77
|
client
|
78
78
|
.http_get_paginated_array!("/catalog/api/items/#{id}/versions")
|
79
|
-
.map { |v| v[
|
79
|
+
.map { |v| v["id"] }
|
80
80
|
end
|
81
81
|
|
82
82
|
def entitle!(opts = {})
|
83
|
-
super(opts.merge(type:
|
83
|
+
super(opts.merge(type: "CatalogItemIdentifier"))
|
84
84
|
end
|
85
85
|
|
86
86
|
class << self
|
@@ -89,7 +89,7 @@ module Vra
|
|
89
89
|
end
|
90
90
|
|
91
91
|
def fetch_latest_version(client, id)
|
92
|
-
new(client, data: {
|
92
|
+
new(client, data: { "id" => id }).versions&.first
|
93
93
|
end
|
94
94
|
end
|
95
95
|
end
|
data/lib/vra/catalog_source.rb
CHANGED
@@ -16,12 +16,12 @@
|
|
16
16
|
# See the License for the specific language governing permissions and
|
17
17
|
# limitations under the License.
|
18
18
|
#
|
19
|
-
require
|
19
|
+
require "ffi_yajl" unless defined?(FFI_Yajl)
|
20
20
|
|
21
21
|
module Vra
|
22
22
|
# Class that represents the Catalog Source
|
23
23
|
class CatalogSource < Vra::CatalogBase
|
24
|
-
INDEX_URL =
|
24
|
+
INDEX_URL = "/catalog/api/admin/sources"
|
25
25
|
|
26
26
|
# @param client [Vra::Client] - a vra client object
|
27
27
|
# @param opts [Hash] - Contains the either id of the catalog or the data hash
|
@@ -33,11 +33,11 @@ module Vra
|
|
33
33
|
end
|
34
34
|
|
35
35
|
def name
|
36
|
-
data[
|
36
|
+
data["name"]
|
37
37
|
end
|
38
38
|
|
39
39
|
def catalog_type_id
|
40
|
-
data[
|
40
|
+
data["typeId"]
|
41
41
|
end
|
42
42
|
|
43
43
|
def catalog_type
|
@@ -45,19 +45,19 @@ module Vra
|
|
45
45
|
end
|
46
46
|
|
47
47
|
def config
|
48
|
-
data[
|
48
|
+
data["config"]
|
49
49
|
end
|
50
50
|
|
51
51
|
def global?
|
52
|
-
data[
|
52
|
+
data["global"] == true
|
53
53
|
end
|
54
54
|
|
55
55
|
def project_id
|
56
|
-
config[
|
56
|
+
config["sourceProjectId"]
|
57
57
|
end
|
58
58
|
|
59
59
|
def entitle!(opts = {})
|
60
|
-
super(opts.merge(type:
|
60
|
+
super(opts.merge(type: "CatalogSourceIdentifier"))
|
61
61
|
end
|
62
62
|
|
63
63
|
class << self
|
@@ -66,7 +66,7 @@ module Vra
|
|
66
66
|
validate_create!(opts)
|
67
67
|
|
68
68
|
response = client.http_post(
|
69
|
-
|
69
|
+
"/catalog/api/admin/sources",
|
70
70
|
FFI_Yajl::Encoder.encode(create_params(opts)),
|
71
71
|
opts[:skip_auth] || false
|
72
72
|
)
|
@@ -83,7 +83,7 @@ module Vra
|
|
83
83
|
private
|
84
84
|
|
85
85
|
def validate_create!(opts)
|
86
|
-
%i
|
86
|
+
%i{name catalog_type_id project_id}.each do |arg|
|
87
87
|
raise ArgumentError, "#{arg} param is required to perform the create action" unless opts.key?(arg)
|
88
88
|
end
|
89
89
|
end
|
@@ -93,8 +93,8 @@ module Vra
|
|
93
93
|
'name': opts[:name],
|
94
94
|
'typeId': opts[:catalog_type_id],
|
95
95
|
'config': {
|
96
|
-
'sourceProjectId': opts[:project_id]
|
97
|
-
}
|
96
|
+
'sourceProjectId': opts[:project_id],
|
97
|
+
},
|
98
98
|
}
|
99
99
|
end
|
100
100
|
end
|
@@ -104,7 +104,7 @@ module Vra
|
|
104
104
|
def fetch_data
|
105
105
|
fetch_catalog_data && return if data.nil?
|
106
106
|
|
107
|
-
@id = data[
|
107
|
+
@id = data["id"]
|
108
108
|
end
|
109
109
|
|
110
110
|
def fetch_catalog_data
|
data/lib/vra/catalog_type.rb
CHANGED
@@ -19,7 +19,7 @@
|
|
19
19
|
module Vra
|
20
20
|
# Class that represents the Catalog Type
|
21
21
|
class CatalogType < Vra::CatalogBase
|
22
|
-
INDEX_URL =
|
22
|
+
INDEX_URL = "/catalog/api/types"
|
23
23
|
|
24
24
|
def initialize(client, opts = {})
|
25
25
|
super
|
@@ -28,25 +28,25 @@ module Vra
|
|
28
28
|
end
|
29
29
|
|
30
30
|
def name
|
31
|
-
data[
|
31
|
+
data["name"]
|
32
32
|
end
|
33
33
|
|
34
34
|
def base_url
|
35
|
-
data[
|
35
|
+
data["baseUri"]
|
36
36
|
end
|
37
37
|
|
38
38
|
def config_schema
|
39
|
-
data[
|
39
|
+
data["configSchema"]
|
40
40
|
end
|
41
41
|
|
42
42
|
def icon_id
|
43
|
-
data[
|
43
|
+
data["iconId"]
|
44
44
|
end
|
45
45
|
|
46
46
|
private
|
47
47
|
|
48
48
|
def fetch_data
|
49
|
-
@id = data[
|
49
|
+
@id = data["id"] and return unless data.nil?
|
50
50
|
|
51
51
|
@data = client.get_parsed("/catalog/api/types/#{id}")
|
52
52
|
rescue Vra::Exception::HTTPNotFound
|
data/lib/vra/client.rb
CHANGED
@@ -17,15 +17,15 @@
|
|
17
17
|
# limitations under the License.
|
18
18
|
#
|
19
19
|
|
20
|
-
require
|
21
|
-
require
|
22
|
-
require
|
20
|
+
require "ffi_yajl" unless defined?(FFI_Yajl)
|
21
|
+
require "passwordmasker"
|
22
|
+
require "vra/http"
|
23
23
|
|
24
24
|
module Vra
|
25
25
|
class Client
|
26
|
-
REFRESH_TOKEN_URL =
|
27
|
-
ACCESS_TOKEN_URL =
|
28
|
-
ROLES_URL =
|
26
|
+
REFRESH_TOKEN_URL = "/csp/gateway/am/api/login?access_token"
|
27
|
+
ACCESS_TOKEN_URL = "/iaas/api/login"
|
28
|
+
ROLES_URL = "/csp/gateway/am/api/loggedin/user/orgs"
|
29
29
|
|
30
30
|
attr_accessor :page_size
|
31
31
|
|
@@ -80,15 +80,15 @@ module Vra
|
|
80
80
|
{
|
81
81
|
'username': @username,
|
82
82
|
'password': @password.value,
|
83
|
-
'
|
83
|
+
'domain': @tenant,
|
84
84
|
}
|
85
85
|
end
|
86
86
|
|
87
87
|
def request_headers
|
88
88
|
headers = {}
|
89
|
-
headers[
|
90
|
-
headers[
|
91
|
-
headers[
|
89
|
+
headers["Accept"] = "application/json"
|
90
|
+
headers["Content-Type"] = "application/json"
|
91
|
+
headers["Authorization"] = "Bearer " + @access_token.value unless @access_token.value.nil?
|
92
92
|
|
93
93
|
headers
|
94
94
|
end
|
@@ -96,7 +96,7 @@ module Vra
|
|
96
96
|
def authorize!
|
97
97
|
generate_access_token unless authorized?
|
98
98
|
|
99
|
-
raise Vra::Exception::Unauthorized,
|
99
|
+
raise Vra::Exception::Unauthorized, "Unable to authorize against vRA" unless authorized?
|
100
100
|
end
|
101
101
|
|
102
102
|
def authorized?
|
@@ -119,14 +119,14 @@ module Vra
|
|
119
119
|
raise Vra::Exception::Unauthorized, "Unable to get the refresh token: #{refresh_response.body}" unless refresh_response.success_ok?
|
120
120
|
|
121
121
|
refresh_response_body = FFI_Yajl::Parser.parse(refresh_response.body)
|
122
|
-
@refresh_token.value = refresh_response_body[
|
122
|
+
@refresh_token.value = refresh_response_body["refresh_token"]
|
123
123
|
|
124
124
|
# Second Step: Sending the refresh token to a separate endpoint to get an Access Token
|
125
125
|
access_response = http_post(ACCESS_TOKEN_URL, "{ \"refreshToken\": \"#{@refresh_token.value}\" }", :skip_auth)
|
126
126
|
raise Vra::Exception::Unauthorized, "Unable to get the access token: #{access_response.body}" unless access_response.success_ok?
|
127
127
|
|
128
128
|
access_response_body = FFI_Yajl::Parser.parse(access_response.body)
|
129
|
-
@access_token.value = access_response_body[
|
129
|
+
@access_token.value = access_response_body["token"]
|
130
130
|
end
|
131
131
|
|
132
132
|
def full_url(path)
|