vmfloaty 1.7.0 → 1.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +33 -20
- data/lib/vmfloaty/pooler.rb +2 -2
- data/lib/vmfloaty/utils.rb +8 -1
- data/lib/vmfloaty/version.rb +1 -1
- data/spec/vmfloaty/utils_spec.rb +67 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bc8f9cbf5501db6e699993e5cf44b2ec84fbf5deb878ed6749cd8aa80c97db5c
|
4
|
+
data.tar.gz: 7670cba4f4b1e08fd02f6ce26a5807230e5163f2580b3321ece8c424d0700cf0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e742c00b940efaf0043d510a682757a129ead52800ea0d25a36dec96a53f212c1df14eae5d7c239e90a4def18668722ac508312aee098238dc98c1381012751e
|
7
|
+
data.tar.gz: 0c2bc4ddb1cc4dc217a1b363ff5c89813ddf8b1592f06c7714d153761fb2263b1090ec8e9b27f5a502fd0c8e8ebea4dd06f89e88e4055584e675844f9c211021
|
data/README.md
CHANGED
@@ -1,37 +1,48 @@
|
|
1
1
|
# vmfloaty
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/vmfloaty.svg)](https://badge.fury.io/rb/vmfloaty)
|
4
|
-
[![
|
4
|
+
[![Test](https://github.com/puppetlabs/vmfloaty/actions/workflows/test.yml/badge.svg)](https://github.com/puppetlabs/vmfloaty/actions/workflows/test.yml)
|
5
5
|
|
6
6
|
A CLI helper tool for [Puppet's VMPooler](https://github.com/puppetlabs/vmpooler) to help you stay afloat.
|
7
7
|
|
8
8
|
![float image](float.jpg)
|
9
9
|
|
10
|
-
- [
|
11
|
-
- [
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
- [
|
16
|
-
- [
|
17
|
-
|
18
|
-
|
19
|
-
- [VMPooler
|
20
|
-
- [
|
21
|
-
|
22
|
-
- [
|
23
|
-
- [
|
24
|
-
- [
|
25
|
-
- [
|
10
|
+
- [vmfloaty](#vmfloaty)
|
11
|
+
- [Install](#install)
|
12
|
+
- [Ruby](#ruby)
|
13
|
+
- [Docker](#docker)
|
14
|
+
- [Usage](#usage)
|
15
|
+
- [Example workflow](#example-workflow)
|
16
|
+
- [vmfloaty dotfile](#vmfloaty-dotfile)
|
17
|
+
- [Basic configuration](#basic-configuration)
|
18
|
+
- [Using multiple services](#using-multiple-services)
|
19
|
+
- [Using backends besides VMPooler](#using-backends-besides-vmpooler)
|
20
|
+
- [Valid config keys](#valid-config-keys)
|
21
|
+
- [Tab Completion](#tab-completion)
|
22
|
+
- [VMPooler API](#vmpooler-api)
|
23
|
+
- [Using the Pooler class](#using-the-pooler-class)
|
24
|
+
- [Example Projects](#example-projects)
|
25
|
+
- [Contributing](#contributing)
|
26
|
+
- [Code Reviews](#code-reviews)
|
27
|
+
- [Releasing](#releasing)
|
28
|
+
- [Special thanks](#special-thanks)
|
26
29
|
|
27
30
|
## Install
|
28
31
|
|
32
|
+
### Ruby
|
33
|
+
|
29
34
|
Grab the latest from ruby gems...
|
30
35
|
|
31
36
|
```bash
|
32
37
|
gem install vmfloaty
|
33
38
|
```
|
34
39
|
|
40
|
+
### Docker
|
41
|
+
|
42
|
+
Run the docker image:
|
43
|
+
|
44
|
+
`docker run -it --rm -v ~/.vmfloaty.yml:/home/floatyuser/.vmfloaty.yml ghcr.io/puppetlabs/vmfloaty --help`
|
45
|
+
|
35
46
|
## Usage
|
36
47
|
|
37
48
|
```plain
|
@@ -177,10 +188,12 @@ Please wait for multiple code owners to sign off on any notable change.
|
|
177
188
|
|
178
189
|
## Releasing
|
179
190
|
|
180
|
-
|
191
|
+
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:
|
181
192
|
|
182
|
-
1.
|
183
|
-
2.
|
193
|
+
1. Bump the "VERSION" in `lib/vmfloaty/version.rb` appropriately based on changes in `CHANGELOG.md` since the last release.
|
194
|
+
2. Run `./release-prep` to update `Gemfile.lock` and `CHANGELOG.md`.
|
195
|
+
3. Commit and push changes to a new branch, then open a pull request against `main` and be sure to add the "maintenance" label.
|
196
|
+
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.
|
184
197
|
|
185
198
|
## Special thanks
|
186
199
|
|
data/lib/vmfloaty/pooler.rb
CHANGED
@@ -146,14 +146,14 @@ class Pooler
|
|
146
146
|
def self.status(verbose, url)
|
147
147
|
conn = Http.get_conn(verbose, url)
|
148
148
|
|
149
|
-
response = conn.get '
|
149
|
+
response = conn.get 'status'
|
150
150
|
JSON.parse(response.body)
|
151
151
|
end
|
152
152
|
|
153
153
|
def self.summary(verbose, url)
|
154
154
|
conn = Http.get_conn(verbose, url)
|
155
155
|
|
156
|
-
response = conn.get '
|
156
|
+
response = conn.get 'summary'
|
157
157
|
JSON.parse(response.body)
|
158
158
|
end
|
159
159
|
|
data/lib/vmfloaty/utils.rb
CHANGED
@@ -150,7 +150,14 @@ class Utils
|
|
150
150
|
tag_pairs = host_data['tags'].map { |key, value| "#{key}: #{value}" } unless host_data['tags'].nil?
|
151
151
|
duration = "#{host_data['running']}/#{host_data['lifetime']} hours"
|
152
152
|
metadata = [host_data['state'], host_data['template'], duration, *tag_pairs]
|
153
|
-
|
153
|
+
# For backwards compatibility with vmpooler api v1
|
154
|
+
message =
|
155
|
+
if host_data['domain']
|
156
|
+
"- #{hostname}.#{host_data['domain']} (#{metadata.join(', ')})".gsub(/^/, ' ' * indent)
|
157
|
+
else
|
158
|
+
"- #{host_data['fqdn']} (#{metadata.join(', ')})".gsub(/^/, ' ' * indent)
|
159
|
+
end
|
160
|
+
|
154
161
|
if host_data['state'] && host_data['state'] == 'destroyed'
|
155
162
|
output_target.puts "- DESTROYED #{hostname}.#{host_data['domain']}".gsub(/^/, ' ' * indent)
|
156
163
|
else
|
data/lib/vmfloaty/version.rb
CHANGED
data/spec/vmfloaty/utils_spec.rb
CHANGED
@@ -280,7 +280,73 @@ describe Utils do
|
|
280
280
|
|
281
281
|
subject { Utils.pretty_print_hosts(verbose, service, hostname, print_to_stderr) }
|
282
282
|
|
283
|
-
describe 'with vmpooler service' do
|
283
|
+
describe 'with vmpooler api v2 service' do
|
284
|
+
let(:service) { Service.new(MockOptions.new, 'url' => url) }
|
285
|
+
|
286
|
+
let(:hostname) { 'mcpy42eqjxli9g2' }
|
287
|
+
let(:fqdn) { [hostname, 'delivery.puppetlabs.net'].join('.') }
|
288
|
+
|
289
|
+
let(:response_body) do
|
290
|
+
{
|
291
|
+
hostname => {
|
292
|
+
'template' => 'ubuntu-1604-x86_64',
|
293
|
+
'lifetime' => 12,
|
294
|
+
'running' => 9.66,
|
295
|
+
'state' => 'running',
|
296
|
+
'ip' => '127.0.0.1',
|
297
|
+
'fqdn' => fqdn
|
298
|
+
}
|
299
|
+
}
|
300
|
+
end
|
301
|
+
|
302
|
+
let(:default_output) { "- #{fqdn} (running, ubuntu-1604-x86_64, 9.66/12 hours)" }
|
303
|
+
|
304
|
+
it 'prints output with host fqdn, template and duration info' do
|
305
|
+
expect($stdout).to receive(:puts).with(default_output)
|
306
|
+
|
307
|
+
subject
|
308
|
+
end
|
309
|
+
|
310
|
+
context 'when tags are supplied' do
|
311
|
+
let(:hostname) { 'aiydvzpg23r415q' }
|
312
|
+
let(:response_body) do
|
313
|
+
{
|
314
|
+
hostname => {
|
315
|
+
'template' => 'redhat-7-x86_64',
|
316
|
+
'lifetime' => 48,
|
317
|
+
'running' => 7.67,
|
318
|
+
'state' => 'running',
|
319
|
+
'tags' => {
|
320
|
+
'user' => 'bob',
|
321
|
+
'role' => 'agent'
|
322
|
+
},
|
323
|
+
'ip' => '127.0.0.1',
|
324
|
+
'fqdn' => fqdn
|
325
|
+
}
|
326
|
+
}
|
327
|
+
end
|
328
|
+
|
329
|
+
it 'prints output with host fqdn, template, duration info, and tags' do
|
330
|
+
output = "- #{fqdn} (running, redhat-7-x86_64, 7.67/48 hours, user: bob, role: agent)"
|
331
|
+
|
332
|
+
expect($stdout).to receive(:puts).with(output)
|
333
|
+
|
334
|
+
subject
|
335
|
+
end
|
336
|
+
end
|
337
|
+
|
338
|
+
context 'when print_to_stderr option is true' do
|
339
|
+
let(:print_to_stderr) { true }
|
340
|
+
|
341
|
+
it 'outputs to stderr instead of stdout' do
|
342
|
+
expect($stderr).to receive(:puts).with(default_output)
|
343
|
+
|
344
|
+
subject
|
345
|
+
end
|
346
|
+
end
|
347
|
+
end
|
348
|
+
|
349
|
+
describe 'with vmpooler api v1 service' do
|
284
350
|
let(:service) { Service.new(MockOptions.new, 'url' => url) }
|
285
351
|
|
286
352
|
let(:hostname) { 'mcpy42eqjxli9g2' }
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vmfloaty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Cain
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2023-08-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: commander
|
@@ -52,7 +52,7 @@ dependencies:
|
|
52
52
|
- !ruby/object:Gem::Version
|
53
53
|
version: 1.5.1
|
54
54
|
description: A helper tool for vmpooler to help you stay afloat
|
55
|
-
email:
|
55
|
+
email: info@puppet.com
|
56
56
|
executables:
|
57
57
|
- floaty
|
58
58
|
extensions: []
|
@@ -105,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
105
|
- !ruby/object:Gem::Version
|
106
106
|
version: '0'
|
107
107
|
requirements: []
|
108
|
-
rubygems_version: 3.
|
108
|
+
rubygems_version: 3.3.26
|
109
109
|
signing_key:
|
110
110
|
specification_version: 4
|
111
111
|
summary: CLI application to interface with vmpooler
|