floatyhelper 2.0.2 → 2.0.3

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: d7024e7ae1ace180d0ba623a779142751f111ca132c7a1511fc639df0813e8f7
4
- data.tar.gz: 3f485a4d782fb4cfd9d9046a37b849f7ed6fdc9612801b52c68fda2df248ea31
3
+ metadata.gz: 431619b53e0f4ef48e234d613b2bd3c4c9c91e62b5366805e50edbb256f81499
4
+ data.tar.gz: 213649667596adfeb3d293cd4862f3f9a6eaffd15137fa581039801729d20ae4
5
5
  SHA512:
6
- metadata.gz: 3160e2841c6e1a56bbae01ef957e0d630cc0e1d73954bbb548fb0c715b0d252cbec65da8d4f19fc6aa6a9e7b5aade015185562dfcfdd56920810d9b4931169b4
7
- data.tar.gz: 71e1c753ad8c414ca6b4c0c914ced8c3c3682d4b6db4be09911d5a4723ad99aee33209a2596e9cff20297d59260659c7ba483855d257b7496394454fee193300
6
+ metadata.gz: db5cc8257144b831c73b76132dfa647bc8d03bc98fcd84ef6a2de1a9613866967e8ffc16ddb3f6961eea62eb08b83e537d07f4fbe5e67cc7475f0b4515df0ece
7
+ data.tar.gz: 45e795caf7ab69ba2f3d0ff980396cb24220233334fd524a1292cbafad934123c642cfeb2248dfd1b97c5b5a926d8109167b1f8bc7143a1890a3547fa67837bc
data/lib/floatyhelper.rb CHANGED
@@ -113,8 +113,10 @@ class Floatyhelper
113
113
  type = ''
114
114
  if options.check
115
115
  query = VM.query(host)
116
- type = query[host]['template'].gsub('-pixa4','')
117
- remaining = VM.alive(host, query) ? "#{query[host]['remaining']} hours remaining" : 'Expired'
116
+ if query && query['ok']
117
+ type = query[host]['template'].gsub('-pixa4','')
118
+ remaining = VM.alive(host, query) ? "#{query[host]['remaining']} hours remaining" : 'Expired'
119
+ end
118
120
  end
119
121
  puts ' %-15s %-28s %s' % [host, type, remaining]
120
122
  end
@@ -81,7 +81,7 @@ class Floaty
81
81
  def self.check_tokens
82
82
  data = load_vmfloaty_config
83
83
  issues = false
84
- FLOATY_SERVICES.each do |service, _info|
84
+ FLOATY_SERVICES.each do |service, info|
85
85
  if data['services'].nil? || data['services'][service].nil? || data['services'][service]['token'].nil?
86
86
  puts "#{service} service token not found in .vmfloaty.yml".yellow
87
87
  issues = true
@@ -93,7 +93,13 @@ class Floaty
93
93
  next if result['ok']
94
94
 
95
95
  puts "Problem checking #{service} token: #{result['reason']}".red
96
- data['services']['token'] = nil
96
+ data['services'][service]['token'] = nil
97
+ if result['reason'].include?('Unparseable')
98
+ # User might have an old URL. Let's make sure to replace it with the latest.
99
+ # Should probably actually check the output for a 503/404 rather than make the
100
+ # assumption here.
101
+ data['services'][service]['url'] = info['url']
102
+ end
97
103
  issues = true
98
104
  end
99
105
  if issues
@@ -108,6 +114,7 @@ class Floaty
108
114
  # so ignore it until we reach the hash.
109
115
  lines = output.split("\n")
110
116
  index = lines.index { |l| l[0] == '{' }
117
+ return { 'ok' => false, 'reason' => 'Unparseable response from floaty' } if index.nil?
111
118
  output = lines[index..-1].join
112
119
  JSON.parse(output.gsub('=>',':'))
113
120
  end
@@ -125,8 +132,10 @@ class Floaty
125
132
  while status.nil?
126
133
  begin
127
134
  line = read.gets
128
- puts line
129
- output += line
135
+ unless line.nil?
136
+ puts line
137
+ output += line
138
+ end
130
139
  rescue EOFError, Errno::EIO
131
140
  # GNU/Linux raises EIO on read operation when pty is closed - see pty.rb docs
132
141
  # Ensure child process finishes and then pass through to ensure below to get status
@@ -1,3 +1,3 @@
1
1
  module FloatyhelperVersion
2
- VERSION = '2.0.2'.freeze
2
+ VERSION = '2.0.3'.freeze
3
3
  end
@@ -109,7 +109,7 @@ class VM
109
109
  puts 'Waiting for snapshots to appear in floaty query...'
110
110
  alldone = false
111
111
  until alldone
112
- puts `tput cup #{hosts.count+2}` if clr
112
+ puts `tput cup #{hosts.count + 2}` if clr
113
113
  alldone = true
114
114
  print "\r" unless clr
115
115
  hosts.each do |host|
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: 2.0.2
4
+ version: 2.0.3
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: 2021-03-23 00:00:00.000000000 Z
11
+ date: 2021-03-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler