vmware-vra 2.5.2 → 2.7.2

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
- SHA1:
3
- metadata.gz: 46c1f1139cc3262cb936510213d4ed55932ff3f5
4
- data.tar.gz: 93721afaaea8f983f84354539905fb49d0eec847
2
+ SHA256:
3
+ metadata.gz: 748935ab6ce2c1922e5ffded2a7d2567709308e4c62bfe81d15d22b71a186508
4
+ data.tar.gz: 95b4943dc8f6015055e4a7c142115a8f555072c79244c4a62fed2e0e1862c8ac
5
5
  SHA512:
6
- metadata.gz: 69fdf73780e7c7550e9a407ca87c2629a64f1be419ee597af5f03bab5f4f88306c7dde6c2b1725442a3e027193735a2904cc8b3a31b499c51d2278dabaf03500
7
- data.tar.gz: a92954fae6a63da0ee4cf1cce76a1934507e06edda6e9219f7e914aa431e49358fa9f2f999ae43fb34edd28b0cadf0a4a19474981e4e40c58461f98bebcf8972
6
+ metadata.gz: 4b244e271a780513e497356114eff2ca721cf7fe2665d1fe6cbb10a500284b7702b53679a3c3aa19bd18727f6064ee6f2cb17fe38e5685e29716667b4d3cf25f
7
+ data.tar.gz: 8f1bd967dc41e4ed9363ae6404c402bdbb4524689d05d86a37c56e1d86f31efa374018108c5ebeef582972d15151391a25c7856621f0eeca33331c84b3846c3c
@@ -2,7 +2,7 @@ language: ruby
2
2
  cache: bundler
3
3
  sudo: false
4
4
  rvm:
5
- - 2.3.1
5
+ - 2.6.3
6
6
  branches:
7
7
  only:
8
8
  - master
@@ -1,14 +1,65 @@
1
1
  # Change Log
2
2
 
3
- ## [2..5.2] (https://github.com/chef-partners/vmware-vra-gem/tree/2.5.2) (2018-01-04)
4
- [Full Changelog](https://github.com/chef-partners/vmware-vra-gem/compare/v2.5.1...2.5.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
5
 
6
- **Enhanced:**
6
+ - Added an extra option to handle shirt size parameter
7
+ - Masking user credentials(password) in debug mode
7
8
 
8
- - Added a method to retrive catalog id from catalog name
9
+ ## [2.7.1](https://github.com/chef-partners/vmware-vra-gem/tree/v2.7.1) (2019-05-28)
10
+ [Full Changelog](https://github.com/chef-partners/vmware-vra-gem/compare/v2.7.0...v2.7.1)
9
11
 
10
- ## [2.5.1](https://github.com/chef-partners/vmware-vra-gem/tree/2.5.1) (2017-10-19)
11
- [Full Changelog](https://github.com/chef-partners/vmware-vra-gem/compare/v2.5.0...2.5.1)
12
+ **Closed issues:**
13
+
14
+ - Some Extra Parameters are not passing through to VRA [\#75](https://github.com/chef-partners/vmware-vra-gem/issues/75)
15
+
16
+ **Merged pull requests:**
17
+
18
+ - 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))
19
+
20
+ ## [2.7.0](https://github.com/chef-partners/vmware-vra-gem/tree/v2.7.0) (2019-05-10)
21
+ [Full Changelog](https://github.com/chef-partners/vmware-vra-gem/compare/v2.6.1...v2.7.0)
22
+
23
+ **Closed issues:**
24
+
25
+ - Extra Parameters Not Being Sent to vRA [\#73](https://github.com/chef-partners/vmware-vra-gem/issues/73)
26
+
27
+ **Merged pull requests:**
28
+
29
+ - vRA7 multiple fixes for nested, non-nested and merged parameters for a Blueprint [\#74](https://github.com/chef-partners/vmware-vra-gem/pull/74) ([stuartpreston](https://github.com/stuartpreston))
30
+
31
+ ## [2.6.1](https://github.com/chef-partners/vmware-vra-gem/tree/v2.6.1) (2018-07-31)
32
+ [Full Changelog](https://github.com/chef-partners/vmware-vra-gem/compare/v2.6.0...2.6.1)
33
+
34
+ **Closed issues:**
35
+
36
+ - Vra::Resource\#ip\_addresses non-deterministically returns an empty array in error [\#65](https://github.com/chef-partners/vmware-vra-gem/issues/65)
37
+
38
+ **Merged pull requests:**
39
+
40
+ - Removed the deep merge [\#68](https://github.com/chef-partners/vmware-vra-gem/pull/68) ([jjasghar](https://github.com/jjasghar))
41
+
42
+ ## [v2.6.0](https://github.com/chef-partners/vmware-vra-gem/tree/v2.6.0) (2018-03-01)
43
+ [Full Changelog](https://github.com/chef-partners/vmware-vra-gem/compare/v2.5.2...v2.6.0)
44
+
45
+ **Closed issues:**
46
+
47
+ - undefined method `\[\]' for nil:NilClass if data for json content is of single entity [\#55](https://github.com/chef-partners/vmware-vra-gem/issues/55)
48
+
49
+ **Merged pull requests:**
50
+
51
+ - Accept subtenant name as input in kitchen.yml [\#67](https://github.com/chef-partners/vmware-vra-gem/pull/67) ([vinuphilip](https://github.com/vinuphilip))
52
+ - Lgustafson/fix 65 [\#66](https://github.com/chef-partners/vmware-vra-gem/pull/66) ([lgustafson](https://github.com/lgustafson))
53
+
54
+ ## [v2.5.2](https://github.com/chef-partners/vmware-vra-gem/tree/v2.5.2) (2018-01-22)
55
+ [Full Changelog](https://github.com/chef-partners/vmware-vra-gem/compare/v2.5.1...v2.5.2)
56
+
57
+ **Merged pull requests:**
58
+
59
+ - Added a method to retrieve catalog id's from catalog name [\#64](https://github.com/chef-partners/vmware-vra-gem/pull/64) ([rupeshpatel88](https://github.com/rupeshpatel88))
60
+
61
+ ## [v2.5.1](https://github.com/chef-partners/vmware-vra-gem/tree/v2.5.1) (2017-10-19)
62
+ [Full Changelog](https://github.com/chef-partners/vmware-vra-gem/compare/v2.5.0...v2.5.1)
12
63
 
13
64
  **Merged pull requests:**
14
65
 
data/README.md CHANGED
@@ -78,7 +78,15 @@ vra.catalog.fetch_catalog_items('my_catalog_name')
78
78
 
79
79
  vRA requires your sub-tenant (a.k.a. "business group") to be specified when requesting an item from the catalog. If the catalog item you are requesting is specifically created for a given business group, the gem will use that ID automatically without you needing to specify it.
80
80
 
81
- However, if there is no sub-tenant ID available for us to use, you will receive an error when you submit:
81
+ An easier option has been provided to end user to provide a friendly sub-tenant name instead of sub-tenant id, and the driver would take care of retrieving the sub-tenant id for the corresponding sub-tenant name. Tenant name is also required along with sub-tenant name to retrieve sub-tenant id.
82
+
83
+ To retrieve sub-tenant id from sub-tenant name:
84
+
85
+ ```
86
+ vra.fetch_subtenant_items('my_tenant', 'my_subtenant_name')
87
+ ```
88
+
89
+ However, if there is no sub-tenant ID or sub-tenant name available for us to use, you will receive an error when you submit:
82
90
 
83
91
  ```
84
92
  request = catalog_request.submit
@@ -154,6 +162,7 @@ request_options = {
154
162
  # create the request
155
163
  catalog_request = vra.catalog.request(blueprint, request_options)
156
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,
157
166
 
158
167
  Now, submit your request! The client will return a new "Request" object you can use to query for status.
159
168
 
@@ -288,6 +297,20 @@ vra = Vra::Client.new(username: 'devmgr@corp.local', password: 'mypassword', ten
288
297
  client.page_size = 100
289
298
  ```
290
299
 
300
+ ### Debugging
301
+
302
+ 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.
303
+
304
+ MacOS/Linux:
305
+ ```ruby
306
+ export VRA_HTTP_TRACE=1
307
+ ```
308
+
309
+ Windows:
310
+ ```powershell
311
+ $env:VRA_HTTP_TRACE=1
312
+ ```
313
+
291
314
  ## License and Authors
292
315
 
293
316
  Author:: Chef Partner Engineering (<partnereng@chef.io>)
data/Rakefile CHANGED
@@ -20,4 +20,4 @@ rescue LoadError
20
20
  puts "github_changelog_generator is not available. gem install github_changelog_generator to generate changelogs"
21
21
  end
22
22
 
23
- task default: [ :spec, :rubocop ]
23
+ task default: %i{spec rubocop}
@@ -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
- .map! { |x| Vra::CatalogItem.new(client, data: x) }
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
- .map! { |x| Vra::CatalogItem.new(client, data: x["catalogItem"]) }
35
+ .map! { |x| Vra::CatalogItem.new(client, data: x["catalogItem"]) }
36
36
  end
37
37
 
38
38
  def request(*args)
@@ -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
- return filename
110
+ filename
111
111
  rescue Vra::Exception::HTTPError => e
112
112
  raise e
113
113
  end
@@ -18,17 +18,25 @@
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
24
- attr_writer :subtenant_id
25
- attr_accessor :cpus, :memory, :requested_for, :lease_days, :notes, :template_payload
31
+ attr_writer :subtenant_id, :template_payload
32
+ attr_accessor :cpus, :memory, :shirt_size, :requested_for, :lease_days, :notes
26
33
 
27
34
  def initialize(client, catalog_id, opts = {})
28
35
  @client = client
29
36
  @catalog_id = catalog_id
30
37
  @cpus = opts[:cpus]
31
38
  @memory = opts[:memory]
39
+ @shirt_size = opts[:shirt_size]
32
40
  @requested_for = opts[:requested_for]
33
41
  @lease_days = opts[:lease_days]
34
42
  @notes = opts[:notes]
@@ -48,6 +56,7 @@ module Vra
48
56
  opts = {}
49
57
  opts[:cpus] = blueprint_data["data"]["cpu"]
50
58
  opts[:memory] = blueprint_data["data"]["memory"]
59
+ opts[:shirt_size] = blueprint_data["data"]["size"]
51
60
  opts[:requested_for] = hash_payload["requestedFor"]
52
61
  opts[:lease_days] = blueprint_data.fetch("leaseDays", nil) || hash_payload["data"].fetch("_lease_days", 1)
53
62
  opts[:description] = hash_payload["description"]
@@ -79,11 +88,11 @@ module Vra
79
88
 
80
89
  def validate_params!
81
90
  missing_params = []
82
- [ :catalog_id, :cpus, :memory, :requested_for, :subtenant_id ].each do |param|
91
+ %i{catalog_id cpus memory requested_for subtenant_id }.each do |param|
83
92
  missing_params << param.to_s if send(param).nil?
84
93
  end
85
94
 
86
- raise ArgumentError, "Unable to submit request, required param(s) missing => #{missing_params.join(', ')}" unless missing_params.empty?
95
+ raise ArgumentError, "Unable to submit request, required param(s) missing => #{missing_params.join(", ")}" unless missing_params.empty?
87
96
  end
88
97
 
89
98
  # @return [String] - the current catalog template payload merged with the settings applied from this request
@@ -93,10 +102,12 @@ module Vra
93
102
  blueprint_name = hash_payload["data"].select { |_k, v| v.is_a?(Hash) }.keys.first
94
103
  hash_payload["data"][blueprint_name]["data"]["cpu"] = @cpus
95
104
  hash_payload["data"][blueprint_name]["data"]["memory"] = @memory
105
+ hash_payload["data"][blueprint_name]["data"]["size"] = @shirt_size
96
106
  hash_payload["requestedFor"] = @requested_for
97
107
  hash_payload["data"]["_leaseDays"] = @lease_days
98
108
  hash_payload["description"] = @notes
99
- JSON.pretty_generate(deep_merge(hash_payload, parameters))
109
+ hash_payload["data"] = hash_payload["data"].deep_merge(parameters["data"]) unless parameters.empty?
110
+ hash_payload.to_json
100
111
  end
101
112
 
102
113
  # @return [String] - the current catalog template payload merged with the settings applied from this request
@@ -112,33 +123,15 @@ module Vra
112
123
  # @return [Vra::Request] - submits and returns the request, validating before hand
113
124
  def submit
114
125
  validate_params!
115
-
116
126
  begin
117
127
  post_response = client.http_post("/catalog-service/api/consumer/entitledCatalogItems/#{@catalog_id}/requests", merged_payload)
118
128
  rescue Vra::Exception::HTTPError => e
119
- raise Vra::Exception::RequestError, "Unable to submit request: #{e.errors.join(', ')}"
129
+ raise Vra::Exception::RequestError, "Unable to submit request: #{e.errors.join(", ")}"
120
130
  rescue
121
131
  raise
122
132
  end
123
133
  request_id = JSON.parse(post_response.body)["id"]
124
134
  Vra::Request.new(client, request_id)
125
135
  end
126
-
127
- def deep_merge(first, second)
128
- merger = proc do |key, v1, v2|
129
- if Hash === v1 && Hash === v2
130
- v1.merge(v2, &merger)
131
- elsif Array === v1 && Array === v2
132
- v1 | v2
133
- elsif [:undefined, nil, :nil].include?(v2)
134
- v1
135
- else
136
- v2
137
- end
138
- end
139
- first.merge(second.to_h, &merger)
140
- end
141
-
142
- private :deep_merge
143
136
  end
144
137
  end
@@ -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
 
@@ -71,7 +71,7 @@ module Vra
71
71
  {
72
72
  "username" => @username,
73
73
  "password" => @password.value,
74
- "tenant" => @tenant,
74
+ "tenant" => @tenant,
75
75
  }
76
76
  end
77
77
 
@@ -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
 
@@ -218,5 +219,10 @@ module Vra
218
219
  rescue URI::InvalidURIError
219
220
  false
220
221
  end
222
+
223
+ def fetch_subtenant_items(tenant, subtenant_name)
224
+ http_get("/identity/api/tenants/#{tenant}/subtenants?%24filter=name+eq+'#{subtenant_name}'")
225
+ end
226
+
221
227
  end
222
228
  end
@@ -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
  module Exception
@@ -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
@@ -8,7 +8,13 @@ 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.gsub(/\"password\":\"(.+)\",/, '"password":"********",' )}" 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?
17
+
12
18
  response
13
19
  end
14
20
 
@@ -24,7 +30,7 @@ module Vra
24
30
  end
25
31
 
26
32
  def redirectable?
27
- [:get, :head].include?(params[:method])
33
+ %i{get head}.include?(params[:method])
28
34
  end
29
35
 
30
36
  def redirect_to(location)
@@ -70,6 +76,7 @@ module Vra
70
76
 
71
77
  def verify_ssl?
72
78
  return true if params[:verify_ssl].nil?
79
+
73
80
  params[:verify_ssl]
74
81
  end
75
82
  end
@@ -84,6 +91,7 @@ module Vra
84
91
  def forward(request)
85
92
  if redirect?
86
93
  raise Http.error(self) unless request.redirectable?
94
+
87
95
  request.redirect_to(location)
88
96
  elsif see_other?
89
97
  request.see_other(location)
@@ -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 Request
@@ -51,7 +51,7 @@ module Vra
51
51
 
52
52
  def set(key, type, value)
53
53
  if key.to_s.include? "~"
54
- split_key = key.split("~")
54
+ split_key = key.to_s.split("~")
55
55
  parent = nil
56
56
  split_key.each_with_index do |item, index|
57
57
  if index == 0
@@ -135,7 +135,6 @@ module Vra
135
135
 
136
136
  def to_vra
137
137
  hash = {}
138
-
139
138
  if @children.count > 0
140
139
  hash[@key] = {}
141
140
 
@@ -148,7 +147,7 @@ module Vra
148
147
  hash[@key] = format_value
149
148
  end
150
149
 
151
- hash
150
+ hash.each_with_object({}) { |(key, value), h| h[key.to_s] = value }
152
151
  end
153
152
 
154
153
  def format_value
@@ -157,6 +156,8 @@ module Vra
157
156
  @value.to_i
158
157
  when "string"
159
158
  @value
159
+ when "boolean"
160
+ @value.to_s == "true"
160
161
  else
161
162
  @value
162
163
  end
@@ -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
 
@@ -172,27 +173,24 @@ module Vra
172
173
 
173
174
  request_id = @resource_data["requestId"]
174
175
 
175
- resource_views = @client.http_get("/catalog-service/api/consumer/requests/#{request_id}/resourceViews")
176
-
177
- data_zero = JSON.parse(resource_views.body)["content"][0]["data"]["ip_address"]
178
- data_one = JSON.parse(resource_views.body)["content"][1]["data"]["ip_address"]
179
-
180
176
  print "Waiting For vRA to collect the IP"
181
- while (data_zero == "" || data_one == "") && (data_zero.nil? || data_one.nil?)
177
+
178
+ loop do
182
179
  resource_views = @client.http_get("/catalog-service/api/consumer/requests/#{request_id}/resourceViews")
183
- data_zero = JSON.parse(resource_views.body)["content"][0]["data"]["ip_address"]
184
- data_one = JSON.parse(resource_views.body)["content"][1]["data"]["ip_address"]
180
+
181
+ JSON.parse(resource_views.body)["content"].each do |content|
182
+ if content.key?("data") &&
183
+ !(content["data"]["ip_address"].nil? ||
184
+ content["data"]["ip_address"] == "")
185
+ addrs << content["data"]["ip_address"]
186
+ end
187
+ end
188
+
189
+ break unless addrs.empty?
190
+
185
191
  sleep 10
186
- print "."
187
192
  end
188
193
 
189
- ip_address = if JSON.parse(resource_views.body)["content"][0]["data"]["ip_address"].nil?
190
- JSON.parse(resource_views.body)["content"][1]["data"]["ip_address"]
191
- else
192
- JSON.parse(resource_views.body)["content"][0]["data"]["ip_address"]
193
- end
194
-
195
- addrs << ip_address
196
194
  addrs
197
195
  end
198
196
 
@@ -18,5 +18,5 @@
18
18
  #
19
19
 
20
20
  module Vra
21
- VERSION = "2.5.2"
21
+ VERSION = "2.7.2"
22
22
  end
@@ -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
- .and_return(response)
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
- .and_return(response)
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
- .and_return(response)
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
- .and_return([ entitled_catalog_item, entitled_catalog_item2 ])
246
+ .and_return([ entitled_catalog_item, entitled_catalog_item2 ])
247
247
  allow(client).to receive(:http_get)
248
- .with("/catalog-service/api/consumer/entitledCatalogItems/d29efd6b-3cd6-4f8d-b1d8-da4ddd4e52b1/requests/template")
249
- .and_return(response)
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
- .with("/catalog-service/api/consumer/entitledCatalogItems/3232323e-5443-4082-afd5-ab5a32939bbc/requests/template")
252
- .and_return(response)
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
- .to eq(["vra_templates/d29efd6b-3cd6-4f8d-b1d8-da4ddd4e52b1.json",
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
@@ -136,16 +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
143
  param1 = payload["data"]["param1"]
143
144
  param2 = payload["data"]["param2"]
144
-
145
+ param3 = payload["data"]["param3"]
145
146
  expect(param1).to be_a(String)
146
147
  expect(param2).to be_a(Integer)
147
148
  expect(param1).to eq "my string"
148
149
  expect(param2).to eq 2468
150
+ expect(param3).to be_truthy
149
151
  end
150
152
 
151
153
  it "properly handles additional nested parameters" do
@@ -156,7 +158,6 @@ describe Vra::CatalogRequest do
156
158
  payload = JSON.parse(request.merge_payload(template))
157
159
  param1 = payload["data"]["BP1"]["data"]["param1"]
158
160
  param2 = payload["data"]["BP1"]["data"]["BP2"]["data"]["param2"]
159
-
160
161
  expect(param1).to be_a(String)
161
162
  expect(param2).to be_a(Integer)
162
163
  expect(param1).to eq "my string"
@@ -205,12 +206,12 @@ describe Vra::CatalogRequest do
205
206
  allow(client).to receive(:authorize!).and_return(true)
206
207
  allow(client).to receive(:http_post).with("/catalog-service/api/consumer/requests", "{}").and_return(response)
207
208
  allow(client).to receive(:http_get).with("/catalog-service/api/consumer/entitledCatalogItems/catalog-12345/requests/template")
208
- .and_return(request_template_response)
209
+ .and_return(request_template_response)
209
210
  end
210
211
 
211
212
  it "calls http_get template" do
212
213
  expect(client).to receive(:http_get).with("/catalog-service/api/consumer/entitledCatalogItems/catalog-12345/requests/template")
213
- .and_return(request_template_response)
214
+ .and_return(request_template_response)
214
215
  allow(client).to receive(:http_post).with("/catalog-service/api/consumer/entitledCatalogItems/catalog-12345/requests", request.merged_payload).and_return(response)
215
216
  request.submit
216
217
  end
@@ -133,7 +133,7 @@ describe Vra::Client do
133
133
  payload = {
134
134
  "username" => "user@corp.local",
135
135
  "password" => "password",
136
- "tenant" => "tenant",
136
+ "tenant" => "tenant",
137
137
  }.to_json
138
138
 
139
139
  it "posts to the tokens API endpoint" do
@@ -226,7 +226,7 @@ describe Vra::Client do
226
226
  url: full_url,
227
227
  headers: headers,
228
228
  verify_ssl: verify_ssl)
229
- .and_return(response)
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
- [:head, :get].each do |method|
402
+ %i{head get}.each do |method|
403
403
  unverified_client.http_fetch(method, "/test", true)
404
404
  end
405
405
  end
@@ -0,0 +1 @@
1
+ {"links":[],"content":[{"@type":"CatalogResourceView","links":[{"@type":"link","rel":"GET: Catalog Item","href":"https://vra71.tirefi.re/catalog-service/api/consumer/entitledCatalogItemViews/2d6d5481-ebb0-4bdc-8af9-b75043a86386"},{"@type":"link","rel":"GET: Request","href":"https://vra71.tirefi.re/catalog-service/api/consumer/requests/bcd175ac-1c02-4a00-b4c8-fa585f23fd2d"},{"@type":"link","rel":"GET Template: {com.vmware.csp.component.cafe.composition@resource.action.deployment.changelease.name}","href":"https://vra71.tirefi.re/catalog-service/api/consumer/resources/700f9e3c-c7bd-41d7-9683-5d3051a8e238/actions/c3595f52-e35a-448c-8409-7ce0c554cfba/requests/template"},{"@type":"link","rel":"POST: {com.vmware.csp.component.cafe.composition@resource.action.deployment.changelease.name}","href":"https://vra71.tirefi.re/catalog-service/api/consumer/resources/700f9e3c-c7bd-41d7-9683-5d3051a8e238/actions/c3595f52-e35a-448c-8409-7ce0c554cfba/requests"},{"@type":"link","rel":"GET Template: {com.vmware.csp.component.cafe.composition@resource.action.deployment.changeowner.name}","href":"https://vra71.tirefi.re/catalog-service/api/consumer/resources/700f9e3c-c7bd-41d7-9683-5d3051a8e238/actions/00f03ade-3850-40c8-93b8-4b093b5bf7c4/requests/template"},{"@type":"link","rel":"POST: {com.vmware.csp.component.cafe.composition@resource.action.deployment.changeowner.name}","href":"https://vra71.tirefi.re/catalog-service/api/consumer/resources/700f9e3c-c7bd-41d7-9683-5d3051a8e238/actions/00f03ade-3850-40c8-93b8-4b093b5bf7c4/requests"},{"@type":"link","rel":"GET Template: {com.vmware.csp.component.cafe.composition@resource.action.deployment.destroy.name}","href":"https://vra71.tirefi.re/catalog-service/api/consumer/resources/700f9e3c-c7bd-41d7-9683-5d3051a8e238/actions/306fbd9b-7129-405a-8c07-fedf32585f3d/requests/template"},{"@type":"link","rel":"POST: {com.vmware.csp.component.cafe.composition@resource.action.deployment.destroy.name}","href":"https://vra71.tirefi.re/catalog-service/api/consumer/resources/700f9e3c-c7bd-41d7-9683-5d3051a8e238/actions/306fbd9b-7129-405a-8c07-fedf32585f3d/requests"},{"@type":"link","rel":"GET Template: {com.vmware.csp.component.cafe.composition@resource.action.deployment.archive.name}","href":"https://vra71.tirefi.re/catalog-service/api/consumer/resources/700f9e3c-c7bd-41d7-9683-5d3051a8e238/actions/e5759af9-56d8-4598-ab7f-4ca6d45bd385/requests/template"},{"@type":"link","rel":"POST: {com.vmware.csp.component.cafe.composition@resource.action.deployment.archive.name}","href":"https://vra71.tirefi.re/catalog-service/api/consumer/resources/700f9e3c-c7bd-41d7-9683-5d3051a8e238/actions/e5759af9-56d8-4598-ab7f-4ca6d45bd385/requests"},{"@type":"link","rel":"GET Template: {com.vmware.csp.component.cafe.composition@resource.action.deployment.scalein.name}","href":"https://vra71.tirefi.re/catalog-service/api/consumer/resources/700f9e3c-c7bd-41d7-9683-5d3051a8e238/actions/6b358c70-ac66-4634-951b-73ab4e36c78d/requests/template"},{"@type":"link","rel":"POST: {com.vmware.csp.component.cafe.composition@resource.action.deployment.scalein.name}","href":"https://vra71.tirefi.re/catalog-service/api/consumer/resources/700f9e3c-c7bd-41d7-9683-5d3051a8e238/actions/6b358c70-ac66-4634-951b-73ab4e36c78d/requests"},{"@type":"link","rel":"GET Template: {com.vmware.csp.component.cafe.composition@resource.action.deployment.scaleout.name}","href":"https://vra71.tirefi.re/catalog-service/api/consumer/resources/700f9e3c-c7bd-41d7-9683-5d3051a8e238/actions/2c50de13-d5aa-4958-9af9-d2451675a2b3/requests/template"},{"@type":"link","rel":"POST: {com.vmware.csp.component.cafe.composition@resource.action.deployment.scaleout.name}","href":"https://vra71.tirefi.re/catalog-service/api/consumer/resources/700f9e3c-c7bd-41d7-9683-5d3051a8e238/actions/2c50de13-d5aa-4958-9af9-d2451675a2b3/requests"},{"@type":"link","rel":"GET: Child Resources","href":"https://vra71.tirefi.re/catalog-service/api/consumer/resourceViews?managedOnly=false&withExtendedData=true&withOperations=true&%24filter=parentResource%20eq%20%27700f9e3c-c7bd-41d7-9683-5d3051a8e238%27"}],"resourceId":"700f9e3c-c7bd-41d7-9683-5d3051a8e238","iconId":"composition.blueprint.png","name":"test-66303366","description":null,"status":null,"catalogItemId":"2d6d5481-ebb0-4bdc-8af9-b75043a86386","catalogItemLabel":"test","requestId":"bcd175ac-1c02-4a00-b4c8-fa585f23fd2d","resourceType":"composition.resource.type.deployment","owners":["vRA Admin"],"businessGroupId":"d0fb4a04-7099-4ba1-a262-b578e129a758","tenantId":"vsphere.local","dateCreated":"2016-12-01T19:59:55.000Z","lastUpdated":"2016-12-01T20:05:03.086Z","lease":{"start":"2016-12-01T19:59:54.988Z"},"costs":null,"costToDate":null,"totalCost":null,"parentResourceId":null,"hasChildren":true,"data":{}},{"@type":"CatalogResourceView","links":[{"@type":"link","rel":"GET: Request","href":"https://vra71.tirefi.re/catalog-service/api/consumer/requests/bcd175ac-1c02-4a00-b4c8-fa585f23fd2d"},{"@type":"link","rel":"GET: Parent Resource","href":"https://vra71.tirefi.re/catalog-service/api/consumer/resourceViews/700f9e3c-c7bd-41d7-9683-5d3051a8e238"}],"resourceId":"a1337573-c379-4f40-aaec-ce81c0c16ce6","iconId":"existing_network","name":"VMNetwork","description":null,"status":null,"catalogItemId":null,"catalogItemLabel":null,"requestId":"bcd175ac-1c02-4a00-b4c8-fa585f23fd2d","resourceType":"Infrastructure.Network.Network.Existing","owners":["vRA Admin"],"businessGroupId":"d0fb4a04-7099-4ba1-a262-b578e129a758","tenantId":"vsphere.local","dateCreated":"2018-02-22T20:23:11.203Z","lastUpdated":"2018-02-22T20:30:09.724Z","lease":{"start":"2018-02-22T20:22:50.171Z","end":"2018-02-24T20:22:50.171Z"},"costs":null,"costToDate":null,"totalCost":null,"parentResourceId":"700f9e3c-c7bd-41d7-9683-5d3051a8e238","hasChildren":false,"data":{"Description":" ","Name":"VMNetwork","_hasChildren":false,"_leaseDays":2,"_number_of_instances":1,"cpu":"1","dns":{"componentTypeId":"com.vmware.csp.iaas.blueprint.service","componentId":null,"classId":"Infrastructure.Network.Network.DnsWins","typeFilter":null,"data":{"alternate_wins":null,"dns_search_suffix":"bogus.invalid","dns_suffix":"bogus.invalid","preferred_wins":null,"primary_dns":"172.16.20.50","secondary_dns":"172.16.20.51"}},"gateway":"172.16.20.1","ip_ranges":[{"componentTypeId":"com.vmware.csp.iaas.blueprint.service","componentId":null,"classId":"Infrastructure.Network.Network.IpRanges","typeFilter":null,"data":{"description":"","end_ip":"172.16.20.200","id":"51ca3210-5e10-4f03-a5a0-02daa701ca36","name":"VMNetwork","start_ip":"172.16.20.10"}}],"memory":"2048","network_profile":"VM Network","providerBindingId":"test","subnet_mask":"255.255.255.0"}},{"@type":"CatalogResourceView","links":[{"@type":"link","rel":"GET: Request","href":"https://vra71.tirefi.re/catalog-service/api/consumer/requests/bcd175ac-1c02-4a00-b4c8-fa585f23fd2d"},{"@type":"link","rel":"GET: Parent Resource","href":"https://vra71.tirefi.re/catalog-service/api/consumer/resourceViews/700f9e3c-c7bd-41d7-9683-5d3051a8e238"},{"@type":"link","rel":"GET Template: {com.vmware.csp.component.iaas.proxy.provider@resource.action.name.machine.ChangeLease}","href":"https://vra71.tirefi.re/catalog-service/api/consumer/resources/3bf23388-38fb-44ef-ab1e-325ad1a1c582/actions/6bfd31da-dc94-4b3d-9d11-a76ca6466fee/requests/template"},{"@type":"link","rel":"POST: {com.vmware.csp.component.iaas.proxy.provider@resource.action.name.machine.ChangeLease}","href":"https://vra71.tirefi.re/catalog-service/api/consumer/resources/3bf23388-38fb-44ef-ab1e-325ad1a1c582/actions/6bfd31da-dc94-4b3d-9d11-a76ca6466fee/requests"},{"@type":"link","rel":"GET Template: {com.vmware.csp.component.iaas.proxy.provider@csp.places.iaas.item.window.ConnectViaVmrc.label}","href":"https://vra71.tirefi.re/catalog-service/api/consumer/resources/3bf23388-38fb-44ef-ab1e-325ad1a1c582/actions/beeea7b5-b75c-46ab-b3f7-92e87419d025/requests/template"},{"@type":"link","rel":"POST: {com.vmware.csp.component.iaas.proxy.provider@csp.places.iaas.item.window.ConnectViaVmrc.label}","href":"https://vra71.tirefi.re/catalog-service/api/consumer/resources/3bf23388-38fb-44ef-ab1e-325ad1a1c582/actions/beeea7b5-b75c-46ab-b3f7-92e87419d025/requests"},{"@type":"link","rel":"GET Template: {com.vmware.csp.component.iaas.proxy.provider@csp.places.iaas.item.noform.ConnectViaRdp.label}","href":"https://vra71.tirefi.re/catalog-service/api/consumer/resources/3bf23388-38fb-44ef-ab1e-325ad1a1c582/actions/33b4eb4b-1602-4d1e-802b-41c54f56b97c/requests/template"},{"@type":"link","rel":"POST: {com.vmware.csp.component.iaas.proxy.provider@csp.places.iaas.item.noform.ConnectViaRdp.label}","href":"https://vra71.tirefi.re/catalog-service/api/consumer/resources/3bf23388-38fb-44ef-ab1e-325ad1a1c582/actions/33b4eb4b-1602-4d1e-802b-41c54f56b97c/requests"},{"@type":"link","rel":"GET Template: {com.vmware.csp.component.iaas.proxy.provider@csp.places.iaas.item.nowindow.ConnectViaNativeVmrc.label}","href":"https://vra71.tirefi.re/catalog-service/api/consumer/resources/3bf23388-38fb-44ef-ab1e-325ad1a1c582/actions/39fb6669-f224-45ed-9b48-4a48a828f10a/requests/template"},{"@type":"link","rel":"POST: {com.vmware.csp.component.iaas.proxy.provider@csp.places.iaas.item.nowindow.ConnectViaNativeVmrc.label}","href":"https://vra71.tirefi.re/catalog-service/api/consumer/resources/3bf23388-38fb-44ef-ab1e-325ad1a1c582/actions/39fb6669-f224-45ed-9b48-4a48a828f10a/requests"},{"@type":"link","rel":"GET Template: {com.vmware.csp.component.iaas.proxy.provider@resource.action.name.virtual.CreateSnapshot}","href":"https://vra71.tirefi.re/catalog-service/api/consumer/resources/3bf23388-38fb-44ef-ab1e-325ad1a1c582/actions/ef01fe39-132d-4800-85b5-987a345202b2/requests/template"},{"@type":"link","rel":"POST: {com.vmware.csp.component.iaas.proxy.provider@resource.action.name.virtual.CreateSnapshot}","href":"https://vra71.tirefi.re/catalog-service/api/consumer/resources/3bf23388-38fb-44ef-ab1e-325ad1a1c582/actions/ef01fe39-132d-4800-85b5-987a345202b2/requests"},{"@type":"link","rel":"GET Template: {com.vmware.csp.component.iaas.proxy.provider@resource.action.name.virtual.Destroy}","href":"https://vra71.tirefi.re/catalog-service/api/consumer/resources/3bf23388-38fb-44ef-ab1e-325ad1a1c582/actions/4a0cfa3b-b686-43c7-9b31-600b99812b15/requests/template"},{"@type":"link","rel":"POST: {com.vmware.csp.component.iaas.proxy.provider@resource.action.name.virtual.Destroy}","href":"https://vra71.tirefi.re/catalog-service/api/consumer/resources/3bf23388-38fb-44ef-ab1e-325ad1a1c582/actions/4a0cfa3b-b686-43c7-9b31-600b99812b15/requests"},{"@type":"link","rel":"GET Template: {com.vmware.csp.component.iaas.proxy.provider@resource.action.name.machine.Expire}","href":"https://vra71.tirefi.re/catalog-service/api/consumer/resources/3bf23388-38fb-44ef-ab1e-325ad1a1c582/actions/5b0f7c6a-0bf1-497f-ab10-d0536ff0cdde/requests/template"},{"@type":"link","rel":"POST: {com.vmware.csp.component.iaas.proxy.provider@resource.action.name.machine.Expire}","href":"https://vra71.tirefi.re/catalog-service/api/consumer/resources/3bf23388-38fb-44ef-ab1e-325ad1a1c582/actions/5b0f7c6a-0bf1-497f-ab10-d0536ff0cdde/requests"},{"@type":"link","rel":"GET Template: {com.vmware.csp.component.iaas.proxy.provider@resource.action.name.machine.InstallTools}","href":"https://vra71.tirefi.re/catalog-service/api/consumer/resources/3bf23388-38fb-44ef-ab1e-325ad1a1c582/actions/7bdb5a37-5a18-4365-bc4a-f1bba27df5f7/requests/template"},{"@type":"link","rel":"POST: {com.vmware.csp.component.iaas.proxy.provider@resource.action.name.machine.InstallTools}","href":"https://vra71.tirefi.re/catalog-service/api/consumer/resources/3bf23388-38fb-44ef-ab1e-325ad1a1c582/actions/7bdb5a37-5a18-4365-bc4a-f1bba27df5f7/requests"},{"@type":"link","rel":"GET Template: {com.vmware.csp.component.iaas.proxy.provider@resource.action.name.machine.Reset}","href":"https://vra71.tirefi.re/catalog-service/api/consumer/resources/3bf23388-38fb-44ef-ab1e-325ad1a1c582/actions/7b6538e2-6eec-4618-bc92-7aafaf9f147e/requests/template"},{"@type":"link","rel":"POST: {com.vmware.csp.component.iaas.proxy.provider@resource.action.name.machine.Reset}","href":"https://vra71.tirefi.re/catalog-service/api/consumer/resources/3bf23388-38fb-44ef-ab1e-325ad1a1c582/actions/7b6538e2-6eec-4618-bc92-7aafaf9f147e/requests"},{"@type":"link","rel":"GET Template: {com.vmware.csp.component.iaas.proxy.provider@resource.action.name.machine.PowerOff}","href":"https://vra71.tirefi.re/catalog-service/api/consumer/resources/3bf23388-38fb-44ef-ab1e-325ad1a1c582/actions/1f9ffa9a-b5cf-4337-b097-6c4dc0bd52b7/requests/template"},{"@type":"link","rel":"POST: {com.vmware.csp.component.iaas.proxy.provider@resource.action.name.machine.PowerOff}","href":"https://vra71.tirefi.re/catalog-service/api/consumer/resources/3bf23388-38fb-44ef-ab1e-325ad1a1c582/actions/1f9ffa9a-b5cf-4337-b097-6c4dc0bd52b7/requests"},{"@type":"link","rel":"GET Template: {com.vmware.csp.component.iaas.proxy.provider@resource.action.name.machine.Reboot}","href":"https://vra71.tirefi.re/catalog-service/api/consumer/resources/3bf23388-38fb-44ef-ab1e-325ad1a1c582/actions/37e2bb8f-ab3c-4e4c-854b-71f85c1db9ee/requests/template"},{"@type":"link","rel":"POST: {com.vmware.csp.component.iaas.proxy.provider@resource.action.name.machine.Reboot}","href":"https://vra71.tirefi.re/catalog-service/api/consumer/resources/3bf23388-38fb-44ef-ab1e-325ad1a1c582/actions/37e2bb8f-ab3c-4e4c-854b-71f85c1db9ee/requests"},{"@type":"link","rel":"GET Template: {com.vmware.csp.component.iaas.proxy.provider@resource.action.name.machine.Reconfigure}","href":"https://vra71.tirefi.re/catalog-service/api/consumer/resources/3bf23388-38fb-44ef-ab1e-325ad1a1c582/actions/14af2ac6-827d-4854-a797-fe2b587bc968/requests/template"},{"@type":"link","rel":"POST: {com.vmware.csp.component.iaas.proxy.provider@resource.action.name.machine.Reconfigure}","href":"https://vra71.tirefi.re/catalog-service/api/consumer/resources/3bf23388-38fb-44ef-ab1e-325ad1a1c582/actions/14af2ac6-827d-4854-a797-fe2b587bc968/requests"},{"@type":"link","rel":"GET Template: {com.vmware.csp.component.iaas.proxy.provider@resource.action.name.machine.Reprovision}","href":"https://vra71.tirefi.re/catalog-service/api/consumer/resources/3bf23388-38fb-44ef-ab1e-325ad1a1c582/actions/eed48ad5-3e8e-41f2-a206-75ae79041779/requests/template"},{"@type":"link","rel":"POST: {com.vmware.csp.component.iaas.proxy.provider@resource.action.name.machine.Reprovision}","href":"https://vra71.tirefi.re/catalog-service/api/consumer/resources/3bf23388-38fb-44ef-ab1e-325ad1a1c582/actions/eed48ad5-3e8e-41f2-a206-75ae79041779/requests"},{"@type":"link","rel":"GET Template: {com.vmware.csp.component.iaas.proxy.provider@resource.action.name.machine.Shutdown}","href":"https://vra71.tirefi.re/catalog-service/api/consumer/resources/3bf23388-38fb-44ef-ab1e-325ad1a1c582/actions/a4fd65a6-8abc-493e-8315-3345b673366f/requests/template"},{"@type":"link","rel":"POST: {com.vmware.csp.component.iaas.proxy.provider@resource.action.name.machine.Shutdown}","href":"https://vra71.tirefi.re/catalog-service/api/consumer/resources/3bf23388-38fb-44ef-ab1e-325ad1a1c582/actions/a4fd65a6-8abc-493e-8315-3345b673366f/requests"},{"@type":"link","rel":"GET Template: {com.vmware.csp.component.iaas.proxy.provider@resource.action.name.machine.Suspend}","href":"https://vra71.tirefi.re/catalog-service/api/consumer/resources/3bf23388-38fb-44ef-ab1e-325ad1a1c582/actions/e1bdb142-1136-40a8-b49e-84ac5d3ed0b1/requests/template"},{"@type":"link","rel":"POST: {com.vmware.csp.component.iaas.proxy.provider@resource.action.name.machine.Suspend}","href":"https://vra71.tirefi.re/catalog-service/api/consumer/resources/3bf23388-38fb-44ef-ab1e-325ad1a1c582/actions/e1bdb142-1136-40a8-b49e-84ac5d3ed0b1/requests"}],"resourceId":"3bf23388-38fb-44ef-ab1e-325ad1a1c582","iconId":"Infrastructure.CatalogItem.Machine.Virtual.vSphere","name":"vra7-32","description":null,"status":"On","catalogItemId":null,"catalogItemLabel":null,"requestId":"bcd175ac-1c02-4a00-b4c8-fa585f23fd2d","resourceType":"Infrastructure.Virtual","owners":["vRA Admin"],"businessGroupId":"d0fb4a04-7099-4ba1-a262-b578e129a758","tenantId":"vsphere.local","dateCreated":"2016-12-01T20:03:59.946Z","lastUpdated":"2016-12-01T20:05:03.086Z","lease":{"start":"2016-12-01T19:59:54.988Z"},"costs":null,"costToDate":null,"totalCost":null,"parentResourceId":"700f9e3c-c7bd-41d7-9683-5d3051a8e238","hasChildren":false,"data":{"ChangeLease":true,"ChangeOwner":true,"Component":"vSphere_Machine_1","ConnectViaNativeVmrc":true,"ConnectViaRdp":true,"ConnectViaVmrc":true,"CreateSnapshot":true,"DISK_VOLUMES":[{"componentTypeId":"com.vmware.csp.component.iaas.proxy.provider","componentId":null,"classId":"dynamicops.api.model.DiskInputModel","typeFilter":null,"data":{"DISK_CAPACITY":28,"DISK_INPUT_ID":"DISK_INPUT_ID1","DISK_LABEL":"Hard disk 1"}}],"Destroy":true,"EXTERNAL_REFERENCE_ID":"vm-171","Expire":true,"IS_COMPONENT_MACHINE":false,"InstallTools":true,"MachineBlueprintName":"test","MachineCPU":1,"MachineDailyCost":0,"MachineDestructionDate":null,"MachineExpirationDate":null,"MachineGroupName":"tirefireadmins","MachineGuestOperatingSystem":null,"MachineInterfaceDisplayName":"vSphere (vCenter)","MachineInterfaceType":"vSphere","MachineMemory":4096,"MachineName":"vra7-32","MachineReservationName":"test","MachineStorage":28,"MachineType":"Virtual","NETWORK_LIST":[{"componentTypeId":"com.vmware.csp.component.iaas.proxy.provider","componentId":null,"classId":"dynamicops.api.model.NetworkViewModel","typeFilter":null,"data":{"NETWORK_MAC_ADDRESS":"00:50:56:8a:62:e1","NETWORK_NAME":"VM Network"}}],"PowerOff":true,"Reboot":true,"Reconfigure":true,"Reprovision":true,"Reset":true,"SNAPSHOT_LIST":[],"Shutdown":true,"Suspend":true,"VirtualMachine.Admin.UUID":"500a9c29-ab12-fc1f-6bd9-57c78eb2c3de","endpointExternalReferenceId":"1a19bcb7-e6b9-487d-b816-a10c91738fd1","ip_address":"172.16.20.147","machineId":"8bd21553-4609-41ef-bebf-60f7c66a28e0"}}],"metadata":{"size":20,"totalElements":2,"totalPages":1,"number":1,"offset":0}}
@@ -1,6 +1,7 @@
1
1
  {
2
2
  "@type": "CatalogResource",
3
3
  "id": "31a7badc-6562-458d-84f3-ec58d74a6953",
4
+ "requestId": "bogus",
4
5
  "resourceTypeRef": {
5
6
  "id": "Infrastructure.Virtual",
6
7
  "label": "Virtual Machine"
@@ -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
- [:get, :head].each do |method|
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
- [:head, :post].each do |method|
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"],
@@ -323,13 +323,74 @@ describe Vra::Resource do
323
323
  end
324
324
 
325
325
  describe "#ip_addresses" do
326
- it "returns the correct IP addresses" do
327
- skip "broken and needs to be updated per changes -JJ 2017-04-14"
328
- stub_request(:post, "https://vra.corp.local/identity/api/tokens")
329
- .with(body: '{"username":"user@corp.local","password":"password","tenant":"tenant"}',
330
- headers: { "Accept" => "application/json", "Content-Type" => "application/json" })
331
- .to_return(status: 200, body: "", headers: {})
332
- expect(resource.ip_addresses).to eq [ "192.168.110.200", "192.168.220.200" ]
326
+ let(:authn_payload) do
327
+ {
328
+ "username" => "user@corp.local",
329
+ "password" => "password",
330
+ "tenant" => "tenant",
331
+ }.to_json
332
+ end
333
+
334
+ let(:resource_view_body) do
335
+ File.read(File.join(File.dirname(__FILE__),
336
+ "fixtures",
337
+ "resource",
338
+ "ip_address.txt"))
339
+ end
340
+
341
+ before do
342
+ stub_request(
343
+ :post,
344
+ "https://vra.corp.local/identity/api/tokens"
345
+ ).with(
346
+ body: authn_payload,
347
+ headers: { "Accept" => "application/json", "Content-Type" => "application/json" }
348
+ ).to_return(
349
+ status: 200,
350
+ body: '{"id":"12345"}',
351
+ headers: {}
352
+ )
353
+
354
+ stub_request(
355
+ :head,
356
+ "https://vra.corp.local/identity/api/tokens/12345"
357
+ ).with(
358
+ headers: { "Accept" => "application/json", "Authorization" => "Bearer 12345", "Content-Type" => "application/json" }
359
+ ).to_return(
360
+ status: 204,
361
+ body: "",
362
+ headers: {}
363
+ )
364
+
365
+ stub_request(
366
+ :get,
367
+ "https://vra.corp.local/catalog-service/api/consumer/requests/bogus/resourceViews"
368
+ ).with(
369
+ headers: { "Accept" => "application/json", "Content-Type" => "application/json" }
370
+ ).to_return(
371
+ status: 200,
372
+ body: resource_view_body,
373
+ headers: {}
374
+ )
375
+ end
376
+
377
+ context "with IP address in the second element" do
378
+ it "returns the correct IP addresses" do
379
+ expect(resource.ip_addresses).to eq [ "172.16.20.147" ]
380
+ end
381
+ end
382
+
383
+ context "with IP address in the third element" do
384
+ let(:resource_view_body) do
385
+ File.read(File.join(File.dirname(__FILE__),
386
+ "fixtures",
387
+ "resource",
388
+ "ip_address_third_element.txt"))
389
+ end
390
+
391
+ it "returns the correct IP addresses" do
392
+ expect(resource.ip_addresses).to eq [ "172.16.20.147" ]
393
+ end
333
394
  end
334
395
 
335
396
  it "returns nil if there are no network interfaces" do
@@ -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
- .with("/catalog-service/api/consumer/resources")
35
- .and_return([ { "id" => "1" }, { "id" => "2" } ])
34
+ .with("/catalog-service/api/consumer/resources")
35
+ .and_return([ { "id" => "1" }, { "id" => "2" } ])
36
36
 
37
37
  items = resources.all_resources
38
38
 
@@ -1,6 +1,5 @@
1
- # coding: utf-8
2
1
  # frozen_string_literal: true
3
- lib = File.expand_path("../lib", __FILE__)
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,12 +21,12 @@ 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", "~> 1.7"
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"
29
28
  spec.add_development_dependency "rake", "~> 10.0"
30
29
  spec.add_development_dependency "rspec", "~> 3.0"
31
- spec.add_development_dependency "webmock", "~> 1.21"
30
+ spec.add_development_dependency "webmock", "~> 3.5"
32
31
 
33
32
  end
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.5.2
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: 2018-01-22 00:00:00.000000000 Z
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
@@ -129,14 +129,14 @@ dependencies:
129
129
  requirements:
130
130
  - - "~>"
131
131
  - !ruby/object:Gem::Version
132
- version: '1.21'
132
+ version: '3.5'
133
133
  type: :development
134
134
  prerelease: false
135
135
  version_requirements: !ruby/object:Gem::Requirement
136
136
  requirements:
137
137
  - - "~>"
138
138
  - !ruby/object:Gem::Version
139
- version: '1.21'
139
+ version: '3.5'
140
140
  description: Client gem for interacting with VMware vRealize Automation.
141
141
  email:
142
142
  - jj@chef.io
@@ -151,7 +151,6 @@ files:
151
151
  - ".travis.yml"
152
152
  - CHANGELOG.md
153
153
  - Gemfile
154
- - Jenkinsfile
155
154
  - LICENSE.txt
156
155
  - README.md
157
156
  - Rakefile
@@ -175,6 +174,7 @@ files:
175
174
  - spec/fixtures/catalog_request_template.json
176
175
  - spec/fixtures/resource/catalog_request.json
177
176
  - spec/fixtures/resource/ip_address.txt
177
+ - spec/fixtures/resource/ip_address_third_element.txt
178
178
  - spec/fixtures/resource/no_ip_address.txt
179
179
  - spec/fixtures/resource/non_vm_resource.json
180
180
  - spec/fixtures/resource/resource_response.json
@@ -207,8 +207,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
207
207
  - !ruby/object:Gem::Version
208
208
  version: '0'
209
209
  requirements: []
210
- rubyforge_project:
211
- rubygems_version: 2.5.1
210
+ rubygems_version: 3.1.2
212
211
  signing_key:
213
212
  specification_version: 4
214
213
  summary: Client gem for interacting with VMware vRealize Automation.
@@ -220,6 +219,7 @@ test_files:
220
219
  - spec/fixtures/catalog_request_template.json
221
220
  - spec/fixtures/resource/catalog_request.json
222
221
  - spec/fixtures/resource/ip_address.txt
222
+ - spec/fixtures/resource/ip_address_third_element.txt
223
223
  - spec/fixtures/resource/no_ip_address.txt
224
224
  - spec/fixtures/resource/non_vm_resource.json
225
225
  - spec/fixtures/resource/resource_response.json
@@ -1,31 +0,0 @@
1
- pipeline {
2
- agent {
3
- docker {
4
- args '-u root'
5
- image 'localhost:5000/jjkeysv3'
6
- }
7
-
8
- }
9
- triggers {
10
- pollSCM('H * * * *')
11
- }
12
- stages {
13
- stage('Pull down the ChefDK') {
14
- steps {
15
- sh '''apt-get update
16
- apt-get install -y curl sudo git build-essential
17
- curl -L https://chef.io/chef/install.sh | sudo bash -s -- -P chefdk -c current'''
18
- }
19
- }
20
- stage('Bundle') {
21
- steps {
22
- sh 'chef exec bundle install'
23
- }
24
- }
25
- stage('Rake') {
26
- steps {
27
- sh 'chef exec bundle exec rake '
28
- }
29
- }
30
- }
31
- }