vmware-vra 2.1.0 → 2.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.rubocop.yml +5 -14
- data/CHANGELOG.md +8 -1
- data/Gemfile +1 -1
- data/README.md +1 -1
- data/Rakefile +8 -5
- data/lib/vra.rb +11 -11
- data/lib/vra/catalog.rb +3 -3
- data/lib/vra/catalog_item.rb +14 -14
- data/lib/vra/catalog_request.rb +9 -9
- data/lib/vra/client.rb +29 -27
- data/lib/vra/exceptions.rb +5 -5
- data/lib/vra/http.rb +9 -9
- data/lib/vra/request.rb +6 -6
- data/lib/vra/request_parameters.rb +7 -7
- data/lib/vra/requests.rb +2 -2
- data/lib/vra/resource.rb +69 -69
- data/lib/vra/resources.rb +1 -1
- data/lib/vra/version.rb +1 -1
- data/spec/catalog_item_spec.rb +61 -61
- data/spec/catalog_request_spec.rb +61 -61
- data/spec/catalog_spec.rb +58 -58
- data/spec/client_spec.rb +187 -187
- data/spec/http_spec.rb +59 -59
- data/spec/request_spec.rb +43 -43
- data/spec/requests_spec.rb +15 -15
- data/spec/resource_spec.rb +163 -163
- data/spec/resources_spec.rb +15 -15
- data/spec/spec_helper.rb +2 -2
- data/vmware-vra.gemspec +18 -18
- metadata +18 -17
data/lib/vra/request.rb
CHANGED
@@ -17,7 +17,7 @@
|
|
17
17
|
# limitations under the License.
|
18
18
|
#
|
19
19
|
|
20
|
-
require
|
20
|
+
require "ffi_yajl"
|
21
21
|
|
22
22
|
module Vra
|
23
23
|
class Request
|
@@ -50,7 +50,7 @@ module Vra
|
|
50
50
|
refresh_if_empty
|
51
51
|
return if request_empty?
|
52
52
|
|
53
|
-
@request_data[
|
53
|
+
@request_data["phase"]
|
54
54
|
end
|
55
55
|
|
56
56
|
def completed?
|
@@ -58,25 +58,25 @@ module Vra
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def successful?
|
61
|
-
status ==
|
61
|
+
status == "SUCCESSFUL"
|
62
62
|
end
|
63
63
|
|
64
64
|
def failed?
|
65
|
-
status ==
|
65
|
+
status == "FAILED"
|
66
66
|
end
|
67
67
|
|
68
68
|
def completion_state
|
69
69
|
refresh_if_empty
|
70
70
|
return if request_empty?
|
71
71
|
|
72
|
-
@request_data[
|
72
|
+
@request_data["requestCompletion"]["requestCompletionState"]
|
73
73
|
end
|
74
74
|
|
75
75
|
def completion_details
|
76
76
|
refresh_if_empty
|
77
77
|
return if request_empty?
|
78
78
|
|
79
|
-
@request_data[
|
79
|
+
@request_data["requestCompletion"]["completionDetails"]
|
80
80
|
end
|
81
81
|
|
82
82
|
def resources
|
@@ -46,19 +46,19 @@ module Vra
|
|
46
46
|
|
47
47
|
def to_h
|
48
48
|
{
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
}
|
49
|
+
"key" => @key,
|
50
|
+
"value" => {
|
51
|
+
"type" => @type,
|
52
|
+
"value" => format_value,
|
53
|
+
},
|
54
54
|
}
|
55
55
|
end
|
56
56
|
|
57
57
|
def format_value
|
58
58
|
case @type
|
59
|
-
when
|
59
|
+
when "integer"
|
60
60
|
@value.to_i
|
61
|
-
when
|
61
|
+
when "string"
|
62
62
|
@value.to_s
|
63
63
|
else
|
64
64
|
@value.to_s
|
data/lib/vra/requests.rb
CHANGED
@@ -26,9 +26,9 @@ module Vra
|
|
26
26
|
def all_requests
|
27
27
|
requests = []
|
28
28
|
|
29
|
-
items = @client.http_get_paginated_array!(
|
29
|
+
items = @client.http_get_paginated_array!("/catalog-service/api/consumer/requests")
|
30
30
|
items.each do |item|
|
31
|
-
requests << Vra::Request.new(@client, item[
|
31
|
+
requests << Vra::Request.new(@client, item["id"])
|
32
32
|
end
|
33
33
|
|
34
34
|
requests
|
data/lib/vra/resource.rb
CHANGED
@@ -17,7 +17,7 @@
|
|
17
17
|
# limitations under the License.
|
18
18
|
#
|
19
19
|
|
20
|
-
require
|
20
|
+
require "ffi_yajl"
|
21
21
|
|
22
22
|
module Vra
|
23
23
|
# rubocop:disable ClassLength
|
@@ -31,17 +31,17 @@ module Vra
|
|
31
31
|
@resource_actions = []
|
32
32
|
|
33
33
|
if @id.nil? && @resource_data.nil?
|
34
|
-
raise ArgumentError,
|
34
|
+
raise ArgumentError, "must supply an id or a resource data hash"
|
35
35
|
end
|
36
36
|
|
37
37
|
if !@id.nil? && !@resource_data.nil?
|
38
|
-
raise ArgumentError,
|
38
|
+
raise ArgumentError, "must supply an id OR a resource data hash, not both"
|
39
39
|
end
|
40
40
|
|
41
41
|
if @resource_data.nil?
|
42
42
|
fetch_resource_data
|
43
43
|
else
|
44
|
-
@id = @resource_data[
|
44
|
+
@id = @resource_data["id"]
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
@@ -53,103 +53,103 @@ module Vra
|
|
53
53
|
alias refresh fetch_resource_data
|
54
54
|
|
55
55
|
def name
|
56
|
-
resource_data[
|
56
|
+
resource_data["name"]
|
57
57
|
end
|
58
58
|
|
59
59
|
def description
|
60
|
-
resource_data[
|
60
|
+
resource_data["description"]
|
61
61
|
end
|
62
62
|
|
63
63
|
def status
|
64
|
-
resource_data[
|
64
|
+
resource_data["status"]
|
65
65
|
end
|
66
66
|
|
67
67
|
def vm?
|
68
|
-
%w
|
68
|
+
%w{Infrastructure.Virtual Infrastructure.Cloud}.include?(resource_data["resourceTypeRef"]["id"])
|
69
69
|
end
|
70
70
|
|
71
71
|
def organization
|
72
|
-
return {} if resource_data[
|
72
|
+
return {} if resource_data["organization"].nil?
|
73
73
|
|
74
|
-
resource_data[
|
74
|
+
resource_data["organization"]
|
75
75
|
end
|
76
76
|
|
77
77
|
def tenant_id
|
78
|
-
organization[
|
78
|
+
organization["tenantRef"]
|
79
79
|
end
|
80
80
|
|
81
81
|
def tenant_name
|
82
|
-
organization[
|
82
|
+
organization["tenantLabel"]
|
83
83
|
end
|
84
84
|
|
85
85
|
def subtenant_id
|
86
|
-
organization[
|
86
|
+
organization["subtenantRef"]
|
87
87
|
end
|
88
88
|
|
89
89
|
def subtenant_name
|
90
|
-
organization[
|
90
|
+
organization["subtenantLabel"]
|
91
91
|
end
|
92
92
|
|
93
93
|
def catalog_item
|
94
|
-
return {} if resource_data[
|
94
|
+
return {} if resource_data["catalogItem"].nil?
|
95
95
|
|
96
|
-
resource_data[
|
96
|
+
resource_data["catalogItem"]
|
97
97
|
end
|
98
98
|
|
99
99
|
def catalog_id
|
100
|
-
catalog_item[
|
100
|
+
catalog_item["id"]
|
101
101
|
end
|
102
102
|
|
103
103
|
def catalog_name
|
104
|
-
catalog_item[
|
104
|
+
catalog_item["label"]
|
105
105
|
end
|
106
106
|
|
107
107
|
def owner_ids
|
108
|
-
resource_data[
|
108
|
+
resource_data["owners"].map { |x| x["ref"] }
|
109
109
|
end
|
110
110
|
|
111
111
|
def owner_names
|
112
|
-
resource_data[
|
112
|
+
resource_data["owners"].map { |x| x["value"] }
|
113
113
|
end
|
114
114
|
|
115
115
|
def machine_status
|
116
|
-
status = resource_data[
|
117
|
-
raise
|
116
|
+
status = resource_data["resourceData"]["entries"].find { |x| x["key"] == "MachineStatus" }
|
117
|
+
raise "No MachineStatus entry available for resource" if status.nil?
|
118
118
|
|
119
|
-
status[
|
119
|
+
status["value"]["value"]
|
120
120
|
end
|
121
121
|
|
122
122
|
def machine_on?
|
123
|
-
machine_status ==
|
123
|
+
machine_status == "On"
|
124
124
|
end
|
125
125
|
|
126
126
|
def machine_off?
|
127
|
-
machine_status ==
|
127
|
+
machine_status == "Off"
|
128
128
|
end
|
129
129
|
|
130
130
|
def machine_turning_on?
|
131
|
-
machine_status ==
|
131
|
+
machine_status == "TurningOn" || machine_status == "MachineActivated"
|
132
132
|
end
|
133
133
|
|
134
134
|
def machine_turning_off?
|
135
|
-
%w
|
135
|
+
%w{TurningOff ShuttingDown}.include?(machine_status)
|
136
136
|
end
|
137
137
|
|
138
138
|
def machine_in_provisioned_state?
|
139
|
-
machine_status ==
|
139
|
+
machine_status == "MachineProvisioned"
|
140
140
|
end
|
141
141
|
|
142
142
|
def network_interfaces
|
143
143
|
return unless vm?
|
144
144
|
|
145
|
-
network_list = resource_data[
|
145
|
+
network_list = resource_data["resourceData"]["entries"].find { |x| x["key"] == "NETWORK_LIST" }
|
146
146
|
return if network_list.nil?
|
147
147
|
|
148
|
-
network_list[
|
148
|
+
network_list["value"]["items"].each_with_object([]) do |item, nics|
|
149
149
|
nic = {}
|
150
|
-
item[
|
151
|
-
key = entry[
|
152
|
-
value = entry[
|
150
|
+
item["values"]["entries"].each do |entry|
|
151
|
+
key = entry["key"]
|
152
|
+
value = entry["value"]["value"]
|
153
153
|
nic[key] = value
|
154
154
|
end
|
155
155
|
|
@@ -162,26 +162,26 @@ module Vra
|
|
162
162
|
|
163
163
|
addrs = []
|
164
164
|
|
165
|
-
request_id = @resource_data[
|
165
|
+
request_id = @resource_data["requestId"]
|
166
166
|
|
167
167
|
resource_views = @client.http_get("/catalog-service/api/consumer/requests/#{request_id}/resourceViews")
|
168
168
|
|
169
|
-
data_zero = JSON.parse(resource_views.body)[
|
170
|
-
data_one = JSON.parse(resource_views.body)[
|
169
|
+
data_zero = JSON.parse(resource_views.body)["content"][0]["data"]["ip_address"]
|
170
|
+
data_one = JSON.parse(resource_views.body)["content"][1]["data"]["ip_address"]
|
171
171
|
|
172
|
-
print
|
173
|
-
while (data_zero ==
|
172
|
+
print "Waiting For vRA to collect the IP"
|
173
|
+
while (data_zero == "" || data_one == "") && (data_zero.nil? || data_one.nil?)
|
174
174
|
resource_views = @client.http_get("/catalog-service/api/consumer/requests/#{request_id}/resourceViews")
|
175
|
-
data_zero = JSON.parse(resource_views.body)[
|
176
|
-
data_one = JSON.parse(resource_views.body)[
|
175
|
+
data_zero = JSON.parse(resource_views.body)["content"][0]["data"]["ip_address"]
|
176
|
+
data_one = JSON.parse(resource_views.body)["content"][1]["data"]["ip_address"]
|
177
177
|
sleep 10
|
178
|
-
print
|
178
|
+
print "."
|
179
179
|
end
|
180
180
|
|
181
|
-
ip_address = if JSON.parse(resource_views.body)[
|
182
|
-
JSON.parse(resource_views.body)[
|
181
|
+
ip_address = if JSON.parse(resource_views.body)["content"][0]["data"]["ip_address"].nil?
|
182
|
+
JSON.parse(resource_views.body)["content"][1]["data"]["ip_address"]
|
183
183
|
else
|
184
|
-
JSON.parse(resource_views.body)[
|
184
|
+
JSON.parse(resource_views.body)["content"][0]["data"]["ip_address"]
|
185
185
|
end
|
186
186
|
|
187
187
|
addrs << ip_address
|
@@ -191,43 +191,43 @@ module Vra
|
|
191
191
|
def actions
|
192
192
|
# if this Resource instance was created with data from a "all_resources" fetch,
|
193
193
|
# it is likely missing operations data because the vRA API is not pleasant sometimes.
|
194
|
-
fetch_resource_data if resource_data[
|
194
|
+
fetch_resource_data if resource_data["operations"].nil?
|
195
195
|
|
196
|
-
resource_data[
|
196
|
+
resource_data["operations"]
|
197
197
|
end
|
198
198
|
|
199
199
|
def action_id_by_name(name)
|
200
200
|
return if actions.nil?
|
201
201
|
|
202
|
-
action = actions.find { |x| x[
|
202
|
+
action = actions.find { |x| x["name"] == name }
|
203
203
|
return if action.nil?
|
204
204
|
|
205
|
-
action[
|
205
|
+
action["id"]
|
206
206
|
end
|
207
207
|
|
208
208
|
def destroy
|
209
|
-
action_id = action_id_by_name(
|
209
|
+
action_id = action_id_by_name("Destroy")
|
210
210
|
raise Vra::Exception::NotFound, "No destroy action found for resource #{@id}" if action_id.nil?
|
211
211
|
|
212
212
|
submit_action_request(action_id)
|
213
213
|
end
|
214
214
|
|
215
215
|
def shutdown
|
216
|
-
action_id = action_id_by_name(
|
216
|
+
action_id = action_id_by_name("Shutdown")
|
217
217
|
raise Vra::Exception::NotFound, "No shutdown action found for resource #{@id}" if action_id.nil?
|
218
218
|
|
219
219
|
submit_action_request(action_id)
|
220
220
|
end
|
221
221
|
|
222
222
|
def poweroff
|
223
|
-
action_id = action_id_by_name(
|
223
|
+
action_id = action_id_by_name("Power Off")
|
224
224
|
raise Vra::Exception::NotFound, "No power-off action found for resource #{@id}" if action_id.nil?
|
225
225
|
|
226
226
|
submit_action_request(action_id)
|
227
227
|
end
|
228
228
|
|
229
229
|
def poweron
|
230
|
-
action_id = action_id_by_name(
|
230
|
+
action_id = action_id_by_name("Power On")
|
231
231
|
raise Vra::Exception::NotFound, "No power-on action found for resource #{@id}" if action_id.nil?
|
232
232
|
|
233
233
|
submit_action_request(action_id)
|
@@ -235,31 +235,31 @@ module Vra
|
|
235
235
|
|
236
236
|
def action_request_payload(action_id)
|
237
237
|
{
|
238
|
-
|
239
|
-
|
240
|
-
|
238
|
+
"@type" => "ResourceActionRequest",
|
239
|
+
"resourceRef" => {
|
240
|
+
"id" => @id,
|
241
241
|
},
|
242
|
-
|
243
|
-
|
242
|
+
"resourceActionRef" => {
|
243
|
+
"id" => action_id,
|
244
244
|
},
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
245
|
+
"organization" => {
|
246
|
+
"tenantRef" => tenant_id,
|
247
|
+
"tenantLabel" => tenant_name,
|
248
|
+
"subtenantRef" => subtenant_id,
|
249
|
+
"subtenantLabel" => subtenant_name,
|
250
|
+
},
|
251
|
+
"state" => "SUBMITTED",
|
252
|
+
"requestNumber" => 0,
|
253
|
+
"requestData" => {
|
254
|
+
"entries" => [],
|
250
255
|
},
|
251
|
-
'state' => 'SUBMITTED',
|
252
|
-
'requestNumber' => 0,
|
253
|
-
'requestData' => {
|
254
|
-
'entries' => []
|
255
|
-
}
|
256
256
|
}
|
257
257
|
end
|
258
258
|
|
259
259
|
def submit_action_request(action_id)
|
260
260
|
payload = action_request_payload(action_id).to_json
|
261
|
-
response = client.http_post(
|
262
|
-
request_id = response.location.split(
|
261
|
+
response = client.http_post("/catalog-service/api/consumer/requests", payload)
|
262
|
+
request_id = response.location.split("/")[-1]
|
263
263
|
Vra::Request.new(client, request_id)
|
264
264
|
end
|
265
265
|
end
|
data/lib/vra/resources.rb
CHANGED
@@ -28,7 +28,7 @@ module Vra
|
|
28
28
|
def all_resources
|
29
29
|
resources = []
|
30
30
|
|
31
|
-
items = client.http_get_paginated_array!(
|
31
|
+
items = client.http_get_paginated_array!("/catalog-service/api/consumer/resources")
|
32
32
|
items.each do |item|
|
33
33
|
resources << Vra::Resource.new(client, data: item)
|
34
34
|
end
|
data/lib/vra/version.rb
CHANGED
data/spec/catalog_item_spec.rb
CHANGED
@@ -17,122 +17,122 @@
|
|
17
17
|
# limitations under the License.
|
18
18
|
#
|
19
19
|
|
20
|
-
require
|
20
|
+
require "spec_helper"
|
21
21
|
|
22
22
|
describe Vra::CatalogItem do
|
23
23
|
let(:client) do
|
24
|
-
Vra::Client.new(username:
|
25
|
-
password:
|
26
|
-
tenant:
|
27
|
-
base_url:
|
24
|
+
Vra::Client.new(username: "user@corp.local",
|
25
|
+
password: "password",
|
26
|
+
tenant: "tenant",
|
27
|
+
base_url: "https://vra.corp.local")
|
28
28
|
end
|
29
29
|
|
30
|
-
let(:catalog_id) {
|
30
|
+
let(:catalog_id) { "9e98042e-5443-4082-afd5-ab5a32939bbc" }
|
31
31
|
|
32
32
|
let(:catalog_item_payload) do
|
33
33
|
{
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
34
|
+
"@type" => "CatalogItem",
|
35
|
+
"id" => "9e98042e-5443-4082-afd5-ab5a32939bbc",
|
36
|
+
"version" => 2,
|
37
|
+
"name" => "CentOS 6.6",
|
38
|
+
"description" => "Blueprint for deploying a CentOS Linux development server",
|
39
|
+
"status" => "PUBLISHED",
|
40
|
+
"statusName" => "Published",
|
41
|
+
"organization" => {
|
42
|
+
"tenantRef" => "vsphere.local",
|
43
|
+
"tenantLabel" => "vsphere.local",
|
44
|
+
"subtenantRef" => "962ab3f9-858c-4483-a49f-fa97392c314b",
|
45
|
+
"subtenantLabel" => "catalog_subtenant",
|
46
|
+
},
|
47
|
+
"providerBinding" => {
|
48
|
+
"bindingId" => "33af5413-4f20-4b3b-8268-32edad434dfb",
|
49
|
+
"providerRef" => {
|
50
|
+
"id" => "c3b2bc30-47b0-454f-b57d-df02a7356fe6",
|
51
|
+
"label" => "iaas-service",
|
52
|
+
},
|
46
53
|
},
|
47
|
-
'providerBinding' => {
|
48
|
-
'bindingId' => '33af5413-4f20-4b3b-8268-32edad434dfb',
|
49
|
-
'providerRef' => {
|
50
|
-
'id' => 'c3b2bc30-47b0-454f-b57d-df02a7356fe6',
|
51
|
-
'label' => 'iaas-service'
|
52
|
-
}
|
53
|
-
}
|
54
54
|
}
|
55
55
|
end
|
56
56
|
|
57
|
-
describe
|
58
|
-
it
|
57
|
+
describe "#initialize" do
|
58
|
+
it "raises an error if no ID or catalog item data have been provided" do
|
59
59
|
expect { Vra::CatalogItem.new }.to raise_error(ArgumentError)
|
60
60
|
end
|
61
61
|
|
62
|
-
it
|
63
|
-
expect { Vra::CatalogItem.new(id: 123, data:
|
62
|
+
it "raises an error if an ID and catalog item data have both been provided" do
|
63
|
+
expect { Vra::CatalogItem.new(id: 123, data: "foo") }.to raise_error(ArgumentError)
|
64
64
|
end
|
65
65
|
|
66
|
-
context
|
67
|
-
it
|
66
|
+
context "when an ID is provided" do
|
67
|
+
it "fetches the catalog_item record" do
|
68
68
|
catalog_item = Vra::CatalogItem.allocate
|
69
69
|
expect(catalog_item).to receive(:fetch_catalog_item)
|
70
70
|
catalog_item.send(:initialize, client, id: catalog_id)
|
71
71
|
end
|
72
72
|
end
|
73
73
|
|
74
|
-
context
|
75
|
-
it
|
74
|
+
context "when catalog item data is provided" do
|
75
|
+
it "populates the ID correctly" do
|
76
76
|
catalog_item = Vra::CatalogItem.new(client, data: catalog_item_payload)
|
77
77
|
expect(catalog_item.id).to eq catalog_id
|
78
78
|
end
|
79
79
|
end
|
80
80
|
end
|
81
81
|
|
82
|
-
describe
|
83
|
-
context
|
84
|
-
let(:response) { double(
|
82
|
+
describe "#fetch_catalog_item" do
|
83
|
+
context "when the catalog item exists" do
|
84
|
+
let(:response) { double("response", code: 200, body: catalog_item_payload.to_json) }
|
85
85
|
|
86
|
-
it
|
87
|
-
expect(client).to receive(:http_get).with(
|
88
|
-
Vra::CatalogItem.new(client, id:
|
86
|
+
it "calls http_get against the catalog_service" do
|
87
|
+
expect(client).to receive(:http_get).with("/catalog-service/api/consumer/catalogItems/catalog-12345").and_return(response)
|
88
|
+
Vra::CatalogItem.new(client, id: "catalog-12345")
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
|
-
context
|
93
|
-
it
|
94
|
-
allow(client).to receive(:http_get).with(
|
95
|
-
expect { Vra::CatalogItem.new(client, id:
|
92
|
+
context "when the catalog item does not exist" do
|
93
|
+
it "raises an exception" do
|
94
|
+
allow(client).to receive(:http_get).with("/catalog-service/api/consumer/catalogItems/catalog-12345").and_raise(Vra::Exception::HTTPNotFound)
|
95
|
+
expect { Vra::CatalogItem.new(client, id: "catalog-12345") }.to raise_error(Vra::Exception::NotFound)
|
96
96
|
end
|
97
97
|
end
|
98
98
|
end
|
99
99
|
|
100
|
-
describe
|
100
|
+
describe "#organization" do
|
101
101
|
let(:catalog_item) { Vra::CatalogItem.new(client, data: catalog_item_payload) }
|
102
102
|
|
103
|
-
context
|
103
|
+
context "when organization data exists" do
|
104
104
|
let(:catalog_item_payload) do
|
105
105
|
{
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
}
|
106
|
+
"@type" => "CatalogItem",
|
107
|
+
"id" => "9e98042e-5443-4082-afd5-ab5a32939bbc",
|
108
|
+
"organization" => {
|
109
|
+
"tenantRef" => "vsphere.local",
|
110
|
+
"tenantLabel" => "vsphere.local",
|
111
|
+
"subtenantRef" => "962ab3f9-858c-4483-a49f-fa97392c314b",
|
112
|
+
"subtenantLabel" => "catalog_subtenant",
|
113
|
+
},
|
114
114
|
}
|
115
115
|
end
|
116
116
|
|
117
|
-
it
|
118
|
-
expect(catalog_item.organization[
|
117
|
+
it "returns the correct organization data" do
|
118
|
+
expect(catalog_item.organization["tenantRef"]).to eq("vsphere.local")
|
119
119
|
end
|
120
120
|
end
|
121
121
|
|
122
|
-
context
|
122
|
+
context "when organization data does not exist" do
|
123
123
|
let(:catalog_item_payload) do
|
124
124
|
{
|
125
|
-
|
126
|
-
|
125
|
+
"@type" => "CatalogItem",
|
126
|
+
"id" => "9e98042e-5443-4082-afd5-ab5a32939bbc",
|
127
127
|
}
|
128
128
|
end
|
129
129
|
|
130
|
-
it
|
130
|
+
it "returns an empty hash" do
|
131
131
|
expect(catalog_item.organization).to eq({})
|
132
132
|
end
|
133
133
|
|
134
|
-
it
|
135
|
-
expect(catalog_item.organization[
|
134
|
+
it "returns nil for any organization keys" do
|
135
|
+
expect(catalog_item.organization["tenantRef"]).to eq(nil)
|
136
136
|
end
|
137
137
|
end
|
138
138
|
end
|