beaker-abs 0.2.0 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,7 @@
1
1
  ---
2
- !binary "U0hBMQ==":
3
- metadata.gz: !binary |-
4
- ZTg4M2E4ZGUxNWQzMDM0MDFhYjlhMDY4YWFhNWI3ODk2ZGY1NDE4Ng==
5
- data.tar.gz: !binary |-
6
- ZGUwOWJhZDZmMWE1YmNkYjBhYmEzNzIwZTc4MjRjZGExZmM5OTRmNA==
2
+ SHA256:
3
+ metadata.gz: 64463104e5baa6488316a4824290f54d746e9ad36a91fad15d4e549a45d525fa
4
+ data.tar.gz: 4c957500c3726171b389eb6610b4c65e8197f984edb868e2da31f8cdf67236cb
7
5
  SHA512:
8
- metadata.gz: !binary |-
9
- NmI2YWJjOTA0ZTRkYWE4ZTE3MjVmZTBkNDBiOTIyYmNhNzk5NzVlYTIzMmYy
10
- YjVmMTYyYTBmMDBmZGZlMzg4NDg4ZDU2YTNiYzQ3NzA1NWQ2NWVhOTQxOWFk
11
- NTJmZDQ2MzVlNWVjNGYyZGVjNzZhODA5NzU2YTEyNjQ1M2VkYmI=
12
- data.tar.gz: !binary |-
13
- N2Q0MmViY2I0NmQxNGY3MGU4YjRiZmZiYzFkOTY1ZWQwNGIwNTYxNmYzMjJi
14
- OWI5MzE1NDgxOGNkZWJkNDYwYmVkYjE0N2FiMDI5NmRmNzJiODhhNWY4MDI4
15
- ZGMzZTYyY2VlZWQ1MWM2NDdmZWViZDBhNmI4NTg1MWU2ZGQ1ZDc=
6
+ metadata.gz: fc6272ea353435e50fa23c78635db4701a8fa2086ea0a44ce074e5aa95e56c16568618d84f8140d12d4bb7d4bbbe8c3f3d8f283cb315708589113c3939dcea9e
7
+ data.tar.gz: d094be28dac020761822898a028593b3f4e3c4b3de0cfcc2ea3fc7ed6c52ea508c30e18d76940e9840a50d3d7c4b1379bf15bc9d2160dbd02a37cf214882b40b
@@ -0,0 +1,8 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: bundler
4
+ directory: "/"
5
+ schedule:
6
+ interval: daily
7
+ time: "13:00"
8
+ open-pull-requests-limit: 10
@@ -1,5 +1,6 @@
1
- sudo: false
2
1
  language: ruby
3
2
  rvm:
4
- - 2.1.8
5
- before_install: gem install bundler -v 1.12.3
3
+ - 2.6
4
+ before_install:
5
+ - gem install bundler
6
+
@@ -0,0 +1 @@
1
+ * @puppetlabs/beaker
data/Gemfile CHANGED
@@ -2,3 +2,17 @@ source 'https://rubygems.org'
2
2
 
3
3
  # Specify your gem's dependencies in beaker-abs.gemspec
4
4
  gemspec
5
+
6
+ def location_for(place, fake_version = nil)
7
+ if place =~ /^(git:[^#]*)#(.*)/
8
+ [fake_version, { :git => $1, :branch => $2, :require => false }].compact
9
+ elsif place =~ /^file:\/\/(.*)/
10
+ ['>= 0', { :path => File.expand_path($1), :require => false }]
11
+ else
12
+ [place, { :require => false }]
13
+ end
14
+ end
15
+
16
+ group :testing do
17
+ gem "beaker", *location_for(ENV['BEAKER_VERSION'] || '~> 4.0')
18
+ end
data/HISTORY.md CHANGED
@@ -1,12 +1,29 @@
1
1
  # qe_beaker-abs_bump_and_tag_master - History
2
2
  ## Tags
3
- * [LATEST - 24 Oct, 2016 (4c14d730)](#LATEST)
3
+ * [LATEST - 14 Aug, 2017 (26840bd3)](#LATEST)
4
+ * [0.2.0 - 24 Oct, 2016 (44ff3935)](#0.2.0)
4
5
  * [0.1.3 - 16 Sep, 2016 (6f1ced08)](#0.1.3)
5
6
  * [0.1.2 - 16 Sep, 2016 (b914ae60)](#0.1.2)
6
7
  * [0.1.1 - 16 Sep, 2016 (10ee39cf)](#0.1.1)
7
8
 
8
9
  ## Details
9
- ### <a name = "LATEST">LATEST - 24 Oct, 2016 (4c14d730)
10
+ ### <a name = "LATEST">LATEST - 14 Aug, 2017 (26840bd3)
11
+
12
+ * (GEM) update beaker-abs version to 0.3.0 (26840bd3)
13
+
14
+ * Merge pull request #9 from rishijavia/BKR-1155-third_attempt (859cb1ec)
15
+
16
+
17
+ ```
18
+ Merge pull request #9 from rishijavia/BKR-1155-third_attempt
19
+
20
+ (BKR-1155) Override beaker's default ssh connection preference
21
+ ```
22
+ * (BKR-1155) Override beaker's default ssh connection preference (8bab8a1c)
23
+
24
+ ### <a name = "0.2.0">0.2.0 - 24 Oct, 2016 (44ff3935)
25
+
26
+ * (HISTORY) update beaker-abs history for gem release 0.2.0 (44ff3935)
10
27
 
11
28
  * (GEM) update beaker-abs version to 0.2.0 (4c14d730)
12
29
 
data/README.md CHANGED
@@ -1,22 +1,21 @@
1
- # BeakerAbs
1
+ # beaker-abs
2
2
 
3
3
  Implements a Beaker hypervisor that makes hosts provisioned by the AlwaysBeScheduling service available to a Beaker run.
4
4
 
5
5
  ## Installation
6
6
 
7
- Add this line to your application's Gemfile:
7
+ Beaker will automatically load the appropriate hypervisors for any given hosts file, so as long as your project dependencies are satisfied there's nothing else to do. No need to `require` this library in your tests.
8
8
 
9
- ```ruby
10
- gem 'beaker-abs'
11
- ```
12
-
13
- And then execute:
14
-
15
- $ bundle
9
+ As of Beaker 4.0, all hypervisor and DSL extension libraries have been removed and are no longer dependencies. In order to use a specific hypervisor or DSL extension library in your project, you will need to include them alongside Beaker in your Gemfile or project.gemspec. E.g.
16
10
 
17
- Or install it yourself as:
18
-
19
- $ gem install beaker-abs
11
+ ~~~ruby
12
+ # Gemfile
13
+ gem 'beaker', '~>4.0'
14
+ gem 'beaker-abs'
15
+ # project.gemspec
16
+ s.add_runtime_dependency 'beaker', '~>4.0'
17
+ s.add_runtime_dependency 'beaker-abs'
18
+ ~~~
20
19
 
21
20
  ## Usage
22
21
 
@@ -42,6 +41,15 @@ env ABS_RESOURCE_HOSTS=<data> beaker --hosts hosts.yaml
42
41
  ```
43
42
 
44
43
  Beaker will populate the `vmhostname` property for each host using information provided by the AlwaysBeScheduling service.
44
+ This is typically used in a CI scenario, where the jenkins run-me-maybe plugin is populating the ABS_RESOURCE_HOSTS variable.
45
+
46
+ ### Using vmfloaty
47
+
48
+ If you do not specify a ABS_RESOURCE_HOSTS and request to provision via the beaker options, beaker-abs will fallback to using
49
+ your vmfloaty configuration. By default it will look for the service named 'abs'. The name can also be configured via
50
+ the environment variable ABS_SERVICE_NAME or the top level option in the hosts file abs_service_name. Similarly, the priority defaults to "1" which means
51
+ it will take precedence over CI tests. Be careful not to run a CI test with this option. The priority can be configured via
52
+ the environment variable ABS_SERVICE_PRIORITY or the top level option in the hosts file abs_service_priority.
45
53
 
46
54
  ## Development
47
55
 
@@ -18,9 +18,10 @@ Gem::Specification.new do |spec|
18
18
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_development_dependency "bundler", "~> 1.12"
22
- spec.add_development_dependency "rake", "~> 10.0"
21
+ spec.add_dependency "beaker", "~> 4.0"
22
+ spec.add_dependency "vmfloaty", ">= 1.0", "< 1.2"
23
+ spec.add_development_dependency "bundler", "~> 2.1"
24
+ spec.add_development_dependency "rake", "~> 13.0"
23
25
  spec.add_development_dependency "minitest", "~> 5.0"
24
26
 
25
- spec.add_runtime_dependency "beaker", '>= 2.9.0', '< 4.0'
26
27
  end
@@ -1,5 +1,5 @@
1
1
  module BeakerAbs
2
2
  module Version
3
- STRING = '0.2.0'
3
+ STRING = '0.7.0'
4
4
  end
5
5
  end
@@ -1,5 +1,9 @@
1
1
  require 'beaker'
2
2
  require 'json'
3
+ require 'pry-byebug'
4
+ require 'vmfloaty'
5
+ require 'vmfloaty/conf'
6
+ require 'vmfloaty/utils'
3
7
 
4
8
  module Beaker
5
9
  class Abs < Beaker::Hypervisor
@@ -9,23 +13,54 @@ module Beaker
9
13
  @hosts = hosts
10
14
 
11
15
  resource_hosts = ENV['ABS_RESOURCE_HOSTS'] || @options[:abs_resource_hosts]
12
- raise ArgumentError.new("ABS_RESOURCE_HOSTS must be specified when using the Beaker::Abs hypervisor") if resource_hosts.nil?
16
+
17
+ @abs_service_name = ENV['ABS_SERVICE_NAME'] || @options[:abs_service_name] || "abs"
18
+ @abs_service_priority = ENV['ABS_SERVICE_PRIORITY'] || @options[:abs_service_priority] || "1"
19
+
20
+ raise ArgumentError.new("ABS_RESOURCE_HOSTS must be specified when using the Beaker::Abs hypervisor when provisioning") if resource_hosts.nil? && !options[:provision]
21
+ resource_hosts = provision_vms(hosts).to_json if resource_hosts.nil?
13
22
  @resource_hosts = JSON.parse(resource_hosts)
14
23
  end
15
24
 
25
+ def connection_preference(host)
26
+ vmhostname = host[:vmhostname]
27
+ if vmhostname && host[:hypervisor] == 'abs'
28
+ @resource_hosts.each do |resource_host|
29
+ if resource_host['hostname'] == vmhostname
30
+ engine = resource_host['engine']
31
+ case engine
32
+ when /^(vmpooler|nspooler)$/
33
+ # ABS does not set ip, do not include
34
+ # vmpooler hostname is the platform name, nspooler hostname == vmhostname
35
+ return [:vmhostname]
36
+ else
37
+ super
38
+ end
39
+ end
40
+ end
41
+ end
42
+ super
43
+ end
44
+
16
45
  def provision
17
46
  type2hosts = {}
18
47
 
19
48
  # Each resource_host is of the form:
20
49
  # {
21
- # "hostname" => "1234567890",
50
+ # "hostname" => "mkbx0m6dnnntgz1.delivery.puppetlabs.net",
22
51
  # "type" => "centos-7-i386",
23
52
  # "engine" => "vmpooler",
24
53
  # }
54
+ # {
55
+ # "hostname" => "sol10-1.delivery.puppetlabs.net",
56
+ # "type" => "solaris-10-sparc",
57
+ # "engine" => "nspooler",
58
+ # }
25
59
  @resource_hosts.each do |resource_host|
26
60
  type = resource_host['type']
27
61
  type2hosts[type] ||= []
28
62
  type2hosts[type] << resource_host['hostname']
63
+ type2hosts[type] << resource_host['ip']
29
64
  end
30
65
 
31
66
  # for each host, get a vm for that template type
@@ -36,14 +71,91 @@ module Beaker
36
71
 
37
72
  if provisioned_hosts = type2hosts[template]
38
73
  host['vmhostname'] = provisioned_hosts.shift
74
+ host['ip'] = provisioned_hosts.shift
39
75
  else
40
76
  raise ArgumentError.new("Failed to provision host '#{host.hostname}', no template of type '#{host['template']}' was provided.")
41
77
  end
42
78
  end
79
+ if Beaker::Hypervisor.respond_to?(:set_ssh_connection_preference)
80
+ Beaker::Hypervisor.set_ssh_connection_preference(@hosts, self)
81
+ end
43
82
  end
44
83
 
45
84
  def cleanup
46
85
  # nothing to do
47
86
  end
87
+
88
+ def provision_vms(hosts)
89
+
90
+ verbose = false
91
+ config = Conf.read_config # get the vmfloaty config file in home dir
92
+
93
+ # TODO: the options object provided by the floaty cli is required in get_service_config()
94
+ # we should make it optional or accept nil
95
+ cli = Object.new
96
+ def cli.service() @abs_service_name end
97
+ def cli.priority() @abs_service_priority end # forces going ahead of queue
98
+ def cli.url() nil end
99
+ def cli.token() nil end
100
+ def cli.user() nil end
101
+
102
+ #the service object is the interfacte to all methods
103
+ abs_service = Service.new(cli, config)
104
+ supported_vm_list = abs_service.list(verbose)
105
+ supported_vm_list = supported_vm_list.reject { |e| e.empty? }
106
+ supported_vm_list = supported_vm_list.reject { |e| e.start_with?("*") }
107
+
108
+ vm_request = generate_floaty_request_strings(hosts, supported_vm_list)
109
+
110
+
111
+ vm_beaker_abs = []
112
+ # Will return a JSON Object like this:
113
+ # {"redhat-7-x86_64"=>["rich-apparition.delivery.puppetlabs.net", "despondent-side.delivery.puppetlabs.net"], "centos-7-x86_64"=>["firmer-vamp.delivery.puppetlabs.net"]}
114
+ os_types = Utils.generate_os_hash(vm_request.split)
115
+ vm_floaty_output = abs_service.retrieve(verbose, os_types)
116
+
117
+
118
+ raise ArgumentError.new("Timed out getting the ABS resources") if vm_floaty_output.nil?
119
+ vm_floaty_output_cleaned = Utils.standardize_hostnames(vm_floaty_output)
120
+ vm_floaty_output_cleaned.each do |os_platform, value|
121
+ # filter any extra key that does not have an Array value
122
+ if !value.is_a?(Array)
123
+ next
124
+ end
125
+ value.each do | hostname |
126
+ # I don't think the engine is being used by the beaker-abs process
127
+ vm_beaker_abs.push({"hostname": hostname, "type": os_platform, "engine":"beaker-abs"})
128
+ end
129
+ end
130
+
131
+ # to do need to figure out what the NSPooler requests are, and combine the output for that with vm_beaker_abs and return that object
132
+ # for now just returning vmpooler abs object
133
+ vm_beaker_abs
134
+ end
135
+
136
+ # Based upon the host file, this method counts the number of each template needed
137
+ # and generates the host=Xnum eg redhat-7-x86_64=2 expected by floaty
138
+ def generate_floaty_request_strings(hosts, supported_vm_list)
139
+ vm_list = {}
140
+
141
+ hosts.each do |host|
142
+ if supported_vm_list.include?(host[:template])
143
+ if vm_list.include?(host[:template])
144
+ vm_list[host[:template]] = vm_list[host[:template]] + 1
145
+ else
146
+ vm_list[host[:template]] = 1
147
+ end
148
+ else
149
+ raise ArgumentError.new("#{host.name} has a template #{host[:template]} that is not found in vmpooler or nspooler")
150
+ end
151
+ end
152
+
153
+ vm_request = ""
154
+ vm_list.each do |key, value|
155
+ vm_request.concat("#{key}=#{value} ")
156
+ end
157
+
158
+ vm_request
159
+ end
48
160
  end
49
161
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: beaker-abs
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.7.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Josh Cooper
@@ -9,70 +9,84 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2016-10-24 00:00:00.000000000 Z
12
+ date: 2020-12-10 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: bundler
15
+ name: beaker
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ~>
18
+ - - "~>"
19
19
  - !ruby/object:Gem::Version
20
- version: '1.12'
21
- type: :development
20
+ version: '4.0'
21
+ type: :runtime
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - ~>
25
+ - - "~>"
26
26
  - !ruby/object:Gem::Version
27
- version: '1.12'
27
+ version: '4.0'
28
28
  - !ruby/object:Gem::Dependency
29
- name: rake
29
+ name: vmfloaty
30
30
  requirement: !ruby/object:Gem::Requirement
31
31
  requirements:
32
- - - ~>
32
+ - - ">="
33
33
  - !ruby/object:Gem::Version
34
- version: '10.0'
35
- type: :development
34
+ version: '1.0'
35
+ - - "<"
36
+ - !ruby/object:Gem::Version
37
+ version: '1.2'
38
+ type: :runtime
36
39
  prerelease: false
37
40
  version_requirements: !ruby/object:Gem::Requirement
38
41
  requirements:
39
- - - ~>
42
+ - - ">="
43
+ - !ruby/object:Gem::Version
44
+ version: '1.0'
45
+ - - "<"
40
46
  - !ruby/object:Gem::Version
41
- version: '10.0'
47
+ version: '1.2'
42
48
  - !ruby/object:Gem::Dependency
43
- name: minitest
49
+ name: bundler
44
50
  requirement: !ruby/object:Gem::Requirement
45
51
  requirements:
46
- - - ~>
52
+ - - "~>"
47
53
  - !ruby/object:Gem::Version
48
- version: '5.0'
54
+ version: '2.1'
49
55
  type: :development
50
56
  prerelease: false
51
57
  version_requirements: !ruby/object:Gem::Requirement
52
58
  requirements:
53
- - - ~>
59
+ - - "~>"
54
60
  - !ruby/object:Gem::Version
55
- version: '5.0'
61
+ version: '2.1'
56
62
  - !ruby/object:Gem::Dependency
57
- name: beaker
63
+ name: rake
58
64
  requirement: !ruby/object:Gem::Requirement
59
65
  requirements:
60
- - - ! '>='
66
+ - - "~>"
61
67
  - !ruby/object:Gem::Version
62
- version: 2.9.0
63
- - - <
64
- - !ruby/object:Gem::Version
65
- version: '4.0'
66
- type: :runtime
68
+ version: '13.0'
69
+ type: :development
67
70
  prerelease: false
68
71
  version_requirements: !ruby/object:Gem::Requirement
69
72
  requirements:
70
- - - ! '>='
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '13.0'
76
+ - !ruby/object:Gem::Dependency
77
+ name: minitest
78
+ requirement: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
71
81
  - !ruby/object:Gem::Version
72
- version: 2.9.0
73
- - - <
82
+ version: '5.0'
83
+ type: :development
84
+ prerelease: false
85
+ version_requirements: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
74
88
  - !ruby/object:Gem::Version
75
- version: '4.0'
89
+ version: '5.0'
76
90
  description: Adds a custom hypervisor that uses hosts provisioned by the Always Be
77
91
  Scheduling service.
78
92
  email:
@@ -82,12 +96,13 @@ executables: []
82
96
  extensions: []
83
97
  extra_rdoc_files: []
84
98
  files:
85
- - .gitignore
86
- - .travis.yml
99
+ - ".github/dependabot.yml"
100
+ - ".gitignore"
101
+ - ".travis.yml"
102
+ - CODEOWNERS
87
103
  - Gemfile
88
104
  - HISTORY.md
89
105
  - LICENSE.txt
90
- - MAINTAINERS
91
106
  - README.md
92
107
  - Rakefile
93
108
  - beaker-abs.gemspec
@@ -104,17 +119,16 @@ require_paths:
104
119
  - lib
105
120
  required_ruby_version: !ruby/object:Gem::Requirement
106
121
  requirements:
107
- - - ! '>='
122
+ - - ">="
108
123
  - !ruby/object:Gem::Version
109
124
  version: '0'
110
125
  required_rubygems_version: !ruby/object:Gem::Requirement
111
126
  requirements:
112
- - - ! '>='
127
+ - - ">="
113
128
  - !ruby/object:Gem::Version
114
129
  version: '0'
115
130
  requirements: []
116
- rubyforge_project:
117
- rubygems_version: 2.4.6
131
+ rubygems_version: 3.0.8
118
132
  signing_key:
119
133
  specification_version: 4
120
134
  summary: Let's test Puppet, using hosts provisioned by Always Be Scheduling service.
@@ -1,17 +0,0 @@
1
- {
2
- "version": 1,
3
- "file_format": "This MAINTAINERS file format is described at http://pup.pt/maintainers",
4
- "issues": "https://tickets.puppetlabs.com/browse/QENG/",
5
- "people": [
6
- {
7
- "github": "joshcooper",
8
- "email": "josh@puppet.com",
9
- "name": "Josh Cooper"
10
- },
11
- {
12
- "github": "rick",
13
- "email": "rick@puppet.com",
14
- "name": "Rick Bradley"
15
- }
16
- ]
17
- }