vmware-vra 2.7.1 → 2.7.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -1
- data/README.md +1 -0
- data/Rakefile +1 -1
- data/lib/vra/catalog.rb +2 -2
- data/lib/vra/catalog_item.rb +2 -2
- data/lib/vra/catalog_request.rb +7 -4
- data/lib/vra/client.rb +2 -1
- data/lib/vra/exceptions.rb +1 -1
- data/lib/vra/http.rb +7 -4
- data/lib/vra/request.rb +1 -1
- data/lib/vra/resource.rb +2 -1
- data/lib/vra/version.rb +1 -1
- data/spec/catalog_item_spec.rb +9 -9
- data/spec/catalog_request_spec.rb +2 -2
- data/spec/client_spec.rb +2 -2
- data/spec/http_spec.rb +2 -2
- data/spec/resources_spec.rb +2 -2
- data/vmware-vra.gemspec +2 -3
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 748935ab6ce2c1922e5ffded2a7d2567709308e4c62bfe81d15d22b71a186508
|
4
|
+
data.tar.gz: 95b4943dc8f6015055e4a7c142115a8f555072c79244c4a62fed2e0e1862c8ac
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4b244e271a780513e497356114eff2ca721cf7fe2665d1fe6cbb10a500284b7702b53679a3c3aa19bd18727f6064ee6f2cb17fe38e5685e29716667b4d3cf25f
|
7
|
+
data.tar.gz: 8f1bd967dc41e4ed9363ae6404c402bdbb4524689d05d86a37c56e1d86f31efa374018108c5ebeef582972d15151391a25c7856621f0eeca33331c84b3846c3c
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## [2.7.2](https://github.com/chef-partners/vmware-vra-gem/tree/v2.7.2) (2020-09-09)
|
4
|
+
[Full Changelog](https://github.com/chef-partners/vmware-vra-gem/compare/v2.7.1...v2.7.2)
|
5
|
+
|
6
|
+
- Added an extra option to handle shirt size parameter
|
7
|
+
- Masking user credentials(password) in debug mode
|
8
|
+
|
3
9
|
## [2.7.1](https://github.com/chef-partners/vmware-vra-gem/tree/v2.7.1) (2019-05-28)
|
4
10
|
[Full Changelog](https://github.com/chef-partners/vmware-vra-gem/compare/v2.7.0...v2.7.1)
|
5
11
|
|
@@ -298,4 +304,4 @@
|
|
298
304
|
|
299
305
|
|
300
306
|
|
301
|
-
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
|
307
|
+
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
|
data/README.md
CHANGED
@@ -162,6 +162,7 @@ request_options = {
|
|
162
162
|
# create the request
|
163
163
|
catalog_request = vra.catalog.request(blueprint, request_options)
|
164
164
|
```
|
165
|
+
In the above option instead of cpus and memory, shirt_size can be used as well if the blueprint has shirt size option enabled. e.g. of shirt size can be like value.small, value.medium etc,
|
165
166
|
|
166
167
|
Now, submit your request! The client will return a new "Request" object you can use to query for status.
|
167
168
|
|
data/Rakefile
CHANGED
data/lib/vra/catalog.rb
CHANGED
@@ -27,12 +27,12 @@ module Vra
|
|
27
27
|
|
28
28
|
def all_items
|
29
29
|
client.http_get_paginated_array!("/catalog-service/api/consumer/catalogItems")
|
30
|
-
|
30
|
+
.map! { |x| Vra::CatalogItem.new(client, data: x) }
|
31
31
|
end
|
32
32
|
|
33
33
|
def entitled_items
|
34
34
|
client.http_get_paginated_array!("/catalog-service/api/consumer/entitledCatalogItems")
|
35
|
-
|
35
|
+
.map! { |x| Vra::CatalogItem.new(client, data: x["catalogItem"]) }
|
36
36
|
end
|
37
37
|
|
38
38
|
def request(*args)
|
data/lib/vra/catalog_item.rb
CHANGED
@@ -17,7 +17,7 @@
|
|
17
17
|
# limitations under the License.
|
18
18
|
#
|
19
19
|
|
20
|
-
require "ffi_yajl"
|
20
|
+
require "ffi_yajl" unless defined?(FFI_Yajl)
|
21
21
|
require "vra/catalog"
|
22
22
|
|
23
23
|
module Vra
|
@@ -107,7 +107,7 @@ module Vra
|
|
107
107
|
data = JSON.parse(contents)
|
108
108
|
pretty_contents = JSON.pretty_generate(data)
|
109
109
|
File.write(filename, pretty_contents)
|
110
|
-
|
110
|
+
filename
|
111
111
|
rescue Vra::Exception::HTTPError => e
|
112
112
|
raise e
|
113
113
|
end
|
data/lib/vra/catalog_request.rb
CHANGED
@@ -29,13 +29,14 @@ module Vra
|
|
29
29
|
class CatalogRequest
|
30
30
|
attr_reader :catalog_id, :catalog_item, :client, :custom_fields
|
31
31
|
attr_writer :subtenant_id, :template_payload
|
32
|
-
attr_accessor :cpus, :memory, :requested_for, :lease_days, :notes
|
32
|
+
attr_accessor :cpus, :memory, :shirt_size, :requested_for, :lease_days, :notes
|
33
33
|
|
34
34
|
def initialize(client, catalog_id, opts = {})
|
35
35
|
@client = client
|
36
36
|
@catalog_id = catalog_id
|
37
37
|
@cpus = opts[:cpus]
|
38
38
|
@memory = opts[:memory]
|
39
|
+
@shirt_size = opts[:shirt_size]
|
39
40
|
@requested_for = opts[:requested_for]
|
40
41
|
@lease_days = opts[:lease_days]
|
41
42
|
@notes = opts[:notes]
|
@@ -55,6 +56,7 @@ module Vra
|
|
55
56
|
opts = {}
|
56
57
|
opts[:cpus] = blueprint_data["data"]["cpu"]
|
57
58
|
opts[:memory] = blueprint_data["data"]["memory"]
|
59
|
+
opts[:shirt_size] = blueprint_data["data"]["size"]
|
58
60
|
opts[:requested_for] = hash_payload["requestedFor"]
|
59
61
|
opts[:lease_days] = blueprint_data.fetch("leaseDays", nil) || hash_payload["data"].fetch("_lease_days", 1)
|
60
62
|
opts[:description] = hash_payload["description"]
|
@@ -86,11 +88,11 @@ module Vra
|
|
86
88
|
|
87
89
|
def validate_params!
|
88
90
|
missing_params = []
|
89
|
-
|
91
|
+
%i{catalog_id cpus memory requested_for subtenant_id }.each do |param|
|
90
92
|
missing_params << param.to_s if send(param).nil?
|
91
93
|
end
|
92
94
|
|
93
|
-
raise ArgumentError, "Unable to submit request, required param(s) missing => #{missing_params.join(
|
95
|
+
raise ArgumentError, "Unable to submit request, required param(s) missing => #{missing_params.join(", ")}" unless missing_params.empty?
|
94
96
|
end
|
95
97
|
|
96
98
|
# @return [String] - the current catalog template payload merged with the settings applied from this request
|
@@ -100,6 +102,7 @@ module Vra
|
|
100
102
|
blueprint_name = hash_payload["data"].select { |_k, v| v.is_a?(Hash) }.keys.first
|
101
103
|
hash_payload["data"][blueprint_name]["data"]["cpu"] = @cpus
|
102
104
|
hash_payload["data"][blueprint_name]["data"]["memory"] = @memory
|
105
|
+
hash_payload["data"][blueprint_name]["data"]["size"] = @shirt_size
|
103
106
|
hash_payload["requestedFor"] = @requested_for
|
104
107
|
hash_payload["data"]["_leaseDays"] = @lease_days
|
105
108
|
hash_payload["description"] = @notes
|
@@ -123,7 +126,7 @@ module Vra
|
|
123
126
|
begin
|
124
127
|
post_response = client.http_post("/catalog-service/api/consumer/entitledCatalogItems/#{@catalog_id}/requests", merged_payload)
|
125
128
|
rescue Vra::Exception::HTTPError => e
|
126
|
-
raise Vra::Exception::RequestError, "Unable to submit request: #{e.errors.join(
|
129
|
+
raise Vra::Exception::RequestError, "Unable to submit request: #{e.errors.join(", ")}"
|
127
130
|
rescue
|
128
131
|
raise
|
129
132
|
end
|
data/lib/vra/client.rb
CHANGED
@@ -17,7 +17,7 @@
|
|
17
17
|
# limitations under the License.
|
18
18
|
#
|
19
19
|
|
20
|
-
require "ffi_yajl"
|
20
|
+
require "ffi_yajl" unless defined?(FFI_Yajl)
|
21
21
|
require "passwordmasker"
|
22
22
|
require "vra/http"
|
23
23
|
|
@@ -154,6 +154,7 @@ module Vra
|
|
154
154
|
items += response["content"]
|
155
155
|
|
156
156
|
break if page >= response["metadata"]["totalPages"]
|
157
|
+
|
157
158
|
page += 1
|
158
159
|
end
|
159
160
|
|
data/lib/vra/exceptions.rb
CHANGED
data/lib/vra/http.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
|
-
require "net/http"
|
3
|
-
require "openssl"
|
2
|
+
require "net/http" unless defined?(Net::HTTP)
|
3
|
+
require "openssl" unless defined?(OpenSSL)
|
4
4
|
|
5
5
|
module Vra
|
6
6
|
module Http
|
@@ -10,10 +10,11 @@ module Vra
|
|
10
10
|
response = response.forward(request).call until response.final?
|
11
11
|
if ENV["VRA_HTTP_TRACE"]
|
12
12
|
puts "#{request.params[:method].upcase} #{request.params[:url]}" unless request.params.nil?
|
13
|
-
puts ">>>>> #{JSON.parse(request.params[:payload]).to_json}" unless request.params[:payload].nil?
|
13
|
+
puts ">>>>> #{JSON.parse(request.params[:payload]).to_json.gsub(/\"password\":\"(.+)\",/, '"password":"********",' )}" unless request.params[:payload].nil?
|
14
14
|
puts "<<<<< #{JSON.parse(response.body).to_json}" unless response.body.nil?
|
15
15
|
end
|
16
16
|
raise error(response) unless response.success?
|
17
|
+
|
17
18
|
response
|
18
19
|
end
|
19
20
|
|
@@ -29,7 +30,7 @@ module Vra
|
|
29
30
|
end
|
30
31
|
|
31
32
|
def redirectable?
|
32
|
-
|
33
|
+
%i{get head}.include?(params[:method])
|
33
34
|
end
|
34
35
|
|
35
36
|
def redirect_to(location)
|
@@ -75,6 +76,7 @@ module Vra
|
|
75
76
|
|
76
77
|
def verify_ssl?
|
77
78
|
return true if params[:verify_ssl].nil?
|
79
|
+
|
78
80
|
params[:verify_ssl]
|
79
81
|
end
|
80
82
|
end
|
@@ -89,6 +91,7 @@ module Vra
|
|
89
91
|
def forward(request)
|
90
92
|
if redirect?
|
91
93
|
raise Http.error(self) unless request.redirectable?
|
94
|
+
|
92
95
|
request.redirect_to(location)
|
93
96
|
elsif see_other?
|
94
97
|
request.see_other(location)
|
data/lib/vra/request.rb
CHANGED
data/lib/vra/resource.rb
CHANGED
@@ -17,7 +17,7 @@
|
|
17
17
|
# limitations under the License.
|
18
18
|
#
|
19
19
|
|
20
|
-
require "ffi_yajl"
|
20
|
+
require "ffi_yajl" unless defined?(FFI_Yajl)
|
21
21
|
|
22
22
|
module Vra
|
23
23
|
class Resource
|
@@ -50,6 +50,7 @@ module Vra
|
|
50
50
|
def self.by_name(client, name)
|
51
51
|
raise ArgumentError.new("name cannot be nil") if name.nil?
|
52
52
|
raise ArgumentError.new("client cannot be nil") if client.nil?
|
53
|
+
|
53
54
|
Resources.all(client).find { |r| r.name.downcase =~ /#{name.downcase}/ }
|
54
55
|
end
|
55
56
|
|
data/lib/vra/version.rb
CHANGED
data/spec/catalog_item_spec.rb
CHANGED
@@ -166,20 +166,20 @@ describe Vra::CatalogItem do
|
|
166
166
|
|
167
167
|
it "#dump_template" do
|
168
168
|
expect(client).to receive(:http_get).with("/catalog-service/api/consumer/entitledCatalogItems/#{catalog_id}/requests/template")
|
169
|
-
|
169
|
+
.and_return(response)
|
170
170
|
described_class.dump_template(client, catalog_id )
|
171
171
|
end
|
172
172
|
|
173
173
|
it "#write_template" do
|
174
174
|
allow(client).to receive(:http_get).with("/catalog-service/api/consumer/entitledCatalogItems/#{catalog_id}/requests/template")
|
175
|
-
|
175
|
+
.and_return(response)
|
176
176
|
expect(File).to receive(:write).with("9e98042e-5443-4082-afd5-ab5a32939bbc.json", JSON.pretty_generate(catalog_item_payload))
|
177
177
|
expect(described_class.write_template(client, catalog_id)).to eq("9e98042e-5443-4082-afd5-ab5a32939bbc.json")
|
178
178
|
end
|
179
179
|
|
180
180
|
it "#write_template with custom filename" do
|
181
181
|
allow(client).to receive(:http_get).with("/catalog-service/api/consumer/entitledCatalogItems/#{catalog_id}/requests/template")
|
182
|
-
|
182
|
+
.and_return(response)
|
183
183
|
expect(File).to receive(:write).with("somefile.json", JSON.pretty_generate(catalog_item_payload))
|
184
184
|
expect(described_class.write_template(client, catalog_id, "somefile.json")).to eq("somefile.json")
|
185
185
|
end
|
@@ -243,13 +243,13 @@ describe Vra::CatalogItem do
|
|
243
243
|
|
244
244
|
before(:each) do
|
245
245
|
allow(client).to receive(:http_get_paginated_array!).with("/catalog-service/api/consumer/entitledCatalogItems")
|
246
|
-
|
246
|
+
.and_return([ entitled_catalog_item, entitled_catalog_item2 ])
|
247
247
|
allow(client).to receive(:http_get)
|
248
|
-
|
249
|
-
|
248
|
+
.with("/catalog-service/api/consumer/entitledCatalogItems/d29efd6b-3cd6-4f8d-b1d8-da4ddd4e52b1/requests/template")
|
249
|
+
.and_return(response)
|
250
250
|
allow(client).to receive(:http_get)
|
251
|
-
|
252
|
-
|
251
|
+
.with("/catalog-service/api/consumer/entitledCatalogItems/3232323e-5443-4082-afd5-ab5a32939bbc/requests/template")
|
252
|
+
.and_return(response)
|
253
253
|
allow(File).to receive(:write).with("vra_templates/d29efd6b-3cd6-4f8d-b1d8-da4ddd4e52b1.json", JSON.pretty_generate(catalog_item_payload))
|
254
254
|
allow(File).to receive(:write).with("vra_templates/3232323e-5443-4082-afd5-ab5a32939bbc.json", JSON.pretty_generate(catalog_item_payload))
|
255
255
|
allow(File).to receive(:write).with("vra_templates/windowsserver2012.json", JSON.pretty_generate(catalog_item_payload))
|
@@ -271,7 +271,7 @@ describe Vra::CatalogItem do
|
|
271
271
|
|
272
272
|
it "#dump_templates with id" do
|
273
273
|
expect(described_class.dump_templates(client, "vra_templates", true))
|
274
|
-
|
274
|
+
.to eq(["vra_templates/d29efd6b-3cd6-4f8d-b1d8-da4ddd4e52b1.json",
|
275
275
|
"vra_templates/3232323e-5443-4082-afd5-ab5a32939bbc.json"])
|
276
276
|
|
277
277
|
end
|
@@ -206,12 +206,12 @@ describe Vra::CatalogRequest do
|
|
206
206
|
allow(client).to receive(:authorize!).and_return(true)
|
207
207
|
allow(client).to receive(:http_post).with("/catalog-service/api/consumer/requests", "{}").and_return(response)
|
208
208
|
allow(client).to receive(:http_get).with("/catalog-service/api/consumer/entitledCatalogItems/catalog-12345/requests/template")
|
209
|
-
|
209
|
+
.and_return(request_template_response)
|
210
210
|
end
|
211
211
|
|
212
212
|
it "calls http_get template" do
|
213
213
|
expect(client).to receive(:http_get).with("/catalog-service/api/consumer/entitledCatalogItems/catalog-12345/requests/template")
|
214
|
-
|
214
|
+
.and_return(request_template_response)
|
215
215
|
allow(client).to receive(:http_post).with("/catalog-service/api/consumer/entitledCatalogItems/catalog-12345/requests", request.merged_payload).and_return(response)
|
216
216
|
request.submit
|
217
217
|
end
|
data/spec/client_spec.rb
CHANGED
@@ -226,7 +226,7 @@ describe Vra::Client do
|
|
226
226
|
url: full_url,
|
227
227
|
headers: headers,
|
228
228
|
verify_ssl: verify_ssl)
|
229
|
-
|
229
|
+
.and_return(response)
|
230
230
|
|
231
231
|
client_without_ssl.http_head(path)
|
232
232
|
end
|
@@ -399,7 +399,7 @@ describe Vra::Client do
|
|
399
399
|
|
400
400
|
unverified_client.http_post("/path", "payload")
|
401
401
|
|
402
|
-
|
402
|
+
%i{head get}.each do |method|
|
403
403
|
unverified_client.http_fetch(method, "/test", true)
|
404
404
|
end
|
405
405
|
end
|
data/spec/http_spec.rb
CHANGED
@@ -117,7 +117,7 @@ describe Vra::Http do
|
|
117
117
|
|
118
118
|
context "when redirected" do
|
119
119
|
[301, 302, 307].each do |status|
|
120
|
-
|
120
|
+
%i{get head}.each do |method|
|
121
121
|
it "follows #{status} redirected #{method.to_s.upcase} requests" do
|
122
122
|
stub_request(method, "http://test.local")
|
123
123
|
.to_return(status: [status, "redirect"],
|
@@ -140,7 +140,7 @@ describe Vra::Http do
|
|
140
140
|
end
|
141
141
|
end
|
142
142
|
|
143
|
-
|
143
|
+
%i{head post}.each do |method|
|
144
144
|
it "converts #{method.to_s.upcase} to GET on 303 redirect" do
|
145
145
|
stub_request(method, "http://test.local")
|
146
146
|
.to_return(status: [303, "See Other"],
|
data/spec/resources_spec.rb
CHANGED
@@ -31,8 +31,8 @@ describe Vra::Resources do
|
|
31
31
|
|
32
32
|
it "#all" do
|
33
33
|
allow(client).to receive(:http_get_paginated_array!)
|
34
|
-
|
35
|
-
|
34
|
+
.with("/catalog-service/api/consumer/resources")
|
35
|
+
.and_return([ { "id" => "1" }, { "id" => "2" } ])
|
36
36
|
|
37
37
|
items = resources.all_resources
|
38
38
|
|
data/vmware-vra.gemspec
CHANGED
@@ -1,6 +1,5 @@
|
|
1
|
-
# coding: utf-8
|
2
1
|
# frozen_string_literal: true
|
3
|
-
lib = File.expand_path("
|
2
|
+
lib = File.expand_path("lib", __dir__)
|
4
3
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
5
4
|
require "vra/version"
|
6
5
|
|
@@ -22,7 +21,7 @@ Gem::Specification.new do |spec|
|
|
22
21
|
spec.add_dependency "ffi-yajl", "~> 2.2"
|
23
22
|
spec.add_dependency "passwordmasker", "~> 1.2"
|
24
23
|
|
25
|
-
spec.add_development_dependency "bundler", "
|
24
|
+
spec.add_development_dependency "bundler", ">= 1.7"
|
26
25
|
spec.add_development_dependency "chefstyle"
|
27
26
|
spec.add_development_dependency "github_changelog_generator"
|
28
27
|
spec.add_development_dependency "pry", "~> 0.10"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vmware-vra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.7.
|
4
|
+
version: 2.7.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Leff
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2020-09-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ffi-yajl
|
@@ -43,14 +43,14 @@ dependencies:
|
|
43
43
|
name: bundler
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- - "
|
46
|
+
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: '1.7'
|
49
49
|
type: :development
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- - "
|
53
|
+
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '1.7'
|
56
56
|
- !ruby/object:Gem::Dependency
|
@@ -207,7 +207,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
207
207
|
- !ruby/object:Gem::Version
|
208
208
|
version: '0'
|
209
209
|
requirements: []
|
210
|
-
rubygems_version: 3.
|
210
|
+
rubygems_version: 3.1.2
|
211
211
|
signing_key:
|
212
212
|
specification_version: 4
|
213
213
|
summary: Client gem for interacting with VMware vRealize Automation.
|