@@ -172,10 +172,43 @@ def run
172
172
token = options . token || config [ 'token' ]
173
173
modify_all = options . all
174
174
175
+ running_vms = nil
176
+
177
+ if modify_all
178
+ begin
179
+ running_vms = Utils . get_all_token_vms ( verbose , url , token )
180
+ rescue Exception => e
181
+ STDERR . puts e
182
+ end
183
+ elsif hostname . include? ","
184
+ running_vms = hostname . split ( "," )
185
+ end
186
+
175
187
if lifetime || tags
176
- # All Vs
177
- if modify_all
188
+ # all vms
189
+ if !running_vms . nil?
190
+ begin
191
+ modify_hash = { }
192
+ modify_flag = true
178
193
194
+ running_vms . each do |vm |
195
+ modify_hash [ vm ] = Pooler . modify ( verbose , url , vm , token , lifetime , tags )
196
+ end
197
+
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
179
212
else
180
213
# Single Vm
181
214
begin
@@ -196,21 +229,47 @@ def run
196
229
end
197
230
198
231
if disk
199
- begin
200
- disk_req = Pooler . disk ( verbose , url , hostname , token , disk )
201
- rescue TokenError => e
202
- STDERR . puts e
203
- exit 1
204
- end
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
241
+
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
205
248
206
- if disk_req [ "ok" ]
207
- puts "Successfully updated disk space of vm #{ hostname } ."
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
208
256
else
209
- STDERR . puts "Could not modify given host #{ hostname } at #{ url } ."
210
- puts disk_req
211
- exit 1
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
212
272
end
213
- else
214
273
end
215
274
end
216
275
end
0 commit comments