vmware-vra 1.5.3 → 1.5.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 909b704335bdb1cf85eeb0639f8f20c458a6ad4d
4
- data.tar.gz: 047b6f2676a73b46563626ab29afbf048de3b137
3
+ metadata.gz: dae60d3196f5ec532da18527585691872db37075
4
+ data.tar.gz: 17359e6d0041c7872ab974375f0a25f60f1794cb
5
5
  SHA512:
6
- metadata.gz: 5bd6ab876d957d8381279b5232e42fb17c8f3a934efe0c3f8911efb298c39ebe1b9e8f6f0b73f287330776903323e4e5ec79df251fdc22e9004881d97821b6b3
7
- data.tar.gz: 510320dd20f2eb5d6998015c5cc38f183b5f360afd484152cf817d3cf8319d92393c11117bf63ea0bb851c8b342203eb3551fe06fc06927c4c1bf0ce1b901ab2
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
 
@@ -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
- @catalog_item_data['organization']['tenantRef']
69
+ organization['tenantRef']
64
70
  end
65
71
 
66
72
  def tenant_name
67
- @catalog_item_data['organization']['tenantLabel']
73
+ organization['tenantLabel']
68
74
  end
69
75
 
70
76
  def subtenant_id
71
- @catalog_item_data['organization']['subtenantRef']
77
+ organization['subtenantRef']
72
78
  end
73
79
 
74
80
  def subtenant_name
75
- @catalog_item_data['organization']['subtenantLabel']
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
- resource_data['organization']['tenantRef']
77
+ organization['tenantRef']
72
78
  end
73
79
 
74
80
  def tenant_name
75
- resource_data['organization']['tenantLabel']
81
+ organization['tenantLabel']
76
82
  end
77
83
 
78
84
  def subtenant_id
79
- resource_data['organization']['subtenantRef']
85
+ organization['subtenantRef']
80
86
  end
81
87
 
82
88
  def subtenant_name
83
- resource_data['organization']['subtenantLabel']
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
- resource_data['catalogItem']['id']
99
+ catalog_item['id']
88
100
  end
89
101
 
90
102
  def catalog_name
91
- resource_data['catalogItem']['label']
103
+ catalog_item['label']
92
104
  end
93
105
 
94
106
  def owner_ids
data/lib/vra/version.rb CHANGED
@@ -17,5 +17,5 @@
17
17
  #
18
18
 
19
19
  module Vra
20
- VERSION = '1.5.3'.freeze
20
+ VERSION = '1.5.4'.freeze
21
21
  end
@@ -18,7 +18,7 @@
18
18
 
19
19
  require 'spec_helper'
20
20
 
21
- describe Vra::CatalogRequest do
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::Resource.new(client, data: catalog_item_payload)
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.3
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-18 00:00:00.000000000 Z
11
+ date: 2016-04-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rest-client