Compare commits

...

243 commits
0.11.1 ... main

Author SHA1 Message Date
puppet-release-bot
6b6d6f73cd
Merge pull request #242 from puppetlabs/dependabot/docker/ruby-3.3.5-slim-bullseye
Bump ruby from 3.3.4-slim-bullseye to 3.3.5-slim-bullseye
2024-09-09 05:57:47 -04:00
dependabot[bot]
b2fd9313f8
Bump ruby from 3.3.4-slim-bullseye to 3.3.5-slim-bullseye
Bumps ruby from 3.3.4-slim-bullseye to 3.3.5-slim-bullseye.

---
updated-dependencies:
- dependency-name: ruby
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-09-09 09:56:48 +00:00
puppet-release-bot
41d55e44b8
Merge pull request #241 from puppetlabs/dependabot/bundler/simplecov-html-0.13.1
Bump simplecov-html from 0.12.3 to 0.13.1
2024-09-09 05:53:50 -04:00
puppet-release-bot
fa92cad278
Merge pull request #240 from puppetlabs/dependabot/bundler/rubocop-1.66.1
Bump rubocop from 1.66.0 to 1.66.1
2024-09-09 05:53:32 -04:00
dependabot[bot]
8df6ceb676
Bump simplecov-html from 0.12.3 to 0.13.1
Bumps [simplecov-html](https://github.com/simplecov-ruby/simplecov-html) from 0.12.3 to 0.13.1.
- [Release notes](https://github.com/simplecov-ruby/simplecov-html/releases)
- [Changelog](https://github.com/simplecov-ruby/simplecov-html/blob/main/CHANGELOG.md)
- [Commits](https://github.com/simplecov-ruby/simplecov-html/compare/v0.12.3...v0.13.1)

---
updated-dependencies:
- dependency-name: simplecov-html
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-09-09 09:52:53 +00:00
dependabot[bot]
197c6e2e60
Bump rubocop from 1.66.0 to 1.66.1
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.66.0 to 1.66.1.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.66.0...v1.66.1)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-09-09 09:52:46 +00:00
puppet-release-bot
d6f1eeddc6
Merge pull request #239 from puppetlabs/dependabot/bundler/rubocop-1.66.0
Bump rubocop from 1.65.1 to 1.66.0
2024-09-02 05:25:16 -04:00
dependabot[bot]
721881395c
Bump rubocop from 1.65.1 to 1.66.0
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.65.1 to 1.66.0.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.65.1...v1.66.0)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-09-02 09:24:28 +00:00
puppet-release-bot
6a46261844
Merge pull request #237 from puppetlabs/dependabot/bundler/rubocop-1.65.1
Bump rubocop from 1.64.1 to 1.65.1
2024-08-01 22:00:17 -04:00
dependabot[bot]
d26bac7409
Bump rubocop from 1.64.1 to 1.65.1
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.64.1 to 1.65.1.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.64.1...v1.65.1)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-08-02 01:59:32 +00:00
puppet-release-bot
f0195ee4db
Merge pull request #236 from puppetlabs/dependabot/bundler/rexml-3.3.3
Bump rexml from 3.2.8 to 3.3.3
2024-08-01 21:58:17 -04:00
dependabot[bot]
82f522e911
Bump rexml from 3.2.8 to 3.3.3
Bumps [rexml](https://github.com/ruby/rexml) from 3.2.8 to 3.3.3.
- [Release notes](https://github.com/ruby/rexml/releases)
- [Changelog](https://github.com/ruby/rexml/blob/master/NEWS.md)
- [Commits](https://github.com/ruby/rexml/compare/v3.2.8...v3.3.3)

---
updated-dependencies:
- dependency-name: rexml
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-08-02 01:57:30 +00:00
puppet-release-bot
d46b7f10ef
Merge pull request #235 from puppetlabs/dependabot/docker/ruby-3.3.4-slim-bullseye
Bump ruby from 3.3.3-slim-bullseye to 3.3.4-slim-bullseye
2024-07-15 05:40:42 -04:00
dependabot[bot]
e4151a00ce
Bump ruby from 3.3.3-slim-bullseye to 3.3.4-slim-bullseye
Bumps ruby from 3.3.3-slim-bullseye to 3.3.4-slim-bullseye.

---
updated-dependencies:
- dependency-name: ruby
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-07-15 09:39:58 +00:00
puppet-release-bot
bea7434436
Merge pull request #232 from puppetlabs/dependabot/docker/ruby-3.3.3-slim-bullseye
Bump ruby from 3.3.2-slim-bullseye to 3.3.3-slim-bullseye
2024-06-17 05:59:27 -04:00
dependabot[bot]
58ddd50618
Bump ruby from 3.3.2-slim-bullseye to 3.3.3-slim-bullseye
Bumps ruby from 3.3.2-slim-bullseye to 3.3.3-slim-bullseye.

---
updated-dependencies:
- dependency-name: ruby
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-17 09:58:43 +00:00
puppet-release-bot
6285e2c854
Merge pull request #231 from puppetlabs/dependabot/bundler/rubocop-1.64.1
Bump rubocop from 1.64.0 to 1.64.1
2024-06-03 05:29:10 -04:00
dependabot[bot]
d1806b23eb
Bump rubocop from 1.64.0 to 1.64.1
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.64.0 to 1.64.1.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.64.0...v1.64.1)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-03 09:28:26 +00:00
puppet-release-bot
43b1977721
Merge pull request #230 from puppetlabs/dependabot/docker/ruby-3.3.2-slim-bullseye
Bump ruby from 3.3.1-slim-bullseye to 3.3.2-slim-bullseye
2024-06-03 05:25:11 -04:00
dependabot[bot]
dc0e440c86
Bump ruby from 3.3.1-slim-bullseye to 3.3.2-slim-bullseye
Bumps ruby from 3.3.1-slim-bullseye to 3.3.2-slim-bullseye.

---
updated-dependencies:
- dependency-name: ruby
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-06-03 09:24:25 +00:00
puppet-release-bot
98c45a5ed3
Merge pull request #229 from puppetlabs/dependabot/bundler/webmock-3.23.1
Bump webmock from 3.23.0 to 3.23.1
2024-05-27 05:45:55 -04:00
dependabot[bot]
06a9b95edf
Bump webmock from 3.23.0 to 3.23.1
Bumps [webmock](https://github.com/bblimke/webmock) from 3.23.0 to 3.23.1.
- [Changelog](https://github.com/bblimke/webmock/blob/master/CHANGELOG.md)
- [Commits](https://github.com/bblimke/webmock/compare/v3.23.0...v3.23.1)

---
updated-dependencies:
- dependency-name: webmock
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-27 09:45:18 +00:00
puppet-release-bot
83d23be8d7
Merge pull request #228 from puppetlabs/dependabot/bundler/rubocop-1.64.0
Bump rubocop from 1.63.5 to 1.64.0
2024-05-27 05:44:50 -04:00
dependabot[bot]
5b09d14926
Bump rubocop from 1.63.5 to 1.64.0
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.63.5 to 1.64.0.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.63.5...v1.64.0)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-27 09:44:03 +00:00
puppet-release-bot
e575ee1ba8
Merge pull request #227 from puppetlabs/dependabot/bundler/rexml-3.2.8
Bump rexml from 3.2.6 to 3.2.8
2024-05-16 17:29:07 -04:00
dependabot[bot]
ddc35eb118
Bump rexml from 3.2.6 to 3.2.8
Bumps [rexml](https://github.com/ruby/rexml) from 3.2.6 to 3.2.8.
- [Release notes](https://github.com/ruby/rexml/releases)
- [Changelog](https://github.com/ruby/rexml/blob/master/NEWS.md)
- [Commits](https://github.com/ruby/rexml/compare/v3.2.6...v3.2.8)

---
updated-dependencies:
- dependency-name: rexml
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-16 21:28:17 +00:00
puppet-release-bot
2acf63c8ba
Merge pull request #226 from puppetlabs/dependabot/bundler/rubocop-1.63.5
Bump rubocop from 1.63.4 to 1.63.5
2024-05-13 05:09:18 -04:00
dependabot[bot]
3213b33b98
Bump rubocop from 1.63.4 to 1.63.5
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.63.4 to 1.63.5.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.63.4...v1.63.5)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-05-13 09:08:29 +00:00
puppet-release-bot
813e76befc
Merge pull request #225 from puppetlabs/dependabot/docker/ruby-3.3.1-slim-bullseye
Bump ruby from 3.3.0-slim-bullseye to 3.3.1-slim-bullseye
2024-04-29 05:48:10 -04:00
dependabot[bot]
473f584a90
Bump ruby from 3.3.0-slim-bullseye to 3.3.1-slim-bullseye
Bumps ruby from 3.3.0-slim-bullseye to 3.3.1-slim-bullseye.

---
updated-dependencies:
- dependency-name: ruby
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-29 09:47:27 +00:00
puppet-release-bot
83bf0877b6
Merge pull request #224 from puppetlabs/dependabot/bundler/rubocop-1.63.4
Bump rubocop from 1.63.2 to 1.63.4
2024-04-29 05:41:03 -04:00
dependabot[bot]
7f32c1aeb2
Bump rubocop from 1.63.2 to 1.63.4
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.63.2 to 1.63.4.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.63.2...v1.63.4)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-29 09:40:13 +00:00
puppet-release-bot
40a0b2e2c6
Merge pull request #223 from puppetlabs/dependabot/bundler/rubocop-1.63.2
Bump rubocop from 1.63.1 to 1.63.2
2024-04-22 05:59:28 -04:00
dependabot[bot]
00484568c0
Bump rubocop from 1.63.1 to 1.63.2
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.63.1 to 1.63.2.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.63.1...v1.63.2)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-22 09:58:43 +00:00
puppet-release-bot
6e7c609d10
Merge pull request #222 from puppetlabs/dependabot/bundler/rubocop-1.63.1
Bump rubocop from 1.63.0 to 1.63.1
2024-04-15 05:48:57 -04:00
dependabot[bot]
30938db02e
Bump rubocop from 1.63.0 to 1.63.1
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.63.0 to 1.63.1.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.63.0...v1.63.1)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-15 09:46:40 +00:00
puppet-release-bot
6c1fe12a44
Merge pull request #221 from puppetlabs/dependabot/bundler/rubocop-1.63.0
Bump rubocop from 1.62.1 to 1.63.0
2024-04-08 05:14:54 -04:00
puppet-release-bot
3425bec1d8
Merge pull request #220 from puppetlabs/dependabot/bundler/rake-13.2.1
Bump rake from 13.1.0 to 13.2.1
2024-04-08 05:14:37 -04:00
dependabot[bot]
03d7bb7963
Bump rubocop from 1.62.1 to 1.63.0
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.62.1 to 1.63.0.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.62.1...v1.63.0)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-08 09:13:58 +00:00
dependabot[bot]
c1f93e40f7
Bump rake from 13.1.0 to 13.2.1
Bumps [rake](https://github.com/ruby/rake) from 13.1.0 to 13.2.1.
- [Release notes](https://github.com/ruby/rake/releases)
- [Changelog](https://github.com/ruby/rake/blob/master/History.rdoc)
- [Commits](https://github.com/ruby/rake/compare/v13.1.0...v13.2.1)

---
updated-dependencies:
- dependency-name: rake
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-04-08 09:13:47 +00:00
puppet-release-bot
e61be465ed
Merge pull request #219 from puppetlabs/dependabot/bundler/rubocop-1.62.1
Bump rubocop from 1.62.0 to 1.62.1
2024-03-18 05:16:00 -04:00
dependabot[bot]
e58a1eb68e
Bump rubocop from 1.62.0 to 1.62.1
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.62.0 to 1.62.1.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.62.0...v1.62.1)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-18 09:15:14 +00:00
puppet-release-bot
8f42af544a
Merge pull request #218 from puppetlabs/dependabot/bundler/rubocop-1.62.0
Bump rubocop from 1.61.0 to 1.62.0
2024-03-11 05:06:07 -04:00
dependabot[bot]
c0609d87b7
Bump rubocop from 1.61.0 to 1.62.0
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.61.0 to 1.62.0.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.61.0...v1.62.0)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-11 09:05:24 +00:00
puppet-release-bot
0d20d2cf2f
Merge pull request #217 from puppetlabs/dependabot/bundler/rubocop-1.61.0
Bump rubocop from 1.60.2 to 1.61.0
2024-03-04 04:55:24 -05:00
dependabot[bot]
961e3d9b3d
Bump rubocop from 1.60.2 to 1.61.0
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.60.2 to 1.61.0.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.60.2...v1.61.0)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-03-04 09:54:41 +00:00
puppet-release-bot
debc766d28
Merge pull request #216 from puppetlabs/dependabot/bundler/webmock-3.23.0
Bump webmock from 3.20.0 to 3.23.0
2024-02-26 04:37:50 -05:00
dependabot[bot]
df08f383fe
Bump webmock from 3.20.0 to 3.23.0
Bumps [webmock](https://github.com/bblimke/webmock) from 3.20.0 to 3.23.0.
- [Changelog](https://github.com/bblimke/webmock/blob/master/CHANGELOG.md)
- [Commits](https://github.com/bblimke/webmock/compare/v3.20.0...v3.23.0)

---
updated-dependencies:
- dependency-name: webmock
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-26 09:37:08 +00:00
puppet-release-bot
11beb6c933
Merge pull request #215 from puppetlabs/dependabot/bundler/webmock-3.20.0
Bump webmock from 3.19.1 to 3.20.0
2024-02-12 04:51:17 -05:00
dependabot[bot]
a5d5cdc53f
Bump webmock from 3.19.1 to 3.20.0
Bumps [webmock](https://github.com/bblimke/webmock) from 3.19.1 to 3.20.0.
- [Changelog](https://github.com/bblimke/webmock/blob/master/CHANGELOG.md)
- [Commits](https://github.com/bblimke/webmock/compare/v3.19.1...v3.20.0)

---
updated-dependencies:
- dependency-name: webmock
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-12 09:50:28 +00:00
puppet-release-bot
edff58a319
Merge pull request #214 from puppetlabs/dependabot/bundler/rspec-3.13.0
Bump rspec from 3.12.0 to 3.13.0
2024-02-05 04:33:44 -05:00
dependabot[bot]
cc018b0599
Bump rspec from 3.12.0 to 3.13.0
Bumps [rspec](https://github.com/rspec/rspec-metagem) from 3.12.0 to 3.13.0.
- [Commits](https://github.com/rspec/rspec-metagem/compare/v3.12.0...v3.13.0)

---
updated-dependencies:
- dependency-name: rspec
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-02-05 09:32:57 +00:00
puppet-release-bot
858e627c62
Merge pull request #213 from puppetlabs/dependabot/bundler/rubocop-1.60.2
Bump rubocop from 1.60.1 to 1.60.2
2024-01-29 04:03:26 -05:00
dependabot[bot]
cd412f8a07
Bump rubocop from 1.60.1 to 1.60.2
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.60.1 to 1.60.2.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.60.1...v1.60.2)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-29 09:02:48 +00:00
puppet-release-bot
0d8cb0232f
Merge pull request #212 from puppetlabs/dependabot/bundler/rubocop-1.60.1
Bump rubocop from 1.59.0 to 1.60.1
2024-01-22 04:22:58 -05:00
dependabot[bot]
0352a687c6
Bump rubocop from 1.59.0 to 1.60.1
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.59.0 to 1.60.1.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.59.0...v1.60.1)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-22 09:22:11 +00:00
Jake Spain
b388bc5f48
Merge pull request #209 from puppetlabs/fix-release-prep-param
(maint) Fix missing param in auto_release_prep
2024-01-19 16:48:17 -05:00
Jake Spain
4c9c82a7c2
Remove interactive option from release prep script 2024-01-19 15:12:37 -05:00
Jake Spain
50d3088ad8
Fix missing param in auto_release_prep 2024-01-15 09:24:30 -05:00
puppet-release-bot
cf362c4f08
Merge pull request #207 from puppetlabs/dependabot/docker/ruby-3.3.0-slim-bullseye
Bump ruby from 3.2.2-slim-bullseye to 3.3.0-slim-bullseye
2024-01-01 04:15:57 -05:00
dependabot[bot]
375eb6b9fd
Bump ruby from 3.2.2-slim-bullseye to 3.3.0-slim-bullseye
Bumps ruby from 3.2.2-slim-bullseye to 3.3.0-slim-bullseye.

---
updated-dependencies:
- dependency-name: ruby
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2024-01-01 09:15:12 +00:00
puppet-release-bot
d5f1d61bd1
Merge pull request #206 from puppetlabs/dependabot/bundler/rubocop-1.59.0
Bump rubocop from 1.58.0 to 1.59.0
2023-12-18 04:06:21 -05:00
dependabot[bot]
85ae0c9914
Bump rubocop from 1.58.0 to 1.59.0
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.58.0 to 1.59.0.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.58.0...v1.59.0)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-18 09:05:38 +00:00
puppet-release-bot
b460f1b2a8
Merge pull request #203 from puppetlabs/dependabot/bundler/rubocop-1.58.0
Bump rubocop from 1.56.4 to 1.58.0
2023-12-07 09:24:38 -05:00
Jake Spain
511ad870a5
Merge pull request #204 from puppetlabs/dependabot/github_actions/actions/setup-java-4
Bump actions/setup-java from 3 to 4
2023-12-07 09:15:31 -05:00
dependabot[bot]
93ecadf49a
Bump actions/setup-java from 3 to 4
Bumps [actions/setup-java](https://github.com/actions/setup-java) from 3 to 4.
- [Release notes](https://github.com/actions/setup-java/releases)
- [Commits](https://github.com/actions/setup-java/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/setup-java
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-07 14:14:53 +00:00
dependabot[bot]
05ae2e55da
Bump rubocop from 1.56.4 to 1.58.0
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.56.4 to 1.58.0.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.56.4...v1.58.0)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-07 14:14:46 +00:00
Jake Spain
b194e4a881
Merge pull request #202 from puppetlabs/dependabot/github_actions/actions/github-script-7
Bump actions/github-script from 6 to 7
2023-12-07 09:14:02 -05:00
dependabot[bot]
494bd3412c
Bump actions/github-script from 6 to 7
Bumps [actions/github-script](https://github.com/actions/github-script) from 6 to 7.
- [Release notes](https://github.com/actions/github-script/releases)
- [Commits](https://github.com/actions/github-script/compare/v6...v7)

---
updated-dependencies:
- dependency-name: actions/github-script
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-07 13:50:01 +00:00
puppet-release-bot
415b92ff97
Merge pull request #201 from puppetlabs/dependabot/bundler/rake-13.1.0
Bump rake from 13.0.6 to 13.1.0
2023-12-07 08:46:30 -05:00
dependabot[bot]
03ebf1d79a
Bump rake from 13.0.6 to 13.1.0
Bumps [rake](https://github.com/ruby/rake) from 13.0.6 to 13.1.0.
- [Release notes](https://github.com/ruby/rake/releases)
- [Changelog](https://github.com/ruby/rake/blob/master/History.rdoc)
- [Commits](https://github.com/ruby/rake/compare/v13.0.6...v13.1.0)

---
updated-dependencies:
- dependency-name: rake
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-12-07 13:45:52 +00:00
Jake Spain
affbdd64c4
Merge pull request #205 from puppetlabs/repo-sync
Add dependabot, release prep, and label reusable workflows from release-engineering-repo-standards
2023-12-07 08:45:03 -05:00
Jake Spain
5953ad89a4
syncing files from release-engineering-repo-standards 2023-12-06 17:15:07 -05:00
Jake Spain
215ec97dcf
Merge pull request #195 from puppetlabs/dependabot/github_actions/docker/build-push-action-5
Bump docker/build-push-action from 4 to 5
2023-10-02 09:47:56 -04:00
Jake Spain
28b64a6913
Merge pull request #198 from puppetlabs/dependabot/bundler/rubocop-1.56.4
Bump rubocop from 1.56.3 to 1.56.4
2023-10-02 09:38:05 -04:00
dependabot[bot]
c5ea73a3ad
Bump rubocop from 1.56.3 to 1.56.4
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.56.3 to 1.56.4.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.56.3...v1.56.4)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-10-02 09:05:59 +00:00
Jake Spain
648cb150c9
Merge pull request #196 from puppetlabs/dependabot/github_actions/docker/setup-buildx-action-3
Bump docker/setup-buildx-action from 2 to 3
2023-09-18 08:11:26 -04:00
Jake Spain
296a2eb5ef
Merge pull request #197 from puppetlabs/dependabot/github_actions/docker/login-action-3
Bump docker/login-action from 2 to 3
2023-09-18 08:11:04 -04:00
dependabot[bot]
df45ec0180
Bump docker/login-action from 2 to 3
Bumps [docker/login-action](https://github.com/docker/login-action) from 2 to 3.
- [Release notes](https://github.com/docker/login-action/releases)
- [Commits](https://github.com/docker/login-action/compare/v2...v3)

---
updated-dependencies:
- dependency-name: docker/login-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-18 09:50:25 +00:00
dependabot[bot]
f77bb2b29a
Bump docker/setup-buildx-action from 2 to 3
Bumps [docker/setup-buildx-action](https://github.com/docker/setup-buildx-action) from 2 to 3.
- [Release notes](https://github.com/docker/setup-buildx-action/releases)
- [Commits](https://github.com/docker/setup-buildx-action/compare/v2...v3)

---
updated-dependencies:
- dependency-name: docker/setup-buildx-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-18 09:50:21 +00:00
dependabot[bot]
ded2cd69dd
Bump docker/build-push-action from 4 to 5
Bumps [docker/build-push-action](https://github.com/docker/build-push-action) from 4 to 5.
- [Release notes](https://github.com/docker/build-push-action/releases)
- [Commits](https://github.com/docker/build-push-action/compare/v4...v5)

---
updated-dependencies:
- dependency-name: docker/build-push-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-18 09:50:18 +00:00
Jake Spain
05432f0387
Merge pull request #193 from puppetlabs/dependabot/bundler/rubocop-1.56.3
Bump rubocop from 1.56.2 to 1.56.3
2023-09-11 08:22:15 -04:00
Jake Spain
aa623ecd3e
Merge pull request #194 from puppetlabs/dependabot/github_actions/actions/checkout-4
Bump actions/checkout from 3 to 4
2023-09-11 08:21:13 -04:00
dependabot[bot]
9f72be5126
Bump actions/checkout from 3 to 4
Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-11 09:36:32 +00:00
dependabot[bot]
a2bf9ead58
Bump rubocop from 1.56.2 to 1.56.3
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.56.2 to 1.56.3.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.56.2...v1.56.3)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-11 09:11:43 +00:00
Jake Spain
91328afc96
Merge pull request #191 from puppetlabs/dependabot/bundler/webmock-3.19.1
Bump webmock from 3.19.0 to 3.19.1
2023-09-05 09:37:37 -04:00
Jake Spain
93aef491c6
Merge pull request #192 from puppetlabs/dependabot/bundler/rubocop-1.56.2
Bump rubocop from 1.56.1 to 1.56.2
2023-09-05 09:37:10 -04:00
dependabot[bot]
75cd758aad
Bump rubocop from 1.56.1 to 1.56.2
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.56.1 to 1.56.2.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.56.1...v1.56.2)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-04 09:19:02 +00:00
dependabot[bot]
ae42ba08ae
Bump webmock from 3.19.0 to 3.19.1
Bumps [webmock](https://github.com/bblimke/webmock) from 3.19.0 to 3.19.1.
- [Changelog](https://github.com/bblimke/webmock/blob/master/CHANGELOG.md)
- [Commits](https://github.com/bblimke/webmock/compare/v3.19.0...v3.19.1)

---
updated-dependencies:
- dependency-name: webmock
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-09-04 09:18:54 +00:00
Jake Spain
e5c47691d3
Merge pull request #190 from puppetlabs/dependabot/bundler/webmock-3.19.0
Bump webmock from 3.18.1 to 3.19.0
2023-08-28 07:59:49 -04:00
dependabot[bot]
6afb47c609
Bump webmock from 3.18.1 to 3.19.0
Bumps [webmock](https://github.com/bblimke/webmock) from 3.18.1 to 3.19.0.
- [Changelog](https://github.com/bblimke/webmock/blob/master/CHANGELOG.md)
- [Commits](https://github.com/bblimke/webmock/compare/v3.18.1...v3.19.0)

---
updated-dependencies:
- dependency-name: webmock
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-28 09:41:09 +00:00
Jake Spain
0119f38ad9
Merge pull request #189 from puppetlabs/dependabot/bundler/rubocop-1.56.1
Bump rubocop from 1.56.0 to 1.56.1
2023-08-21 07:04:39 -04:00
dependabot[bot]
7f06fbd0bc
Bump rubocop from 1.56.0 to 1.56.1
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.56.0 to 1.56.1.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.56.0...v1.56.1)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-21 09:31:07 +00:00
Jake Spain
b2cd786a42
Merge pull request #188 from puppetlabs/dependabot/bundler/rubocop-1.56.0
Bump rubocop from 1.55.1 to 1.56.0
2023-08-14 07:06:38 -04:00
dependabot[bot]
ebede7799d
Bump rubocop from 1.55.1 to 1.56.0
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.55.1 to 1.56.0.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.55.1...v1.56.0)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-14 09:43:18 +00:00
Jake Spain
194b0e3aa6
Merge pull request #187 from puppetlabs/release-1.8.1
1.8.1 release prep
2023-08-07 19:38:18 -04:00
Jake Spain
06127d7e67
1.8.1 release prep 2023-08-07 16:13:19 -04:00
Jake Spain
8daf63665d
Bump docker tag to latest used in test matrix 2023-08-07 16:11:06 -04:00
Jake Spain
46810ebf65
Merge pull request #183 from puppetlabs/dependabot/bundler/rubocop-1.55.1
Bump rubocop from 1.54.2 to 1.55.1
2023-08-07 16:06:04 -04:00
dependabot[bot]
7b24c81360
Bump rubocop from 1.54.2 to 1.55.1
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.54.2 to 1.55.1.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.54.2...v1.55.1)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-08-07 17:59:07 +00:00
Jake Spain
bfae973e46
Merge pull request #186 from puppetlabs/fix_status_path
(RE-15687) Use relative path for pooler status and summary
2023-08-07 13:57:47 -04:00
Jake Spain
6b041f5c48
Use relative path for pooler status and summary 2023-08-07 11:31:37 -04:00
Jake Spain
67020d29b6
Merge pull request #184 from puppetlabs/revert-issue-management
Revert "Migrate issue management to Jira"
2023-08-07 09:59:32 -04:00
Jake Spain
a4e006615e
Revert "Migrate issue management to Jira"
This reverts commit 6fa018d0b1.
2023-08-07 09:53:23 -04:00
Jake Spain
f7016a1a58
Merge pull request #182 from puppetlabs/dependabot/bundler/rubocop-1.54.2
Bump rubocop from 1.52.0 to 1.54.2
2023-07-17 08:02:40 -04:00
dependabot[bot]
3702cc8c98
Bump rubocop from 1.52.0 to 1.54.2
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.52.0 to 1.54.2.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.52.0...v1.54.2)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-07-17 09:56:10 +00:00
Jake Spain
f9c6043a47
Merge pull request #177 from puppetlabs/dependabot/bundler/rubocop-1.52.0
Bump rubocop from 1.51.0 to 1.52.0
2023-06-05 08:08:03 -04:00
dependabot[bot]
0d7119bb8a
Bump rubocop from 1.51.0 to 1.52.0
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.51.0 to 1.52.0.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.51.0...v1.52.0)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-05 09:56:37 +00:00
Jake Spain
3680668a08
Merge pull request #176 from puppetlabs/dependabot/bundler/rubocop-1.51.0
Bump rubocop from 1.50.2 to 1.51.0
2023-05-15 07:40:36 -04:00
dependabot[bot]
ff6ee2ddd8
Bump rubocop from 1.50.2 to 1.51.0
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.50.2 to 1.51.0.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.50.2...v1.51.0)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-05-15 09:56:34 +00:00
Jake Spain
48e2c035ca
Merge pull request #174 from puppetlabs/dependabot/bundler/rubocop-1.50.2
Bump rubocop from 1.49.0 to 1.50.2
2023-04-20 11:28:06 -04:00
Jake Spain
2db6e8c3fd
Merge pull request #175 from puppetlabs/migrate-issues
Migrate issue management to Jira
2023-04-20 09:56:14 -04:00
Jake Spain
6fa018d0b1
Migrate issue management to Jira 2023-04-20 08:52:58 -04:00
dependabot[bot]
6b6bf539cc
Bump rubocop from 1.49.0 to 1.50.2
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.49.0 to 1.50.2.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.49.0...v1.50.2)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-17 09:56:44 +00:00
Jake Spain
99f8cd04aa
Merge pull request #166 from puppetlabs/dependabot/bundler/rspec-tw-3.12.0
Update rspec requirement from ~> 3.11.0 to ~> 3.12.0
2023-04-03 17:18:54 -04:00
dependabot[bot]
5b7b3e69f3
Update rspec requirement from ~> 3.11.0 to ~> 3.12.0
Updates the requirements on [rspec](https://github.com/rspec/rspec-metagem) to permit the latest version.
- [Release notes](https://github.com/rspec/rspec-metagem/releases)
- [Commits](https://github.com/rspec/rspec-metagem/compare/v3.11.0...v3.12.0)

---
updated-dependencies:
- dependency-name: rspec
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-03 13:08:53 +00:00
Jake Spain
c2bfb5f34f
Merge pull request #167 from puppetlabs/dependabot/bundler/simplecov-tw-0.22.0
Update simplecov requirement from ~> 0.21.2 to ~> 0.22.0
2023-04-03 08:59:50 -04:00
dependabot[bot]
9de7ef1635
Update simplecov requirement from ~> 0.21.2 to ~> 0.22.0
Updates the requirements on [simplecov](https://github.com/simplecov-ruby/simplecov) to permit the latest version.
- [Release notes](https://github.com/simplecov-ruby/simplecov/releases)
- [Changelog](https://github.com/simplecov-ruby/simplecov/blob/main/CHANGELOG.md)
- [Commits](https://github.com/simplecov-ruby/simplecov/compare/v0.21.2...v0.22.0)

---
updated-dependencies:
- dependency-name: simplecov
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-03 12:38:12 +00:00
Jake Spain
64f7185bdc
Merge pull request #173 from puppetlabs/dependabot/bundler/rubocop-1.49.0
Bump rubocop from 1.48.1 to 1.49.0
2023-04-03 08:37:27 -04:00
dependabot[bot]
2adf27a7e0
Bump rubocop from 1.48.1 to 1.49.0
Bumps [rubocop](https://github.com/rubocop/rubocop) from 1.48.1 to 1.49.0.
- [Release notes](https://github.com/rubocop/rubocop/releases)
- [Changelog](https://github.com/rubocop/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop/rubocop/compare/v1.48.1...v1.49.0)

---
updated-dependencies:
- dependency-name: rubocop
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-04-03 09:56:45 +00:00
Jake Spain
930277a730
Merge pull request #172 from puppetlabs/fix-release-indent
Fix release workflow indentation
2023-03-21 15:04:07 -04:00
Jake Spain
56757d6cb4
Fix release workflow indentation 2023-03-21 14:17:16 -04:00
Jake Spain
da27ffd04c
Merge pull request #171 from puppetlabs/release_prep
1.8.0 release prep
2023-03-21 14:15:18 -04:00
Jake Spain
f327e5d5ee
1.8.0 release prep 2023-03-21 08:29:30 -04:00
Jake Spain
fcea431868
Merge pull request #170 from puppetlabs/docker-and-actions-updates
Docker, Actions, and Docs Updates
2023-03-20 17:03:40 -04:00
Jake Spain
9b669f6aca
Add Gemfile.lock 2023-03-20 15:42:54 -04:00
Jake Spain
4ab4d511f7
Add release instructions and reference docker image 2023-03-20 15:42:53 -04:00
Jake Spain
68843c1ecf
Add changelog 2023-03-20 15:42:52 -04:00
Jake Spain
9fdbb4acb9
Update workflow to check changelog, add release notes and docker push 2023-03-20 15:42:46 -04:00
Jake Spain
dba1215db4
Use Dockerfile for publishing an image 2023-03-20 15:32:55 -04:00
Jake Spain
d50e903167
Dependabot scan for actions updates 2023-03-20 15:32:55 -04:00
Jake Spain
e65a1dad3b
Update test workflow names, action tags, and add ruby 3.2 2023-03-20 15:32:55 -04:00
Jake Spain
90437ddf86
Merge pull request #169 from puppetlabs/fix-vmpooler-api-v2-active
Fix `floaty list --active` for vmpooler api v2
2023-03-20 15:16:40 -04:00
Jake Spain
d5d87ed54a
Fix floaty list --active for vmpooler api v2 2023-03-20 15:06:28 -04:00
Jake Spain
15d9da4514
Merge pull request #168 from puppetlabs/add-mend
(RE-15111) Migrate Synk to Mend
2023-01-20 14:47:52 -05:00
Jake Spain
6f35d0b16b
Migrate Snyk to Mend Scanning 2023-01-20 12:41:02 -05:00
Jake Spain
cda848d214
Change dependabot to weekly 2023-01-19 19:23:14 -05:00
Jake Spain
1258e70d03
Merge pull request #165 from puppetlabs/update_codeowners
(RE-14811) Move codeowners from DIO to RE
2022-08-26 10:33:52 -04:00
Jake Spain
b69b17d00a
Merge pull request #164 from puppetlabs/migrate_snyk
Add Snyk action and Move to RE org
2022-08-26 10:09:38 -04:00
Jake Spain
594544ea67
Move codeowners from DIO to RE 2022-08-26 09:30:51 -04:00
Jake Spain
a93bc24649
Add Snyk action 2022-08-16 17:12:19 -04:00
Jake Spain
9be5cd233e
Merge pull request #163 from puppetlabs/update-codeowners
Add release-engineering to codeowners
2022-08-08 15:04:12 -04:00
Jake Spain
14c160c2bc
Add release-engineering to codeowners 2022-08-08 14:36:32 -04:00
Jake Spain
da3d707fc8
Merge pull request #162 from puppetlabs/release-prep
v1.7.0 release prep
2022-04-05 12:02:52 -04:00
Jake Spain
f74fe22245
v1.7.0 release prep
Includes the following PRs since the last release:
- https://github.com/puppetlabs/vmfloaty/pull/157
- https://github.com/puppetlabs/vmfloaty/pull/160
- https://github.com/puppetlabs/vmfloaty/pull/159
- https://github.com/puppetlabs/vmfloaty/pull/155
- https://github.com/puppetlabs/vmfloaty/pull/152
- https://github.com/puppetlabs/vmfloaty/pull/158
2022-04-05 11:51:23 -04:00
Jake Spain
8f7487b7c3
Merge pull request #158 from puppetlabs/vmpooler-api-v2
(DIO-3101) Add VMPooler API v2 Support
2022-04-05 11:43:16 -04:00
Jake Spain
667dacbcea
Add ondemand flag and api v2 support to floaty ssh 2022-04-05 11:41:44 -04:00
Jake Spain
b84bc2b5d5
Merge pull request #152 from puppetlabs/reviews-and-releases
Docs on contributing and releasing
2022-04-05 11:39:29 -04:00
Jake Spain
3e8ddca1e3
Update release workflow to on dispatch and add notes about releasing 2022-04-05 11:37:53 -04:00
Jake Spain
4103fdeccc
Add VMPooler api v2 support for floaty get 2022-04-04 14:14:40 -04:00
Jake Spain
22b525b5c5
Merge pull request #155 from puppetlabs/dependabot/bundler/rspec-tw-3.11.0
Update rspec requirement from ~> 3.10.0 to ~> 3.11.0
2022-04-04 11:46:15 -04:00
dependabot[bot]
da48a4de0a
Update rspec requirement from ~> 3.10.0 to ~> 3.11.0
Updates the requirements on [rspec](https://github.com/rspec/rspec-metagem) to permit the latest version.
- [Release notes](https://github.com/rspec/rspec-metagem/releases)
- [Commits](https://github.com/rspec/rspec-metagem/compare/v3.10.0...v3.11.0)

---
updated-dependencies:
- dependency-name: rspec
  dependency-type: direct:development
...

Signed-off-by: dependabot[bot] <support@github.com>
2022-04-04 15:44:45 +00:00
Samuel
7108af4079
Merge pull request #159 from puppetlabs/bump-ruby
(maint) Add Ruby 3.1 to test matrix + dockerfile and drop EOL Ruby 2.6
2022-04-04 10:42:29 -05:00
Samuel
bbadec174c
Merge pull request #160 from puppetlabs/remove-colorize-usage
(maint) Remove colorize usage from `floaty status`
2022-04-04 10:37:03 -05:00
Jake Spain
6b67c216f5
Remove colorize usage from floaty status 2022-04-04 11:25:56 -04:00
Jake Spain
577579ffdd
Add Ruby 3.1 to test matrix + dockerfile and drop EOL Ruby 2.6 2022-04-04 11:13:31 -04:00
Brandon High
80f832ac20
Merge pull request #157 from binford2k/remove_previous_maintainers
(maint) removing previous maintainers
2022-03-17 23:57:29 -07:00
Ben Ford
0463180a67
(maint) removing previous maintainers
Cleaning up our github org and repos. I checked in with each previous
maintainer and they're cool with being off the hook here ;-)
2022-03-17 08:53:31 -07:00
trvs-sdlr
85c833a290
Merge pull request #156 from puppetlabs/DIO-2700
(DIO-2700) Vmfloaty should not use the Colorize gem
2022-02-16 11:12:14 -08:00
Samuel Beaulieu
6b9b4ea626
(DIO-2700) Vmfloaty should not use the Colorize gem
removing cosmetic use of colorize
2022-02-16 13:07:05 -06:00
Samuel
1b64ce3b03
Merge pull request #154 from cthorn42/maint/main/fix_nspooler_list_active_nil_error
(maint) Fix up nspooler list active bug
2022-02-08 14:04:31 -06:00
Christopher Thorn
5793ea78b9 (maint) Fix up nspooler list active bug
If no reason is defined for checking out a nspooler VM we'd get a nil
refrence error message when listing active nspooler VMs. This PR fixes
that.
2022-02-08 11:53:55 -08:00
903e59afb8
ignore .dccache 2021-10-12 13:48:52 -04:00
Heath Seals
ecf8925775
Merge pull request #151 from puppetlabs/readme-cleanup
Minor cleanup to the readme
2021-10-12 12:44:49 -05:00
61b87a5a58
Minor cleanup to the readme 2021-10-12 13:35:39 -04:00
Heath Seals
2fa122733a
Merge pull request #150 from puppetlabs/release-1.5.0
Release prep for 1.5.0
2021-10-12 12:18:21 -05:00
62f9731910
Release prep for 1.5.0 2021-10-12 13:11:30 -04:00
Tanisha Payne
8573a4e976
Merge pull request #149 from puppetlabs/DIO-2412
DIO 2412- Ondemand and Priority flag added to SSH command
2021-10-12 12:24:30 -04:00
Tanisha Payne
3c3623689a ondemand added to ssh command 2021-10-12 10:39:06 -04:00
Tanisha Payne
bd5d1a36f0 priority flag added to ssh command 2021-10-08 11:44:45 -04:00
Heath Seals
d361f4c0b7
Merge pull request #148 from puppetlabs/DIO-2135
(DIO-2135) Update docker FROM image to ruby 3.0.2
2021-08-13 10:01:31 -05:00
Samuel Beaulieu
33758081d1
(DIO-2135) Update docker FROM image to ruby 3.0.2 2021-08-11 15:13:24 -05:00
17b8dbfa5c
Merge pull request #146 from puppetlabs/release-1.4.0
v1.4.0 release prep
2021-07-21 09:47:38 -04:00
77a3eeb57a
Merge pull request #147 from puppetlabs/ci-updating
Migrate CI to GitHub Actions
2021-07-21 09:47:23 -04:00
38a465e862
Migrate CI to GitHub Actions 2021-07-16 17:13:51 -04:00
b89154648f
v1.4.0 release prep 2021-07-16 16:24:32 -04:00
f2f3a3bfa9
Merge pull request #140 from puppetlabs/dependabot/bundler/commander-gte-4.4.3-and-lt-4.7.0
Update commander requirement from >= 4.4.3, < 4.6.0 to >= 4.4.3, < 4.7.0
2021-07-16 16:20:59 -04:00
dependabot[bot]
bcd08fca15
Update commander requirement from >= 4.4.3, < 4.6.0 to >= 4.4.3, < 4.7.0
Updates the requirements on [commander](https://github.com/commander-rb/commander) to permit the latest version.
- [Release notes](https://github.com/commander-rb/commander/releases)
- [Changelog](https://github.com/commander-rb/commander/blob/master/History.rdoc)
- [Commits](https://github.com/commander-rb/commander/compare/v4.4.3...v4.6.0)

Signed-off-by: dependabot[bot] <support@github.com>
2021-07-13 17:02:52 +00:00
Brandon High
3b40cbe498
Merge pull request #145 from nmburgan/maint/master/fix_specs
(maint) Use latest Faraday/webmock, update specs
2021-07-13 10:02:14 -07:00
Nick Burgan-Illig
f6febc9b8f (maint) Use latest Faraday/webmock, update specs
This unpins Faraday and webmock, and updates specs so that the Faraday changes (primarily including auth in the header rather than in the URL) is reflected.
2021-07-12 18:33:50 +00:00
302d52a45e
Merge pull request #135 from puppetlabs/rubocop_auto_fix
Run the rubocop auto_correct
2021-07-12 10:04:35 -04:00
Heath Seals
d0fb0f3ac1
Merge pull request #137 from puppetlabs/release-1.3.0
Release prep for v1.3.0
2021-03-03 12:34:25 -06:00
Samuel
38f24f4ad1
Release prep for v1.3.0 2021-03-03 12:25:08 -06:00
Samuel Beaulieu
eb99ba1dec
Run the rubocop auto_correct
fixed 27 files inspected, 975 offenses detected, 804 offenses corrected
2021-02-25 13:38:11 -06:00
Samuel
7041df82f0
Merge pull request #124 from puppetlabs/dependabot/bundler/rubocop-tw-1.6
Update rubocop requirement from ~> 0.52 to ~> 1.6
2021-02-25 13:35:01 -06:00
Samuel
55ead89ab2
Merge pull request #134 from puppetlabs/DIO-1522
(DIO-1522) Show the VM state (running, destroyed) and colorize in red…
2021-02-25 13:24:57 -06:00
Samuel Beaulieu
8143641f83
(DIO-1522) Show the VM state (running, destroyed) and colorize in red when it has been deleted
the ABS system does not have a real sense of the current state of the resources
it has allocated. When running list --active it can list VMs that have been
deleted or reaped after their lifetime expired.
This change enables to show more information when a vmpooler_fallback service
is provided to ABS, and will show the state (running, destroyed) and colorize
in red when the VM is destroyed.
2021-02-25 10:14:41 -06:00
Samuel
f811e252eb
Merge pull request #132 from puppetlabs/release-1.2.0
Release prep for 1.2.0
2021-02-11 09:20:20 -06:00
a9c8d17e9a
Release prep for 1.2.0 2021-02-11 10:16:21 -05:00
796cd8e858
Merge pull request #131 from puppetlabs/DIO-908
(DIO-908) Floaty can now report the status of ABS requests
2021-02-11 10:11:13 -05:00
Samuel Beaulieu
4192631d70 (DIO-908) Adding a way to set Logger level via --loglevel
this is specially useful if you also use in combination --json to remove superfluous stdout
2021-02-09 15:38:43 -06:00
Samuel Beaulieu
a3d8484124 (DIO-908) Floaty can now report the status of ABS requests
- If ABS queries returns a body for 200 or 202, floaty will print it
this is useful in the new version of ABS, since it shows the progress
for ondemand requests (AWS or vmpooler)
- removed the queue_place and querying the queue for a 'get' request
this queue_place number was misleading since it was just a redis index
and did not represent well where the request was in the queue
- Also added a flag option --continue to be used when the cli was
interrupted for example with ctrl-c
2021-02-09 11:29:19 -06:00
Brandon High
f3299285b8
Merge branch 'master' into dependabot/bundler/rubocop-tw-1.6 2020-12-12 14:45:43 -08:00
Brandon High
85a63e85fe
Merge pull request #116 from puppetlabs/dependabot/bundler/rspec-tw-3.10.0
Update rspec requirement from ~> 3.9.0 to ~> 3.10.0
2020-12-12 14:43:52 -08:00
dependabot[bot]
d4c2795df0
Update rubocop requirement from ~> 0.52 to ~> 1.6
Updates the requirements on [rubocop](https://github.com/rubocop-hq/rubocop) to permit the latest version.
- [Release notes](https://github.com/rubocop-hq/rubocop/releases)
- [Changelog](https://github.com/rubocop-hq/rubocop/blob/master/CHANGELOG.md)
- [Commits](https://github.com/rubocop-hq/rubocop/compare/v0.52.0...v1.6.0)

Signed-off-by: dependabot[bot] <support@github.com>
2020-12-09 13:04:56 +00:00
dependabot[bot]
c969e9c552
Update rspec requirement from ~> 3.9.0 to ~> 3.10.0
Updates the requirements on [rspec](https://github.com/rspec/rspec) to permit the latest version.
- [Release notes](https://github.com/rspec/rspec/releases)
- [Commits](https://github.com/rspec/rspec/compare/v3.9.0...v3.10.0)

Signed-off-by: dependabot[bot] <support@github.com>
2020-11-02 13:03:24 +00:00
e50c9ec4ca
Merge pull request #112 from puppetlabs/v1.1.1
V1.1.1
2020-10-16 16:03:05 -04:00
Samuel Beaulieu
4aa78a1b66 fix tests 2020-10-16 13:23:50 -05:00
Samuel Beaulieu
ced6b46032 (v1.1.1) Prepare for pushing the gem to rubygems 2020-10-16 13:15:15 -05:00
Samuel Beaulieu
846cc7050c when missing, adds the api/v2 to the url endpoint 2020-10-16 13:14:57 -05:00
Samuel
6d1130bc8b
Merge pull request #104 from nwolfe/maint/dont-require-fallback-config
(maint) Don't require configuration file for get
2020-10-09 14:56:25 -05:00
Samuel
ad8196970c
Merge branch 'master' into maint/dont-require-fallback-config 2020-10-09 14:54:29 -05:00
e146857706
Merge pull request #103 from cthorn42/maint/master/add_vmpooler_fallback_to_service_check
(maint) Add vmpooler_fallback to the get service check
2020-10-09 11:52:24 -04:00
3ce0222b38
Merge pull request #105 from puppetlabs/dont-require-vmfloaty.yml-list
(maint) Don't require config file for list --active
2020-10-09 11:45:13 -04:00
221f6c18cc
Merge pull request #107 from puppetlabs/fix-jobid-uniqueness
(maint) Add more uniqueness to jobid and useful termination message
2020-10-09 11:44:29 -04:00
3f8417d192
Merge pull request #106 from puppetlabs/fix-endpoint-check
(maint) Fix bug with detecting ABS service
2020-10-09 11:42:38 -04:00
Samuel Beaulieu
671623bc4f handle ctrl-c and term signal and return useful message on how
to query ABS for the state of the request or to delete it
2020-10-09 10:37:16 -05:00
Samuel Beaulieu
e0fac0bb6c (maint) Add more uniqueness to jobid
Before this change there was a non zero chance that two requests could be received
at the same millisecond and have the same jobid. Added the username as a prefix
to the job id
2020-10-09 10:23:23 -05:00
Samuel Beaulieu
fbd98f93ae (maint) Fix bug with detecting ABS service
Before this change the code would try to check if an object was ABS
by using is_a? which is only for instances of a class. It also compared
with ABS.class which returns the Class class.
Now fixed by comparing the object to the static class
2020-10-09 10:18:53 -05:00
a4231cc6f1
Merge pull request #102 from scotje/service_subcommand_completions
Update completion scripts for `service` subcommands
2020-09-25 13:02:06 -04:00
Nate Wolfe
56f0896d48
(maint) Don't require configuration file for get
Make the vmpooler_fallback optional for cases when there's no
configuration file and everything is specified on the CLI invocation.
2020-09-24 12:32:29 -07:00
Samuel Beaulieu
6deadb2267 Fix tests 2020-09-24 10:00:15 -05:00
Samuel Beaulieu
3a60ffbdbd (maint) Don't require config file for list --active
Will fallback to printing ABS information, which is less than what you
get if vmpooler_fallback is available
2020-09-24 09:46:22 -05:00
Christopher Thorn
5c8aa13081 (maint) Add vmpooler_fallback to the get service check
Previously the vmpooler_fallback setting was not being recognizied, this
PR will fix it.
2020-09-23 15:06:24 -07:00
Jesse Scott
c5b9e1d184
Update completion scripts for service subcommands 2020-09-22 12:07:11 -07:00
Belén
1e81c78a5b
Merge pull request #100 from puppetlabs/v1-release
Bump to version 1.0.0
2020-09-22 09:15:43 -07:00
d9b5bb5e89
Bump to version 1.0.0 2020-09-22 12:02:56 -04:00
bc1ea2e2d9
Merge pull request #90 from scotje/add_zsh_completions_new
Add tab completion script for zsh and fix bash completion for ABS services
2020-09-22 11:56:31 -04:00
Samuel Beaulieu
2b56448d50 Fix pretty print when multiple backend services
are returned by ABS. Added test with vmpooler and nspooler result
2020-09-22 09:53:13 -05:00
Samuel Beaulieu
45f0ef031e Fix spec tests for ABS pretty print
ABS now returns the ABS job_id on the first line, then every
vmpooler hostname indented. It queries them from vmpooler to
get the metadata like lifetime etc
2020-09-22 09:15:15 -05:00
013325b7a6
Merge pull request #99 from puppetlabs/fix-returned-abs-json
(maint) Fix for ABS PR#306 that includes json responses
2020-09-22 08:57:08 -04:00
Jesse Scott
8546c1c4b6
WIP: fixup specs after rebase 2020-09-21 16:59:04 -07:00
Jesse Scott
e269d71fea
Add README for zsh tab completion 2020-09-21 16:58:50 -07:00
Jesse Scott
dee735e017
(FIXUP) Collect hostnames in array before outputting 2020-09-21 16:55:09 -07:00
Jesse Scott
57e7542f73
Add tab completion script for zsh
This commit adds a new tab completion script for zsh. It also
fixes the completion script for bash to work with ABS backends.
2020-09-21 16:55:09 -07:00
Jesse Scott
b31f44fb40
Add --hostnameonly option to floaty list --active
Adds an option to the `floaty list` subcommand so that, when listing
active hosts, floaty will output just the hostnames, without any
additional information or formatting. Hostnames will be separated by a
newline.

This functionality is primarily intended for consuming by tooling (such
as the tab completion scripts).
2020-09-21 16:55:07 -07:00
Jesse Scott
40072e90e4
Fix print_to_stderr option for Utils.pretty_print_hosts
Previously this option had no effect on the output. This commit makes
the option effective and also refactors the tests for this method to
cover this case.
2020-09-21 16:54:17 -07:00
Samuel Beaulieu
cd7c0fae13 Adding spec tests for #list 2020-09-21 15:20:22 -05:00
Samuel Beaulieu
4df970b21f (maint) Fix for ABS PR#306 that includes json responses
Before this change ABS sometiimes returned a string of JSON with escaped
quotes, that had to be parsed again
With this change, floaty should accept both the legacy and the new
full JSON responses.
2020-09-21 14:46:00 -05:00
mattkirby
f3cd540455
Merge pull request #98 from puppetlabs/better-abs-config
(maint) Support any vmpooler for ABS via vmpooler_fallback
2020-09-17 10:08:05 -07:00
mattkirby
81c6e48528
Merge pull request #97 from puppetlabs/types-docs
(DIO-991) Add service command
2020-09-17 08:58:24 -07:00
mattkirby
e34964be00
Merge pull request #96 from puppetlabs/dio-911
( DIO-911) Include job_id in ABS --json output
2020-09-17 08:55:43 -07:00
9e61247cfe
Add service command
This change creates the `floaty service` command with two valid
arguemnts: types and examples

- `floaty service types` prints out a list of valid types for use in a
  service definition in ~/.vmfloaty.yml
- `floaty service examples` prints out example configuration files for
  both a single service and multiple services.
2020-09-16 12:55:42 -04:00
Samuel Beaulieu
5333158bdc (maint) Support any vmpooler for ABS via vmpooler_fallback
Before this change, the fallback vmpooler for ABS had to be named
'vmpooler' and it only supported one. With this new code, users can
set a key within an 'abs' service type called vmpooler_fallback that
points to any other service configured in the ~/.vmfloaty.yml config
file. If not set, the appropriate error message is returned, with
an example configuration.
Added the various use cases for the config to the unit tests
2020-09-16 11:25:49 -05:00
Samuel Beaulieu
4b7cbbf0e5 fix abs spec tests 2020-09-15 11:21:58 -05:00
mattkirby
512adb4af1
Merge pull request #94 from puppetlabs/fix-abs-vmpooler
ABS enables fallback to vmpooler for some scenarios
2020-09-11 13:27:02 -07:00
Samuel Beaulieu
c65b72d86b Document the ~/.vmfloaty content for ABS usage 2020-09-11 13:38:33 -05:00
Samuel Beaulieu
dbf6c54173 The main goal for this PR is to enable using all of the vmfloaty scenarios when
the service is set to ABS. Since ABS does not implement all the services, it
fallsback on vmpooler when needed (example increasing the lifetime value)

- Validating JSON can be parsed before parsing, as it used to throw uncaught errors
- self.list_active is returning hosts for both nspooler and vmpooler but was returning
job_ids for abs. Now standardized the returned values for use in the "modify" cli,
and created a separate list_active_job_ids for the cases where a job_id list is expected

- added a way to change the service in place for methods that do not make sense
for ABS, and instead fallback on using vmpooler in those cases:
1. summary
2. modify
3. snapshot
4. revert
5. disk
For those methods in the class itself, raising a NoMethodError, in case it is used directly

- query now returns the queue info. For information on VMs, users should use --service vmpooler
- pretty_print_hosts (used in list, and delete scenarios) will now print the job_id
ABS information and indent each VM within and print it's metadata. Useful for
knowing the running time and extending it.

- added a new utility method to get the config for the vmpooler service, used for the fallback
- added a passthrough for the vmpooler token to use when running ABS. This enables
vmpooler to track the VMs used by each token (user). Also aligns the list between
both ABS and vmpooler. Fixes the bit-bar issue where the VMs do not appear when created
via ABS
2020-09-11 13:38:24 -05:00
5a0640c515
Merge pull request #91 from nwolfe/maint/remove-warning
(maint) Remove warning about missing configuration file
2020-09-03 07:06:05 -04:00
Nate Wolfe
cb1ea8247b
WIP (DIO-911) Include job_id in ABS --json output
Prior to this commit, when using --service=abs and --json the job_id
value is not included in the JSON blob, which makes it difficult for
calling code to grab both the job_id and the hosts without text
processing the log messages printed to standard error.
2020-08-24 16:07:49 -07:00
Nate Wolfe
9a44cc480e
(maint) Add --user CLI option on delete and list subcommands
To support usage without a configuration file.
2020-08-24 12:11:06 -07:00
Nate Wolfe
8341a5f45d
(maint) Mention configuration file in CLI help text description
So users can be aware of the configuration file since it will no
longer be emitted as a warning during CLI invocation.
2020-08-21 15:45:10 -07:00
Nate Wolfe
04c73a970d
(maint) Remove warning about missing configuration file
Previously the CLI would emit a warning about missing configuration
file, but a configuration file does not appear to be a requirement, at
least based on the documentation and the fact that everything can be
specified directly on the command line.

This commit simply removes the warning.

Users will no longer get a warning when doing things like `floaty
--version`, `floaty help`, and any other subcommand.
2020-08-21 14:38:04 -07:00
45 changed files with 2351 additions and 657 deletions

View file

@ -1 +0,0 @@
service_name: travis-pro

View file

@ -3,10 +3,7 @@
**/*.md **/*.md
**/*example **/*example
**/Dockerfile* **/Dockerfile*
Gemfile.lock
Rakefile
coverage coverage
spec
examples examples
scripts scripts
vendor vendor

View file

@ -15,8 +15,3 @@ FIXME
- [ ] Tests - [ ] Tests
- [ ] Documentation - [ ] Documentation
## Reviewers
@puppetlabs/dio
@highb
@briancain

View file

@ -3,6 +3,17 @@ updates:
- package-ecosystem: bundler - package-ecosystem: bundler
directory: "/" directory: "/"
schedule: schedule:
interval: daily interval: weekly
time: "13:00" open-pull-requests-limit: 10
- package-ecosystem: docker
directory: "/"
schedule:
interval: weekly
open-pull-requests-limit: 10
- package-ecosystem: github-actions
directory: "/"
schedule:
interval: weekly
open-pull-requests-limit: 10 open-pull-requests-limit: 10

12
.github/workflows/auto_release_prep.yml vendored Normal file
View file

@ -0,0 +1,12 @@
name: Automated release prep
on:
workflow_dispatch:
jobs:
auto_release_prep:
uses: puppetlabs/release-engineering-repo-standards/.github/workflows/auto_release_prep.yml@v1
secrets: inherit
with:
project-type: ruby
version-file-path: lib/vmfloaty/version.rb

View file

@ -0,0 +1,8 @@
name: Dependabot auto-merge
on: pull_request
jobs:
dependabot_merge:
uses: puppetlabs/release-engineering-repo-standards/.github/workflows/dependabot_merge.yml@v1
secrets: inherit

8
.github/workflows/ensure_label.yml vendored Normal file
View file

@ -0,0 +1,8 @@
name: Ensure label
on: pull_request
jobs:
ensure_label:
uses: puppetlabs/release-engineering-repo-standards/.github/workflows/ensure_label.yml@v1
secrets: inherit

View file

@ -1,29 +0,0 @@
name: Ruby Gem
on:
push:
tags:
- 'v*.*.*'
jobs:
build:
name: Build + Publish
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Ruby 2.6
uses: actions/setup-ruby@v1
with:
version: 2.6.x
- name: Publish to RubyGems
run: |
mkdir -p $HOME/.gem
touch $HOME/.gem/credentials
chmod 0600 $HOME/.gem/credentials
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
gem build *.gemspec
gem push *.gem
env:
GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_AUTH_TOKEN}}

118
.github/workflows/release.yml vendored Normal file
View file

@ -0,0 +1,118 @@
name: Tag Release & Push Gem & Docker
on: workflow_dispatch
permissions:
contents: write
issues: read
pull-requests: read
packages: write
jobs:
release:
name: Validate Docs, Tag, and Docker Push
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.ref }}
clean: true
fetch-depth: 0
- name: Get New Version
id: nv
run: |
version=$(grep VERSION lib/vmfloaty/version.rb |rev |cut -d "'" -f2 |rev)
echo "version=$version" >> $GITHUB_OUTPUT
echo "Found version $version from lib/vmfloaty/version.rb"
- name: Get Current Version
uses: actions/github-script@v7
id: cv
with:
script: |
const { data: response } = await github.rest.repos.getLatestRelease({
owner: context.repo.owner,
repo: context.repo.repo,
})
console.log(`The latest release is ${response.tag_name}`)
return response.tag_name
result-encoding: string
- name: Generate Changelog
uses: docker://githubchangeloggenerator/github-changelog-generator:1.16.2
with:
args: >-
--future-release ${{ steps.nv.outputs.version }}
env:
CHANGELOG_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Validate Changelog
run : |
set -e
if output=$(git status --porcelain) && [ ! -z "$output" ]; then
echo "Here is the current git status:"
git status
echo
echo "The following changes were detected:"
git --no-pager diff
echo "Uncommitted PRs found in the changelog. Please submit a release prep PR of changes after running './release-prep ${{ steps.nv.outputs.version }}'"
exit 1
fi
- name: Generate Release Notes
uses: docker://githubchangeloggenerator/github-changelog-generator:1.16.2
with:
args: >-
--since-tag ${{ steps.cv.outputs.result }}
--future-release ${{ steps.nv.outputs.version }}
--output release-notes.md
env:
CHANGELOG_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Tag Release
uses: ncipollo/release-action@v1
with:
tag: ${{ steps.nv.outputs.version }}
token: ${{ secrets.GITHUB_TOKEN }}
bodyfile: release-notes.md
draft: false
prerelease: false
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
push: true
tags: |
ghcr.io/${{ github.repository }}:${{ steps.nv.outputs.version }}
ghcr.io/${{ github.repository }}:latest
- name: Set up Ruby 3.2
uses: actions/setup-ruby@v1
with:
version: 3.2.x
- name: Build gem
run: gem build *.gemspec
- name: Publish gem
run: |
mkdir -p $HOME/.gem
touch $HOME/.gem/credentials
chmod 0600 $HOME/.gem/credentials
printf -- "---\n:rubygems_api_key: ${GEM_HOST_API_KEY}\n" > $HOME/.gem/credentials
gem push *.gem
env:
GEM_HOST_API_KEY: ${{secrets.RUBYGEMS_AUTH_TOKEN}}

39
.github/workflows/security.yml vendored Normal file
View file

@ -0,0 +1,39 @@
name: Security
on:
workflow_dispatch:
push:
branches:
- main
jobs:
scan:
name: Mend Scanning
runs-on: ubuntu-latest
steps:
- name: checkout repo content
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: setup ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: 2.7
# setup a package lock if one doesn't exist, otherwise do nothing
- name: check lock
run: '[ -f "Gemfile.lock" ] && echo "package lock file exists, skipping" || bundle lock'
# install java
- uses: actions/setup-java@v4
with:
distribution: 'temurin' # See 'Supported distributions' for available options
java-version: '17'
# download mend
- name: download_mend
run: curl -o wss-unified-agent.jar https://unified-agent.s3.amazonaws.com/wss-unified-agent.jar
- name: run mend
run: java -jar wss-unified-agent.jar
env:
WS_APIKEY: ${{ secrets.MEND_API_KEY }}
WS_WSS_URL: https://saas-eu.whitesourcesoftware.com/agent
WS_USERKEY: ${{ secrets.MEND_TOKEN }}
WS_PRODUCTNAME: RE
WS_PROJECTNAME: ${{ github.event.repository.name }}

54
.github/workflows/test.yml vendored Normal file
View file

@ -0,0 +1,54 @@
# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.
# This workflow will download a prebuilt Ruby version, install dependencies and run tests with Rake
# For more information see: https://github.com/marketplace/actions/setup-ruby-jruby-and-truffleruby
name: Test
on:
pull_request:
branches:
- main
jobs:
spec:
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version:
- '2.7'
- '3.0'
- '3.1'
- '3.2'
steps:
- uses: actions/checkout@v4
- name: Set up Ruby
# To automatically get bug fixes and new Ruby versions for ruby/setup-ruby,
# change this to (see https://github.com/ruby/setup-ruby#versioning):
# uses: ruby/setup-ruby@v1
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ matrix.ruby-version }}
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
- name: Run tests
run: bundle exec rake spec
- name: Coveralls
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
flag-name: run-${{ matrix.ruby-version }}
parallel: true
finish:
needs: spec
if: ${{ always() }}
runs-on: ubuntu-latest
steps:
- name: Coveralls Finished
uses: coverallsapp/github-action@v2
with:
github-token: ${{ secrets.github_token }}
parallel-finished: true

View file

@ -0,0 +1,3 @@
project=vmfloaty
user=puppetlabs
exclude_labels=maintenance

3
.gitignore vendored
View file

@ -25,9 +25,10 @@ build/
/vendor/ /vendor/
/lib/bundler/man/ /lib/bundler/man/
.dccache
# for a library or gem, you might want to ignore these files since the code is # for a library or gem, you might want to ignore these files since the code is
# intended to run in multiple environments; otherwise, check them in: # intended to run in multiple environments; otherwise, check them in:
Gemfile.lock
.ruby-version .ruby-version
.ruby-gemset .ruby-gemset

View file

@ -1,7 +0,0 @@
language: ruby
dist: xenial
os:
- linux
rvm:
- 2.6.5
script: bundle exec rake spec

340
CHANGELOG.md Normal file
View file

@ -0,0 +1,340 @@
# Changelog
## [1.8.1](https://github.com/puppetlabs/vmfloaty/tree/1.8.1) (2023-08-07)
[Full Changelog](https://github.com/puppetlabs/vmfloaty/compare/1.8.0...1.8.1)
**Fixed bugs:**
- status and summary broken for pooler service after v3 [\#185](https://github.com/puppetlabs/vmfloaty/issues/185)
- \(RE-15687\) Use relative path for pooler status and summary [\#186](https://github.com/puppetlabs/vmfloaty/pull/186) ([yachub](https://github.com/yachub))
**Merged pull requests:**
- Bump rubocop from 1.54.2 to 1.55.1 [\#183](https://github.com/puppetlabs/vmfloaty/pull/183) ([dependabot[bot]](https://github.com/apps/dependabot))
- Bump rubocop from 1.52.0 to 1.54.2 [\#182](https://github.com/puppetlabs/vmfloaty/pull/182) ([dependabot[bot]](https://github.com/apps/dependabot))
- Bump rubocop from 1.51.0 to 1.52.0 [\#177](https://github.com/puppetlabs/vmfloaty/pull/177) ([dependabot[bot]](https://github.com/apps/dependabot))
- Bump rubocop from 1.50.2 to 1.51.0 [\#176](https://github.com/puppetlabs/vmfloaty/pull/176) ([dependabot[bot]](https://github.com/apps/dependabot))
- Bump rubocop from 1.49.0 to 1.50.2 [\#174](https://github.com/puppetlabs/vmfloaty/pull/174) ([dependabot[bot]](https://github.com/apps/dependabot))
- Bump rubocop from 1.48.1 to 1.49.0 [\#173](https://github.com/puppetlabs/vmfloaty/pull/173) ([dependabot[bot]](https://github.com/apps/dependabot))
- Update simplecov requirement from ~\> 0.21.2 to ~\> 0.22.0 [\#167](https://github.com/puppetlabs/vmfloaty/pull/167) ([dependabot[bot]](https://github.com/apps/dependabot))
- Update rspec requirement from ~\> 3.11.0 to ~\> 3.12.0 [\#166](https://github.com/puppetlabs/vmfloaty/pull/166) ([dependabot[bot]](https://github.com/apps/dependabot))
## [1.8.0](https://github.com/puppetlabs/vmfloaty/tree/1.8.0) (2023-03-21)
[Full Changelog](https://github.com/puppetlabs/vmfloaty/compare/1.7.0...1.8.0)
**Implemented enhancements:**
- Docker, Actions, and Docs Updates [\#170](https://github.com/puppetlabs/vmfloaty/pull/170) ([yachub](https://github.com/yachub))
**Fixed bugs:**
- Fix `floaty list --active` for vmpooler api v2 [\#169](https://github.com/puppetlabs/vmfloaty/pull/169) ([yachub](https://github.com/yachub))
**Merged pull requests:**
- \(RE-15111\) Migrate Synk to Mend [\#168](https://github.com/puppetlabs/vmfloaty/pull/168) ([yachub](https://github.com/yachub))
- \(RE-14811\) Move codeowners from DIO to RE [\#165](https://github.com/puppetlabs/vmfloaty/pull/165) ([yachub](https://github.com/yachub))
- Add Snyk action and Move to RE org [\#164](https://github.com/puppetlabs/vmfloaty/pull/164) ([yachub](https://github.com/yachub))
- Add release-engineering to codeowners [\#163](https://github.com/puppetlabs/vmfloaty/pull/163) ([yachub](https://github.com/yachub))
## [1.7.0](https://github.com/puppetlabs/vmfloaty/tree/1.7.0) (2022-04-05)
[Full Changelog](https://github.com/puppetlabs/vmfloaty/compare/v1.6.0...1.7.0)
**Implemented enhancements:**
- \(maint\) Add Ruby 3.1 to test matrix + dockerfile and drop EOL Ruby 2.6 [\#159](https://github.com/puppetlabs/vmfloaty/pull/159) ([yachub](https://github.com/yachub))
- \(DIO-3101\) Add VMPooler API v2 Support [\#158](https://github.com/puppetlabs/vmfloaty/pull/158) ([yachub](https://github.com/yachub))
**Fixed bugs:**
- \(maint\) Remove colorize usage from `floaty status` [\#160](https://github.com/puppetlabs/vmfloaty/pull/160) ([yachub](https://github.com/yachub))
**Merged pull requests:**
- v1.7.0 release prep [\#162](https://github.com/puppetlabs/vmfloaty/pull/162) ([yachub](https://github.com/yachub))
- \(maint\) removing previous maintainers [\#157](https://github.com/puppetlabs/vmfloaty/pull/157) ([binford2k](https://github.com/binford2k))
- Update rspec requirement from ~\> 3.10.0 to ~\> 3.11.0 [\#155](https://github.com/puppetlabs/vmfloaty/pull/155) ([dependabot[bot]](https://github.com/apps/dependabot))
- Docs on contributing and releasing [\#152](https://github.com/puppetlabs/vmfloaty/pull/152) ([genebean](https://github.com/genebean))
## [v1.6.0](https://github.com/puppetlabs/vmfloaty/tree/v1.6.0) (2022-02-16)
[Full Changelog](https://github.com/puppetlabs/vmfloaty/compare/v1.5.0...v1.6.0)
**Merged pull requests:**
- \(DIO-2700\) Vmfloaty should not use the Colorize gem [\#156](https://github.com/puppetlabs/vmfloaty/pull/156) ([sbeaulie](https://github.com/sbeaulie))
- \(maint\) Fix up nspooler list active bug [\#154](https://github.com/puppetlabs/vmfloaty/pull/154) ([cthorn42](https://github.com/cthorn42))
- Minor cleanup to the readme [\#151](https://github.com/puppetlabs/vmfloaty/pull/151) ([genebean](https://github.com/genebean))
- Release prep for 1.5.0 [\#150](https://github.com/puppetlabs/vmfloaty/pull/150) ([genebean](https://github.com/genebean))
## [v1.5.0](https://github.com/puppetlabs/vmfloaty/tree/v1.5.0) (2021-10-12)
[Full Changelog](https://github.com/puppetlabs/vmfloaty/compare/v1.4.0...v1.5.0)
**Merged pull requests:**
- DIO 2412- Ondemand and Priority flag added to SSH command [\#149](https://github.com/puppetlabs/vmfloaty/pull/149) ([tanisha-payne](https://github.com/tanisha-payne))
- \(DIO-2135\) Update docker FROM image to ruby 3.0.2 [\#148](https://github.com/puppetlabs/vmfloaty/pull/148) ([sbeaulie](https://github.com/sbeaulie))
- Migrate CI to GitHub Actions [\#147](https://github.com/puppetlabs/vmfloaty/pull/147) ([genebean](https://github.com/genebean))
- v1.4.0 release prep [\#146](https://github.com/puppetlabs/vmfloaty/pull/146) ([genebean](https://github.com/genebean))
## [v1.4.0](https://github.com/puppetlabs/vmfloaty/tree/v1.4.0) (2021-07-16)
[Full Changelog](https://github.com/puppetlabs/vmfloaty/compare/v1.3.0...v1.4.0)
**Merged pull requests:**
- \(maint\) Use latest Faraday/webmock, update specs [\#145](https://github.com/puppetlabs/vmfloaty/pull/145) ([nmburgan](https://github.com/nmburgan))
- Update commander requirement from \>= 4.4.3, \< 4.6.0 to \>= 4.4.3, \< 4.7.0 [\#140](https://github.com/puppetlabs/vmfloaty/pull/140) ([dependabot[bot]](https://github.com/apps/dependabot))
- Release prep for v1.3.0 [\#137](https://github.com/puppetlabs/vmfloaty/pull/137) ([sbeaulie](https://github.com/sbeaulie))
- Run the rubocop auto\_correct [\#135](https://github.com/puppetlabs/vmfloaty/pull/135) ([sbeaulie](https://github.com/sbeaulie))
## [v1.3.0](https://github.com/puppetlabs/vmfloaty/tree/v1.3.0) (2021-03-03)
[Full Changelog](https://github.com/puppetlabs/vmfloaty/compare/v1.2.0...v1.3.0)
**Merged pull requests:**
- \(DIO-1522\) Show the VM state \(running, destroyed\) and colorize in red… [\#134](https://github.com/puppetlabs/vmfloaty/pull/134) ([sbeaulie](https://github.com/sbeaulie))
- Release prep for 1.2.0 [\#132](https://github.com/puppetlabs/vmfloaty/pull/132) ([genebean](https://github.com/genebean))
- Update rubocop requirement from ~\> 0.52 to ~\> 1.6 [\#124](https://github.com/puppetlabs/vmfloaty/pull/124) ([dependabot[bot]](https://github.com/apps/dependabot))
## [v1.2.0](https://github.com/puppetlabs/vmfloaty/tree/v1.2.0) (2021-02-11)
[Full Changelog](https://github.com/puppetlabs/vmfloaty/compare/v1.1.1...v1.2.0)
**Merged pull requests:**
- \(DIO-908\) Floaty can now report the status of ABS requests [\#131](https://github.com/puppetlabs/vmfloaty/pull/131) ([sbeaulie](https://github.com/sbeaulie))
- Update rspec requirement from ~\> 3.9.0 to ~\> 3.10.0 [\#116](https://github.com/puppetlabs/vmfloaty/pull/116) ([dependabot[bot]](https://github.com/apps/dependabot))
## [v1.1.1](https://github.com/puppetlabs/vmfloaty/tree/v1.1.1) (2020-10-16)
[Full Changelog](https://github.com/puppetlabs/vmfloaty/compare/v1.1.0...v1.1.1)
**Merged pull requests:**
- V1.1.1 [\#112](https://github.com/puppetlabs/vmfloaty/pull/112) ([sbeaulie](https://github.com/sbeaulie))
## [v1.1.0](https://github.com/puppetlabs/vmfloaty/tree/v1.1.0) (2020-10-09)
[Full Changelog](https://github.com/puppetlabs/vmfloaty/compare/v1.0.0...v1.1.0)
**Merged pull requests:**
- \(maint\) Add more uniqueness to jobid and useful termination message [\#107](https://github.com/puppetlabs/vmfloaty/pull/107) ([sbeaulie](https://github.com/sbeaulie))
- \(maint\) Fix bug with detecting ABS service [\#106](https://github.com/puppetlabs/vmfloaty/pull/106) ([sbeaulie](https://github.com/sbeaulie))
- \(maint\) Don't require config file for list --active [\#105](https://github.com/puppetlabs/vmfloaty/pull/105) ([sbeaulie](https://github.com/sbeaulie))
- \(maint\) Don't require configuration file for get [\#104](https://github.com/puppetlabs/vmfloaty/pull/104) ([nwolfe](https://github.com/nwolfe))
- \(maint\) Add vmpooler\_fallback to the get service check [\#103](https://github.com/puppetlabs/vmfloaty/pull/103) ([cthorn42](https://github.com/cthorn42))
- Update completion scripts for `service` subcommands [\#102](https://github.com/puppetlabs/vmfloaty/pull/102) ([scotje](https://github.com/scotje))
- Bump to version 1.0.0 [\#100](https://github.com/puppetlabs/vmfloaty/pull/100) ([genebean](https://github.com/genebean))
## [v1.0.0](https://github.com/puppetlabs/vmfloaty/tree/v1.0.0) (2020-09-22)
[Full Changelog](https://github.com/puppetlabs/vmfloaty/compare/0.11.1...v1.0.0)
**Merged pull requests:**
- \(maint\) Fix for ABS PR\#306 that includes json responses [\#99](https://github.com/puppetlabs/vmfloaty/pull/99) ([sbeaulie](https://github.com/sbeaulie))
- \(maint\) Support any vmpooler for ABS via vmpooler\_fallback [\#98](https://github.com/puppetlabs/vmfloaty/pull/98) ([sbeaulie](https://github.com/sbeaulie))
- \(DIO-991\) Add service command [\#97](https://github.com/puppetlabs/vmfloaty/pull/97) ([genebean](https://github.com/genebean))
- \( DIO-911\) Include job\_id in ABS --json output [\#96](https://github.com/puppetlabs/vmfloaty/pull/96) ([sbeaulie](https://github.com/sbeaulie))
- ABS enables fallback to vmpooler for some scenarios [\#94](https://github.com/puppetlabs/vmfloaty/pull/94) ([sbeaulie](https://github.com/sbeaulie))
- WIP \(DIO-911\) Include job\_id in ABS --json output [\#92](https://github.com/puppetlabs/vmfloaty/pull/92) ([nwolfe](https://github.com/nwolfe))
- \(maint\) Remove warning about missing configuration file [\#91](https://github.com/puppetlabs/vmfloaty/pull/91) ([nwolfe](https://github.com/nwolfe))
- Add tab completion script for zsh and fix bash completion for ABS services [\#90](https://github.com/puppetlabs/vmfloaty/pull/90) ([scotje](https://github.com/scotje))
## [0.11.1](https://github.com/puppetlabs/vmfloaty/tree/0.11.1) (2020-08-20)
[Full Changelog](https://github.com/puppetlabs/vmfloaty/compare/0.10.0...0.11.1)
**Merged pull requests:**
- Update version for 0.11.1 release [\#89](https://github.com/puppetlabs/vmfloaty/pull/89) ([mattkirby](https://github.com/mattkirby))
- \(maint\) Fix using ABS service without a .vmfloaty.yml file [\#88](https://github.com/puppetlabs/vmfloaty/pull/88) ([cthorn42](https://github.com/cthorn42))
- Fix the argument list for nonstandardpooler [\#87](https://github.com/puppetlabs/vmfloaty/pull/87) ([jarretlavallee](https://github.com/jarretlavallee))
- Json output for delete/list + better ABS error handling [\#86](https://github.com/puppetlabs/vmfloaty/pull/86) ([mcdonaldseanp](https://github.com/mcdonaldseanp))
- Bump version for 0.11.0 release [\#85](https://github.com/puppetlabs/vmfloaty/pull/85) ([mattkirby](https://github.com/mattkirby))
- Print all non-success output to STDERR [\#84](https://github.com/puppetlabs/vmfloaty/pull/84) ([austb](https://github.com/austb))
- Update travis.yml [\#83](https://github.com/puppetlabs/vmfloaty/pull/83) ([rooneyshuman](https://github.com/rooneyshuman))
- Bump version to 0.10.0 for release [\#82](https://github.com/puppetlabs/vmfloaty/pull/82) ([mattkirby](https://github.com/mattkirby))
## [0.10.0](https://github.com/puppetlabs/vmfloaty/tree/0.10.0) (2020-08-04)
[Full Changelog](https://github.com/puppetlabs/vmfloaty/compare/v0.9.2-retag-for-gh-actions-for-real...0.10.0)
**Merged pull requests:**
- Update Dependabot config file [\#78](https://github.com/puppetlabs/vmfloaty/pull/78) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
- Update rspec requirement from ~\> 3.5.0 to ~\> 3.9.0 [\#75](https://github.com/puppetlabs/vmfloaty/pull/75) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
- Update commander requirement from ~\> 4.4.3 to \>= 4.4.3, \< 4.6.0 [\#73](https://github.com/puppetlabs/vmfloaty/pull/73) ([dependabot-preview[bot]](https://github.com/apps/dependabot-preview))
- Fix formatting of CODEOWNERS [\#71](https://github.com/puppetlabs/vmfloaty/pull/71) ([genebean](https://github.com/genebean))
- Add Dependabot and Coveralls [\#70](https://github.com/puppetlabs/vmfloaty/pull/70) ([genebean](https://github.com/genebean))
- Update docs [\#69](https://github.com/puppetlabs/vmfloaty/pull/69) ([genebean](https://github.com/genebean))
- Remove old maintainer note [\#68](https://github.com/puppetlabs/vmfloaty/pull/68) ([briancain](https://github.com/briancain))
- Add support for vmpooler on demand provisioning [\#67](https://github.com/puppetlabs/vmfloaty/pull/67) ([mattkirby](https://github.com/mattkirby))
## [v0.9.2-retag-for-gh-actions-for-real](https://github.com/puppetlabs/vmfloaty/tree/v0.9.2-retag-for-gh-actions-for-real) (2020-02-05)
[Full Changelog](https://github.com/puppetlabs/vmfloaty/compare/v0.9.2...v0.9.2-retag-for-gh-actions-for-real)
**Merged pull requests:**
- Update gempush action to remove GPR publish [\#66](https://github.com/puppetlabs/vmfloaty/pull/66) ([highb](https://github.com/highb))
## [v0.9.2](https://github.com/puppetlabs/vmfloaty/tree/v0.9.2) (2020-02-05)
[Full Changelog](https://github.com/puppetlabs/vmfloaty/compare/v0.9.2-retag-for-gh-actions...v0.9.2)
## [v0.9.2-retag-for-gh-actions](https://github.com/puppetlabs/vmfloaty/tree/v0.9.2-retag-for-gh-actions) (2020-02-05)
[Full Changelog](https://github.com/puppetlabs/vmfloaty/compare/v0.9.0...v0.9.2-retag-for-gh-actions)
**Merged pull requests:**
- Bump version.rb to 0.9.2 for release [\#65](https://github.com/puppetlabs/vmfloaty/pull/65) ([highb](https://github.com/highb))
- Create gempush.yml Github Action [\#64](https://github.com/puppetlabs/vmfloaty/pull/64) ([highb](https://github.com/highb))
- Bump faraday dependency for Ruby 2.7 compatibility [\#62](https://github.com/puppetlabs/vmfloaty/pull/62) ([nicklewis](https://github.com/nicklewis))
- SSH Command respects ABS now and tests should fail if the API changes… [\#61](https://github.com/puppetlabs/vmfloaty/pull/61) ([mikkergimenez](https://github.com/mikkergimenez))
- \(QENG-7604\) Add support for Job IDs to ABS delete [\#60](https://github.com/puppetlabs/vmfloaty/pull/60) ([highb](https://github.com/highb))
- Bump version.rb to 0.9.1 [\#59](https://github.com/puppetlabs/vmfloaty/pull/59) ([highb](https://github.com/highb))
- Fix error with delete command for vmpooler and nspooler [\#58](https://github.com/puppetlabs/vmfloaty/pull/58) ([mikkergimenez](https://github.com/mikkergimenez))
## [v0.9.0](https://github.com/puppetlabs/vmfloaty/tree/v0.9.0) (2019-12-17)
[Full Changelog](https://github.com/puppetlabs/vmfloaty/compare/v0.8.2...v0.9.0)
**Implemented enhancements:**
- Add abs vm get [\#53](https://github.com/puppetlabs/vmfloaty/pull/53) ([mikkergimenez](https://github.com/mikkergimenez))
**Fixed bugs:**
- vmfloaty reports an error on latest API version output [\#48](https://github.com/puppetlabs/vmfloaty/issues/48)
**Merged pull requests:**
- ABS will sometimes return null values in the /status/queue endpoint [\#57](https://github.com/puppetlabs/vmfloaty/pull/57) ([mikkergimenez](https://github.com/mikkergimenez))
- Minor version bump to 0.9.0 [\#56](https://github.com/puppetlabs/vmfloaty/pull/56) ([highb](https://github.com/highb))
- Update pooler provider to throw an exception if the API returns non-OK [\#55](https://github.com/puppetlabs/vmfloaty/pull/55) ([highb](https://github.com/highb))
- Update Faraday to 0.15, remove unnecessary headers [\#54](https://github.com/puppetlabs/vmfloaty/pull/54) ([highb](https://github.com/highb))
- change urls in docs to use example.net/.com [\#50](https://github.com/puppetlabs/vmfloaty/pull/50) ([steveax](https://github.com/steveax))
- Rubocop cleanup [\#49](https://github.com/puppetlabs/vmfloaty/pull/49) ([rodjek](https://github.com/rodjek))
## [v0.8.2](https://github.com/puppetlabs/vmfloaty/tree/v0.8.2) (2018-01-05)
[Full Changelog](https://github.com/puppetlabs/vmfloaty/compare/v0.8.1...v0.8.2)
**Merged pull requests:**
- 🎂🎂🎂 Add --json option for `floaty get` [\#47](https://github.com/puppetlabs/vmfloaty/pull/47) ([nicklewis](https://github.com/nicklewis))
## [v0.8.1](https://github.com/puppetlabs/vmfloaty/tree/v0.8.1) (2017-10-24)
[Full Changelog](https://github.com/puppetlabs/vmfloaty/compare/v0.8.0...v0.8.1)
**Merged pull requests:**
- Bump commander version to clear up deprecation warnings [\#46](https://github.com/puppetlabs/vmfloaty/pull/46) ([highb](https://github.com/highb))
## [v0.8.0](https://github.com/puppetlabs/vmfloaty/tree/v0.8.0) (2017-10-13)
[Full Changelog](https://github.com/puppetlabs/vmfloaty/compare/v0.7.9...v0.8.0)
**Closed issues:**
- don't automatically call system pager for help screens [\#20](https://github.com/puppetlabs/vmfloaty/issues/20)
**Merged pull requests:**
- Add configuration for multiple pooler services and integration with nspooler [\#45](https://github.com/puppetlabs/vmfloaty/pull/45) ([caseywilliams](https://github.com/caseywilliams))
## [v0.7.9](https://github.com/puppetlabs/vmfloaty/tree/v0.7.9) (2017-07-31)
[Full Changelog](https://github.com/puppetlabs/vmfloaty/compare/v0.7.8...v0.7.9)
**Closed issues:**
- Handle when vmfloaty cannot reach vmpooler [\#39](https://github.com/puppetlabs/vmfloaty/issues/39)
**Merged pull requests:**
- Add basic bash completion script and framework for others [\#44](https://github.com/puppetlabs/vmfloaty/pull/44) ([scotje](https://github.com/scotje))
- Developersdevelopersdevelopers [\#43](https://github.com/puppetlabs/vmfloaty/pull/43) ([mckern](https://github.com/mckern))
## [v0.7.8](https://github.com/puppetlabs/vmfloaty/tree/v0.7.8) (2016-12-20)
[Full Changelog](https://github.com/puppetlabs/vmfloaty/compare/v0.7.7...v0.7.8)
## [v0.7.7](https://github.com/puppetlabs/vmfloaty/tree/v0.7.7) (2016-12-14)
[Full Changelog](https://github.com/puppetlabs/vmfloaty/compare/v0.7.6...v0.7.7)
## [v0.7.6](https://github.com/puppetlabs/vmfloaty/tree/v0.7.6) (2016-12-09)
[Full Changelog](https://github.com/puppetlabs/vmfloaty/compare/v0.7.5...v0.7.6)
**Closed issues:**
- Improve the help text for floaty commands [\#41](https://github.com/puppetlabs/vmfloaty/issues/41)
- Require force flag for pool requests larger than 5? [\#40](https://github.com/puppetlabs/vmfloaty/issues/40)
## [v0.7.5](https://github.com/puppetlabs/vmfloaty/tree/v0.7.5) (2016-12-06)
[Full Changelog](https://github.com/puppetlabs/vmfloaty/compare/1f86113243eb2e898b21c29892c05477e3487d2d...v0.7.5)
**Implemented enhancements:**
- Improve how to specify number of vms in get request [\#8](https://github.com/puppetlabs/vmfloaty/issues/8)
- Improve output from commands [\#3](https://github.com/puppetlabs/vmfloaty/issues/3)
**Fixed bugs:**
- floaty snapshot fails to authenticate [\#4](https://github.com/puppetlabs/vmfloaty/issues/4)
**Closed issues:**
- floaty snapshot should warn users about how long it takes to get snapshot [\#37](https://github.com/puppetlabs/vmfloaty/issues/37)
- floaty modify should allow to make changes on more than one machine [\#36](https://github.com/puppetlabs/vmfloaty/issues/36)
- Pooler.modify raises exception if Token is nil [\#34](https://github.com/puppetlabs/vmfloaty/issues/34)
- Improve error handling in Pooler and Auth classes [\#33](https://github.com/puppetlabs/vmfloaty/issues/33)
- Handle vmpooler responses when token is invalid in Pooler class [\#32](https://github.com/puppetlabs/vmfloaty/issues/32)
- Misuse of 'floaty revert ...' seems to create a new snapshot [\#31](https://github.com/puppetlabs/vmfloaty/issues/31)
- Test [\#30](https://github.com/puppetlabs/vmfloaty/issues/30)
- Don't system exit in Auth class [\#29](https://github.com/puppetlabs/vmfloaty/issues/29)
- Add flag to auto-ssh into a newly created \(single\) VM [\#28](https://github.com/puppetlabs/vmfloaty/issues/28)
- Handle vmpooler URL key that doesn't have 'https' [\#27](https://github.com/puppetlabs/vmfloaty/issues/27)
- Abstract vmfloaty cli related errors to command class rather than pooler class [\#26](https://github.com/puppetlabs/vmfloaty/issues/26)
- Don't puts results in `delete` method in Pooler library [\#25](https://github.com/puppetlabs/vmfloaty/issues/25)
- Improve `get` output [\#24](https://github.com/puppetlabs/vmfloaty/issues/24)
- specs don't work [\#22](https://github.com/puppetlabs/vmfloaty/issues/22)
- Add ability to get additional disk space for a running vm [\#19](https://github.com/puppetlabs/vmfloaty/issues/19)
- Have a force option for `delete --all` [\#17](https://github.com/puppetlabs/vmfloaty/issues/17)
- Stop printing json response in library methods [\#14](https://github.com/puppetlabs/vmfloaty/issues/14)
- Stop system exiting in library methods [\#13](https://github.com/puppetlabs/vmfloaty/issues/13)
- List active vms for a given token [\#12](https://github.com/puppetlabs/vmfloaty/issues/12)
- Provide a way to clean up vms obtained by a token [\#11](https://github.com/puppetlabs/vmfloaty/issues/11)
- Allow spaces when passing in vms for commands [\#10](https://github.com/puppetlabs/vmfloaty/issues/10)
- Write Tests for Pooler class [\#9](https://github.com/puppetlabs/vmfloaty/issues/9)
- Document all valid config file keys [\#7](https://github.com/puppetlabs/vmfloaty/issues/7)
- Write up simple "introduction" to using the tool [\#6](https://github.com/puppetlabs/vmfloaty/issues/6)
- Document how to use Pooler class for ruby scripts [\#5](https://github.com/puppetlabs/vmfloaty/issues/5)
- Convert vmfloaty to use latest pooler API [\#1](https://github.com/puppetlabs/vmfloaty/issues/1)
**Merged pull requests:**
- Show the status of pools with `floaty status` [\#38](https://github.com/puppetlabs/vmfloaty/pull/38) ([nicklewis](https://github.com/nicklewis))
- Show tag values in `list --active` [\#23](https://github.com/puppetlabs/vmfloaty/pull/23) ([justinstoller](https://github.com/justinstoller))
- \(\#19\) Update vmfloaty to expect /api/v1 in URL for disk endpoint [\#21](https://github.com/puppetlabs/vmfloaty/pull/21) ([briancain](https://github.com/briancain))
- \(\#17\) Add a force option for delete --all [\#18](https://github.com/puppetlabs/vmfloaty/pull/18) ([briancain](https://github.com/briancain))
- \(\#12\) List active vms for a given token [\#16](https://github.com/puppetlabs/vmfloaty/pull/16) ([briancain](https://github.com/briancain))
- Cleanup vmfloaty library and command processor [\#15](https://github.com/puppetlabs/vmfloaty/pull/15) ([briancain](https://github.com/briancain))
- \(\#1\) Update with commander [\#2](https://github.com/puppetlabs/vmfloaty/pull/2) ([briancain](https://github.com/briancain))
\* *This Changelog was automatically generated by [github_changelog_generator](https://github.com/github-changelog-generator/github-changelog-generator)*

View file

@ -1,3 +1,3 @@
# Set the default code owners # Set the default code owners
* @puppetlabs/dio @briancain @highb * @puppetlabs/release-engineering

View file

@ -1,6 +1,23 @@
FROM ruby:2.7 FROM ruby:3.3.5-slim-bullseye
COPY ./ ./ LABEL org.opencontainers.image.authors="@puppetlabs/release-engineering"
LABEL org.opencontainers.image.title="vmfloaty"
LABEL org.opencontainers.image.source=https://github.com/puppetlabs/vmfloaty
LABEL org.opencontainers.image.description="A CLI helper tool for VMPooler"
RUN apt-get update && apt-get install -y less RUN apt-get update -qq && apt-get install -y build-essential less make openssh-client
RUN gem install bundler && bundle install && gem build vmfloaty.gemspec && gem install vmfloaty*.gem
RUN groupadd --gid 1000 floatygroup \
&& useradd --uid 1000 --gid 1000 -m floatyuser
USER floatyuser
WORKDIR /home/floatyuser/app
COPY --chown=floatyuser:floatygroup . .
RUN gem install bundler \
&& bundle install \
&& gem build vmfloaty.gemspec \
&& gem install vmfloaty*.gem
ENTRYPOINT [ "floaty" ]

12
Gemfile
View file

@ -4,13 +4,15 @@ source 'https://rubygems.org'
gemspec gemspec
gem 'rake', :require => false gem 'rake', require: false
group :test do group :test do
gem 'coveralls', '~> 0.8.23' gem 'simplecov', '~> 0.22.0'
gem 'simplecov-html', '~> 0.13.1'
gem 'simplecov-lcov', '~> 0.8.0'
gem 'pry' gem 'pry'
gem 'rb-readline' gem 'rb-readline'
gem 'rspec', '~> 3.9.0' gem 'rspec', '~> 3.13.0'
gem 'rubocop', '~> 0.52' gem 'rubocop', '~> 1.66'
gem 'webmock', '1.21.0' gem 'webmock', '~> 3.23'
end end

125
Gemfile.lock Normal file
View file

@ -0,0 +1,125 @@
PATH
remote: .
specs:
vmfloaty (1.8.1)
commander (>= 4.4.3, < 4.7.0)
faraday (~> 1.5, >= 1.5.1)
GEM
remote: https://rubygems.org/
specs:
addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0)
ast (2.4.2)
bigdecimal (3.1.8)
coderay (1.1.3)
commander (4.6.0)
highline (~> 2.0.0)
crack (1.0.0)
bigdecimal
rexml
diff-lcs (1.5.1)
docile (1.4.0)
faraday (1.10.3)
faraday-em_http (~> 1.0)
faraday-em_synchrony (~> 1.0)
faraday-excon (~> 1.1)
faraday-httpclient (~> 1.0)
faraday-multipart (~> 1.0)
faraday-net_http (~> 1.0)
faraday-net_http_persistent (~> 1.0)
faraday-patron (~> 1.0)
faraday-rack (~> 1.0)
faraday-retry (~> 1.0)
ruby2_keywords (>= 0.0.4)
faraday-em_http (1.0.0)
faraday-em_synchrony (1.0.0)
faraday-excon (1.1.0)
faraday-httpclient (1.0.1)
faraday-multipart (1.0.4)
multipart-post (~> 2)
faraday-net_http (1.0.1)
faraday-net_http_persistent (1.2.0)
faraday-patron (1.0.0)
faraday-rack (1.0.0)
faraday-retry (1.0.3)
hashdiff (1.1.0)
highline (2.0.3)
json (2.7.2)
language_server-protocol (3.17.0.3)
method_source (1.0.0)
multipart-post (2.3.0)
parallel (1.26.3)
parser (3.3.5.0)
ast (~> 2.4.1)
racc
pry (0.14.2)
coderay (~> 1.1)
method_source (~> 1.0)
public_suffix (5.0.5)
racc (1.8.1)
rainbow (3.1.1)
rake (13.2.1)
rb-readline (0.5.5)
regexp_parser (2.9.2)
rexml (3.3.6)
strscan
rspec (3.13.0)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
rspec-mocks (~> 3.13.0)
rspec-core (3.13.0)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.0)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-support (3.13.0)
rubocop (1.66.1)
json (~> 2.3)
language_server-protocol (>= 3.17.0)
parallel (~> 1.10)
parser (>= 3.3.0.2)
rainbow (>= 2.2.2, < 4.0)
regexp_parser (>= 2.4, < 3.0)
rubocop-ast (>= 1.32.2, < 2.0)
ruby-progressbar (~> 1.7)
unicode-display_width (>= 2.4.0, < 3.0)
rubocop-ast (1.32.3)
parser (>= 3.3.1.0)
ruby-progressbar (1.13.0)
ruby2_keywords (0.0.5)
simplecov (0.22.0)
docile (~> 1.1)
simplecov-html (~> 0.11)
simplecov_json_formatter (~> 0.1)
simplecov-html (0.13.1)
simplecov-lcov (0.8.0)
simplecov_json_formatter (0.1.4)
strscan (3.1.0)
unicode-display_width (2.5.0)
webmock (3.23.1)
addressable (>= 2.8.0)
crack (>= 0.3.2)
hashdiff (>= 0.4.0, < 2.0.0)
PLATFORMS
aarch64-linux
x86_64-linux
DEPENDENCIES
pry
rake
rb-readline
rspec (~> 3.13.0)
rubocop (~> 1.66)
simplecov (~> 0.22.0)
simplecov-html (~> 0.13.1)
simplecov-lcov (~> 0.8.0)
vmfloaty!
webmock (~> 3.23)
BUNDLED WITH
2.4.8

141
README.md
View file

@ -1,37 +1,48 @@
# vmfloaty # vmfloaty
[![Gem Version](https://badge.fury.io/rb/vmfloaty.svg)](https://badge.fury.io/rb/vmfloaty) [![Gem Version](https://badge.fury.io/rb/vmfloaty.svg)](https://badge.fury.io/rb/vmfloaty)
[![Build Status](https://travis-ci.com/puppetlabs/vmfloaty.svg?branch=master)](https://travis-ci.com/puppetlabs/vmfloaty) [![Test](https://github.com/puppetlabs/vmfloaty/actions/workflows/test.yml/badge.svg)](https://github.com/puppetlabs/vmfloaty/actions/workflows/test.yml)
[![Coverage Status](https://coveralls.io/repos/github/puppetlabs/vmfloaty/badge.svg?branch=master)](https://coveralls.io/github/puppetlabs/vmfloaty?branch=master)
[![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=puppetlabs/vmfloaty)](https://dependabot.com)
A CLI helper tool for [Puppet's vmpooler](https://github.com/puppetlabs/vmpooler) to help you stay afloat. A CLI helper tool for [Puppet's VMPooler](https://github.com/puppetlabs/vmpooler) to help you stay afloat.
![float image](float.jpg) ![float image](float.jpg)
- [vmfloaty](#vmfloaty)
- [Install](#install) - [Install](#install)
- [Ruby](#ruby)
- [Docker](#docker)
- [Usage](#usage) - [Usage](#usage)
- [Example workflow](#example-workflow) - [Example workflow](#example-workflow)
- [vmfloaty dotfile](#vmfloaty-dotfile) - [vmfloaty dotfile](#vmfloaty-dotfile)
- [Basic configuration](#basic-configuration) - [Basic configuration](#basic-configuration)
- [Default to Puppet's ABS instead of vmpooler](#default-to-puppets-abs-instead-of-vmpooler) - [Using multiple services](#using-multiple-services)
- [Configuring multiple services](#configuring-multiple-services) - [Using backends besides VMPooler](#using-backends-besides-vmpooler)
- [Using a Nonstandard Pooler service](#using-a-nonstandard-pooler-service)
- [Valid config keys](#valid-config-keys) - [Valid config keys](#valid-config-keys)
- [Tab Completion](#tab-completion) - [Tab Completion](#tab-completion)
- [vmpooler API](#vmpooler-api) - [VMPooler API](#vmpooler-api)
- [Using the Pooler class](#using-the-pooler-class) - [Using the Pooler class](#using-the-pooler-class)
- [Example Projects](#example-projects) - [Example Projects](#example-projects)
- [Contributing](#contributing)
- [Code Reviews](#code-reviews)
- [Releasing](#releasing)
- [Special thanks](#special-thanks) - [Special thanks](#special-thanks)
## Install ## Install
### Ruby
Grab the latest from ruby gems... Grab the latest from ruby gems...
```bash ```bash
gem install vmfloaty gem install vmfloaty
``` ```
### Docker
Run the docker image:
`docker run -it --rm -v ~/.vmfloaty.yml:/home/floatyuser/.vmfloaty.yml ghcr.io/puppetlabs/vmfloaty --help`
## Usage ## Usage
```plain ```plain
@ -42,7 +53,7 @@ $ floaty --help
DESCRIPTION: DESCRIPTION:
A CLI helper tool for Puppet's vmpooler to help you stay afloat A CLI helper tool for Puppet's VMPooler to help you stay afloat
COMMANDS: COMMANDS:
@ -54,6 +65,7 @@ $ floaty --help
modify Modify a VM's tags, time to live, disk space, or reservation reason modify Modify a VM's tags, time to live, disk space, or reservation reason
query Get information about a given vm query Get information about a given vm
revert Reverts a vm to a specified snapshot revert Reverts a vm to a specified snapshot
service Display information about floaty services and their configuration
snapshot Takes a snapshot of a given vm snapshot Takes a snapshot of a given vm
ssh Grabs a single vm and sshs into it ssh Grabs a single vm and sshs into it
status Prints the status of pools in the pooler service status Prints the status of pools in the pooler service
@ -90,10 +102,12 @@ floaty get centos-7-x86_64=2 debian-7-x86_64 windows-10=3 --token mytokenstring
### vmfloaty dotfile ### vmfloaty dotfile
If you do not wish to continually specify various config options with the cli, you can have a dotfile in your home directory for some defaults. For example: If you do not wish to continually specify various config options with the cli, you can `~/.vmfloaty.yml` for some defaults. You can get a list of valid service types and example configuration files via `floaty service types` and `floaty service examples`, respectively.
#### Basic configuration #### Basic configuration
This is the simplest type of configuration where you only need a single service:
```yaml ```yaml
# file at ~/.vmfloaty.yml # file at ~/.vmfloaty.yml
url: 'https://vmpooler.example.net/api/v1' url: 'https://vmpooler.example.net/api/v1'
@ -101,84 +115,19 @@ user: 'brian'
token: 'tokenstring' token: 'tokenstring'
``` ```
Now vmfloaty will use those config files if no flag was specified. Run `floaty service examples` to see additional configuration options
#### Default to Puppet's ABS instead of vmpooler #### Using multiple services
```yaml Most commands allow you to specify a `--service <servicename>` option to allow the use of multiple pooler instances. This can be useful when you'd rather not specify a `--url` or `--token` by hand for alternate services.
# file at ~/.vmfloaty.yml
url: 'https://abs.example.net'
user: 'brian'
token: 'tokenstring'
type: 'abs'
```
#### Configuring multiple services
Most commands allow you to specify a `--service <servicename>` option to allow the use of multiple vmpooler instances. This can be useful when you'd rather not specify a `--url` or `--token` by hand for alternate services.
To configure multiple services, you can set up your `~/.vmfloaty.yml` config file like this:
```yaml
# file at /Users/me/.vmfloaty.yml
user: 'brian'
services:
main:
url: 'https://vmpooler.example.net/api/v1'
token: 'tokenstring'
alternate:
url: 'https://vmpooler.example.com/api/v1'
token: 'alternate-tokenstring'
```
- If you run `floaty` without a `--service <name>` option, vmfloaty will use the first configured service by default. - If you run `floaty` without a `--service <name>` option, vmfloaty will use the first configured service by default.
With the config file above, the default would be to use the 'main' vmpooler instance.
- If keys are missing for a configured service, vmfloaty will attempt to fall back to the top-level values. - If keys are missing for a configured service, vmfloaty will attempt to fall back to the top-level values.
With the config file above, 'brian' will be used as the username for both configured services, since neither specifies a username. This makes it so you can specify things like `user` once at the top of your `~/.vmfloaty.yml`.
Examples using the above configuration: #### Using backends besides VMPooler
List available vm types from our main vmpooler instance: vmfloaty supports additional backends besides VMPooler. To see a complete list, run `floaty service types`. The output of `floaty service examples` will show you how to configure each of the supported backends.
```bash
floaty list --service main
# or, since the first configured service is used by default:
floaty list
```
List available vm types from our alternate vmpooler instance:
```bash
floaty list --service alternate
```
#### Using a Nonstandard Pooler service
vmfloaty is capable of working with Puppet's [nonstandard pooler](https://github.com/puppetlabs/nspooler) in addition to the default vmpooler API. To add a nonstandard pooler service, specify an API `type` value in your service configuration, like this:
```yaml
# file at /Users/me/.vmfloaty.yml
user: 'brian'
services:
vm:
url: 'https://vmpooler.example.net/api/v1'
token: 'tokenstring'
ns:
url: 'https://nspooler.example.net/api/v1'
token: 'nspooler-tokenstring'
type: 'nonstandard' # <-- 'type' is necessary for any non-vmpooler service
abs:
url: 'https://abs.example.net/'
token: 'abs-tokenstring'
type: 'abs' # <-- 'type' is necessary for any non-vmpooler service
```
With this configuration, you could list available OS types from nspooler like this:
```bash
floaty list --service ns
```
#### Valid config keys #### Valid config keys
@ -190,6 +139,7 @@ Here are the keys that vmfloaty currently supports:
- url (String) - url (String)
- services (String) - services (String)
- type (String) - type (String)
- vmpooler_fallback (String)
### Tab Completion ### Tab Completion
@ -207,13 +157,19 @@ If you are running on macOS and use Homebrew's `bash-completion` formula, you ca
ln -s $(floaty completion --shell bash) /usr/local/etc/bash_completion.d/floaty ln -s $(floaty completion --shell bash) /usr/local/etc/bash_completion.d/floaty
``` ```
## vmpooler API There is also tab completion for zsh:
This cli tool uses the [vmpooler API](https://github.com/puppetlabs/vmpooler/blob/master/API.md). ```zsh
source $(floaty completion --shell zsh)
```
## VMPooler API
This cli tool uses the [VMPooler API](https://github.com/puppetlabs/vmpooler/blob/master/API.md).
## Using the Pooler class ## Using the Pooler class
vmfloaty providers a `Pooler` class that gives users the ability to make requests to vmpooler without having to write their own requests. It also provides an `Auth` class for managing vmpooler tokens within your application. vmfloaty providers a `Pooler` class that gives users the ability to make requests to VMPooler without having to write their own requests. It also provides an `Auth` class for managing VMPooler tokens within your application.
### Example Projects ### Example Projects
@ -222,6 +178,23 @@ vmfloaty providers a `Pooler` class that gives users the ability to make request
- [Brian Cain: vagrant-vmpooler](https://github.com/briancain/vagrant-vmpooler) - [Brian Cain: vagrant-vmpooler](https://github.com/briancain/vagrant-vmpooler)
- Use Vagrant to manage your vmpooler instances - Use Vagrant to manage your vmpooler instances
## Contributing
PR's are welcome! We always love to see how others think this tool can be made better.
### Code Reviews
Please wait for multiple code owners to sign off on any notable change.
## Releasing
Follow these steps to publish a new GitHub release, build and push the gem to <https://rubygems.org>, and build and push a Docker Image to GitHub Container Registry:
1. Bump the "VERSION" in `lib/vmfloaty/version.rb` appropriately based on changes in `CHANGELOG.md` since the last release.
2. Run `./release-prep` to update `Gemfile.lock` and `CHANGELOG.md`.
3. Commit and push changes to a new branch, then open a pull request against `main` and be sure to add the "maintenance" label.
4. After the pull request is approved and merged, then navigate to <https://github.com/puppetlabs/vmfloaty/actions/workflows/release.yml> --> Run workflow --> select "main" branch --> Run workflow. This will publish a GitHub release, build and push the gem to RubyGems, and build and push a Docker Image to GitHub Container Registry.
## Special thanks ## Special thanks
Special thanks to [Brian Cain](https://github.com/briancain) as he is the original author of vmfloaty! Vast amounts of this code exist thanks to his efforts. Special thanks to [Brian Cain](https://github.com/briancain) as he is the original author of vmfloaty! Vast amounts of this code exist thanks to his efforts.

View file

@ -28,4 +28,4 @@ RuboCop::RakeTask.new(:rubocop) do |task|
end end
# Default task is to run the unit tests # Default task is to run the unit tests
task :default => :spec task default: :spec

View file

@ -2,29 +2,37 @@
_vmfloaty() _vmfloaty()
{ {
local cur prev subcommands template_subcommands hostname_subcommands local cur prev commands template_arg_commands hostname_arg_commands service_subcommands
COMPREPLY=() COMPREPLY=()
cur="${COMP_WORDS[COMP_CWORD]}" cur="${COMP_WORDS[COMP_CWORD]}"
prev="${COMP_WORDS[COMP_CWORD-1]}" prev="${COMP_WORDS[COMP_CWORD-1]}"
subcommands="delete get help list modify query revert snapshot ssh status summary token" commands="delete get help list modify query revert service snapshot ssh status summary token"
template_subcommands="get ssh" template_arg_commands="get ssh"
hostname_subcommands="delete modify query revert snapshot" hostname_arg_commands="delete modify query revert snapshot"
service_subcommands="types examples"
if [[ $cur == -* ]] ; then if [[ $cur == -* ]] ; then
# TODO: option completion # TODO: option completion
COMPREPLY=() COMPREPLY=()
elif [[ $template_subcommands =~ (^| )$prev($| ) ]] ; then elif [[ $template_arg_commands =~ (^| )$prev($| ) ]] ; then
if [[ -z "$_vmfloaty_avail_templates" ]] ; then if [[ -z "$_vmfloaty_avail_templates" ]] ; then
# TODO: need a --hostnameonly equivalent here because the section headers of
# `floaty list` are adding some spurious entries (including files in current
# directory because part of the headers is `**` which is getting expanded)
_vmfloaty_avail_templates=$(floaty list 2>/dev/null) _vmfloaty_avail_templates=$(floaty list 2>/dev/null)
fi fi
COMPREPLY=( $(compgen -W "${_vmfloaty_avail_templates}" -- "${cur}") ) COMPREPLY=( $(compgen -W "${_vmfloaty_avail_templates}" -- "${cur}") )
elif [[ $hostname_subcommands =~ (^| )$prev($| ) ]] ; then elif [[ $hostname_arg_commands =~ (^| )$prev($| ) ]] ; then
_vmfloaty_active_hostnames=$(floaty list --active 2>/dev/null | grep '^-' | cut -d' ' -f2) _vmfloaty_active_hostnames=$(floaty list --active --hostnameonly 2>/dev/null)
COMPREPLY=( $(compgen -W "${_vmfloaty_active_hostnames}" -- "${cur}") ) COMPREPLY=( $(compgen -W "${_vmfloaty_active_hostnames}" -- "${cur}") )
else elif [[ "service" == $prev ]] ; then
COMPREPLY=( $(compgen -W "${subcommands}" -- "${cur}") ) COMPREPLY=( $(compgen -W "${service_subcommands}" -- "${cur}") )
elif [[ $1 == $prev ]] ; then
# only show top level commands we are at root
COMPREPLY=( $(compgen -W "${commands}" -- "${cur}") )
fi fi
} }
complete -F _vmfloaty floaty complete -F _vmfloaty floaty

View file

@ -0,0 +1,43 @@
_floaty()
{
local line commands template_arg_commands hostname_arg_commands service_subcommands
commands="delete get help list modify query revert service snapshot ssh status summary token"
template_arg_commands=("get" "ssh")
hostname_arg_commands=("delete" "modify" "query" "revert" "snapshot")
service_subcommands=("types" "examples")
_arguments -C \
"1: :(${commands})" \
"*::arg:->args"
if ((template_arg_commands[(Ie)$line[1]])); then
_floaty_template_sub
elif ((hostname_arg_commands[(Ie)$line[1]])); then
_floaty_hostname_sub
elif [[ "service" == $line[1] ]]; then
_arguments "1: :(${service_subcommands})"
fi
}
_floaty_template_sub()
{
if [[ -z "$_vmfloaty_avail_templates" ]] ; then
# TODO: need a --hostnameonly equivalent here because the section headers of
# `floaty list` are adding some spurious entries (including files in current
# directory because part of the headers is `**` which is getting expanded)
_vmfloaty_avail_templates=$(floaty list 2>/dev/null)
fi
_arguments "1: :(${_vmfloaty_avail_templates})"
}
_floaty_hostname_sub()
{
_vmfloaty_active_hostnames=$(floaty list --active --hostnameonly 2>/dev/null)
_arguments "1: :(${_vmfloaty_active_hostnames})"
}
compdef _floaty floaty

View file

@ -2,7 +2,6 @@
require 'rubygems' require 'rubygems'
require 'commander' require 'commander'
require 'colorize'
require 'json' require 'json'
require 'pp' require 'pp'
require 'uri' require 'uri'
@ -20,7 +19,8 @@ class Vmfloaty
def run # rubocop:disable Metrics/AbcSize def run # rubocop:disable Metrics/AbcSize
program :version, Vmfloaty::VERSION program :version, Vmfloaty::VERSION
program :description, "A CLI helper tool for Puppet's vmpooler to help you stay afloat" program :description,
"A CLI helper tool for Puppet's vmpooler to help you stay afloat.\n\nConfiguration may be placed in a ~/.vmfloaty.yml file."
config = Conf.read_config config = Conf.read_config
@ -39,8 +39,11 @@ class Vmfloaty
c.option '--force', 'Forces vmfloaty to get requested vms' c.option '--force', 'Forces vmfloaty to get requested vms'
c.option '--json', 'Prints retrieved vms in JSON format' c.option '--json', 'Prints retrieved vms in JSON format'
c.option '--ondemand', 'Requested vms are provisioned upon receival of the request, tracked by a request ID' c.option '--ondemand', 'Requested vms are provisioned upon receival of the request, tracked by a request ID'
c.option '--continue STRING', String, 'resume polling ABS for job_id, for use when the cli was interrupted'
c.option '--loglevel STRING', String, 'the log level to use (debug, info, error)'
c.action do |args, options| c.action do |args, options|
verbose = options.verbose || config['verbose'] verbose = options.verbose || config['verbose']
FloatyLogger.setlevel = options.loglevel if options.loglevel
service = Service.new(options, config) service = Service.new(options, config)
use_token = !options.notoken use_token = !options.notoken
force = options.force force = options.force
@ -52,6 +55,11 @@ class Vmfloaty
os_types = Utils.generate_os_hash(args) os_types = Utils.generate_os_hash(args)
if os_types.empty?
FloatyLogger.error 'No operating systems provided to obtain. See `floaty get --help` for more information on how to get VMs.'
exit 1
end
max_pool_request = 5 max_pool_request = 5
large_pool_requests = os_types.select { |_, v| v > max_pool_request } large_pool_requests = os_types.select { |_, v| v > max_pool_request }
if !large_pool_requests.empty? && !force if !large_pool_requests.empty? && !force
@ -60,12 +68,7 @@ class Vmfloaty
exit 1 exit 1
end end
if os_types.empty? response = service.retrieve(verbose, os_types, use_token, options.ondemand, options.continue)
FloatyLogger.error 'No operating systems provided to obtain. See `floaty get --help` for more information on how to get VMs.'
exit 1
end
response = service.retrieve(verbose, os_types, use_token, options.ondemand)
request_id = response['request_id'] if options.ondemand request_id = response['request_id'] if options.ondemand
response = service.wait_for_request(verbose, request_id) if options.ondemand response = service.wait_for_request(verbose, request_id) if options.ondemand
@ -88,17 +91,26 @@ class Vmfloaty
c.option '--service STRING', String, 'Configured pooler service name' c.option '--service STRING', String, 'Configured pooler service name'
c.option '--active', 'Prints information about active vms for a given token' c.option '--active', 'Prints information about active vms for a given token'
c.option '--json', 'Prints information as JSON' c.option '--json', 'Prints information as JSON'
c.option '--hostnameonly', 'When listing active vms, prints only hostnames, one per line'
c.option '--token STRING', String, 'Token for pooler service' c.option '--token STRING', String, 'Token for pooler service'
c.option '--url STRING', String, 'URL of pooler service' c.option '--url STRING', String, 'URL of pooler service'
c.option '--user STRING', String, 'User to authenticate with'
c.option '--loglevel STRING', String, 'the log level to use (debug, info, error)'
c.action do |args, options| c.action do |args, options|
verbose = options.verbose || config['verbose'] verbose = options.verbose || config['verbose']
FloatyLogger.setlevel = options.loglevel if options.loglevel
service = Service.new(options, config) service = Service.new(options, config)
filter = args[0] filter = args[0]
if options.active if options.active
# list active vms # list active vms
running_vms = service.list_active(verbose) running_vms = if service.type == 'ABS'
# this is actually job_ids
service.list_active_job_ids(verbose, service.url, service.user)
else
service.list_active(verbose)
end
host = URI.parse(service.url).host host = URI.parse(service.url).host
if running_vms.empty? if running_vms.empty?
if options.json if options.json
@ -106,14 +118,16 @@ class Vmfloaty
else else
FloatyLogger.info "You have no running VMs on #{host}" FloatyLogger.info "You have no running VMs on #{host}"
end end
else elsif options.json
if options.json
puts Utils.get_host_data(verbose, service, running_vms).to_json puts Utils.get_host_data(verbose, service, running_vms).to_json
elsif options.hostnameonly
Utils.get_host_data(verbose, service, running_vms).each do |hostname, host_data|
Utils.print_fqdn_for_host(service, hostname, host_data)
end
else else
puts "Your VMs on #{host}:" puts "Your VMs on #{host}:"
Utils.pretty_print_hosts(verbose, service, running_vms) Utils.pretty_print_hosts(verbose, service, running_vms)
end end
end
else else
# list available vms from pooler # list available vms from pooler
os_list = service.list(verbose, filter) os_list = service.list(verbose, filter)
@ -125,7 +139,7 @@ class Vmfloaty
command :query do |c| command :query do |c|
c.syntax = 'floaty query hostname [options]' c.syntax = 'floaty query hostname [options]'
c.summary = 'Get information about a given vm' c.summary = 'Get information about a given vm'
c.description = 'Given a hostname from the pooler service, vmfloaty with query the service to get various details about the vm.' c.description = 'Given a hostname from the pooler service, vmfloaty with query the service to get various details about the vm. If using ABS, you can query a job_id'
c.example 'Get information about a sample host', 'floaty query hostname --url http://vmpooler.example.com' c.example 'Get information about a sample host', 'floaty query hostname --url http://vmpooler.example.com'
c.option '--verbose', 'Enables verbose output' c.option '--verbose', 'Enables verbose output'
c.option '--service STRING', String, 'Configured pooler service name' c.option '--service STRING', String, 'Configured pooler service name'
@ -144,7 +158,8 @@ class Vmfloaty
c.syntax = 'floaty modify hostname [options]' c.syntax = 'floaty modify hostname [options]'
c.summary = 'Modify a VM\'s tags, time to live, disk space, or reservation reason' c.summary = 'Modify a VM\'s tags, time to live, disk space, or reservation reason'
c.description = 'This command makes modifications to the virtual machines state in the pooler service. You can either append tags to the vm, increase how long it stays active for, or increase the amount of disk space.' c.description = 'This command makes modifications to the virtual machines state in the pooler service. You can either append tags to the vm, increase how long it stays active for, or increase the amount of disk space.'
c.example 'Modifies myhost1 to have a TTL of 12 hours and adds a custom tag', 'floaty modify myhost1 --lifetime 12 --url https://myurl --token mytokenstring --tags \'{"tag":"myvalue"}\'' c.example 'Modifies myhost1 to have a TTL of 12 hours and adds a custom tag',
'floaty modify myhost1 --lifetime 12 --url https://myurl --token mytokenstring --tags \'{"tag":"myvalue"}\''
c.option '--verbose', 'Enables verbose output' c.option '--verbose', 'Enables verbose output'
c.option '--service STRING', String, 'Configured pooler service name' c.option '--service STRING', String, 'Configured pooler service name'
c.option '--url STRING', String, 'URL of pooler service' c.option '--url STRING', String, 'URL of pooler service'
@ -164,14 +179,19 @@ class Vmfloaty
FloatyLogger.error 'ERROR: Provide a hostname or specify --all.' FloatyLogger.error 'ERROR: Provide a hostname or specify --all.'
exit 1 exit 1
end end
running_vms = modify_all ? service.list_active(verbose) : hostname.split(',') running_vms =
if modify_all
service.list_active(verbose)
else
hostname.split(',')
end
tags = options.tags ? JSON.parse(options.tags) : nil tags = options.tags ? JSON.parse(options.tags) : nil
modify_hash = { modify_hash = {
:lifetime => options.lifetime, lifetime: options.lifetime,
:disk => options.disk, disk: options.disk,
:tags => tags, tags: tags,
:reason => options.reason, reason: options.reason
} }
modify_hash.delete_if { |_, value| value.nil? } modify_hash.delete_if { |_, value| value.nil? }
@ -179,16 +199,14 @@ class Vmfloaty
ok = true ok = true
modified_hash = {} modified_hash = {}
running_vms.each do |vm| running_vms.each do |vm|
begin
modified_hash[vm] = service.modify(verbose, vm, modify_hash) modified_hash[vm] = service.modify(verbose, vm, modify_hash)
rescue ModifyError => e rescue ModifyError => e
FloatyLogger.error e FloatyLogger.error e
ok = false ok = false
end end
end
if ok if ok
if modify_all if modify_all
puts 'Successfully modified all VMs.' puts "Successfully modified all #{running_vms.count} VMs."
else else
puts "Successfully modified VM #{hostname}." puts "Successfully modified VM #{hostname}."
end end
@ -212,8 +230,12 @@ class Vmfloaty
c.option '--json', 'Outputs hosts scheduled for deletion as JSON' c.option '--json', 'Outputs hosts scheduled for deletion as JSON'
c.option '--token STRING', String, 'Token for pooler service' c.option '--token STRING', String, 'Token for pooler service'
c.option '--url STRING', String, 'URL of pooler service' c.option '--url STRING', String, 'URL of pooler service'
c.option '--user STRING', String, 'User to authenticate with'
c.option '--loglevel STRING', String, 'the log level to use (debug, info, error)'
c.action do |args, options| c.action do |args, options|
verbose = options.verbose || config['verbose'] verbose = options.verbose || config['verbose']
FloatyLogger.setlevel = options.loglevel if options.loglevel
service = Service.new(options, config) service = Service.new(options, config)
hostnames = args[0] hostnames = args[0]
delete_all = options.all delete_all = options.all
@ -223,12 +245,17 @@ class Vmfloaty
successes = [] successes = []
if delete_all if delete_all
running_vms = service.list_active(verbose) running_vms = if service.type == 'ABS'
# this is actually job_ids
service.list_active_job_ids(verbose, service.url, service.user)
else
service.list_active(verbose)
end
if running_vms.empty? if running_vms.empty?
if options.json if options.json
puts {}.to_json puts {}.to_json
else else
FloatyLogger.info "You have no running VMs." FloatyLogger.info 'You have no running VMs.'
end end
else else
confirmed = true confirmed = true
@ -272,7 +299,6 @@ class Vmfloaty
end end
unless successes.empty? unless successes.empty?
FloatyLogger.info unless failures.empty?
if options.json if options.json
puts successes.to_json puts successes.to_json
else else
@ -293,7 +319,8 @@ class Vmfloaty
c.syntax = 'floaty snapshot hostname [options]' c.syntax = 'floaty snapshot hostname [options]'
c.summary = 'Takes a snapshot of a given vm' c.summary = 'Takes a snapshot of a given vm'
c.description = 'Will request a snapshot be taken of the given hostname in the pooler service. This command is known to take a while depending on how much load is on the pooler service.' c.description = 'Will request a snapshot be taken of the given hostname in the pooler service. This command is known to take a while depending on how much load is on the pooler service.'
c.example 'Takes a snapshot for a given host', 'floaty snapshot myvm.example.com --url http://vmpooler.example.com --token a9znth9dn01t416hrguu56ze37t790bl' c.example 'Takes a snapshot for a given host',
'floaty snapshot myvm.example.com --url http://vmpooler.example.com --token a9znth9dn01t416hrguu56ze37t790bl'
c.option '--verbose', 'Enables verbose output' c.option '--verbose', 'Enables verbose output'
c.option '--service STRING', String, 'Configured pooler service name' c.option '--service STRING', String, 'Configured pooler service name'
c.option '--url STRING', String, 'URL of pooler service' c.option '--url STRING', String, 'URL of pooler service'
@ -319,7 +346,8 @@ class Vmfloaty
c.syntax = 'floaty revert hostname snapshot [options]' c.syntax = 'floaty revert hostname snapshot [options]'
c.summary = 'Reverts a vm to a specified snapshot' c.summary = 'Reverts a vm to a specified snapshot'
c.description = 'Given a snapshot SHA, vmfloaty will request a revert to the pooler service to go back to a previous snapshot.' c.description = 'Given a snapshot SHA, vmfloaty will request a revert to the pooler service to go back to a previous snapshot.'
c.example 'Reverts to a snapshot for a given host', 'floaty revert myvm.example.com n4eb4kdtp7rwv4x158366vd9jhac8btq --url http://vmpooler.example.com --token a9znth9dn01t416hrguu56ze37t790bl' c.example 'Reverts to a snapshot for a given host',
'floaty revert myvm.example.com n4eb4kdtp7rwv4x158366vd9jhac8btq --url http://vmpooler.example.com --token a9znth9dn01t416hrguu56ze37t790bl'
c.option '--verbose', 'Enables verbose output' c.option '--verbose', 'Enables verbose output'
c.option '--service STRING', String, 'Configured pooler service name' c.option '--service STRING', String, 'Configured pooler service name'
c.option '--url STRING', String, 'URL of pooler service' c.option '--url STRING', String, 'URL of pooler service'
@ -331,7 +359,9 @@ class Vmfloaty
hostname = args[0] hostname = args[0]
snapshot_sha = args[1] || options.snapshot snapshot_sha = args[1] || options.snapshot
FloatyLogger.info "Two snapshot arguments were given....using snapshot #{snapshot_sha}" if args[1] && options.snapshot if args[1] && options.snapshot
FloatyLogger.info "Two snapshot arguments were given....using snapshot #{snapshot_sha}"
end
begin begin
revert_req = service.revert(verbose, hostname, snapshot_sha) revert_req = service.revert(verbose, hostname, snapshot_sha)
@ -353,8 +383,10 @@ class Vmfloaty
c.option '--service STRING', String, 'Configured pooler service name' c.option '--service STRING', String, 'Configured pooler service name'
c.option '--url STRING', String, 'URL of pooler service' c.option '--url STRING', String, 'URL of pooler service'
c.option '--json', 'Prints status in JSON format' c.option '--json', 'Prints status in JSON format'
c.option '--loglevel STRING', String, 'the log level to use (debug, info, error)'
c.action do |_, options| c.action do |_, options|
verbose = options.verbose || config['verbose'] verbose = options.verbose || config['verbose']
FloatyLogger.setlevel = options.loglevel if options.loglevel
service = Service.new(options, config) service = Service.new(options, config)
if options.json if options.json
pp service.status(verbose) pp service.status(verbose)
@ -436,6 +468,8 @@ class Vmfloaty
c.option '--user STRING', String, 'User to authenticate with' c.option '--user STRING', String, 'User to authenticate with'
c.option '--token STRING', String, 'Token for pooler service' c.option '--token STRING', String, 'Token for pooler service'
c.option '--notoken', 'Makes a request without a token' c.option '--notoken', 'Makes a request without a token'
c.option '--priority STRING', 'Priority for supported backends(ABS) (High(1), Medium(2), Low(3))'
c.option '--ondemand', 'Requested vms are provisioned upon receival of the request, tracked by a request ID'
c.action do |args, options| c.action do |args, options|
verbose = options.verbose || config['verbose'] verbose = options.verbose || config['verbose']
service = Service.new(options, config) service = Service.new(options, config)
@ -450,7 +484,7 @@ class Vmfloaty
FloatyLogger.info "Can't ssh to multiple hosts; Using #{host_os} only..." if args.length > 1 FloatyLogger.info "Can't ssh to multiple hosts; Using #{host_os} only..." if args.length > 1
service.ssh(verbose, host_os, use_token) service.ssh(verbose, host_os, use_token, options.ondemand)
exit 0 exit 0
end end
end end
@ -481,6 +515,70 @@ class Vmfloaty
end end
end end
command :service do |c|
c.syntax = 'floaty service <types examples>'
c.summary = 'Display information about floaty services and their configuration'
c.description = 'Display information about floaty services to aid in setting up a configuration file.'
c.example 'Print a list of the valid service types', 'floaty service types'
c.example 'Print a sample config file with multiple services', 'floaty service examples'
c.example 'list vms from the service named "nspooler-prod"', 'floaty list --service nspooler-prod'
c.action do |args, _options|
action = args.first
example_config = Utils.strip_heredoc(<<-CONFIG)
# Sample ~/.vmfloaty.yml with just vmpooler
user: 'jdoe'
url: 'https://vmpooler.example.net'
token: '456def789'
# Sample ~/.vmfloaty.yml with multiple services
# Note: when the --service is not specified on the command line,
# the first service listed here is selected automatically
user: 'jdoe'
services:
abs-prod:
type: 'abs'
url: 'https://abs.example.net/api/v2'
token: '123abc456'
vmpooler_fallback: 'vmpooler-prod'
nspooler-prod:
type: 'nspooler'
url: 'https://nspooler.example.net'
token: '789ghi012'
vmpooler-dev:
type: 'vmpooler'
url: 'https://vmpooler-dev.example.net'
token: '987dsa654'
vmpooler-prod:
type: 'vmpooler'
url: 'https://vmpooler.example.net'
token: '456def789'
CONFIG
types_output = Utils.strip_heredoc(<<-TYPES)
The values on the left below can be used in ~/.vmfloaty.yml as the value of type:
abs: Puppet's Always Be Scheduling
nspooler: Puppet's Non-standard Pooler, aka NSPooler
vmpooler: Puppet's VMPooler
TYPES
case action
when 'examples'
FloatyLogger.info example_config
when 'types'
FloatyLogger.info types_output
when nil
FloatyLogger.error 'No action provided'
exit 1
else
FloatyLogger.error "Unknown action: #{action}"
exit 1
end
end
end
run! run!
end end
end end

View file

@ -2,6 +2,7 @@
require 'vmfloaty/errors' require 'vmfloaty/errors'
require 'vmfloaty/http' require 'vmfloaty/http'
require 'vmfloaty/utils'
require 'faraday' require 'faraday'
require 'json' require 'json'
@ -36,39 +37,61 @@ class ABS
# } # }
# } # }
# #
@active_hostnames = {} @active_hostnames = {}
def self.list_active(verbose, url, _token, user) def self.list_active_job_ids(verbose, url, user)
all_jobs = [] all_job_ids = []
@active_hostnames = {} @active_hostnames = {}
get_active_requests(verbose, url, user).each do |req_hash| get_active_requests(verbose, url, user).each do |req_hash|
all_jobs.push(req_hash['request']['job']['id']) @active_hostnames[req_hash['request']['job']['id']] = req_hash # full hash saved for later retrieval
@active_hostnames[req_hash['request']['job']['id']] = req_hash all_job_ids.push(req_hash['request']['job']['id'])
end end
all_jobs all_job_ids
end
def self.list_active(verbose, url, _token, user)
hosts = []
get_active_requests(verbose, url, user).each do |req_hash|
next unless req_hash.key?('allocated_resources')
req_hash['allocated_resources'].each do |onehost|
hosts.push(onehost['hostname'])
end
end
hosts
end end
def self.get_active_requests(verbose, url, user) def self.get_active_requests(verbose, url, user)
conn = Http.get_conn(verbose, url) conn = Http.get_conn(verbose, supported_abs_url(url))
res = conn.get 'status/queue' res = conn.get 'status/queue'
if valid_json?(res.body)
requests = JSON.parse(res.body) requests = JSON.parse(res.body)
else
FloatyLogger.warn "Warning: couldn't parse body returned from abs/status/queue"
end
ret_val = [] ret_val = []
requests.each do |req| requests.each do |req|
next if req == 'null' next if req == 'null'
if valid_json?(req) # legacy ABS had another JSON string always-be-scheduling/pull/306
req_hash = JSON.parse(req) req_hash = JSON.parse(req)
elsif req.is_a?(Hash)
req_hash = req
else
FloatyLogger.warn "Warning: couldn't parse request returned from abs/status/queue"
next
end
begin begin
next unless user == req_hash['request']['job']['user'] next unless user == req_hash['request']['job']['user']
ret_val.push(req_hash) ret_val.push(req_hash)
rescue NoMethodError rescue NoMethodError
FloatyLogger.warn "Warning: couldn't parse line returned from abs/status/queue: " FloatyLogger.warn "Warning: couldn't parse user returned from abs/status/queue: "
end end
end end
@ -82,7 +105,7 @@ class ABS
def self.delete(verbose, url, hosts, token, user) def self.delete(verbose, url, hosts, token, user)
# In ABS terms, this is a "returned" host. # In ABS terms, this is a "returned" host.
conn = Http.get_conn(verbose, url) conn = Http.get_conn(verbose, supported_abs_url(url))
conn.headers['X-AUTH-TOKEN'] = token if token conn.headers['X-AUTH-TOKEN'] = token if token
FloatyLogger.info "Trying to delete hosts #{hosts}" if verbose FloatyLogger.info "Trying to delete hosts #{hosts}" if verbose
@ -93,7 +116,7 @@ class ABS
ret_status = {} ret_status = {}
hosts.each do |host| hosts.each do |host|
ret_status[host] = { ret_status[host] = {
'ok' => false, 'ok' => false
} }
end end
@ -109,7 +132,7 @@ class ABS
if hosts.include? vm_name['hostname'] if hosts.include? vm_name['hostname']
if all_job_resources_accounted_for(req_hash['allocated_resources'], hosts) if all_job_resources_accounted_for(req_hash['allocated_resources'], hosts)
ret_status[vm_name['hostname']] = { ret_status[vm_name['hostname']] = {
'ok' => true, 'ok' => true
} }
jobs_to_delete.push(req_hash) jobs_to_delete.push(req_hash)
else else
@ -124,7 +147,7 @@ class ABS
jobs_to_delete.each do |job| jobs_to_delete.each do |job|
req_obj = { req_obj = {
'job_id' => job['request']['job']['id'], 'job_id' => job['request']['job']['id'],
'hosts' => job['allocated_resources'], 'hosts' => job['allocated_resources']
} }
FloatyLogger.info "Deleting #{req_obj}" if verbose FloatyLogger.info "Deleting #{req_obj}" if verbose
@ -140,35 +163,64 @@ class ABS
# List available VMs in ABS # List available VMs in ABS
def self.list(verbose, url, os_filter = nil) def self.list(verbose, url, os_filter = nil)
conn = Http.get_conn(verbose, url) conn = Http.get_conn(verbose, supported_abs_url(url))
os_list = [] os_list = []
res = conn.get 'status/platforms/vmpooler' res = conn.get 'status/platforms/vmpooler'
if valid_json?(res.body)
res_body = JSON.parse(res.body) res_body = JSON.parse(res.body)
if res_body.key?('vmpooler_platforms')
os_list << '*** VMPOOLER Pools ***' os_list << '*** VMPOOLER Pools ***'
os_list += JSON.parse(res_body['vmpooler_platforms']) os_list += if res_body['vmpooler_platforms'].is_a?(String)
JSON.parse(res_body['vmpooler_platforms']) # legacy ABS had another JSON string always-be-scheduling/pull/306
else
res_body['vmpooler_platforms']
end
end
end
res = conn.get 'status/platforms/ondemand_vmpooler' res = conn.get 'status/platforms/ondemand_vmpooler'
if valid_json?(res.body)
res_body = JSON.parse(res.body) res_body = JSON.parse(res.body)
unless res_body['ondemand_vmpooler_platforms'] == '[]' if res_body.key?('ondemand_vmpooler_platforms') && res_body['ondemand_vmpooler_platforms'] != '[]'
os_list << '' os_list << ''
os_list << '*** VMPOOLER ONDEMAND Pools ***' os_list << '*** VMPOOLER ONDEMAND Pools ***'
os_list += JSON.parse(res_body['ondemand_vmpooler_platforms']) if res_body['ondemand_vmpooler_platforms'].is_a?(String)
os_list += JSON.parse(res_body['ondemand_vmpooler_platforms']) # legacy ABS had another JSON string always-be-scheduling/pull/306
else
os_list += res_body['ondemand_vmpooler_platforms']
end
end
end end
res = conn.get 'status/platforms/nspooler' res = conn.get 'status/platforms/nspooler'
if valid_json?(res.body)
res_body = JSON.parse(res.body) res_body = JSON.parse(res.body)
if res_body.key?('nspooler_platforms')
os_list << '' os_list << ''
os_list << '*** NSPOOLER Pools ***' os_list << '*** NSPOOLER Pools ***'
os_list += JSON.parse(res_body['nspooler_platforms']) os_list += if res_body['nspooler_platforms'].is_a?(String)
JSON.parse(res_body['nspooler_platforms']) # legacy ABS had another JSON string always-be-scheduling/pull/306
else
res_body['nspooler_platforms']
end
end
end
res = conn.get 'status/platforms/aws' res = conn.get 'status/platforms/aws'
if valid_json?(res.body)
res_body = JSON.parse(res.body) res_body = JSON.parse(res.body)
if res_body.key?('aws_platforms')
os_list << '' os_list << ''
os_list << '*** AWS Pools ***' os_list << '*** AWS Pools ***'
os_list += JSON.parse(res_body['aws_platforms']) os_list += if res_body['aws_platforms'].is_a?(String)
JSON.parse(res_body['aws_platforms']) # legacy ABS had another JSON string always-be-scheduling/pull/306
else
res_body['aws_platforms']
end
end
end
os_list.delete 'ok' os_list.delete 'ok'
@ -176,7 +228,7 @@ class ABS
end end
# Retrieve an OS from ABS. # Retrieve an OS from ABS.
def self.retrieve(verbose, os_types, token, url, user, options, _ondemand = nil) def self.retrieve(verbose, os_types, token, url, user, config, _ondemand = nil, continue = nil)
# #
# Contents of post must be like: # Contents of post must be like:
# #
@ -193,30 +245,41 @@ class ABS
# } # }
# } # }
conn = Http.get_conn(verbose, url) conn = Http.get_conn(verbose, supported_abs_url(url))
conn.headers['X-AUTH-TOKEN'] = token if token conn.headers['X-AUTH-TOKEN'] = token if token
saved_job_id = DateTime.now.strftime('%Q') saved_job_id = if continue.nil?
"#{user}-#{DateTime.now.strftime('%Q')}"
else
continue
end
req_obj = { req_obj = {
:resources => os_types, resources: os_types,
:job => { job: {
:id => saved_job_id, id: saved_job_id,
:tags => { tags: {
:user => user, user: user
}, }
}, }
} }
if options['priority'] if config['vmpooler_fallback'] # optional and not available as cli flag
req_obj[:priority] = if options['priority'] == 'high' vmpooler_config = Utils.get_vmpooler_service_config(config['vmpooler_fallback'])
# request with this token, on behalf of this user
req_obj[:vm_token] = vmpooler_config['token']
end
if config['priority']
req_obj[:priority] = case config['priority']
when 'high'
1 1
elsif options['priority'] == 'medium' when 'medium'
2 2
elsif options['priority'] == 'low' when 'low'
3 3
else else
options['priority'].to_i config['priority'].to_i
end end
end end
@ -224,34 +287,39 @@ class ABS
# os_string = os_type.map { |os, num| Array(os) * num }.flatten.join('+') # os_string = os_type.map { |os, num| Array(os) * num }.flatten.join('+')
# raise MissingParamError, 'No operating systems provided to obtain.' if os_string.empty? # raise MissingParamError, 'No operating systems provided to obtain.' if os_string.empty?
FloatyLogger.info "Requesting VMs with job_id: #{saved_job_id}. Will retry for up to an hour." FloatyLogger.info "Requesting VMs with job_id: #{saved_job_id} Will retry for up to an hour."
res = conn.post 'request', req_obj.to_json res = conn.post 'request', req_obj.to_json
retries = 360 retries = 360
validate_queue_status_response(res.status, res.body, "Initial request", verbose) status = validate_queue_status_response(res.status, res.body, 'Initial request', verbose)
begin
(1..retries).each do |i| (1..retries).each do |i|
queue_place, res_body = check_queue(conn, saved_job_id, req_obj, verbose) res_body = check_queue(conn, saved_job_id, req_obj, verbose)
return translated(res_body) if res_body return translated(res_body, saved_job_id) if res_body.is_a?(Array) # when we get a response with hostnames
sleep_seconds = 10 if i >= 10 sleep_seconds = 10 if i >= 10
sleep_seconds = i if i < 10 sleep_seconds = i if i < 10
FloatyLogger.info "Waiting #{sleep_seconds} seconds to check if ABS request has been filled. Queue Position: #{queue_place}... (x#{i})" FloatyLogger.info "Waiting #{sleep_seconds}s (x#{i}) #{res_body.strip}"
sleep(sleep_seconds) sleep(sleep_seconds)
end end
rescue SystemExit, Interrupt
FloatyLogger.info "\n\nFloaty interrupted, you can resume polling with\n1) `floaty get [same arguments] and adding the flag --continue #{saved_job_id}` or query the state of the queue via\n2) `floaty query #{saved_job_id}` or delete it via\n3) `floaty delete #{saved_job_id}`"
exit 1
end
nil nil
end end
# #
# We should fix the ABS API to be more like the vmpooler or nspooler api, but for now # We should fix the ABS API to be more like the vmpooler or nspooler api, but for now
# #
def self.translated(res_body) def self.translated(res_body, job_id)
vmpooler_formatted_body = {} vmpooler_formatted_body = { 'job_id' => job_id }
res_body.each do |host| res_body.each do |host|
if vmpooler_formatted_body[host['type']] && vmpooler_formatted_body[host['type']]['hostname'].class == Array if vmpooler_formatted_body[host['type']] && vmpooler_formatted_body[host['type']]['hostname'].instance_of?(Array)
vmpooler_formatted_body[host['type']]['hostname'] << host['hostname'] vmpooler_formatted_body[host['type']]['hostname'] << host['hostname']
else else
vmpooler_formatted_body[host['type']] = { 'hostname' => [host['hostname']] } vmpooler_formatted_body[host['type']] = { 'hostname' => [host['hostname']] }
@ -262,47 +330,47 @@ class ABS
vmpooler_formatted_body vmpooler_formatted_body
end end
def self.check_queue(conn, job_id, req_obj, verbose) def self.check_queue(conn, _job_id, req_obj, verbose)
queue_info_res = conn.get "status/queue/info/#{job_id}"
queue_info = JSON.parse(queue_info_res.body)
res = conn.post 'request', req_obj.to_json res = conn.post 'request', req_obj.to_json
validate_queue_status_response(res.status, res.body, "Check queue request", verbose) status = validate_queue_status_response(res.status, res.body, 'Check queue request', verbose)
unless res.body.empty? || !valid_json?(res.body)
unless res.body.empty?
res_body = JSON.parse(res.body) res_body = JSON.parse(res.body)
return queue_info['queue_place'], res_body return res_body
end end
[queue_info['queue_place'], nil] res.body
end end
def self.snapshot(_verbose, _url, _hostname, _token) def self.snapshot(_verbose, _url, _hostname, _token)
FloatyLogger.info "Can't snapshot with ABS, use '--service vmpooler' (even for vms checked out with ABS)" raise NoMethodError, "Can't snapshot with ABS, use '--service vmpooler' (even for vms checked out with ABS)"
end end
def self.status(verbose, url) def self.status(verbose, url)
conn = Http.get_conn(verbose, url) conn = Http.get_conn(verbose, supported_abs_url(url))
res = conn.get 'status' res = conn.get 'status'
res.body == 'OK' res.body == 'OK'
end end
def self.summary(verbose, url) def self.summary(_verbose, _url)
conn = Http.get_conn(verbose, url) raise NoMethodError, 'summary is not defined for ABS'
res = conn.get 'summary'
JSON.parse(res.body)
end end
def self.query(verbose, url, hostname) def self.query(verbose, url, job_id)
return @active_hostnames if @active_hostnames # return saved hostnames from the last time list_active was run
# preventing having to query the API again.
# This works as long as query is called after list_active
return @active_hostnames if @active_hostnames && !@active_hostnames.empty?
FloatyLogger.info "For vmpooler/snapshot information, use '--service vmpooler' (even for vms checked out with ABS)" # If using the cli query job_id
conn = Http.get_conn(verbose, url) conn = Http.get_conn(verbose, supported_abs_url(url))
queue_info_res = conn.get "status/queue/info/#{job_id}"
res = conn.get "host/#{hostname}" if valid_json?(queue_info_res.body)
JSON.parse(res.body) queue_info = JSON.parse(queue_info_res.body)
else
FloatyLogger.warn "Could not parse the status/queue/info/#{job_id}"
end
queue_info
end end
def self.modify(_verbose, _url, _hostname, _token, _modify_hash) def self.modify(_verbose, _url, _hostname, _token, _modify_hash)
@ -333,4 +401,22 @@ class ABS
raise "HTTP #{status_code}: #{request_name} request to ABS failed!\n#{body}" raise "HTTP #{status_code}: #{request_name} request to ABS failed!\n#{body}"
end end
end end
def self.valid_json?(json)
JSON.parse(json)
true
rescue TypeError, JSON::ParserError => e
false
end
# when missing, adds the required api/v2 in the url
def self.supported_abs_url(url)
expected_ending = 'api/v2'
unless url.include?(expected_ending)
# add a slash if missing
expected_ending = "/#{expected_ending}" if url[-1] != '/'
url = "#{url}#{expected_ending}"
end
url
end
end end

View file

@ -8,7 +8,7 @@ class Conf
begin begin
conf = YAML.load_file("#{Dir.home}/.vmfloaty.yml") conf = YAML.load_file("#{Dir.home}/.vmfloaty.yml")
rescue StandardError rescue StandardError
FloatyLogger.warn "WARNING: There was no config file at #{Dir.home}/.vmfloaty.yml" # ignore
end end
conf conf
end end

View file

@ -21,13 +21,11 @@ class Http
url = "https://#{url}" unless url?(url) url = "https://#{url}" unless url?(url)
conn = Faraday.new(:url => url, :ssl => { :verify => false }) do |faraday| Faraday.new(url: url, ssl: { verify: false }) do |faraday|
faraday.request :url_encoded faraday.request :url_encoded
faraday.response :logger if verbose faraday.response :logger if verbose
faraday.adapter Faraday.default_adapter faraday.adapter Faraday.default_adapter
end end
conn
end end
def self.get_conn_with_auth(verbose, url, user, password) def self.get_conn_with_auth(verbose, url, user, password)
@ -37,13 +35,11 @@ class Http
url = "https://#{url}" unless url?(url) url = "https://#{url}" unless url?(url)
conn = Faraday.new(:url => url, :ssl => { :verify => false }) do |faraday| Faraday.new(url: url, ssl: { verify: false }) do |faraday|
faraday.request :url_encoded faraday.request :url_encoded
faraday.request :basic_auth, user, password faraday.request :basic_auth, user, password
faraday.response :logger if verbose faraday.response :logger if verbose
faraday.adapter Faraday.default_adapter faraday.adapter Faraday.default_adapter
end end
conn
end end
end end

View file

@ -1,3 +1,5 @@
# frozen_string_literal: true
require 'logger' require 'logger'
class FloatyLogger < ::Logger class FloatyLogger < ::Logger
@ -17,10 +19,24 @@ class FloatyLogger < ::Logger
FloatyLogger.logger.error msg FloatyLogger.logger.error msg
end end
def self.setlevel=(level)
level = level.downcase
case level
when 'debug'
logger.level = ::Logger::DEBUG
when 'info'
logger.level = ::Logger::INFO
when 'error'
logger.level = ::Logger::ERROR
else
error('set loglevel to debug, info or error')
end
end
def initialize def initialize
super(STDERR) super($stderr)
self.level = ::Logger::INFO self.level = ::Logger::INFO
self.formatter = proc do |severity, datetime, progname, msg| self.formatter = proc do |_severity, _datetime, _progname, msg|
"#{msg}\n" "#{msg}\n"
end end
end end

View file

@ -22,7 +22,7 @@ class NonstandardPooler
status['reserved_hosts'] || [] status['reserved_hosts'] || []
end end
def self.retrieve(verbose, os_type, token, url, _user, _options, ondemand = nil) def self.retrieve(verbose, os_type, token, url, _user, _options, _ondemand = nil, _continue = nil)
conn = Http.get_conn(verbose, url) conn = Http.get_conn(verbose, url)
conn.headers['X-AUTH-TOKEN'] = token if token conn.headers['X-AUTH-TOKEN'] = token if token
@ -46,7 +46,8 @@ class NonstandardPooler
raise TokenError, 'Token provided was nil; Request cannot be made to modify VM' if token.nil? raise TokenError, 'Token provided was nil; Request cannot be made to modify VM' if token.nil?
modify_hash.each do |key, _value| modify_hash.each do |key, _value|
raise ModifyError, "Configured service type does not support modification of #{key}" unless %i[reason reserved_for_reason].include? key raise ModifyError, "Configured service type does not support modification of #{key}" unless %i[reason
reserved_for_reason].include? key
end end
if modify_hash[:reason] if modify_hash[:reason]

View file

@ -12,13 +12,11 @@ class Pooler
response = conn.get 'vm' response = conn.get 'vm'
response_body = JSON.parse(response.body) response_body = JSON.parse(response.body)
hosts = if os_filter if os_filter
response_body.select { |i| i[/#{os_filter}/] } response_body.select { |i| i[/#{os_filter}/] }
else else
response_body response_body
end end
hosts
end end
def self.list_active(verbose, url, token, _user) def self.list_active(verbose, url, token, _user)
@ -28,7 +26,7 @@ class Pooler
vms vms
end end
def self.retrieve(verbose, os_type, token, url, _user, _options, ondemand = nil) def self.retrieve(verbose, os_type, token, url, _user, _options, ondemand = nil, _continue = nil)
# NOTE: # NOTE:
# Developers can use `Utils.generate_os_hash` to # Developers can use `Utils.generate_os_hash` to
# generate the os_type param. # generate the os_type param.
@ -50,7 +48,10 @@ class Pooler
elsif response.status == 403 elsif response.status == 403
raise "HTTP #{response.status}: Failed to obtain VMs from the pooler at #{url}/vm/#{os_string}. Request exceeds the configured per pool maximum. #{res_body}" raise "HTTP #{response.status}: Failed to obtain VMs from the pooler at #{url}/vm/#{os_string}. Request exceeds the configured per pool maximum. #{res_body}"
else else
raise "HTTP #{response.status}: Failed to obtain VMs from the pooler at #{url}/vm/#{os_string}. #{res_body}" unless ondemand unless ondemand
raise "HTTP #{response.status}: Failed to obtain VMs from the pooler at #{url}/vm/#{os_string}. #{res_body}"
end
raise "HTTP #{response.status}: Failed to obtain VMs from the pooler at #{url}/ondemandvm/#{os_string}. #{res_body}" raise "HTTP #{response.status}: Failed to obtain VMs from the pooler at #{url}/ondemandvm/#{os_string}. #{res_body}"
end end
end end
@ -63,7 +64,7 @@ class Pooler
FloatyLogger.info "waiting for request #{request_id} to be fulfilled" FloatyLogger.info "waiting for request #{request_id} to be fulfilled"
sleep 5 sleep 5
end end
FloatyLogger.info "The request has been fulfilled" FloatyLogger.info 'The request has been fulfilled'
check_ondemandvm(verbose, request_id, url) check_ondemandvm(verbose, request_id, url)
end end
@ -84,8 +85,9 @@ class Pooler
def self.modify(verbose, url, hostname, token, modify_hash) def self.modify(verbose, url, hostname, token, modify_hash)
raise TokenError, 'Token provided was nil. Request cannot be made to modify vm' if token.nil? raise TokenError, 'Token provided was nil. Request cannot be made to modify vm' if token.nil?
modify_hash.keys.each do |key| modify_hash.each_key do |key|
raise ModifyError, "Configured service type does not support modification of #{key}." unless %i[tags lifetime disk].include? key raise ModifyError, "Configured service type does not support modification of #{key}." unless %i[tags lifetime
disk].include? key
end end
conn = Http.get_conn(verbose, url) conn = Http.get_conn(verbose, url)
@ -120,8 +122,7 @@ class Pooler
response = conn.post "vm/#{hostname}/disk/#{disk}" response = conn.post "vm/#{hostname}/disk/#{disk}"
res_body = JSON.parse(response.body) JSON.parse(response.body)
res_body
end end
def self.delete(verbose, url, hosts, token, _user) def self.delete(verbose, url, hosts, token, _user)
@ -145,26 +146,22 @@ class Pooler
def self.status(verbose, url) def self.status(verbose, url)
conn = Http.get_conn(verbose, url) conn = Http.get_conn(verbose, url)
response = conn.get '/status' response = conn.get 'status'
res_body = JSON.parse(response.body) JSON.parse(response.body)
res_body
end end
def self.summary(verbose, url) def self.summary(verbose, url)
conn = Http.get_conn(verbose, url) conn = Http.get_conn(verbose, url)
response = conn.get '/summary' response = conn.get 'summary'
res_body = JSON.parse(response.body) JSON.parse(response.body)
res_body
end end
def self.query(verbose, url, hostname) def self.query(verbose, url, hostname)
conn = Http.get_conn(verbose, url) conn = Http.get_conn(verbose, url)
response = conn.get "vm/#{hostname}" response = conn.get "vm/#{hostname}"
res_body = JSON.parse(response.body) JSON.parse(response.body)
res_body
end end
def self.snapshot(verbose, url, hostname, token) def self.snapshot(verbose, url, hostname, token)
@ -174,8 +171,7 @@ class Pooler
conn.headers['X-AUTH-TOKEN'] = token conn.headers['X-AUTH-TOKEN'] = token
response = conn.post "vm/#{hostname}/snapshot" response = conn.post "vm/#{hostname}/snapshot"
res_body = JSON.parse(response.body) JSON.parse(response.body)
res_body
end end
def self.revert(verbose, url, hostname, token, snapshot_sha) def self.revert(verbose, url, hostname, token, snapshot_sha)
@ -187,7 +183,6 @@ class Pooler
raise "Snapshot SHA provided was nil, could not revert #{hostname}" if snapshot_sha.nil? raise "Snapshot SHA provided was nil, could not revert #{hostname}" if snapshot_sha.nil?
response = conn.post "vm/#{hostname}/snapshot/#{snapshot_sha}" response = conn.post "vm/#{hostname}/snapshot/#{snapshot_sha}"
res_body = JSON.parse(response.body) JSON.parse(response.body)
res_body
end end
end end

View file

@ -7,11 +7,13 @@ require 'vmfloaty/ssh'
class Service class Service
attr_reader :config attr_reader :config
attr_accessor :silent
def initialize(options, config_hash = {}) def initialize(options, config_hash = {})
options ||= Commander::Command::Options.new options ||= Commander::Command::Options.new
@config = Utils.get_service_config config_hash, options @config = Utils.get_service_config config_hash, options
@service_object = Utils.get_service_object @config['type'] @service_object = Utils.get_service_object @config['type']
@silent = false
end end
def method_missing(method_name, *args, &block) def method_missing(method_name, *args, &block)
@ -37,7 +39,7 @@ class Service
def user def user
unless @config['user'] unless @config['user']
FloatyLogger.info "Enter your #{@config['url']} service username:" FloatyLogger.info "Enter your #{@config['url']} service username:"
@config['user'] = STDIN.gets.chomp @config['user'] = $stdin.gets.chomp
end end
@config['user'] @config['user']
end end
@ -75,17 +77,17 @@ class Service
@service_object.list_active verbose, url, token, user @service_object.list_active verbose, url, token, user
end end
def retrieve(verbose, os_types, use_token = true, ondemand = nil) def retrieve(verbose, os_types, use_token = true, ondemand = nil, continue = nil)
FloatyLogger.info 'Requesting a vm without a token...' unless use_token FloatyLogger.info 'Requesting a vm without a token...' unless use_token
token_value = use_token ? token : nil token_value = use_token ? token : nil
@service_object.retrieve verbose, os_types, token_value, url, user, @config, ondemand @service_object.retrieve verbose, os_types, token_value, url, user, @config, ondemand, continue
end end
def wait_for_request(verbose, requestid) def wait_for_request(verbose, requestid)
@service_object.wait_for_request verbose, requestid, url @service_object.wait_for_request verbose, requestid, url
end end
def ssh(verbose, host_os, use_token = true) def ssh(verbose, host_os, use_token = true, ondemand = nil)
token_value = nil token_value = nil
if use_token if use_token
begin begin
@ -95,7 +97,7 @@ class Service
FloatyLogger.info 'Could not get token... requesting vm without a token anyway...' FloatyLogger.info 'Could not get token... requesting vm without a token anyway...'
end end
end end
Ssh.ssh(verbose, self, host_os, token_value) Ssh.ssh(verbose, self, host_os, token_value, ondemand)
end end
def query(verbose, hostname) def query(verbose, hostname)
@ -103,6 +105,7 @@ class Service
end end
def modify(verbose, hostname, modify_hash) def modify(verbose, hostname, modify_hash)
maybe_use_vmpooler
@service_object.modify verbose, url, hostname, token, modify_hash @service_object.modify verbose, url, hostname, token, modify_hash
end end
@ -115,18 +118,35 @@ class Service
end end
def summary(verbose) def summary(verbose)
maybe_use_vmpooler
@service_object.summary verbose, url @service_object.summary verbose, url
end end
def snapshot(verbose, hostname) def snapshot(verbose, hostname)
maybe_use_vmpooler
@service_object.snapshot verbose, url, hostname, token @service_object.snapshot verbose, url, hostname, token
end end
def revert(verbose, hostname, snapshot_sha) def revert(verbose, hostname, snapshot_sha)
maybe_use_vmpooler
@service_object.revert verbose, url, hostname, token, snapshot_sha @service_object.revert verbose, url, hostname, token, snapshot_sha
end end
def disk(verbose, hostname, disk) def disk(verbose, hostname, disk)
maybe_use_vmpooler
@service_object.disk(verbose, url, hostname, token, disk) @service_object.disk(verbose, url, hostname, token, disk)
end end
# some methods do not exist for ABS, and if possible should target the Pooler service
def maybe_use_vmpooler
if @service_object == ABS # this is not an instance
unless silent
FloatyLogger.info 'The service in use is ABS, but the requested method should run against vmpooler directly, using fallback_vmpooler config from ~/.vmfloaty.yml'
self.silent = true
end
@config = Utils.get_vmpooler_service_config(@config['vmpooler_fallback'])
@service_object = Pooler
end
end
end end

View file

@ -14,27 +14,45 @@ class Ssh
nil nil
end end
def self.command_string(verbose, service, host_os, use_token) def self.command_string(verbose, service, host_os, use_token, ondemand = nil)
ssh_path = which('ssh') ssh_path = which('ssh')
raise 'Could not determine path to ssh' unless ssh_path raise 'Could not determine path to ssh' unless ssh_path
os_types = Utils.generate_os_hash([host_os])
os_types = {}
os_types[host_os] = 1 os_types[host_os] = 1
response = service.retrieve(verbose, os_types, use_token) response = service.retrieve(verbose, os_types, use_token, ondemand)
raise "Could not get vm from #{service.type}:\n #{response}" unless response['ok'] raise "Could not get vm from #{service.type}:\n #{response}" unless response['ok']
user = /win/.match?(host_os) ? 'Administrator' : 'root' user = /win/.match?(host_os) ? 'Administrator' : 'root'
if ondemand
requestid = response['request_id']
service.wait_for_request(verbose, requestid)
hosts = service.check_ondemandvm(verbose, requestid, service.url)
if hosts['domain'].nil?
hostname = hosts[host_os]['hostname']
hostname = hosts[host_os]['hostname'][0] if hosts[host_os]['hostname'].is_a?(Array)
else
# Provides backwards compatibility with VMPooler API v1
hostname = "#{hosts[host_os]['hostname']}.#{hosts['domain']}"
hostname = "#{hosts[host_os]['hostname'][0]}.#{hosts['domain']}" if hosts[host_os]['hostname'].is_a?(Array)
end
else
if response['domain'].nil?
hostname = response[host_os]['hostname'] hostname = response[host_os]['hostname']
hostname = response[host_os]['hostname'][0] if response[host_os]['hostname'].is_a?(Array) hostname = response[host_os]['hostname'][0] if response[host_os]['hostname'].is_a?(Array)
hostname = "#{hostname}.#{response['domain']}" unless hostname.end_with?('puppetlabs.net') else
# Provides backwards compatibility with VMPooler API v1
hostname = "#{response[host_os]['hostname']}.#{response['domain']}"
hostname = "#{response[host_os]['hostname'][0]}.#{response['domain']}" if response[host_os]['hostname'].is_a?(Array)
end
end
"#{ssh_path} #{user}@#{hostname}" "#{ssh_path} #{user}@#{hostname}"
end end
def self.ssh(verbose, service, host_os, use_token) def self.ssh(verbose, service, host_os, use_token, ondemand)
cmd = command_string(verbose, service, host_os, use_token) cmd = command_string(verbose, service, host_os, use_token, ondemand)
# TODO: Should this respect more ssh settings? Can it be configured # TODO: Should this respect more ssh settings? Can it be configured
# by users ssh config and does this respect those settings? # by users ssh config and does this respect those settings?
Kernel.exec(cmd) Kernel.exec(cmd)

View file

@ -3,12 +3,13 @@
require 'vmfloaty/abs' require 'vmfloaty/abs'
require 'vmfloaty/nonstandard_pooler' require 'vmfloaty/nonstandard_pooler'
require 'vmfloaty/pooler' require 'vmfloaty/pooler'
require 'vmfloaty/conf'
class Utils class Utils
# TODO: Takes the json response body from an HTTP GET # TODO: Takes the json response body from an HTTP GET
# request and "pretty prints" it # request and "pretty prints" it
def self.standardize_hostnames(response_body) def self.standardize_hostnames(response_body)
# vmpooler response body example when `floaty get` arguments are `ubuntu-1610-x86_64=2 centos-7-x86_64`: # vmpooler api v1 response body example when `floaty get` arguments are `ubuntu-1610-x86_64=2 centos-7-x86_64`:
# { # {
# "ok": true, # "ok": true,
# "domain": "delivery.mycompany.net", # "domain": "delivery.mycompany.net",
@ -20,6 +21,17 @@ class Utils
# } # }
# } # }
# vmpooler api v2 response body example when `floaty get` arguments are `ubuntu-1610-x86_64=2 centos-7-x86_64`:
# {
# "ok": true,
# "ubuntu-1610-x86_64": {
# "hostname": ["gdoy8q3nckuob0i.pooler.example.com", "ctnktsd0u11p9tm.pooler.example.com"]
# },
# "centos-7-x86_64": {
# "hostname": "dlgietfmgeegry2.pooler.example.com"
# }
# }
# nonstandard pooler response body example when `floaty get` arguments are `solaris-11-sparc=2 ubuntu-16.04-power8`: # nonstandard pooler response body example when `floaty get` arguments are `solaris-11-sparc=2 ubuntu-16.04-power8`:
# { # {
# "ok": true, # "ok": true,
@ -38,14 +50,21 @@ class Utils
# "engine"=>"vmpooler" # "engine"=>"vmpooler"
# } # }
raise ArgumentError, "Bad GET response passed to format_hosts: #{response_body.to_json}" unless response_body.delete('ok') unless response_body.delete('ok')
raise ArgumentError,
"Bad GET response passed to format_hosts: #{response_body.to_json}"
end
# vmpooler reports the domain separately from the hostname # vmpooler reports the domain separately from the hostname
domain = response_body.delete('domain') domain = response_body.delete('domain')
result = {} result = {}
filtered_response_body = response_body.reject { |key, _| key == 'request_id' || key == 'ready' } # ABS has a job_id associated with hosts so pass that along
abs_job_id = response_body.delete('job_id')
result['job_id'] = abs_job_id unless abs_job_id.nil?
filtered_response_body = response_body.reject { |key, _| %w[request_id ready].include?(key) }
filtered_response_body.each do |os, value| filtered_response_body.each do |os, value|
hostnames = Array(value['hostname']) hostnames = Array(value['hostname'])
hostnames.map! { |host| "#{host}.#{domain}" } if domain hostnames.map! { |host| "#{host}.#{domain}" } if domain
@ -57,7 +76,8 @@ class Utils
def self.format_host_output(hosts) def self.format_host_output(hosts)
hosts.flat_map do |os, names| hosts.flat_map do |os, names|
names.map { |name| "- #{name} (#{os})" } # Assume hosts are stored in Arrays and ignore everything else
names.map { |name| "- #{name} (#{os})" } if names.is_a? Array
end.join("\n") end.join("\n")
end end
@ -78,27 +98,77 @@ class Utils
os_types os_types
end end
def self.pretty_print_hosts(verbose, service, hostnames = [], print_to_stderr = false) def self.print_fqdn_for_host(service, hostname, host_data)
fetched_data = self.get_host_data(verbose, service, hostnames) case service.type
when 'ABS'
abs_hostnames = []
host_data['allocated_resources'].each do |vm_name, _i|
abs_hostnames << vm_name['hostname']
end
puts abs_hostnames.join("\n")
when 'Pooler'
if host_data['domain'].nil?
puts hostname
else
puts "#{hostname}.#{host_data['domain']}"
end
when 'NonstandardPooler'
puts host_data['fqdn']
else
raise "Invalid service type #{service.type}"
end
end
def self.pretty_print_hosts(verbose, service, hostnames = [], print_to_stderr = false, indent = 0)
output_target = print_to_stderr ? $stderr : $stdout
fetched_data = get_host_data(verbose, service, hostnames)
fetched_data.each do |hostname, host_data| fetched_data.each do |hostname, host_data|
case service.type case service.type
when 'ABS' when 'ABS'
# For ABS, 'hostname' variable is the jobID # For ABS, 'hostname' variable is the jobID
host_data['allocated_resources'].each do |vm_name, _i| #
puts "- [JobID:#{host_data['request']['job']['id']}] #{vm_name['hostname']} (#{vm_name['type']}) <#{host_data['state']}>" # Create a vmpooler service to query each hostname there so as to get the metadata too
output_target.puts "- [JobID:#{host_data['request']['job']['id']}] <#{host_data['state']}>"
host_data['allocated_resources'].each do |allocated_resources, _i|
if (allocated_resources['engine'] == 'vmpooler' || allocated_resources['engine'] == 'ondemand') && service.config['vmpooler_fallback']
vmpooler_service = service.clone
vmpooler_service.silent = true
vmpooler_service.maybe_use_vmpooler
pretty_print_hosts(verbose, vmpooler_service, allocated_resources['hostname'].split('.')[0],
print_to_stderr, indent + 2)
else
# TODO: we could add more specific metadata for the other services, nspooler and aws
output_target.puts " - #{allocated_resources['hostname']} (#{allocated_resources['type']})"
end
end end
when 'Pooler' when 'Pooler'
tag_pairs = [] tag_pairs = []
tag_pairs = host_data['tags'].map { |key, value| "#{key}: #{value}" } unless host_data['tags'].nil? tag_pairs = host_data['tags'].map { |key, value| "#{key}: #{value}" } unless host_data['tags'].nil?
duration = "#{host_data['running']}/#{host_data['lifetime']} hours" duration = "#{host_data['running']}/#{host_data['lifetime']} hours"
metadata = [host_data['template'], duration, *tag_pairs] metadata = [host_data['state'], host_data['template'], duration, *tag_pairs]
puts "- #{hostname}.#{host_data['domain']} (#{metadata.join(', ')})" # For backwards compatibility with vmpooler api v1
message =
if host_data['domain']
"- #{hostname}.#{host_data['domain']} (#{metadata.join(', ')})".gsub(/^/, ' ' * indent)
else
"- #{host_data['fqdn']} (#{metadata.join(', ')})".gsub(/^/, ' ' * indent)
end
if host_data['state'] && host_data['state'] == 'destroyed'
output_target.puts "- DESTROYED #{hostname}.#{host_data['domain']}".gsub(/^/, ' ' * indent)
else
output_target.puts message
end
when 'NonstandardPooler' when 'NonstandardPooler'
line = "- #{host_data['fqdn']} (#{host_data['os_triple']}" line = "- #{host_data['fqdn']} (#{host_data['os_triple']}"
line += ", #{host_data['hours_left_on_reservation']}h remaining" line += ", #{host_data['hours_left_on_reservation']}h remaining"
line += ", reason: #{host_data['reserved_for_reason']}" unless host_data['reserved_for_reason'].empty? line += ", reason: #{host_data['reserved_for_reason']}" unless host_data['reserved_for_reason'].nil? || host_data['reserved_for_reason'].empty?
line += ')' line += ')'
puts line output_target.puts line
else else
raise "Invalid service type #{service.type}" raise "Invalid service type #{service.type}"
end end
@ -109,7 +179,6 @@ class Utils
result = {} result = {}
hostnames = [hostnames] unless hostnames.is_a? Array hostnames = [hostnames] unless hostnames.is_a? Array
hostnames.each do |hostname| hostnames.each do |hostname|
begin
response = service.query(verbose, hostname) response = service.query(verbose, hostname)
host_data = response[hostname] host_data = response[hostname]
if block_given? if block_given?
@ -118,9 +187,7 @@ class Utils
case service.type case service.type
when 'ABS' when 'ABS'
# For ABS, 'hostname' variable is the jobID # For ABS, 'hostname' variable is the jobID
if host_data['state'] == 'allocated' || host_data['state'] == 'filled' result[hostname] = host_data if host_data['state'] == 'allocated' || host_data['state'] == 'filled'
result[hostname] = host_data
end
when 'Pooler' when 'Pooler'
result[hostname] = host_data result[hostname] = host_data
when 'NonstandardPooler' when 'NonstandardPooler'
@ -133,7 +200,6 @@ class Utils
FloatyLogger.error("Something went wrong while trying to gather information on #{hostname}:") FloatyLogger.error("Something went wrong while trying to gather information on #{hostname}:")
FloatyLogger.error(e) FloatyLogger.error(e)
end end
end
result result
end end
@ -148,18 +214,16 @@ class Utils
width = pools.keys.map(&:length).max width = pools.keys.map(&:length).max
pools.each do |name, pool| pools.each do |name, pool|
begin
max = pool['max'] max = pool['max']
ready = pool['ready'] ready = pool['ready']
pending = pool['pending'] pending = pool['pending']
missing = max - ready - pending missing = max - ready - pending
char = 'o' char = 'o'
puts "#{name.ljust(width)} #{(char * ready).green}#{(char * pending).yellow}#{(char * missing).red}" puts "#{name.ljust(width)} #{(char * ready)}#{(char * pending)}#{(char * missing)}"
rescue StandardError => e rescue StandardError => e
FloatyLogger.error "#{name.ljust(width)} #{e.red}" FloatyLogger.error "#{name.ljust(width)} #{e}"
end end
end puts message
puts message.colorize(status_response['status']['ok'] ? :default : :red)
when 'NonstandardPooler' when 'NonstandardPooler'
pools = status_response pools = status_response
pools.delete 'ok' pools.delete 'ok'
@ -167,20 +231,18 @@ class Utils
width = pools.keys.map(&:length).max width = pools.keys.map(&:length).max
pools.each do |name, pool| pools.each do |name, pool|
begin
max = pool['total_hosts'] max = pool['total_hosts']
ready = pool['available_hosts'] ready = pool['available_hosts']
pending = pool['pending'] || 0 # not available for nspooler pending = pool['pending'] || 0 # not available for nspooler
missing = max - ready - pending missing = max - ready - pending
char = 'o' char = 'o'
puts "#{name.ljust(width)} #{(char * ready).green}#{(char * pending).yellow}#{(char * missing).red}" puts "#{name.ljust(width)} #{(char * ready)}#{(char * pending)}#{(char * missing)}"
rescue StandardError => e rescue StandardError => e
FloatyLogger.error "#{name.ljust(width)} #{e.red}" FloatyLogger.error "#{name.ljust(width)} #{e}"
end
end end
when 'ABS' when 'ABS'
FloatyLogger.error 'ABS Not OK' unless status_response FloatyLogger.error 'ABS Not OK' unless status_response
puts 'ABS is OK'.green if status_response puts 'ABS is OK' if status_response
else else
raise "Invalid service type #{service.type}" raise "Invalid service type #{service.type}"
end end
@ -195,12 +257,15 @@ class Utils
end end
def self.get_service_object(type = '') def self.get_service_object(type = '')
nspooler_strings = %w[ns nspooler nonstandard nonstandard_pooler]
abs_strings = %w[abs alwaysbescheduling always_be_scheduling] abs_strings = %w[abs alwaysbescheduling always_be_scheduling]
if nspooler_strings.include? type.downcase nspooler_strings = %w[ns nspooler nonstandard nonstandard_pooler]
NonstandardPooler vmpooler_strings = %w[vmpooler]
elsif abs_strings.include? type.downcase if abs_strings.include? type.downcase
ABS ABS
elsif nspooler_strings.include? type.downcase
NonstandardPooler
elsif vmpooler_strings.include? type.downcase
Pooler
else else
Pooler Pooler
end end
@ -212,7 +277,8 @@ class Utils
'url' => config['url'], 'url' => config['url'],
'user' => config['user'], 'user' => config['user'],
'token' => config['token'], 'token' => config['token'],
'type' => config['type'] || 'vmpooler', 'vmpooler_fallback' => config['vmpooler_fallback'],
'type' => config['type'] || 'vmpooler'
} }
if config['services'] if config['services']
@ -223,7 +289,10 @@ class Utils
service_config.merge! values service_config.merge! values
else else
# If the user provided a service name at the command line, use that service if posible, or fail # If the user provided a service name at the command line, use that service if posible, or fail
raise ArgumentError, "Could not find a configured service named '#{options.service}' in ~/.vmfloaty.yml" unless config['services'][options.service] unless config['services'][options.service]
raise ArgumentError,
"Could not find a configured service named '#{options.service}' in ~/.vmfloaty.yml"
end
# If the service is configured but some values are missing, use the top-level defaults to fill them in # If the service is configured but some values are missing, use the top-level defaults to fill them in
service_config.merge! config['services'][options.service] service_config.merge! config['services'][options.service]
@ -241,4 +310,30 @@ class Utils
service_config service_config
end end
# This method gets the vmpooler service configured in ~/.vmfloaty
def self.get_vmpooler_service_config(vmpooler_fallback)
config = Conf.read_config
# The top-level url, user, and token values in the config file are treated as defaults
service_config = {
'url' => config['url'],
'user' => config['user'],
'token' => config['token'],
'type' => 'vmpooler'
}
# at a minimum, the url needs to be configured
if config['services'] && config['services'][vmpooler_fallback] && config['services'][vmpooler_fallback]['url']
# If the service is configured but some values are missing, use the top-level defaults to fill them in
service_config.merge! config['services'][vmpooler_fallback]
elsif vmpooler_fallback.nil?
raise ArgumentError,
"The abs service should have a key named 'vmpooler_fallback' in ~/.vmfloaty.yml with a value that points to a vmpooler service name use this format:\nservices:\n myabs:\n url: 'http://abs.com'\n user: 'superman'\n token: 'kryptonite'\n vmpooler_fallback: 'myvmpooler'\n myvmpooler:\n url: 'http://vmpooler.com'\n user: 'superman'\n token: 'kryptonite'"
else
raise ArgumentError,
"Could not find a configured service named '#{vmpooler_fallback}' in ~/.vmfloaty.yml use this format:\nservices:\n #{vmpooler_fallback}:\n url: 'http://vmpooler.com'\n user: 'superman'\n token: 'kryptonite'"
end
service_config
end
end end

View file

@ -1,5 +1,5 @@
# frozen_string_literal: true # frozen_string_literal: true
class Vmfloaty class Vmfloaty
VERSION = '0.11.1' VERSION = '1.8.1'
end end

12
release-prep Executable file
View file

@ -0,0 +1,12 @@
#!/usr/bin/env bash
# bundle install
docker run -t --rm \
-v $(pwd):/app \
$(grep ^FROM ./Dockerfile |cut -d ' ' -f2) \
/bin/bash -c 'apt-get update -qq && apt-get install -y --no-install-recommends build-essential make openssh-client && cd /app && gem install bundler && bundle install --jobs 3; echo "LOCK_FILE_UPDATE_EXIT_CODE=$?"'
# Update Changelog
docker run -t --rm -e CHANGELOG_GITHUB_TOKEN -v $(pwd):/usr/local/src/your-app \
githubchangeloggenerator/github-changelog-generator:1.16.2 \
github_changelog_generator --future-release $(grep VERSION lib/vmfloaty/version.rb |rev |cut -d "'" -f2 |rev)

View file

@ -1,12 +1,21 @@
# frozen_string_literal: true # frozen_string_literal: true
require 'simplecov' require 'simplecov'
require 'coveralls' require 'simplecov-lcov'
require 'base64'
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new([ SimpleCov::Formatter::LcovFormatter.config do |c|
c.report_with_single_file = true
c.single_report_path = 'coverage/lcov.info'
end
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
[
SimpleCov::Formatter::HTMLFormatter, SimpleCov::Formatter::HTMLFormatter,
Coveralls::SimpleCov::Formatter SimpleCov::Formatter::LcovFormatter
]) ]
)
SimpleCov.start do SimpleCov.start do
add_filter %r{^/spec/} add_filter %r{^/spec/}
end end
@ -26,3 +35,19 @@ RSpec.configure do |config|
config.tty = true config.tty = true
config.formatter = :documentation config.formatter = :documentation
end end
def get_headers(username: nil, password: nil, token: nil, content_type: nil, content_length: nil)
headers = {
'Accept' => '*/*',
'Accept-Encoding' => /gzip/,
'User-Agent' => /Faraday/,
}
if username && password
auth = Base64.encode64("#{username}:#{password}").chomp
headers['Authorization'] = "Basic #{auth}"
end
headers['X-Auth-Token'] = token if token
headers['Content-Type'] = content_type if content_type
headers['Content-Length'] = content_length.to_s if content_length
headers
end

View file

@ -3,7 +3,11 @@
require 'spec_helper' require 'spec_helper'
require_relative '../../../lib/vmfloaty/auth' require_relative '../../../lib/vmfloaty/auth'
user = 'first.last'
pass = 'password'
describe Pooler do describe Pooler do
before :each do before :each do
@abs_url = 'https://abs.example.com/api/v2' @abs_url = 'https://abs.example.com/api/v2'
end end
@ -15,18 +19,20 @@ describe Pooler do
end end
it 'returns a token from abs' do it 'returns a token from abs' do
stub_request(:post, 'https://first.last:password@abs.example.com/api/v2/token') stub_request(:post, 'https://abs.example.com/api/v2/token')
.to_return(:status => 200, :body => @get_token_response, :headers => {}) .with(headers: get_headers(username: user, password: pass, content_length: 0))
.to_return(status: 200, body: @get_token_response, headers: {})
token = Auth.get_token(false, @abs_url, 'first.last', 'password') token = Auth.get_token(false, @abs_url, user, pass)
expect(token).to eq @token expect(token).to eq @token
end end
it 'raises a token error if something goes wrong' do it 'raises a token error if something goes wrong' do
stub_request(:post, 'https://first.last:password@abs.example.com/api/v2/token') stub_request(:post, 'https://abs.example.com/api/v2/token')
.to_return(:status => 500, :body => '{"ok":false}', :headers => {}) .with(headers: get_headers(username: user, password: pass, content_length: 0))
.to_return(status: 500, body: '{"ok":false}', headers: {})
expect { Auth.get_token(false, @abs_url, 'first.last', 'password') }.to raise_error(TokenError) expect { Auth.get_token(false, @abs_url, user, pass) }.to raise_error(TokenError)
end end
end end
@ -37,21 +43,24 @@ describe Pooler do
end end
it 'deletes the specified token' do it 'deletes the specified token' do
stub_request(:delete, 'https://first.last:password@abs.example.com/api/v2/token/utpg2i2xswor6h8ttjhu3d47z53yy47y') stub_request(:delete, 'https://abs.example.com/api/v2/token/utpg2i2xswor6h8ttjhu3d47z53yy47y')
.to_return(:status => 200, :body => @delete_token_response, :headers => {}) .with(headers: get_headers(username: user, password: pass))
.to_return(status: 200, body: @delete_token_response, headers: {})
expect(Auth.delete_token(false, @abs_url, 'first.last', 'password', @token)).to eq JSON.parse(@delete_token_response) expect(Auth.delete_token(false, @abs_url, user, pass,
@token)).to eq JSON.parse(@delete_token_response)
end end
it 'raises a token error if something goes wrong' do it 'raises a token error if something goes wrong' do
stub_request(:delete, 'https://first.last:password@abs.example.com/api/v2/token/utpg2i2xswor6h8ttjhu3d47z53yy47y') stub_request(:delete, 'https://abs.example.com/api/v2/token/utpg2i2xswor6h8ttjhu3d47z53yy47y')
.to_return(:status => 500, :body => '{"ok":false}', :headers => {}) .with(headers: get_headers(username: user, password: pass))
.to_return(status: 500, body: '{"ok":false}', headers: {})
expect { Auth.delete_token(false, @abs_url, 'first.last', 'password', @token) }.to raise_error(TokenError) expect { Auth.delete_token(false, @abs_url, user, pass, @token) }.to raise_error(TokenError)
end end
it 'raises a token error if no token provided' do it 'raises a token error if no token provided' do
expect { Auth.delete_token(false, @abs_url, 'first.last', 'password', nil) }.to raise_error(TokenError) expect { Auth.delete_token(false, @abs_url, user, pass, nil) }.to raise_error(TokenError)
end end
end end
@ -63,16 +72,16 @@ describe Pooler do
it 'checks the status of a token' do it 'checks the status of a token' do
stub_request(:get, "#{@abs_url}/token/utpg2i2xswor6h8ttjhu3d47z53yy47y") stub_request(:get, "#{@abs_url}/token/utpg2i2xswor6h8ttjhu3d47z53yy47y")
.with(:headers => { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3' }) .with(headers: get_headers)
.to_return(:status => 200, :body => @token_status_response, :headers => {}) .to_return(status: 200, body: @token_status_response, headers: {})
expect(Auth.token_status(false, @abs_url, @token)).to eq JSON.parse(@token_status_response) expect(Auth.token_status(false, @abs_url, @token)).to eq JSON.parse(@token_status_response)
end end
it 'raises a token error if something goes wrong' do it 'raises a token error if something goes wrong' do
stub_request(:get, "#{@abs_url}/token/utpg2i2xswor6h8ttjhu3d47z53yy47y") stub_request(:get, "#{@abs_url}/token/utpg2i2xswor6h8ttjhu3d47z53yy47y")
.with(:headers => { 'Accept' => '*/*', 'Accept-Encoding' => 'gzip;q=1.0,deflate;q=0.6,identity;q=0.3' }) .with(headers: get_headers)
.to_return(:status => 500, :body => '{"ok":false}', :headers => {}) .to_return(status: 500, body: '{"ok":false}', headers: {})
expect { Auth.token_status(false, @abs_url, @token) }.to raise_error(TokenError) expect { Auth.token_status(false, @abs_url, @token) }.to raise_error(TokenError)
end end

View file

@ -9,26 +9,78 @@ describe ABS do
before :each do before :each do
end end
describe '#list' do
it 'skips empty platforms and lists aws' do
stub_request(:get, 'http://foo/api/v2/status/platforms/vmpooler')
.to_return(status: 200, body: '', headers: {})
stub_request(:get, 'http://foo/api/v2/status/platforms/ondemand_vmpooler')
.to_return(status: 200, body: '', headers: {})
stub_request(:get, 'http://foo/api/v2/status/platforms/nspooler')
.to_return(status: 200, body: '', headers: {})
body = '{
"aws_platforms": [
"amazon-6-x86_64",
"amazon-7-x86_64",
"amazon-7-arm64",
"centos-7-x86-64-west",
"redhat-8-arm64"
]
}'
stub_request(:get, 'http://foo/api/v2/status/platforms/aws')
.to_return(status: 200, body: body, headers: {})
results = ABS.list(false, 'http://foo')
expect(results).to include('amazon-6-x86_64', 'amazon-7-x86_64', 'amazon-7-arm64', 'centos-7-x86-64-west',
'redhat-8-arm64')
end
it 'legacy JSON string, prior to PR 306' do
stub_request(:get, 'http://foo/api/v2/status/platforms/vmpooler')
.to_return(status: 200, body: '', headers: {})
stub_request(:get, 'http://foo/api/v2/status/platforms/ondemand_vmpooler')
.to_return(status: 200, body: '', headers: {})
stub_request(:get, 'http://foo/api/v2/status/platforms/nspooler')
.to_return(status: 200, body: '', headers: {})
body = '{
"aws_platforms": "[\"amazon-6-x86_64\",\"amazon-7-x86_64\",\"amazon-7-arm64\",\"centos-7-x86-64-west\",\"redhat-8-arm64\"]"
}'
stub_request(:get, 'http://foo/api/v2/status/platforms/aws')
.to_return(status: 200, body: body, headers: {})
results = ABS.list(false, 'http://foo')
expect(results).to include('amazon-6-x86_64', 'amazon-7-x86_64', 'amazon-7-arm64', 'centos-7-x86-64-west',
'redhat-8-arm64')
end
end
describe '#format' do describe '#format' do
it 'returns an hash formatted like a vmpooler return' do it 'returns an hash formatted like a vmpooler return, plus the job_id' do
job_id = 'generated_by_floaty_12345'
abs_formatted_response = [ abs_formatted_response = [
{ 'hostname' => 'aaaaaaaaaaaaaaa.delivery.puppetlabs.net', 'type' => 'centos-7.2-x86_64', 'engine' => 'vmpooler' }, { 'hostname' => 'aaaaaaaaaaaaaaa.delivery.puppetlabs.net', 'type' => 'centos-7.2-x86_64',
{ 'hostname' => 'aaaaaaaaaaaaaab.delivery.puppetlabs.net', 'type' => 'centos-7.2-x86_64', 'engine' => 'vmpooler' }, 'engine' => 'vmpooler' },
{ 'hostname' => 'aaaaaaaaaaaaaac.delivery.puppetlabs.net', 'type' => 'ubuntu-7.2-x86_64', 'engine' => 'vmpooler' }, { 'hostname' => 'aaaaaaaaaaaaaab.delivery.puppetlabs.net', 'type' => 'centos-7.2-x86_64',
'engine' => 'vmpooler' },
{ 'hostname' => 'aaaaaaaaaaaaaac.delivery.puppetlabs.net', 'type' => 'ubuntu-7.2-x86_64',
'engine' => 'vmpooler' }
] ]
vmpooler_formatted_response = ABS.translated(abs_formatted_response) vmpooler_formatted_response = ABS.translated(abs_formatted_response, job_id)
vmpooler_formatted_compare = { vmpooler_formatted_compare = {
'centos-7.2-x86_64' => {}, 'centos-7.2-x86_64' => {},
'ubuntu-7.2-x86_64' => {}, 'ubuntu-7.2-x86_64' => {}
} }
vmpooler_formatted_compare['centos-7.2-x86_64']['hostname'] = ['aaaaaaaaaaaaaaa.delivery.puppetlabs.net', 'aaaaaaaaaaaaaab.delivery.puppetlabs.net'] vmpooler_formatted_compare['centos-7.2-x86_64']['hostname'] =
['aaaaaaaaaaaaaaa.delivery.puppetlabs.net', 'aaaaaaaaaaaaaab.delivery.puppetlabs.net']
vmpooler_formatted_compare['ubuntu-7.2-x86_64']['hostname'] = ['aaaaaaaaaaaaaac.delivery.puppetlabs.net'] vmpooler_formatted_compare['ubuntu-7.2-x86_64']['hostname'] = ['aaaaaaaaaaaaaac.delivery.puppetlabs.net']
vmpooler_formatted_compare['ok'] = true vmpooler_formatted_compare['ok'] = true
vmpooler_formatted_compare['job_id'] = job_id
expect(vmpooler_formatted_response).to eq(vmpooler_formatted_compare) expect(vmpooler_formatted_response).to eq(vmpooler_formatted_compare)
vmpooler_formatted_response.delete('ok') vmpooler_formatted_response.delete('ok')
vmpooler_formatted_compare.delete('ok') vmpooler_formatted_compare.delete('ok')
@ -39,22 +91,22 @@ describe ABS do
hosts = ['host1'] hosts = ['host1']
allocated_resources = [ allocated_resources = [
{ {
'hostname' => 'host1', 'hostname' => 'host1'
}, },
{ {
'hostname' => 'host2', 'hostname' => 'host2'
}, }
] ]
expect(ABS.all_job_resources_accounted_for(allocated_resources, hosts)).to eq(false) expect(ABS.all_job_resources_accounted_for(allocated_resources, hosts)).to eq(false)
hosts = ['host1', 'host2'] hosts = %w[host1 host2]
allocated_resources = [ allocated_resources = [
{ {
'hostname' => 'host1', 'hostname' => 'host1'
}, },
{ {
'hostname' => 'host2', 'hostname' => 'host2'
}, }
] ]
expect(ABS.all_job_resources_accounted_for(allocated_resources, hosts)).to eq(true) expect(ABS.all_job_resources_accounted_for(allocated_resources, hosts)).to eq(true)
end end
@ -68,9 +120,9 @@ describe ABS do
# rubocop:disable Layout/LineLength # rubocop:disable Layout/LineLength
@active_requests_response = ' @active_requests_response = '
[ [
"{ \"state\":\"allocated\",\"last_processed\":\"2019-12-16 23:00:34 +0000\",\"allocated_resources\":[{\"hostname\":\"take-this.delivery.puppetlabs.net\",\"type\":\"win-2012r2-x86_64\",\"engine\":\"vmpooler\"}],\"audit_log\":{\"2019-12-13 16:45:29 +0000\":\"Allocated take-this.delivery.puppetlabs.net for job 1576255517241\"},\"request\":{\"resources\":{\"win-2012r2-x86_64\":1},\"job\":{\"id\":\"1576255517241\",\"tags\":{\"user\":\"test-user\"},\"user\":\"test-user\",\"time-received\":1576255519},\"priority\":1}}", { "state":"allocated","last_processed":"2019-12-16 23:00:34 +0000","allocated_resources":[{"hostname":"take-this.delivery.puppetlabs.net","type":"win-2012r2-x86_64","engine":"vmpooler"}],"audit_log":{"2019-12-13 16:45:29 +0000":"Allocated take-this.delivery.puppetlabs.net for job 1576255517241"},"request":{"resources":{"win-2012r2-x86_64":1},"job":{"id":"1576255517241","tags":{"user":"test-user"},"user":"test-user","time-received":1576255519},"priority":1}},
"null", "null",
"{\"state\":\"allocated\",\"last_processed\":\"2019-12-16 23:00:34 +0000\",\"allocated_resources\":[{\"hostname\":\"not-this.delivery.puppetlabs.net\",\"type\":\"win-2012r2-x86_64\",\"engine\":\"vmpooler\"}],\"audit_log\":{\"2019-12-13 16:46:14 +0000\":\"Allocated not-this.delivery.puppetlabs.net for job 1576255565159\"},\"request\":{\"resources\":{\"win-2012r2-x86_64\":1},\"job\":{\"id\":\"1576255565159\",\"tags\":{\"user\":\"not-test-user\"},\"user\":\"not-test-user\",\"time-received\":1576255566},\"priority\":1}}" {"state":"allocated","last_processed":"2019-12-16 23:00:34 +0000","allocated_resources":[{"hostname":"not-this.delivery.puppetlabs.net","type":"win-2012r2-x86_64","engine":"vmpooler"}],"audit_log":{"2019-12-13 16:46:14 +0000":"Allocated not-this.delivery.puppetlabs.net for job 1576255565159"},"request":{"resources":{"win-2012r2-x86_64":1},"job":{"id":"1576255565159","tags":{"user":"not-test-user"},"user":"not-test-user","time-received":1576255566},"priority":1}}
]' ]'
# rubocop:enable Layout/LineLength # rubocop:enable Layout/LineLength
@token = 'utpg2i2xswor6h8ttjhu3d47z53yy47y' @token = 'utpg2i2xswor6h8ttjhu3d47z53yy47y'
@ -78,8 +130,8 @@ describe ABS do
end end
it 'will skip a line with a null value returned from abs' do it 'will skip a line with a null value returned from abs' do
stub_request(:get, 'https://abs.example.com/status/queue') stub_request(:get, 'https://abs.example.com/api/v2/status/queue')
.to_return(:status => 200, :body => @active_requests_response, :headers => {}) .to_return(status: 200, body: @active_requests_response, headers: {})
ret = ABS.get_active_requests(false, @abs_url, @test_user) ret = ABS.get_active_requests(false, @abs_url, @test_user)
@ -87,8 +139,8 @@ describe ABS do
'allocated_resources' => [{ 'allocated_resources' => [{
'hostname' => 'take-this.delivery.puppetlabs.net', 'hostname' => 'take-this.delivery.puppetlabs.net',
'type' => 'win-2012r2-x86_64', 'type' => 'win-2012r2-x86_64',
'engine' => 'vmpooler', 'engine' => 'vmpooler'
}], }]
) )
end end
end end
@ -98,9 +150,13 @@ describe ABS do
# rubocop:disable Layout/LineLength # rubocop:disable Layout/LineLength
@active_requests_response = ' @active_requests_response = '
[ [
"{ \"state\":\"allocated\", \"last_processed\":\"2020-01-17 22:29:13 +0000\", \"allocated_resources\":[{\"hostname\":\"craggy-chord.delivery.puppetlabs.net\", \"type\":\"centos-7-x86_64\", \"engine\":\"vmpooler\"}, {\"hostname\":\"visible-revival.delivery.puppetlabs.net\", \"type\":\"centos-7-x86_64\", \"engine\":\"vmpooler\"}], \"audit_log\":{\"2020-01-17 22:28:45 +0000\":\"Allocated craggy-chord.delivery.puppetlabs.net, visible-revival.delivery.puppetlabs.net for job 1579300120799\"}, \"request\":{\"resources\":{\"centos-7-x86_64\":2}, \"job\":{\"id\":\"1579300120799\", \"tags\":{\"user\":\"test-user\"}, \"user\":\"test-user\", \"time-received\":1579300120}, \"priority\":3}}" { "state":"allocated", "last_processed":"2020-01-17 22:29:13 +0000", "allocated_resources":[{"hostname":"craggy-chord.delivery.puppetlabs.net", "type":"centos-7-x86_64", "engine":"vmpooler"}, {"hostname":"visible-revival.delivery.puppetlabs.net", "type":"centos-7-x86_64", "engine":"vmpooler"}], "audit_log":{"2020-01-17 22:28:45 +0000":"Allocated craggy-chord.delivery.puppetlabs.net, visible-revival.delivery.puppetlabs.net for job 1579300120799"}, "request":{"resources":{"centos-7-x86_64":2}, "job":{"id":"1579300120799", "tags":{"user":"test-user"}, "user":"test-user", "time-received":1579300120}, "priority":3}}
]' ]'
@return_request = { '{"job_id":"1579300120799","hosts":{"hostname":"craggy-chord.delivery.puppetlabs.net","type":"centos-7-x86_64","engine":"vmpooler"},{"hostname":"visible-revival.delivery.puppetlabs.net","type":"centos-7-x86_64","engine":"vmpooler"}}'=>true } @return_request = {
"job_id" => "1579300120799",
"hosts" => [{"hostname"=>"craggy-chord.delivery.puppetlabs.net","type"=>"centos-7-x86_64","engine"=>"vmpooler"},
{"hostname"=>"visible-revival.delivery.puppetlabs.net","type"=>"centos-7-x86_64","engine"=>"vmpooler"}]
}
# rubocop:enable Layout/LineLength # rubocop:enable Layout/LineLength
@token = 'utpg2i2xswor6h8ttjhu3d47z53yy47y' @token = 'utpg2i2xswor6h8ttjhu3d47z53yy47y'
@test_user = 'test-user' @test_user = 'test-user'
@ -109,16 +165,16 @@ describe ABS do
end end
it 'will delete the whole job' do it 'will delete the whole job' do
stub_request(:get, 'https://abs.example.com/status/queue') stub_request(:get, 'https://abs.example.com/api/v2/status/queue')
.to_return(:status => 200, :body => @active_requests_response, :headers => {}) .to_return(status: 200, body: @active_requests_response, headers: {})
stub_request(:post, 'https://abs.example.com/return') stub_request(:post, 'https://abs.example.com/api/v2/return')
.with(:body => @return_request) .with(headers: get_headers(content_type: 'application/x-www-form-urlencoded', token: @token), body: @return_request.to_json)
.to_return(:status => 200, :body => 'OK', :headers => {}) .to_return(status: 200, body: 'OK', headers: {})
ret = ABS.delete(false, @abs_url, @hosts, @token, @test_user) ret = ABS.delete(false, @abs_url, @hosts, @token, @test_user)
expect(ret).to include( expect(ret).to include(
'craggy-chord.delivery.puppetlabs.net' => { 'ok'=>true }, 'visible-revival.delivery.puppetlabs.net' => { 'ok'=>true }, 'craggy-chord.delivery.puppetlabs.net' => { 'ok' => true }, 'visible-revival.delivery.puppetlabs.net' => { 'ok' => true }
) )
end end
end end

View file

@ -3,6 +3,9 @@
require 'spec_helper' require 'spec_helper'
require_relative '../../lib/vmfloaty/auth' require_relative '../../lib/vmfloaty/auth'
user = 'first.last'
pass = 'password'
describe Pooler do describe Pooler do
before :each do before :each do
@vmpooler_url = 'https://vmpooler.example.com' @vmpooler_url = 'https://vmpooler.example.com'
@ -15,18 +18,20 @@ describe Pooler do
end end
it 'returns a token from vmpooler' do it 'returns a token from vmpooler' do
stub_request(:post, 'https://first.last:password@vmpooler.example.com/token') stub_request(:post, 'https://vmpooler.example.com/token')
.to_return(:status => 200, :body => @get_token_response, :headers => {}) .with(headers: get_headers(username: user, password: pass, content_length: 0))
.to_return(status: 200, body: @get_token_response, headers: {})
token = Auth.get_token(false, @vmpooler_url, 'first.last', 'password') token = Auth.get_token(false, @vmpooler_url, user, pass)
expect(token).to eq @token expect(token).to eq @token
end end
it 'raises a token error if something goes wrong' do it 'raises a token error if something goes wrong' do
stub_request(:post, 'https://first.last:password@vmpooler.example.com/token') stub_request(:post, 'https://vmpooler.example.com/token')
.to_return(:status => 500, :body => '{"ok":false}', :headers => {}) .with(headers: get_headers(username: user, password: pass, content_length: 0))
.to_return(status: 500, body: '{"ok":false}', headers: {})
expect { Auth.get_token(false, @vmpooler_url, 'first.last', 'password') }.to raise_error(TokenError) expect { Auth.get_token(false, @vmpooler_url, user, pass) }.to raise_error(TokenError)
end end
end end
@ -37,15 +42,18 @@ describe Pooler do
end end
it 'deletes the specified token' do it 'deletes the specified token' do
stub_request(:delete, 'https://first.last:password@vmpooler.example.com/token/utpg2i2xswor6h8ttjhu3d47z53yy47y') stub_request(:delete, 'https://vmpooler.example.com/token/utpg2i2xswor6h8ttjhu3d47z53yy47y')
.to_return(:status => 200, :body => @delete_token_response, :headers => {}) .with(headers: get_headers(username: user, password: pass))
.to_return(status: 200, body: @delete_token_response, headers: {})
expect(Auth.delete_token(false, @vmpooler_url, 'first.last', 'password', @token)).to eq JSON.parse(@delete_token_response) expect(Auth.delete_token(false, @vmpooler_url, user, pass,
@token)).to eq JSON.parse(@delete_token_response)
end end
it 'raises a token error if something goes wrong' do it 'raises a token error if something goes wrong' do
stub_request(:delete, 'https://first.last:password@vmpooler.example.com/token/utpg2i2xswor6h8ttjhu3d47z53yy47y') stub_request(:delete, 'https://vmpooler.example.com/token/utpg2i2xswor6h8ttjhu3d47z53yy47y')
.to_return(:status => 500, :body => '{"ok":false}', :headers => {}) .with(headers: get_headers(username: user, password: pass))
.to_return(status: 500, body: '{"ok":false}', headers: {})
expect { Auth.delete_token(false, @vmpooler_url, 'first.last', 'password', @token) }.to raise_error(TokenError) expect { Auth.delete_token(false, @vmpooler_url, 'first.last', 'password', @token) }.to raise_error(TokenError)
end end
@ -63,14 +71,16 @@ describe Pooler do
it 'checks the status of a token' do it 'checks the status of a token' do
stub_request(:get, "#{@vmpooler_url}/token/utpg2i2xswor6h8ttjhu3d47z53yy47y") stub_request(:get, "#{@vmpooler_url}/token/utpg2i2xswor6h8ttjhu3d47z53yy47y")
.to_return(:status => 200, :body => @token_status_response, :headers => {}) .with(headers: get_headers)
.to_return(status: 200, body: @token_status_response, headers: {})
expect(Auth.token_status(false, @vmpooler_url, @token)).to eq JSON.parse(@token_status_response) expect(Auth.token_status(false, @vmpooler_url, @token)).to eq JSON.parse(@token_status_response)
end end
it 'raises a token error if something goes wrong' do it 'raises a token error if something goes wrong' do
stub_request(:get, "#{@vmpooler_url}/token/utpg2i2xswor6h8ttjhu3d47z53yy47y") stub_request(:get, "#{@vmpooler_url}/token/utpg2i2xswor6h8ttjhu3d47z53yy47y")
.to_return(:status => 500, :body => '{"ok":false}', :headers => {}) .with(headers: get_headers)
.to_return(status: 500, body: '{"ok":false}', headers: {})
expect { Auth.token_status(false, @vmpooler_url, @token) }.to raise_error(TokenError) expect { Auth.token_status(false, @vmpooler_url, @token) }.to raise_error(TokenError)
end end

View file

@ -8,9 +8,7 @@ require 'vmfloaty/nonstandard_pooler'
describe NonstandardPooler do describe NonstandardPooler do
before :each do before :each do
@nspooler_url = 'https://nspooler.example.com' @nspooler_url = 'https://nspooler.example.com'
@auth_token_headers = { @auth_token_headers = get_headers(token: 'token-value')
'X-Auth-Token' => 'token-value',
}
end end
describe '#list' do describe '#list' do
@ -36,7 +34,7 @@ describe NonstandardPooler do
it 'returns an array with operating systems from the pooler' do it 'returns an array with operating systems from the pooler' do
stub_request(:get, "#{@nspooler_url}/status") stub_request(:get, "#{@nspooler_url}/status")
.to_return(:status => 200, :body => @status_response_body, :headers => {}) .to_return(status: 200, body: @status_response_body, headers: {})
list = NonstandardPooler.list(false, @nspooler_url, nil) list = NonstandardPooler.list(false, @nspooler_url, nil)
expect(list).to be_an_instance_of Array expect(list).to be_an_instance_of Array
@ -44,7 +42,7 @@ describe NonstandardPooler do
it 'filters operating systems based on the filter param' do it 'filters operating systems based on the filter param' do
stub_request(:get, "#{@nspooler_url}/status") stub_request(:get, "#{@nspooler_url}/status")
.to_return(:status => 200, :body => @status_response_body, :headers => {}) .to_return(status: 200, body: @status_response_body, headers: {})
list = NonstandardPooler.list(false, @nspooler_url, 'aix') list = NonstandardPooler.list(false, @nspooler_url, 'aix')
expect(list).to be_an_instance_of Array expect(list).to be_an_instance_of Array
@ -53,7 +51,7 @@ describe NonstandardPooler do
it 'returns nothing if the filter does not match' do it 'returns nothing if the filter does not match' do
stub_request(:get, "#{@nspooler_url}/status") stub_request(:get, "#{@nspooler_url}/status")
.to_return(:status => 199, :body => @status_response_body, :headers => {}) .to_return(status: 199, body: @status_response_body, headers: {})
list = NonstandardPooler.list(false, @nspooler_url, 'windows') list = NonstandardPooler.list(false, @nspooler_url, 'windows')
expect(list).to be_an_instance_of Array expect(list).to be_an_instance_of Array
@ -89,7 +87,7 @@ describe NonstandardPooler do
.and_return(JSON.parse(@token_status_body_active)) .and_return(JSON.parse(@token_status_body_active))
list = NonstandardPooler.list_active(false, @nspooler_url, 'token-value', 'user') list = NonstandardPooler.list_active(false, @nspooler_url, 'token-value', 'user')
expect(list).to eql ['sol10-9', 'sol10-11'] expect(list).to eql %w[sol10-9 sol10-11]
end end
end end
@ -121,17 +119,19 @@ describe NonstandardPooler do
it 'raises an AuthError if the token is invalid' do it 'raises an AuthError if the token is invalid' do
stub_request(:post, "#{@nspooler_url}/host/solaris-11-sparc") stub_request(:post, "#{@nspooler_url}/host/solaris-11-sparc")
.with(:headers => @auth_token_headers) .with(headers: get_headers(token: 'token-value'))
.to_return(:status => 401, :body => '{"ok":false,"reason": "token: token-value does not exist"}', :headers => {}) .to_return(status: 401, body: '{"ok":false,"reason": "token: token-value does not exist"}', headers: {})
vm_hash = { 'solaris-11-sparc' => 1 } vm_hash = { 'solaris-11-sparc' => 1 }
expect { NonstandardPooler.retrieve(false, vm_hash, 'token-value', @nspooler_url, 'first.last', {}) }.to raise_error(AuthError) expect do
NonstandardPooler.retrieve(false, vm_hash, 'token-value', @nspooler_url, 'first.last', {})
end.to raise_error(AuthError)
end end
it 'retrieves a single vm with a token' do it 'retrieves a single vm with a token' do
stub_request(:post, "#{@nspooler_url}/host/solaris-11-sparc") stub_request(:post, "#{@nspooler_url}/host/solaris-11-sparc")
.with(:headers => @auth_token_headers) .with(headers: @auth_token_headers)
.to_return(:status => 200, :body => @retrieve_response_body_single, :headers => {}) .to_return(status: 200, body: @retrieve_response_body_single, headers: {})
vm_hash = { 'solaris-11-sparc' => 1 } vm_hash = { 'solaris-11-sparc' => 1 }
vm_req = NonstandardPooler.retrieve(false, vm_hash, 'token-value', @nspooler_url, 'first.last', {}) vm_req = NonstandardPooler.retrieve(false, vm_hash, 'token-value', @nspooler_url, 'first.last', {})
@ -142,15 +142,16 @@ describe NonstandardPooler do
it 'retrieves a multiple vms with a token' do it 'retrieves a multiple vms with a token' do
stub_request(:post, "#{@nspooler_url}/host/aix-7.1-power+solaris-10-sparc+solaris-10-sparc") stub_request(:post, "#{@nspooler_url}/host/aix-7.1-power+solaris-10-sparc+solaris-10-sparc")
.with(:headers => @auth_token_headers) .with(headers: @auth_token_headers)
.to_return(:status => 200, :body => @retrieve_response_body_many, :headers => {}) .to_return(status: 200, body: @retrieve_response_body_many, headers: {})
vm_hash = { 'aix-7.1-power' => 1, 'solaris-10-sparc' => 2 } vm_hash = { 'aix-7.1-power' => 1, 'solaris-10-sparc' => 2 }
vm_req = NonstandardPooler.retrieve(false, vm_hash, 'token-value', @nspooler_url, 'first.last', {}) vm_req = NonstandardPooler.retrieve(false, vm_hash, 'token-value', @nspooler_url, 'first.last', {})
expect(vm_req).to be_an_instance_of Hash expect(vm_req).to be_an_instance_of Hash
expect(vm_req['ok']).to equal true expect(vm_req['ok']).to equal true
expect(vm_req['solaris-10-sparc']['hostname']).to be_an_instance_of Array expect(vm_req['solaris-10-sparc']['hostname']).to be_an_instance_of Array
expect(vm_req['solaris-10-sparc']['hostname']).to eq ['sol10-9.delivery.puppetlabs.net', 'sol10-10.delivery.puppetlabs.net'] expect(vm_req['solaris-10-sparc']['hostname']).to eq ['sol10-9.delivery.puppetlabs.net',
'sol10-10.delivery.puppetlabs.net']
expect(vm_req['aix-7.1-power']['hostname']).to eq 'pe-aix-71-ci-acceptance.delivery.puppetlabs.net' expect(vm_req['aix-7.1-power']['hostname']).to eq 'pe-aix-71-ci-acceptance.delivery.puppetlabs.net'
end end
end end
@ -162,22 +163,22 @@ describe NonstandardPooler do
it 'raises an error if the user tries to modify an unsupported attribute' do it 'raises an error if the user tries to modify an unsupported attribute' do
stub_request(:put, 'https://nspooler.example.com/host/myfakehost') stub_request(:put, 'https://nspooler.example.com/host/myfakehost')
.with(:body => { '{}' => true }, .with(body: { '{}' => true },
:headers => @auth_token_headers) headers: @auth_token_headers)
.to_return(:status => 200, :body => '', :headers => {}) .to_return(status: 200, body: '', headers: {})
details = { :lifetime => 12 } details = { lifetime: 12 }
expect { NonstandardPooler.modify(false, @nspooler_url, 'myfakehost', 'token-value', details) } expect { NonstandardPooler.modify(false, @nspooler_url, 'myfakehost', 'token-value', details) }
.to raise_error(ModifyError) .to raise_error(ModifyError)
end end
it 'modifies the reason of a vm' do it 'modifies the reason of a vm' do
modify_request_body = { '{"reserved_for_reason":"testing"}' => true } modify_request_body = { '{"reserved_for_reason":"testing"}' => nil }
stub_request(:put, "#{@nspooler_url}/host/myfakehost") stub_request(:put, "#{@nspooler_url}/host/myfakehost")
.with(:body => modify_request_body, .with(body: modify_request_body,
:headers => @auth_token_headers) headers: @auth_token_headers)
.to_return(:status => 200, :body => '{"ok": true}', :headers => {}) .to_return(status: 200, body: '{"ok": true}', headers: {})
modify_hash = { :reason => 'testing' } modify_hash = { reason: 'testing' }
modify_req = NonstandardPooler.modify(false, @nspooler_url, 'myfakehost', 'token-value', modify_hash) modify_req = NonstandardPooler.modify(false, @nspooler_url, 'myfakehost', 'token-value', modify_hash)
expect(modify_req['ok']).to be true expect(modify_req['ok']).to be true
end end
@ -208,7 +209,7 @@ describe NonstandardPooler do
it 'prints the status' do it 'prints the status' do
stub_request(:get, "#{@nspooler_url}/status") stub_request(:get, "#{@nspooler_url}/status")
.to_return(:status => 200, :body => @status_response_body, :headers => {}) .to_return(status: 200, body: @status_response_body, headers: {})
status = NonstandardPooler.status(false, @nspooler_url) status = NonstandardPooler.status(false, @nspooler_url)
expect(status).to be_an_instance_of Hash expect(status).to be_an_instance_of Hash
@ -231,7 +232,7 @@ describe NonstandardPooler do
it 'prints the summary' do it 'prints the summary' do
stub_request(:get, "#{@nspooler_url}/summary") stub_request(:get, "#{@nspooler_url}/summary")
.to_return(:status => 200, :body => @status_response_body, :headers => {}) .to_return(status: 200, body: @status_response_body, headers: {})
summary = NonstandardPooler.summary(false, @nspooler_url) summary = NonstandardPooler.summary(false, @nspooler_url)
expect(summary).to be_an_instance_of Hash expect(summary).to be_an_instance_of Hash
@ -256,7 +257,7 @@ describe NonstandardPooler do
it 'makes a query about a vm' do it 'makes a query about a vm' do
stub_request(:get, "#{@nspooler_url}/host/sol10-11") stub_request(:get, "#{@nspooler_url}/host/sol10-11")
.to_return(:status => 200, :body => @query_response_body, :headers => {}) .to_return(status: 200, body: @query_response_body, headers: {})
query_req = NonstandardPooler.query(false, @nspooler_url, 'sol10-11') query_req = NonstandardPooler.query(false, @nspooler_url, 'sol10-11')
expect(query_req).to be_an_instance_of Hash expect(query_req).to be_an_instance_of Hash
@ -271,8 +272,8 @@ describe NonstandardPooler do
it 'deletes a single existing vm' do it 'deletes a single existing vm' do
stub_request(:delete, "#{@nspooler_url}/host/sol11-7") stub_request(:delete, "#{@nspooler_url}/host/sol11-7")
.with(:headers => @auth_token_headers) .with(headers: @auth_token_headers)
.to_return(:status => 200, :body => @delete_response_success, :headers => {}) .to_return(status: 200, body: @delete_response_success, headers: {})
request = NonstandardPooler.delete(false, @nspooler_url, 'sol11-7', 'token-value', nil) request = NonstandardPooler.delete(false, @nspooler_url, 'sol11-7', 'token-value', nil)
expect(request['sol11-7']['ok']).to be true expect(request['sol11-7']['ok']).to be true
@ -280,8 +281,8 @@ describe NonstandardPooler do
it 'does not delete a nonexistant vm' do it 'does not delete a nonexistant vm' do
stub_request(:delete, "#{@nspooler_url}/host/fakehost") stub_request(:delete, "#{@nspooler_url}/host/fakehost")
.with(:headers => @auth_token_headers) .with(headers: @auth_token_headers)
.to_return(:status => 401, :body => @delete_response_failure, :headers => {}) .to_return(status: 401, body: @delete_response_failure, headers: {})
request = NonstandardPooler.delete(false, @nspooler_url, 'fakehost', 'token-value', nil) request = NonstandardPooler.delete(false, @nspooler_url, 'fakehost', 'token-value', nil)
expect(request['fakehost']['ok']).to be false expect(request['fakehost']['ok']).to be false

View file

@ -15,7 +15,7 @@ describe Pooler do
it 'returns a hash with operating systems from the pooler' do it 'returns a hash with operating systems from the pooler' do
stub_request(:get, "#{@vmpooler_url}/vm") stub_request(:get, "#{@vmpooler_url}/vm")
.to_return(:status => 200, :body => @list_response_body, :headers => {}) .to_return(status: 200, body: @list_response_body, headers: {})
list = Pooler.list(false, @vmpooler_url, nil) list = Pooler.list(false, @vmpooler_url, nil)
expect(list).to be_an_instance_of Array expect(list).to be_an_instance_of Array
@ -23,7 +23,7 @@ describe Pooler do
it 'filters operating systems based on the filter param' do it 'filters operating systems based on the filter param' do
stub_request(:get, "#{@vmpooler_url}/vm") stub_request(:get, "#{@vmpooler_url}/vm")
.to_return(:status => 200, :body => @list_response_body, :headers => {}) .to_return(status: 200, body: @list_response_body, headers: {})
list = Pooler.list(false, @vmpooler_url, 'deb') list = Pooler.list(false, @vmpooler_url, 'deb')
expect(list).to be_an_instance_of Array expect(list).to be_an_instance_of Array
@ -32,7 +32,7 @@ describe Pooler do
it 'returns nothing if the filter does not match' do it 'returns nothing if the filter does not match' do
stub_request(:get, "#{@vmpooler_url}/vm") stub_request(:get, "#{@vmpooler_url}/vm")
.to_return(:status => 200, :body => @list_response_body, :headers => {}) .to_return(status: 200, body: @list_response_body, headers: {})
list = Pooler.list(false, @vmpooler_url, 'windows') list = Pooler.list(false, @vmpooler_url, 'windows')
expect(list).to be_an_instance_of Array expect(list).to be_an_instance_of Array
@ -48,8 +48,8 @@ describe Pooler do
it 'raises an AuthError if the token is invalid' do it 'raises an AuthError if the token is invalid' do
stub_request(:post, "#{@vmpooler_url}/vm/debian-7-i386") stub_request(:post, "#{@vmpooler_url}/vm/debian-7-i386")
.with(:headers => { 'X-Auth-Token' => 'mytokenfile' }) .with(headers: { 'X-Auth-Token' => 'mytokenfile' })
.to_return(:status => 401, :body => '{"ok":false}', :headers => {}) .to_return(status: 401, body: '{"ok":false}', headers: {})
vm_hash = {} vm_hash = {}
vm_hash['debian-7-i386'] = 1 vm_hash['debian-7-i386'] = 1
@ -58,8 +58,8 @@ describe Pooler do
it 'retrieves a single vm with a token' do it 'retrieves a single vm with a token' do
stub_request(:post, "#{@vmpooler_url}/vm/debian-7-i386") stub_request(:post, "#{@vmpooler_url}/vm/debian-7-i386")
.with(:headers => { 'X-Auth-Token' => 'mytokenfile' }) .with(headers: { 'X-Auth-Token' => 'mytokenfile' })
.to_return(:status => 200, :body => @retrieve_response_body_single, :headers => {}) .to_return(status: 200, body: @retrieve_response_body_single, headers: {})
vm_hash = {} vm_hash = {}
vm_hash['debian-7-i386'] = 1 vm_hash['debian-7-i386'] = 1
@ -71,8 +71,8 @@ describe Pooler do
it 'retrieves a multiple vms with a token' do it 'retrieves a multiple vms with a token' do
stub_request(:post, "#{@vmpooler_url}/vm/debian-7-i386+debian-7-i386+centos-7-x86_64") stub_request(:post, "#{@vmpooler_url}/vm/debian-7-i386+debian-7-i386+centos-7-x86_64")
.with(:headers => { 'X-Auth-Token' => 'mytokenfile' }) .with(headers: { 'X-Auth-Token' => 'mytokenfile' })
.to_return(:status => 200, :body => @retrieve_response_body_double, :headers => {}) .to_return(status: 200, body: @retrieve_response_body_double, headers: {})
vm_hash = {} vm_hash = {}
vm_hash['debian-7-i386'] = 2 vm_hash['debian-7-i386'] = 2
@ -89,11 +89,11 @@ describe Pooler do
let(:ondemand_response) { '{"ok":true,"request_id":"1234"}' } let(:ondemand_response) { '{"ok":true,"request_id":"1234"}' }
it 'retreives the vm with a token' do it 'retreives the vm with a token' do
stub_request(:post, "#{@vmpooler_url}/ondemandvm/debian-7-i386") stub_request(:post, "#{@vmpooler_url}/ondemandvm/debian-7-i386")
.with(:headers => { 'X-Auth-Token' => 'mytokenfile' }) .with(headers: { 'X-Auth-Token' => 'mytokenfile' })
.to_return(:status => 200, :body => ondemand_response, :headers => {}) .to_return(status: 200, body: ondemand_response, headers: {})
stub_request(:get, "#{@vmpooler_url}/ondemandvm/1234") stub_request(:get, "#{@vmpooler_url}/ondemandvm/1234")
.to_return(:status => 200, :body => @retrieve_response_body_single, :headers => {}) .to_return(status: 200, body: @retrieve_response_body_single, headers: {})
vm_hash = {} vm_hash = {}
vm_hash['debian-7-i386'] = 1 vm_hash['debian-7-i386'] = 1
@ -117,11 +117,11 @@ describe Pooler do
end end
it 'modifies the TTL of a vm' do it 'modifies the TTL of a vm' do
modify_hash = { :lifetime => 12 } modify_hash = { lifetime: 12 }
stub_request(:put, "#{@vmpooler_url}/vm/fq6qlpjlsskycq6") stub_request(:put, "#{@vmpooler_url}/vm/fq6qlpjlsskycq6")
.with(:body => { '{"lifetime":12}' => true }, .with(body: { '{"lifetime":12}' => nil },
:headers => { 'Content-Type' => 'application/x-www-form-urlencoded', 'X-Auth-Token' => 'mytokenfile' }) headers: get_headers(content_type: 'application/x-www-form-urlencoded', token: 'mytokenfile'))
.to_return(:status => 200, :body => @modify_response_body_success, :headers => {}) .to_return(status: 200, body: @modify_response_body_success, headers: {})
modify_req = Pooler.modify(false, @vmpooler_url, 'fq6qlpjlsskycq6', 'mytokenfile', modify_hash) modify_req = Pooler.modify(false, @vmpooler_url, 'fq6qlpjlsskycq6', 'mytokenfile', modify_hash)
expect(modify_req['ok']).to be true expect(modify_req['ok']).to be true
@ -136,8 +136,8 @@ describe Pooler do
it 'deletes a specified vm' do it 'deletes a specified vm' do
stub_request(:delete, "#{@vmpooler_url}/vm/fq6qlpjlsskycq6") stub_request(:delete, "#{@vmpooler_url}/vm/fq6qlpjlsskycq6")
.with(:headers => { 'X-Auth-Token' => 'mytokenfile' }) .with(headers: { 'X-Auth-Token' => 'mytokenfile' })
.to_return(:status => 200, :body => @delete_response_body_success, :headers => {}) .to_return(status: 200, body: @delete_response_body_success, headers: {})
expect(Pooler.delete(false, @vmpooler_url, ['fq6qlpjlsskycq6'], 'mytokenfile', nil)).to eq @delete_response expect(Pooler.delete(false, @vmpooler_url, ['fq6qlpjlsskycq6'], 'mytokenfile', nil)).to eq @delete_response
end end
@ -155,7 +155,7 @@ describe Pooler do
it 'prints the status' do it 'prints the status' do
stub_request(:get, "#{@vmpooler_url}/status") stub_request(:get, "#{@vmpooler_url}/status")
.to_return(:status => 200, :body => @status_response_body, :headers => {}) .to_return(status: 200, body: @status_response_body, headers: {})
status = Pooler.status(false, @vmpooler_url) status = Pooler.status(false, @vmpooler_url)
expect(status).to be_an_instance_of Hash expect(status).to be_an_instance_of Hash
@ -178,7 +178,7 @@ describe Pooler do
it 'makes a query about a vm' do it 'makes a query about a vm' do
stub_request(:get, "#{@vmpooler_url}/vm/fq6qlpjlsskycq6") stub_request(:get, "#{@vmpooler_url}/vm/fq6qlpjlsskycq6")
.to_return(:status => 200, :body => @query_response_body, :headers => {}) .to_return(status: 200, body: @query_response_body, headers: {})
query_req = Pooler.query(false, @vmpooler_url, 'fq6qlpjlsskycq6') query_req = Pooler.query(false, @vmpooler_url, 'fq6qlpjlsskycq6')
expect(query_req).to be_an_instance_of Hash expect(query_req).to be_an_instance_of Hash
@ -192,8 +192,8 @@ describe Pooler do
it 'makes a snapshot for a single vm' do it 'makes a snapshot for a single vm' do
stub_request(:post, "#{@vmpooler_url}/vm/fq6qlpjlsskycq6/snapshot") stub_request(:post, "#{@vmpooler_url}/vm/fq6qlpjlsskycq6/snapshot")
.with(:headers => { 'X-Auth-Token' => 'mytokenfile' }) .with(headers: { 'X-Auth-Token' => 'mytokenfile' })
.to_return(:status => 200, :body => @snapshot_response_body, :headers => {}) .to_return(status: 200, body: @snapshot_response_body, headers: {})
snapshot_req = Pooler.snapshot(false, @vmpooler_url, 'fq6qlpjlsskycq6', 'mytokenfile') snapshot_req = Pooler.snapshot(false, @vmpooler_url, 'fq6qlpjlsskycq6', 'mytokenfile')
expect(snapshot_req['ok']).to be true expect(snapshot_req['ok']).to be true
@ -207,15 +207,18 @@ describe Pooler do
it 'makes a request to revert a vm from a snapshot' do it 'makes a request to revert a vm from a snapshot' do
stub_request(:post, "#{@vmpooler_url}/vm/fq6qlpjlsskycq6/snapshot/dAfewKNfaweLKNve") stub_request(:post, "#{@vmpooler_url}/vm/fq6qlpjlsskycq6/snapshot/dAfewKNfaweLKNve")
.with(:headers => { 'X-Auth-Token' => 'mytokenfile' }) .with(headers: { 'X-Auth-Token' => 'mytokenfile' })
.to_return(:status => 200, :body => @revert_response_body, :headers => {}) .to_return(status: 200, body: @revert_response_body, headers: {})
revert_req = Pooler.revert(false, @vmpooler_url, 'fq6qlpjlsskycq6', 'mytokenfile', 'dAfewKNfaweLKNve') revert_req = Pooler.revert(false, @vmpooler_url, 'fq6qlpjlsskycq6', 'mytokenfile', 'dAfewKNfaweLKNve')
expect(revert_req['ok']).to be true expect(revert_req['ok']).to be true
end end
it "doesn't make a request to revert a vm if snapshot is not provided" do it "doesn't make a request to revert a vm if snapshot is not provided" do
expect { Pooler.revert(false, @vmpooler_url, 'fq6qlpjlsskycq6', 'mytokenfile', nil) }.to raise_error(RuntimeError, 'Snapshot SHA provided was nil, could not revert fq6qlpjlsskycq6') expect do
Pooler.revert(false, @vmpooler_url, 'fq6qlpjlsskycq6', 'mytokenfile',
nil)
end.to raise_error(RuntimeError, 'Snapshot SHA provided was nil, could not revert fq6qlpjlsskycq6')
end end
it 'raises a TokenError if no token was provided' do it 'raises a TokenError if no token was provided' do
@ -231,7 +234,7 @@ describe Pooler do
it 'makes a request to extend disk space of a vm' do it 'makes a request to extend disk space of a vm' do
stub_request(:post, "#{@vmpooler_url}/vm/fq6qlpjlsskycq6/disk/12") stub_request(:post, "#{@vmpooler_url}/vm/fq6qlpjlsskycq6/disk/12")
.with(:headers => { 'X-Auth-Token' => 'mytokenfile' }). to_return(:status => 200, :body => @disk_response_body_success, :headers => {}) .with(headers: { 'X-Auth-Token' => 'mytokenfile' }).to_return(status: 200, body: @disk_response_body_success, headers: {})
disk_req = Pooler.disk(false, @vmpooler_url, 'fq6qlpjlsskycq6', 'mytokenfile', 12) disk_req = Pooler.disk(false, @vmpooler_url, 'fq6qlpjlsskycq6', 'mytokenfile', 12)
expect(disk_req['ok']).to be true expect(disk_req['ok']).to be true

View file

@ -16,7 +16,7 @@ describe Service do
it 'prompts the user for their password and retrieves a token' do it 'prompts the user for their password and retrieves a token' do
config = { 'user' => 'first.last', 'url' => 'http://default.url' } config = { 'user' => 'first.last', 'url' => 'http://default.url' }
service = Service.new(MockOptions.new, config) service = Service.new(MockOptions.new, config)
allow(STDOUT).to receive(:puts).with('Enter your http://default.url service password:') allow($stdout).to receive(:puts).with('Enter your http://default.url service password:')
allow(Commander::UI).to(receive(:password) allow(Commander::UI).to(receive(:password)
.with('Enter your http://default.url service password:', '*') .with('Enter your http://default.url service password:', '*')
.and_return('hunter2')) .and_return('hunter2'))
@ -29,9 +29,9 @@ describe Service do
it 'prompts the user for their username and password if the username is unknown' do it 'prompts the user for their username and password if the username is unknown' do
config = { 'url' => 'http://default.url' } config = { 'url' => 'http://default.url' }
service = Service.new(MockOptions.new({}), config) service = Service.new(MockOptions.new({}), config)
allow(STDOUT).to receive(:puts).with 'Enter your http://default.url service username:' allow($stdout).to receive(:puts).with 'Enter your http://default.url service username:'
allow(STDOUT).to receive(:puts).with "\n" allow($stdout).to receive(:puts).with "\n"
allow(STDIN).to receive(:gets).and_return('first.last') allow($stdin).to receive(:gets).and_return('first.last')
allow(Commander::UI).to(receive(:password) allow(Commander::UI).to(receive(:password)
.with('Enter your http://default.url service password:', '*') .with('Enter your http://default.url service password:', '*')
.and_return('hunter2')) .and_return('hunter2'))
@ -59,7 +59,7 @@ describe Service do
it 'reports the status of a token' do it 'reports the status of a token' do
config = { config = {
'user' => 'first.last', 'user' => 'first.last',
'url' => 'http://default.url', 'url' => 'http://default.url'
} }
options = MockOptions.new('token' => 'token-value') options = MockOptions.new('token' => 'token-value')
service = Service.new(options, config) service = Service.new(options, config)
@ -68,7 +68,7 @@ describe Service do
'user' => config['user'], 'user' => config['user'],
'created' => '2017-09-22 02:04:18 +0000', 'created' => '2017-09-22 02:04:18 +0000',
'last_accessed' => '2017-09-22 02:04:28 +0000', 'last_accessed' => '2017-09-22 02:04:28 +0000',
'reserved_hosts' => [], 'reserved_hosts' => []
} }
allow(Auth).to(receive(:token_status) allow(Auth).to(receive(:token_status)
.with(nil, config['url'], 'token-value') .with(nil, config['url'], 'token-value')

View file

@ -4,24 +4,35 @@ require 'spec_helper'
require 'vmfloaty/ssh' require 'vmfloaty/ssh'
class ServiceStub class ServiceStub
def retrieve(_verbose, os_types, _use_token) def retrieve(_verbose, os_types, _use_token, ondemand)
if os_types.keys[0] == 'abs_host_string' if os_types.keys[0] == 'abs_host_string'
return { return {
os_types.keys[0] => { 'hostname' => ['abs-hostname.delivery.puppetlabs.net'] }, os_types.keys[0] => { 'hostname' => ['abs-hostname.delivery.puppetlabs.net'] },
'ok' => true, 'ok' => true
}
elsif os_types.keys[0] == 'vmpooler_api_v2_host_string'
return {
os_types.keys[0] => { 'hostname' => ['vmpooler-v2-hostname.delivery.puppetlabs.net'] },
'ok' => true
}
else
return {
os_types.keys[0] => { 'hostname' => 'vmpooler-v1-hostname' },
'domain' => 'delivery.puppetlabs.net',
'ok' => true
} }
end end
{
os_types.keys[0] => { 'hostname' => 'vmpooler-hostname' },
'domain' => 'delivery.puppetlabs.net',
'ok' => true,
}
end end
def type def type
return 'abs' if os_types == 'abs_host_string' return 'abs' if os_types == 'abs_host_string'
return 'vmpooler' if os_types == 'vmpooler_host_string' return 'vmpooler' if os_types == 'vmpooler_api_v1_host_string' || os_types == 'vmpooler_api_v2_host_string'
end
def wait_for_request(verbose, requestid)
return true
end end
end end
@ -29,6 +40,7 @@ describe Ssh do
before :each do before :each do
end end
context "for pooled requests" do
it 'gets a hostname string for abs' do it 'gets a hostname string for abs' do
verbose = false verbose = false
service = ServiceStub.new service = ServiceStub.new
@ -38,12 +50,63 @@ describe Ssh do
expect(cmd).to match(/ssh root@abs-hostname.delivery.puppetlabs.net/) expect(cmd).to match(/ssh root@abs-hostname.delivery.puppetlabs.net/)
end end
it 'gets a hostname string for vmpooler' do it 'gets a hostname string for vmpooler api v1' do
verbose = false verbose = true
service = ServiceStub.new service = ServiceStub.new
host_os = 'vmpooler_host_string' host_os = 'vmpooler_api_v1_host_string'
use_token = false use_token = false
cmd = Ssh.command_string(verbose, service, host_os, use_token) cmd = Ssh.command_string(verbose, service, host_os, use_token)
expect(cmd).to match(/ssh root@vmpooler-hostname.delivery.puppetlabs.net/) expect(cmd).to match(/ssh root@vmpooler-v1-hostname.delivery.puppetlabs.net/)
end
it 'gets a hostname string for vmpooler api v2' do
verbose = false
service = ServiceStub.new
host_os = 'vmpooler_api_v2_host_string'
use_token = false
cmd = Ssh.command_string(verbose, service, host_os, use_token)
expect(cmd).to match(/ssh root@vmpooler-v2-hostname.delivery.puppetlabs.net/)
end
end
context "for ondemand requests" do
let(:service) { ServiceStub.new }
let(:url) { 'http://pooler.example.com' }
it 'gets a hostname string for abs' do
verbose = false
host_os = 'abs_host_string'
use_token = false
ondemand = true
response = {'abs_host_string' => { 'hostname' => ['abs-hostname.delivery.puppetlabs.net']}}
allow(service).to receive(:url)
allow(service).to receive(:check_ondemandvm).and_return(response)
cmd = Ssh.command_string(verbose, service, host_os, use_token, ondemand)
expect(cmd).to match(/ssh root@abs-hostname.delivery.puppetlabs.net/)
end
it 'gets a hostname string for abs' do
verbose = false
host_os = 'vmpooler_api_v1_host_string'
use_token = false
ondemand = true
response = {'vmpooler_api_v1_host_string' => { 'hostname' => ['vmpooler_api_v1_host_string.delivery.puppetlabs.net']}}
allow(service).to receive(:url)
allow(service).to receive(:check_ondemandvm).and_return(response)
cmd = Ssh.command_string(verbose, service, host_os, use_token, ondemand)
expect(cmd).to match(/ssh root@vmpooler_api_v1_host_string.delivery.puppetlabs.net/)
end
it 'gets a hostname string for abs' do
verbose = false
host_os = 'vmpooler_api_v2_host_string'
use_token = false
ondemand = true
response = {'vmpooler_api_v2_host_string' => { 'hostname' => ['vmpooler_api_v2_host_string.delivery.puppetlabs.net']}}
allow(service).to receive(:url)
allow(service).to receive(:check_ondemandvm).and_return(response)
cmd = Ssh.command_string(verbose, service, host_os, use_token, ondemand)
expect(cmd).to match(/ssh root@vmpooler_api_v2_host_string.delivery.puppetlabs.net/)
end
end end
end end

View file

@ -5,10 +5,15 @@ require 'json'
require 'commander/command' require 'commander/command'
require_relative '../../lib/vmfloaty/utils' require_relative '../../lib/vmfloaty/utils'
# allow changing config in service for tests
class Service
attr_writer :config
end
describe Utils do describe Utils do
describe '#standardize_hostnames' do describe '#standardize_hostnames' do
before :each do before :each do
@vmpooler_response_body = '{ @vmpooler_api_v1_response_body = '{
"ok": true, "ok": true,
"domain": "delivery.mycompany.net", "domain": "delivery.mycompany.net",
"ubuntu-1610-x86_64": { "ubuntu-1610-x86_64": {
@ -18,6 +23,15 @@ describe Utils do
"hostname": "dlgietfmgeegry2" "hostname": "dlgietfmgeegry2"
} }
}' }'
@vmpooler_api_v2_response_body = '{
"ok": true,
"ubuntu-1610-x86_64": {
"hostname": ["gdoy8q3nckuob0i.delivery.mycompany.net", "ctnktsd0u11p9tm.delivery.mycompany.net"]
},
"centos-7-x86_64": {
"hostname": "dlgietfmgeegry2.delivery.mycompany.net"
}
}'
@nonstandard_response_body = '{ @nonstandard_response_body = '{
"ok": true, "ok": true,
"solaris-10-sparc": { "solaris-10-sparc": {
@ -29,10 +43,18 @@ describe Utils do
}' }'
end end
it 'formats a result from vmpooler into a hash of os to hostnames' do it 'formats a result from vmpooler v1 api into a hash of os to hostnames' do
result = Utils.standardize_hostnames(JSON.parse(@vmpooler_response_body)) result = Utils.standardize_hostnames(JSON.parse(@vmpooler_api_v1_response_body))
expect(result).to eq('centos-7-x86_64' => ['dlgietfmgeegry2.delivery.mycompany.net'], expect(result).to eq('centos-7-x86_64' => ['dlgietfmgeegry2.delivery.mycompany.net'],
'ubuntu-1610-x86_64' => ['gdoy8q3nckuob0i.delivery.mycompany.net', 'ctnktsd0u11p9tm.delivery.mycompany.net']) 'ubuntu-1610-x86_64' => ['gdoy8q3nckuob0i.delivery.mycompany.net',
'ctnktsd0u11p9tm.delivery.mycompany.net'])
end
it 'formats a result from vmpooler v2 api into a hash of os to hostnames' do
result = Utils.standardize_hostnames(JSON.parse(@vmpooler_api_v2_response_body))
expect(result).to eq('centos-7-x86_64' => ['dlgietfmgeegry2.delivery.mycompany.net'],
'ubuntu-1610-x86_64' => ['gdoy8q3nckuob0i.delivery.mycompany.net',
'ctnktsd0u11p9tm.delivery.mycompany.net'])
end end
it 'formats a result from the nonstandard pooler into a hash of os to hostnames' do it 'formats a result from the nonstandard pooler into a hash of os to hostnames' do
@ -46,11 +68,11 @@ describe Utils do
before :each do before :each do
@vmpooler_results = { @vmpooler_results = {
'centos-7-x86_64' => ['dlgietfmgeegry2.delivery.mycompany.net'], 'centos-7-x86_64' => ['dlgietfmgeegry2.delivery.mycompany.net'],
'ubuntu-1610-x86_64' => ['gdoy8q3nckuob0i.delivery.mycompany.net', 'ctnktsd0u11p9tm.delivery.mycompany.net'], 'ubuntu-1610-x86_64' => ['gdoy8q3nckuob0i.delivery.mycompany.net', 'ctnktsd0u11p9tm.delivery.mycompany.net']
} }
@nonstandard_results = { @nonstandard_results = {
'solaris-10-sparc' => ['sol10-10.delivery.mycompany.net', 'sol10-11.delivery.mycompany.net'], 'solaris-10-sparc' => ['sol10-10.delivery.mycompany.net', 'sol10-11.delivery.mycompany.net'],
'ubuntu-16.04-power8' => ['power8-ubuntu16.04-6.delivery.mycompany.net'], 'ubuntu-16.04-power8' => ['power8-ubuntu16.04-6.delivery.mycompany.net']
} }
@vmpooler_output = <<~OUT.chomp @vmpooler_output = <<~OUT.chomp
- dlgietfmgeegry2.delivery.mycompany.net (centos-7-x86_64) - dlgietfmgeegry2.delivery.mycompany.net (centos-7-x86_64)
@ -77,9 +99,17 @@ describe Utils do
expect(Utils.get_service_object).to be Pooler expect(Utils.get_service_object).to be Pooler
end end
it 'uses abs when told explicitly' do
expect(Utils.get_service_object('abs')).to be ABS
end
it 'uses nspooler when told explicitly' do it 'uses nspooler when told explicitly' do
expect(Utils.get_service_object('nspooler')).to be NonstandardPooler expect(Utils.get_service_object('nspooler')).to be NonstandardPooler
end end
it 'uses vmpooler when told explicitly' do
expect(Utils.get_service_object('vmpooler')).to be Pooler
end
end end
describe '#get_service_config' do describe '#get_service_config' do
@ -87,21 +117,21 @@ describe Utils do
@default_config = { @default_config = {
'url' => 'http://default.url', 'url' => 'http://default.url',
'user' => 'first.last.default', 'user' => 'first.last.default',
'token' => 'default-token', 'token' => 'default-token'
} }
@services_config = { @services_config = {
'services' => { 'services' => {
'vm' => { 'vm' => {
'url' => 'http://vmpooler.url', 'url' => 'http://vmpooler.url',
'user' => 'first.last.vmpooler', 'user' => 'first.last.vmpooler',
'token' => 'vmpooler-token', 'token' => 'vmpooler-token'
}, },
'ns' => { 'ns' => {
'url' => 'http://nspooler.url', 'url' => 'http://nspooler.url',
'user' => 'first.last.nspooler', 'user' => 'first.last.nspooler',
'token' => 'nspooler-token', 'token' => 'nspooler-token'
}, }
}, }
} }
end end
@ -113,26 +143,26 @@ describe Utils do
it 'allows selection by configured service key' do it 'allows selection by configured service key' do
config = @default_config.merge @services_config config = @default_config.merge @services_config
options = MockOptions.new(:service => 'ns') options = MockOptions.new(service: 'ns')
expect(Utils.get_service_config(config, options)).to include @services_config['services']['ns'] expect(Utils.get_service_config(config, options)).to include @services_config['services']['ns']
end end
it 'uses top-level service config values as defaults when configured service values are missing' do it 'uses top-level service config values as defaults when configured service values are missing' do
config = @default_config.merge @services_config config = @default_config.merge @services_config
config['services']['vm'].delete 'url' config['services']['vm'].delete 'url'
options = MockOptions.new(:service => 'vm') options = MockOptions.new(service: 'vm')
expect(Utils.get_service_config(config, options)['url']).to eq 'http://default.url' expect(Utils.get_service_config(config, options)['url']).to eq 'http://default.url'
end end
it "raises an error if passed a service name that hasn't been configured" do it "raises an error if passed a service name that hasn't been configured" do
config = @default_config.merge @services_config config = @default_config.merge @services_config
options = MockOptions.new(:service => 'none') options = MockOptions.new(service: 'none')
expect { Utils.get_service_config(config, options) }.to raise_error ArgumentError expect { Utils.get_service_config(config, options) }.to raise_error ArgumentError
end end
it 'prioritizes values passed as command line options over configuration options' do it 'prioritizes values passed as command line options over configuration options' do
config = @default_config config = @default_config
options = MockOptions.new(:url => 'http://alternate.url', :token => 'alternate-token') options = MockOptions.new(url: 'http://alternate.url', token: 'alternate-token')
expected = config.merge('url' => 'http://alternate.url', 'token' => 'alternate-token') expected = config.merge('url' => 'http://alternate.url', 'token' => 'alternate-token')
expect(Utils.get_service_config(config, options)).to include expected expect(Utils.get_service_config(config, options)).to include expected
end end
@ -154,97 +184,544 @@ describe Utils do
end end
end end
describe '#pretty_print_hosts' do describe '#print_fqdn_for_host' do
let(:url) { 'http://pooler.example.com' } let(:url) { 'http://pooler.example.com' }
it 'prints a vmpooler output with host fqdn, template and duration info' do subject { Utils.print_fqdn_for_host(service, hostname, host_data) }
hostname = 'mcpy42eqjxli9g2'
response_body = { hostname => { describe 'with vmpooler host' do
let(:service) { Service.new(MockOptions.new, 'url' => url) }
let(:hostname) { 'mcpy42eqjxli9g2' }
let(:domain) { 'delivery.mycompany.net' }
let(:fqdn) { [hostname, domain].join('.') }
let(:host_data) do
{
'template' => 'ubuntu-1604-x86_64', 'template' => 'ubuntu-1604-x86_64',
'lifetime' => 12, 'lifetime' => 12,
'running' => 9.66, 'running' => 9.66,
'state' => 'running', 'state' => 'running',
'ip' => '127.0.0.1', 'ip' => '127.0.0.1',
'domain' => 'delivery.mycompany.net', 'domain' => domain
} } }
output = '- mcpy42eqjxli9g2.delivery.mycompany.net (ubuntu-1604-x86_64, 9.66/12 hours)'
expect(STDOUT).to receive(:puts).with(output)
service = Service.new(MockOptions.new, 'url' => url)
allow(service).to receive(:query)
.with(nil, hostname)
.and_return(response_body)
Utils.pretty_print_hosts(nil, service, hostname)
end end
it 'prints a vmpooler output with host fqdn, template, duration info, and tags when supplied' do it 'outputs fqdn for host' do
hostname = 'aiydvzpg23r415q' expect($stdout).to receive(:puts).with(fqdn)
response_body = { hostname => {
subject
end
end
describe 'with nonstandard pooler host' do
let(:service) { Service.new(MockOptions.new, 'url' => url, 'type' => 'ns') }
let(:hostname) { 'sol11-9.delivery.mycompany.net' }
let(:host_data) do
{
'fqdn' => hostname,
'os_triple' => 'solaris-11-sparc',
'reserved_by_user' => 'first.last',
'reserved_for_reason' => '',
'hours_left_on_reservation' => 35.89
}
end
let(:fqdn) { hostname } # for nspooler these are the same
it 'outputs fqdn for host' do
expect($stdout).to receive(:puts).with(fqdn)
subject
end
end
describe 'with ABS host' do
let(:service) { Service.new(MockOptions.new, 'url' => url, 'type' => 'abs') }
let(:hostname) { '1597952189390' }
let(:fqdn) { 'example-noun.delivery.puppetlabs.net' }
let(:template) { 'ubuntu-1604-x86_64' }
# This seems to be the miminal stub response from ABS for the current output
let(:host_data) do
{
'state' => 'allocated',
'allocated_resources' => [
{
'hostname' => fqdn,
'type' => template,
'enging' => 'vmpooler'
}
],
'request' => {
'job' => {
'id' => hostname
}
}
}
end
it 'outputs fqdn for host' do
expect($stdout).to receive(:puts).with(fqdn)
subject
end
end
end
describe '#pretty_print_hosts' do
let(:url) { 'http://pooler.example.com' }
let(:verbose) { nil }
let(:print_to_stderr) { false }
before(:each) do
allow(service).to receive(:query)
.with(anything, hostname)
.and_return(response_body)
end
subject { Utils.pretty_print_hosts(verbose, service, hostname, print_to_stderr) }
describe 'with vmpooler api v2 service' do
let(:service) { Service.new(MockOptions.new, 'url' => url) }
let(:hostname) { 'mcpy42eqjxli9g2' }
let(:fqdn) { [hostname, 'delivery.puppetlabs.net'].join('.') }
let(:response_body) do
{
hostname => {
'template' => 'ubuntu-1604-x86_64',
'lifetime' => 12,
'running' => 9.66,
'state' => 'running',
'ip' => '127.0.0.1',
'fqdn' => fqdn
}
}
end
let(:default_output) { "- #{fqdn} (running, ubuntu-1604-x86_64, 9.66/12 hours)" }
it 'prints output with host fqdn, template and duration info' do
expect($stdout).to receive(:puts).with(default_output)
subject
end
context 'when tags are supplied' do
let(:hostname) { 'aiydvzpg23r415q' }
let(:response_body) do
{
hostname => {
'template' => 'redhat-7-x86_64', 'template' => 'redhat-7-x86_64',
'lifetime' => 48, 'lifetime' => 48,
'running' => 7.67, 'running' => 7.67,
'state' => 'running', 'state' => 'running',
'tags' => { 'tags' => {
'user' => 'bob', 'user' => 'bob',
'role' => 'agent', 'role' => 'agent'
}, },
'ip' => '127.0.0.1', 'ip' => '127.0.0.1',
'domain' => 'delivery.mycompany.net', 'fqdn' => fqdn
} } }
output = '- aiydvzpg23r415q.delivery.mycompany.net (redhat-7-x86_64, 7.67/48 hours, user: bob, role: agent)' }
expect(STDOUT).to receive(:puts).with(output)
service = Service.new(MockOptions.new, 'url' => url)
allow(service).to receive(:query)
.with(nil, hostname)
.and_return(response_body)
Utils.pretty_print_hosts(nil, service, hostname)
end end
it 'prints a nonstandard pooler output with host, template, and time remaining' do it 'prints output with host fqdn, template, duration info, and tags' do
hostname = 'sol11-9.delivery.mycompany.net' output = "- #{fqdn} (running, redhat-7-x86_64, 7.67/48 hours, user: bob, role: agent)"
response_body = { hostname => {
expect($stdout).to receive(:puts).with(output)
subject
end
end
context 'when print_to_stderr option is true' do
let(:print_to_stderr) { true }
it 'outputs to stderr instead of stdout' do
expect($stderr).to receive(:puts).with(default_output)
subject
end
end
end
describe 'with vmpooler api v1 service' do
let(:service) { Service.new(MockOptions.new, 'url' => url) }
let(:hostname) { 'mcpy42eqjxli9g2' }
let(:domain) { 'delivery.mycompany.net' }
let(:fqdn) { [hostname, domain].join('.') }
let(:response_body) do
{
hostname => {
'template' => 'ubuntu-1604-x86_64',
'lifetime' => 12,
'running' => 9.66,
'state' => 'running',
'ip' => '127.0.0.1',
'domain' => domain
}
}
end
let(:default_output) { "- #{fqdn} (running, ubuntu-1604-x86_64, 9.66/12 hours)" }
it 'prints output with host fqdn, template and duration info' do
expect($stdout).to receive(:puts).with(default_output)
subject
end
context 'when tags are supplied' do
let(:hostname) { 'aiydvzpg23r415q' }
let(:response_body) do
{
hostname => {
'template' => 'redhat-7-x86_64',
'lifetime' => 48,
'running' => 7.67,
'state' => 'running',
'tags' => {
'user' => 'bob',
'role' => 'agent'
},
'ip' => '127.0.0.1',
'domain' => domain
}
}
end
it 'prints output with host fqdn, template, duration info, and tags' do
output = "- #{fqdn} (running, redhat-7-x86_64, 7.67/48 hours, user: bob, role: agent)"
expect($stdout).to receive(:puts).with(output)
subject
end
end
context 'when print_to_stderr option is true' do
let(:print_to_stderr) { true }
it 'outputs to stderr instead of stdout' do
expect($stderr).to receive(:puts).with(default_output)
subject
end
end
end
describe 'with nonstandard pooler service' do
let(:service) { Service.new(MockOptions.new, 'url' => url, 'type' => 'ns') }
let(:hostname) { 'sol11-9.delivery.mycompany.net' }
let(:response_body) do
{
hostname => {
'fqdn' => hostname, 'fqdn' => hostname,
'os_triple' => 'solaris-11-sparc', 'os_triple' => 'solaris-11-sparc',
'reserved_by_user' => 'first.last', 'reserved_by_user' => 'first.last',
'reserved_for_reason' => '', 'reserved_for_reason' => '',
'hours_left_on_reservation' => 35.89, 'hours_left_on_reservation' => 35.89
} } }
output = '- sol11-9.delivery.mycompany.net (solaris-11-sparc, 35.89h remaining)' }
expect(STDOUT).to receive(:puts).with(output)
service = Service.new(MockOptions.new, 'url' => url, 'type' => 'ns')
allow(service).to receive(:query)
.with(nil, hostname)
.and_return(response_body)
Utils.pretty_print_hosts(nil, service, hostname)
end end
it 'prints a nonstandard pooler output with host, template, time remaining, and reason' do let(:default_output) { "- #{hostname} (solaris-11-sparc, 35.89h remaining)" }
hostname = 'sol11-9.delivery.mycompany.net'
response_body = { hostname => { it 'prints output with host, template, and time remaining' do
expect($stdout).to receive(:puts).with(default_output)
subject
end
context 'when reason is supplied' do
let(:response_body) do
{
hostname => {
'fqdn' => hostname, 'fqdn' => hostname,
'os_triple' => 'solaris-11-sparc', 'os_triple' => 'solaris-11-sparc',
'reserved_by_user' => 'first.last', 'reserved_by_user' => 'first.last',
'reserved_for_reason' => 'testing', 'reserved_for_reason' => 'testing',
'hours_left_on_reservation' => 35.89, 'hours_left_on_reservation' => 35.89
} } }
}
end
it 'prints output with host, template, time remaining, and reason' do
output = '- sol11-9.delivery.mycompany.net (solaris-11-sparc, 35.89h remaining, reason: testing)' output = '- sol11-9.delivery.mycompany.net (solaris-11-sparc, 35.89h remaining, reason: testing)'
expect(STDOUT).to receive(:puts).with(output) expect($stdout).to receive(:puts).with(output)
service = Service.new(MockOptions.new, 'url' => url, 'type' => 'ns') subject
end
end
context 'when print_to_stderr option is true' do
let(:print_to_stderr) { true }
it 'outputs to stderr instead of stdout' do
expect($stderr).to receive(:puts).with(default_output)
subject
end
end
end
describe 'with ABS service' do
let(:service) { Service.new(MockOptions.new, 'url' => url, 'type' => 'abs') }
let(:hostname) { '1597952189390' }
let(:fqdn) { 'example-noun.delivery.mycompany.net' }
let(:fqdn_hostname) { 'example-noun' }
let(:template) { 'ubuntu-1604-x86_64' }
# This seems to be the miminal stub response from ABS for the current output
let(:response_body) do
{
hostname => {
'state' => 'allocated',
'allocated_resources' => [
{
'hostname' => fqdn,
'type' => template,
'engine' => 'vmpooler'
}
],
'request' => {
'job' => {
'id' => hostname
}
}
}
}
end
# The vmpooler response contains metadata that is printed
let(:domain) { 'delivery.mycompany.net' }
let(:response_body_vmpooler) do
{
fqdn_hostname => {
'template' => template,
'lifetime' => 48,
'running' => 7.67,
'state' => 'running',
'tags' => {
'user' => 'bob',
'role' => 'agent'
},
'ip' => '127.0.0.1',
'domain' => domain
}
}
end
before(:each) do
allow(Utils).to receive(:get_vmpooler_service_config).and_return({
'url' => 'http://vmpooler.example.com',
'token' => 'krypto-knight'
})
allow(service).to receive(:query) allow(service).to receive(:query)
.with(nil, hostname) .with(anything, fqdn_hostname)
.and_return(response_body) .and_return(response_body_vmpooler)
end
Utils.pretty_print_hosts(nil, service, hostname) let(:default_output_first_line) { "- [JobID:#{hostname}] <allocated>" }
let(:default_output_second_line) { " - #{fqdn} (#{template})" }
it 'prints output with job id, host, and template' do
expect($stdout).to receive(:puts).with(default_output_first_line)
expect($stdout).to receive(:puts).with(default_output_second_line)
subject
end
it 'prints more information when vmpooler_fallback is set output with job id, host, template, lifetime, user and role' do
fallback = { 'vmpooler_fallback' => 'vmpooler' }
service.config.merge! fallback
default_output_second_line = " - #{fqdn} (running, #{template}, 7.67/48 hours, user: bob, role: agent)"
expect($stdout).to receive(:puts).with(default_output_first_line)
expect($stdout).to receive(:puts).with(default_output_second_line)
subject
end
it 'prints DESTROYED and hostname when destroyed' do
fallback = { 'vmpooler_fallback' => 'vmpooler' }
service.config.merge! fallback
response_body_vmpooler[fqdn_hostname]['state'] = 'destroyed'
default_output_second_line = " - DESTROYED #{fqdn}"
expect($stdout).to receive(:puts).with(default_output_first_line)
expect($stdout).to receive(:puts).with(default_output_second_line)
subject
end
context 'when print_to_stderr option is true' do
let(:print_to_stderr) { true }
it 'outputs to stderr instead of stdout' do
expect($stderr).to receive(:puts).with(default_output_first_line)
expect($stderr).to receive(:puts).with(default_output_second_line)
subject
end
end
end
describe 'with ABS service returning vmpooler and nspooler resources' do
let(:service) { Service.new(MockOptions.new, 'url' => url, 'type' => 'abs') }
let(:hostname) { '1597952189390' }
let(:fqdn) { 'this-noun.delivery.mycompany.net' }
let(:fqdn_ns) { 'that-noun.delivery.mycompany.net' }
let(:fqdn_hostname) { 'this-noun' }
let(:fqdn_ns_hostname) { 'that-noun' }
let(:template) { 'ubuntu-1604-x86_64' }
let(:template_ns) { 'solaris-10-sparc' }
# This seems to be the miminal stub response from ABS for the current output
let(:response_body) do
{
hostname => {
'state' => 'allocated',
'allocated_resources' => [
{
'hostname' => fqdn,
'type' => template,
'engine' => 'vmpooler'
},
{
'hostname' => fqdn_ns,
'type' => template_ns,
'engine' => 'nspooler'
}
],
'request' => {
'job' => {
'id' => hostname
}
}
}
}
end
# The vmpooler response contains metadata that is printed
let(:domain) { 'delivery.mycompany.net' }
let(:response_body_vmpooler) do
{
fqdn_hostname => {
'template' => template,
'lifetime' => 48,
'running' => 7.67,
'state' => 'running',
'tags' => {
'user' => 'bob',
'role' => 'agent'
},
'ip' => '127.0.0.1',
'domain' => domain
}
}
end
before(:each) do
allow(Utils).to receive(:get_vmpooler_service_config).and_return({
'url' => 'http://vmpooler.example.com',
'token' => 'krypto-knight'
})
allow(service).to receive(:query)
.with(anything, fqdn_hostname)
.and_return(response_body_vmpooler)
end
let(:default_output_first_line) { "- [JobID:#{hostname}] <allocated>" }
let(:default_output_second_line) { " - #{fqdn} (#{template})" }
let(:default_output_third_line) { " - #{fqdn_ns} (#{template_ns})" }
it 'prints output with job id, host, and template' do
expect($stdout).to receive(:puts).with(default_output_first_line)
expect($stdout).to receive(:puts).with(default_output_second_line)
expect($stdout).to receive(:puts).with(default_output_third_line)
subject
end
context 'when print_to_stderr option is true' do
let(:print_to_stderr) { true }
it 'outputs to stderr instead of stdout' do
expect($stderr).to receive(:puts).with(default_output_first_line)
expect($stderr).to receive(:puts).with(default_output_second_line)
expect($stderr).to receive(:puts).with(default_output_third_line)
subject
end
end
end
end
describe '#get_vmpooler_service_config' do
let(:Conf) { double }
it 'returns an error if the vmpooler_fallback is not setup' do
config = {
'user' => 'foo',
'services' => {
'myabs' => {
'url' => 'http://abs.com',
'token' => 'krypto-night',
'type' => 'abs'
}
}
}
allow(Conf).to receive(:read_config).and_return(config)
expect do
Utils.get_vmpooler_service_config(config['services']['myabs']['vmpooler_fallback'])
end.to raise_error(ArgumentError)
end
it 'returns an error if the vmpooler_fallback is setup but cannot be found' do
config = {
'user' => 'foo',
'services' => {
'myabs' => {
'url' => 'http://abs.com',
'token' => 'krypto-night',
'type' => 'abs',
'vmpooler_fallback' => 'myvmpooler'
}
}
}
allow(Conf).to receive(:read_config).and_return(config)
expect do
Utils.get_vmpooler_service_config(config['services']['myabs']['vmpooler_fallback'])
end.to raise_error(ArgumentError,
/myvmpooler/)
end
it 'returns the vmpooler_fallback config' do
config = {
'user' => 'foo',
'services' => {
'myabs' => {
'url' => 'http://abs.com',
'token' => 'krypto-night',
'type' => 'abs',
'vmpooler_fallback' => 'myvmpooler'
},
'myvmpooler' => {
'url' => 'http://vmpooler.com',
'token' => 'krypto-knight'
}
}
}
allow(Conf).to receive(:read_config).and_return(config)
expect(Utils.get_vmpooler_service_config(config['services']['myabs']['vmpooler_fallback'])).to include({
'url' => 'http://vmpooler.com',
'token' => 'krypto-knight',
'user' => 'foo',
'type' => 'vmpooler'
})
end end
end end
end end

View file

@ -8,12 +8,9 @@ Gem::Specification.new do |s|
s.version = Vmfloaty::VERSION s.version = Vmfloaty::VERSION
s.authors = [ s.authors = [
'Brian Cain', 'Brian Cain',
'Puppet', 'Puppet'
]
s.email = [
'brianccain@gmail.com',
'dio-gems@puppet.com',
] ]
s.email = 'info@puppet.com'
s.license = 'Apache-2.0' s.license = 'Apache-2.0'
s.homepage = 'https://github.com/puppetlabs/vmfloaty' s.homepage = 'https://github.com/puppetlabs/vmfloaty'
s.description = 'A helper tool for vmpooler to help you stay afloat' s.description = 'A helper tool for vmpooler to help you stay afloat'
@ -24,7 +21,6 @@ Gem::Specification.new do |s|
s.test_files = Dir['spec/**/*'] s.test_files = Dir['spec/**/*']
s.require_path = 'lib' s.require_path = 'lib'
s.add_dependency 'colorize', '~> 0.8.1' s.add_dependency 'commander', '>= 4.4.3', '< 4.7.0'
s.add_dependency 'commander', '>= 4.4.3', '< 4.6.0' s.add_dependency 'faraday', '~> 1.5', '>= 1.5.1'
s.add_dependency 'faraday', '~> 0.17.0'
end end