kitchen-vra 2.1.0 → 2.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/kitchen-vra.gemspec +3 -1
- data/lib/kitchen/driver/vra.rb +53 -3
- data/lib/kitchen/driver/vra_version.rb +1 -1
- metadata +16 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: b6cc3c25b21a83eac8d374f6a9210d7ceefc7043
|
|
4
|
+
data.tar.gz: b17fd352f4cd7f095d87dcecd24f391e58abb1fd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: e6b8a50b00f03eda8fcc38dad7355dcaa87b3728d0b4876b5f324ce52c3b484c8a568d7055fa67751894a32dade67896cbe4ebe659d24f95d8bc9ba27cc15831
|
|
7
|
+
data.tar.gz: 1a7fc733c6d13253d0a93affa3ba6fdacd262011704eed4467d9f6fb2b89dfc397999b73cf292a60d413e9461d9f7ea985b1d7e92ce015c6e011a7c7c5df6f61
|
data/README.md
CHANGED
data/kitchen-vra.gemspec
CHANGED
|
@@ -20,7 +20,9 @@ Gem::Specification.new do |spec|
|
|
|
20
20
|
|
|
21
21
|
spec.add_dependency 'test-kitchen'
|
|
22
22
|
spec.add_dependency 'vmware-vra', '~> 2'
|
|
23
|
-
|
|
23
|
+
spec.add_dependency 'highline'
|
|
24
|
+
spec.add_dependency 'rack', '~> 1.6' unless RUBY_VERSION.index('2.0.').nil?
|
|
25
|
+
spec.add_dependency 'ffi-yajl', '~> 2.2.3' unless RUBY_VERSION.index('2.0.').nil?
|
|
24
26
|
spec.add_development_dependency 'bundler', '~> 1.7'
|
|
25
27
|
spec.add_development_dependency 'rake', '~> 10.0'
|
|
26
28
|
spec.add_development_dependency 'rspec', '~> 3.2'
|
data/lib/kitchen/driver/vra.rb
CHANGED
|
@@ -17,6 +17,10 @@
|
|
|
17
17
|
#
|
|
18
18
|
|
|
19
19
|
require 'kitchen'
|
|
20
|
+
require 'highline/import'
|
|
21
|
+
require 'openssl'
|
|
22
|
+
require 'base64'
|
|
23
|
+
require 'digest/sha1'
|
|
20
24
|
require 'vra'
|
|
21
25
|
require_relative 'vra_version'
|
|
22
26
|
|
|
@@ -26,8 +30,8 @@ module Kitchen
|
|
|
26
30
|
kitchen_driver_api_version 2
|
|
27
31
|
plugin_version Kitchen::Driver::VRA_VERSION
|
|
28
32
|
|
|
29
|
-
|
|
30
|
-
|
|
33
|
+
default_config :username, ''
|
|
34
|
+
default_config :password, ''
|
|
31
35
|
required_config :base_url
|
|
32
36
|
required_config :tenant
|
|
33
37
|
required_config :catalog_id
|
|
@@ -44,6 +48,7 @@ module Kitchen
|
|
|
44
48
|
end
|
|
45
49
|
default_config :lease_days, nil
|
|
46
50
|
default_config :notes, nil
|
|
51
|
+
default_config :cache_credentials, false
|
|
47
52
|
default_config :extra_parameters, {}
|
|
48
53
|
default_config :private_key_path do
|
|
49
54
|
%w(id_rsa id_dsa).map do |key|
|
|
@@ -58,6 +63,46 @@ module Kitchen
|
|
|
58
63
|
'vRA'
|
|
59
64
|
end
|
|
60
65
|
|
|
66
|
+
def check_config(force_change = false)
|
|
67
|
+
c_load
|
|
68
|
+
config[:username] = ask('Enter Username: ') if config[:username].eql?('') || force_change
|
|
69
|
+
config[:password] = ask('Enter password: ') { |q| q.echo = '*' } if config[:password].eql?('') || force_change
|
|
70
|
+
c_save
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def c_save
|
|
74
|
+
cipher = OpenSSL::Cipher::Cipher.new('aes-256-cbc')
|
|
75
|
+
cipher.encrypt
|
|
76
|
+
cipher.key = Digest::SHA1.hexdigest(config[:base_url])
|
|
77
|
+
iv = cipher.random_iv
|
|
78
|
+
cipher.iv = iv
|
|
79
|
+
username = cipher.update(config[:username]) + cipher.final
|
|
80
|
+
password = cipher.update(config[:password]) + cipher.final
|
|
81
|
+
output = "#{Base64.encode64(iv).strip!}:#{Base64.encode64(username).strip!}:#{Base64.encode64(password).strip!}"
|
|
82
|
+
file = File.open('.kitchen/cached_vra', 'w')
|
|
83
|
+
file.write(output)
|
|
84
|
+
file.close
|
|
85
|
+
rescue
|
|
86
|
+
puts 'Unable to save credentials'
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def c_load
|
|
90
|
+
if File.exist? '.kitchen/cached_vra'
|
|
91
|
+
encrypted = File.read('.kitchen/cached_vra')
|
|
92
|
+
iv = Base64.decode64(encrypted.split(':')[0] + '\n')
|
|
93
|
+
username = Base64.decode64(encrypted.split(':')[1] + "\n")
|
|
94
|
+
password = Base64.decode64(encrypted.split(':')[2] + "\n")
|
|
95
|
+
cipher = OpenSSL::Cipher::Cipher.new('aes-256-cbc')
|
|
96
|
+
cipher.decrypt
|
|
97
|
+
cipher.key = Digest::SHA1.hexdigest(config[:base_url])
|
|
98
|
+
cipher.iv = iv
|
|
99
|
+
config[:username] = cipher.update(username) + cipher.final
|
|
100
|
+
config[:password] = cipher.update(password) + cipher.final
|
|
101
|
+
end
|
|
102
|
+
rescue
|
|
103
|
+
puts 'Failed to load cached credentials'
|
|
104
|
+
end
|
|
105
|
+
|
|
61
106
|
def create(state)
|
|
62
107
|
return if state[:resource_id]
|
|
63
108
|
|
|
@@ -95,7 +140,7 @@ module Kitchen
|
|
|
95
140
|
|
|
96
141
|
servers = submitted_request.resources.select(&:vm?)
|
|
97
142
|
raise 'The vRA request created more than one server. The catalog blueprint should only return one.' if servers.size > 1
|
|
98
|
-
raise 'the vRA request did not create any servers.' if servers.
|
|
143
|
+
raise 'the vRA request did not create any servers.' if servers.size.zero?
|
|
99
144
|
|
|
100
145
|
servers.first
|
|
101
146
|
end
|
|
@@ -165,6 +210,7 @@ module Kitchen
|
|
|
165
210
|
end
|
|
166
211
|
|
|
167
212
|
def vra_client
|
|
213
|
+
check_config false if config[:cache_credentials]
|
|
168
214
|
@client ||= ::Vra::Client.new(
|
|
169
215
|
base_url: config[:base_url],
|
|
170
216
|
username: config[:username],
|
|
@@ -172,9 +218,13 @@ module Kitchen
|
|
|
172
218
|
tenant: config[:tenant],
|
|
173
219
|
verify_ssl: config[:verify_ssl]
|
|
174
220
|
)
|
|
221
|
+
rescue => _e
|
|
222
|
+
check_config true
|
|
175
223
|
end
|
|
176
224
|
|
|
177
225
|
def wait_for_request(request)
|
|
226
|
+
# config = check_config config
|
|
227
|
+
|
|
178
228
|
last_status = ''
|
|
179
229
|
wait_time = config[:request_timeout]
|
|
180
230
|
sleep_time = config[:request_refresh_rate]
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: kitchen-vra
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 2.
|
|
4
|
+
version: 2.2.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Chef Partner Engineering
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2017-02-
|
|
11
|
+
date: 2017-02-15 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: test-kitchen
|
|
@@ -38,6 +38,20 @@ dependencies:
|
|
|
38
38
|
- - "~>"
|
|
39
39
|
- !ruby/object:Gem::Version
|
|
40
40
|
version: '2'
|
|
41
|
+
- !ruby/object:Gem::Dependency
|
|
42
|
+
name: highline
|
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
|
44
|
+
requirements:
|
|
45
|
+
- - ">="
|
|
46
|
+
- !ruby/object:Gem::Version
|
|
47
|
+
version: '0'
|
|
48
|
+
type: :runtime
|
|
49
|
+
prerelease: false
|
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
51
|
+
requirements:
|
|
52
|
+
- - ">="
|
|
53
|
+
- !ruby/object:Gem::Version
|
|
54
|
+
version: '0'
|
|
41
55
|
- !ruby/object:Gem::Dependency
|
|
42
56
|
name: bundler
|
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|