kitchen-vra 2.7.1 → 3.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/dependabot.yml +7 -0
- data/.github/workflows/ci.yml +22 -0
- data/CHANGELOG.md +6 -0
- data/Gemfile +2 -2
- data/README.md +18 -9
- data/Rakefile +5 -15
- data/kitchen-vra.gemspec +22 -22
- data/lib/kitchen/driver/vra.rb +70 -65
- data/lib/kitchen/driver/vra_version.rb +1 -1
- data/spec/spec_helper.rb +6 -6
- data/spec/vra_spec.rb +178 -187
- metadata +41 -27
- data/.rubocop.yml +0 -32
- data/.travis.yml +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2dd5eb1c44307d885cafca15ead2050b18cc44339d1ee0ef2cae0729c02b1fb0
|
4
|
+
data.tar.gz: 406983722267fe198f460fb24e38726b7534d6ab722b5a7b9fda96028c4df3c4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c1258498bd2583ffa37232dd4b2a0f47e6f37e035edd597947b887a32ce74c830b450893c7d6489b70dd5666b893a4f3ccf94fd58c842ac0676341774ee5d174
|
7
|
+
data.tar.gz: ef96e597cf8289935c79491951c0aba5c6156c3d8e0e0aa5b73e6aadbe996db6fd7ed8dc2d6e973390fc374e7b91896445558f6928288158c912204f6ae29e1b
|
@@ -0,0 +1,22 @@
|
|
1
|
+
name: CI
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request:
|
5
|
+
push:
|
6
|
+
branches:
|
7
|
+
- master
|
8
|
+
|
9
|
+
jobs:
|
10
|
+
test:
|
11
|
+
runs-on: ubuntu-latest
|
12
|
+
strategy:
|
13
|
+
matrix:
|
14
|
+
ruby: [ '2.7', '3.0']
|
15
|
+
name: Lint & Test with Ruby ${{ matrix.ruby }}
|
16
|
+
steps:
|
17
|
+
- uses: actions/checkout@v2
|
18
|
+
- uses: ruby/setup-ruby@v1
|
19
|
+
with:
|
20
|
+
ruby-version: ${{ matrix.ruby }}
|
21
|
+
bundler-cache: true
|
22
|
+
- run: bundle exec rake
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## [v3.0.0](https://github.com/chef-partners/kitchen-vra/tree/v3.0.0)
|
4
|
+
|
5
|
+
[Full Changelog](https://github.com/chef-partners/kitchen-vra/compare/v2.7.1...v3.0.0)
|
6
|
+
|
7
|
+
- kitchen-vra now supports VMware vRealize Automation 8. See the readme of kitchen.ci driver documentation for new configuration options necessary for use with vRA 8. If you need support for vRA 7 make sure to pin to an earlier release.
|
8
|
+
|
3
9
|
## [v2.7.1](https://github.com/chef-partners/kitchen-vra/tree/v2.7.1)
|
4
10
|
|
5
11
|
[Full Changelog](https://github.com/chef-partners/kitchen-vra/compare/v2.7.0...v2.7.1)
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -50,7 +50,7 @@ If you don't want to explicitly specify username and password in the kitchen.yml
|
|
50
50
|
$ export VRA_USER_NAME='myuser@corp.local'
|
51
51
|
$ export VRA_USER_PASSWORD='mypassword'
|
52
52
|
|
53
|
-
Then configure your platforms. Either a catalog_id or a catalog_name is required for each platform. If both catalog_id and catalog_name are mentioned in .kitchen.yml then catalog_name would be used to derive the catalog_id and this catalog_id would override the catalog_id being passed in .kitchen.yml. In the below example as can be seen we are using catalog_id for centos6 driver while catalog_name for the centos7 driver just to demonstrate that we can use either of the two.
|
53
|
+
Then configure your platforms. You will need to specify project_id, image_mapping, flavor_mapping and version for the platform. image_mapping specifies the OS image for a machine and the flavor_mapping specifies the CPU count and RAM of the machine. Either a catalog_id or a catalog_name is required for each platform. If both catalog_id and catalog_name are mentioned in .kitchen.yml then catalog_name would be used to derive the catalog_id and this catalog_id would override the catalog_id being passed in .kitchen.yml. In the below example as can be seen we are using catalog_id for centos6 driver while catalog_name for the centos7 driver just to demonstrate that we can use either of the two.
|
54
54
|
|
55
55
|
|
56
56
|
```yaml
|
@@ -58,22 +58,25 @@ platforms:
|
|
58
58
|
- name: centos6
|
59
59
|
driver:
|
60
60
|
catalog_id: e9db1084-d1c6-4c1f-8e3c-eb8f3dc574f9
|
61
|
+
project_id: 6ba69375-79d5-42c3-a099-7d32739f71a9
|
62
|
+
image_mapping: SQL 2016
|
63
|
+
flavor_mapping: Small
|
64
|
+
version: 1
|
61
65
|
- name: centos7
|
62
66
|
driver:
|
63
67
|
catalog_name: my_catalog_name
|
68
|
+
project_id: 6ba69375-79d5-42c3-a099-7d32739f71a9
|
69
|
+
image_mapping: VRA-nc-lnx-ce8.4-Docker
|
70
|
+
flavor_mapping: Small
|
71
|
+
version: 1
|
64
72
|
```
|
65
73
|
|
66
74
|
|
67
75
|
|
68
76
|
Other options that you can set include:
|
69
77
|
|
70
|
-
* **lease_days**: number of days to request for a lease, if your catalog item / blueprint requires it
|
71
78
|
* **request_timeout**: amount of time, in seconds, to wait for a vRA request to complete. Default is 600 seconds.
|
72
79
|
* **server_ready_retries**: Number of times to retry the "waiting for server to be ready" check. In some cases, this will error out immediately due to DNS propagation issues, etc. Setting this to a number greater than 0 will retry the `wait_until_ready` method with a growing sleep in between each attempt. Defaults to 1. Set to 0 to disable any retrying of the `wait_until_ready` method.
|
73
|
-
* **cpus**: number of CPUs the host should have
|
74
|
-
* **memory**: amount of RAM, in MB, the host should have
|
75
|
-
* **shirt_size**: This parameter corresponds to shirt size option of vRA available on blueprint like ValueSet.Large, ValueSet.Small etc. As shirt size is a combination of memory and RAM, hence while using this no need to use cpus and memory parameter. This shirt size option helps in standardizing the sizing available for end users
|
76
|
-
* **requested_for**: the vRA login ID to list as the owner of this resource. Defaults to the vRA username configured in the `driver` section.
|
77
80
|
* **subtenant_id**: the Business Group ID to list as the owner. This is required if the catalog item is a shared/global item; we are unable to determine the subtenant_id from the catalog, and vRA requires it to be set on every request.
|
78
81
|
* **subtenant_name**: the Business Group Name as the owner. This can be passed instead of subtenant_id and would act as a more friendly name. subtenant_id would be internally retrieved based on the provided subtenant_name. In case both subtenant_id and subtenant_name are passed, subtenant_name would take the precendence and would try to retrieve subtenant_id based on subtenant_name passed.
|
79
82
|
* **private_key_path**: path to the SSH private key to use when logging in. Defaults to '~/.ssh/id_rsa' or '~/.ssh/id_dsa', preferring the RSA key. Only applies to instances where SSH transport is used; i.e., does not apply to Windows hosts with the WinRM transport configured.
|
@@ -86,13 +89,16 @@ These settings can be set globally under the top-level `driver` section, or they
|
|
86
89
|
```yaml
|
87
90
|
driver:
|
88
91
|
name: vra
|
89
|
-
cpus: 1
|
90
92
|
|
91
93
|
platforms:
|
92
94
|
- name: small
|
93
95
|
driver:
|
94
96
|
catalog_name: my_catalog_name_small
|
95
97
|
catalog_id: 8a189191-fea6-43eb-981e-ee0fa40f8f57
|
98
|
+
project_id: 6ba69375-79d5-42c3-a099-7d32739f71a9
|
99
|
+
image_mapping: SQL 2016
|
100
|
+
flavor_mapping: Small
|
101
|
+
version: 1
|
96
102
|
extra_parameters:
|
97
103
|
mycustompropname:
|
98
104
|
type: string
|
@@ -104,7 +110,10 @@ platforms:
|
|
104
110
|
driver:
|
105
111
|
catalog_name: my_catalog_name_large
|
106
112
|
catalog_id: 1d7c6122-18fa-4ed6-bd13-8a33b6c6ed50
|
107
|
-
|
113
|
+
project_id: 6ba69375-79d5-42c3-a099-7d32739f71a9
|
114
|
+
image_mapping: VRA-nc-lnx-ce8.4-Docker
|
115
|
+
flavor_mapping: Large
|
116
|
+
version: 1
|
108
117
|
subtenant_name: my_subtenant_name
|
109
118
|
extra_parameters:
|
110
119
|
mycustompropname:
|
@@ -119,7 +128,7 @@ platforms:
|
|
119
128
|
|
120
129
|
Author:: Chef Partner Engineering (<partnereng@chef.io>)
|
121
130
|
|
122
|
-
Copyright:: Copyright (c)
|
131
|
+
Copyright:: Copyright (c) 2022 Chef Software, Inc.
|
123
132
|
|
124
133
|
License:: Apache License, Version 2.0
|
125
134
|
|
data/Rakefile
CHANGED
@@ -1,21 +1,11 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
4
|
-
require
|
5
|
-
require
|
3
|
+
require "bundler/gem_tasks"
|
4
|
+
require "rspec/core/rake_task"
|
5
|
+
require "chefstyle"
|
6
|
+
require "rubocop/rake_task"
|
6
7
|
|
7
8
|
RSpec::Core::RakeTask.new(:spec)
|
8
9
|
RuboCop::RakeTask.new(:style)
|
9
10
|
|
10
|
-
|
11
|
-
require 'github_changelog_generator/task'
|
12
|
-
|
13
|
-
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
|
14
|
-
config.future_release = Kitchen::Driver::VRA_VERSION
|
15
|
-
config.issues = true
|
16
|
-
end
|
17
|
-
rescue LoadError
|
18
|
-
puts 'github_changelog_generator is not available. gem install github_changelog_generator to generate changelogs'
|
19
|
-
end
|
20
|
-
|
21
|
-
task default: %i[spec style]
|
11
|
+
task default: %i{spec style}
|
data/kitchen-vra.gemspec
CHANGED
@@ -1,35 +1,35 @@
|
|
1
|
-
# coding: utf-8
|
2
1
|
# frozen_string_literal: true
|
3
2
|
|
4
|
-
lib = File.expand_path(
|
3
|
+
lib = File.expand_path("lib", __dir__)
|
5
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
6
|
-
require
|
5
|
+
require "kitchen/driver/vra_version"
|
7
6
|
|
8
7
|
Gem::Specification.new do |spec|
|
9
|
-
spec.name =
|
8
|
+
spec.name = "kitchen-vra"
|
10
9
|
spec.version = Kitchen::Driver::VRA_VERSION
|
11
|
-
spec.authors = [
|
12
|
-
spec.email = [
|
13
|
-
spec.summary =
|
10
|
+
spec.authors = ["Chef Partner Engineering"]
|
11
|
+
spec.email = ["partnereng@chef.io"]
|
12
|
+
spec.summary = "A Test Kitchen driver for VMware vRealize Automation (vRA)"
|
14
13
|
spec.description = spec.summary
|
15
|
-
spec.homepage =
|
16
|
-
spec.license =
|
14
|
+
spec.homepage = "https://github.com/chef-partners/kitchen-vra"
|
15
|
+
spec.license = "Apache-2.0"
|
17
16
|
|
18
17
|
spec.files = `git ls-files -z`.split("\x0")
|
19
18
|
spec.executables = []
|
20
19
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
21
|
-
spec.require_paths = [
|
20
|
+
spec.require_paths = ["lib"]
|
22
21
|
|
23
|
-
spec.
|
24
|
-
|
25
|
-
spec.add_dependency
|
26
|
-
spec.add_dependency
|
27
|
-
spec.add_dependency
|
28
|
-
spec.
|
29
|
-
spec.
|
30
|
-
spec.add_development_dependency
|
31
|
-
spec.add_development_dependency
|
32
|
-
spec.add_development_dependency
|
33
|
-
spec.add_development_dependency
|
34
|
-
spec.add_development_dependency
|
22
|
+
spec.required_ruby_version = ">= 2.7"
|
23
|
+
|
24
|
+
spec.add_dependency "test-kitchen"
|
25
|
+
spec.add_dependency "vmware-vra", "~> 3.0" # 3.0 required for vRA 8.x
|
26
|
+
spec.add_dependency "highline"
|
27
|
+
spec.add_dependency "rack", "~> 1.6"
|
28
|
+
spec.add_dependency "ffi-yajl", ">= 2.2.3", "< 2.5.0"
|
29
|
+
spec.add_development_dependency "bundler", ">= 1.7"
|
30
|
+
spec.add_development_dependency "rake", "~> 13.0"
|
31
|
+
spec.add_development_dependency "rspec", "~> 3.2"
|
32
|
+
spec.add_development_dependency "simplecov", "~> 0.10"
|
33
|
+
spec.add_development_dependency "webmock", "~> 3.14"
|
34
|
+
spec.add_development_dependency "chefstyle", "~> 2.2.1"
|
35
35
|
end
|
data/lib/kitchen/driver/vra.rb
CHANGED
@@ -18,13 +18,13 @@
|
|
18
18
|
# limitations under the License.
|
19
19
|
#
|
20
20
|
|
21
|
-
require
|
22
|
-
require
|
23
|
-
require
|
24
|
-
require
|
25
|
-
require
|
26
|
-
require
|
27
|
-
require_relative
|
21
|
+
require "kitchen"
|
22
|
+
require "highline/import"
|
23
|
+
require "openssl" unless defined?(OpenSSL)
|
24
|
+
require "base64" unless defined?(Base64)
|
25
|
+
require "digest/sha1" unless defined?(Digest::SHA1)
|
26
|
+
require "vra"
|
27
|
+
require_relative "vra_version"
|
28
28
|
|
29
29
|
module Kitchen
|
30
30
|
module Driver
|
@@ -36,6 +36,11 @@ module Kitchen
|
|
36
36
|
default_config :password, nil
|
37
37
|
required_config :base_url
|
38
38
|
required_config :tenant
|
39
|
+
required_config :project_id
|
40
|
+
required_config :image_mapping
|
41
|
+
required_config :flavor_mapping
|
42
|
+
required_config :version
|
43
|
+
|
39
44
|
default_config :catalog_id, nil
|
40
45
|
default_config :catalog_name, nil
|
41
46
|
|
@@ -45,18 +50,13 @@ module Kitchen
|
|
45
50
|
default_config :request_timeout, 600
|
46
51
|
default_config :request_refresh_rate, 2
|
47
52
|
default_config :server_ready_retries, 1
|
48
|
-
default_config :
|
49
|
-
|
50
|
-
default_config :shirt_size, nil
|
51
|
-
default_config :requested_for do |driver|
|
52
|
-
driver[:username]
|
53
|
+
default_config :deployment_name do |driver|
|
54
|
+
driver&.instance&.platform&.name
|
53
55
|
end
|
54
|
-
default_config :lease_days, nil
|
55
|
-
default_config :notes, nil
|
56
56
|
default_config :cache_credentials, false
|
57
57
|
default_config :extra_parameters, {}
|
58
58
|
default_config :private_key_path do
|
59
|
-
%w
|
59
|
+
%w{id_rsa id_dsa}.map do |key|
|
60
60
|
file = File.expand_path("~/.ssh/#{key}")
|
61
61
|
file if File.exist?(file)
|
62
62
|
end.compact.first
|
@@ -65,21 +65,21 @@ module Kitchen
|
|
65
65
|
default_config :dns_suffix, nil
|
66
66
|
|
67
67
|
def name
|
68
|
-
|
68
|
+
"vRA"
|
69
69
|
end
|
70
70
|
|
71
71
|
def check_config(force_change = false)
|
72
|
-
config[:username] = config[:username] || ENV[
|
73
|
-
config[:password] = config[:password] || ENV[
|
72
|
+
config[:username] = config[:username] || ENV["VRA_USER_NAME"]
|
73
|
+
config[:password] = config[:password] || ENV["VRA_USER_PASSWORD"]
|
74
74
|
c_load if config[:username].nil? && config[:password].nil?
|
75
75
|
|
76
|
-
config[:username] = ask(
|
77
|
-
config[:password] = ask(
|
76
|
+
config[:username] = ask("Enter Username: e.g. username@domain") if config[:username].nil? || force_change
|
77
|
+
config[:password] = ask("Enter password: ") { |q| q.echo = "*" } if config[:password].nil? || force_change
|
78
78
|
c_save if config[:cache_credentials]
|
79
79
|
end
|
80
80
|
|
81
81
|
def c_save
|
82
|
-
cipher = OpenSSL::Cipher
|
82
|
+
cipher = OpenSSL::Cipher.new("cip-her-aes")
|
83
83
|
cipher.encrypt
|
84
84
|
cipher.key = Digest::SHA1.hexdigest(config[:base_url])
|
85
85
|
iv_user = cipher.random_iv
|
@@ -89,21 +89,21 @@ module Kitchen
|
|
89
89
|
cipher.iv = iv_pwd
|
90
90
|
password = cipher.update(config[:password]) + cipher.final
|
91
91
|
output = "#{Base64.encode64(iv_user).strip!}:#{Base64.encode64(username).strip!}:#{Base64.encode64(iv_pwd).strip!}:#{Base64.encode64(password).strip!}"
|
92
|
-
file = File.open(
|
92
|
+
file = File.open(".kitchen/cached_vra", "w")
|
93
93
|
file.write(output)
|
94
94
|
file.close
|
95
95
|
rescue
|
96
|
-
puts
|
96
|
+
puts "Unable to save credentials"
|
97
97
|
end
|
98
98
|
|
99
99
|
def c_load
|
100
|
-
if File.exist?
|
101
|
-
encrypted = File.read(
|
102
|
-
iv_user = Base64.decode64(encrypted.split(
|
103
|
-
username = Base64.decode64(encrypted.split(
|
104
|
-
iv_pwd = Base64.decode64(encrypted.split(
|
105
|
-
password = Base64.decode64(encrypted.split(
|
106
|
-
cipher = OpenSSL::Cipher
|
100
|
+
if File.exist? ".kitchen/cached_vra"
|
101
|
+
encrypted = File.read(".kitchen/cached_vra")
|
102
|
+
iv_user = Base64.decode64(encrypted.split(":")[0] + '\n')
|
103
|
+
username = Base64.decode64(encrypted.split(":")[1] + "\n")
|
104
|
+
iv_pwd = Base64.decode64(encrypted.split(":")[2] + "\n")
|
105
|
+
password = Base64.decode64(encrypted.split(":")[3] + "\n")
|
106
|
+
cipher = OpenSSL::Cipher.new("cip-her-aes")
|
107
107
|
cipher.decrypt
|
108
108
|
cipher.key = Digest::SHA1.hexdigest(config[:base_url])
|
109
109
|
cipher.iv = iv_user
|
@@ -112,30 +112,31 @@ module Kitchen
|
|
112
112
|
config[:password] = cipher.update(password) + cipher.final
|
113
113
|
end
|
114
114
|
rescue
|
115
|
-
puts
|
115
|
+
puts "Failed to load cached credentials"
|
116
116
|
end
|
117
117
|
|
118
118
|
def create(state)
|
119
|
-
return if state[:
|
119
|
+
return if state[:deployment_id]
|
120
120
|
|
121
121
|
server = request_server
|
122
|
-
state[:
|
122
|
+
state[:deployment_id] = server.deployment_id
|
123
123
|
state[:hostname] = hostname_for(server)
|
124
124
|
state[:ssh_key] = config[:private_key_path] unless config[:private_key_path].nil?
|
125
125
|
|
126
126
|
wait_for_server(state, server)
|
127
|
-
info("Server #{server.
|
127
|
+
info("Server #{server.deployment_id} (#{server.name}) ready.")
|
128
128
|
end
|
129
129
|
|
130
130
|
def hostname_for(server)
|
131
131
|
if config[:use_dns]
|
132
|
-
raise
|
132
|
+
raise "No server name returned for the vRA request" if server.name.nil?
|
133
|
+
|
133
134
|
return config[:dns_suffix] ? "#{server.name}.#{config[:dns_suffix]}" : server.name
|
134
135
|
end
|
135
136
|
|
136
|
-
ip_address = server.
|
137
|
+
ip_address = server.ip_address
|
137
138
|
if ip_address.nil?
|
138
|
-
warn("Server #{server.
|
139
|
+
warn("Server #{server.deployment_id} has no IP address. Falling back to server name (#{server.name})...")
|
139
140
|
server.name
|
140
141
|
else
|
141
142
|
ip_address
|
@@ -143,16 +144,18 @@ module Kitchen
|
|
143
144
|
end
|
144
145
|
|
145
146
|
def request_server
|
146
|
-
info(
|
147
|
-
|
148
|
-
|
147
|
+
info("Building vRA catalog request...")
|
148
|
+
|
149
|
+
deployment_request = catalog_request.submit
|
149
150
|
|
150
|
-
|
151
|
-
raise "The vRA request failed: #{submitted_request.completion_details}" if submitted_request.failed?
|
151
|
+
info("Catalog request #{deployment_request.id} submitted.")
|
152
152
|
|
153
|
-
|
154
|
-
raise
|
155
|
-
|
153
|
+
wait_for_request(deployment_request)
|
154
|
+
raise "The vRA request failed: #{deployment_request.completion_details}" if deployment_request.failed?
|
155
|
+
|
156
|
+
servers = deployment_request.resources.select(&:vm?)
|
157
|
+
raise "The vRA request created more than one server. The catalog blueprint should only return one." if servers.size > 1
|
158
|
+
raise "the vRA request did not create any servers." if servers.size == 0
|
156
159
|
|
157
160
|
servers.first
|
158
161
|
end
|
@@ -172,7 +175,7 @@ module Kitchen
|
|
172
175
|
sleep_time += 5 if sleep_time < 30
|
173
176
|
|
174
177
|
if try > config[:server_ready_retries]
|
175
|
-
error(
|
178
|
+
error("Retries exceeded. Destroying server...")
|
176
179
|
destroy(state)
|
177
180
|
raise
|
178
181
|
else
|
@@ -184,56 +187,57 @@ module Kitchen
|
|
184
187
|
end
|
185
188
|
|
186
189
|
def destroy(state)
|
187
|
-
return if state[:
|
190
|
+
return if state[:deployment_id].nil?
|
188
191
|
|
189
192
|
begin
|
190
|
-
server = vra_client.
|
193
|
+
server = vra_client.deployments.by_id(state[:deployment_id])
|
191
194
|
rescue ::Vra::Exception::NotFound
|
192
|
-
warn("No server found with ID #{state[:
|
195
|
+
warn("No server found with ID #{state[:deployment_id]}, assuming it has been destroyed already.")
|
193
196
|
return
|
194
197
|
end
|
195
198
|
|
196
199
|
begin
|
197
200
|
destroy_request = server.destroy
|
198
201
|
rescue ::Vra::Exception::NotFound
|
199
|
-
info(
|
202
|
+
info("Server not found, or no destroy action available, perhaps because it is already destroyed.")
|
200
203
|
return
|
201
204
|
end
|
202
205
|
info("Destroy request #{destroy_request.id} submitted.")
|
203
206
|
wait_for_request(destroy_request)
|
204
|
-
info(
|
207
|
+
info("Destroy request complete.")
|
205
208
|
|
206
|
-
File.delete(
|
207
|
-
info(
|
209
|
+
File.delete(".kitchen/cached_vra") if File.exist?(".kitchen/cached_vra")
|
210
|
+
info("Removed cached file")
|
208
211
|
end
|
209
212
|
|
210
213
|
def catalog_request # rubocop:disable Metrics/MethodLength
|
211
214
|
unless config[:catalog_name].nil?
|
212
|
-
info(
|
215
|
+
info("Fetching Catalog ID by Catalog Name")
|
213
216
|
response = vra_client.catalog.fetch_catalog_items(config[:catalog_name])
|
214
217
|
parsed_json = JSON.parse(response.body)
|
215
218
|
begin
|
216
|
-
config[:catalog_id] = parsed_json[
|
219
|
+
config[:catalog_id] = parsed_json["content"][0]["catalogItemId"]
|
217
220
|
rescue
|
218
221
|
puts "Unable to retrieve Catalog ID from Catalog Name: #{config[:catalog_name]}"
|
219
222
|
end
|
220
223
|
end
|
221
224
|
|
222
|
-
|
225
|
+
deployment_params = {
|
226
|
+
image_mapping: config[:image_mapping],
|
227
|
+
flavor_mapping: config[:flavor_mapping],
|
228
|
+
name: config[:deployment_name],
|
229
|
+
project_id: config[:project_id],
|
230
|
+
version: config[:version],
|
231
|
+
}
|
223
232
|
|
224
|
-
catalog_request
|
225
|
-
catalog_request.memory = config[:memory]
|
226
|
-
catalog_request.shirt_size = config[:shirt_size] unless config[:shirt_size].nil?
|
227
|
-
catalog_request.requested_for = config[:requested_for]
|
228
|
-
catalog_request.lease_days = config[:lease_days] unless config[:lease_days].nil?
|
229
|
-
catalog_request.notes = config[:notes] unless config[:notes].nil?
|
233
|
+
catalog_request = vra_client.catalog.request(config[:catalog_id], deployment_params)
|
230
234
|
|
231
235
|
unless config[:subtenant_name].nil?
|
232
|
-
info(
|
236
|
+
info("Fetching Subtenant ID by Subtenant Name")
|
233
237
|
response = vra_client.fetch_subtenant_items(config[:tenant], config[:subtenant_name])
|
234
238
|
parsed_json = JSON.parse(response.body)
|
235
239
|
begin
|
236
|
-
config[:subtenant_id] = parsed_json[
|
240
|
+
config[:subtenant_id] = parsed_json["content"][0]["id"]
|
237
241
|
rescue
|
238
242
|
puts "Unable to retrieve Subtenant ID from Subtenant Name: #{config[:subtenant_name]}"
|
239
243
|
end
|
@@ -263,9 +267,10 @@ module Kitchen
|
|
263
267
|
def wait_for_request(request)
|
264
268
|
# config = check_config config
|
265
269
|
|
266
|
-
last_status =
|
270
|
+
last_status = ""
|
267
271
|
wait_time = config[:request_timeout]
|
268
272
|
sleep_time = config[:request_refresh_rate]
|
273
|
+
|
269
274
|
Timeout.timeout(wait_time) do
|
270
275
|
loop do
|
271
276
|
request.refresh
|
data/spec/spec_helper.rb
CHANGED
@@ -18,14 +18,14 @@
|
|
18
18
|
# limitations under the License.
|
19
19
|
#
|
20
20
|
|
21
|
-
require
|
21
|
+
require "webmock/rspec"
|
22
22
|
|
23
23
|
WebMock.disable_net_connect!(allow_localhost: true)
|
24
24
|
|
25
|
-
if ENV[
|
26
|
-
require
|
27
|
-
SimpleCov.profiles.define
|
28
|
-
command_name
|
25
|
+
if ENV["COVERAGE"]
|
26
|
+
require "simplecov"
|
27
|
+
SimpleCov.profiles.define "gem" do
|
28
|
+
command_name "Specs"
|
29
29
|
end
|
30
|
-
SimpleCov.start
|
30
|
+
SimpleCov.start "gem"
|
31
31
|
end
|