vmc 0.4.0.beta.65 → 0.4.0.beta.66

Sign up to get free protection for your applications and to get access to all the features.
@@ -269,7 +269,7 @@ module VMC
269
269
  desc "List an app's instances"
270
270
  group :apps, :info, :hidden => true
271
271
  input :apps, :argument => :splat, :singular => :app,
272
- :desc => "Applications to start",
272
+ :desc => "Applications whose instances to list",
273
273
  :from_given => by_name("app")
274
274
  def instances
275
275
  apps = input[:apps]
@@ -293,6 +293,33 @@ module VMC
293
293
  end
294
294
 
295
295
 
296
+ desc "List an app's crashed "
297
+ group :apps, :info, :hidden => true
298
+ input :apps, :argument => :splat, :singular => :app,
299
+ :desc => "Applications whose crashed instances to list",
300
+ :from_given => by_name("app")
301
+ def crashes
302
+ apps = input[:apps]
303
+ fail "No applications given." if apps.empty?
304
+
305
+ spaced(apps) do |app|
306
+ instances =
307
+ with_progress("Getting crashed instances for #{c(app.name, :name)}") do
308
+ app.crashes
309
+ end
310
+
311
+ spaced(instances) do |i|
312
+ if quiet?
313
+ line i.id
314
+ else
315
+ line
316
+ display_crashed_instance(i)
317
+ end
318
+ end
319
+ end
320
+ end
321
+
322
+
296
323
  desc "Update the instances/memory limit for an application"
297
324
  group :apps, :info, :hidden => true
298
325
  input :app, :argument => true, :desc => "Application to update",
@@ -384,24 +411,25 @@ module VMC
384
411
  end
385
412
 
386
413
  spaced(instances) do |i|
387
- logs =
388
- with_progress(
389
- "Getting logs for #{c(app.name, :name)} " +
390
- c("\##{i.id}", :instance)) do
391
- i.files("logs")
392
- end
414
+ show_instance_logs(app, i)
415
+ end
416
+ end
393
417
 
394
- line unless quiet?
395
418
 
396
- spaced(logs) do |log|
397
- body =
398
- with_progress("Reading " + b(log.join("/"))) do
399
- i.file(*log)
400
- end
419
+ desc "Print out the logs for an app's crashed instances"
420
+ group :apps, :info, :hidden => true
421
+ input :app, :argument => true,
422
+ :desc => "Application to get the logs of",
423
+ :from_given => by_name("app")
424
+ def crashlogs
425
+ app = input[:app]
401
426
 
402
- lines body
403
- line unless body.empty?
404
- end
427
+ crashes = app.crashes
428
+
429
+ fail "No crashed instances found." if crashes.empty?
430
+
431
+ spaced(crashes) do |i|
432
+ show_instance_logs(app, i)
405
433
  end
406
434
  end
407
435
 
@@ -511,7 +539,7 @@ module VMC
511
539
 
512
540
  table(
513
541
  %w{instance cpu memory disk},
514
- stats.sort_by(&:first).collect { |idx, info|
542
+ stats.sort_by { |idx, _| idx.to_i }.collect { |idx, info|
515
543
  idx = c("\##{idx}", :instance)
516
544
 
517
545
  if info[:state] == "DOWN"
@@ -1056,7 +1084,7 @@ module VMC
1056
1084
 
1057
1085
  indented do
1058
1086
  if s = i.since
1059
- line "started: #{c(s.strftime("%F %r"), :cyan)}"
1087
+ line "started: #{c(s.strftime("%F %r"), :neutral)}"
1060
1088
  end
1061
1089
 
1062
1090
  if d = i.debugger
@@ -1069,6 +1097,43 @@ module VMC
1069
1097
  end
1070
1098
  end
1071
1099
 
1100
+ def display_crashed_instance(i)
1101
+ start_line "instance #{c("\##{i.id}", :instance)}: "
1102
+ puts "#{b(c("crashed", :error))} "
1103
+
1104
+ indented do
1105
+ if s = i.since
1106
+ line "since: #{c(s.strftime("%F %r"), :neutral)}"
1107
+ end
1108
+ end
1109
+ end
1110
+
1111
+ def show_instance_logs(app, i)
1112
+ return unless i.id
1113
+
1114
+ logs =
1115
+ with_progress(
1116
+ "Getting logs for #{c(app.name, :name)} " +
1117
+ c("\##{i.id}", :instance)) do
1118
+ i.files("logs")
1119
+ end
1120
+
1121
+ line unless quiet?
1122
+
1123
+ spaced(logs) do |log|
1124
+ begin
1125
+ body =
1126
+ with_progress("Reading " + b(log.join("/"))) do |s|
1127
+ i.file(*log)
1128
+ end
1129
+
1130
+ lines body
1131
+ line unless body.empty?
1132
+ rescue CFoundry::NotFound
1133
+ end
1134
+ end
1135
+ end
1136
+
1072
1137
  def find_orphaned_services(apps, others = [])
1073
1138
  orphaned = Set.new
1074
1139
 
@@ -1,3 +1,3 @@
1
1
  module VMC
2
- VERSION = "0.4.0.beta.65"
2
+ VERSION = "0.4.0.beta.66"
3
3
  end
metadata CHANGED
@@ -1,15 +1,15 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: vmc
3
3
  version: !ruby/object:Gem::Version
4
- hash: 1083977469
4
+ hash: -614476860
5
5
  prerelease: 6
6
6
  segments:
7
7
  - 0
8
8
  - 4
9
9
  - 0
10
10
  - beta
11
- - 65
12
- version: 0.4.0.beta.65
11
+ - 66
12
+ version: 0.4.0.beta.66
13
13
  platform: ruby
14
14
  authors:
15
15
  - VMware
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2012-10-11 00:00:00 Z
20
+ date: 2012-10-15 00:00:00 Z
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
23
23
  name: json_pure
@@ -265,12 +265,12 @@ dependencies:
265
265
  requirements:
266
266
  - - ~>
267
267
  - !ruby/object:Gem::Version
268
- hash: 65
268
+ hash: 71
269
269
  segments:
270
270
  - 0
271
271
  - 3
272
- - 41
273
- version: 0.3.41
272
+ - 42
273
+ version: 0.3.42
274
274
  type: :runtime
275
275
  version_requirements: *id015
276
276
  - !ruby/object:Gem::Dependency