beaker-hostgenerator 1.18.1 → 2.0.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.
@@ -1,7 +1,9 @@
1
1
  module BeakerHostGenerator
2
2
  module Exceptions
3
- class Error < RuntimeError ; end
4
- class InvalidNodeSpecError < BeakerHostGenerator::Exceptions::Error ; end
5
- class SafeEarlyExit < SystemExit ; end
3
+ class Error < RuntimeError; end
4
+
5
+ class InvalidNodeSpecError < BeakerHostGenerator::Exceptions::Error; end
6
+
7
+ class SafeEarlyExit < SystemExit; end
6
8
  end
7
9
  end
@@ -13,7 +13,7 @@ module BeakerHostGenerator
13
13
  # specification and optional configuration.
14
14
  #
15
15
  # @param layout [String] The raw hosts specification user input.
16
- # For example `"centos6-64m-redhat7-64a"`.
16
+ # For example `"centos9-64m-redhat7-64a"`.
17
17
  # @param options [Hash] Global, optional configuration such as the default
18
18
  # hypervisor or OS info version.
19
19
  #
@@ -32,6 +32,7 @@ module BeakerHostGenerator
32
32
  if nodeid[ostype] == 1 and ostype != nil
33
33
  raise "Error: no nodes generated for #{ostype}"
34
34
  end
35
+
35
36
  ostype = token
36
37
  next
37
38
  end
@@ -27,31 +27,14 @@ module BeakerHostGenerator
27
27
  base_config['image'] = "amd64/#{base_config['image']}"
28
28
  end
29
29
 
30
- docker_commands = []
31
-
32
30
  case node_info['ostype']
33
31
  when /^ubuntu/
34
- docker_commands << 'cp /bin/true /sbin/agetty'
35
-
36
- if node_info['ostype'] =~ /1404/
37
- docker_commands << 'rm /usr/sbin/policy-rc.d'
38
- docker_commands << 'rm /sbin/initctl; dpkg-divert --rename --remove /sbin/initctl'
39
- end
40
-
41
- extra_packages_to_install = case node_info['ostype']
42
- when /1404/
43
- ['apt-transport-https']
44
- when /1604/
45
- ['locales']
46
- else
47
- ['locales', 'iproute2', 'gnupg']
48
- end
49
-
50
- docker_commands << "apt-get install -y net-tools wget #{extra_packages_to_install.join(' ')}"
51
- docker_commands << 'locale-gen en_US.UTF-8'
52
- docker_commands << 'echo LANG=en_US.UTF-8 > /etc/default/locale'
53
-
54
- base_config['docker_image_commands'] = docker_commands
32
+ base_config['docker_image_commands'] = [
33
+ 'cp /bin/true /sbin/agetty',
34
+ 'apt-get install -y net-tools wget locales iproute2 gnupg',
35
+ 'locale-gen en_US.UTF-8',
36
+ 'echo LANG=en_US.UTF-8 > /etc/default/locale',
37
+ ]
55
38
  end
56
39
 
57
40
  return base_generate_node(node_info, base_config, bhg_version, :docker)
@@ -3,7 +3,6 @@ require 'beaker-hostgenerator/hypervisor'
3
3
 
4
4
  module BeakerHostGenerator
5
5
  module Hypervisor
6
-
7
6
  class Hcloud < BeakerHostGenerator::Hypervisor::Interface
8
7
  include BeakerHostGenerator::Data
9
8
 
@@ -13,7 +12,7 @@ module BeakerHostGenerator
13
12
  os, version = node_info['ostype'].split(/(\D+)/).reject!(&:empty?)
14
13
  base_config['image'] = case os
15
14
  when 'ubuntu'
16
- "#{os}-#{version[0, 2]}.#{version[2,2]}"
15
+ "#{os}-#{version[0, 2]}.#{version[2, 2]}"
17
16
  when 'centos'
18
17
  version.to_i == 7 ? "#{os}-#{version}" : "#{os}-stream-#{version}"
19
18
  else
@@ -10,7 +10,7 @@ module BeakerHostGenerator
10
10
  # default global configuration keys
11
11
  def global_config
12
12
  {
13
- 'pooling_api' => 'https://vmpooler-prod.k8s.infracore.puppet.net/'
13
+ 'pooling_api' => 'https://vmpooler-prod.k8s.infracore.puppet.net/',
14
14
  }
15
15
  end
16
16
 
@@ -35,10 +35,6 @@ module BeakerHostGenerator
35
35
  base_config['template'] ||= "#{node_info['ostype'].sub('ubuntu', 'ubuntu-')}-#{arch}" if arch
36
36
  end
37
37
 
38
- # Some vmpooler/vsphere platforms have special requirements.
39
- # We munge the node host config here if that is necessary.
40
- fixup_node base_config
41
-
42
38
  return base_config
43
39
  end
44
40
  end
@@ -1,5 +1,4 @@
1
1
  module BeakerHostGenerator
2
-
3
2
  # Defines an Interface for the implementation of a hypervisor, and provides
4
3
  # a static module function `create(node_info, options)` for instantiating
5
4
  # the appropriate hypervisor implementation.
@@ -13,7 +12,6 @@ module BeakerHostGenerator
13
12
  # Generator will instantiate the appropriate hypervisor via
14
13
  # `BeakerHostGenerator::Hypervisor.create`.
15
14
  module Hypervisor
16
-
17
15
  # Static factory method to instantiate the appropriate hypervisor for the
18
16
  # given node. If no hypervisor is specified in the node info, then the
19
17
  # hypervisor specified in the options will be created. If the hypervisor is
@@ -15,7 +15,6 @@ module BeakerHostGenerator
15
15
  # into tokens via `tokenize_layout`, and then for each token you would call
16
16
  # `is_ostype_token?` and/or `parse_node_info_token`.
17
17
  module Parser
18
-
19
18
  # Parses a single node definition into the following components:
20
19
  #
21
20
  # * bits Uppercase-only alphanumeric
@@ -63,7 +62,7 @@ module BeakerHostGenerator
63
62
  # * agent
64
63
  # * database
65
64
  #
66
- NODE_REGEX=/\A(?<bits>[A-Z0-9]+|\d+)((?<arbitrary_roles>([[:lower:]_]*|\,)*)\.)?(?<roles>[uacldfm]*)(?<host_settings>\{[[:print:]]*\})?\Z/
65
+ NODE_REGEX = /\A(?<bits>[A-Z0-9]+|\d+)((?<arbitrary_roles>([[:lower:]_]*|\,)*)\.)?(?<roles>[uacldfm]*)(?<host_settings>\{[[:print:]]*\})?\Z/
67
66
 
68
67
  module_function
69
68
 
@@ -86,25 +85,25 @@ module BeakerHostGenerator
86
85
  # which are used to define arbitrary key-values on a node.
87
86
  #
88
87
  # @param spec [String] Well-formatted string specification of the hosts to
89
- # generate. For example `"centos6-64m-debian8-32a"`.
88
+ # generate. For example `"centos9-64m-debian11-64a"`.
90
89
  # @returns [Array<String>] Input string split into substrings suitable for
91
90
  # processing by the generator. For example
92
- # `["centos6", "64m", "debian8", "32a"]`.
91
+ # `["centos9", "64m", "debian11", "64a"]`.
93
92
  def tokenize_layout(layout_spec)
94
93
  # Here we allow dashes in certain parts of the spec string
95
- # i.e. "centos6-64m{hostname=foo-bar}-debian8-32"
94
+ # i.e. "centos9-64m{hostname=foo-bar}-debian11-64"
96
95
  # by first replacing all occurrences of - with | that exist within
97
96
  # the braces {...}.
98
97
  #
99
98
  # So we'd end up with:
100
- # "centos6-64m{hostname=foo|bar}-debian8-32"
99
+ # "centos9-64m{hostname=foo|bar}-debian11-64"
101
100
  #
102
101
  # Which we can then simply split on - into:
103
- # ["centos6", "64m{hostname=foo|bar}", "debian8", "32"]
102
+ # ["centos9", "64m{hostname=foo|bar}", "debian11", "64"]
104
103
  #
105
104
  # And then finally turn the | back into - now that we've
106
105
  # properly decomposed the spec string:
107
- # ["centos6", "64m{hostname=foo-bar}", "debian8", "32"]
106
+ # ["centos9", "64m{hostname=foo-bar}", "debian11", "64"]
108
107
  #
109
108
  # NOTE we've specifically chosen to use the pipe character |
110
109
  # due to its unlikely occurrence in the user input string.
@@ -124,8 +123,8 @@ module BeakerHostGenerator
124
123
  tokens.map { |t| t.gsub('|', '-') }
125
124
  end
126
125
 
127
- # Tests if a string token represents an OS platform (i.e. "centos6" or
128
- # "debian8") and not another part of the host specification like the
126
+ # Tests if a string token represents an OS platform (i.e. "centos9" or
127
+ # "debian11") and not another part of the host specification like the
129
128
  # architecture bit (i.e. "32" or "64").
130
129
  #
131
130
  # This is used when parsing the host generator input string to determine
@@ -133,7 +132,7 @@ module BeakerHostGenerator
133
132
  # host for a current platform.
134
133
  #
135
134
  # @param [String] token A piece of the host generator input that might refer
136
- # to an OS platform. For example `"centos6"` or `"debian8"`.
135
+ # to an OS platform. For example `"centos9"` or `"debian11"`.
137
136
  #
138
137
  # @param [Integer] bhg_version The version of OS info to use when testing
139
138
  # for whether the token represent an OS platform.
@@ -169,7 +168,7 @@ module BeakerHostGenerator
169
168
  node_info = NODE_REGEX.match(token)
170
169
 
171
170
  if node_info
172
- node_info = Hash[ node_info.names.zip( node_info.captures ) ]
171
+ node_info = Hash[node_info.names.zip(node_info.captures)]
173
172
  else
174
173
  raise BeakerHostGenerator::Exceptions::InvalidNodeSpecError.new,
175
174
  "Invalid node_info token: #{token}"
@@ -209,7 +208,6 @@ module BeakerHostGenerator
209
208
  #
210
209
  # @returns [Hash{String=>String|Array|Hash}] The host_settings string as a map.
211
210
  def settings_string_to_map(host_settings)
212
-
213
211
  stringscan = StringScanner.new(host_settings)
214
212
  object = nil
215
213
  object_depth = []
@@ -253,8 +251,6 @@ module BeakerHostGenerator
253
251
  next
254
252
  end
255
253
 
256
-
257
-
258
254
  if blob == ']' or blob == '}'
259
255
  object_depth.pop
260
256
  current_depth = current_depth.pred
@@ -265,7 +261,8 @@ module BeakerHostGenerator
265
261
  # corresponding data structure, add it to the object depth, and
266
262
  # then change the current depth
267
263
  if blob[-2] == '='
268
- raise Beaker::HostGenerator::Exceptions::InvalidNodeSpecError unless blob.end_with?('{','[')
264
+ raise Beaker::HostGenerator::Exceptions::InvalidNodeSpecError unless blob.end_with?('{', '[')
265
+
269
266
  if blob[-1] == '{'
270
267
  current_object[blob[0..-3]] = {}
271
268
  else
@@ -278,8 +275,10 @@ module BeakerHostGenerator
278
275
 
279
276
  if blob[-1] == '}'
280
277
  raise Beaker::HostGenerator::Exceptions::InvalidNodeSpecError if blob.count('=') != 1
278
+
281
279
  key_pair = blob[0..-2].split('=')
282
280
  raise Beaker::HostGenerator::Exceptions::InvalidNodeSpecError if key_pair.size != 2
281
+
283
282
  key_pair.each do |element|
284
283
  raise Beaker::HostGenerator::Exceptions::InvalidNodeSpecError if element.empty?
285
284
  end
@@ -297,6 +296,7 @@ module BeakerHostGenerator
297
296
  if current_type == Hash
298
297
  key_pair = blob[0..-2].split('=')
299
298
  raise Beaker::HostGenerator::Exceptions::InvalidNodeSpecError if key_pair.size != 2
299
+
300
300
  key_pair.each do |element|
301
301
  raise Beaker::HostGenerator::Exceptions::InvalidNodeSpecError if element.empty?
302
302
  end
@@ -317,10 +317,9 @@ module BeakerHostGenerator
317
317
  end
318
318
 
319
319
  object
320
- rescue Exception => e
320
+ rescue Exception
321
321
  raise BeakerHostGenerator::Exceptions::InvalidNodeSpecError,
322
322
  "Malformed host settings: #{host_settings}"
323
323
  end
324
-
325
324
  end
326
325
  end
@@ -1,6 +1,5 @@
1
1
  module BeakerHostGenerator
2
2
  module Roles
3
-
4
3
  ROLES = {
5
4
  'a' => 'agent',
6
5
  'u' => 'ca',
@@ -14,7 +13,7 @@ module BeakerHostGenerator
14
13
  CM_CONFIG = { 'main' => {
15
14
  'dns_alt_names' => 'puppet',
16
15
  'environmentpath' => '/etc/puppetlabs/puppet/environments',
17
- }
16
+ },
18
17
  }
19
18
 
20
19
  ROLE_CONFIG = {
@@ -11,10 +11,6 @@ module BeakerHostGenerator
11
11
  BeakerHostGenerator::Data.pe_dir(version)
12
12
  end
13
13
 
14
- def fixup_node(cfg)
15
- BeakerHostGenerator::Data.fixup_node(cfg)
16
- end
17
-
18
14
  def dump_hosts(hosts, path)
19
15
  vmpooler_hypervisor = BeakerHostGenerator::Hypervisor::Vmpooler.new
20
16
  config = {}
@@ -34,7 +30,7 @@ module BeakerHostGenerator
34
30
  end
35
31
  end
36
32
 
37
- def get_platforms(hypervisor_type='vmpooler', bhg_version=0)
33
+ def get_platforms(hypervisor_type = 'vmpooler', bhg_version = 0)
38
34
  BeakerHostGenerator::Data.get_platforms(bhg_version)
39
35
  end
40
36
 
@@ -1,5 +1,5 @@
1
1
  module BeakerHostGenerator
2
2
  module Version
3
- STRING = '1.18.1'
3
+ STRING = '2.0.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,47 +1,40 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beaker-hostgenerator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.18.1
4
+ version: 2.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Branan Purvine-Riley
8
8
  - Wayne Warren
9
9
  - Nate Wolfe
10
+ - Vox Pupuli
10
11
  autorequire:
11
12
  bindir: bin
12
13
  cert_chain: []
13
- date: 2022-12-14 00:00:00.000000000 Z
14
+ date: 2023-04-28 00:00:00.000000000 Z
14
15
  dependencies:
15
16
  - !ruby/object:Gem::Dependency
16
- name: minitest
17
+ name: fakefs
17
18
  requirement: !ruby/object:Gem::Requirement
18
19
  requirements:
19
20
  - - ">="
20
21
  - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :development
23
- prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- requirements:
26
- - - ">="
27
- - !ruby/object:Gem::Version
28
- version: '0'
29
- - !ruby/object:Gem::Dependency
30
- name: rspec
31
- requirement: !ruby/object:Gem::Requirement
32
- requirements:
33
- - - "~>"
22
+ version: '0.6'
23
+ - - "<"
34
24
  - !ruby/object:Gem::Version
35
25
  version: '3.0'
36
26
  type: :development
37
27
  prerelease: false
38
28
  version_requirements: !ruby/object:Gem::Requirement
39
29
  requirements:
40
- - - "~>"
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0.6'
33
+ - - "<"
41
34
  - !ruby/object:Gem::Version
42
35
  version: '3.0'
43
36
  - !ruby/object:Gem::Dependency
44
- name: rspec-its
37
+ name: minitest
45
38
  requirement: !ruby/object:Gem::Requirement
46
39
  requirements:
47
40
  - - ">="
@@ -55,25 +48,19 @@ dependencies:
55
48
  - !ruby/object:Gem::Version
56
49
  version: '0'
57
50
  - !ruby/object:Gem::Dependency
58
- name: fakefs
51
+ name: pry
59
52
  requirement: !ruby/object:Gem::Requirement
60
53
  requirements:
61
- - - ">="
62
- - !ruby/object:Gem::Version
63
- version: '0.6'
64
- - - "<"
54
+ - - "~>"
65
55
  - !ruby/object:Gem::Version
66
- version: '2.0'
56
+ version: '0.10'
67
57
  type: :development
68
58
  prerelease: false
69
59
  version_requirements: !ruby/object:Gem::Requirement
70
60
  requirements:
71
- - - ">="
72
- - !ruby/object:Gem::Version
73
- version: '0.6'
74
- - - "<"
61
+ - - "~>"
75
62
  - !ruby/object:Gem::Version
76
- version: '2.0'
63
+ version: '0.10'
77
64
  - !ruby/object:Gem::Dependency
78
65
  name: rake
79
66
  requirement: !ruby/object:Gem::Requirement
@@ -89,21 +76,21 @@ dependencies:
89
76
  - !ruby/object:Gem::Version
90
77
  version: '13.0'
91
78
  - !ruby/object:Gem::Dependency
92
- name: pry
79
+ name: rspec
93
80
  requirement: !ruby/object:Gem::Requirement
94
81
  requirements:
95
82
  - - "~>"
96
83
  - !ruby/object:Gem::Version
97
- version: '0.10'
84
+ version: '3.0'
98
85
  type: :development
99
86
  prerelease: false
100
87
  version_requirements: !ruby/object:Gem::Requirement
101
88
  requirements:
102
89
  - - "~>"
103
90
  - !ruby/object:Gem::Version
104
- version: '0.10'
91
+ version: '3.0'
105
92
  - !ruby/object:Gem::Dependency
106
- name: yard
93
+ name: rspec-its
107
94
  requirement: !ruby/object:Gem::Requirement
108
95
  requirements:
109
96
  - - ">="
@@ -130,6 +117,20 @@ dependencies:
130
117
  - - ">="
131
118
  - !ruby/object:Gem::Version
132
119
  version: '0'
120
+ - !ruby/object:Gem::Dependency
121
+ name: yard
122
+ requirement: !ruby/object:Gem::Requirement
123
+ requirements:
124
+ - - ">="
125
+ - !ruby/object:Gem::Version
126
+ version: '0'
127
+ type: :development
128
+ prerelease: false
129
+ version_requirements: !ruby/object:Gem::Requirement
130
+ requirements:
131
+ - - ">="
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
133
134
  - !ruby/object:Gem::Dependency
134
135
  name: deep_merge
135
136
  requirement: !ruby/object:Gem::Requirement
@@ -149,10 +150,9 @@ description: |
149
150
  its first positional argument and use that to generate a Beaker host
150
151
  configuration file.
151
152
  email:
152
- - qe-team@puppet.com
153
+ - pmc@voxpupuli.org
153
154
  executables:
154
155
  - beaker-hostgenerator
155
- - genconfig2
156
156
  extensions: []
157
157
  extra_rdoc_files: []
158
158
  files:
@@ -161,6 +161,8 @@ files:
161
161
  - ".github/workflows/test.yml"
162
162
  - ".gitignore"
163
163
  - ".rspec"
164
+ - ".rubocop.yml"
165
+ - ".rubocop_todo.yml"
164
166
  - ".simplecov"
165
167
  - CHANGELOG.md
166
168
  - CODEOWNERS
@@ -172,7 +174,6 @@ files:
172
174
  - Rakefile
173
175
  - beaker-hostgenerator.gemspec
174
176
  - bin/beaker-hostgenerator
175
- - bin/genconfig2
176
177
  - lib/beaker-hostgenerator.rb
177
178
  - lib/beaker-hostgenerator/abs_support.rb
178
179
  - lib/beaker-hostgenerator/cli.rb
@@ -202,7 +203,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
202
203
  requirements:
203
204
  - - ">="
204
205
  - !ruby/object:Gem::Version
205
- version: '0'
206
+ version: '2.7'
206
207
  required_rubygems_version: !ruby/object:Gem::Requirement
207
208
  requirements:
208
209
  - - ">="
data/bin/genconfig2 DELETED
@@ -1,14 +0,0 @@
1
- #! /usr/bin/env ruby
2
-
3
- lib_dir = File.expand_path(File.dirname(File.dirname(__FILE__)), 'lib')
4
- $LOAD_PATH.unshift(lib_dir)
5
-
6
- require 'beaker-hostgenerator'
7
-
8
- $stderr.puts("Warning: 'genconfig2' is deprecated and will be removed in beaker-hostgenerator 1.x\n\n")
9
-
10
- begin
11
- cli = BeakerHostGenerator::CLI.new
12
- cli.execute!
13
- rescue BeakerHostGenerator::Exceptions::SafeEarlyExit
14
- end