kitchen-vra 2.7.0 → 3.1.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: e26fd3e9f2467163cb766f196eb7691059c12084f259b285f2bc709a591c273a
4
- data.tar.gz: f263e07c9667b4d171fc61d83ebe177d81200e31aef472e9ca2a83cf2be90f0a
3
+ metadata.gz: 42841b378dc1efcd266d40f01990f7dedc82e8e3d49e742d3268e0cca5c21049
4
+ data.tar.gz: fdd7dfe3c395a460cb92414617a990006508007230aa25c4995af63edadc6a0e
5
5
  SHA512:
6
- metadata.gz: 3f316b3afac08b092c47bec00d79458bae0a88013384639391e3a1ab6383aecab5e382869b6e2292fe3a094bfd4ead9a1246d8ef2f05274c26170ba09ed8ed55
7
- data.tar.gz: 7d1bb7739fa994331a0643ebc8339dda2184fe25b0dee621e259078221679ec417b392f825eda37320df8cf64838fc228ceb90b55290865bcd28f592cea5291a
6
+ metadata.gz: c8742b99fef04d72bd9cd87357ff1d6e30971e5afa70ed3ecadec371a705e7505aafbb38cc655a75e6fab47b2089c61a2323fa1bf084e468913aa852d23c4601
7
+ data.tar.gz: 76d046c6da25ef7c78379bf0c64bb49c3c438cf7f62a05b3a5da49a1c2057b7a5a4d7fbae6b00aac1db2adaa6bf8cd2d1ac84d28f67bc27ab04dea1b139ec6b7
@@ -0,0 +1,7 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: bundler
4
+ directory: "/"
5
+ schedule:
6
+ interval: daily
7
+ open-pull-requests-limit: 10
@@ -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/.rubocop.yml CHANGED
@@ -1,32 +1,2 @@
1
1
  AllCops:
2
- DisplayCopNames: true
3
- Metrics/AbcSize:
4
- Max: 100
5
- Metrics/ClassLength:
6
- Max: 125
7
- Metrics/CyclomaticComplexity:
8
- Max: 20
9
- Metrics/MethodLength:
10
- Exclude:
11
- - '**/*.rb'
12
- Enabled: false
13
- Metrics/PerceivedComplexity:
14
- Max: 30
15
- Metrics/LineLength:
16
- Max: 200
17
- Metrics/MethodLength:
18
- Max: 25
19
- Style/Documentation:
20
- Enabled: false
21
- Style/EndOfLine:
22
- EnforcedStyle: lf
23
- Style/SignalException:
24
- Enabled: false
25
- Layout/SpaceInsideBrackets:
26
- Enabled: false
27
- Style/MutableConstant:
28
- Enabled: false
29
- Metrics/BlockLength:
30
- Exclude:
31
- - "**/*_spec.rb"
32
-
2
+ TargetRubyVersion: 2.7
data/CHANGELOG.md CHANGED
@@ -1,8 +1,35 @@
1
1
  # Change Log
2
2
 
3
- ## [v2.6.0](https://github.com/chef-partners/kitchen-vra/tree/v2.6.0)
3
+ ## [v3.1.0](https://github.com/chef-partners/kitchen-vra/tree/v3.1.0)
4
4
 
5
- [Full Changelog](https://github.com/chef-partners/kitchen-vra/compare/v2.5.0...v2.6.0)
5
+ [Full Changelog](https://github.com/chef-partners/kitchen-vra/compare/v3.0.1...v3.1.0)
6
+
7
+ - Move usage documentation from the readme to the kitchen.ci website
8
+ - Make the version configuration optional
9
+ - Remove the bundler dev dep
10
+ - Update the gemspec for the new maintainer of this project
11
+
12
+ ## [v3.0.1](https://github.com/chef-partners/kitchen-vra/tree/v3.0.1)
13
+
14
+ [Full Changelog](https://github.com/chef-partners/kitchen-vra/compare/v3.0.0...v3.0.1)
15
+
16
+ - Updated the rack gem dependency to allow for modern releases of rack.
17
+
18
+ ## [v3.0.0](https://github.com/chef-partners/kitchen-vra/tree/v3.0.0)
19
+
20
+ [Full Changelog](https://github.com/chef-partners/kitchen-vra/compare/v2.7.1...v3.0.0)
21
+
22
+ - 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.
23
+
24
+ ## [v2.7.1](https://github.com/chef-partners/kitchen-vra/tree/v2.7.1)
25
+
26
+ [Full Changelog](https://github.com/chef-partners/kitchen-vra/compare/v2.7.0...v2.7.1)
27
+
28
+ - Pin vmware-vra gem dep to < 3 to prevent pulling in the new release
29
+
30
+ ## [v2.7.0](https://github.com/chef-partners/kitchen-vra/tree/v2.7.0)
31
+
32
+ [Full Changelog](https://github.com/chef-partners/kitchen-vra/compare/v2.6.0...v2.7.0)
6
33
 
7
34
  - Accept shirt size option available in blueprint as input in kitchen.yml
8
35
 
data/Gemfile CHANGED
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- source 'https://rubygems.org'
4
- gemspec
3
+ source "https://rubygems.org"
4
+ gemspec
data/README.md CHANGED
@@ -22,104 +22,15 @@ Or even better, install it via ChefDK:
22
22
 
23
23
  $ chef gem install kitchen-vra
24
24
 
25
- ## Usage
26
-
27
- After installing the gem as described above, edit your .kitchen.yml file to set the driver to 'vra' and supply your login credentials:
28
-
29
- ```yaml
30
- driver:
31
- name: vra
32
- username: myuser@corp.local
33
- password: mypassword
34
- tenant: mytenant
35
- base_url: https://vra.corp.local
36
- verify_ssl: true
37
- ```
38
-
39
- If you want username and password to be prompted, remove usename and password in your .kitchen.yml as shown below:
40
-
41
- ```yaml
42
- driver:
43
- name: vra
44
- tenant: mytenant
45
- base_url: https://vra.corp.local
46
- verify_ssl: true
47
- ```
48
- If you don't want to explicitly specify username and password in the kitchen.yml, you have an option to set it in the environment variable as
49
-
50
- $ export VRA_USER_NAME='myuser@corp.local'
51
- $ export VRA_USER_PASSWORD='mypassword'
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.
25
+ ## Configuration
54
26
 
55
-
56
- ```yaml
57
- platforms:
58
- - name: centos6
59
- driver:
60
- catalog_id: e9db1084-d1c6-4c1f-8e3c-eb8f3dc574f9
61
- - name: centos7
62
- driver:
63
- catalog_name: my_catalog_name
64
- ```
65
-
66
-
67
-
68
- Other options that you can set include:
69
-
70
- * **lease_days**: number of days to request for a lease, if your catalog item / blueprint requires it
71
- * **request_timeout**: amount of time, in seconds, to wait for a vRA request to complete. Default is 600 seconds.
72
- * **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
- * **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
- * **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
- * **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.
80
- * **use_dns**: Defaults to `false`. Set to `true` if vRA doesn't manage vm ip addresses. This will cause kitchen to attempt to connect via hostname.
81
- * **dns_suffix**: Defaults to `nil`. Set to your domain suffix, for example 'mydomain.com'. This only takes effect when `use_dns` == true and is appended to the hostname returned by vRA.
82
- * **extra_parameters**: a hash of other data to set on a catalog request, most notably custom properties. Allows updates to existing properties on the blueprint as well as the addition of new properties. Each key in the hash is the property name, and the value is a another hash containing the value data type and the value itself. It is possible to use a `~` to add nested parameters.
83
-
84
- These settings can be set globally under the top-level `driver` section, or they can be set on each platform, which allows you to set globals and then override them. For example, this configuration would set the CPU count to 1 except on the "large" platform:
85
-
86
- ```yaml
87
- driver:
88
- name: vra
89
- cpus: 1
90
-
91
- platforms:
92
- - name: small
93
- driver:
94
- catalog_name: my_catalog_name_small
95
- catalog_id: 8a189191-fea6-43eb-981e-ee0fa40f8f57
96
- extra_parameters:
97
- mycustompropname:
98
- type: string
99
- value: smallvalue
100
- Vrm.DataCenter.Location:
101
- type: string
102
- value: Non-Prod
103
- - name: large
104
- driver:
105
- catalog_name: my_catalog_name_large
106
- catalog_id: 1d7c6122-18fa-4ed6-bd13-8a33b6c6ed50
107
- cpus: 2
108
- subtenant_name: my_subtenant_name
109
- extra_parameters:
110
- mycustompropname:
111
- type: string
112
- value: largevalue
113
- Vrm.DataCenter.Location:
114
- type: string
115
- value: Prod
116
- ```
27
+ See the [kitchen.ci kitchen-vra docs](https://kitchen.ci/docs/drivers/vra/) for a complete list of configuration options.
117
28
 
118
29
  ## License and Authors
119
30
 
120
31
  Author:: Chef Partner Engineering (<partnereng@chef.io>)
121
32
 
122
- Copyright:: Copyright (c) 2015-2019 Chef Software, Inc.
33
+ Copyright:: Copyright (c) 2022 Chef Software, Inc.
123
34
 
124
35
  License:: Apache License, Version 2.0
125
36
 
data/Rakefile CHANGED
@@ -1,21 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'bundler/gem_tasks'
4
- require 'rspec/core/rake_task'
5
- require 'rubocop/rake_task'
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
- begin
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,34 @@
1
- # coding: utf-8
2
1
  # frozen_string_literal: true
3
2
 
4
- lib = File.expand_path('../lib', __FILE__)
3
+ lib = File.expand_path("lib", __dir__)
5
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
6
- require 'kitchen/driver/vra_version'
5
+ require "kitchen/driver/vra_version"
7
6
 
8
7
  Gem::Specification.new do |spec|
9
- spec.name = 'kitchen-vra'
8
+ spec.name = "kitchen-vra"
10
9
  spec.version = Kitchen::Driver::VRA_VERSION
11
- spec.authors = ['Chef Partner Engineering']
12
- spec.email = ['partnereng@chef.io']
13
- spec.summary = 'A Test Kitchen driver for VMware vRealize Automation (vRA)'
10
+ spec.authors = ["Chef Commmunity Tools Team"]
11
+ spec.email = ["oss@chef.io"]
12
+ spec.summary = "A Test Kitchen driver for VMware vRealize Automation (vRA)"
14
13
  spec.description = spec.summary
15
- spec.homepage = 'https://github.com/chef-partners/kitchen-vra'
16
- spec.license = 'Apache 2.0'
14
+ spec.homepage = "https://github.com/test-kitchen/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 = ['lib']
20
+ spec.require_paths = ["lib"]
22
21
 
23
- spec.add_dependency 'test-kitchen'
24
- spec.add_dependency 'vmware-vra', '~> 2'
25
- spec.add_dependency 'highline'
26
- spec.add_dependency 'rack', '~> 1.6' unless RUBY_VERSION.index('2.0.').nil?
27
- spec.add_dependency 'ffi-yajl', '~> 2.2.3' unless RUBY_VERSION.index('2.0.').nil?
28
- spec.add_development_dependency 'bundler', '>= 1.7'
29
- spec.add_development_dependency 'github_changelog_generator'
30
- spec.add_development_dependency 'rake', '~> 10.0'
31
- spec.add_development_dependency 'rspec', '~> 3.2'
32
- spec.add_development_dependency 'simplecov', '~> 0.10'
33
- spec.add_development_dependency 'webmock', '~> 1.21'
34
- spec.add_development_dependency 'rubocop', '~> 0.49.0'
22
+ spec.required_ruby_version = ">= 2.7"
23
+
24
+ spec.add_dependency "test-kitchen"
25
+ spec.add_dependency "vmware-vra", ">= 3.1.0" # 3.0 required for vRA 8.x
26
+ spec.add_dependency "highline"
27
+ spec.add_dependency "rack", ">= 1.6", "< 3.0"
28
+ spec.add_dependency "ffi-yajl", ">= 2.2.3", "< 2.5.0"
29
+ spec.add_development_dependency "rake", "~> 13.0"
30
+ spec.add_development_dependency "rspec", "~> 3.2"
31
+ spec.add_development_dependency "simplecov", "~> 0.10"
32
+ spec.add_development_dependency "webmock", "~> 3.14"
33
+ spec.add_development_dependency "chefstyle", "~> 2.2.1"
35
34
  end
@@ -18,13 +18,13 @@
18
18
  # limitations under the License.
19
19
  #
20
20
 
21
- require 'kitchen'
22
- require 'highline/import'
23
- require 'openssl'
24
- require 'base64'
25
- require 'digest/sha1'
26
- require 'vra'
27
- require_relative 'vra_version'
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
+
43
+ default_config :version, nil
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 :cpus, 1
49
- default_config :memory, 1024
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[id_rsa id_dsa].map do |key|
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
- 'vRA'
68
+ "vRA"
69
69
  end
70
70
 
71
71
  def check_config(force_change = false)
72
- config[:username] = config[:username] || ENV['VRA_USER_NAME']
73
- config[:password] = config[:password] || ENV['VRA_USER_PASSWORD']
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('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
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::Cipher.new('aes-256-cbc')
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('.kitchen/cached_vra', 'w')
92
+ file = File.open(".kitchen/cached_vra", "w")
93
93
  file.write(output)
94
94
  file.close
95
95
  rescue
96
- puts 'Unable to save credentials'
96
+ puts "Unable to save credentials"
97
97
  end
98
98
 
99
99
  def c_load
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::Cipher.new('aes-256-cbc')
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 'Failed to load cached credentials'
115
+ puts "Failed to load cached credentials"
116
116
  end
117
117
 
118
118
  def create(state)
119
- return if state[:resource_id]
119
+ return if state[:deployment_id]
120
120
 
121
121
  server = request_server
122
- state[:resource_id] = server.id
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.id} (#{server.name}) ready.")
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 'No server name returned for the vRA request' if server.name.nil?
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.ip_addresses.first
137
+ ip_address = server.ip_address
137
138
  if ip_address.nil?
138
- warn("Server #{server.id} has no IP address. Falling back to server name (#{server.name})...")
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('Building vRA catalog request...')
147
- submitted_request = catalog_request.submit
148
- info("Catalog request #{submitted_request.id} submitted.")
147
+ info("Building vRA catalog request...")
148
+
149
+ deployment_request = catalog_request.submit
149
150
 
150
- wait_for_request(submitted_request)
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
- servers = submitted_request.resources.select(&:vm?)
154
- raise 'The vRA request created more than one server. The catalog blueprint should only return one.' if servers.size > 1
155
- raise 'the vRA request did not create any servers.' if servers.size.zero?
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('Retries exceeded. Destroying server...')
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[:resource_id].nil?
190
+ return if state[:deployment_id].nil?
188
191
 
189
192
  begin
190
- server = vra_client.resources.by_id(state[:resource_id])
193
+ server = vra_client.deployments.by_id(state[:deployment_id])
191
194
  rescue ::Vra::Exception::NotFound
192
- warn("No server found with ID #{state[:resource_id]}, assuming it has been destroyed already.")
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('Server not found, or no destroy action available, perhaps because it is already destroyed.')
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('Destroy request complete.')
207
+ info("Destroy request complete.")
205
208
 
206
- File.delete('.kitchen/cached_vra') if File.exist?('.kitchen/cached_vra')
207
- info('Removed cached file')
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('Fetching Catalog ID by Catalog Name')
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['content'][0]['catalogItemId']
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
- catalog_request = vra_client.catalog.request(config[:catalog_id])
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.cpus = config[:cpus]
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('Fetching Subtenant ID by Subtenant Name')
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['content'][0]['id']
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
@@ -2,7 +2,7 @@
2
2
 
3
3
  #
4
4
  # Author:: Chef Partner Engineering (<partnereng@chef.io>)
5
- # Copyright:: Copyright (c) 2015 Chef Software, Inc.
5
+ # Copyright:: Copyright (c) Chef Software, Inc.
6
6
  # License:: Apache License, Version 2.0
7
7
  #
8
8
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -20,6 +20,6 @@
20
20
 
21
21
  module Kitchen
22
22
  module Driver
23
- VRA_VERSION = '2.7.0'
23
+ VRA_VERSION = "3.1.0"
24
24
  end
25
25
  end
data/spec/spec_helper.rb CHANGED
@@ -18,14 +18,14 @@
18
18
  # limitations under the License.
19
19
  #
20
20
 
21
- require 'webmock/rspec'
21
+ require "webmock/rspec"
22
22
 
23
23
  WebMock.disable_net_connect!(allow_localhost: true)
24
24
 
25
- if ENV['COVERAGE']
26
- require 'simplecov'
27
- SimpleCov.profiles.define 'gem' do
28
- command_name 'Specs'
25
+ if ENV["COVERAGE"]
26
+ require "simplecov"
27
+ SimpleCov.profiles.define "gem" do
28
+ command_name "Specs"
29
29
  end
30
- SimpleCov.start 'gem'
30
+ SimpleCov.start "gem"
31
31
  end