vmfloaty 0.2.14 → 0.2.15

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: b24b1f8db9ba5d7741f7364868c17976f779cf28
4
- data.tar.gz: 3ac32fe7709e6e8a2ba39b32aaa503ce92e0e5ab
3
+ metadata.gz: cf2985c45b997c54451e9d295f228d064f385c78
4
+ data.tar.gz: 1b94780071b7258f34fda134c720b468fd8e909c
5
5
  SHA512:
6
- metadata.gz: 67f4beb31fc6fb3b2880177a301648cd431b4d79097d4a2aa4b74211b7446cf146338dafffb425d5feb7b5d34048dd1d557e36f677e82ecdd26576a466c1d2fe
7
- data.tar.gz: 63e69b768a855e37d845f7aca4f6221734e1cedeffa63f89453d4ee68da52f65e00dfd5fd553e50b8264dc81240630dbebd5f1e54494800421c910e469e01f52
6
+ metadata.gz: 8e41473307c941b2aa4078457110036a35743a896ec26c658c431ee9edc7b3356c716aa6e0b282352056a291c2b557179f0f1931fe3f6180e16d48644abdbc32
7
+ data.tar.gz: 31d3f725a8551c259134eb250ec7f148edb69320e12276775cb1d57e12f87ba5fa0a40fd62899c9c8886fcb4c1f7d5025fd4edb8aea3c63005432b563af18c08
data/lib/vmfloaty.rb CHANGED
@@ -140,14 +140,51 @@ class Vmfloaty
140
140
  c.description = ''
141
141
  c.example 'Schedules the deletion of a host or hosts', 'floaty delete myhost1,myhost2 --url http://vmpooler.example.com'
142
142
  c.option '--verbose', 'Enables verbose output'
143
+ c.option '--all', 'Deletes all vms acquired by a token'
143
144
  c.option '--token STRING', String, 'Token for vmpooler'
144
145
  c.option '--url STRING', String, 'URL of vmpooler'
145
146
  c.action do |args, options|
146
147
  verbose = options.verbose || config['verbose']
147
- hosts = args[0]
148
+ hostnames = args[0]
148
149
  token = options.token || config['token']
149
150
  url = options.url ||= config['url']
151
+ delete_all = options.all
150
152
 
153
+ if delete_all
154
+ # get vms with token
155
+ status = Auth.token_status(verbose, url, token)
156
+ # print vms
157
+ vms = status[token]['vms']
158
+ if vms.nil?
159
+ STDERR.puts "You have no running vms"
160
+ exit 0
161
+ end
162
+
163
+ running_vms = vms['running']
164
+
165
+ if ! running_vms.nil?
166
+ puts "Running VMs:"
167
+ running_vms.each do |vm|
168
+ puts "- #{vm}"
169
+ end
170
+ # query y/n
171
+ puts ""
172
+ ans = agree("Delete all VMs associated with token #{token}? [y/N]")
173
+ if ans
174
+ # delete vms
175
+ Pooler.delete(verbose, url, running_vms, token)
176
+ end
177
+ end
178
+
179
+ exit 0
180
+ end
181
+
182
+ if hostnames.nil?
183
+ STDERR.puts "You did not provide any hosts to delete"
184
+ exit 1
185
+ end
186
+
187
+ hosts = hostnames.split(',')
151
188
  Pooler.delete(verbose, url, hosts, token)
152
189
  end
153
190
  end
@@ -248,7 +285,7 @@ class Vmfloaty
248
285
  pass = password "Enter your password please:", '*'
249
286
  Auth.delete_token(verbose, url, user, pass, token)
250
287
  when "status"
251
- Auth.token_status(verbose, url, token)
288
+ puts Auth.token_status(verbose, url, token)
252
289
  when nil
253
290
  STDERR.puts "No action provided"
254
291
  else
data/lib/vmfloaty/auth.rb CHANGED
@@ -49,7 +49,7 @@ class Auth
49
49
  res_body = JSON.parse(response.body)
50
50
 
51
51
  if res_body["ok"]
52
- puts res_body
52
+ res_body
53
53
  else
54
54
  STDERR.puts "There was a problem with your request:"
55
55
  puts res_body
@@ -71,13 +71,7 @@ class Pooler
71
71
  res_body
72
72
  end
73
73
 
74
- def self.delete(verbose, url, hostnames, token)
75
- if hostnames.nil?
76
- STDERR.puts "You did not provide any hosts to delete"
77
- exit 1
78
- end
79
-
80
- hosts = hostnames.split(',')
74
+ def self.delete(verbose, url, hosts, token)
81
75
  conn = Http.get_conn(verbose, url)
82
76
 
83
77
  if token
@@ -1,6 +1,6 @@
1
1
 
2
2
  class Version
3
- @version = '0.2.14'
3
+ @version = '0.2.15'
4
4
 
5
5
  def self.get
6
6
  @version
@@ -48,7 +48,7 @@ describe Pooler do
48
48
  with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Faraday v0.9.1'}).
49
49
  to_return(:status => 200, :body => @token_status_response, :headers => {})
50
50
 
51
- expect(Auth.token_status(false, @vmpooler_url, @token)).to eq @get_token_response
51
+ expect(Auth.token_status(false, @vmpooler_url, @token)).to eq JSON.parse(@token_status_response)
52
52
  end
53
53
  end
54
54
  end
@@ -101,7 +101,7 @@ describe Pooler do
101
101
  with(:headers => {'Accept'=>'*/*', 'Accept-Encoding'=>'gzip;q=1.0,deflate;q=0.6,identity;q=0.3', 'User-Agent'=>'Faraday v0.9.1', 'X-Auth-Token'=>'mytokenfile'}).
102
102
  to_return(:status => 200, :body => @delete_response_body_success, :headers => {})
103
103
 
104
- #expect(Pooler.delete(false, @vmpooler_url, 'fq6qlpjlsskycq6', 'mytokenfile')).to output(/Scheduling host fq6qlpjlsskycq6 for deletion/).to_stdout
104
+ #expect(Pooler.delete(false, @vmpooler_url, ['fq6qlpjlsskycq6'], 'mytokenfile')).to output(/Scheduling host fq6qlpjlsskycq6 for deletion/).to_stdout
105
105
  end
106
106
  end
107
107
 
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.2.14
4
+ version: 0.2.15
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brian Cain
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-05 00:00:00.000000000 Z
11
+ date: 2015-11-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: commander