vmfloaty 0.7.1 → 0.7.2
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 +97 -41
- data/lib/vmfloaty/utils.rb +13 -0
- data/lib/vmfloaty/version.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: 7f2eaf3fd1178351347feaa7733d6742ac0f5dc9
|
4
|
+
data.tar.gz: b62b58f255127ad8b9566805f962b070c1f590fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 15e588134c795f3014e09e980c0d84b22aa8e477404ecf8ebf74240ab03aa4290903e95dc528c4081fd8915f42e955c6ca84055122d84353a60dc62a69d2c830
|
7
|
+
data.tar.gz: 283f9468a507845eac92cd8f74d486aacc63fca9e3ffafc9b50a086660ffd9f1ec35dbfbda0aeb03c6bc857e2e9efad109e23eaa6beeebda8744ec742b3195a7
|
data/lib/vmfloaty.rb
CHANGED
@@ -113,21 +113,15 @@ class Vmfloaty
|
|
113
113
|
if active
|
114
114
|
# list active vms
|
115
115
|
begin
|
116
|
-
|
116
|
+
running_vms = Utils.get_all_token_vms(verbose, url, token)
|
117
117
|
rescue TokenError => e
|
118
118
|
STDERR.puts e
|
119
119
|
exit 1
|
120
|
+
rescue Exception => e
|
121
|
+
STDERR.puts e
|
122
|
+
exit 1
|
120
123
|
end
|
121
124
|
|
122
|
-
# print vms
|
123
|
-
vms = status[token]['vms']
|
124
|
-
if vms.nil?
|
125
|
-
STDERR.puts "You have no running vms"
|
126
|
-
exit 0
|
127
|
-
end
|
128
|
-
|
129
|
-
running_vms = vms['running']
|
130
|
-
|
131
125
|
if ! running_vms.nil?
|
132
126
|
Utils.prettyprint_hosts(running_vms, verbose, url)
|
133
127
|
end
|
@@ -167,6 +161,7 @@ class Vmfloaty
|
|
167
161
|
c.option '--lifetime INT', Integer, 'VM TTL (Integer, in hours)'
|
168
162
|
c.option '--disk INT', Integer, 'Increases VM disk space (Integer, in gb)'
|
169
163
|
c.option '--tags STRING', String, 'free-form VM tagging (json)'
|
164
|
+
c.option '--all', 'Modifies all vms acquired by a token'
|
170
165
|
c.action do |args, options|
|
171
166
|
verbose = options.verbose || config['verbose']
|
172
167
|
url = options.url ||= config['url']
|
@@ -175,40 +170,106 @@ class Vmfloaty
|
|
175
170
|
disk = options.disk
|
176
171
|
tags = JSON.parse(options.tags) if options.tags
|
177
172
|
token = options.token || config['token']
|
173
|
+
modify_all = options.all
|
178
174
|
|
179
|
-
|
175
|
+
running_vms = nil
|
176
|
+
|
177
|
+
if modify_all
|
180
178
|
begin
|
181
|
-
|
182
|
-
rescue
|
179
|
+
running_vms = Utils.get_all_token_vms(verbose, url, token)
|
180
|
+
rescue Exception => e
|
183
181
|
STDERR.puts e
|
184
|
-
exit 1
|
185
182
|
end
|
183
|
+
elsif hostname.include? ","
|
184
|
+
running_vms = hostname.split(",")
|
185
|
+
end
|
186
|
+
|
187
|
+
if lifetime || tags
|
188
|
+
# all vms
|
189
|
+
if !running_vms.nil?
|
190
|
+
begin
|
191
|
+
modify_hash = {}
|
192
|
+
modify_flag = true
|
193
|
+
|
194
|
+
running_vms.each do |vm|
|
195
|
+
modify_hash[vm] = Pooler.modify(verbose, url, vm, token, lifetime, tags)
|
196
|
+
end
|
186
197
|
|
187
|
-
|
188
|
-
|
198
|
+
modify_hash.each do |hostname,status|
|
199
|
+
if status == false
|
200
|
+
STDERR.puts "Could not modify #{hostname}."
|
201
|
+
modify_flag = false
|
202
|
+
end
|
203
|
+
end
|
204
|
+
|
205
|
+
if modify_flag
|
206
|
+
puts "Successfully modified all vms. Use `floaty list --active` to see the results."
|
207
|
+
end
|
208
|
+
rescue Exception => e
|
209
|
+
STDERR.puts e
|
210
|
+
exit 1
|
211
|
+
end
|
189
212
|
else
|
190
|
-
|
191
|
-
|
192
|
-
|
213
|
+
# Single Vm
|
214
|
+
begin
|
215
|
+
modify_req = Pooler.modify(verbose, url, hostname, token, lifetime, tags)
|
216
|
+
rescue TokenError => e
|
217
|
+
STDERR.puts e
|
218
|
+
exit 1
|
219
|
+
end
|
220
|
+
|
221
|
+
if modify_req["ok"]
|
222
|
+
puts "Successfully modified vm #{hostname}."
|
223
|
+
else
|
224
|
+
STDERR.puts "Could not modify given host #{hostname} at #{url}."
|
225
|
+
puts modify_req
|
226
|
+
exit 1
|
227
|
+
end
|
193
228
|
end
|
194
229
|
end
|
195
230
|
|
196
231
|
if disk
|
197
|
-
|
198
|
-
|
199
|
-
|
200
|
-
|
201
|
-
|
202
|
-
|
232
|
+
# all vms
|
233
|
+
if !running_vms.nil?
|
234
|
+
begin
|
235
|
+
modify_hash = {}
|
236
|
+
modify_flag = true
|
237
|
+
|
238
|
+
running_vms.each do |vm|
|
239
|
+
modify_hash[vm] = Pooler.disk(verbose, url, vm, token, disk)
|
240
|
+
end
|
203
241
|
|
204
|
-
|
205
|
-
|
242
|
+
modify_hash.each do |hostname,status|
|
243
|
+
if status == false
|
244
|
+
STDERR.puts "Could not update disk space on #{hostname}."
|
245
|
+
modify_flag = false
|
246
|
+
end
|
247
|
+
end
|
248
|
+
|
249
|
+
if modify_flag
|
250
|
+
puts "Successfully made request to update disk space on all vms."
|
251
|
+
end
|
252
|
+
rescue Exception => e
|
253
|
+
STDERR.puts e
|
254
|
+
exit 1
|
255
|
+
end
|
206
256
|
else
|
207
|
-
|
208
|
-
|
209
|
-
|
257
|
+
# single vm
|
258
|
+
begin
|
259
|
+
disk_req = Pooler.disk(verbose, url, hostname, token, disk)
|
260
|
+
rescue TokenError => e
|
261
|
+
STDERR.puts e
|
262
|
+
exit 1
|
263
|
+
end
|
264
|
+
|
265
|
+
if disk_req["ok"]
|
266
|
+
puts "Successfully made request to update disk space of vm #{hostname}."
|
267
|
+
else
|
268
|
+
STDERR.puts "Could not modify given host #{hostname} at #{url}."
|
269
|
+
puts disk_req
|
270
|
+
exit 1
|
271
|
+
end
|
210
272
|
end
|
211
|
-
else
|
212
273
|
end
|
213
274
|
end
|
214
275
|
end
|
@@ -234,21 +295,15 @@ class Vmfloaty
|
|
234
295
|
if delete_all
|
235
296
|
# get vms with token
|
236
297
|
begin
|
237
|
-
|
298
|
+
running_vms = Utils.get_all_token_vms(verbose, url, token)
|
238
299
|
rescue TokenError => e
|
239
300
|
STDERR.puts e
|
240
301
|
exit 1
|
302
|
+
rescue Exception => e
|
303
|
+
STDERR.puts e
|
304
|
+
exit 1
|
241
305
|
end
|
242
306
|
|
243
|
-
# print vms
|
244
|
-
vms = status[token]['vms']
|
245
|
-
if vms.nil?
|
246
|
-
STDERR.puts "You have no running vms"
|
247
|
-
exit 0
|
248
|
-
end
|
249
|
-
|
250
|
-
running_vms = vms['running']
|
251
|
-
|
252
307
|
if ! running_vms.nil?
|
253
308
|
Utils.prettyprint_hosts(running_vms, verbose, url)
|
254
309
|
# query y/n
|
@@ -308,6 +363,7 @@ class Vmfloaty
|
|
308
363
|
exit 1
|
309
364
|
end
|
310
365
|
|
366
|
+
puts "Snapshot pending. Use `floaty query host` to determine when snapshot is valid."
|
311
367
|
pp snapshot_req
|
312
368
|
end
|
313
369
|
end
|
data/lib/vmfloaty/utils.rb
CHANGED
@@ -79,4 +79,17 @@ class Utils
|
|
79
79
|
puts "- #{vm}.#{domain} (#{metadata.join(", ")})"
|
80
80
|
end
|
81
81
|
end
|
82
|
+
|
83
|
+
def self.get_all_token_vms(verbose, url, token)
|
84
|
+
# get vms with token
|
85
|
+
status = Auth.token_status(verbose, url, token)
|
86
|
+
|
87
|
+
vms = status[token]['vms']
|
88
|
+
if vms.nil?
|
89
|
+
raise "You have no running vms"
|
90
|
+
end
|
91
|
+
|
92
|
+
running_vms = vms['running']
|
93
|
+
running_vms
|
94
|
+
end
|
82
95
|
end
|
data/lib/vmfloaty/version.rb
CHANGED
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.7.
|
4
|
+
version: 0.7.2
|
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-
|
11
|
+
date: 2016-11-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: commander
|