vmware-vra 3.1.2 → 3.2.0

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
2
  SHA256:
3
- metadata.gz: 4d18c9dda0b686aad417c4f46c36c3c3a23f4523e68f78d1715f86f24a0a1ef4
4
- data.tar.gz: aff6ebd90a5b5ecbc43e249065a04ac34f8978c151dd27869e11378bfd08adc8
3
+ metadata.gz: 0e0045f6ebfa8fa27f8842d7d99cab6caebbfed8dde6143caeca4f3586b84e89
4
+ data.tar.gz: f44441731dd50642476d4a47c0e5d7c0d2bd957cb262cd10f566011ff902b299
5
5
  SHA512:
6
- metadata.gz: 2dfd08b68a8ee04d9c657e4776b02a3a8edfc6e74f21dde0faff948a1d279a617010563beeb6c83e9602db26259abf9547e506cec4dea5012e989547a67481aa
7
- data.tar.gz: 1d3c7f0a3003185dc8e82fa2e5be29462b1957c56a4d231a081fae82e6641b728a6022cbc8356efada6e8b41b4f414c7982d1b2c24722bca84c4ac0b79682b1d
6
+ metadata.gz: ae31f69005d0e71b02712f75486619e8e68b22265ba5d45874a7f96e2c83ee75f5eea71d9c0bcd6eb8bad93bc8e3cf254b1fb1b2d2d0dbefb1447a7b3f26419d
7
+ data.tar.gz: c8c59ca96efa6784ddcad31204fa1e23b2c9119e5173a829cd87fdfb4f08fefd0af0eb84366593f3f731259da3b71c840e9471e743852acdd80a52fc68734e8b
@@ -0,0 +1,9 @@
1
+ ---
2
+ name: 'Test'
3
+
4
+ 'on':
5
+ pull_request:
6
+
7
+ jobs:
8
+ lint-unit:
9
+ uses: test-kitchen/.github/.github/workflows/lint-unit.yml@main
@@ -0,0 +1,5 @@
1
+ ---
2
+ MD012: false
3
+ MD013: false
4
+ MD024: false
5
+ MD036: false
data/.mdlrc ADDED
@@ -0,0 +1 @@
1
+ rules "~MD036", "~MD013", "~MD024", "~MD029"
data/CHANGELOG.md CHANGED
@@ -1,5 +1,19 @@
1
1
  # Change Log
2
2
 
3
+ ## [3.2.0](https://github.com/test-kitchen/vmware-vra-gem/tree/v3.2.0) (2022-12-19)
4
+
5
+ - Updated the tenant attribute to domain
6
+
7
+ [Full Changelog](https://github.com/test-kitchen/vmware-vra-gem/compare/v3.1.3...v3.2.0)
8
+
9
+ ## [3.1.3](https://github.com/test-kitchen/vmware-vra-gem/tree/v3.1.3) (2022-05-26)
10
+
11
+ - Use regular admin catalog endpoint to fetch catalog items
12
+ - Fixed the issue with multi-tenancy
13
+ - Fix chefstyle issues and optimise workflow
14
+
15
+ [Full Changelog](https://github.com/test-kitchen/vmware-vra-gem/compare/v3.1.2...v3.1.3)
16
+
3
17
 
4
18
  ## [3.1.2] (2022-03-28)
5
19
 
@@ -298,6 +312,7 @@
298
312
  - Add support for Infrastructure.Cloud resources [\#15](https://github.com/test-kitchen/vmware-vra-gem/pull/15) ([adamleff](https://github.com/adamleff))
299
313
 
300
314
  ## [v1.4.0](https://github.com/test-kitchen/vmware-vra-gem/tree/v1.4.0) (2015-11-13)
315
+
301
316
  [Full Changelog](https://github.com/test-kitchen/vmware-vra-gem/compare/v1.3.0...v1.4.0)
302
317
 
303
318
  **Closed issues:**
data/README.md CHANGED
@@ -1,4 +1,5 @@
1
1
  # VMware vRA Gem
2
+
2
3
  [![Gem Version](https://badge.fury.io/rb/vmware-vra.svg)](http://badge.fury.io/rb/vmware-vra)
3
4
 
4
5
  Client gem for interacting with VMware's vRealize Automation application.
@@ -27,55 +28,60 @@ gem 'vmware-vra'
27
28
 
28
29
  And then execute:
29
30
 
30
- $ bundle
31
+ ```shell
32
+ bundle
33
+ ```
31
34
 
32
35
  Or install it yourself as:
33
36
 
34
- $ gem install vmware-vra
37
+ ```shell
38
+ gem install vmware-vra
39
+ ```
35
40
 
36
41
  ## Usage
37
42
 
38
43
  First, load in the gem.
39
44
 
40
- ```
45
+ ```shell
41
46
  require 'vra'
42
47
  => true
43
48
  ```
44
49
 
45
- Then, set up your client object. You will need to know your tenant ID from your vRA administrator.
50
+ Then, set up your client object. You will need to know your domain from your vRA administrator.
46
51
 
47
- ```
48
- client = Vra::Client.new(username: 'devmgr@corp.local', password: 'mypassword', tenant: 'mytenant', base_url: 'https://vra.corp.local', verify_ssl: true)
52
+ ```shell
53
+ client = Vra::Client.new(username: 'devmgr@corp.local', password: 'mypassword', domain: 'domain.corp.local', base_url: 'https://vra.corp.local', verify_ssl: true)
49
54
  => #<Vra::Client:0x000000034c0df8 ... >
50
55
  ```
51
- ### Catalog Types:
56
+
57
+ ### Catalog Types
52
58
 
53
59
  To list all the catalog types:
54
60
 
55
- ```
61
+ ```shell
56
62
  client.catalog.all_types
57
63
  => [#<Vra::CatalogType:0x00007fcde6855370 @id="com.vmw.vro.workflow", @data={"id"=>"com.vmw.vro.workflow", ... ]
58
64
  ```
59
65
 
60
- ### Catalog Sources:
66
+ ### Catalog Sources
61
67
 
62
68
  To list all the catalog sources:
63
69
 
64
- ```
70
+ ```shell
65
71
  client.catalog.all_sources
66
72
  [#<Vra::CatalogSource:0x00007fcde3948c30 @id="2f5b2d5c-6dc2-4ea7-b304-cd8fea5ede0f", @data= ...]
67
73
  ```
68
74
 
69
75
  And to list the sources that are entitled only:
70
76
 
71
- ```
77
+ ```shell
72
78
  client.catalog.entitled_sources(project_id)
73
79
  => [#<Vra::CatalogSource:0x00007fcde2a28c00 @id="18102dc2-9e48-487a-93a8-aafab2ecc05 ...]
74
80
  ```
75
81
 
76
82
  Creating a new source can be done as follows:
77
83
 
78
- ```
84
+ ```shell
79
85
  source = Vra::CatalogSource.create(client, name: 'New source', catalog_type_id: 'com.vmw.vro.workflow', project_id: project_id)
80
86
  => #<Vra::CatalogSource:0x00007fad651f63b8 ... >
81
87
  ```
@@ -84,21 +90,21 @@ source = Vra::CatalogSource.create(client, name: 'New source', catalog_type_id:
84
90
 
85
91
  To list all items in the catalog:
86
92
 
87
- ```
93
+ ```shell
88
94
  client.catalog.all_items
89
95
  => [#<Vra::CatalogItem:0x00007fe583863b28>, #<Vra::CatalogItem:0x00007fe583863ad8 ... ]
90
96
  ```
91
97
 
92
98
  To only list the items in the catalog for which you are entitled to request:
93
99
 
94
- ```
100
+ ```shell
95
101
  client.catalog.entitled_items(project_id)
96
102
  => [#<Vra::CatalogItem:0x00007fe583863b28>, #<Vra::CatalogItem:0x00007fe583863ad8 ... ]
97
103
  ```
98
104
 
99
105
  To retrive catalog id from catalog name:
100
106
 
101
- ```
107
+ ```shell
102
108
  client.catalog.fetch_catalog_items('centos')
103
109
  =>
104
110
  [#<Vra::CatalogItem:0x00007fb734110f60
@@ -110,9 +116,10 @@ client.catalog.fetch_catalog_items('centos')
110
116
  ```
111
117
 
112
118
  ### Requesting Deployments
119
+
113
120
  When you are ready to request a deployment using a catalog, create a new deployment object:
114
121
 
115
- ```
122
+ ```shell
116
123
  request = client.catalog.request(
117
124
  catalog_id,
118
125
  image_mapping: 'VRA-nc-lnx-ce8.4-Docker',
@@ -125,16 +132,17 @@ request = client.catalog.request(
125
132
  #<Vra::DeploymentRequest:0x00007fb7340b7438
126
133
  ...
127
134
  ```
135
+
128
136
  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
137
 
130
138
  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
-
139
+
132
140
  Additionally, the name of the deployment should be specified and it should be unique.
133
141
  The image mapping specifies the OS image for a VM and the flavor mapping specifies the CPU count and RAM of a VM.
134
142
 
135
143
  If your catalog blueprint item requires additional parameters to successfully submit your request, you may add them:
136
144
 
137
- ```
145
+ ```shell
138
146
  request.set_parameter('my_parameter', 'string', 'my value')
139
147
  ```
140
148
 
@@ -142,7 +150,7 @@ request.set_parameter('my_parameter', 'string', 'my value')
142
150
 
143
151
  Now, submit your request! The client will return a new "Deployment" object you can use to query for status.
144
152
 
145
- ```
153
+ ```shell
146
154
  deployment = catalog_request.submit
147
155
  => #<Vra::Deployment:0x000000027caea0 ... >
148
156
 
@@ -152,14 +160,14 @@ deployment.status
152
160
 
153
161
  You can refresh your deployment object to get the latest status:
154
162
 
155
- ```
163
+ ```shell
156
164
  deployment.refresh && deployment.status
157
165
  => "SUCCESSFUL"
158
166
  ```
159
167
 
160
168
  You can also save the deployment ID for later, and create a new deployment object at your leisure to follow-up on your deployment request:
161
169
 
162
- ```
170
+ ```shell
163
171
  deployment.id
164
172
  => "aed22465-02db-481d-b55a-cefe216096a2"
165
173
 
@@ -171,9 +179,10 @@ new_deployment.status
171
179
  ```
172
180
 
173
181
  ### Deployment Resources
182
+
174
183
  When the deployment request is successful, you can query the resources created as the result of your request. Assuming that the catalog item blueprint we requested only creates a single VM, we can get that resource and learn more information about it:
175
184
 
176
- ```
185
+ ```shell
177
186
  resource = deployment.resources.first
178
187
  => #<Vra::Resource:0x00000006772e68 ... >
179
188
 
@@ -189,7 +198,7 @@ resource.name
189
198
 
190
199
  If you have the resource_id and the deployment object, you can fetch the resources details as follows
191
200
 
192
- ```
201
+ ```shell
193
202
  resource.id
194
203
  => "331fd10b-f2a2-40ae-86bc-1255c1ee9a6d"
195
204
 
@@ -202,10 +211,10 @@ new_resource.name
202
211
 
203
212
  ### Deleting a deployment from vRA
204
213
 
205
- When you no longer need the VM, you can destroy the deployment which will delete all the associated resources as well.
214
+ When you no longer need the VM, you can destroy the deployment which will delete all the associated resources as well.
206
215
  The method will return a request object you can query for status:
207
216
 
208
- ```
217
+ ```shell
209
218
  destroy_req = deployment.destroy
210
219
  => #<Vra::Request:0x00000006ea90d8 ... >
211
220
 
@@ -215,7 +224,7 @@ destroy_req.status
215
224
 
216
225
  You can also list all resources and requests you have permission to see with these methods:
217
226
 
218
- ```
227
+ ```shell
219
228
  deployment.resources
220
229
  deployment.requests
221
230
  ```
@@ -225,7 +234,7 @@ deployment.requests
225
234
  vRA paginates API requests where lists of items are returned. By default, this gem will ask vRA to provide items in groups of 20. However, as reported in [Issue 10](https://github.com/chef-partners/vmware-vra-gem/issues/10), it appears vRA may have a pagination bug. You can change the default page size from 20 to a value of your choice by passing in a `page_size` option when setting up the client:
226
235
 
227
236
  ```ruby
228
- vra = Vra::Client.new(username: 'devmgr@corp.local', password: 'mypassword', tenant: 'mytenant', base_url: 'https://vra.corp.local', verify_ssl: true, page_size: 100)
237
+ vra = Vra::Client.new(username: 'devmgr@corp.local', password: 'mypassword', domain: 'domain.corp.local', base_url: 'https://vra.corp.local', verify_ssl: true, page_size: 100)
229
238
  ```
230
239
 
231
240
  ... or setting `page_size` on the client object after you've created it:
@@ -239,11 +248,13 @@ client.page_size = 100
239
248
  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.
240
249
 
241
250
  MacOS/Linux:
251
+
242
252
  ```ruby
243
253
  export VRA_HTTP_TRACE=1
244
254
  ```
245
255
 
246
256
  Windows:
257
+
247
258
  ```powershell
248
259
  $env:VRA_HTTP_TRACE=1
249
260
  ```
@@ -259,7 +270,7 @@ License:: Apache License, Version 2.0
259
270
  Licensed under the Apache License, Version 2.0 (the "License"); you may not use
260
271
  this file except in compliance with the License. You may obtain a copy of the License at
261
272
 
262
- ```
273
+ ```text
263
274
  http://www.apache.org/licenses/LICENSE-2.0
264
275
  ```
265
276
 
@@ -270,7 +281,7 @@ and limitations under the License.
270
281
 
271
282
  ## Contributing
272
283
 
273
- 1. Fork it ( https://github.com/[my-github-username]/vmware-vra-gem/fork )
284
+ 1. Fork it ( <https://github.com/[my-github-username]/vmware-vra-gem/fork> )
274
285
  2. Create your feature branch (`git checkout -b my-new-feature`)
275
286
  3. Commit your changes (`git commit -am 'Add some feature'`)
276
287
  4. Push to the branch (`git push origin my-new-feature`)
data/Rakefile CHANGED
@@ -4,9 +4,9 @@ require "rspec/core/rake_task"
4
4
  require "chefstyle"
5
5
  require "rubocop/rake_task"
6
6
 
7
- RSpec::Core::RakeTask.new(:spec)
7
+ RSpec::Core::RakeTask.new(:test)
8
8
  RuboCop::RakeTask.new do |task|
9
9
  task.options << "--display-cop-names"
10
10
  end
11
11
 
12
- task default: %i{spec rubocop}
12
+ task default: %i{test rubocop}
data/lib/vra/catalog.rb CHANGED
@@ -15,7 +15,6 @@
15
15
  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
16
  # See the License for the specific language governing permissions and
17
17
  # limitations under the License.
18
- #
19
18
 
20
19
  module Vra
21
20
  class Catalog
@@ -38,11 +37,11 @@ module Vra
38
37
  end
39
38
 
40
39
  def entitled_sources(project_id)
41
- fetch_entitlements(project_id, 'CatalogSourceIdentifier')
40
+ fetch_entitlements(project_id, "CatalogSourceIdentifier")
42
41
  end
43
42
 
44
43
  def entitled_items(project_id)
45
- fetch_entitlements(project_id, 'CatalogItemIdentifier')
44
+ fetch_entitlements(project_id, "CatalogItemIdentifier")
46
45
  end
47
46
 
48
47
  def request(*args)
@@ -52,7 +51,7 @@ module Vra
52
51
  def fetch_catalog_items(catalog_name)
53
52
  fetch_resources(
54
53
  Vra::CatalogItem,
55
- '/catalog/api/admin/items',
54
+ "/catalog/api/items",
56
55
  "search=#{catalog_name}"
57
56
  )
58
57
  end
@@ -66,12 +65,12 @@ module Vra
66
65
  end
67
66
 
68
67
  def fetch_entitlements(project_id, type)
69
- klass = type == 'CatalogSourceIdentifier' ? Vra::CatalogSource : Vra::CatalogItem
68
+ klass = type == "CatalogSourceIdentifier" ? Vra::CatalogSource : Vra::CatalogItem
70
69
 
71
70
  client
72
71
  .get_parsed("/catalog/api/admin/entitlements?projectId=#{project_id}")
73
- .select { |x| x['definition']['type'] == type }
74
- .map! { |x| klass.new(client, data: x['definition']) }
72
+ .select { |x| x["definition"]["type"] == type }
73
+ .map! { |x| klass.new(client, data: x["definition"]) }
75
74
  end
76
75
  end
77
76
  end
@@ -45,8 +45,8 @@ module Vra
45
45
  attr_reader :client, :data
46
46
 
47
47
  def validate!
48
- raise ArgumentError, 'must supply id or data hash' if @id.nil? && @data.nil?
49
- raise ArgumentError, 'must supply id or data hash, not both' if !@id.nil? && !@data.nil?
48
+ raise ArgumentError, "must supply id or data hash" if @id.nil? && @data.nil?
49
+ raise ArgumentError, "must supply id or data hash, not both" if !@id.nil? && !@data.nil?
50
50
  end
51
51
 
52
52
  def entitle_params(type)
@@ -54,8 +54,8 @@ module Vra
54
54
  'projectId': project_id,
55
55
  'definition': {
56
56
  'type': type,
57
- 'id': id
58
- }
57
+ 'id': id,
58
+ },
59
59
  }
60
60
  end
61
61
  end
@@ -23,7 +23,7 @@ require "vra/catalog"
23
23
  module Vra
24
24
  # Class that represents the Catalog Item
25
25
  class CatalogItem < Vra::CatalogBase
26
- INDEX_URL = '/catalog/api/admin/items'
26
+ INDEX_URL = "/catalog/api/items"
27
27
 
28
28
  attr_reader :project_id
29
29
 
@@ -35,30 +35,30 @@ module Vra
35
35
  if @data.nil?
36
36
  fetch_catalog_item
37
37
  else
38
- @id = @data['id']
38
+ @id = @data["id"]
39
39
  end
40
40
  end
41
41
 
42
42
  def fetch_catalog_item
43
- @data = client.get_parsed("/catalog/api/admin/items/#{id}")
43
+ @data = client.get_parsed("/catalog/api/items/#{id}")
44
44
  rescue Vra::Exception::HTTPNotFound
45
45
  raise Vra::Exception::NotFound, "catalog ID #{id} does not exist"
46
46
  end
47
47
 
48
48
  def name
49
- data['name']
49
+ data["name"]
50
50
  end
51
51
 
52
52
  def description
53
- data['description']
53
+ data["description"]
54
54
  end
55
55
 
56
56
  def source_id
57
- data['sourceId']
57
+ data["sourceId"]
58
58
  end
59
59
 
60
60
  def source_name
61
- data['sourceName']
61
+ data["sourceName"]
62
62
  end
63
63
 
64
64
  def source
@@ -66,21 +66,21 @@ module Vra
66
66
  end
67
67
 
68
68
  def type
69
- @type ||= Vra::CatalogType.new(client, data: data['type'])
69
+ @type ||= Vra::CatalogType.new(client, data: data["type"])
70
70
  end
71
71
 
72
72
  def icon_id
73
- data['iconId']
73
+ data["iconId"]
74
74
  end
75
75
 
76
76
  def versions
77
77
  client
78
78
  .http_get_paginated_array!("/catalog/api/items/#{id}/versions")
79
- .map { |v| v['id'] }
79
+ .map { |v| v["id"] }
80
80
  end
81
81
 
82
82
  def entitle!(opts = {})
83
- super(opts.merge(type: 'CatalogItemIdentifier'))
83
+ super(opts.merge(type: "CatalogItemIdentifier"))
84
84
  end
85
85
 
86
86
  class << self
@@ -89,7 +89,7 @@ module Vra
89
89
  end
90
90
 
91
91
  def fetch_latest_version(client, id)
92
- new(client, data: { 'id' => id }).versions&.first
92
+ new(client, data: { "id" => id }).versions&.first
93
93
  end
94
94
  end
95
95
  end
@@ -16,12 +16,12 @@
16
16
  # See the License for the specific language governing permissions and
17
17
  # limitations under the License.
18
18
  #
19
- require 'ffi_yajl' unless defined?(FFI_Yajl)
19
+ require "ffi_yajl" unless defined?(FFI_Yajl)
20
20
 
21
21
  module Vra
22
22
  # Class that represents the Catalog Source
23
23
  class CatalogSource < Vra::CatalogBase
24
- INDEX_URL = '/catalog/api/admin/sources'
24
+ INDEX_URL = "/catalog/api/admin/sources"
25
25
 
26
26
  # @param client [Vra::Client] - a vra client object
27
27
  # @param opts [Hash] - Contains the either id of the catalog or the data hash
@@ -33,11 +33,11 @@ module Vra
33
33
  end
34
34
 
35
35
  def name
36
- data['name']
36
+ data["name"]
37
37
  end
38
38
 
39
39
  def catalog_type_id
40
- data['typeId']
40
+ data["typeId"]
41
41
  end
42
42
 
43
43
  def catalog_type
@@ -45,19 +45,19 @@ module Vra
45
45
  end
46
46
 
47
47
  def config
48
- data['config']
48
+ data["config"]
49
49
  end
50
50
 
51
51
  def global?
52
- data['global'] == true
52
+ data["global"] == true
53
53
  end
54
54
 
55
55
  def project_id
56
- config['sourceProjectId']
56
+ config["sourceProjectId"]
57
57
  end
58
58
 
59
59
  def entitle!(opts = {})
60
- super(opts.merge(type: 'CatalogSourceIdentifier'))
60
+ super(opts.merge(type: "CatalogSourceIdentifier"))
61
61
  end
62
62
 
63
63
  class << self
@@ -66,7 +66,7 @@ module Vra
66
66
  validate_create!(opts)
67
67
 
68
68
  response = client.http_post(
69
- '/catalog/api/admin/sources',
69
+ "/catalog/api/admin/sources",
70
70
  FFI_Yajl::Encoder.encode(create_params(opts)),
71
71
  opts[:skip_auth] || false
72
72
  )
@@ -83,7 +83,7 @@ module Vra
83
83
  private
84
84
 
85
85
  def validate_create!(opts)
86
- %i[name catalog_type_id project_id].each do |arg|
86
+ %i{name catalog_type_id project_id}.each do |arg|
87
87
  raise ArgumentError, "#{arg} param is required to perform the create action" unless opts.key?(arg)
88
88
  end
89
89
  end
@@ -93,8 +93,8 @@ module Vra
93
93
  'name': opts[:name],
94
94
  'typeId': opts[:catalog_type_id],
95
95
  'config': {
96
- 'sourceProjectId': opts[:project_id]
97
- }
96
+ 'sourceProjectId': opts[:project_id],
97
+ },
98
98
  }
99
99
  end
100
100
  end
@@ -104,7 +104,7 @@ module Vra
104
104
  def fetch_data
105
105
  fetch_catalog_data && return if data.nil?
106
106
 
107
- @id = data['id']
107
+ @id = data["id"]
108
108
  end
109
109
 
110
110
  def fetch_catalog_data
@@ -19,7 +19,7 @@
19
19
  module Vra
20
20
  # Class that represents the Catalog Type
21
21
  class CatalogType < Vra::CatalogBase
22
- INDEX_URL = '/catalog/api/types'
22
+ INDEX_URL = "/catalog/api/types"
23
23
 
24
24
  def initialize(client, opts = {})
25
25
  super
@@ -28,25 +28,25 @@ module Vra
28
28
  end
29
29
 
30
30
  def name
31
- data['name']
31
+ data["name"]
32
32
  end
33
33
 
34
34
  def base_url
35
- data['baseUri']
35
+ data["baseUri"]
36
36
  end
37
37
 
38
38
  def config_schema
39
- data['configSchema']
39
+ data["configSchema"]
40
40
  end
41
41
 
42
42
  def icon_id
43
- data['iconId']
43
+ data["iconId"]
44
44
  end
45
45
 
46
46
  private
47
47
 
48
48
  def fetch_data
49
- @id = data['id'] and return unless data.nil?
49
+ @id = data["id"] and return unless data.nil?
50
50
 
51
51
  @data = client.get_parsed("/catalog/api/types/#{id}")
52
52
  rescue Vra::Exception::HTTPNotFound