vmfloaty 1.4.0 → 1.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +25 -9
- data/lib/vmfloaty/service.rb +2 -2
- data/lib/vmfloaty/ssh.rb +27 -9
- data/lib/vmfloaty/utils.rb +25 -10
- data/lib/vmfloaty/version.rb +1 -1
- data/lib/vmfloaty.rb +3 -2
- data/spec/spec_helper.rb +13 -5
- data/spec/vmfloaty/ssh_spec.rb +85 -22
- data/spec/vmfloaty/utils_spec.rb +22 -6
- metadata +4 -20
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 259a0672eabcb43fbb7fddd8205341050ab60f902e7842cb520f81bab1f139eb
|
4
|
+
data.tar.gz: 22fdda03271053a921f305c6e547d09308d1d734bc77dfbd60bbbf47483e4137
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c0ca6bc4d734b7b0712001d7bd33b8b493cdf2e588712d422383631ef9a749f8b98964ff6a8b05dd2c4c465fb0726af3af88692bc4baa94278c546461614bc4
|
7
|
+
data.tar.gz: 072a4ab26891877393d3b70bc71d409b0a7dccd930bc6271fe6cf6bd7e16fe10e5fcd250b8313112afb9e8e9f25043c41d5173ad6bc0fb121d7e1f8255e74d4d
|
data/README.md
CHANGED
@@ -1,11 +1,9 @@
|
|
1
1
|
# vmfloaty
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/vmfloaty.svg)](https://badge.fury.io/rb/vmfloaty)
|
4
|
-
[![
|
5
|
-
[![Coverage Status](https://coveralls.io/repos/github/puppetlabs/vmfloaty/badge.svg?branch=master)](https://coveralls.io/github/puppetlabs/vmfloaty?branch=master)
|
6
|
-
[![Dependabot Status](https://api.dependabot.com/badges/status?host=github&repo=puppetlabs/vmfloaty)](https://dependabot.com)
|
4
|
+
[![CI](https://github.com/puppetlabs/vmfloaty/actions/workflows/ci.yml/badge.svg)](https://github.com/puppetlabs/vmfloaty/actions/workflows/ci.yml)
|
7
5
|
|
8
|
-
A CLI helper tool for [Puppet's
|
6
|
+
A CLI helper tool for [Puppet's VMPooler](https://github.com/puppetlabs/vmpooler) to help you stay afloat.
|
9
7
|
|
10
8
|
![float image](float.jpg)
|
11
9
|
|
@@ -18,9 +16,12 @@ A CLI helper tool for [Puppet's vmpooler](https://github.com/puppetlabs/vmpooler
|
|
18
16
|
- [Using backends besides VMPooler](#using-backends-besides-vmpooler)
|
19
17
|
- [Valid config keys](#valid-config-keys)
|
20
18
|
- [Tab Completion](#tab-completion)
|
21
|
-
- [
|
19
|
+
- [VMPooler API](#vmpooler-api)
|
22
20
|
- [Using the Pooler class](#using-the-pooler-class)
|
23
21
|
- [Example Projects](#example-projects)
|
22
|
+
- [Contributing](#contributing)
|
23
|
+
- [Code Reviews](#code-reviews)
|
24
|
+
- [Releasing](#releasing)
|
24
25
|
- [Special thanks](#special-thanks)
|
25
26
|
|
26
27
|
## Install
|
@@ -41,7 +42,7 @@ $ floaty --help
|
|
41
42
|
|
42
43
|
DESCRIPTION:
|
43
44
|
|
44
|
-
A CLI helper tool for Puppet's
|
45
|
+
A CLI helper tool for Puppet's VMPooler to help you stay afloat
|
45
46
|
|
46
47
|
COMMANDS:
|
47
48
|
|
@@ -151,13 +152,13 @@ There is also tab completion for zsh:
|
|
151
152
|
source $(floaty completion --shell zsh)
|
152
153
|
```
|
153
154
|
|
154
|
-
##
|
155
|
+
## VMPooler API
|
155
156
|
|
156
|
-
This cli tool uses the [
|
157
|
+
This cli tool uses the [VMPooler API](https://github.com/puppetlabs/vmpooler/blob/master/API.md).
|
157
158
|
|
158
159
|
## Using the Pooler class
|
159
160
|
|
160
|
-
vmfloaty providers a `Pooler` class that gives users the ability to make requests to
|
161
|
+
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.
|
161
162
|
|
162
163
|
### Example Projects
|
163
164
|
|
@@ -166,6 +167,21 @@ vmfloaty providers a `Pooler` class that gives users the ability to make request
|
|
166
167
|
- [Brian Cain: vagrant-vmpooler](https://github.com/briancain/vagrant-vmpooler)
|
167
168
|
- Use Vagrant to manage your vmpooler instances
|
168
169
|
|
170
|
+
## Contributing
|
171
|
+
|
172
|
+
PR's are welcome! We always love to see how others think this tool can be made better.
|
173
|
+
|
174
|
+
### Code Reviews
|
175
|
+
|
176
|
+
Please wait for multiple code owners to sign off on any notable change.
|
177
|
+
|
178
|
+
## Releasing
|
179
|
+
|
180
|
+
Releasing is a two step process:
|
181
|
+
|
182
|
+
1. Submit a release prep PR that updates `lib/vmfloaty/version.rb` to the desired new version and get that merged
|
183
|
+
2. 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.
|
184
|
+
|
169
185
|
## Special thanks
|
170
186
|
|
171
187
|
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.
|
data/lib/vmfloaty/service.rb
CHANGED
@@ -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
|
-
|
30
|
-
|
31
|
-
|
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)
|
data/lib/vmfloaty/utils.rb
CHANGED
@@ -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
|
-
|
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
|
@@ -137,14 +152,14 @@ class Utils
|
|
137
152
|
metadata = [host_data['state'], host_data['template'], duration, *tag_pairs]
|
138
153
|
message = "- #{hostname}.#{host_data['domain']} (#{metadata.join(', ')})".gsub(/^/, ' ' * indent)
|
139
154
|
if host_data['state'] && host_data['state'] == 'destroyed'
|
140
|
-
output_target.puts
|
155
|
+
output_target.puts "- DESTROYED #{hostname}.#{host_data['domain']}".gsub(/^/, ' ' * indent)
|
141
156
|
else
|
142
157
|
output_target.puts message
|
143
158
|
end
|
144
159
|
when 'NonstandardPooler'
|
145
160
|
line = "- #{host_data['fqdn']} (#{host_data['os_triple']}"
|
146
161
|
line += ", #{host_data['hours_left_on_reservation']}h remaining"
|
147
|
-
line += ", reason: #{host_data['reserved_for_reason']}" unless host_data['reserved_for_reason'].empty?
|
162
|
+
line += ", reason: #{host_data['reserved_for_reason']}" unless host_data['reserved_for_reason'].nil? || host_data['reserved_for_reason'].empty?
|
148
163
|
line += ')'
|
149
164
|
output_target.puts line
|
150
165
|
else
|
@@ -197,11 +212,11 @@ class Utils
|
|
197
212
|
pending = pool['pending']
|
198
213
|
missing = max - ready - pending
|
199
214
|
char = 'o'
|
200
|
-
puts "#{name.ljust(width)} #{(char * ready)
|
215
|
+
puts "#{name.ljust(width)} #{(char * ready)}#{(char * pending)}#{(char * missing)}"
|
201
216
|
rescue StandardError => e
|
202
|
-
FloatyLogger.error "#{name.ljust(width)} #{e
|
217
|
+
FloatyLogger.error "#{name.ljust(width)} #{e}"
|
203
218
|
end
|
204
|
-
puts message
|
219
|
+
puts message
|
205
220
|
when 'NonstandardPooler'
|
206
221
|
pools = status_response
|
207
222
|
pools.delete 'ok'
|
@@ -214,13 +229,13 @@ class Utils
|
|
214
229
|
pending = pool['pending'] || 0 # not available for nspooler
|
215
230
|
missing = max - ready - pending
|
216
231
|
char = 'o'
|
217
|
-
puts "#{name.ljust(width)} #{(char * ready)
|
232
|
+
puts "#{name.ljust(width)} #{(char * ready)}#{(char * pending)}#{(char * missing)}"
|
218
233
|
rescue StandardError => e
|
219
|
-
FloatyLogger.error "#{name.ljust(width)} #{e
|
234
|
+
FloatyLogger.error "#{name.ljust(width)} #{e}"
|
220
235
|
end
|
221
236
|
when 'ABS'
|
222
237
|
FloatyLogger.error 'ABS Not OK' unless status_response
|
223
|
-
puts 'ABS is OK'
|
238
|
+
puts 'ABS is OK' if status_response
|
224
239
|
else
|
225
240
|
raise "Invalid service type #{service.type}"
|
226
241
|
end
|
data/lib/vmfloaty/version.rb
CHANGED
data/lib/vmfloaty.rb
CHANGED
@@ -2,7 +2,6 @@
|
|
2
2
|
|
3
3
|
require 'rubygems'
|
4
4
|
require 'commander'
|
5
|
-
require 'colorize'
|
6
5
|
require 'json'
|
7
6
|
require 'pp'
|
8
7
|
require 'uri'
|
@@ -469,6 +468,8 @@ class Vmfloaty
|
|
469
468
|
c.option '--user STRING', String, 'User to authenticate with'
|
470
469
|
c.option '--token STRING', String, 'Token for pooler service'
|
471
470
|
c.option '--notoken', 'Makes a request without a token'
|
471
|
+
c.option '--priority STRING', 'Priority for supported backends(ABS) (High(1), Medium(2), Low(3))'
|
472
|
+
c.option '--ondemand', 'Requested vms are provisioned upon receival of the request, tracked by a request ID'
|
472
473
|
c.action do |args, options|
|
473
474
|
verbose = options.verbose || config['verbose']
|
474
475
|
service = Service.new(options, config)
|
@@ -483,7 +484,7 @@ class Vmfloaty
|
|
483
484
|
|
484
485
|
FloatyLogger.info "Can't ssh to multiple hosts; Using #{host_os} only..." if args.length > 1
|
485
486
|
|
486
|
-
service.ssh(verbose, host_os, use_token)
|
487
|
+
service.ssh(verbose, host_os, use_token, options.ondemand)
|
487
488
|
exit 0
|
488
489
|
end
|
489
490
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,13 +1,21 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
require 'simplecov'
|
4
|
-
require '
|
4
|
+
require 'simplecov-lcov'
|
5
5
|
require 'base64'
|
6
6
|
|
7
|
-
SimpleCov
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
SimpleCov::Formatter::LcovFormatter.config do |c|
|
8
|
+
c.report_with_single_file = true
|
9
|
+
c.single_report_path = 'coverage/lcov.info'
|
10
|
+
end
|
11
|
+
|
12
|
+
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter.new(
|
13
|
+
[
|
14
|
+
SimpleCov::Formatter::HTMLFormatter,
|
15
|
+
SimpleCov::Formatter::LcovFormatter
|
16
|
+
]
|
17
|
+
)
|
18
|
+
|
11
19
|
SimpleCov.start do
|
12
20
|
add_filter %r{^/spec/}
|
13
21
|
end
|
data/spec/vmfloaty/ssh_spec.rb
CHANGED
@@ -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
|
-
|
17
|
-
|
18
|
-
|
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 == '
|
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
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
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
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
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
|
data/spec/vmfloaty/utils_spec.rb
CHANGED
@@ -13,7 +13,7 @@ end
|
|
13
13
|
describe Utils do
|
14
14
|
describe '#standardize_hostnames' do
|
15
15
|
before :each do
|
16
|
-
@
|
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(@
|
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'])
|
@@ -466,13 +482,13 @@ describe Utils do
|
|
466
482
|
subject
|
467
483
|
end
|
468
484
|
|
469
|
-
it 'prints
|
485
|
+
it 'prints DESTROYED and hostname when destroyed' do
|
470
486
|
fallback = { 'vmpooler_fallback' => 'vmpooler' }
|
471
487
|
service.config.merge! fallback
|
472
488
|
response_body_vmpooler[fqdn_hostname]['state'] = 'destroyed'
|
473
|
-
|
489
|
+
default_output_second_line = " - DESTROYED #{fqdn}"
|
474
490
|
expect($stdout).to receive(:puts).with(default_output_first_line)
|
475
|
-
expect($stdout).to receive(:puts).with(
|
491
|
+
expect($stdout).to receive(:puts).with(default_output_second_line)
|
476
492
|
|
477
493
|
subject
|
478
494
|
end
|
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.7.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Cain
|
@@ -9,22 +9,8 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2022-04-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
-
- !ruby/object:Gem::Dependency
|
15
|
-
name: colorize
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
requirements:
|
18
|
-
- - "~>"
|
19
|
-
- !ruby/object:Gem::Version
|
20
|
-
version: 0.8.1
|
21
|
-
type: :runtime
|
22
|
-
prerelease: false
|
23
|
-
version_requirements: !ruby/object:Gem::Requirement
|
24
|
-
requirements:
|
25
|
-
- - "~>"
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
version: 0.8.1
|
28
14
|
- !ruby/object:Gem::Dependency
|
29
15
|
name: commander
|
30
16
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,9 +52,7 @@ dependencies:
|
|
66
52
|
- !ruby/object:Gem::Version
|
67
53
|
version: 1.5.1
|
68
54
|
description: A helper tool for vmpooler to help you stay afloat
|
69
|
-
email:
|
70
|
-
- brianccain@gmail.com
|
71
|
-
- dio-gems@puppet.com
|
55
|
+
email: dio-gems@puppet.com
|
72
56
|
executables:
|
73
57
|
- floaty
|
74
58
|
extensions: []
|
@@ -121,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
121
105
|
- !ruby/object:Gem::Version
|
122
106
|
version: '0'
|
123
107
|
requirements: []
|
124
|
-
rubygems_version: 3.2.
|
108
|
+
rubygems_version: 3.2.32
|
125
109
|
signing_key:
|
126
110
|
specification_version: 4
|
127
111
|
summary: CLI application to interface with vmpooler
|