kitchen-rackspace 0.21.0 → 0.21.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,38 +1,17 @@
1
- # Encoding: UTF-8
2
- #
3
- # Author:: Jonathan Hartman (<j@p4nt5.com>)
4
- #
5
- # Copyright (C) 2013-2015, Jonathan Hartman
6
- #
7
- # Licensed under the Apache License, Version 2.0 (the "License");
8
- # you may not use this file except in compliance with the License.
9
- # You may obtain a copy of the License at
10
- #
11
- # http://www.apache.org/licenses/LICENSE-2.0
12
- #
13
- # Unless required by applicable law or agreed to in writing, software
14
- # distributed under the License is distributed on an "AS IS" BASIS,
15
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
- # See the License for the specific language governing permissions and
17
- # limitations under the License.
18
-
19
- require 'benchmark'
20
- require 'fog'
21
- require 'kitchen'
22
- require 'etc'
23
- require 'socket'
1
+ require "benchmark" unless defined?(Benchmark)
2
+ require "fog/rackspace"
3
+ require "kitchen"
4
+ require "etc" unless defined?(Etc)
5
+ require "socket" unless defined?(Socket)
6
+ require "json" unless defined?(JSON)
24
7
 
25
8
  module Kitchen
26
9
  module Driver
27
- # Rackspace driver for Kitchen.
28
- #
29
- # @author Jonathan Hartman <j@p4nt5.com>
30
10
  class Rackspace < Kitchen::Driver::SSHBase
31
- default_config :version, 'v2'
32
- default_config :flavor_id, 'performance1-1'
33
- default_config :username, 'root'
34
- default_config :port, '22'
35
- default_config :rackspace_region, 'dfw'
11
+ default_config :version, "v2"
12
+ default_config :flavor_id, "performance1-1"
13
+ default_config :username, "root"
14
+ default_config :port, "22"
36
15
  default_config :wait_for, 600
37
16
  default_config :no_ssh_tcp_check, false
38
17
  default_config :no_ssh_tcp_check_sleep, 120
@@ -43,22 +22,28 @@ module Kitchen
43
22
  default_config(:image_id, &:default_image)
44
23
  default_config(:server_name, &:default_name)
45
24
  default_config :networks, nil
25
+ default_config :user_data, nil
26
+ default_config :config_drive, true
46
27
 
47
28
  default_config :public_key_path do
48
29
  [
49
- File.expand_path('~/.ssh/id_rsa.pub'),
50
- File.expand_path('~/.ssh/id_dsa.pub'),
51
- File.expand_path('~/.ssh/identity.pub'),
52
- File.expand_path('~/.ssh/id_ecdsa.pub')
30
+ File.expand_path("~/.ssh/id_rsa.pub"),
31
+ File.expand_path("~/.ssh/id_dsa.pub"),
32
+ File.expand_path("~/.ssh/identity.pub"),
33
+ File.expand_path("~/.ssh/id_ecdsa.pub"),
53
34
  ].find { |path| File.exist?(path) }
54
35
  end
55
36
 
56
37
  default_config :rackspace_username do
57
- ENV['RACKSPACE_USERNAME'] || ENV['OS_USERNAME']
38
+ ENV["RACKSPACE_USERNAME"] || ENV["OS_USERNAME"]
58
39
  end
59
40
 
60
41
  default_config :rackspace_api_key do
61
- ENV['RACKSPACE_API_KEY'] || ENV['OS_PASSWORD']
42
+ ENV["RACKSPACE_API_KEY"] || ENV["OS_PASSWORD"]
43
+ end
44
+
45
+ default_config :rackspace_region do
46
+ ENV["RACKSPACE_REGION"] || ENV["OS_REGION_NAME"] || "dfw"
62
47
  end
63
48
 
64
49
  required_config :rackspace_username
@@ -76,7 +61,7 @@ module Kitchen
76
61
  state[:server_id] = server.id
77
62
  info("Rackspace instance <#{state[:server_id]}> created.")
78
63
  server.wait_for { ready? }
79
- puts '(server ready)'
64
+ puts "(server ready)"
80
65
  rackconnect_check(server) if config[:rackconnect_wait]
81
66
  servicelevel_check(server) if config[:servicelevel_wait]
82
67
  state[:hostname] = hostname(server)
@@ -109,19 +94,19 @@ module Kitchen
109
94
  # Total: 63
110
95
  def default_name
111
96
  [
112
- instance.name.gsub(/\W/, '')[0..14],
113
- (Etc.getlogin || 'nologin').gsub(/\W/, '')[0..14],
114
- Socket.gethostname.gsub(/\W/, '')[0..22],
115
- Array.new(7) { rand(36).to_s(36) }.join
116
- ].join('-')
97
+ instance.name.gsub(/\W/, "")[0..14],
98
+ (Etc.getlogin || "nologin").gsub(/\W/, "")[0..14],
99
+ Socket.gethostname.gsub(/\W/, "")[0..22],
100
+ Array.new(7) { rand(36).to_s(36) }.join,
101
+ ].join("-")
117
102
  end
118
103
 
119
104
  private
120
105
 
121
106
  def compute
122
- server_def = { provider: 'Rackspace' }
123
- opts = [:version, :rackspace_username, :rackspace_api_key,
124
- :rackspace_region]
107
+ server_def = { provider: "Rackspace" }
108
+ opts = %i{version rackspace_username rackspace_api_key
109
+ rackspace_region}
125
110
  opts.each do |opt|
126
111
  server_def[opt] = config[opt]
127
112
  end
@@ -129,8 +114,8 @@ module Kitchen
129
114
  end
130
115
 
131
116
  def create_server
132
- server_def = { name: config[:server_name], networks: networks }
133
- [:image_id, :flavor_id, :public_key_path, :no_passwd_lock].each do |opt|
117
+ server_def = { name: config[:server_name], networks: }
118
+ %i{image_id flavor_id public_key_path no_passwd_lock user_data config_drive}.each do |opt|
134
119
  server_def[opt] = config[opt]
135
120
  end
136
121
  # see @note on bootstrap def about rackconnect
@@ -141,8 +126,8 @@ module Kitchen
141
126
 
142
127
  def images
143
128
  @images ||= begin
144
- json_file = File.expand_path('../../../../data/images.json', __FILE__)
145
- JSON.load(IO.read(json_file))
129
+ json_file = File.expand_path("../../../data/images.json", __dir__)
130
+ JSON.parse(IO.read(json_file))
146
131
  end
147
132
  end
148
133
 
@@ -151,20 +136,20 @@ module Kitchen
151
136
  # it doesn't respect ssh_config values that might be required
152
137
  wait_for_sshd(state[:hostname]) unless config[:no_ssh_tcp_check]
153
138
  sleep(config[:no_ssh_tcp_check_sleep]) if config[:no_ssh_tcp_check]
154
- puts '(ssh ready)'
139
+ puts "(ssh ready)"
155
140
  end
156
141
 
157
142
  def rackconnect_check(server)
158
143
  server.wait_for \
159
- { metadata.all['rackconnect_automation_status'] == 'DEPLOYED' }
160
- puts '(rackconnect automation complete)'
144
+ { metadata.all["rackconnect_automation_status"] == "DEPLOYED" }
145
+ puts "(rackconnect automation complete)"
161
146
  server.update # refresh accessIPv4 with new IP
162
147
  end
163
148
 
164
149
  def servicelevel_check(server)
165
150
  server.wait_for \
166
- { metadata.all['rax_service_level_automation'] == 'Complete' }
167
- puts '(service level automation complete)'
151
+ { metadata.all["rax_service_level_automation"] == "Complete" }
152
+ puts "(service level automation complete)"
168
153
  end
169
154
 
170
155
  def hostname(server)
@@ -176,10 +161,10 @@ module Kitchen
176
161
  end
177
162
 
178
163
  def networks
179
- base_nets = %w(
164
+ base_nets = %w{
180
165
  00000000-0000-0000-0000-000000000000
181
166
  11111111-1111-1111-1111-111111111111
182
- )
167
+ }
183
168
  config[:networks] ? base_nets + config[:networks] : nil
184
169
  end
185
170
  end
@@ -1,27 +1,6 @@
1
- # Encoding: UTF-8
2
1
  # frozen_string_literal: true
3
- #
4
- # Author:: Jonathan Hartman (<j@p4nt5.com>)
5
- #
6
- # Copyright (C) 2013-2015, Jonathan Hartman
7
- #
8
- # Licensed under the Apache License, Version 2.0 (the "License");
9
- # you may not use this file except in compliance with the License.
10
- # You may obtain a copy of the License at
11
- #
12
- # http://www.apache.org/licenses/LICENSE-2.0
13
- #
14
- # Unless required by applicable law or agreed to in writing, software
15
- # distributed under the License is distributed on an "AS IS" BASIS,
16
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17
- # See the License for the specific language governing permissions and
18
- # limitations under the License.
19
-
20
2
  module Kitchen
21
- # Version string for Rackspace Kitchen driver
22
- #
23
- # @author Jonathan Hartman <j@p4nt5.com>
24
3
  module Driver
25
- RACKSPACE_VERSION = '0.21.0'.freeze
4
+ RACKSPACE_VERSION = "0.21.1"
26
5
  end
27
6
  end
@@ -0,0 +1,12 @@
1
+ {
2
+ "packages": {
3
+ ".": {
4
+ "package-name": "kitchen-rackspace",
5
+ "changelog-path": "CHANGELOG.md",
6
+ "release-type": "ruby",
7
+ "include-component-in-tag": false,
8
+ "version-file": "lib/kitchen/driver/rackspace_version.rb"
9
+ }
10
+ },
11
+ "$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json"
12
+ }
data/renovate.json ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "$schema": "https://docs.renovatebot.com/renovate-schema.json",
3
+ "extends": [
4
+ "config:recommended",
5
+ ":disableDependencyDashboard",
6
+ "schedule:automergeEarlyMondays"
7
+ ]
8
+ }