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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7f2eaf3fd1178351347feaa7733d6742ac0f5dc9
4
- data.tar.gz: b62b58f255127ad8b9566805f962b070c1f590fe
3
+ metadata.gz: 5e9839332624e775b43ac11d341814f66e08af2e
4
+ data.tar.gz: 1d7c9903d7a1c0f8b7005796163de932deeaa0cf
5
5
  SHA512:
6
- metadata.gz: 15e588134c795f3014e09e980c0d84b22aa8e477404ecf8ebf74240ab03aa4290903e95dc528c4081fd8915f42e955c6ca84055122d84353a60dc62a69d2c830
7
- data.tar.gz: 283f9468a507845eac92cd8f74d486aacc63fca9e3ffafc9b50a086660ffd9f1ec35dbfbda0aeb03c6bc857e2e9efad109e23eaa6beeebda8744ec742b3195a7
6
+ metadata.gz: 0905e72f1f27ff2f8deec1931949b1772b39cfba8613f493c9e997d0cd36cd688ef43f62a57391e258332a40273557bf2fba95fe2e2b141c8cda06b57621324d
7
+ data.tar.gz: 7b4049b1384737e711d8f1946d51290aa234e6cbbccf8741de802603351d5a070013eaba14b3dee91d6bd2db3b30902ca6e99a341a257438cac2cd16708b9e31
@@ -94,6 +94,10 @@ class Pooler
94
94
  end
95
95
 
96
96
  def self.delete(verbose, url, hosts, token)
97
+ if token.nil?
98
+ raise TokenError, "Token provided was nil. Request cannot be made to delete vm"
99
+ end
100
+
97
101
  conn = Http.get_conn(verbose, url)
98
102
 
99
103
  if token
@@ -1,6 +1,6 @@
1
1
 
2
2
  class Version
3
- @version = '0.7.2'
3
+ @version = '0.7.3'
4
4
 
5
5
  def self.get
6
6
  @version
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
- Pooler.delete(verbose, url, hosts, token)
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
- pp status
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.2
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-12 00:00:00.000000000 Z
11
+ date: 2016-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commander