vmfloaty 0.7.2 → 0.7.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/vmfloaty/pooler.rb +4 -0
- data/lib/vmfloaty/version.rb +1 -1
- data/lib/vmfloaty.rb +38 -2
- data/spec/vmfloaty/pooler_spec.rb +4 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5e9839332624e775b43ac11d341814f66e08af2e
|
4
|
+
data.tar.gz: 1d7c9903d7a1c0f8b7005796163de932deeaa0cf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0905e72f1f27ff2f8deec1931949b1772b39cfba8613f493c9e997d0cd36cd688ef43f62a57391e258332a40273557bf2fba95fe2e2b141c8cda06b57621324d
|
7
|
+
data.tar.gz: 7b4049b1384737e711d8f1946d51290aa234e6cbbccf8741de802603351d5a070013eaba14b3dee91d6bd2db3b30902ca6e99a341a257438cac2cd16708b9e31
|
data/lib/vmfloaty/pooler.rb
CHANGED
data/lib/vmfloaty/version.rb
CHANGED
data/lib/vmfloaty.rb
CHANGED
@@ -2,6 +2,8 @@
|
|
2
2
|
|
3
3
|
require 'rubygems'
|
4
4
|
require 'commander'
|
5
|
+
require 'colorize'
|
6
|
+
require 'json'
|
5
7
|
require 'pp'
|
6
8
|
require 'vmfloaty/auth'
|
7
9
|
require 'vmfloaty/pooler'
|
@@ -336,7 +338,14 @@ class Vmfloaty
|
|
336
338
|
exit 1
|
337
339
|
else
|
338
340
|
hosts = hostnames.split(',')
|
339
|
-
|
341
|
+
begin
|
342
|
+
Pooler.delete(verbose, url, hosts, token)
|
343
|
+
rescue TokenError => e
|
344
|
+
STDERR.puts e
|
345
|
+
exit 1
|
346
|
+
end
|
347
|
+
|
348
|
+
puts "Schedulered vmpooler to delete vms #{hosts}."
|
340
349
|
exit 0
|
341
350
|
end
|
342
351
|
end
|
@@ -406,12 +415,39 @@ class Vmfloaty
|
|
406
415
|
c.example 'Gets the current vmpooler status', 'floaty status --url http://vmpooler.example.com'
|
407
416
|
c.option '--verbose', 'Enables verbose output'
|
408
417
|
c.option '--url STRING', String, 'URL of vmpooler'
|
418
|
+
c.option '--json', 'Prints status in JSON format'
|
409
419
|
c.action do |args, options|
|
410
420
|
verbose = options.verbose || config['verbose']
|
411
421
|
url = options.url ||= config['url']
|
412
422
|
|
413
423
|
status = Pooler.status(verbose, url)
|
414
|
-
|
424
|
+
message = status['status']['message']
|
425
|
+
pools = status['pools']
|
426
|
+
|
427
|
+
if options.json
|
428
|
+
pp status
|
429
|
+
else
|
430
|
+
pools.select! {|name,pool| pool['ready'] < pool['max']} if ! verbose
|
431
|
+
|
432
|
+
width = pools.keys.map(&:length).max
|
433
|
+
pools.each do |name,pool|
|
434
|
+
begin
|
435
|
+
max = pool['max']
|
436
|
+
ready = pool['ready']
|
437
|
+
pending = pool['pending']
|
438
|
+
missing = max - ready - pending
|
439
|
+
char = 'o'
|
440
|
+
puts "#{name.ljust(width)} #{(char*ready).green}#{(char*pending).yellow}#{(char*missing).red}"
|
441
|
+
rescue => e
|
442
|
+
puts "#{name.ljust(width)} #{e.red}"
|
443
|
+
end
|
444
|
+
end
|
445
|
+
|
446
|
+
puts
|
447
|
+
puts message.colorize(status['status']['ok'] ? :default : :red)
|
448
|
+
end
|
449
|
+
|
450
|
+
exit status['status']['ok']
|
415
451
|
end
|
416
452
|
end
|
417
453
|
|
@@ -118,6 +118,10 @@ describe Pooler do
|
|
118
118
|
|
119
119
|
expect(Pooler.delete(false, @vmpooler_url, ['fq6qlpjlsskycq6'], 'mytokenfile')).to eq @delete_response
|
120
120
|
end
|
121
|
+
|
122
|
+
it "raises a token error if no token provided" do
|
123
|
+
expect{ Pooler.delete(false, @vmpooler_url, ['myfakehost'], nil) }.to raise_error(TokenError)
|
124
|
+
end
|
121
125
|
end
|
122
126
|
|
123
127
|
describe "#status" do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: vmfloaty
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.7.
|
4
|
+
version: 0.7.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Cain
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: commander
|