beaker-openstack 0.3.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.github/dependabot.yml +17 -0
- data/.github/workflows/release.yml +31 -0
- data/.github/workflows/test.yml +24 -0
- data/CHANGELOG.md +64 -0
- data/Gemfile +3 -20
- data/README.md +103 -8
- data/Rakefile +16 -0
- data/beaker-openstack.gemspec +9 -13
- data/lib/beaker/hypervisor/openstack.rb +135 -76
- data/lib/beaker-openstack/version.rb +1 -1
- metadata +35 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c5432c86653f848d141b7170b2f434bdd9479268956aad4dd821bfbb4f66eed7
|
4
|
+
data.tar.gz: a3e397ec1d79f453858d00e641211feaeef426f55bc95ee99ac3e5bdfcf60151
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8665d145f7d23bfcbc5fdb5bf504e333570156507b94e8bbbf5c251ca0a7eff95e4924a600dcbdb96b60f569e0068c38eea240c45553fd5738f6b420228d0979
|
7
|
+
data.tar.gz: b25f60256f8687260e3ac7f690789ebeec180d4f27fb88b06e9f8b8d0731faf7a899f38ea5e5b1f8842628e27490fbec4b2838a5c782adf678f77845b81db587
|
@@ -0,0 +1,17 @@
|
|
1
|
+
version: 2
|
2
|
+
updates:
|
3
|
+
# raise PRs for gem updates
|
4
|
+
- package-ecosystem: bundler
|
5
|
+
directory: "/"
|
6
|
+
schedule:
|
7
|
+
interval: daily
|
8
|
+
time: "13:00"
|
9
|
+
open-pull-requests-limit: 10
|
10
|
+
|
11
|
+
# Maintain dependencies for GitHub Actions
|
12
|
+
- package-ecosystem: github-actions
|
13
|
+
directory: "/"
|
14
|
+
schedule:
|
15
|
+
interval: daily
|
16
|
+
time: "13:00"
|
17
|
+
open-pull-requests-limit: 10
|
@@ -0,0 +1,31 @@
|
|
1
|
+
name: Release
|
2
|
+
|
3
|
+
on:
|
4
|
+
create:
|
5
|
+
ref_type: tag
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
release:
|
9
|
+
runs-on: ubuntu-latest
|
10
|
+
if: github.repository == 'voxpupuli/beaker-openstack'
|
11
|
+
steps:
|
12
|
+
- uses: actions/checkout@v4
|
13
|
+
- name: Install Ruby 3.0
|
14
|
+
uses: ruby/setup-ruby@v1
|
15
|
+
with:
|
16
|
+
ruby-version: '3.0'
|
17
|
+
env:
|
18
|
+
BUNDLE_WITHOUT: release
|
19
|
+
- name: Build gem
|
20
|
+
run: gem build *.gemspec
|
21
|
+
- name: Publish gem to rubygems.org
|
22
|
+
run: gem push *.gem
|
23
|
+
env:
|
24
|
+
GEM_HOST_API_KEY: '${{ secrets.RUBYGEMS_AUTH_TOKEN }}'
|
25
|
+
- name: Setup GitHub packages access
|
26
|
+
run: |
|
27
|
+
mkdir -p ~/.gem
|
28
|
+
echo ":github: Bearer ${{ secrets.GITHUB_TOKEN }}" >> ~/.gem/credentials
|
29
|
+
chmod 0600 ~/.gem/credentials
|
30
|
+
- name: Publish gem to GitHub packages
|
31
|
+
run: gem push --key github --host https://rubygems.pkg.github.com/voxpupuli *.gem
|
@@ -0,0 +1,24 @@
|
|
1
|
+
name: Test
|
2
|
+
|
3
|
+
on:
|
4
|
+
- pull_request
|
5
|
+
- push
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
test:
|
9
|
+
runs-on: ubuntu-latest
|
10
|
+
strategy:
|
11
|
+
fail-fast: false
|
12
|
+
matrix:
|
13
|
+
ruby:
|
14
|
+
- "2.7"
|
15
|
+
- "3.0"
|
16
|
+
steps:
|
17
|
+
- uses: actions/checkout@v4
|
18
|
+
- name: Install Ruby ${{ matrix.ruby }}
|
19
|
+
uses: ruby/setup-ruby@v1
|
20
|
+
with:
|
21
|
+
ruby-version: ${{ matrix.ruby }}
|
22
|
+
bundler-cache: true
|
23
|
+
- name: Run tests
|
24
|
+
run: bundle exec rake spec
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
# Changelog
|
2
|
+
|
3
|
+
All notable changes to this project will be documented in this file.
|
4
|
+
|
5
|
+
## [2.0.0](https://github.com/voxpupuli/beaker-openstack/tree/2.0.0) (2024-02-03)
|
6
|
+
|
7
|
+
[Full Changelog](https://github.com/voxpupuli/beaker-openstack/compare/1.0.0...2.0.0)
|
8
|
+
|
9
|
+
**Breaking changes:**
|
10
|
+
|
11
|
+
- Drop EoL Ruby 2.4/2.5/2.6 support [\#22](https://github.com/voxpupuli/beaker-openstack/pull/22) ([bastelfreak](https://github.com/bastelfreak))
|
12
|
+
|
13
|
+
**Implemented enhancements:**
|
14
|
+
|
15
|
+
- Add parallel instance creation opt-in option [\#20](https://github.com/voxpupuli/beaker-openstack/pull/20) ([canihavethisone](https://github.com/canihavethisone))
|
16
|
+
|
17
|
+
**Merged pull requests:**
|
18
|
+
|
19
|
+
- gemspec: Fix typo in Apache-2.0 license name [\#27](https://github.com/voxpupuli/beaker-openstack/pull/27) ([bastelfreak](https://github.com/bastelfreak))
|
20
|
+
- Apply best practices for our changelog generator [\#26](https://github.com/voxpupuli/beaker-openstack/pull/26) ([bastelfreak](https://github.com/bastelfreak))
|
21
|
+
- Cleanup Gemfile, add beaker as runtime dependency [\#24](https://github.com/voxpupuli/beaker-openstack/pull/24) ([bastelfreak](https://github.com/bastelfreak))
|
22
|
+
- dependabot: check for github actions and bundler [\#21](https://github.com/voxpupuli/beaker-openstack/pull/21) ([bastelfreak](https://github.com/bastelfreak))
|
23
|
+
- Update fakefs requirement from ~\> 1.3 to ~\> 2.4 [\#19](https://github.com/voxpupuli/beaker-openstack/pull/19) ([dependabot[bot]](https://github.com/apps/dependabot))
|
24
|
+
|
25
|
+
## [1.0.0](https://github.com/voxpupuli/beaker-openstack/tree/1.0.0) (2021-07-09)
|
26
|
+
|
27
|
+
[Full Changelog](https://github.com/voxpupuli/beaker-openstack/compare/0.3.0...1.0.0)
|
28
|
+
|
29
|
+
**Merged pull requests:**
|
30
|
+
|
31
|
+
- Cleanup README/gemspec/GitHub actions [\#13](https://github.com/voxpupuli/beaker-openstack/pull/13) ([bastelfreak](https://github.com/bastelfreak))
|
32
|
+
- Update fakefs requirement from ~\> 0.6 to ~\> 1.3 [\#11](https://github.com/voxpupuli/beaker-openstack/pull/11) ([dependabot[bot]](https://github.com/apps/dependabot))
|
33
|
+
- Add Vox Pupuli's CI bits [\#10](https://github.com/voxpupuli/beaker-openstack/pull/10) ([genebean](https://github.com/genebean))
|
34
|
+
- Add openstack\_project\_id logic etc, expand example nodeset in readme [\#9](https://github.com/voxpupuli/beaker-openstack/pull/9) ([canihavethisone](https://github.com/canihavethisone))
|
35
|
+
|
36
|
+
## [0.3.0](https://github.com/voxpupuli/beaker-openstack/tree/0.3.0) (2019-06-17)
|
37
|
+
|
38
|
+
[Full Changelog](https://github.com/voxpupuli/beaker-openstack/compare/0.2.0...0.3.0)
|
39
|
+
|
40
|
+
**Merged pull requests:**
|
41
|
+
|
42
|
+
- hypervisor/openstack: fix usage with V3 API [\#5](https://github.com/voxpupuli/beaker-openstack/pull/5) ([GiedriusS](https://github.com/GiedriusS))
|
43
|
+
- \(BKR-1509\) Hypervisor usage instructions for Beaker 4.0 [\#4](https://github.com/voxpupuli/beaker-openstack/pull/4) ([Dakta](https://github.com/Dakta))
|
44
|
+
|
45
|
+
## [0.2.0](https://github.com/voxpupuli/beaker-openstack/tree/0.2.0) (2018-01-09)
|
46
|
+
|
47
|
+
[Full Changelog](https://github.com/voxpupuli/beaker-openstack/compare/0.1.0...0.2.0)
|
48
|
+
|
49
|
+
**Merged pull requests:**
|
50
|
+
|
51
|
+
- \(BKR-1270\) Use fog-openstack instead of fog [\#3](https://github.com/voxpupuli/beaker-openstack/pull/3) ([Sharpie](https://github.com/Sharpie))
|
52
|
+
|
53
|
+
## [0.1.0](https://github.com/voxpupuli/beaker-openstack/tree/0.1.0) (2017-07-28)
|
54
|
+
|
55
|
+
[Full Changelog](https://github.com/voxpupuli/beaker-openstack/compare/9fc506a9a93f9985fb3f36132a91805026f19d79...0.1.0)
|
56
|
+
|
57
|
+
**Merged pull requests:**
|
58
|
+
|
59
|
+
- \(MAINT\) Update docs [\#2](https://github.com/voxpupuli/beaker-openstack/pull/2) ([rishijavia](https://github.com/rishijavia))
|
60
|
+
- \(MAINT\) Update env variable to correct hypervisor [\#1](https://github.com/voxpupuli/beaker-openstack/pull/1) ([rishijavia](https://github.com/rishijavia))
|
61
|
+
|
62
|
+
|
63
|
+
|
64
|
+
\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*
|
data/Gemfile
CHANGED
@@ -2,24 +2,7 @@ source ENV['GEM_SOURCE'] || "https://rubygems.org"
|
|
2
2
|
|
3
3
|
gemspec
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
elsif place =~ /^file:\/\/(.*)/
|
9
|
-
['>= 0', { :path => File.expand_path($1), :require => false }]
|
10
|
-
else
|
11
|
-
[place, { :require => false }]
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
|
16
|
-
# We don't put beaker in as a test dependency because we
|
17
|
-
# don't want to create a transitive dependency
|
18
|
-
group :acceptance_testing do
|
19
|
-
gem "beaker", *location_for(ENV['BEAKER_VERSION'] || '~> 3.0')
|
20
|
-
end
|
21
|
-
|
22
|
-
|
23
|
-
if File.exists? "#{__FILE__}.local"
|
24
|
-
eval(File.read("#{__FILE__}.local"), binding)
|
5
|
+
group :release, optional: true do
|
6
|
+
gem 'faraday-retry', '~> 2.1', require: false
|
7
|
+
gem 'github_changelog_generator','~> 1.16', '>= 1.16.4', require: false
|
25
8
|
end
|
data/README.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# beaker-openstack
|
2
2
|
|
3
|
+
[![License](https://img.shields.io/github/license/voxpupuli/beaker-openstack.svg)](https://github.com/voxpupuli/beaker-openstack/blob/master/LICENSE)
|
4
|
+
[![Test](https://github.com/voxpupuli/beaker-openstack/actions/workflows/test.yml/badge.svg)](https://github.com/voxpupuli/beaker-openstack/actions/workflows/test.yml)
|
5
|
+
[![Release](https://github.com/voxpupuli/beaker-openstack/actions/workflows/release.yml/badge.svg)](https://github.com/voxpupuli/beaker-openstack/actions/workflows/release.yml)
|
6
|
+
[![RubyGem Version](https://img.shields.io/gem/v/beaker-openstack.svg)](https://rubygems.org/gems/beaker-openstack)
|
7
|
+
[![RubyGem Downloads](https://img.shields.io/gem/dt/beaker-openstack.svg)](https://rubygems.org/gems/beaker-openstack)
|
8
|
+
[![Donated by Puppet Inc](https://img.shields.io/badge/donated%20by-Puppet%20Inc-fb7047.svg)](#transfer-notice)
|
9
|
+
|
3
10
|
Beaker library to use openstack hypervisor
|
4
11
|
|
5
12
|
# How to use this wizardry
|
@@ -40,33 +47,121 @@ We run beaker's base acceptance tests with this library to see if the hypervisor
|
|
40
47
|
|
41
48
|
2. `OPENSTACK_KEY` - Path to private key that is used to SSH into Openstack VMs
|
42
49
|
|
43
|
-
You will need two hosts
|
50
|
+
You will need at least two hosts defined in a nodeset file. An example comprehensive nodeset is below (note that not all parameters are required):
|
44
51
|
|
45
52
|
```yaml
|
53
|
+
|
46
54
|
HOSTS:
|
47
|
-
|
55
|
+
master:
|
56
|
+
roles:
|
57
|
+
- agent
|
58
|
+
- master
|
59
|
+
- dashboard
|
60
|
+
- database
|
48
61
|
hypervisor: openstack
|
49
62
|
platform: <my_platform>
|
50
63
|
user: <host_username>
|
51
64
|
image: <host_image>
|
65
|
+
flavor: <host_flavor>
|
66
|
+
ssh:
|
67
|
+
user: cloud-user
|
68
|
+
password: <cloud-user_password>
|
69
|
+
auth_methods:
|
70
|
+
- password
|
71
|
+
- publickey
|
72
|
+
keys:
|
73
|
+
- <relative_path/public_key>
|
74
|
+
user_data: |
|
75
|
+
#cloud-config
|
76
|
+
output: {all: '| tee -a /var/log/cloud-init-output.log'}
|
77
|
+
disable_root: <True/False>
|
78
|
+
ssh_pwauth: <True/False>
|
79
|
+
chpasswd:
|
80
|
+
list: |
|
81
|
+
root:<root_password>
|
82
|
+
cloud-user:<cloud-user_password>
|
83
|
+
expire: False
|
84
|
+
runcmd:
|
85
|
+
- <my_optional_commands>
|
86
|
+
|
87
|
+
agent_1:
|
52
88
|
roles:
|
53
89
|
- agent
|
54
|
-
- master
|
55
|
-
- dashboard
|
56
|
-
- database
|
57
90
|
- default
|
58
|
-
host-2:
|
59
91
|
hypervisor: openstack
|
60
92
|
platform: <my_platform>
|
61
93
|
user: <host_username>
|
62
94
|
image: <host_image>
|
63
|
-
|
64
|
-
|
95
|
+
flavor: <host_flavor>
|
96
|
+
ssh:
|
97
|
+
user: cloud-user
|
98
|
+
password: <cloud-user_password>
|
99
|
+
auth_methods:
|
100
|
+
- publickey
|
101
|
+
keys:
|
102
|
+
- <relative_path/public_key>
|
103
|
+
number_of_password_prompts: 0
|
104
|
+
keepalive: true
|
105
|
+
keepalive_interval: 5
|
106
|
+
user_data: |
|
107
|
+
#cloud-config
|
108
|
+
output: {all: '| tee -a /var/log/cloud-init-output.log'}
|
109
|
+
disable_root: <True/False>
|
110
|
+
ssh_pwauth: <True/False>
|
111
|
+
chpasswd:
|
112
|
+
list: |
|
113
|
+
root:<root_password>
|
114
|
+
cloud-user:<cloud-user_password>
|
115
|
+
expire: False
|
116
|
+
runcmd:
|
117
|
+
- <my_optional_commands>
|
118
|
+
|
65
119
|
CONFIG:
|
120
|
+
log_level: <trace/debug/verbose/info/notify/warn>
|
121
|
+
trace_limit: 50
|
122
|
+
timesync: <true/false>
|
66
123
|
nfs_server: none
|
67
124
|
consoleport: 443
|
125
|
+
openstack_username: <insert_username>
|
126
|
+
openstack_api_key: <insert_password>
|
127
|
+
# openstack_project_name: <insert_project_name> # alternatively use openstack_project_id
|
128
|
+
openstack_project_id: <insert_id>
|
129
|
+
# openstack_user_domain: <insert user_domain> # alternatively use openstack_user_domain_id
|
130
|
+
openstack_user_domain_id: <insert_id>
|
131
|
+
# openstack_project_domain: <insert_project_domain> # alternatively use openstack_project_domain_id
|
132
|
+
openstack_project_domain_id: <insert_id>
|
133
|
+
openstack_auth_url: http://<keystone_ip>:5000/v3/
|
134
|
+
openstack_network: <insert_network>
|
135
|
+
openstack_keyname: <insert_key>
|
136
|
+
openstack_floating_ip: <true/false>
|
137
|
+
openstack_volume_support: <true/false>
|
138
|
+
security_group: ['default']
|
139
|
+
preserve_hosts: <always/onfail/onpass/never>
|
140
|
+
create_in_parallel: true
|
141
|
+
run_in_parallel: ['configure', 'install']
|
142
|
+
type: <foss/git/pe>
|
143
|
+
```
|
144
|
+
|
145
|
+
Note that when using _id parameters, you must also match the parameter type across the following when domain is specified:
|
146
|
+
- openstack_project_id
|
147
|
+
- openstack_user_domain_id
|
148
|
+
- openstack_project_domain_id
|
149
|
+
|
150
|
+
Further, you can opt to use a static master by setting the master's hypervisor to none, and identifying its location thus:
|
151
|
+
```yaml
|
152
|
+
hypervisor: none
|
153
|
+
hostname: <master_hostname>
|
154
|
+
vmhostname: <master_hostname>
|
155
|
+
ip: <master_ip>
|
68
156
|
```
|
69
157
|
|
158
|
+
Additionally, you can set instance creation to occur in parallel instead of sequentially via this CONFIG entry:
|
159
|
+
```yaml
|
160
|
+
create_in_parallel: true
|
161
|
+
```
|
162
|
+
|
163
|
+
Additional parameter information is available at https://github.com/voxpupuli/beaker/blob/master/docs/concepts/argument_processing_and_precedence.md
|
164
|
+
|
70
165
|
There is a simple rake task to invoke acceptance test for the library once the two environment variables are set:
|
71
166
|
```bash
|
72
167
|
bundle exec rake test:acceptance
|
data/Rakefile
CHANGED
@@ -58,6 +58,7 @@ task 'test:acceptance' => 'test:acceptance:quick'
|
|
58
58
|
# global defaults
|
59
59
|
task :test => 'test:spec'
|
60
60
|
task :default => :test
|
61
|
+
task :spec => 'test:spec'
|
61
62
|
|
62
63
|
###########################################################
|
63
64
|
#
|
@@ -164,3 +165,18 @@ namespace :docs do
|
|
164
165
|
end
|
165
166
|
end
|
166
167
|
end
|
168
|
+
|
169
|
+
begin
|
170
|
+
require 'rubygems'
|
171
|
+
require 'github_changelog_generator/task'
|
172
|
+
rescue LoadError
|
173
|
+
# github_changelog_generator is an optional group
|
174
|
+
else
|
175
|
+
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
|
176
|
+
config.header = "# Changelog\n\nAll notable changes to this project will be documented in this file."
|
177
|
+
config.exclude_labels = %w[duplicate question invalid wontfix wont-fix skip-changelog github_actions]
|
178
|
+
config.user = 'voxpupuli'
|
179
|
+
config.project = 'beaker-openstack'
|
180
|
+
config.future_release = Gem::Specification.load("#{config.project}.gemspec").version
|
181
|
+
end
|
182
|
+
end
|
data/beaker-openstack.gemspec
CHANGED
@@ -5,28 +5,25 @@ require 'beaker-openstack/version'
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = "beaker-openstack"
|
7
7
|
s.version = BeakerOpenstack::VERSION
|
8
|
-
s.authors =
|
9
|
-
s.email =
|
10
|
-
s.homepage =
|
8
|
+
s.authors = 'Vox Pupuli'
|
9
|
+
s.email = 'voxpupuli@groups.io'
|
10
|
+
s.homepage = 'https://github.com/voxpupuli/beaker-openstack'
|
11
11
|
s.summary = %q{Beaker DSL Extension Helpers!}
|
12
12
|
s.description = %q{For use for the Beaker acceptance testing tool}
|
13
|
-
s.license = '
|
13
|
+
s.license = 'Apache-2.0'
|
14
14
|
|
15
15
|
s.files = `git ls-files`.split("\n")
|
16
16
|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
17
17
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
18
|
s.require_paths = ["lib"]
|
19
19
|
|
20
|
+
s.required_ruby_version = '>= 2.7', '< 4'
|
21
|
+
|
20
22
|
# Testing dependencies
|
21
23
|
s.add_development_dependency 'rspec', '~> 3.0'
|
22
24
|
s.add_development_dependency 'rspec-its'
|
23
|
-
|
24
|
-
|
25
|
-
s.add_development_dependency 'fakefs', '~> 0.6', '< 0.14'
|
26
|
-
else
|
27
|
-
s.add_development_dependency 'fakefs', '~> 0.6'
|
28
|
-
end
|
29
|
-
s.add_development_dependency 'rake', '~> 10.1'
|
25
|
+
s.add_development_dependency 'fakefs', '~> 2.4'
|
26
|
+
s.add_development_dependency 'rake', '>= 12.3.3'
|
30
27
|
s.add_development_dependency 'simplecov'
|
31
28
|
s.add_development_dependency 'pry', '~> 0.10'
|
32
29
|
|
@@ -38,6 +35,5 @@ Gem::Specification.new do |s|
|
|
38
35
|
# Run time dependencies
|
39
36
|
s.add_runtime_dependency 'stringify-hash', '~> 0.0.0'
|
40
37
|
s.add_runtime_dependency 'fog-openstack', '~> 1.0.0'
|
41
|
-
|
38
|
+
s.add_runtime_dependency 'beaker', '~> 5.6'
|
42
39
|
end
|
43
|
-
|
@@ -14,6 +14,11 @@ module Beaker
|
|
14
14
|
#@option options [String] :openstack_auth_url The URL to access the OpenStack instance with (required)
|
15
15
|
#@option options [String] :openstack_tenant The tenant to access the OpenStack instance with (either this or openstack_project_name is required)
|
16
16
|
#@option options [String] :openstack_project_name The project name to access the OpenStack instance with (either this or openstack_tenant is required)
|
17
|
+
#@option options [String] :openstack_project_id The project id to access the OpenStack instance with (alternative to openstack_project_name)
|
18
|
+
#@option options [String] :openstack_user_domain The user domain name to access the OpenStack instance with
|
19
|
+
#@option options [String] :openstack_user_domain_id The user domain id to access the OpenStack instance with (alternative to openstack_user_domain)
|
20
|
+
#@option options [String] :openstack_project_domain The project domain to access the OpenStack instance with
|
21
|
+
#@option options [String] :openstack_project_domain_id The project domain id to access the OpenStack instance with (alternative to openstack_project_domain)
|
17
22
|
#@option options [String] :openstack_region The region that each OpenStack instance should be provisioned on (optional)
|
18
23
|
#@option options [String] :openstack_network The network that each OpenStack instance should be contacted through (required)
|
19
24
|
#@option options [Bool] :openstack_floating_ip Whether a floating IP should be allocated (required)
|
@@ -38,16 +43,25 @@ module Beaker
|
|
38
43
|
raise 'You must specify whether a floating IP (:openstack_floating_ip) should be used for OpenStack instances!' unless !@options[:openstack_floating_ip].nil?
|
39
44
|
|
40
45
|
is_v3 = @options[:openstack_auth_url].include?('/v3/')
|
41
|
-
raise 'You must specify an Openstack project name (:openstack_project_name) for OpenStack instances!' if is_v3 and !@options[:openstack_project_name]
|
42
46
|
raise 'You must specify an Openstack tenant (:openstack_tenant) for OpenStack instances!' if !is_v3 and !@options[:openstack_tenant]
|
43
|
-
raise '
|
44
|
-
raise '
|
47
|
+
raise 'You must specify an Openstack project name (:openstack_project_name) or Openstack project id (:openstack_project_id) for OpenStack instances!' if is_v3 and (!@options[:openstack_project_name] and !@options[:openstack_project_id])
|
48
|
+
raise 'You must specify either Openstack project name (:openstack_project_name) or Openstack project id (:openstack_project_id) not both!' if is_v3 and (@options[:openstack_project_name] and @options[:openstack_project_id])
|
49
|
+
raise 'You may specify either Openstack user domain (:openstack_user_domain) or Openstack user domain id (:openstack_user_domain_id) not both!' if is_v3 and (@options[:openstack_user_domain] and @options[:openstack_user_domain_id])
|
50
|
+
raise 'You may specify either Openstack project domain (:openstack_project_domain) or Openstack project domain id (:openstack_project_domain_id) not both!' if is_v3 and (@options[:openstack_project_domain] and @options[:openstack_project_domain_id])
|
51
|
+
raise 'Invalid option specified: v3 API expects :openstack_project_name or :openstack_project_id, not :openstack_tenant for OpenStack instances!' if is_v3 and @options[:openstack_tenant]
|
52
|
+
raise 'Invalid option specified: v2 API expects :openstack_tenant, not :openstack_project_name or :openstack_project_id for OpenStack instances!' if !is_v3 and (@options[:openstack_project_name] or @options[:openstack_project_id])
|
53
|
+
# Ensure that _id and non _id params are not mixed (due to bug in fog-openstack)
|
54
|
+
raise 'You must not mix _id values non _id (name) values. Please use the same type for (:openstack_project_), (:openstack_user_domain) and (:openstack_project_domain)!' if is_v3 and (@options[:openstack_project_name] or @options[:openstack_user_domain] or @options[:openstack_project_domain]) and (@options[:openstack_project_id] or @options[:openstack_user_domain_id] or @options[:openstack_project_domain_id])
|
45
55
|
|
46
56
|
# Keystone version 3 changed the parameter names
|
47
57
|
if !is_v3
|
48
58
|
extra_credentials = {:openstack_tenant => @options[:openstack_tenant]}
|
49
59
|
else
|
50
|
-
|
60
|
+
if @options[:openstack_project_id]
|
61
|
+
extra_credentials = {:openstack_project_id => @options[:openstack_project_id]}
|
62
|
+
else
|
63
|
+
extra_credentials = {:openstack_project_name => @options[:openstack_project_name]}
|
64
|
+
end
|
51
65
|
end
|
52
66
|
|
53
67
|
# Common keystone authentication credentials
|
@@ -62,8 +76,16 @@ module Beaker
|
|
62
76
|
|
63
77
|
# Keystone version 3 requires users and projects to be scoped
|
64
78
|
if is_v3
|
65
|
-
|
66
|
-
|
79
|
+
if @options[:openstack_user_domain_id]
|
80
|
+
@credentials[:openstack_user_domain_id] = @options[:openstack_user_domain_id]
|
81
|
+
else
|
82
|
+
@credentials[:openstack_user_domain] = @options[:openstack_user_domain] || 'Default'
|
83
|
+
end
|
84
|
+
if @options[:openstack_project_domain_id]
|
85
|
+
@credentials[:openstack_project_domain_id] = @options[:openstack_project_domain_id]
|
86
|
+
else
|
87
|
+
@credentials[:openstack_project_domain] = @options[:openstack_project_domain] || 'Default'
|
88
|
+
end
|
67
89
|
end
|
68
90
|
|
69
91
|
@compute_client ||= Fog::Compute.new(@credentials)
|
@@ -228,86 +250,123 @@ module Beaker
|
|
228
250
|
ip
|
229
251
|
end
|
230
252
|
|
231
|
-
#Create new instances in OpenStack
|
253
|
+
# Create new instances in OpenStack, depending on if create_in_parallel is true or not
|
232
254
|
def provision
|
233
|
-
@
|
234
|
-
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
create_or_associate_keypair(host, hostname)
|
246
|
-
@logger.debug "Provisioning #{host.name} (#{host[:vmhostname]})"
|
247
|
-
options = {
|
248
|
-
:flavor_ref => flavor(host[:flavor]).id,
|
249
|
-
:image_ref => image(host[:image]).id,
|
250
|
-
:nics => [ {'net_id' => network(@options[:openstack_network]).id } ],
|
251
|
-
:name => host[:vmhostname],
|
252
|
-
:hostname => host[:vmhostname],
|
253
|
-
:user_data => host[:user_data] || "#cloud-config\nmanage_etc_hosts: true\n",
|
254
|
-
:key_name => host[:keyname],
|
255
|
-
}
|
256
|
-
options[:security_groups] = security_groups(@options[:security_group]) unless @options[:security_group].nil?
|
257
|
-
vm = @compute_client.servers.create(options)
|
258
|
-
|
259
|
-
#wait for the new instance to start up
|
260
|
-
try = 1
|
261
|
-
attempts = @options[:timeout].to_i / SLEEPWAIT
|
262
|
-
|
263
|
-
while try <= attempts
|
264
|
-
begin
|
265
|
-
vm.wait_for(5) { ready? }
|
266
|
-
break
|
267
|
-
rescue Fog::Errors::TimeoutError => e
|
268
|
-
if try >= attempts
|
269
|
-
@logger.debug "Failed to connect to new OpenStack instance #{host.name} (#{host[:vmhostname]})"
|
270
|
-
raise e
|
271
|
-
end
|
272
|
-
@logger.debug "Timeout connecting to instance #{host.name} (#{host[:vmhostname]}), trying again..."
|
273
|
-
end
|
274
|
-
sleep SLEEPWAIT
|
275
|
-
try += 1
|
276
|
-
end
|
255
|
+
if @options[:create_in_parallel]
|
256
|
+
# Enable abort on exception for threads
|
257
|
+
Thread.abort_on_exception = true
|
258
|
+
@logger.notify "Provisioning OpenStack in parallel"
|
259
|
+
provision_parallel
|
260
|
+
else
|
261
|
+
@logger.notify "Provisioning OpenStack sequentially"
|
262
|
+
provision_sequential
|
263
|
+
end
|
264
|
+
hack_etc_hosts @hosts, @options
|
265
|
+
end
|
277
266
|
|
278
|
-
|
279
|
-
|
280
|
-
|
281
|
-
|
282
|
-
|
283
|
-
|
284
|
-
# OpenStack UI
|
285
|
-
host[:ip] = vm.addresses.first[1][0]["addr"]
|
267
|
+
# Parallel creation wrapper
|
268
|
+
def provision_parallel
|
269
|
+
# Array to store threads
|
270
|
+
threads = @hosts.map do |host|
|
271
|
+
Thread.new do
|
272
|
+
create_instance_resources(host)
|
286
273
|
end
|
274
|
+
end
|
275
|
+
# Wait for all threads to finish
|
276
|
+
threads.each(&:join)
|
277
|
+
end
|
287
278
|
|
288
|
-
|
289
|
-
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
@vms << vm
|
295
|
-
|
296
|
-
# Wait for the host to accept ssh logins
|
297
|
-
host.wait_for_port(22)
|
279
|
+
# Sequential creation wrapper
|
280
|
+
def provision_sequential
|
281
|
+
@hosts.each do |host|
|
282
|
+
create_instance_resources(host)
|
283
|
+
end
|
284
|
+
end
|
298
285
|
|
299
|
-
|
300
|
-
|
286
|
+
# Create the actual instance resources
|
287
|
+
def create_instance_resources(host)
|
288
|
+
@logger.notify "Provisioning OpenStack"
|
289
|
+
if @options[:openstack_floating_ip]
|
290
|
+
ip = get_floating_ip
|
291
|
+
hostname = ip.ip.gsub('.', '-')
|
292
|
+
host[:vmhostname] = hostname + '.rfc1918.puppetlabs.net'
|
293
|
+
else
|
294
|
+
hostname = ('a'..'z').to_a.shuffle[0, 10].join
|
295
|
+
host[:vmhostname] = hostname
|
296
|
+
end
|
301
297
|
|
302
|
-
|
303
|
-
|
298
|
+
create_or_associate_keypair(host, hostname)
|
299
|
+
@logger.debug "Provisioning #{host.name} (#{host[:vmhostname]})"
|
300
|
+
options = {
|
301
|
+
:flavor_ref => flavor(host[:flavor]).id,
|
302
|
+
:image_ref => image(host[:image]).id,
|
303
|
+
:nics => [{'net_id' => network(@options[:openstack_network]).id}],
|
304
|
+
:name => host[:vmhostname],
|
305
|
+
:hostname => host[:vmhostname],
|
306
|
+
:user_data => host[:user_data] || "#cloud-config\nmanage_etc_hosts: true\n",
|
307
|
+
:key_name => host[:keyname],
|
308
|
+
}
|
309
|
+
options[:security_groups] = security_groups(@options[:security_group]) unless @options[:security_group].nil?
|
310
|
+
vm = @compute_client.servers.create(options)
|
311
|
+
|
312
|
+
# Wait for the new instance to start up
|
313
|
+
try = 1
|
314
|
+
attempts = @options[:timeout].to_i / SLEEPWAIT
|
315
|
+
|
316
|
+
while try <= attempts
|
317
|
+
begin
|
318
|
+
vm.wait_for(5) { ready? }
|
319
|
+
break
|
320
|
+
rescue Fog::Errors::TimeoutError => e
|
321
|
+
if try >= attempts
|
322
|
+
@logger.debug "Failed to connect to new OpenStack instance #{host.name} (#{host[:vmhostname]})"
|
323
|
+
raise e
|
324
|
+
end
|
325
|
+
@logger.debug "Timeout connecting to instance #{host.name} (#{host[:vmhostname]}), trying again..."
|
326
|
+
end
|
327
|
+
sleep SLEEPWAIT
|
328
|
+
try += 1
|
304
329
|
end
|
305
330
|
|
306
|
-
|
331
|
+
if @options[:openstack_floating_ip]
|
332
|
+
# Associate a public IP to the VM
|
333
|
+
ip.server = vm
|
334
|
+
host[:ip] = ip.ip
|
335
|
+
else
|
336
|
+
# Get the first address of the VM that was just created just like in the
|
337
|
+
# OpenStack UI
|
338
|
+
host[:ip] = vm.addresses.first[1][0]["addr"]
|
339
|
+
end
|
307
340
|
|
341
|
+
@logger.debug "OpenStack host #{host.name} (#{host[:vmhostname]}) assigned ip: #{host[:ip]}"
|
342
|
+
|
343
|
+
# Set metadata
|
344
|
+
vm.metadata.update({:jenkins_build_url => @options[:jenkins_build_url].to_s,
|
345
|
+
:department => @options[:department].to_s,
|
346
|
+
:project => @options[:project].to_s })
|
347
|
+
@vms << vm
|
348
|
+
|
349
|
+
# Wait for the host to accept SSH logins
|
350
|
+
host.wait_for_port(22)
|
351
|
+
|
352
|
+
# Enable root if the user is not root
|
353
|
+
enable_root(host)
|
354
|
+
|
355
|
+
provision_storage(host, vm) if @options[:openstack_volume_support]
|
356
|
+
@logger.notify "OpenStack Volume Support Disabled, can't provision volumes" if not @options[:openstack_volume_support]
|
357
|
+
|
358
|
+
# Handle exceptions in the thread
|
359
|
+
rescue => e
|
360
|
+
@logger.error "Thread #{host} failed with error: #{e.message}"
|
361
|
+
# Call cleanup function to delete orphaned hosts
|
362
|
+
cleanup
|
363
|
+
# Pass the error to the main thread to terminate all threads
|
364
|
+
Thread.main.raise(e)
|
365
|
+
# Terminate the current thread (to prevent hack_etc_hosts trying to run after error raised)
|
366
|
+
Thread.kill(Thread.current)
|
308
367
|
end
|
309
368
|
|
310
|
-
#Destroy any OpenStack instances
|
369
|
+
# Destroy any OpenStack instances
|
311
370
|
def cleanup
|
312
371
|
@logger.notify "Cleaning up OpenStack"
|
313
372
|
@vms.each do |vm|
|
@@ -339,7 +398,7 @@ module Beaker
|
|
339
398
|
end
|
340
399
|
end
|
341
400
|
|
342
|
-
#
|
401
|
+
# Enable root on a single host (the current one presumably) but only
|
343
402
|
# if the username isn't 'root'
|
344
403
|
def enable_root(host)
|
345
404
|
if host['user'] != 'root'
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: beaker-openstack
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 2.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Vox Pupuli
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-02-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -44,28 +44,28 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '2.4'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '2.4'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- - "
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version:
|
61
|
+
version: 12.3.3
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- - "
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version:
|
68
|
+
version: 12.3.3
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: simplecov
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -164,16 +164,33 @@ dependencies:
|
|
164
164
|
- - "~>"
|
165
165
|
- !ruby/object:Gem::Version
|
166
166
|
version: 1.0.0
|
167
|
+
- !ruby/object:Gem::Dependency
|
168
|
+
name: beaker
|
169
|
+
requirement: !ruby/object:Gem::Requirement
|
170
|
+
requirements:
|
171
|
+
- - "~>"
|
172
|
+
- !ruby/object:Gem::Version
|
173
|
+
version: '5.6'
|
174
|
+
type: :runtime
|
175
|
+
prerelease: false
|
176
|
+
version_requirements: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - "~>"
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '5.6'
|
167
181
|
description: For use for the Beaker acceptance testing tool
|
168
|
-
email:
|
169
|
-
- rishi.javia@puppet.com, kevin.imber@puppet.com, tony.vu@puppet.com
|
182
|
+
email: voxpupuli@groups.io
|
170
183
|
executables:
|
171
184
|
- beaker-openstack
|
172
185
|
extensions: []
|
173
186
|
extra_rdoc_files: []
|
174
187
|
files:
|
188
|
+
- ".github/dependabot.yml"
|
189
|
+
- ".github/workflows/release.yml"
|
190
|
+
- ".github/workflows/test.yml"
|
175
191
|
- ".gitignore"
|
176
192
|
- ".simplecov"
|
193
|
+
- CHANGELOG.md
|
177
194
|
- Gemfile
|
178
195
|
- LICENSE
|
179
196
|
- README.md
|
@@ -185,9 +202,9 @@ files:
|
|
185
202
|
- openstack.md
|
186
203
|
- spec/beaker/hypervisor/openstack_spec.rb
|
187
204
|
- spec/spec_helper.rb
|
188
|
-
homepage: https://github.com/
|
205
|
+
homepage: https://github.com/voxpupuli/beaker-openstack
|
189
206
|
licenses:
|
190
|
-
-
|
207
|
+
- Apache-2.0
|
191
208
|
metadata: {}
|
192
209
|
post_install_message:
|
193
210
|
rdoc_options: []
|
@@ -197,15 +214,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
197
214
|
requirements:
|
198
215
|
- - ">="
|
199
216
|
- !ruby/object:Gem::Version
|
200
|
-
version: '
|
217
|
+
version: '2.7'
|
218
|
+
- - "<"
|
219
|
+
- !ruby/object:Gem::Version
|
220
|
+
version: '4'
|
201
221
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
202
222
|
requirements:
|
203
223
|
- - ">="
|
204
224
|
- !ruby/object:Gem::Version
|
205
225
|
version: '0'
|
206
226
|
requirements: []
|
207
|
-
|
208
|
-
rubygems_version: 2.5.1
|
227
|
+
rubygems_version: 3.2.33
|
209
228
|
signing_key:
|
210
229
|
specification_version: 4
|
211
230
|
summary: Beaker DSL Extension Helpers!
|