beaker-hostgenerator 1.2.10 → 1.6.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -22,7 +22,7 @@ module BeakerHostGenerator
22
22
  def generate(layout, options)
23
23
  layout = prepare(layout)
24
24
  tokens = tokenize_layout(layout)
25
- config = {}.deep_merge(BASE_CONFIG)
25
+ config = {}.deeper_merge(BASE_CONFIG)
26
26
  nodeid = Hash.new(1)
27
27
  ostype = nil
28
28
  bhg_version = options[:osinfo_version] || 0
@@ -51,7 +51,7 @@ module BeakerHostGenerator
51
51
  # Delegate to the hypervisor
52
52
  hypervisor = BeakerHostGenerator::Hypervisor.create(node_info, options)
53
53
  host_config = hypervisor.generate_node(node_info, host_config, bhg_version)
54
- config['CONFIG'].deep_merge!(hypervisor.global_config())
54
+ config['CONFIG'].deeper_merge!(hypervisor.global_config())
55
55
 
56
56
  # Merge in any arbitrary key-value host settings. Treat the 'hostname'
57
57
  # setting specially, and don't merge it in as an arbitrary setting.
@@ -80,7 +80,7 @@ module BeakerHostGenerator
80
80
  decoded = "{#{decoded}}"
81
81
  end
82
82
  global_config = settings_string_to_map(decoded)
83
- config['CONFIG'].deep_merge!(global_config)
83
+ config['CONFIG'].deeper_merge!(global_config)
84
84
  end
85
85
 
86
86
  # Munge non-string scalar values into proper data types
@@ -117,7 +117,7 @@ module BeakerHostGenerator
117
117
 
118
118
  if not options[:disable_role_config]
119
119
  host_config['roles'].each do |role|
120
- host_config.deep_merge! get_role_config(role)
120
+ host_config.deeper_merge! get_role_config(role)
121
121
  end
122
122
  end
123
123
  end
@@ -94,7 +94,7 @@ module BeakerHostGenerator
94
94
  def base_generate_node(node_info, base_config, bhg_version, *hypervisors)
95
95
  platform = node_info['platform']
96
96
  hypervisors.map do |hypervisor|
97
- base_config.deep_merge! get_platform_info(bhg_version, platform, hypervisor)
97
+ base_config.deeper_merge! get_platform_info(bhg_version, platform, hypervisor)
98
98
  end
99
99
 
100
100
  base_config['hypervisor'] = @name
@@ -1,6 +1,6 @@
1
1
  require 'beaker-hostgenerator/data'
2
2
  require 'beaker-hostgenerator/hypervisor'
3
- require 'deep_merge'
3
+ require 'deep_merge/rails_compat'
4
4
 
5
5
  module BeakerHostGenerator
6
6
  module Hypervisor
@@ -20,7 +20,32 @@ module BeakerHostGenerator
20
20
  # any given platform will have *either* :vmpooler data or :abs data
21
21
  # so we're not worried about one overriding the other when we merge
22
22
  # the hashes together.
23
- return base_generate_node(node_info, base_config, bhg_version, :vmpooler, :abs)
23
+ base_config = base_generate_node(node_info, base_config, bhg_version, :vmpooler, :abs)
24
+
25
+ case node_info['ostype']
26
+ when /^centos/
27
+ base_config['template'] = base_config['platform'].gsub(/^el/, 'centos')
28
+ when /^fedora/
29
+ base_config['template'] = base_config['platform']
30
+ when /^ubuntu/
31
+ base_template = node_info['ostype'].sub('ubuntu', 'ubuntu-')
32
+ arch = case node_info['bits']
33
+ when '64'
34
+ 'x86_64'
35
+ when '32'
36
+ 'i386'
37
+ when 'AARCH64'
38
+ 'arm64'
39
+ when 'POWER'
40
+ base_template = node_info['ostype'].sub(/ubuntu(\d\d)/, 'ubuntu-\1.')
41
+ 'power8'
42
+ else
43
+ raise "Unknown bits '#{node_info['bits']}' for '#{node_info['ostype']}'"
44
+ end
45
+ base_config['template'] = "#{base_template}-#{arch}"
46
+ end
47
+
48
+ base_config
24
49
  end
25
50
  end
26
51
  end
@@ -1,6 +1,6 @@
1
1
  require 'beaker-hostgenerator/data'
2
2
  require 'beaker-hostgenerator/hypervisor'
3
- require 'deep_merge'
3
+ require 'deep_merge/rails_compat'
4
4
 
5
5
  module BeakerHostGenerator
6
6
  module Hypervisor
@@ -10,7 +10,39 @@ module BeakerHostGenerator
10
10
  def generate_node(node_info, base_config, bhg_version)
11
11
  base_config['docker_cmd'] = ['/sbin/init']
12
12
  base_config['image'] = node_info['ostype'].sub(/(\d)/, ':\1')
13
+ base_config['image'].sub!(/\w+/, 'oraclelinux') if node_info['ostype'] =~ /^oracle/
14
+ base_config['image'].sub!(/(\w+)/, '\1/leap') if node_info['ostype'] =~ /^opensuse/
13
15
  base_config['image'].sub!(/(\d{2})/, '\1.') if node_info['ostype'] =~ /^ubuntu/
16
+ if node_info['bits'] == '64'
17
+ base_config['image'] = "amd64/#{base_config['image']}"
18
+ end
19
+
20
+ docker_commands = []
21
+
22
+ case node_info['ostype']
23
+ when /^ubuntu/
24
+ docker_commands << 'cp /bin/true /sbin/agetty'
25
+
26
+ if node_info['ostype'] =~ /1404/
27
+ docker_commands << 'rm /usr/sbin/policy-rc.d'
28
+ docker_commands << 'rm /sbin/initctl; dpkg-divert --rename --remove /sbin/initctl'
29
+ end
30
+
31
+ extra_packages_to_install = case node_info['ostype']
32
+ when /1404/
33
+ ['apt-transport-https']
34
+ when /1604/
35
+ ['locales']
36
+ else
37
+ ['locales', 'iproute2', 'gnupg']
38
+ end
39
+
40
+ docker_commands << "apt-get install -y net-tools wget #{extra_packages_to_install.join(' ')}"
41
+ docker_commands << 'locale-gen en_US.UTF-8'
42
+ docker_commands << 'echo LANG=en_US.UTF-8 > /etc/default/locale'
43
+
44
+ base_config['docker_image_commands'] = docker_commands
45
+ end
14
46
 
15
47
  return base_generate_node(node_info, base_config, bhg_version, :docker)
16
48
  end
@@ -1,6 +1,6 @@
1
1
  require 'beaker-hostgenerator/hypervisor'
2
2
  require 'beaker-hostgenerator/data'
3
- require 'deep_merge'
3
+ require 'deep_merge/rails_compat'
4
4
 
5
5
  module BeakerHostGenerator::Hypervisor
6
6
  class Unknown < BeakerHostGenerator::Hypervisor::Interface
@@ -1,6 +1,6 @@
1
1
  require 'beaker-hostgenerator/data'
2
2
  require 'beaker-hostgenerator/hypervisor'
3
- require 'deep_merge'
3
+ require 'deep_merge/rails_compat'
4
4
 
5
5
  module BeakerHostGenerator
6
6
  module Hypervisor
@@ -1,6 +1,6 @@
1
1
  require 'beaker-hostgenerator/data'
2
2
  require 'beaker-hostgenerator/hypervisor'
3
- require 'deep_merge'
3
+ require 'deep_merge/rails_compat'
4
4
 
5
5
  module BeakerHostGenerator
6
6
  module Hypervisor
@@ -8,7 +8,7 @@ module BeakerHostGenerator
8
8
  include BeakerHostGenerator::Data
9
9
 
10
10
  # default global configuration keys
11
- def global_config()
11
+ def global_config
12
12
  {
13
13
  'pooling_api' => 'http://vmpooler.delivery.puppetlabs.net/'
14
14
  }
@@ -17,6 +17,24 @@ module BeakerHostGenerator
17
17
  def generate_node(node_info, base_config, bhg_version)
18
18
  base_config = base_generate_node(node_info, base_config, bhg_version, :vmpooler)
19
19
 
20
+ case node_info['ostype']
21
+ when /^centos/
22
+ base_config['template'] = base_config['platform'].gsub(/^el/, 'centos')
23
+ when /^fedora/
24
+ base_config['template'] = base_config['platform']
25
+ when /^ubuntu/
26
+ arch = case node_info['bits']
27
+ when '64'
28
+ 'x86_64'
29
+ when '32'
30
+ 'i386'
31
+ else
32
+ nil
33
+ end
34
+
35
+ base_config['template'] = "#{node_info['ostype'].sub('ubuntu', 'ubuntu-')}-#{arch}" if arch
36
+ end
37
+
20
38
  # Some vmpooler/vsphere platforms have special requirements.
21
39
  # We munge the node host config here if that is necessary.
22
40
  fixup_node base_config
@@ -1,6 +1,6 @@
1
1
  require 'beaker-hostgenerator/data'
2
2
  require 'beaker-hostgenerator/exceptions'
3
- require 'uri'
3
+ require 'cgi'
4
4
 
5
5
  module BeakerHostGenerator
6
6
  # Functions for parsing the raw user input host layout string and turning
@@ -75,7 +75,7 @@ module BeakerHostGenerator
75
75
  # @returns [String] Input string with transformations necessary for
76
76
  # tokenization.
77
77
  def prepare(spec)
78
- URI.decode(spec)
78
+ CGI.unescape(spec)
79
79
  end
80
80
 
81
81
  # Breaks apart the host input string into chunks suitable for processing
@@ -260,7 +260,7 @@ module BeakerHostGenerator
260
260
  current_depth = current_depth.pred
261
261
  next
262
262
  end
263
-
263
+
264
264
  # When there is assignment happening, we need to create a new
265
265
  # corresponding data structure, add it to the object depth, and
266
266
  # then change the current depth
@@ -1,7 +1,7 @@
1
1
  require 'beaker-hostgenerator/data'
2
2
  require 'beaker-hostgenerator/roles'
3
3
  require 'beaker-hostgenerator/hypervisor/vmpooler'
4
- require 'deep_merge'
4
+ require 'deep_merge/rails_compat'
5
5
 
6
6
  module BeakerHostGenerator
7
7
  module Utils
@@ -18,8 +18,8 @@ module BeakerHostGenerator
18
18
  def dump_hosts(hosts, path)
19
19
  vmpooler_hypervisor = BeakerHostGenerator::Hypervisor::Vmpooler.new
20
20
  config = {}
21
- config.deep_merge! BeakerHostGenerator::Data.BASE_CONFIG
22
- config['CONFIG'].deep_merge! vmpooler_hypervisor.global_config()
21
+ config.deeper_merge! BeakerHostGenerator::Data.BASE_CONFIG
22
+ config['CONFIG'].deeper_merge! vmpooler_hypervisor.global_config()
23
23
 
24
24
  hosts.each do |host|
25
25
  config['HOSTS'][host.node_name] = {
@@ -1,5 +1,5 @@
1
1
  module BeakerHostGenerator
2
2
  module Version
3
- STRING = '1.2.10'
3
+ STRING = '1.6.0'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beaker-hostgenerator
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.10
4
+ version: 1.6.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Branan Purvine-Riley
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2020-11-20 00:00:00.000000000 Z
13
+ date: 2021-08-17 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: minitest
@@ -58,36 +58,36 @@ dependencies:
58
58
  name: fakefs
59
59
  requirement: !ruby/object:Gem::Requirement
60
60
  requirements:
61
- - - "~>"
61
+ - - ">="
62
62
  - !ruby/object:Gem::Version
63
63
  version: '0.6'
64
64
  - - "<"
65
65
  - !ruby/object:Gem::Version
66
- version: 0.14.0
66
+ version: '2.0'
67
67
  type: :development
68
68
  prerelease: false
69
69
  version_requirements: !ruby/object:Gem::Requirement
70
70
  requirements:
71
- - - "~>"
71
+ - - ">="
72
72
  - !ruby/object:Gem::Version
73
73
  version: '0.6'
74
74
  - - "<"
75
75
  - !ruby/object:Gem::Version
76
- version: 0.14.0
76
+ version: '2.0'
77
77
  - !ruby/object:Gem::Dependency
78
78
  name: rake
79
79
  requirement: !ruby/object:Gem::Requirement
80
80
  requirements:
81
81
  - - "~>"
82
82
  - !ruby/object:Gem::Version
83
- version: '10.1'
83
+ version: '13.0'
84
84
  type: :development
85
85
  prerelease: false
86
86
  version_requirements: !ruby/object:Gem::Requirement
87
87
  requirements:
88
88
  - - "~>"
89
89
  - !ruby/object:Gem::Version
90
- version: '10.1'
90
+ version: '13.0'
91
91
  - !ruby/object:Gem::Dependency
92
92
  name: simplecov
93
93
  requirement: !ruby/object:Gem::Requirement
@@ -185,10 +185,11 @@ extensions: []
185
185
  extra_rdoc_files: []
186
186
  files:
187
187
  - ".github/dependabot.yml"
188
+ - ".github/workflows/release.yml"
189
+ - ".github/workflows/test.yml"
188
190
  - ".gitignore"
189
191
  - ".rspec"
190
192
  - ".simplecov"
191
- - ".travis.yml"
192
193
  - CHANGELOG.md
193
194
  - CODEOWNERS
194
195
  - CONTRIBUTING.md
@@ -235,7 +236,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
235
236
  - !ruby/object:Gem::Version
236
237
  version: '0'
237
238
  requirements: []
238
- rubygems_version: 3.0.8
239
+ rubygems_version: 3.1.6
239
240
  signing_key:
240
241
  specification_version: 4
241
242
  summary: Beaker Host Generator Utility
data/.travis.yml DELETED
@@ -1,10 +0,0 @@
1
- before_install:
2
- - gem update
3
- - gem --version
4
- language: ruby
5
- script: "bundle exec rake test:spec"
6
- notifications:
7
- email: false
8
- rvm:
9
- - 2.6
10
- - 2.4