vmware-vra 2.7.0 → 2.7.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: adc7871ce36fca6a61e634ea47bd4453e12d0c57fd2a53b30d67b327f819a7e5
4
- data.tar.gz: 8f9ad1fc148858c9f686c53f0818a3ad8af418eaa8dac845e2b36833b60274cf
3
+ metadata.gz: 3e28bed631cab067e13738576e243460e12e5b4ab8421f984faf1261c5b70691
4
+ data.tar.gz: 1be855a3503c4a15386c885accdd75a8f5fc5fc13eb84abc82c91cfe08250b6a
5
5
  SHA512:
6
- metadata.gz: e007662f641db9438846aecb6bd5f2063cb55c961b1131b85433185cb86b8031b0e6978441c35bd7d55d67daf02667ee58ca8c025f58872569d5ed84c8ba9c91
7
- data.tar.gz: 0343c931007f55fbbbe1fce15b516674a1ae46f74630d1d7a2b529d2c7068386e5b1a087447b58ac9ca68de06b1112a773acf406fe97de93a85af6cf57e62654
6
+ metadata.gz: 300797ca6f9997718a76e9c86fd1ba9f898463a94ebc95dd8e626799e77bdd6e0cd0bec7a4290f5246c31dbebbed338c84941fc132fc71763b1d7bedd10c2b1d
7
+ data.tar.gz: 3d8e098691e4edadafa5b5c9b6768b267ad92ff5736aed899c31ed0f62969714f743f2f8cd2b96f6a23cab6fa83609810cdfd71860c7aaaf980bd8a60d25f7c9
@@ -1,5 +1,16 @@
1
1
  # Change Log
2
2
 
3
+ ## [2.7.1](https://github.com/chef-partners/vmware-vra-gem/tree/v2.7.1) (2019-05-28)
4
+ [Full Changelog](https://github.com/chef-partners/vmware-vra-gem/compare/v2.7.0...v2.7.1)
5
+
6
+ **Closed issues:**
7
+
8
+ - Some Extra Parameters are not passing through to VRA [\#75](https://github.com/chef-partners/vmware-vra-gem/issues/75)
9
+
10
+ **Merged pull requests:**
11
+
12
+ - Add support for boolean vRA parameters, fix deep merge, add tracing [\#76](https://github.com/chef-partners/vmware-vra-gem/pull/76) ([stuartpreston](https://github.com/stuartpreston))
13
+
3
14
  ## [2.7.0](https://github.com/chef-partners/vmware-vra-gem/tree/v2.7.0) (2019-05-10)
4
15
  [Full Changelog](https://github.com/chef-partners/vmware-vra-gem/compare/v2.6.1...v2.7.0)
5
16
 
data/README.md CHANGED
@@ -296,6 +296,20 @@ vra = Vra::Client.new(username: 'devmgr@corp.local', password: 'mypassword', ten
296
296
  client.page_size = 100
297
297
  ```
298
298
 
299
+ ### Debugging
300
+
301
+ 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.
302
+
303
+ MacOS/Linux:
304
+ ```ruby
305
+ export VRA_HTTP_TRACE=1
306
+ ```
307
+
308
+ Windows:
309
+ ```powershell
310
+ $env:VRA_HTTP_TRACE=1
311
+ ```
312
+
299
313
  ## License and Authors
300
314
 
301
315
  Author:: Chef Partner Engineering (<partnereng@chef.io>)
@@ -18,6 +18,13 @@
18
18
  #
19
19
  require "vra/catalog_item"
20
20
 
21
+ class ::Hash
22
+ def deep_merge(second)
23
+ merger = proc { |key, v1, v2| Hash === v1 && Hash === v2 ? v1.merge(v2, &merger) : v2 }
24
+ merge(second, &merger)
25
+ end
26
+ end
27
+
21
28
  module Vra
22
29
  class CatalogRequest
23
30
  attr_reader :catalog_id, :catalog_item, :client, :custom_fields
@@ -96,7 +103,7 @@ module Vra
96
103
  hash_payload["requestedFor"] = @requested_for
97
104
  hash_payload["data"]["_leaseDays"] = @lease_days
98
105
  hash_payload["description"] = @notes
99
- hash_payload["data"][blueprint_name]["data"].merge!(parameters["data"]) unless parameters.empty?
106
+ hash_payload["data"] = hash_payload["data"].deep_merge(parameters["data"]) unless parameters.empty?
100
107
  hash_payload.to_json
101
108
  end
102
109
 
@@ -8,6 +8,11 @@ module Vra
8
8
  request = Request.new(params)
9
9
  response = request.call
10
10
  response = response.forward(request).call until response.final?
11
+ if ENV["VRA_HTTP_TRACE"]
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?
14
+ puts "<<<<< #{JSON.parse(response.body).to_json}" unless response.body.nil?
15
+ end
11
16
  raise error(response) unless response.success?
12
17
  response
13
18
  end
@@ -156,6 +156,8 @@ module Vra
156
156
  @value.to_i
157
157
  when "string"
158
158
  @value
159
+ when "boolean"
160
+ @value.to_s == "true"
159
161
  else
160
162
  @value
161
163
  end
@@ -18,5 +18,5 @@
18
18
  #
19
19
 
20
20
  module Vra
21
- VERSION = "2.7.0"
21
+ VERSION = "2.7.1"
22
22
  end
@@ -136,15 +136,18 @@ describe Vra::CatalogRequest do
136
136
  it "properly handles additional parameters" do
137
137
  request.set_parameter("param1", "string", "my string")
138
138
  request.set_parameter("param2", "integer", "2468")
139
+ request.set_parameter("param3", "boolean", "true")
139
140
 
140
141
  template = File.read("spec/fixtures/resource/catalog_request.json")
141
142
  payload = JSON.parse(request.merge_payload(template))
142
- param1 = payload["data"]["my_blueprint"]["data"]["param1"]
143
- param2 = payload["data"]["my_blueprint"]["data"]["param2"]
143
+ param1 = payload["data"]["param1"]
144
+ param2 = payload["data"]["param2"]
145
+ param3 = payload["data"]["param3"]
144
146
  expect(param1).to be_a(String)
145
147
  expect(param2).to be_a(Integer)
146
148
  expect(param1).to eq "my string"
147
149
  expect(param2).to eq 2468
150
+ expect(param3).to be_truthy
148
151
  end
149
152
 
150
153
  it "properly handles additional nested parameters" do
@@ -153,8 +156,8 @@ describe Vra::CatalogRequest do
153
156
 
154
157
  template = File.read("spec/fixtures/resource/catalog_request.json")
155
158
  payload = JSON.parse(request.merge_payload(template))
156
- param1 = payload["data"]["my_blueprint"]["data"]["BP1"]["data"]["param1"]
157
- param2 = payload["data"]["my_blueprint"]["data"]["BP1"]["data"]["BP2"]["data"]["param2"]
159
+ param1 = payload["data"]["BP1"]["data"]["param1"]
160
+ param2 = payload["data"]["BP1"]["data"]["BP2"]["data"]["param2"]
158
161
  expect(param1).to be_a(String)
159
162
  expect(param2).to be_a(Integer)
160
163
  expect(param1).to eq "my string"
@@ -183,8 +186,8 @@ describe Vra::CatalogRequest do
183
186
 
184
187
  template = File.read("spec/fixtures/resource/catalog_request.json")
185
188
  payload = JSON.parse(request.merge_payload(template))
186
- param1 = payload["data"]["my_blueprint"]["data"]["BP1"]["data"]["param1"]
187
- param2 = payload["data"]["my_blueprint"]["data"]["BP1"]["data"]["BP2"]["data"]["param2"]
189
+ param1 = payload["data"]["BP1"]["data"]["param1"]
190
+ param2 = payload["data"]["BP1"]["data"]["BP2"]["data"]["param2"]
188
191
 
189
192
  expect(param1).to be_a(String)
190
193
  expect(param2).to be_a(Integer)
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.0
4
+ version: 2.7.1
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: 2019-05-10 00:00:00.000000000 Z
12
+ date: 2019-05-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: ffi-yajl