kitchen-vra 2.3.0 → 2.4.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
  SHA1:
3
- metadata.gz: 5e4cfc4ac71a96821a3b283979f4f02a37c2ea71
4
- data.tar.gz: 1d1029f7792c46a8c4cbe8e19d45418dc6969617
3
+ metadata.gz: dc5351db8abc9e1ebed8cd6d250cd6eed5294ac3
4
+ data.tar.gz: dadebc21274f1612b11325524295e60e23c6c64d
5
5
  SHA512:
6
- metadata.gz: ce5a986c98e748a248d9053f989b6480620d5307e2211636ac59dfc4ca861d221cc8b0f71c421575e5baefd0626b0228751fa6308ed2ce5b6c04e7a892672456
7
- data.tar.gz: 96caae81ee6b15e35d26e28e44915d2176964bc46d253aa7f2e8dc2f04e007674f32175af23205cb1e0fec155677c9a98a553179239e7f3509f7ce61affe63fe
6
+ metadata.gz: 1fe82016e8c6bb3042772a7b3dd42ee4d824a6ac06ca43a0e85bb9b4ddd47b6886a22d7372b5ef5e7997e99d2a975130d145fb6d6d35c7eadb87537696dc3178
7
+ data.tar.gz: 081cd1c7f6aee2fa0f9577323efb79de324f9e9a2328a15cdeb20336a52f00106b0d96995d21270ec8dd83819f346509f77b4fddc0114b312f7e669ed67c4635
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Change Log
2
2
 
3
+ ## [2.4.0] (https://github.com/chef-partners/kitchen-vra/tree/v2.4.0) (2018-01-04)
4
+ [Full Changelog](https://github.com/chef-partners/kitchen-vra/compare/v2.3.0...2.4.0)
5
+
6
+ **Enhanced/Fixed:**
7
+
8
+ - Enhance vRA Kitchen driver to accept Catalog name as an input.
9
+ - Ability of vRA Kitchen driver to accept credentials from environment variable even if they are not being mentioned in the `.kitchen.yml` file
10
+ - Ability of vRA kitchen driver to prompt for credentials if it’s not able retrieve from `.kitchen.yml` or from environment variable.
11
+ - An option to not save credentials based on the usage of an existing flag.
12
+ - Fixed a bug in the encryption/decryption logic.
13
+
14
+
3
15
  ## [2.3.0](https://github.com/chef-partners/kitchen-vra/tree/2.3.0) (2017-07-14)
4
16
  [Full Changelog](https://github.com/chef-partners/kitchen-vra/compare/v2.2.0...2.3.0)
5
17
 
@@ -82,4 +94,4 @@
82
94
 
83
95
 
84
96
 
85
- \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
97
+ \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
data/README.md CHANGED
@@ -36,7 +36,22 @@ driver:
36
36
  verify_ssl: true
37
37
  ```
38
38
 
39
- Then configure your platforms. A catalog_id is required for each platform:
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.
54
+
40
55
 
41
56
  ```yaml
42
57
  platforms:
@@ -45,9 +60,11 @@ platforms:
45
60
  catalog_id: e9db1084-d1c6-4c1f-8e3c-eb8f3dc574f9
46
61
  - name: centos7
47
62
  driver:
48
- catalog_id: c4211950-ab07-42b1-ba80-8f5d3f2c8251
63
+ catalog_name: my_catalog_name
49
64
  ```
50
65
 
66
+
67
+
51
68
  Other options that you can set include:
52
69
 
53
70
  * **lease_days**: number of days to request for a lease, if your catalog item / blueprint requires it
@@ -72,6 +89,7 @@ driver:
72
89
  platforms:
73
90
  - name: small
74
91
  driver:
92
+ catalog_name: my_catalog_name_small
75
93
  catalog_id: 8a189191-fea6-43eb-981e-ee0fa40f8f57
76
94
  extra_parameters:
77
95
  provider-mycustompropname:
@@ -82,6 +100,7 @@ platforms:
82
100
  value: Non-Prod
83
101
  - name: large
84
102
  driver:
103
+ catalog_name: my_catalog_name_large
85
104
  catalog_id: 1d7c6122-18fa-4ed6-bd13-8a33b6c6ed50
86
105
  cpus: 2
87
106
  extra_parameters:
@@ -31,11 +31,12 @@ module Kitchen
31
31
  kitchen_driver_api_version 2
32
32
  plugin_version Kitchen::Driver::VRA_VERSION
33
33
 
34
- default_config :username, ''
35
- default_config :password, ''
34
+ default_config :username, nil
35
+ default_config :password, nil
36
36
  required_config :base_url
37
37
  required_config :tenant
38
- required_config :catalog_id
38
+ default_config :catalog_id, nil
39
+ default_config :catalog_name, nil
39
40
 
40
41
  default_config :subtenant, nil
41
42
  default_config :verify_ssl, true
@@ -65,21 +66,26 @@ module Kitchen
65
66
  end
66
67
 
67
68
  def check_config(force_change = false)
68
- c_load
69
- config[:username] = ask('Enter Username: ') if config[:username].eql?('') || force_change
70
- config[:password] = ask('Enter password: ') { |q| q.echo = '*' } if config[:password].eql?('') || force_change
71
- c_save
69
+ config[:username] = config[:username] || ENV['VRA_USER_NAME']
70
+ config[:password] = config[:password] || ENV['VRA_USER_PASSWORD']
71
+ c_load if config[:username].nil? && config[:password].nil?
72
+
73
+ config[:username] = ask('Enter Username: ') if config[:username].nil? || force_change
74
+ config[:password] = ask('Enter password: ') { |q| q.echo = '*' } if config[:password].nil? || force_change
75
+ c_save if config[:cache_credentials]
72
76
  end
73
77
 
74
78
  def c_save
75
79
  cipher = OpenSSL::Cipher::Cipher.new('aes-256-cbc')
76
80
  cipher.encrypt
77
81
  cipher.key = Digest::SHA1.hexdigest(config[:base_url])
78
- iv = cipher.random_iv
79
- cipher.iv = iv
82
+ iv_user = cipher.random_iv
83
+ cipher.iv = iv_user
80
84
  username = cipher.update(config[:username]) + cipher.final
85
+ iv_pwd = cipher.random_iv
86
+ cipher.iv = iv_pwd
81
87
  password = cipher.update(config[:password]) + cipher.final
82
- output = "#{Base64.encode64(iv).strip!}:#{Base64.encode64(username).strip!}:#{Base64.encode64(password).strip!}"
88
+ output = "#{Base64.encode64(iv_user).strip!}:#{Base64.encode64(username).strip!}:#{Base64.encode64(iv_pwd).strip!}:#{Base64.encode64(password).strip!}"
83
89
  file = File.open('.kitchen/cached_vra', 'w')
84
90
  file.write(output)
85
91
  file.close
@@ -90,14 +96,16 @@ module Kitchen
90
96
  def c_load
91
97
  if File.exist? '.kitchen/cached_vra'
92
98
  encrypted = File.read('.kitchen/cached_vra')
93
- iv = Base64.decode64(encrypted.split(':')[0] + '\n')
99
+ iv_user = Base64.decode64(encrypted.split(':')[0] + '\n')
94
100
  username = Base64.decode64(encrypted.split(':')[1] + "\n")
95
- password = Base64.decode64(encrypted.split(':')[2] + "\n")
101
+ iv_pwd = Base64.decode64(encrypted.split(':')[2] + "\n")
102
+ password = Base64.decode64(encrypted.split(':')[3] + "\n")
96
103
  cipher = OpenSSL::Cipher::Cipher.new('aes-256-cbc')
97
104
  cipher.decrypt
98
105
  cipher.key = Digest::SHA1.hexdigest(config[:base_url])
99
- cipher.iv = iv
106
+ cipher.iv = iv_user
100
107
  config[:username] = cipher.update(username) + cipher.final
108
+ cipher.iv = iv_pwd
101
109
  config[:password] = cipher.update(password) + cipher.final
102
110
  end
103
111
  rescue
@@ -191,9 +199,23 @@ module Kitchen
191
199
  info("Destroy request #{destroy_request.id} submitted.")
192
200
  wait_for_request(destroy_request)
193
201
  info('Destroy request complete.')
202
+
203
+ File.delete('.kitchen/cached_vra') if File.exist?('.kitchen/cached_vra')
204
+ info('Removed cached file')
194
205
  end
195
206
 
196
207
  def catalog_request
208
+ if config[:catalog_name] != nil
209
+ info('Fetching Catalog ID by Catalog Name')
210
+ response = vra_client.catalog.fetch_catalog_items(config[:catalog_name])
211
+ parsed_json = JSON.parse(response.body)
212
+ begin
213
+ config[:catalog_id] = parsed_json['content'][0]['catalogItemId']
214
+ rescue
215
+ puts "Unable to retrieve Catalog ID from Catalog Name: #{config[:catalog_name]}"
216
+ end
217
+ end
218
+
197
219
  catalog_request = vra_client.catalog.request(config[:catalog_id])
198
220
 
199
221
  catalog_request.cpus = config[:cpus]
@@ -211,7 +233,7 @@ module Kitchen
211
233
  end
212
234
 
213
235
  def vra_client
214
- check_config false if config[:cache_credentials]
236
+ check_config config[:cache_credentials]
215
237
  @client ||= ::Vra::Client.new(
216
238
  base_url: config[:base_url],
217
239
  username: config[:username],
@@ -19,6 +19,6 @@
19
19
 
20
20
  module Kitchen
21
21
  module Driver
22
- VRA_VERSION = '2.3.0'
22
+ VRA_VERSION = '2.4.0'
23
23
  end
24
24
  end
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.3.0
4
+ version: 2.4.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-07-14 00:00:00.000000000 Z
11
+ date: 2018-01-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: test-kitchen