vmfloaty 0.6.0 → 0.6.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
  SHA1:
3
- metadata.gz: 67dbbc5d6d8ccb1f5c5663f9483759784f6a97d4
4
- data.tar.gz: aee780777b391982f50e1cfc2bd84bc74c93e9d1
3
+ metadata.gz: eab6e0237c6ce8afe7ce25cb2573a852bd4e6e63
4
+ data.tar.gz: 6fa9a7232f1814cc602f1e8aa98900b618aab97d
5
5
  SHA512:
6
- metadata.gz: 1f23297133c942c633df3d1b44ab645df7049c43a726739f606d71458fec57b353d05e81123dcf7a5731f923eccd92a6b60e276ffa2fdc99d50c8247dc7686b5
7
- data.tar.gz: ccfc5600caab2e20698052fb299e2db7bdb9b40058cc185aa8308bb5cac872e5333b592d108298301ac3c63e7c40c07da533450c4c40d266740b61dcf3015e01
6
+ metadata.gz: 32cc876286d8dcc6d887dc471d5a4ca7af1bc541a7b838674fea05ff809712367f20e0181fda5182d9cde487e487b69277ae02b84a6972dbe8b11d6011a6996d
7
+ data.tar.gz: a1f92a6bd32a1d30fea8bdb258b03e56440fb81c5bf289510973ce02e8666a19aedfddd3a1a504fc459c3a21f705b3fb93ce46457b39510e4b75abb9ad1beb58
data/lib/vmfloaty.rb CHANGED
@@ -56,8 +56,10 @@ class Vmfloaty
56
56
  end
57
57
  pass = password "Enter your password please:", '*'
58
58
  token = Auth.get_token(verbose, url, user, pass)
59
- puts "\nToken retrieved!"
60
- puts token
59
+ unless token.nil?
60
+ puts "\nToken retrieved!"
61
+ puts token
62
+ end
61
63
  end
62
64
 
63
65
  response = Pooler.retrieve(verbose, os_types, token, url)
@@ -90,11 +92,15 @@ class Vmfloaty
90
92
  if active
91
93
  # list active vms
92
94
  status = Auth.token_status(verbose, url, token)
93
- # print vms
94
- vms = status[token]['vms']
95
- if vms.nil?
96
- STDERR.puts "You have no running vms"
97
- exit 0
95
+ unless status.nil?
96
+ # print vms
97
+ vms = status[token]['vms']
98
+ if vms.nil?
99
+ STDERR.puts "You have no running vms"
100
+ exit 0
101
+ end
102
+ else
103
+ STDERR.puts "Could not retrieve active vms"
98
104
  end
99
105
 
100
106
  running_vms = vms['running']
@@ -194,6 +200,12 @@ class Vmfloaty
194
200
  if delete_all
195
201
  # get vms with token
196
202
  status = Auth.token_status(verbose, url, token)
203
+
204
+ if status.nil?
205
+ STDERR.puts "Could not retrieve status with token"
206
+ exit 1
207
+ end
208
+
197
209
  # print vms
198
210
  vms = status[token]['vms']
199
211
  if vms.nil?
@@ -333,14 +345,26 @@ class Vmfloaty
333
345
  when "get"
334
346
  pass = password "Enter your password please:", '*'
335
347
  token = Auth.get_token(verbose, url, user, pass)
336
- puts token
348
+ unless token.nil?
349
+ puts token
350
+ else
351
+ STDERR.puts 'Could not make a request for a token'
352
+ end
337
353
  when "delete"
338
354
  pass = password "Enter your password please:", '*'
339
355
  result = Auth.delete_token(verbose, url, user, pass, token)
340
- puts result
356
+ unless result.nil?
357
+ puts result
358
+ else
359
+ STDERR.puts 'Could not make a request to delete a token'
360
+ end
341
361
  when "status"
342
362
  status = Auth.token_status(verbose, url, token)
343
- puts status
363
+ unless status.nil?
364
+ puts status
365
+ else
366
+ STDERR.puts 'Could not make a request to get token status'
367
+ end
344
368
  when nil
345
369
  STDERR.puts "No action provided"
346
370
  else
@@ -380,8 +404,12 @@ class Vmfloaty
380
404
  end
381
405
  pass = password "Enter your password please:", '*'
382
406
  token = Auth.get_token(verbose, url, user, pass)
383
- puts "\nToken retrieved!"
384
- puts token
407
+ unless token.nil?
408
+ puts "\nToken retrieved!"
409
+ puts token
410
+ else
411
+ STDERR.puts 'Could not get token...requesting vm without a token anyway...'
412
+ end
385
413
  end
386
414
 
387
415
  Ssh.ssh(verbose, host_os, token, url)
data/lib/vmfloaty/auth.rb CHANGED
@@ -12,16 +12,15 @@ class Auth
12
12
  if res_body["ok"]
13
13
  return res_body["token"]
14
14
  else
15
- STDERR.puts "There was a problem with your request:"
16
- puts res_body
17
- exit 1
15
+ STDERR.puts "There was a problem with your request:\n#{res_body}"
16
+ return nil
18
17
  end
19
18
  end
20
19
 
21
20
  def self.delete_token(verbose, url, user, password, token)
22
21
  if token.nil?
23
22
  STDERR.puts 'You did not provide a token'
24
- exit 1
23
+ return nil
25
24
  end
26
25
 
27
26
  conn = Http.get_conn_with_auth(verbose, url, user, password)
@@ -31,16 +30,15 @@ class Auth
31
30
  if res_body["ok"]
32
31
  return res_body
33
32
  else
34
- STDERR.puts "There was a problem with your request:"
35
- puts res_body
36
- exit 1
33
+ STDERR.puts "There was a problem with your request:\n#{res_body}"
34
+ return nil
37
35
  end
38
36
  end
39
37
 
40
38
  def self.token_status(verbose, url, token)
41
39
  if token.nil?
42
40
  STDERR.puts 'You did not provide a token'
43
- exit 1
41
+ return nil
44
42
  end
45
43
 
46
44
  conn = Http.get_conn(verbose, url)
@@ -51,9 +49,8 @@ class Auth
51
49
  if res_body["ok"]
52
50
  return res_body
53
51
  else
54
- STDERR.puts "There was a problem with your request:"
55
- puts res_body
56
- exit 1
52
+ STDERR.puts "There was a problem with your request:\n#{res_body}"
53
+ return nil
57
54
  end
58
55
  end
59
56
  end
@@ -1,6 +1,6 @@
1
1
 
2
2
  class Version
3
- @version = '0.6.0'
3
+ @version = '0.6.1'
4
4
 
5
5
  def self.get
6
6
  @version
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.6.0
4
+ version: 0.6.1
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-08-26 00:00:00.000000000 Z
11
+ date: 2016-09-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commander