kitchen-vra 2.6.0 → 3.0.1

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
- SHA1:
3
- metadata.gz: 1a1755122b24800867dba47c9142638866369c71
4
- data.tar.gz: c0f760021d3605f40680c5d3f69fbb3f761c9750
2
+ SHA256:
3
+ metadata.gz: b4d867c4c40278ede310114028b5adac346d694f8ff51b94a2b6a22ce9ad81ed
4
+ data.tar.gz: cd585930793bd9e668e23c0744c0632833d8ee572d5715d6ca2527653e943d74
5
5
  SHA512:
6
- metadata.gz: 78ea45407ed4b29b58b10da77af9d2525ae7cd9d9b4099dc3102f3cb7708d296865e6e145c69054ee7218203c1c43c52c26760c1f77749f1c396f2ffcbc6aa2a
7
- data.tar.gz: a17c654055b279fb3cb8d9194942f762a6fec795f6d609e8b3b13afec9b69f05926711367af7b5ff0812907d44b92ca71303af0dab8c835afcd19c8fd5693322
6
+ metadata.gz: 1f5c83ba324e3ad87b1dc792e7fc137f239bc8e6de6e5a244e2c92d0df5f614d5fa5c9605f6e91c94fdebe6e305a41fdff40332793858b10d729e40e0e561376
7
+ data.tar.gz: 29607ec9d52027f6bd67331d157f6d41aee6a647ff3fba5fcc12f5f5befee78da7744bf151bf455d5698f4619cde9f4daa4264b5b29f92f02219bef4ab96086f
@@ -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/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # Change Log
2
2
 
3
+ ## [v3.0.1](https://github.com/chef-partners/kitchen-vra/tree/v3.0.1)
4
+
5
+ [Full Changelog](https://github.com/chef-partners/kitchen-vra/compare/v3.0.0...v3.0.1)
6
+
7
+ - Updated the rack gem dependency to allow for modern releases of rack.
8
+
9
+ ## [v3.0.0](https://github.com/chef-partners/kitchen-vra/tree/v3.0.0)
10
+
11
+ [Full Changelog](https://github.com/chef-partners/kitchen-vra/compare/v2.7.1...v3.0.0)
12
+
13
+ - 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.
14
+
15
+ ## [v2.7.1](https://github.com/chef-partners/kitchen-vra/tree/v2.7.1)
16
+
17
+ [Full Changelog](https://github.com/chef-partners/kitchen-vra/compare/v2.7.0...v2.7.1)
18
+
19
+ - Pin vmware-vra gem dep to < 3 to prevent pulling in the new release
20
+
21
+ ## [v2.7.0](https://github.com/chef-partners/kitchen-vra/tree/v2.7.0)
22
+
23
+ [Full Changelog](https://github.com/chef-partners/kitchen-vra/compare/v2.6.0...v2.7.0)
24
+
25
+ - Accept shirt size option available in blueprint as input in kitchen.yml
26
+
3
27
  ## [v2.5.0](https://github.com/chef-partners/kitchen-vra/tree/v2.5.0)
4
28
 
5
29
  [Full Changelog](https://github.com/chef-partners/kitchen-vra/compare/v2.4.0...v2.5.0)
data/Gemfile CHANGED
@@ -1,3 +1,4 @@
1
1
  # frozen_string_literal: true
2
- source 'https://rubygems.org'
3
- gemspec
2
+
3
+ source "https://rubygems.org"
4
+ gemspec
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,58 +58,68 @@ 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
- * **requested_for**: the vRA login ID to list as the owner of this resource. Defaults to the vRA username configured in the `driver` section.
76
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.
77
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.
78
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.
79
83
  * **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.
80
84
  * **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.
81
- * **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. The vRA REST API expects 'provider-' appended to the front of a property name; 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.
85
+ * **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.
82
86
 
83
87
  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:
84
88
 
85
89
  ```yaml
86
90
  driver:
87
91
  name: vra
88
- cpus: 1
89
92
 
90
93
  platforms:
91
94
  - name: small
92
95
  driver:
93
96
  catalog_name: my_catalog_name_small
94
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
95
102
  extra_parameters:
96
- provider-mycustompropname:
103
+ mycustompropname:
97
104
  type: string
98
105
  value: smallvalue
99
- provider-Vrm.DataCenter.Location:
106
+ Vrm.DataCenter.Location:
100
107
  type: string
101
108
  value: Non-Prod
102
109
  - name: large
103
110
  driver:
104
111
  catalog_name: my_catalog_name_large
105
112
  catalog_id: 1d7c6122-18fa-4ed6-bd13-8a33b6c6ed50
106
- cpus: 2
113
+ project_id: 6ba69375-79d5-42c3-a099-7d32739f71a9
114
+ image_mapping: VRA-nc-lnx-ce8.4-Docker
115
+ flavor_mapping: Large
116
+ version: 1
107
117
  subtenant_name: my_subtenant_name
108
118
  extra_parameters:
109
- provider-mycustompropname:
119
+ mycustompropname:
110
120
  type: string
111
121
  value: largevalue
112
- provider-Vrm.DataCenter.Location:
122
+ Vrm.DataCenter.Location:
113
123
  type: string
114
124
  value: Prod
115
125
  ```
@@ -118,7 +128,7 @@ platforms:
118
128
 
119
129
  Author:: Chef Partner Engineering (<partnereng@chef.io>)
120
130
 
121
- Copyright:: Copyright (c) 2015-2017 Chef Software, Inc.
131
+ Copyright:: Copyright (c) 2022 Chef Software, Inc.
122
132
 
123
133
  License:: Apache License, Version 2.0
124
134
 
data/Rakefile CHANGED
@@ -1,20 +1,11 @@
1
1
  # frozen_string_literal: true
2
- require 'bundler/gem_tasks'
3
- require 'rspec/core/rake_task'
4
- require 'rubocop/rake_task'
2
+
3
+ require "bundler/gem_tasks"
4
+ require "rspec/core/rake_task"
5
+ require "chefstyle"
6
+ require "rubocop/rake_task"
5
7
 
6
8
  RSpec::Core::RakeTask.new(:spec)
7
9
  RuboCop::RakeTask.new(:style)
8
10
 
9
- begin
10
- require 'github_changelog_generator/task'
11
-
12
- GitHubChangelogGenerator::RakeTask.new :changelog do |config|
13
- config.future_release = Kitchen::Driver::VRA_VERSION
14
- config.issues = true
15
- end
16
- rescue LoadError
17
- puts 'github_changelog_generator is not available. gem install github_changelog_generator to generate changelogs'
18
- end
19
-
20
- task default: [ :spec, :style ]
11
+ task default: %i{spec style}
data/kitchen-vra.gemspec CHANGED
@@ -1,34 +1,35 @@
1
- # coding: utf-8
2
1
  # frozen_string_literal: true
3
- lib = File.expand_path('../lib', __FILE__)
2
+
3
+ lib = File.expand_path("lib", __dir__)
4
4
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
- require 'kitchen/driver/vra_version'
5
+ require "kitchen/driver/vra_version"
6
6
 
7
7
  Gem::Specification.new do |spec|
8
- spec.name = 'kitchen-vra'
8
+ spec.name = "kitchen-vra"
9
9
  spec.version = Kitchen::Driver::VRA_VERSION
10
- spec.authors = ['Chef Partner Engineering']
11
- spec.email = ['partnereng@chef.io']
12
- spec.summary = 'A Test Kitchen driver for VMware vRealize Automation (vRA)'
10
+ spec.authors = ["Chef Partner Engineering"]
11
+ spec.email = ["partnereng@chef.io"]
12
+ spec.summary = "A Test Kitchen driver for VMware vRealize Automation (vRA)"
13
13
  spec.description = spec.summary
14
- spec.homepage = 'https://github.com/chef-partners/kitchen-vra'
15
- spec.license = 'Apache 2.0'
14
+ spec.homepage = "https://github.com/chef-partners/kitchen-vra"
15
+ spec.license = "Apache-2.0"
16
16
 
17
17
  spec.files = `git ls-files -z`.split("\x0")
18
18
  spec.executables = []
19
19
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
20
- spec.require_paths = ['lib']
20
+ spec.require_paths = ["lib"]
21
+
22
+ spec.required_ruby_version = ">= 2.7"
21
23
 
22
- spec.add_dependency 'test-kitchen'
23
- spec.add_dependency 'vmware-vra', '~> 2'
24
- spec.add_dependency 'highline'
25
- spec.add_dependency 'rack', '~> 1.6' unless RUBY_VERSION.index('2.0.').nil?
26
- spec.add_dependency 'ffi-yajl', '~> 2.2.3' unless RUBY_VERSION.index('2.0.').nil?
27
- spec.add_development_dependency 'bundler', '~> 1.7'
28
- spec.add_development_dependency 'github_changelog_generator'
29
- spec.add_development_dependency 'rake', '~> 10.0'
30
- spec.add_development_dependency 'rspec', '~> 3.2'
31
- spec.add_development_dependency 'simplecov', '~> 0.10'
32
- spec.add_development_dependency 'webmock', '~> 1.21'
33
- spec.add_development_dependency 'rubocop', '~> 0.35'
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", "< 3.0"
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"
34
35
  end
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  #
3
4
  # Author:: Chef Partner Engineering (<partnereng@chef.io>)
4
5
  # Copyright:: Copyright (c) 2015 Chef Software, Inc.
@@ -17,13 +18,13 @@
17
18
  # limitations under the License.
18
19
  #
19
20
 
20
- require 'kitchen'
21
- require 'highline/import'
22
- require 'openssl'
23
- require 'base64'
24
- require 'digest/sha1'
25
- require 'vra'
26
- 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"
27
28
 
28
29
  module Kitchen
29
30
  module Driver
@@ -35,6 +36,11 @@ module Kitchen
35
36
  default_config :password, nil
36
37
  required_config :base_url
37
38
  required_config :tenant
39
+ required_config :project_id
40
+ required_config :image_mapping
41
+ required_config :flavor_mapping
42
+ required_config :version
43
+
38
44
  default_config :catalog_id, nil
39
45
  default_config :catalog_name, nil
40
46
 
@@ -44,17 +50,13 @@ module Kitchen
44
50
  default_config :request_timeout, 600
45
51
  default_config :request_refresh_rate, 2
46
52
  default_config :server_ready_retries, 1
47
- default_config :cpus, 1
48
- default_config :memory, 1024
49
- default_config :requested_for do |driver|
50
- driver[:username]
53
+ default_config :deployment_name do |driver|
54
+ driver&.instance&.platform&.name
51
55
  end
52
- default_config :lease_days, nil
53
- default_config :notes, nil
54
56
  default_config :cache_credentials, false
55
57
  default_config :extra_parameters, {}
56
58
  default_config :private_key_path do
57
- %w(id_rsa id_dsa).map do |key|
59
+ %w{id_rsa id_dsa}.map do |key|
58
60
  file = File.expand_path("~/.ssh/#{key}")
59
61
  file if File.exist?(file)
60
62
  end.compact.first
@@ -63,21 +65,21 @@ module Kitchen
63
65
  default_config :dns_suffix, nil
64
66
 
65
67
  def name
66
- 'vRA'
68
+ "vRA"
67
69
  end
68
70
 
69
71
  def check_config(force_change = false)
70
- config[:username] = config[:username] || ENV['VRA_USER_NAME']
71
- 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"]
72
74
  c_load if config[:username].nil? && config[:password].nil?
73
75
 
74
- config[:username] = ask('Enter Username: ') if config[:username].nil? || force_change
75
- 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
76
78
  c_save if config[:cache_credentials]
77
79
  end
78
80
 
79
81
  def c_save
80
- cipher = OpenSSL::Cipher::Cipher.new('aes-256-cbc')
82
+ cipher = OpenSSL::Cipher.new("cip-her-aes")
81
83
  cipher.encrypt
82
84
  cipher.key = Digest::SHA1.hexdigest(config[:base_url])
83
85
  iv_user = cipher.random_iv
@@ -87,21 +89,21 @@ module Kitchen
87
89
  cipher.iv = iv_pwd
88
90
  password = cipher.update(config[:password]) + cipher.final
89
91
  output = "#{Base64.encode64(iv_user).strip!}:#{Base64.encode64(username).strip!}:#{Base64.encode64(iv_pwd).strip!}:#{Base64.encode64(password).strip!}"
90
- file = File.open('.kitchen/cached_vra', 'w')
92
+ file = File.open(".kitchen/cached_vra", "w")
91
93
  file.write(output)
92
94
  file.close
93
95
  rescue
94
- puts 'Unable to save credentials'
96
+ puts "Unable to save credentials"
95
97
  end
96
98
 
97
99
  def c_load
98
- if File.exist? '.kitchen/cached_vra'
99
- encrypted = File.read('.kitchen/cached_vra')
100
- iv_user = Base64.decode64(encrypted.split(':')[0] + '\n')
101
- username = Base64.decode64(encrypted.split(':')[1] + "\n")
102
- iv_pwd = Base64.decode64(encrypted.split(':')[2] + "\n")
103
- password = Base64.decode64(encrypted.split(':')[3] + "\n")
104
- 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")
105
107
  cipher.decrypt
106
108
  cipher.key = Digest::SHA1.hexdigest(config[:base_url])
107
109
  cipher.iv = iv_user
@@ -110,30 +112,31 @@ module Kitchen
110
112
  config[:password] = cipher.update(password) + cipher.final
111
113
  end
112
114
  rescue
113
- puts 'Failed to load cached credentials'
115
+ puts "Failed to load cached credentials"
114
116
  end
115
117
 
116
118
  def create(state)
117
- return if state[:resource_id]
119
+ return if state[:deployment_id]
118
120
 
119
121
  server = request_server
120
- state[:resource_id] = server.id
122
+ state[:deployment_id] = server.deployment_id
121
123
  state[:hostname] = hostname_for(server)
122
124
  state[:ssh_key] = config[:private_key_path] unless config[:private_key_path].nil?
123
125
 
124
126
  wait_for_server(state, server)
125
- info("Server #{server.id} (#{server.name}) ready.")
127
+ info("Server #{server.deployment_id} (#{server.name}) ready.")
126
128
  end
127
129
 
128
130
  def hostname_for(server)
129
131
  if config[:use_dns]
130
- 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
+
131
134
  return config[:dns_suffix] ? "#{server.name}.#{config[:dns_suffix]}" : server.name
132
135
  end
133
136
 
134
- ip_address = server.ip_addresses.first
137
+ ip_address = server.ip_address
135
138
  if ip_address.nil?
136
- 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})...")
137
140
  server.name
138
141
  else
139
142
  ip_address
@@ -141,16 +144,18 @@ module Kitchen
141
144
  end
142
145
 
143
146
  def request_server
144
- info('Building vRA catalog request...')
145
- submitted_request = catalog_request.submit
146
- info("Catalog request #{submitted_request.id} submitted.")
147
+ info("Building vRA catalog request...")
147
148
 
148
- wait_for_request(submitted_request)
149
- raise "The vRA request failed: #{submitted_request.completion_details}" if submitted_request.failed?
149
+ deployment_request = catalog_request.submit
150
150
 
151
- servers = submitted_request.resources.select(&:vm?)
152
- raise 'The vRA request created more than one server. The catalog blueprint should only return one.' if servers.size > 1
153
- raise 'the vRA request did not create any servers.' if servers.size.zero?
151
+ info("Catalog request #{deployment_request.id} submitted.")
152
+
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
154
159
 
155
160
  servers.first
156
161
  end
@@ -170,7 +175,7 @@ module Kitchen
170
175
  sleep_time += 5 if sleep_time < 30
171
176
 
172
177
  if try > config[:server_ready_retries]
173
- error('Retries exceeded. Destroying server...')
178
+ error("Retries exceeded. Destroying server...")
174
179
  destroy(state)
175
180
  raise
176
181
  else
@@ -182,60 +187,62 @@ module Kitchen
182
187
  end
183
188
 
184
189
  def destroy(state)
185
- return if state[:resource_id].nil?
190
+ return if state[:deployment_id].nil?
186
191
 
187
192
  begin
188
- server = vra_client.resources.by_id(state[:resource_id])
193
+ server = vra_client.deployments.by_id(state[:deployment_id])
189
194
  rescue ::Vra::Exception::NotFound
190
- 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.")
191
196
  return
192
197
  end
193
198
 
194
199
  begin
195
200
  destroy_request = server.destroy
196
201
  rescue ::Vra::Exception::NotFound
197
- 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.")
198
203
  return
199
204
  end
200
205
  info("Destroy request #{destroy_request.id} submitted.")
201
206
  wait_for_request(destroy_request)
202
- info('Destroy request complete.')
203
-
204
- File.delete('.kitchen/cached_vra') if File.exist?('.kitchen/cached_vra')
205
- info('Removed cached file')
207
+ info("Destroy request complete.")
208
+
209
+ File.delete(".kitchen/cached_vra") if File.exist?(".kitchen/cached_vra")
210
+ info("Removed cached file")
206
211
  end
207
212
 
208
- def catalog_request
209
- if config[:catalog_name] != nil
210
- info('Fetching Catalog ID by Catalog Name')
211
- response = vra_client.catalog.fetch_catalog_items(config[:catalog_name])
212
- parsed_json = JSON.parse(response.body)
213
- begin
214
- config[:catalog_id] = parsed_json['content'][0]['catalogItemId']
215
- rescue
216
- puts "Unable to retrieve Catalog ID from Catalog Name: #{config[:catalog_name]}"
217
- end
213
+ def catalog_request # rubocop:disable Metrics/MethodLength
214
+ unless config[:catalog_name].nil?
215
+ info("Fetching Catalog ID by Catalog Name")
216
+ response = vra_client.catalog.fetch_catalog_items(config[:catalog_name])
217
+ parsed_json = JSON.parse(response.body)
218
+ begin
219
+ config[:catalog_id] = parsed_json["content"][0]["catalogItemId"]
220
+ rescue
221
+ puts "Unable to retrieve Catalog ID from Catalog Name: #{config[:catalog_name]}"
222
+ end
218
223
  end
219
224
 
220
- 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
+ }
221
232
 
222
- catalog_request.cpus = config[:cpus]
223
- catalog_request.memory = config[:memory]
224
- catalog_request.requested_for = config[:requested_for]
225
- catalog_request.lease_days = config[:lease_days] unless config[:lease_days].nil?
226
- catalog_request.notes = config[:notes] unless config[:notes].nil?
233
+ catalog_request = vra_client.catalog.request(config[:catalog_id], deployment_params)
227
234
 
228
- if config[:subtenant_name] != nil
229
- info('Fetching Subtenant ID by Subtenant Name')
235
+ unless config[:subtenant_name].nil?
236
+ info("Fetching Subtenant ID by Subtenant Name")
230
237
  response = vra_client.fetch_subtenant_items(config[:tenant], config[:subtenant_name])
231
238
  parsed_json = JSON.parse(response.body)
232
239
  begin
233
- config[:subtenant_id] = parsed_json['content'][0]['id']
240
+ config[:subtenant_id] = parsed_json["content"][0]["id"]
234
241
  rescue
235
242
  puts "Unable to retrieve Subtenant ID from Subtenant Name: #{config[:subtenant_name]}"
236
243
  end
237
- end
238
- catalog_request.subtenant_id = config[:subtenant_id] unless config[:subtenant_id].nil?
244
+ end
245
+ catalog_request.subtenant_id = config[:subtenant_id] unless config[:subtenant_id].nil?
239
246
 
240
247
  config[:extra_parameters].each do |key, value_data|
241
248
  catalog_request.set_parameters(key, value_data)
@@ -260,9 +267,10 @@ module Kitchen
260
267
  def wait_for_request(request)
261
268
  # config = check_config config
262
269
 
263
- last_status = ''
270
+ last_status = ""
264
271
  wait_time = config[:request_timeout]
265
272
  sleep_time = config[:request_refresh_rate]
273
+
266
274
  Timeout.timeout(wait_time) do
267
275
  loop do
268
276
  request.refresh
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  #
3
4
  # Author:: Chef Partner Engineering (<partnereng@chef.io>)
4
5
  # Copyright:: Copyright (c) 2015 Chef Software, Inc.
@@ -19,6 +20,6 @@
19
20
 
20
21
  module Kitchen
21
22
  module Driver
22
- VRA_VERSION = '2.6.0'
23
+ VRA_VERSION = "3.0.1"
23
24
  end
24
25
  end
data/spec/spec_helper.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+
2
3
  #
3
4
  # Author:: Chef Partner Engineering (<partnereng@chef.io>)
4
5
  # Copyright:: Copyright (c) 2015 Chef Software, Inc.
@@ -17,14 +18,14 @@
17
18
  # limitations under the License.
18
19
  #
19
20
 
20
- require 'webmock/rspec'
21
+ require "webmock/rspec"
21
22
 
22
23
  WebMock.disable_net_connect!(allow_localhost: true)
23
24
 
24
- if ENV['COVERAGE']
25
- require 'simplecov'
26
- SimpleCov.profiles.define 'gem' do
27
- command_name 'Specs'
25
+ if ENV["COVERAGE"]
26
+ require "simplecov"
27
+ SimpleCov.profiles.define "gem" do
28
+ command_name "Specs"
28
29
  end
29
- SimpleCov.start 'gem'
30
+ SimpleCov.start "gem"
30
31
  end