vmware-vra 1.5.3 → 1.5.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/vra/catalog_item.rb +10 -4
- data/lib/vra/resource.rb +18 -6
- data/lib/vra/version.rb +1 -1
- data/spec/catalog_item_spec.rb +42 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dae60d3196f5ec532da18527585691872db37075
|
4
|
+
data.tar.gz: 17359e6d0041c7872ab974375f0a25f60f1794cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5f918bbddfde58b24f9c948a5f9c49c3b3648cb6cc96ae19eeb06803491fb2250881c2f02c5a2dd71a954886f6c454b18fd992f46c1b7f8fc8e80a416b5148db
|
7
|
+
data.tar.gz: a96438c7ff9e64f15cb076bf7a403dbe71a9b0fd57e3c662dfc9ce72a7192bb6f510c292aa510da8607d77cc8f5d4bc6c1ed3292f0dacaa53ac1fce50763d565
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# vmware-vra-gem CHANGELOG
|
2
2
|
|
3
|
+
## v1.5.4 (2016-04-27)
|
4
|
+
* [pr#29](https://github.com/chef-partners/vmware-vra-gem/pull/29) Bug fix: handle more gracefully the situations where a resource or catalog item is missing data in the API response
|
5
|
+
|
3
6
|
## v1.5.3 (2016-04-18)
|
4
7
|
* [pr#25](https://github.com/chef-partners/vmware-vra-gem/pull/25) Bug fix: use the proper exception helper method when raising exceptions encountered during HTTP HEAD requests
|
5
8
|
|
data/lib/vra/catalog_item.rb
CHANGED
@@ -59,20 +59,26 @@ module Vra
|
|
59
59
|
@catalog_item_data['status']
|
60
60
|
end
|
61
61
|
|
62
|
+
def organization
|
63
|
+
return {} if @catalog_item_data['organization'].nil?
|
64
|
+
|
65
|
+
@catalog_item_data['organization']
|
66
|
+
end
|
67
|
+
|
62
68
|
def tenant_id
|
63
|
-
|
69
|
+
organization['tenantRef']
|
64
70
|
end
|
65
71
|
|
66
72
|
def tenant_name
|
67
|
-
|
73
|
+
organization['tenantLabel']
|
68
74
|
end
|
69
75
|
|
70
76
|
def subtenant_id
|
71
|
-
|
77
|
+
organization['subtenantRef']
|
72
78
|
end
|
73
79
|
|
74
80
|
def subtenant_name
|
75
|
-
|
81
|
+
organization['subtenantLabel']
|
76
82
|
end
|
77
83
|
|
78
84
|
def blueprint_id
|
data/lib/vra/resource.rb
CHANGED
@@ -67,28 +67,40 @@ module Vra
|
|
67
67
|
%w(Infrastructure.Virtual Infrastructure.Cloud).include?(resource_data['resourceTypeRef']['id'])
|
68
68
|
end
|
69
69
|
|
70
|
+
def organization
|
71
|
+
return {} if resource_data['organization'].nil?
|
72
|
+
|
73
|
+
resource_data['organization']
|
74
|
+
end
|
75
|
+
|
70
76
|
def tenant_id
|
71
|
-
|
77
|
+
organization['tenantRef']
|
72
78
|
end
|
73
79
|
|
74
80
|
def tenant_name
|
75
|
-
|
81
|
+
organization['tenantLabel']
|
76
82
|
end
|
77
83
|
|
78
84
|
def subtenant_id
|
79
|
-
|
85
|
+
organization['subtenantRef']
|
80
86
|
end
|
81
87
|
|
82
88
|
def subtenant_name
|
83
|
-
|
89
|
+
organization['subtenantLabel']
|
90
|
+
end
|
91
|
+
|
92
|
+
def catalog_item
|
93
|
+
return {} if resource_data['catalogItem'].nil?
|
94
|
+
|
95
|
+
resource_data['catalogItem']
|
84
96
|
end
|
85
97
|
|
86
98
|
def catalog_id
|
87
|
-
|
99
|
+
catalog_item['id']
|
88
100
|
end
|
89
101
|
|
90
102
|
def catalog_name
|
91
|
-
|
103
|
+
catalog_item['label']
|
92
104
|
end
|
93
105
|
|
94
106
|
def owner_ids
|
data/lib/vra/version.rb
CHANGED
data/spec/catalog_item_spec.rb
CHANGED
@@ -18,7 +18,7 @@
|
|
18
18
|
|
19
19
|
require 'spec_helper'
|
20
20
|
|
21
|
-
describe Vra::
|
21
|
+
describe Vra::CatalogItem do
|
22
22
|
let(:client) do
|
23
23
|
Vra::Client.new(username: 'user@corp.local',
|
24
24
|
password: 'password',
|
@@ -72,7 +72,7 @@ describe Vra::CatalogRequest do
|
|
72
72
|
|
73
73
|
context 'when catalog item data is provided' do
|
74
74
|
it 'populates the ID correctly' do
|
75
|
-
catalog_item = Vra::
|
75
|
+
catalog_item = Vra::CatalogItem.new(client, data: catalog_item_payload)
|
76
76
|
expect(catalog_item.id).to eq catalog_id
|
77
77
|
end
|
78
78
|
end
|
@@ -95,4 +95,44 @@ describe Vra::CatalogRequest do
|
|
95
95
|
end
|
96
96
|
end
|
97
97
|
end
|
98
|
+
|
99
|
+
describe '#organization' do
|
100
|
+
let(:catalog_item) { Vra::CatalogItem.new(client, data: catalog_item_payload) }
|
101
|
+
|
102
|
+
context 'when organization data exists' do
|
103
|
+
let(:catalog_item_payload) do
|
104
|
+
{
|
105
|
+
'@type' => 'CatalogItem',
|
106
|
+
'id' => '9e98042e-5443-4082-afd5-ab5a32939bbc',
|
107
|
+
'organization' => {
|
108
|
+
'tenantRef' => 'vsphere.local',
|
109
|
+
'tenantLabel' => 'vsphere.local',
|
110
|
+
'subtenantRef' => '962ab3f9-858c-4483-a49f-fa97392c314b',
|
111
|
+
'subtenantLabel' => 'catalog_subtenant'
|
112
|
+
}
|
113
|
+
}
|
114
|
+
end
|
115
|
+
|
116
|
+
it 'returns the correct organization data' do
|
117
|
+
expect(catalog_item.organization['tenantRef']).to eq('vsphere.local')
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
context 'when organization data does not exist' do
|
122
|
+
let(:catalog_item_payload) do
|
123
|
+
{
|
124
|
+
'@type' => 'CatalogItem',
|
125
|
+
'id' => '9e98042e-5443-4082-afd5-ab5a32939bbc'
|
126
|
+
}
|
127
|
+
end
|
128
|
+
|
129
|
+
it 'returns an empty hash' do
|
130
|
+
expect(catalog_item.organization).to eq({})
|
131
|
+
end
|
132
|
+
|
133
|
+
it 'returns nil for any organization keys' do
|
134
|
+
expect(catalog_item.organization['tenantRef']).to eq(nil)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
98
138
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vmware-vra
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Leff
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-04-
|
11
|
+
date: 2016-04-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rest-client
|