floatyhelper 1.0 → 1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 15888ba1cfc729b4e52f5a0dd5c33e3c7873439e8c6c5422509c17ac264d0878
4
- data.tar.gz: bae08f4e75b2530ba10d9a028f2346a3c89e5706015fea4258e8f1fd118e2bb6
3
+ metadata.gz: 3ec4a8e272838f94aa48d2917739aa2c57396f25e9e156e12f98e6e210732b5c
4
+ data.tar.gz: 1af47c81157071dc4d72bcf48d62a726cb71f43c888048dab878b4ef6e1d93af
5
5
  SHA512:
6
- metadata.gz: 888ebc61101ac904f1893d3698edf7adbfc41d31b34c722dbe3a21ac8c9aa538db6711f1485f2297251527787fbb4e13fb5bf1ae066cbe676ba461ac1c360743
7
- data.tar.gz: 36a956a699d35d51e7af96d6a646392dfb4871605194a924a7843031742b390da071ffdc5df147c7752eb2741473c7be9a146a2d702477b36ac070bd53c3935d
6
+ metadata.gz: 64d4f6adfd316a906db6a196afced6649892c03a119bb76d73367d0684122ae4fe7c52854ad497d254e4d7622a78eab58dcf690b4675a72b6e2cda1f2a95327e
7
+ data.tar.gz: 3f2f6b0bb5066b5b9a17f39c412160906da339a2d53b3792bb177e0a1edc94aca50689b297ad940cb88a29a4a8acbbffc2c52bb792376afb0d24079a8e913e8d
data/lib/floatyhelper.rb CHANGED
@@ -41,7 +41,7 @@ class Floatyhelper
41
41
  c.syntax = 'floatyhelper list'
42
42
  c.summary = 'List all VMs and their associated tags'
43
43
  c.description = 'This lists all VMs currently defined in the status.yaml file, added via the addhosts command, and their associated tags.'
44
- c.option '--nocheck', 'Do not check remaining lifetime of each VM'
44
+ c.option '--check', 'Check remaining lifetime of each VM'
45
45
  c.action do |args, options|
46
46
  data = Conf.load_data
47
47
  if data['vms'].keys.length == 0
@@ -51,11 +51,11 @@ class Floatyhelper
51
51
  puts "#{tag}:"
52
52
  hosts.each do |host|
53
53
  remaining = ''
54
- unless options.nocheck
54
+ if options.check
55
55
  query = VM.query(host)
56
56
  remaining = VM.alive(host, query) ? "#{query[host]['remaining']} hours remaining" : "Expired"
57
57
  end
58
- puts " #{host}\t#{remaining}"
58
+ puts " %-15s %s" % [host, remaining]
59
59
  end
60
60
  end
61
61
  end
@@ -274,20 +274,25 @@ class Floatyhelper
274
274
  data = Conf.load_data
275
275
  expired = false
276
276
  data['vms'].each do |tag, hosts|
277
- is_alive = false
277
+ expired_hosts = []
278
278
  hosts.each do |host|
279
- is_alive |= VM.alive(host)
279
+ expired_hosts << host unless VM.alive(host)
280
280
  end
281
- unless is_alive
281
+ unless expired_hosts.empty?
282
282
  expired = true
283
- if options.y
284
- answer = 'y'
283
+ if expired_hosts & hosts == hosts
284
+ answer = options.y ? 'y' : ask("All hosts in tag #{tag} have expired. Delete this tag? [Y/n] ".yellow)
285
+ if answer.empty? || answer.capitalize == 'Y'
286
+ Groups.delete_tag(tag)
287
+ puts "Tag #{tag} deleted".green
288
+ end
285
289
  else
286
- answer = ask "All hosts in tag #{tag} have expired. Delete this tag? [Y/n] ".yellow
287
- end
288
- if answer.empty? || answer.capitalize == 'Y'
289
- Groups.delete_tag(tag)
290
- puts "Tag #{tag} deleted".green
290
+ expired_hosts.each { |host| puts "#{host}".yellow } unless options.y
291
+ answer = options.y ? 'y' : ask("The above hosts in tag #{tag} have expired. Delete these hosts from the tag? [Y/n]".yellow)
292
+ if answer.empty? || answer.capitalize == 'Y'
293
+ Groups.removehosts(expired_hosts, tag)
294
+ puts "Expired hosts from #{tag} deleted".green
295
+ end
291
296
  end
292
297
  end
293
298
  end
@@ -1,3 +1,3 @@
1
1
  module Floatyhelper
2
- VERSION = "1.0"
2
+ VERSION = "1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: floatyhelper
3
3
  version: !ruby/object:Gem::Version
4
- version: '1.0'
4
+ version: '1.1'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nick Burgan-Illig
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-30 00:00:00.000000000 Z
11
+ date: 2019-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler