vmfloaty 1.6.0 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: cf8e6d210de6ae23fdd371025ace279b939768d1f197b81b2226f326263bc204
4
- data.tar.gz: 7da421b68bb4377e31c4e5784e394ab672adb616ce8be4376e55f0006dd81849
3
+ metadata.gz: 5d8a0fcfd2e8fd42301c8a8c6ec14336444c5d70dda0adaed0731cbddcc90f7d
4
+ data.tar.gz: f3d5ef1252fbcb9142afba59d78f93d6cdbaaf76f11680a13c91654fbbc308fc
5
5
  SHA512:
6
- metadata.gz: 846823d38e3b7dc5cfa066efcda72a6f58ad11ce875529a3ac6443551a138fbc3e05e262226e3dd756e93e8d31c9fa5c3bb4639f139158f5903a95c43bfb9b40
7
- data.tar.gz: e693187229fb1b845e4a2b24f9bf9b22e7b0e4244887f8c1fc6042e64d6082638266b56421e04a46948b2efc92e4abd3e4d0ccdf28e345e30a89a77909872022
6
+ metadata.gz: 568f97d95dccec571488649670fb9fb8022ca58ec6a94c7b333d0f45d9f08ce4ff42c82cd8aef9bfc2079920b3178d333989d8422b68d2dfafe96fbaa08968c9
7
+ data.tar.gz: 7df48c34d04d7b6aaf4c6b4ac66fd845016c44519040192ddb2aa5d69f89043960d974a910cb1c8eceef6014d96f04891c71276ff5367760b0fa45ec5184aa88
data/README.md CHANGED
@@ -1,34 +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
- [![CI](https://github.com/puppetlabs/vmfloaty/actions/workflows/ci.yml/badge.svg)](https://github.com/puppetlabs/vmfloaty/actions/workflows/ci.yml)
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
- - [Install](#install)
11
- - [Usage](#usage)
12
- - [Example workflow](#example-workflow)
13
- - [vmfloaty dotfile](#vmfloaty-dotfile)
14
- - [Basic configuration](#basic-configuration)
15
- - [Using multiple services](#using-multiple-services)
16
- - [Using backends besides VMPooler](#using-backends-besides-vmpooler)
17
- - [Valid config keys](#valid-config-keys)
18
- - [Tab Completion](#tab-completion)
19
- - [VMPooler API](#vmpooler-api)
20
- - [Using the Pooler class](#using-the-pooler-class)
21
- - [Example Projects](#example-projects)
22
- - [Special thanks](#special-thanks)
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)
23
29
 
24
30
  ## Install
25
31
 
32
+ ### Ruby
33
+
26
34
  Grab the latest from ruby gems...
27
35
 
28
36
  ```bash
29
37
  gem install vmfloaty
30
38
  ```
31
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
+
32
46
  ## Usage
33
47
 
34
48
  ```plain
@@ -164,6 +178,23 @@ vmfloaty providers a `Pooler` class that gives users the ability to make request
164
178
  - [Brian Cain: vagrant-vmpooler](https://github.com/briancain/vagrant-vmpooler)
165
179
  - Use Vagrant to manage your vmpooler instances
166
180
 
181
+ ## Contributing
182
+
183
+ PR's are welcome! We always love to see how others think this tool can be made better.
184
+
185
+ ### Code Reviews
186
+
187
+ Please wait for multiple code owners to sign off on any notable change.
188
+
189
+ ## Releasing
190
+
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:
192
+
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.
197
+
167
198
  ## Special thanks
168
199
 
169
200
  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.
@@ -87,7 +87,7 @@ class Service
87
87
  @service_object.wait_for_request verbose, requestid, url
88
88
  end
89
89
 
90
- def ssh(verbose, host_os, use_token = true)
90
+ def ssh(verbose, host_os, use_token = true, ondemand = nil)
91
91
  token_value = nil
92
92
  if use_token
93
93
  begin
@@ -97,7 +97,7 @@ class Service
97
97
  FloatyLogger.info 'Could not get token... requesting vm without a token anyway...'
98
98
  end
99
99
  end
100
- Ssh.ssh(verbose, self, host_os, token_value)
100
+ Ssh.ssh(verbose, self, host_os, token_value, ondemand)
101
101
  end
102
102
 
103
103
  def query(verbose, hostname)
data/lib/vmfloaty/ssh.rb CHANGED
@@ -14,27 +14,45 @@ class Ssh
14
14
  nil
15
15
  end
16
16
 
17
- def self.command_string(verbose, service, host_os, use_token)
17
+ def self.command_string(verbose, service, host_os, use_token, ondemand = nil)
18
18
  ssh_path = which('ssh')
19
19
  raise 'Could not determine path to ssh' unless ssh_path
20
-
21
- os_types = {}
20
+ os_types = Utils.generate_os_hash([host_os])
22
21
  os_types[host_os] = 1
23
22
 
24
- response = service.retrieve(verbose, os_types, use_token)
23
+ response = service.retrieve(verbose, os_types, use_token, ondemand)
25
24
  raise "Could not get vm from #{service.type}:\n #{response}" unless response['ok']
26
25
 
27
26
  user = /win/.match?(host_os) ? 'Administrator' : 'root'
28
27
 
29
- hostname = response[host_os]['hostname']
30
- hostname = response[host_os]['hostname'][0] if response[host_os]['hostname'].is_a?(Array)
31
- hostname = "#{hostname}.#{response['domain']}" unless hostname.end_with?('puppetlabs.net')
28
+ if ondemand
29
+ requestid = response['request_id']
30
+ service.wait_for_request(verbose, requestid)
31
+ hosts = service.check_ondemandvm(verbose, requestid, service.url)
32
+ if hosts['domain'].nil?
33
+ hostname = hosts[host_os]['hostname']
34
+ hostname = hosts[host_os]['hostname'][0] if hosts[host_os]['hostname'].is_a?(Array)
35
+ else
36
+ # Provides backwards compatibility with VMPooler API v1
37
+ hostname = "#{hosts[host_os]['hostname']}.#{hosts['domain']}"
38
+ hostname = "#{hosts[host_os]['hostname'][0]}.#{hosts['domain']}" if hosts[host_os]['hostname'].is_a?(Array)
39
+ end
40
+ else
41
+ if response['domain'].nil?
42
+ hostname = response[host_os]['hostname']
43
+ hostname = response[host_os]['hostname'][0] if response[host_os]['hostname'].is_a?(Array)
44
+ else
45
+ # Provides backwards compatibility with VMPooler API v1
46
+ hostname = "#{response[host_os]['hostname']}.#{response['domain']}"
47
+ hostname = "#{response[host_os]['hostname'][0]}.#{response['domain']}" if response[host_os]['hostname'].is_a?(Array)
48
+ end
49
+ end
32
50
 
33
51
  "#{ssh_path} #{user}@#{hostname}"
34
52
  end
35
53
 
36
- def self.ssh(verbose, service, host_os, use_token)
37
- cmd = command_string(verbose, service, host_os, use_token)
54
+ def self.ssh(verbose, service, host_os, use_token, ondemand)
55
+ cmd = command_string(verbose, service, host_os, use_token, ondemand)
38
56
  # TODO: Should this respect more ssh settings? Can it be configured
39
57
  # by users ssh config and does this respect those settings?
40
58
  Kernel.exec(cmd)
@@ -9,7 +9,7 @@ class Utils
9
9
  # TODO: Takes the json response body from an HTTP GET
10
10
  # request and "pretty prints" it
11
11
  def self.standardize_hostnames(response_body)
12
- # vmpooler response body example when `floaty get` arguments are `ubuntu-1610-x86_64=2 centos-7-x86_64`:
12
+ # vmpooler api v1 response body example when `floaty get` arguments are `ubuntu-1610-x86_64=2 centos-7-x86_64`:
13
13
  # {
14
14
  # "ok": true,
15
15
  # "domain": "delivery.mycompany.net",
@@ -21,6 +21,17 @@ class Utils
21
21
  # }
22
22
  # }
23
23
 
24
+ # vmpooler api v2 response body example when `floaty get` arguments are `ubuntu-1610-x86_64=2 centos-7-x86_64`:
25
+ # {
26
+ # "ok": true,
27
+ # "ubuntu-1610-x86_64": {
28
+ # "hostname": ["gdoy8q3nckuob0i.pooler.example.com", "ctnktsd0u11p9tm.pooler.example.com"]
29
+ # },
30
+ # "centos-7-x86_64": {
31
+ # "hostname": "dlgietfmgeegry2.pooler.example.com"
32
+ # }
33
+ # }
34
+
24
35
  # nonstandard pooler response body example when `floaty get` arguments are `solaris-11-sparc=2 ubuntu-16.04-power8`:
25
36
  # {
26
37
  # "ok": true,
@@ -98,7 +109,11 @@ class Utils
98
109
 
99
110
  puts abs_hostnames.join("\n")
100
111
  when 'Pooler'
101
- puts "#{hostname}.#{host_data['domain']}"
112
+ if host_data['domain'].nil?
113
+ puts hostname
114
+ else
115
+ puts "#{hostname}.#{host_data['domain']}"
116
+ end
102
117
  when 'NonstandardPooler'
103
118
  puts host_data['fqdn']
104
119
  else
@@ -135,7 +150,14 @@ class Utils
135
150
  tag_pairs = host_data['tags'].map { |key, value| "#{key}: #{value}" } unless host_data['tags'].nil?
136
151
  duration = "#{host_data['running']}/#{host_data['lifetime']} hours"
137
152
  metadata = [host_data['state'], host_data['template'], duration, *tag_pairs]
138
- message = "- #{hostname}.#{host_data['domain']} (#{metadata.join(', ')})".gsub(/^/, ' ' * indent)
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
+
139
161
  if host_data['state'] && host_data['state'] == 'destroyed'
140
162
  output_target.puts "- DESTROYED #{hostname}.#{host_data['domain']}".gsub(/^/, ' ' * indent)
141
163
  else
@@ -197,9 +219,9 @@ class Utils
197
219
  pending = pool['pending']
198
220
  missing = max - ready - pending
199
221
  char = 'o'
200
- puts "#{name.ljust(width)} #{(char * ready).green}#{(char * pending).yellow}#{(char * missing).red}"
222
+ puts "#{name.ljust(width)} #{(char * ready)}#{(char * pending)}#{(char * missing)}"
201
223
  rescue StandardError => e
202
- FloatyLogger.error "#{name.ljust(width)} #{e.red}"
224
+ FloatyLogger.error "#{name.ljust(width)} #{e}"
203
225
  end
204
226
  puts message
205
227
  when 'NonstandardPooler'
@@ -214,13 +236,13 @@ class Utils
214
236
  pending = pool['pending'] || 0 # not available for nspooler
215
237
  missing = max - ready - pending
216
238
  char = 'o'
217
- puts "#{name.ljust(width)} #{(char * ready).green}#{(char * pending).yellow}#{(char * missing).red}"
239
+ puts "#{name.ljust(width)} #{(char * ready)}#{(char * pending)}#{(char * missing)}"
218
240
  rescue StandardError => e
219
- FloatyLogger.error "#{name.ljust(width)} #{e.red}"
241
+ FloatyLogger.error "#{name.ljust(width)} #{e}"
220
242
  end
221
243
  when 'ABS'
222
244
  FloatyLogger.error 'ABS Not OK' unless status_response
223
- puts 'ABS is OK'.green if status_response
245
+ puts 'ABS is OK' if status_response
224
246
  else
225
247
  raise "Invalid service type #{service.type}"
226
248
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class Vmfloaty
4
- VERSION = '1.6.0'
4
+ VERSION = '1.8.0'
5
5
  end
data/lib/vmfloaty.rb CHANGED
@@ -484,7 +484,7 @@ class Vmfloaty
484
484
 
485
485
  FloatyLogger.info "Can't ssh to multiple hosts; Using #{host_os} only..." if args.length > 1
486
486
 
487
- service.ssh(verbose, host_os, use_token)
487
+ service.ssh(verbose, host_os, use_token, options.ondemand)
488
488
  exit 0
489
489
  end
490
490
  end
@@ -4,24 +4,35 @@ require 'spec_helper'
4
4
  require 'vmfloaty/ssh'
5
5
 
6
6
  class ServiceStub
7
- def retrieve(_verbose, os_types, _use_token)
7
+ def retrieve(_verbose, os_types, _use_token, ondemand)
8
8
  if os_types.keys[0] == 'abs_host_string'
9
9
  return {
10
10
  os_types.keys[0] => { 'hostname' => ['abs-hostname.delivery.puppetlabs.net'] },
11
11
  'ok' => true
12
12
  }
13
- end
14
13
 
15
- {
16
- os_types.keys[0] => { 'hostname' => 'vmpooler-hostname' },
17
- 'domain' => 'delivery.puppetlabs.net',
18
- 'ok' => true
19
- }
14
+ elsif os_types.keys[0] == 'vmpooler_api_v2_host_string'
15
+ return {
16
+ os_types.keys[0] => { 'hostname' => ['vmpooler-v2-hostname.delivery.puppetlabs.net'] },
17
+ 'ok' => true
18
+ }
19
+
20
+ else
21
+ return {
22
+ os_types.keys[0] => { 'hostname' => 'vmpooler-v1-hostname' },
23
+ 'domain' => 'delivery.puppetlabs.net',
24
+ 'ok' => true
25
+ }
26
+ end
20
27
  end
21
28
 
22
29
  def type
23
30
  return 'abs' if os_types == 'abs_host_string'
24
- return 'vmpooler' if os_types == 'vmpooler_host_string'
31
+ return 'vmpooler' if os_types == 'vmpooler_api_v1_host_string' || os_types == 'vmpooler_api_v2_host_string'
32
+ end
33
+
34
+ def wait_for_request(verbose, requestid)
35
+ return true
25
36
  end
26
37
  end
27
38
 
@@ -29,21 +40,73 @@ describe Ssh do
29
40
  before :each do
30
41
  end
31
42
 
32
- it 'gets a hostname string for abs' do
33
- verbose = false
34
- service = ServiceStub.new
35
- host_os = 'abs_host_string'
36
- use_token = false
37
- cmd = Ssh.command_string(verbose, service, host_os, use_token)
38
- expect(cmd).to match(/ssh root@abs-hostname.delivery.puppetlabs.net/)
43
+ context "for pooled requests" do
44
+ it 'gets a hostname string for abs' do
45
+ verbose = false
46
+ service = ServiceStub.new
47
+ host_os = 'abs_host_string'
48
+ use_token = false
49
+ cmd = Ssh.command_string(verbose, service, host_os, use_token)
50
+ expect(cmd).to match(/ssh root@abs-hostname.delivery.puppetlabs.net/)
51
+ end
52
+
53
+ it 'gets a hostname string for vmpooler api v1' do
54
+ verbose = true
55
+ service = ServiceStub.new
56
+ host_os = 'vmpooler_api_v1_host_string'
57
+ use_token = false
58
+ cmd = Ssh.command_string(verbose, service, host_os, use_token)
59
+ expect(cmd).to match(/ssh root@vmpooler-v1-hostname.delivery.puppetlabs.net/)
60
+ end
61
+
62
+ it 'gets a hostname string for vmpooler api v2' do
63
+ verbose = false
64
+ service = ServiceStub.new
65
+ host_os = 'vmpooler_api_v2_host_string'
66
+ use_token = false
67
+ cmd = Ssh.command_string(verbose, service, host_os, use_token)
68
+ expect(cmd).to match(/ssh root@vmpooler-v2-hostname.delivery.puppetlabs.net/)
69
+ end
39
70
  end
40
71
 
41
- it 'gets a hostname string for vmpooler' do
42
- verbose = false
43
- service = ServiceStub.new
44
- host_os = 'vmpooler_host_string'
45
- use_token = false
46
- cmd = Ssh.command_string(verbose, service, host_os, use_token)
47
- expect(cmd).to match(/ssh root@vmpooler-hostname.delivery.puppetlabs.net/)
72
+ context "for ondemand requests" do
73
+ let(:service) { ServiceStub.new }
74
+ let(:url) { 'http://pooler.example.com' }
75
+
76
+ it 'gets a hostname string for abs' do
77
+ verbose = false
78
+ host_os = 'abs_host_string'
79
+ use_token = false
80
+ ondemand = true
81
+ response = {'abs_host_string' => { 'hostname' => ['abs-hostname.delivery.puppetlabs.net']}}
82
+ allow(service).to receive(:url)
83
+ allow(service).to receive(:check_ondemandvm).and_return(response)
84
+ cmd = Ssh.command_string(verbose, service, host_os, use_token, ondemand)
85
+ expect(cmd).to match(/ssh root@abs-hostname.delivery.puppetlabs.net/)
86
+ end
87
+
88
+ it 'gets a hostname string for abs' do
89
+ verbose = false
90
+ host_os = 'vmpooler_api_v1_host_string'
91
+ use_token = false
92
+ ondemand = true
93
+ response = {'vmpooler_api_v1_host_string' => { 'hostname' => ['vmpooler_api_v1_host_string.delivery.puppetlabs.net']}}
94
+ allow(service).to receive(:url)
95
+ allow(service).to receive(:check_ondemandvm).and_return(response)
96
+ cmd = Ssh.command_string(verbose, service, host_os, use_token, ondemand)
97
+ expect(cmd).to match(/ssh root@vmpooler_api_v1_host_string.delivery.puppetlabs.net/)
98
+ end
99
+
100
+ it 'gets a hostname string for abs' do
101
+ verbose = false
102
+ host_os = 'vmpooler_api_v2_host_string'
103
+ use_token = false
104
+ ondemand = true
105
+ response = {'vmpooler_api_v2_host_string' => { 'hostname' => ['vmpooler_api_v2_host_string.delivery.puppetlabs.net']}}
106
+ allow(service).to receive(:url)
107
+ allow(service).to receive(:check_ondemandvm).and_return(response)
108
+ cmd = Ssh.command_string(verbose, service, host_os, use_token, ondemand)
109
+ expect(cmd).to match(/ssh root@vmpooler_api_v2_host_string.delivery.puppetlabs.net/)
110
+ end
48
111
  end
49
112
  end
@@ -13,7 +13,7 @@ end
13
13
  describe Utils do
14
14
  describe '#standardize_hostnames' do
15
15
  before :each do
16
- @vmpooler_response_body = '{
16
+ @vmpooler_api_v1_response_body = '{
17
17
  "ok": true,
18
18
  "domain": "delivery.mycompany.net",
19
19
  "ubuntu-1610-x86_64": {
@@ -23,6 +23,15 @@ describe Utils do
23
23
  "hostname": "dlgietfmgeegry2"
24
24
  }
25
25
  }'
26
+ @vmpooler_api_v2_response_body = '{
27
+ "ok": true,
28
+ "ubuntu-1610-x86_64": {
29
+ "hostname": ["gdoy8q3nckuob0i.delivery.mycompany.net", "ctnktsd0u11p9tm.delivery.mycompany.net"]
30
+ },
31
+ "centos-7-x86_64": {
32
+ "hostname": "dlgietfmgeegry2.delivery.mycompany.net"
33
+ }
34
+ }'
26
35
  @nonstandard_response_body = '{
27
36
  "ok": true,
28
37
  "solaris-10-sparc": {
@@ -34,8 +43,15 @@ describe Utils do
34
43
  }'
35
44
  end
36
45
 
37
- it 'formats a result from vmpooler into a hash of os to hostnames' do
38
- result = Utils.standardize_hostnames(JSON.parse(@vmpooler_response_body))
46
+ it 'formats a result from vmpooler v1 api into a hash of os to hostnames' do
47
+ result = Utils.standardize_hostnames(JSON.parse(@vmpooler_api_v1_response_body))
48
+ expect(result).to eq('centos-7-x86_64' => ['dlgietfmgeegry2.delivery.mycompany.net'],
49
+ 'ubuntu-1610-x86_64' => ['gdoy8q3nckuob0i.delivery.mycompany.net',
50
+ 'ctnktsd0u11p9tm.delivery.mycompany.net'])
51
+ end
52
+
53
+ it 'formats a result from vmpooler v2 api into a hash of os to hostnames' do
54
+ result = Utils.standardize_hostnames(JSON.parse(@vmpooler_api_v2_response_body))
39
55
  expect(result).to eq('centos-7-x86_64' => ['dlgietfmgeegry2.delivery.mycompany.net'],
40
56
  'ubuntu-1610-x86_64' => ['gdoy8q3nckuob0i.delivery.mycompany.net',
41
57
  'ctnktsd0u11p9tm.delivery.mycompany.net'])
@@ -264,7 +280,73 @@ describe Utils do
264
280
 
265
281
  subject { Utils.pretty_print_hosts(verbose, service, hostname, print_to_stderr) }
266
282
 
267
- 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
268
350
  let(:service) { Service.new(MockOptions.new, 'url' => url) }
269
351
 
270
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.6.0
4
+ version: 1.8.0
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: 2022-02-16 00:00:00.000000000 Z
12
+ date: 2023-03-21 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: commander
@@ -52,9 +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:
56
- - brianccain@gmail.com
57
- - dio-gems@puppet.com
55
+ email: info@puppet.com
58
56
  executables:
59
57
  - floaty
60
58
  extensions: []
@@ -107,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
107
105
  - !ruby/object:Gem::Version
108
106
  version: '0'
109
107
  requirements: []
110
- rubygems_version: 3.2.32
108
+ rubygems_version: 3.3.26
111
109
  signing_key:
112
110
  specification_version: 4
113
111
  summary: CLI application to interface with vmpooler