rvc 1.7.0 → 1.8.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,15 +1,15 @@
1
1
  # Copyright (c) 2011 VMware, Inc. All Rights Reserved.
2
- #
2
+ #
3
3
  # Permission is hereby granted, free of charge, to any person obtaining a copy
4
4
  # of this software and associated documentation files (the "Software"), to deal
5
5
  # in the Software without restriction, including without limitation the rights
6
6
  # to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
7
  # copies of the Software, and to permit persons to whom the Software is
8
8
  # furnished to do so, subject to the following conditions:
9
- #
9
+ #
10
10
  # The above copyright notice and this permission notice shall be included in
11
11
  # all copies or substantial portions of the Software.
12
- #
12
+ #
13
13
  # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
14
  # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
15
  # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
@@ -24,6 +24,12 @@ module RVC
24
24
  module Util
25
25
  extend self
26
26
 
27
+ if RbConfig::CONFIG['host_os'] =~ /^darwin/
28
+ TCSETPGRP = 0x80047476
29
+ else
30
+ TCSETPGRP = 0x5410
31
+ end
32
+
27
33
  def menu items
28
34
  items.each_with_index { |x, i| puts "#{i} #{x}" }
29
35
  input = Readline.readline("? ", false)
@@ -64,9 +70,22 @@ module Util
64
70
  end
65
71
 
66
72
  def tasks objs, sym, args={}
67
- progress(objs.map { |obj| obj._call :"#{sym}_Task", args })
73
+ # Stores valid objs to send to progress method
74
+ taskobjs = []
75
+
76
+ objs.each do |obj|
77
+ begin
78
+ taskobjs.push (obj._call :"#{sym}_Task", args)
79
+ rescue Exception => ex
80
+ puts "util.rb:tasks: Skipping current object #{obj} due to Exception: #{ex.message}"
81
+ end
82
+ end
83
+
84
+ #Process only those objects which haven't raised any exception
85
+ progress (taskobjs)
68
86
  end
69
87
 
88
+
70
89
  if ENV['LANG'] =~ /UTF/ and RUBY_VERSION >= '1.9.1'
71
90
  PROGRESS_BAR_LEFT = "\u2772"
72
91
  PROGRESS_BAR_MIDDLE = "\u25AC"
@@ -90,6 +109,7 @@ module Util
90
109
  text = "#{name} #{entityName}: #{state} "
91
110
  progress = props['info.progress']
92
111
  barlen = terminal_columns - text.size - 2
112
+ barlen = 0 if barlen < 0 # we can't draw -ive bars, simple fix TODO: draw on next line
93
113
  progresslen = ((progress||0)*barlen)/100
94
114
  progress_bar = "#{PROGRESS_BAR_LEFT}#{PROGRESS_BAR_MIDDLE * progresslen}#{' ' * (barlen-progresslen)}#{PROGRESS_BAR_RIGHT}"
95
115
  $stdout.write "\e[K#{text}#{progress_bar}\n"
@@ -132,7 +152,7 @@ module Util
132
152
  def tcsetpgrp pgrp=Process.getpgrp
133
153
  return unless $stdin.tty?
134
154
  trap('TTOU', 'SIG_IGN')
135
- $stdin.ioctl 0x5410, [pgrp].pack('I')
155
+ $stdin.ioctl TCSETPGRP, [pgrp].pack('I')
136
156
  trap('TTOU', 'SIG_DFL')
137
157
  end
138
158
 
@@ -206,7 +226,7 @@ module Util
206
226
  retry
207
227
  end
208
228
  end
209
-
229
+
210
230
  buckets = {}
211
231
  objs.each do |o|
212
232
  metrics = o.perfmetrics(fields)
@@ -223,8 +243,8 @@ module Util
223
243
  stats = perfmgr.retrieve_stats os, metric[:metrics], metric[:opts]
224
244
  os.each do |o|
225
245
  perf_values[o] = {}
226
- metric[:metrics].map do |x|
227
- if stats[o]
246
+ metric[:metrics].map do |x|
247
+ if stats[o]
228
248
  perf_values[o][x] = stats[o][:metrics][x]
229
249
  end
230
250
  end
@@ -235,11 +255,11 @@ module Util
235
255
  end
236
256
  end
237
257
  end
238
-
258
+
239
259
  Hash[objs.map do |o|
240
260
  begin
241
- [o, Hash[fields.map do |f|
242
- [f, o.field(f, props_values[o], perf_values[o])]
261
+ [o, Hash[fields.map do |f|
262
+ [f, o.field(f, props_values[o], perf_values[o])]
243
263
  end]]
244
264
  rescue VIM::ManagedObjectNotFound
245
265
  next
metadata CHANGED
@@ -1,15 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rvc
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.0
4
+ version: 1.8.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Rich Lane
9
+ - Christian Dickmann
9
10
  autorequire:
10
11
  bindir: bin
11
12
  cert_chain: []
12
- date: 2012-09-25 00:00:00.000000000 Z
13
+ date: 2013-12-17 00:00:00.000000000 Z
13
14
  dependencies:
14
15
  - !ruby/object:Gem::Dependency
15
16
  name: rbvmomi
@@ -170,13 +171,16 @@ files:
170
171
  - lib/rvc/modules/resource_pool.rb
171
172
  - lib/rvc/modules/role.rb
172
173
  - lib/rvc/modules/snapshot.rb
174
+ - lib/rvc/modules/spbm.rb
173
175
  - lib/rvc/modules/statsinterval.rb
176
+ - lib/rvc/modules/syslog.rb
174
177
  - lib/rvc/modules/vds.rb
175
178
  - lib/rvc/modules/vim.rb
176
179
  - lib/rvc/modules/vm.rb
177
180
  - lib/rvc/modules/vm_guest.rb
178
181
  - lib/rvc/modules/vmrc.rb
179
182
  - lib/rvc/modules/vnc.rb
183
+ - lib/rvc/modules/vsan.rb
180
184
  - lib/rvc/namespace.rb
181
185
  - lib/rvc/option_parser.rb
182
186
  - lib/rvc/path.rb
@@ -200,7 +204,7 @@ files:
200
204
  - test/test_parse_path.rb
201
205
  - test/test_shell.rb
202
206
  - test/test_uri.rb
203
- homepage:
207
+ homepage: https://github.com/vmware/rvc
204
208
  licenses: []
205
209
  post_install_message:
206
210
  rdoc_options: []