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 +4 -4
- data/lib/vmfloaty.rb +39 -2
- data/lib/vmfloaty/auth.rb +1 -1
- data/lib/vmfloaty/pooler.rb +1 -7
- data/lib/vmfloaty/version.rb +1 -1
- data/spec/vmfloaty/auth_spec.rb +1 -1
- data/spec/vmfloaty/pooler_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cf2985c45b997c54451e9d295f228d064f385c78
|
4
|
+
data.tar.gz: 1b94780071b7258f34fda134c720b468fd8e909c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
data/lib/vmfloaty/pooler.rb
CHANGED
@@ -71,13 +71,7 @@ class Pooler
|
|
71
71
|
res_body
|
72
72
|
end
|
73
73
|
|
74
|
-
def self.delete(verbose, url,
|
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
|
data/lib/vmfloaty/version.rb
CHANGED
data/spec/vmfloaty/auth_spec.rb
CHANGED
@@ -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 @
|
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.
|
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-
|
11
|
+
date: 2015-11-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: commander
|