vmware-vra 3.0.1 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -0
- data/README.md +4 -2
- data/lib/vra/catalog_item.rb +14 -2
- data/lib/vra/deployment_request.rb +11 -3
- data/lib/vra/version.rb +1 -1
- data/spec/catalog_item_spec.rb +33 -0
- data/spec/deployment_request_spec.rb +39 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55b844fe4edf716d4c6668cfa5c13721caa0f36a4873aae4f2949509cf6bfc1c
|
4
|
+
data.tar.gz: 5a68b428aa38c0e30a8ba89790ccdb5fd9b5d233485497886cd4d290f4f528d0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b41f6cf8aca5fde7912e59937a569af9b0fb550877a07eb1302edd94b02a3caac478ca41474786fbf2293c2a96fc3334440b0eb72784a7b48c41090a401a9f99
|
7
|
+
data.tar.gz: 3dfa51c5e343ca7994f9240afa7b6b2f81de243bd88de0b8a9f19f9d189d571a4d95d4fe00628950a50673e8e15f4f2b849cf78456edc8423ff20aa512a84eb8
|
data/CHANGELOG.md
CHANGED
@@ -1,4 +1,10 @@
|
|
1
1
|
# Change Log
|
2
|
+
|
3
|
+
## [3.1.0](https://github.com/chef-partners/vmware-vra-gem/tree/v3.1.0) (2022-01-30)
|
4
|
+
[Full Changelog](https://github.com/chef-partners/vmware-vra-gem/compare/v3.0.1...v3.1.0)
|
5
|
+
|
6
|
+
- Make the version param optional in deployment request api
|
7
|
+
|
2
8
|
## [3.0.1](https://github.com/chef-partners/vmware-vra-gem/tree/v3.0.1) (2022-01-25)
|
3
9
|
[Full Changelog](https://github.com/chef-partners/vmware-vra-gem/compare/v3.0.0...v3.0.1)
|
4
10
|
|
data/README.md
CHANGED
@@ -125,8 +125,10 @@ request = client.catalog.request(
|
|
125
125
|
#<Vra::DeploymentRequest:0x00007fb7340b7438
|
126
126
|
...
|
127
127
|
```
|
128
|
-
To request a deployment from a catalog item, you can use the above method with a project ID that has a cloud template version released to the project.
|
129
|
-
|
128
|
+
To request a deployment from a catalog item, you can use the above method with a project ID that has a cloud template version released to the project.
|
129
|
+
|
130
|
+
The ID of the catalog item from which you are requesting the deployment should be also included, and the version of the released cloud template. If the user doesn't specify a version explicitly, the latest version will be fetched automatically and will be used for the request.
|
131
|
+
|
130
132
|
Additionally, the name of the deployment should be specified and it should be unique.
|
131
133
|
The image mapping specifies the OS image for a VM and the flavor mapping specifies the CPU count and RAM of a VM.
|
132
134
|
|
data/lib/vra/catalog_item.rb
CHANGED
@@ -73,12 +73,24 @@ module Vra
|
|
73
73
|
data['iconId']
|
74
74
|
end
|
75
75
|
|
76
|
+
def versions
|
77
|
+
client
|
78
|
+
.http_get_paginated_array!("/catalog/api/items/#{id}/versions")
|
79
|
+
.map { |v| v['id'] }
|
80
|
+
end
|
81
|
+
|
76
82
|
def entitle!(opts = {})
|
77
83
|
super(opts.merge(type: 'CatalogItemIdentifier'))
|
78
84
|
end
|
79
85
|
|
80
|
-
|
81
|
-
|
86
|
+
class << self
|
87
|
+
def entitle!(client, id)
|
88
|
+
new(client, id: id).entitle!
|
89
|
+
end
|
90
|
+
|
91
|
+
def fetch_latest_version(client, id)
|
92
|
+
new(client, data: { 'id' => id }).versions&.first
|
93
|
+
end
|
82
94
|
end
|
83
95
|
end
|
84
96
|
end
|
@@ -85,13 +85,21 @@ module Vra
|
|
85
85
|
|
86
86
|
def validate!
|
87
87
|
missing_params = []
|
88
|
-
%i[image_mapping flavor_mapping name project_id
|
88
|
+
%i[image_mapping flavor_mapping name project_id].each do |arg|
|
89
89
|
missing_params << arg if send(arg).nil?
|
90
90
|
end
|
91
91
|
|
92
|
-
|
92
|
+
unless missing_params.empty?
|
93
|
+
raise ArgumentError, "Unable to submit request, required param(s) missing => #{missing_params.join(', ')}"
|
94
|
+
end
|
95
|
+
|
96
|
+
# If the user doesn't supply the catalog version, fetch the latest version and use it
|
97
|
+
# and if the API was unable to find a valid version, alert the user.
|
98
|
+
return unless @version.nil?
|
99
|
+
|
93
100
|
|
94
|
-
|
101
|
+
@version = CatalogItem.fetch_latest_version(client, catalog_id)
|
102
|
+
raise ArgumentError, 'Unable to fetch a valid catalog version' if @version.nil?
|
95
103
|
end
|
96
104
|
|
97
105
|
def send_request!
|
data/lib/vra/version.rb
CHANGED
data/spec/catalog_item_spec.rb
CHANGED
@@ -122,4 +122,37 @@ describe Vra::CatalogItem do
|
|
122
122
|
expect(catalog_item.type).to be_a(Vra::CatalogType)
|
123
123
|
end
|
124
124
|
end
|
125
|
+
|
126
|
+
describe '#versions' do
|
127
|
+
let(:versions_response) do
|
128
|
+
[{ id: '2', description: 'v2.0' }, { id: '1', description: 'v1.0' }]
|
129
|
+
end
|
130
|
+
|
131
|
+
before do
|
132
|
+
allow(client).to receive(:authorized?).and_return(true)
|
133
|
+
end
|
134
|
+
|
135
|
+
it 'should call the api to fetch the versions' do
|
136
|
+
expect(client)
|
137
|
+
.to receive(:http_get_paginated_array!)
|
138
|
+
.with('/catalog/api/items/catalog-12345/versions')
|
139
|
+
.and_return(versions_response)
|
140
|
+
|
141
|
+
described_class.fetch_latest_version(client, 'catalog-12345')
|
142
|
+
end
|
143
|
+
|
144
|
+
it 'should return the correct version' do
|
145
|
+
stub_request(:get, client.full_url('/catalog/api/items/catalog-12345/versions?$skip=0&$top=20'))
|
146
|
+
.to_return(
|
147
|
+
status: 200,
|
148
|
+
body: {
|
149
|
+
content: versions_response,
|
150
|
+
totalPages: 1
|
151
|
+
}.to_json,
|
152
|
+
headers: {}
|
153
|
+
)
|
154
|
+
|
155
|
+
expect(described_class.fetch_latest_version(client, 'catalog-12345')).to eq('2')
|
156
|
+
end
|
157
|
+
end
|
125
158
|
end
|
@@ -70,6 +70,45 @@ describe Vra::DeploymentRequest do
|
|
70
70
|
|
71
71
|
expect { request.send(:validate!) }.not_to raise_error(ArgumentError)
|
72
72
|
end
|
73
|
+
|
74
|
+
context 'versions' do
|
75
|
+
let(:dep_request) do
|
76
|
+
described_class.new(
|
77
|
+
client,
|
78
|
+
catalog_id,
|
79
|
+
image_mapping: 'centos',
|
80
|
+
name: 'sample dep',
|
81
|
+
flavor_mapping: 'small',
|
82
|
+
project_id: 'pro-123'
|
83
|
+
)
|
84
|
+
end
|
85
|
+
|
86
|
+
before do
|
87
|
+
allow(client).to receive(:authorized?).and_return(true)
|
88
|
+
end
|
89
|
+
|
90
|
+
it 'should not call the api to fetch versions if provided in the params' do
|
91
|
+
expect(client).not_to receive(:http_get_paginated_array!)
|
92
|
+
|
93
|
+
dep_request.version = '1'
|
94
|
+
dep_request.send(:validate!)
|
95
|
+
end
|
96
|
+
|
97
|
+
it 'should fetch version from api if version is blank' do
|
98
|
+
expect(client).to receive(:http_get_paginated_array!).and_return([{ 'id' => '2', 'description' => 'v2.0' }])
|
99
|
+
|
100
|
+
dep_request.send(:validate!)
|
101
|
+
expect(dep_request.version).to eq('2')
|
102
|
+
end
|
103
|
+
|
104
|
+
it 'should raise an exception if no valid versions found' do
|
105
|
+
expect(client).to receive(:http_get_paginated_array!).and_return([])
|
106
|
+
|
107
|
+
expect { dep_request.send(:validate!) }
|
108
|
+
.to raise_error(ArgumentError)
|
109
|
+
.with_message('Unable to fetch a valid catalog version')
|
110
|
+
end
|
111
|
+
end
|
73
112
|
end
|
74
113
|
|
75
114
|
describe '#additional parameters' do
|
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: 3.0
|
4
|
+
version: 3.1.0
|
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: 2022-01-
|
12
|
+
date: 2022-01-30 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: ffi-yajl
|