floatyhelper 1.2 → 1.4

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: 47ee4302416a75ac2d3833651e42e48a78bec672c2b01b71a443c1a757c965ed
4
- data.tar.gz: 03a74f9eb941e32c7d594ecfcb7e618b6de61dc6e14ca26bf5218dd996afba99
3
+ metadata.gz: b9107871b6337de1b4508247eebc2f59e1250e5ed7b61a4ee358f3e7d920e5e5
4
+ data.tar.gz: d346fccc76b850c599d9ab7bef16e2a5eebb51897482158e273d45c7082bb9fa
5
5
  SHA512:
6
- metadata.gz: 1fe09821098beea2bb66b3e0629f531728dda29c7da57fe053946ce248bd84df25fc5ff704feaa0e69241320cbbe02fd0f2b30aa476cccc53abe5fcefd56b5ce
7
- data.tar.gz: 025641c3d7e9515258e4e370d4fb598cc6fb4998edd859549981e3214b0aae3d8cfed1f9e12d3cbcece725bd5f15c736635b416755e69d93ae9e26eeffe00d18
6
+ metadata.gz: 23e2932ddc4a3f11edbd8cff698420d83f3e41c9e0e13b92b8391e6eb474cfe5078958542e4b572a9f99728ed2a7fe6832fba17d9f3958d744da153cfb537832
7
+ data.tar.gz: 1600273e214fb4abf841f64150ccaf393e14088e312e3147af8adb9c2634e4ce4c3642c0974470e03bf96a37147657d7750a5e7ae44940a38fe8bb0b0445747e
@@ -15,7 +15,7 @@ class Floatyhelper
15
15
  def run
16
16
  program :name, 'floatyhelper'
17
17
  program :version, '1.0.0'
18
- program :description, <<-EOT
18
+ program :description, <<~EOT
19
19
  Commands for manipulating vmpooler VMs with floaty. Use the addhosts command from within a pe_acceptance_tests folder
20
20
  that has recently finished a run to add those hosts to the list of hosts managed by floatyhelper (or specify a sut.log
21
21
  file directly).
@@ -38,24 +38,31 @@ class Floatyhelper
38
38
  end
39
39
 
40
40
  command :list do |c|
41
- c.syntax = 'floatyhelper list'
41
+ c.syntax = 'floatyhelper list [tag]'
42
42
  c.summary = 'List all VMs and their associated tags'
43
- c.description = 'This lists all VMs currently defined in the status.yaml file, added via the addhosts command, and their associated tags.'
43
+ c.description = <<~EOT
44
+ This lists all VMs currently defined in the status.yaml file, added via the addhosts command, and their associated tags.
45
+ If a tag is specified, it will only lists the hosts in that tag.
46
+ EOT
44
47
  c.option '--check', 'Check remaining lifetime of each VM'
45
48
  c.action do |args, options|
46
49
  data = Conf.load_data
47
50
  if data['vms'].keys.length == 0
48
51
  puts 'No VM groups are defined'.yellow
49
52
  else
53
+ requested_tag = args.count > 0 ? args[0] : nil
50
54
  data['vms'].each do |tag, hosts|
55
+ next if requested_tag && requested_tag != tag
51
56
  puts "#{tag}:"
52
57
  hosts.each do |host|
53
58
  remaining = ''
59
+ type = ''
54
60
  if options.check
55
61
  query = VM.query(host)
62
+ type = query[host]['template'].gsub('-pixa4','')
56
63
  remaining = VM.alive(host, query) ? "#{query[host]['remaining']} hours remaining" : "Expired"
57
64
  end
58
- puts " %-15s %s" % [host, remaining]
65
+ puts " %-15s %-28s %s" % [host, type, remaining]
59
66
  end
60
67
  end
61
68
  end
@@ -63,11 +70,14 @@ class Floatyhelper
63
70
  end
64
71
 
65
72
  command :check do |c|
66
- c.syntax = 'floatyhelper check'
73
+ c.syntax = 'floatyhelper check [tag]'
67
74
  c.summary = 'Checks the remaining lifetime of each tracked VM.'
68
- c.description = 'Same as floatyhelper list --check. Checks the remaining lifetime of each tracked VM.'
75
+ c.description = <<~EOT
76
+ Same as floatyhelper list --check. Checks the remaining lifetime of each tracked VM.
77
+ If a tag is specified, it will only check hosts in that tag.
78
+ EOT
69
79
  c.action do |args, options|
70
- command(:list).run('--check')
80
+ command(:list).run(*args,'--check')
71
81
  end
72
82
  end
73
83
 
@@ -261,6 +271,7 @@ class Floatyhelper
261
271
  c.syntax = 'floatyhelper snapshot <host|tag> <snaptag>'
262
272
  c.summary = 'Snapshot the given VM or group of taggedhosts'
263
273
  c.description = 'Creates a snapshot of a host or group of tagged hosts, and defines a string to use as a "snaptag" to refer to this group of snapshots.'
274
+ c.option '--clr', 'Clear screen and show VMs in a column when checking status, rather than a single line.'
264
275
  c.action do |args, options|
265
276
  if args.length < 2
266
277
  puts "Please specify both a host/tag and a snaptag"
@@ -269,7 +280,7 @@ class Floatyhelper
269
280
  answer = ask "Snaptag #{args[1]} already exists. Are you sure you want to overwrite? [y/N] ".yellow
270
281
  return unless answer.capitalize == 'Y'
271
282
  end
272
- VM.snapshot(args[0], args[1])
283
+ VM.snapshot(args[0], args[1], options.clr)
273
284
  end
274
285
  end
275
286
  end
@@ -1,3 +1,3 @@
1
1
  module Floatyhelper
2
- VERSION = "1.2"
2
+ VERSION = "1.4"
3
3
  end
@@ -40,7 +40,7 @@ class VM
40
40
  end
41
41
  end
42
42
 
43
- def self.snapshot(id, snaptag)
43
+ def self.snapshot(id, snaptag, clr=false)
44
44
  snaptag = 'Blank Snaptag' unless snaptag
45
45
  hosts = Hosts.get_hosts_from_id(id)
46
46
  shas = {}
@@ -54,27 +54,30 @@ class VM
54
54
  shas[host] = sha
55
55
  end
56
56
 
57
+ data = Conf.load_data
58
+ data['snapshots'] ||= {}
59
+ data['snapshots'][id] ||= {}
60
+ data['snapshots'][id][snaptag] = shas
61
+ Conf.write_data(data)
62
+
63
+ puts `tput clear` if clr
57
64
  puts 'Waiting for snapshots to appear in floaty query...'
58
65
  alldone = false
59
66
  while !alldone do
67
+ puts `tput cup 1` if clr
60
68
  alldone = true
61
- print "\r"
69
+ print "\r" unless clr
62
70
  hosts.each do |host|
63
71
  answer = eval(`floaty query #{host}`)[host]
64
72
  done = answer.keys.include?('snapshots') && answer['snapshots'].include?(shas[host])
65
73
  status = done ? 'Done' : 'Wait'
66
- print "* #{host}: #{status} *"
74
+ print "* #{host}: #{status} *" unless clr
75
+ puts "* #{host}: #{status} *" if clr
67
76
  alldone &= done
68
77
  end
69
78
  sleep(1)
70
79
  end
71
80
  puts ''
72
-
73
- data = Conf.load_data
74
- data['snapshots'] ||= {}
75
- data['snapshots'][id] ||= {}
76
- data['snapshots'][id][snaptag] = shas
77
- Conf.write_data(data)
78
81
  end
79
82
 
80
83
  def self.getsnapshot(id, snaptag)
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.2'
4
+ version: '1.4'
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: 2020-01-15 00:00:00.000000000 Z
11
+ date: 2020-06-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler