vmware_web_service 2.0.3 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (31) hide show
  1. checksums.yaml +4 -4
  2. data/lib/VMwareWebService/MiqHostDatastoreSystem.rb +5 -1
  3. data/lib/VMwareWebService/MiqVim.rb +80 -56
  4. data/lib/VMwareWebService/MiqVimClientBase.rb +11 -10
  5. data/lib/VMwareWebService/MiqVimCluster.rb +6 -2
  6. data/lib/VMwareWebService/MiqVimDataStore.rb +9 -6
  7. data/lib/VMwareWebService/MiqVimDump.rb +1 -1
  8. data/lib/VMwareWebService/MiqVimEventHistoryCollector.rb +5 -1
  9. data/lib/VMwareWebService/MiqVimEventMonitor.rb +22 -20
  10. data/lib/VMwareWebService/MiqVimFolder.rb +15 -11
  11. data/lib/VMwareWebService/MiqVimHost.rb +15 -13
  12. data/lib/VMwareWebService/MiqVimInventory.rb +78 -79
  13. data/lib/VMwareWebService/MiqVimPerfHistory.rb +13 -10
  14. data/lib/VMwareWebService/MiqVimUpdate.rb +50 -50
  15. data/lib/VMwareWebService/MiqVimVdlMod.rb +7 -7
  16. data/lib/VMwareWebService/MiqVimVm.rb +102 -101
  17. data/lib/VMwareWebService/VimService.rb +5 -2
  18. data/lib/VMwareWebService/VixDiskLib/VixDiskLib.rb +15 -7
  19. data/lib/VMwareWebService/VixDiskLib/VixDiskLibServer.rb +15 -15
  20. data/lib/VMwareWebService/VixDiskLib/vdl_wrapper.rb +26 -27
  21. data/lib/VMwareWebService/exception.rb +0 -2
  22. data/lib/VMwareWebService/logging.rb +16 -0
  23. data/lib/VMwareWebService/version.rb +1 -1
  24. data/lib/vmware_web_service.rb +2 -0
  25. metadata +15 -48
  26. data/lib/VMwareWebService/DMiqVim.rb +0 -95
  27. data/lib/VMwareWebService/DMiqVimSync.rb +0 -45
  28. data/lib/VMwareWebService/MiqVimBroker.rb +0 -581
  29. data/lib/VMwareWebService/MiqVimBrokerMods.rb +0 -222
  30. data/lib/VMwareWebService/MiqVimCoreUpdater.rb +0 -269
  31. data/lib/VMwareWebService/miq_fault_tolerant_vim.rb +0 -246
@@ -1,17 +1,18 @@
1
1
  require 'sync'
2
2
 
3
- require 'enumerator'
4
3
  require "ostruct"
5
4
 
6
5
  require 'more_core_extensions/core_ext/hash'
7
6
  require 'active_support/core_ext/object/try'
8
7
 
9
8
  require 'VMwareWebService/exception'
9
+ require 'VMwareWebService/logging'
10
10
  require 'VMwareWebService/MiqVimVdlMod'
11
11
  require 'VMwareWebService/esx_thumb_print'
12
12
  require 'VMwareWebService/vcenter_thumb_print'
13
13
 
14
14
  class MiqVimVm
15
+ include VMwareWebService::Logging
15
16
  include MiqVimVdlVcConnectionMod
16
17
 
17
18
  EVM_SNAPSHOT_NAME = "EvmSnapshot".freeze # TODO: externalize - not VIM specific
@@ -92,53 +93,53 @@ class MiqVimVm
92
93
  #######################
93
94
 
94
95
  def start(wait = true)
95
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).start: calling powerOnVM_Task" if $vim_log
96
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).start: calling powerOnVM_Task"
96
97
  taskMor = @invObj.powerOnVM_Task(@vmMor)
97
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).start: returned from powerOnVM_Task" if $vim_log
98
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).start: returned from powerOnVM_Task"
98
99
  return taskMor unless wait
99
100
  waitForTask(taskMor)
100
101
  end # def start
101
102
 
102
103
  def stop(wait = true)
103
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).stop: calling powerOffVM_Task" if $vim_log
104
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).stop: calling powerOffVM_Task"
104
105
  taskMor = @invObj.powerOffVM_Task(@vmMor)
105
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).stop: returned from powerOffVM_Task" if $vim_log
106
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).stop: returned from powerOffVM_Task"
106
107
  return taskMor unless wait
107
108
  waitForTask(taskMor)
108
109
  end # def stop
109
110
 
110
111
  def suspend(wait = true)
111
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).suspend: calling suspendVM_Task" if $vim_log
112
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).suspend: calling suspendVM_Task"
112
113
  taskMor = @invObj.suspendVM_Task(@vmMor)
113
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).suspend: returned from suspendVM_Task" if $vim_log
114
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).suspend: returned from suspendVM_Task"
114
115
  return taskMor unless wait
115
116
  waitForTask(taskMor)
116
117
  end # def suspend
117
118
 
118
119
  def reset(wait = true)
119
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).reset: calling resetVM_Task" if $vim_log
120
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).reset: calling resetVM_Task"
120
121
  taskMor = @invObj.resetVM_Task(@vmMor)
121
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).reset: returned from resetVM_Task" if $vim_log
122
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).reset: returned from resetVM_Task"
122
123
  return taskMor unless wait
123
124
  waitForTask(taskMor)
124
125
  end
125
126
 
126
127
  def rebootGuest
127
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).rebootGuest: calling rebootGuest" if $vim_log
128
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).rebootGuest: calling rebootGuest"
128
129
  @invObj.rebootGuest(@vmMor)
129
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).rebootGuest: returned from rebootGuest" if $vim_log
130
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).rebootGuest: returned from rebootGuest"
130
131
  end
131
132
 
132
133
  def shutdownGuest
133
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).shutdownGuest: calling shutdownGuest" if $vim_log
134
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).shutdownGuest: calling shutdownGuest"
134
135
  @invObj.shutdownGuest(@vmMor)
135
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).shutdownGuest: returned from shutdownGuest" if $vim_log
136
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).shutdownGuest: returned from shutdownGuest"
136
137
  end
137
138
 
138
139
  def standbyGuest
139
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).standbyGuest: calling standbyGuest" if $vim_log
140
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).standbyGuest: calling standbyGuest"
140
141
  @invObj.standbyGuest(@vmMor)
141
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).standbyGuest: returned from standbyGuest" if $vim_log
142
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).standbyGuest: returned from standbyGuest"
142
143
  end
143
144
 
144
145
  def powerState
@@ -168,18 +169,18 @@ class MiqVimVm
168
169
  ############################
169
170
 
170
171
  def markAsTemplate
171
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).markAsTemplate: calling markAsTemplate" if $vim_log
172
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).markAsTemplate: calling markAsTemplate"
172
173
  @invObj.markAsTemplate(@vmMor)
173
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).markAsTemplate: returned from markAsTemplate" if $vim_log
174
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).markAsTemplate: returned from markAsTemplate"
174
175
  end
175
176
 
176
177
  def markAsVm(pool, host = nil)
177
178
  hmor = nil
178
179
  hmor = (host.kind_of?(Hash) ? host['MOR'] : host) if host
179
180
  pmor = (pool.kind_of?(Hash) ? pool['MOR'] : pool)
180
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).markAsVm: calling markAsVirtualMachine" if $vim_log
181
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).markAsVm: calling markAsVirtualMachine"
181
182
  @invObj.markAsVirtualMachine(@vmMor, pmor, hmor)
182
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).markAsVm: returned from markAsVirtualMachine" if $vim_log
183
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).markAsVm: returned from markAsVirtualMachine"
183
184
  end
184
185
 
185
186
  def template?
@@ -194,18 +195,18 @@ class MiqVimVm
194
195
  hmor = (host.kind_of?(Hash) ? host['MOR'] : host)
195
196
  pool = (pool.kind_of?(Hash) ? pool['MOR'] : pool) if pool
196
197
 
197
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).migrate: calling migrateVM_Task, vm=<#{@vmMor.inspect}>, host=<#{hmor.inspect}>, pool=<#{pool.inspect}>, priority=<#{priority.inspect}>, state=<#{state.inspect}>" if $vim_log
198
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).migrate: calling migrateVM_Task, vm=<#{@vmMor.inspect}>, host=<#{hmor.inspect}>, pool=<#{pool.inspect}>, priority=<#{priority.inspect}>, state=<#{state.inspect}>"
198
199
  taskMor = @invObj.migrateVM_Task(@vmMor, pool, hmor, priority, state)
199
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).migrate: returned from migrateVM_Task" if $vim_log
200
- $vim_log.debug "MiqVimVm::migrate: taskMor = #{taskMor}" if $vim_log
200
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).migrate: returned from migrateVM_Task"
201
+ logger.debug "MiqVimVm::migrate: taskMor = #{taskMor}"
201
202
  waitForTask(taskMor)
202
203
  end
203
204
 
204
205
  def renameVM(newName)
205
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).renameVM: calling rename_Task, vm=<#{@vmMor.inspect}>, newName=<#{newName}>" if $vim_log
206
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).renameVM: calling rename_Task, vm=<#{@vmMor.inspect}>, newName=<#{newName}>"
206
207
  task_mor = @invObj.rename_Task(@vmMor, newName)
207
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).renameVM: returned from rename_Task" if $vim_log
208
- $vim_log.debug "MiqVimVm::renameVM: taskMor = #{task_mor}" if $vim_log
208
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).renameVM: returned from rename_Task"
209
+ logger.debug "MiqVimVm::renameVM: taskMor = #{task_mor}"
209
210
  waitForTask(task_mor)
210
211
  end
211
212
 
@@ -223,26 +224,26 @@ class MiqVimVm
223
224
  rsl.transform = transform if transform
224
225
  end
225
226
 
226
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).relocate: calling relocateVM_Task, vm=<#{@vmMor.inspect}>, host=<#{hmor.inspect}>, pool=<#{pool.inspect}>, datastore=<#{dsmor.inspect}>, priority=<#{priority.inspect}>" if $vim_log
227
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).relocate: calling relocateVM_Task, vm=<#{@vmMor.inspect}>, host=<#{hmor.inspect}>, pool=<#{pool.inspect}>, datastore=<#{dsmor.inspect}>, priority=<#{priority.inspect}>"
227
228
  taskMor = @invObj.relocateVM_Task(@vmMor, rspec, priority)
228
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).relocate: returned from relocateVM_Task" if $vim_log
229
- $vim_log.debug "MiqVimVm::relocate: taskMor = #{taskMor}" if $vim_log
229
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).relocate: returned from relocateVM_Task"
230
+ logger.debug "MiqVimVm::relocate: taskMor = #{taskMor}"
230
231
  waitForTask(taskMor)
231
232
  end
232
233
 
233
234
  def cloneVM_raw(folder, name, spec, wait = true)
234
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).cloneVM_raw: calling cloneVM_Task" if $vim_log
235
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).cloneVM_raw: calling cloneVM_Task"
235
236
  taskMor = @invObj.cloneVM_Task(@vmMor, folder, name, spec)
236
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).cloneVM_raw: returned from cloneVM_Task" if $vim_log
237
- $vim_log.debug "MiqVimVm::cloneVM_raw: taskMor = #{taskMor}" if $vim_log
237
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).cloneVM_raw: returned from cloneVM_Task"
238
+ logger.debug "MiqVimVm::cloneVM_raw: taskMor = #{taskMor}"
238
239
 
239
240
  if wait
240
241
  rv = waitForTask(taskMor)
241
- $vim_log.debug "MiqVimVm::cloneVM_raw: rv = #{rv}" if $vim_log
242
+ logger.debug "MiqVimVm::cloneVM_raw: rv = #{rv}"
242
243
  return rv
243
244
  end
244
245
 
245
- $vim_log.debug "MiqVimVm::cloneVM_raw - no wait: taskMor = #{taskMor}" if $vim_log
246
+ logger.debug "MiqVimVm::cloneVM_raw - no wait: taskMor = #{taskMor}"
246
247
  taskMor
247
248
  end
248
249
 
@@ -288,15 +289,15 @@ class MiqVimVm
288
289
  # end
289
290
 
290
291
  def unregister
291
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).unregister: calling unregisterVM" if $vim_log
292
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).unregister: calling unregisterVM"
292
293
  @invObj.unregisterVM(@vmMor)
293
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).unregister: returned from unregisterVM" if $vim_log
294
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).unregister: returned from unregisterVM"
294
295
  end
295
296
 
296
297
  def destroy
297
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).destroy: calling destroy_Task" if $vim_log
298
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).destroy: calling destroy_Task"
298
299
  taskMor = @invObj.destroy_Task(@vmMor)
299
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).destroy: returned from destroy_Task" if $vim_log
300
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).destroy: returned from destroy_Task"
300
301
  waitForTask(taskMor)
301
302
  end
302
303
 
@@ -378,33 +379,33 @@ class MiqVimVm
378
379
  end
379
380
 
380
381
  def createSnapshot(name, desc, memory, quiesce, wait = true, free_space_percent = 100)
381
- $vim_log.debug "MiqVimVm::createSnapshot(#{name}, #{desc}, #{memory}, #{quiesce})" if $vim_log
382
+ logger.debug "MiqVimVm::createSnapshot(#{name}, #{desc}, #{memory}, #{quiesce})"
382
383
  cs = connectionState
383
384
  raise "MiqVimVm(#{@invObj.server}, #{@invObj.username}).createSnapshot: VM is not connected, connectionState = #{cs}" if cs != "connected"
384
385
  snapshot_free_space_check('create', free_space_percent)
385
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).createSnapshot: calling createSnapshot_Task" if $vim_log
386
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).createSnapshot: calling createSnapshot_Task"
386
387
  taskMor = @invObj.createSnapshot_Task(@vmMor, name, desc, memory, quiesce)
387
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).createSnapshot: returned from createSnapshot_Task" if $vim_log
388
- $vim_log.debug "MiqVimVm::createSnapshot: taskMor = #{taskMor}" if $vim_log
388
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).createSnapshot: returned from createSnapshot_Task"
389
+ logger.debug "MiqVimVm::createSnapshot: taskMor = #{taskMor}"
389
390
 
390
391
  if wait
391
392
  snMor = waitForTask(taskMor)
392
- $vim_log.warn "MiqVimVm::createSnapshot: snMor = #{snMor}" if $vim_log
393
+ logger.warn "MiqVimVm::createSnapshot: snMor = #{snMor}"
393
394
  return snMor
394
395
  end
395
396
 
396
- $vim_log.debug "MiqVimVm::createSnapshot - no wait: taskMor = #{taskMor}" if $vim_log
397
+ logger.debug "MiqVimVm::createSnapshot - no wait: taskMor = #{taskMor}"
397
398
  taskMor
398
399
  end # def createSnapshot
399
400
 
400
401
  def removeSnapshot(snMor, subTree = "false", wait = true, free_space_percent = 100)
401
- $vim_log.warn "MiqVimVm::removeSnapshot(#{snMor}, #{subTree})" if $vim_log
402
+ logger.warn "MiqVimVm::removeSnapshot(#{snMor}, #{subTree})"
402
403
  snMor = getSnapMor(snMor)
403
404
  snapshot_free_space_check('remove', free_space_percent)
404
- $vim_log.warn "MiqVimVm(#{@invObj.server}, #{@invObj.username}).removeSnapshot: calling removeSnapshot_Task: snMor [#{snMor}] subtree [#{subTree}]" if $vim_log
405
+ logger.warn "MiqVimVm(#{@invObj.server}, #{@invObj.username}).removeSnapshot: calling removeSnapshot_Task: snMor [#{snMor}] subtree [#{subTree}]"
405
406
  taskMor = @invObj.removeSnapshot_Task(snMor, subTree)
406
- $vim_log.warn "MiqVimVm(#{@invObj.server}, #{@invObj.username}).removeSnapshot: returned from removeSnapshot_Task: snMor [#{snMor}]" if $vim_log
407
- $vim_log.debug "MiqVimVm::removeSnapshot: taskMor = #{taskMor}" if $vim_log
407
+ logger.warn "MiqVimVm(#{@invObj.server}, #{@invObj.username}).removeSnapshot: returned from removeSnapshot_Task: snMor [#{snMor}]"
408
+ logger.debug "MiqVimVm::removeSnapshot: taskMor = #{taskMor}"
408
409
  return taskMor unless wait
409
410
  waitForTask(taskMor)
410
411
  end # def removeSnapshot
@@ -422,40 +423,40 @@ class MiqVimVm
422
423
  end # def removeSnapshotByDescription
423
424
 
424
425
  def removeAllSnapshots(free_space_percent = 100)
425
- $vim_log.debug "MiqVimVm::removeAllSnapshots" if $vim_log
426
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).removeAllSnapshots: calling removeAllSnapshots_Task" if $vim_log
426
+ logger.debug "MiqVimVm::removeAllSnapshots"
427
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).removeAllSnapshots: calling removeAllSnapshots_Task"
427
428
  snapshot_free_space_check('remove_all', free_space_percent)
428
429
  taskMor = @invObj.removeAllSnapshots_Task(@vmMor)
429
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).removeAllSnapshots: returned from removeAllSnapshots_Task" if $vim_log
430
- $vim_log.debug "MiqVimVm::removeAllSnapshots: taskMor = #{taskMor}" if $vim_log
430
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).removeAllSnapshots: returned from removeAllSnapshots_Task"
431
+ logger.debug "MiqVimVm::removeAllSnapshots: taskMor = #{taskMor}"
431
432
  waitForTask(taskMor)
432
433
  end # def removeAllSnapshots
433
434
 
434
435
  def revertToSnapshot(snMor)
435
- $vim_log.debug "MiqVimVm::revertToSnapshot(#{snMor})" if $vim_log
436
+ logger.debug "MiqVimVm::revertToSnapshot(#{snMor})"
436
437
  snMor = getSnapMor(snMor)
437
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).revertToSnapshot: calling revertToSnapshot_Task" if $vim_log
438
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).revertToSnapshot: calling revertToSnapshot_Task"
438
439
  taskMor = @invObj.revertToSnapshot_Task(snMor)
439
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).revertToSnapshot: returned from revertToSnapshot_Task" if $vim_log
440
- $vim_log.debug "MiqVimVm::revertToSnapshot: taskMor = #{taskMor}" if $vim_log
440
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).revertToSnapshot: returned from revertToSnapshot_Task"
441
+ logger.debug "MiqVimVm::revertToSnapshot: taskMor = #{taskMor}"
441
442
  waitForTask(taskMor)
442
443
  end # def revertToSnapshot
443
444
 
444
445
  def revertToCurrentSnapshot
445
- $vim_log.debug "MiqVimVm::revertToCurrentSnapshot" if $vim_log
446
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).revertToCurrentSnapshot: calling revertToCurrentSnapshot_Task" if $vim_log
446
+ logger.debug "MiqVimVm::revertToCurrentSnapshot"
447
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).revertToCurrentSnapshot: calling revertToCurrentSnapshot_Task"
447
448
  taskMor = @invObj.revertToCurrentSnapshot_Task(@vmMor)
448
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).revertToCurrentSnapshot: returned from revertToCurrentSnapshot_Task" if $vim_log
449
- $vim_log.debug "MiqVimVm::revertToCurrentSnapshot: taskMor = #{taskMor}" if $vim_log
449
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).revertToCurrentSnapshot: returned from revertToCurrentSnapshot_Task"
450
+ logger.debug "MiqVimVm::revertToCurrentSnapshot: taskMor = #{taskMor}"
450
451
  waitForTask(taskMor)
451
452
  end # def revertToCurrentSnapshot
452
453
 
453
454
  def renameSnapshot(snMor, name, desc)
454
- $vim_log.debug "MiqVimVm::renameSnapshot(#{snMor}, #{name}, #{desc})" if $vim_log
455
+ logger.debug "MiqVimVm::renameSnapshot(#{snMor}, #{name}, #{desc})"
455
456
  snMor = getSnapMor(snMor)
456
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).renameSnapshot: calling renameSnapshot" if $vim_log
457
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).renameSnapshot: calling renameSnapshot"
457
458
  @invObj.renameSnapshot(snMor, name, desc)
458
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).renameSnapshot: returned from renameSnapshot" if $vim_log
459
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).renameSnapshot: returned from renameSnapshot"
459
460
  end # def renameSnapshot
460
461
 
461
462
  def snapshot_free_space_check(action, free_space_percent = 100)
@@ -509,13 +510,13 @@ class MiqVimVm
509
510
 
510
511
  def getSnapMor(snMor)
511
512
  unless snMor.respond_to?(:vimType)
512
- $vim_log.debug "MiqVimVm::getSnapMor converting #{snMor} to MOR" if $vim_log
513
+ logger.debug "MiqVimVm::getSnapMor converting #{snMor} to MOR"
513
514
  @cacheLock.synchronize(:SH) do
514
515
  raise "getSnapMor: VM #{@dsPath} has no snapshots" unless (sni = snapshotInfo_locked(true))
515
516
  raise "getSnapMor: snapshot #{snMor} not found" unless (snObj = sni['ssMorHash'][snMor])
516
517
  snMor = snObj['snapshot']
517
518
  end
518
- $vim_log.debug "MiqVimVm::getSnapMor new MOR: #{snMor}" if $vim_log
519
+ logger.debug "MiqVimVm::getSnapMor new MOR: #{snMor}"
519
520
  end
520
521
  (snMor)
521
522
  end # def getSnapMor
@@ -610,9 +611,9 @@ class MiqVimVm
610
611
  end # def getCfg
611
612
 
612
613
  def reconfig(vmConfigSpec)
613
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).reconfig: calling reconfigVM_Task" if $vim_log
614
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).reconfig: calling reconfigVM_Task"
614
615
  taskMor = @invObj.reconfigVM_Task(@vmMor, vmConfigSpec)
615
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).reconfig: returned from reconfigVM_Task" if $vim_log
616
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).reconfig: returned from reconfigVM_Task"
616
617
  waitForTask(taskMor)
617
618
  end
618
619
 
@@ -631,9 +632,9 @@ class MiqVimVm
631
632
 
632
633
  def setMemory(memMB)
633
634
  vmConfigSpec = VimHash.new("VirtualMachineConfigSpec") { |cs| cs.memoryMB = memMB }
634
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).setMemory: calling reconfigVM_Task" if $vim_log
635
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).setMemory: calling reconfigVM_Task"
635
636
  taskMor = @invObj.reconfigVM_Task(@vmMor, vmConfigSpec)
636
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).setMemory: returned from reconfigVM_Task" if $vim_log
637
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).setMemory: returned from reconfigVM_Task"
637
638
  waitForTask(taskMor)
638
639
  end
639
640
 
@@ -643,9 +644,9 @@ class MiqVimVm
643
644
 
644
645
  def setNumCPUs(numCPUs)
645
646
  vmConfigSpec = VimHash.new("VirtualMachineConfigSpec") { |cs| cs.numCPUs = numCPUs }
646
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).setNumCPUs: calling reconfigVM_Task" if $vim_log
647
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).setNumCPUs: calling reconfigVM_Task"
647
648
  taskMor = @invObj.reconfigVM_Task(@vmMor, vmConfigSpec)
648
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).setNumCPUs: returned from reconfigVM_Task" if $vim_log
649
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).setNumCPUs: returned from reconfigVM_Task"
649
650
  waitForTask(taskMor)
650
651
  end
651
652
 
@@ -667,9 +668,9 @@ class MiqVimVm
667
668
  end
668
669
  end
669
670
 
670
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).connectDevice: calling reconfigVM_Task" if $vim_log
671
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).connectDevice: calling reconfigVM_Task"
671
672
  taskMor = @invObj.reconfigVM_Task(@vmMor, vmConfigSpec)
672
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).connectDevice: returned from reconfigVM_Task" if $vim_log
673
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).connectDevice: returned from reconfigVM_Task"
673
674
  waitForTask(taskMor)
674
675
  end # def connectDevice
675
676
 
@@ -705,9 +706,9 @@ class MiqVimVm
705
706
  end
706
707
  end
707
708
 
708
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).attachIsoToCd: calling reconfigVM_Task" if $vim_log
709
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).attachIsoToCd: calling reconfigVM_Task"
709
710
  taskMor = @invObj.reconfigVM_Task(@vmMor, vmConfigSpec)
710
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).attachIsoToCd: returned from reconfigVM_Task" if $vim_log
711
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).attachIsoToCd: returned from reconfigVM_Task"
711
712
  waitForTask(taskMor)
712
713
  end
713
714
 
@@ -723,9 +724,9 @@ class MiqVimVm
723
724
  end
724
725
  end
725
726
 
726
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).resetCd: calling reconfigVM_Task" if $vim_log
727
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).resetCd: calling reconfigVM_Task"
727
728
  taskMor = @invObj.reconfigVM_Task(@vmMor, vmConfigSpec)
728
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).resetCd: returned from reconfigVM_Task" if $vim_log
729
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).resetCd: returned from reconfigVM_Task"
729
730
  waitForTask(taskMor)
730
731
  end
731
732
 
@@ -803,9 +804,9 @@ class MiqVimVm
803
804
  end
804
805
  end
805
806
 
806
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).addDisk: calling reconfigVM_Task" if $vim_log
807
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).addDisk: calling reconfigVM_Task"
807
808
  taskMor = @invObj.reconfigVM_Task(@vmMor, vmConfigSpec)
808
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).addDisk: returned from reconfigVM_Task" if $vim_log
809
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).addDisk: returned from reconfigVM_Task"
809
810
  waitForTask(taskMor)
810
811
  end # def addDisk
811
812
 
@@ -820,8 +821,8 @@ class MiqVimVm
820
821
  raise "removeDiskByFile: false setting for deleteBacking not yet supported" if deleteBacking == false
821
822
  controllerKey, key = getDeviceKeysByBacking(backingFile)
822
823
  raise "removeDiskByFile: no virtual device associated with: #{backingFile}" unless key
823
- $vim_log.debug "MiqVimVm::MiqVimVm: backingFile = #{backingFile}" if $vim_log
824
- $vim_log.debug "MiqVimVm::MiqVimVm: controllerKey = #{controllerKey}, key = #{key}" if $vim_log
824
+ logger.debug "MiqVimVm::MiqVimVm: backingFile = #{backingFile}"
825
+ logger.debug "MiqVimVm::MiqVimVm: controllerKey = #{controllerKey}, key = #{key}"
825
826
 
826
827
  vmConfigSpec = VimHash.new("VirtualMachineConfigSpec") do |vmcs|
827
828
  vmcs.deviceChange = VimArray.new("ArrayOfVirtualDeviceConfigSpec") do |vmcs_vca|
@@ -859,9 +860,9 @@ class MiqVimVm
859
860
  end
860
861
  end
861
862
 
862
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).removeDiskByFile: calling reconfigVM_Task" if $vim_log
863
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).removeDiskByFile: calling reconfigVM_Task"
863
864
  taskMor = @invObj.reconfigVM_Task(@vmMor, vmConfigSpec)
864
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).removeDiskByFile: returned from reconfigVM_Task" if $vim_log
865
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).removeDiskByFile: returned from reconfigVM_Task"
865
866
  waitForTask(taskMor)
866
867
  end # def removeDiskByFile
867
868
 
@@ -869,7 +870,7 @@ class MiqVimVm
869
870
  disk = getDeviceByBacking(backingFile)
870
871
  raise "resizeDisk: no virtual device associated with: #{backingFile}" unless disk
871
872
  raise "resizeDisk: cannot reduce the size of a disk" unless newSizeInKb >= Integer(disk.capacityInKB)
872
- $vim_log.debug "MiqVimVm::resizeDisk: backingFile = #{backingFile} current size = #{device.capacityInKB} newSize = #{newSizeInKb} KB" if $vim_log
873
+ logger.debug "MiqVimVm::resizeDisk: backingFile = #{backingFile} current size = #{device.capacityInKB} newSize = #{newSizeInKb} KB"
873
874
 
874
875
  vmConfigSpec = VimHash.new("VirtualMachineConfigSpec") do |vmcs|
875
876
  vmcs.deviceChange = VimArray.new("ArrayOfVirtualDeviceConfigSpec") do |vmcs_vca|
@@ -887,9 +888,9 @@ class MiqVimVm
887
888
  end
888
889
  end
889
890
 
890
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).resizeDisk: calling reconfigVM_Task" if $vim_log
891
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).resizeDisk: calling reconfigVM_Task"
891
892
  taskMor = @invObj.reconfigVM_Task(@vmMor, vmConfigSpec)
892
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).resizeDisk: returned from reconfigVM_Task" if $vim_log
893
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).resizeDisk: returned from reconfigVM_Task"
893
894
  waitForTask(taskMor)
894
895
  end
895
896
 
@@ -1041,9 +1042,9 @@ class MiqVimVm
1041
1042
  else
1042
1043
  aSpec = @miqAlarmSpecDisabled
1043
1044
  end
1044
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).addMiqAlarm_locked: calling createAlarm" if $vim_log
1045
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).addMiqAlarm_locked: calling createAlarm"
1045
1046
  alarmMor = @invObj.createAlarm(alarmManager, @vmMor, aSpec)
1046
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).addMiqAlarm_locked: returned from createAlarm" if $vim_log
1047
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).addMiqAlarm_locked: returned from createAlarm"
1047
1048
  @miqAlarmMor = alarmMor
1048
1049
  ensure
1049
1050
  @cacheLock.sync_unlock if unlock
@@ -1074,9 +1075,9 @@ class MiqVimVm
1074
1075
  begin
1075
1076
  @cacheLock.sync_lock(:EX) if (unlock = @cacheLock.sync_shared?)
1076
1077
 
1077
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).getMiqAlarm_locked: calling getAlarm" if $vim_log
1078
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).getMiqAlarm_locked: calling getAlarm"
1078
1079
  alarms = @invObj.getAlarm(@sic.alarmManager, @vmMor)
1079
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).getMiqAlarm_locked: returned from getAlarm" if $vim_log
1080
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).getMiqAlarm_locked: returned from getAlarm"
1080
1081
  alarms.each do |aMor|
1081
1082
  ap = @invObj.getMoProp(aMor, "info.name")
1082
1083
  next unless ap['info']['name'][MIQ_ALARM_PFX]
@@ -1105,27 +1106,27 @@ class MiqVimVm
1105
1106
  def disableMiqAlarm
1106
1107
  @cacheLock.synchronize(:SH) do
1107
1108
  raise "disableMiqAlarm: MiqAlarm not configured for VM #{@dsPath}" unless (aMor = getMiqAlarm_locked)
1108
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).disableMiqAlarm: calling reconfigureAlarm" if $vim_log
1109
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).disableMiqAlarm: calling reconfigureAlarm"
1109
1110
  @invObj.reconfigureAlarm(aMor, @miqAlarmSpecDisabled)
1110
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).disableMiqAlarm: returned from reconfigureAlarm" if $vim_log
1111
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).disableMiqAlarm: returned from reconfigureAlarm"
1111
1112
  end
1112
1113
  end
1113
1114
 
1114
1115
  def enableMiqAlarm
1115
1116
  @cacheLock.synchronize(:SH) do
1116
1117
  raise "enableMiqAlarm: MiqAlarm not configured for VM #{@dsPath}" unless (aMor = getMiqAlarm_locked)
1117
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).enableMiqAlarm: calling reconfigureAlarm" if $vim_log
1118
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).enableMiqAlarm: calling reconfigureAlarm"
1118
1119
  @invObj.reconfigureAlarm(aMor, @miqAlarmSpecEnabled)
1119
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).enableMiqAlarm: returned from reconfigureAlarm" if $vim_log
1120
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).enableMiqAlarm: returned from reconfigureAlarm"
1120
1121
  end
1121
1122
  end
1122
1123
 
1123
1124
  def removeMiqAlarm
1124
1125
  @cacheLock.synchronize(:SH) do
1125
1126
  return unless (aMor = getMiqAlarm_locked)
1126
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).removeMiqAlarm: calling removeAlarm" if $vim_log
1127
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).removeMiqAlarm: calling removeAlarm"
1127
1128
  @invObj.removeAlarm(aMor)
1128
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).removeMiqAlarm: returned from removeAlarm" if $vim_log
1129
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).removeMiqAlarm: returned from removeAlarm"
1129
1130
  @miqAlarmMor = nil
1130
1131
  end
1131
1132
  end
@@ -1177,9 +1178,9 @@ class MiqVimVm
1177
1178
  end
1178
1179
  end
1179
1180
 
1180
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).setExtraConfigAttributes: calling reconfigVM_Task" if $vim_log
1181
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).setExtraConfigAttributes: calling reconfigVM_Task"
1181
1182
  taskMor = @invObj.reconfigVM_Task(@vmMor, vmConfigSpec)
1182
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).setExtraConfigAttributes: returned from reconfigVM_Task" if $vim_log
1183
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).setExtraConfigAttributes: returned from reconfigVM_Task"
1183
1184
  waitForTask(taskMor)
1184
1185
 
1185
1186
  @extraConfig = nil
@@ -1287,16 +1288,16 @@ class MiqVimVm
1287
1288
  end
1288
1289
 
1289
1290
  def acquireMksTicket
1290
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).acquireMksTicket: calling acquireMksTicket" if $vim_log
1291
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).acquireMksTicket: calling acquireMksTicket"
1291
1292
  rv = @invObj.acquireMksTicket(@vmMor)
1292
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).acquireMksTicket: returned from acquireMksTicket" if $vim_log
1293
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).acquireMksTicket: returned from acquireMksTicket"
1293
1294
  (rv)
1294
1295
  end # def acquireMksTicket
1295
1296
 
1296
1297
  def acquireTicket(ticketType)
1297
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).acquireTicket: calling acquireTicket" if $vim_log
1298
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).acquireTicket: calling acquireTicket"
1298
1299
  rv = @invObj.acquireTicket(@vmMor, ticketType)
1299
- $vim_log.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).acquireTicket: returned from acquireTicket" if $vim_log
1300
+ logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).acquireTicket: returned from acquireTicket"
1300
1301
  (rv)
1301
1302
  end # def acquireTicket
1302
1303
 
@@ -1,8 +1,11 @@
1
1
  require "handsoap"
2
2
  require 'active_support/core_ext/numeric/bytes'
3
+ require 'VMwareWebService/logging'
3
4
  require 'VMwareWebService/VimTypes'
4
5
 
5
6
  class VimService < Handsoap::Service
7
+ include VMwareWebService::Logging
8
+
6
9
  attr_reader :sic, :about, :apiVersion, :isVirtualCenter, :v20, :v2, :v4, :v5, :v6, :serviceInstanceMor, :session_cookie
7
10
 
8
11
  Handsoap.http_driver = :HTTPClient
@@ -1291,14 +1294,14 @@ class VimService < Handsoap::Service
1291
1294
  if @xml_payload_len > @xml_payload_max
1292
1295
  @xml_payload_len = 0
1293
1296
 
1294
- $vim_log.debug("#{log_prefix} Running garbage collection")
1297
+ logger.debug("#{log_prefix} Running garbage collection")
1295
1298
 
1296
1299
  # Force a GC, because Ruby's GC is triggered on number of objects without
1297
1300
  # regard to size. The object we just freed may not be released right away.
1298
1301
  gc_time = Benchmark.realtime { GC.start }
1299
1302
 
1300
1303
  gc_log_level = gc_time >= 5 ? :warn : :debug
1301
- $vim_log.send(gc_log_level, "#{log_prefix} Garbage collection took #{gc_time} seconds")
1304
+ logger.send(gc_log_level, "#{log_prefix} Garbage collection took #{gc_time} seconds")
1302
1305
  end
1303
1306
  end
1304
1307
  end
@@ -2,6 +2,8 @@ require 'drb/drb'
2
2
  require 'sync'
3
3
  require 'ffi-vix_disk_lib/const'
4
4
  require 'ffi-vix_disk_lib/enum'
5
+ require 'VMwareWebService/logging'
6
+
5
7
  #
6
8
  # The path to the VixDiskLib directory to be added to the process' LD_LIBRARY_PATH
7
9
  #
@@ -17,6 +19,8 @@ end
17
19
  SERVER_PATH = File.expand_path(__dir__)
18
20
 
19
21
  class VixDiskLib
22
+ include VMwareWebService::Logging
23
+
20
24
  VIXDISKLIB_FLAG_OPEN_READ_ONLY = FFI::VixDiskLib::API::VIXDISKLIB_FLAG_OPEN_READ_ONLY
21
25
  @initialized = nil
22
26
  @drb_services = []
@@ -66,12 +70,12 @@ class VixDiskLib
66
70
  i = 0
67
71
  @drb_services.each do |vdl_service|
68
72
  i += 1
69
- $vim_log.info "VixDiskLib.exit: shutting down service #{i} of #{@drb_services.size}" if $vim_log
73
+ logger.info "VixDiskLib.exit: shutting down service #{i} of #{@drb_services.size}"
70
74
  unless vdl_service.nil?
71
75
  begin
72
76
  vdl_service.shutdown = true
73
77
  rescue DRb::DRbConnError
74
- $vim_log.info "VixDiskLib.exit: DRb connection closed due to service shutdown. Continuing" if $vim_log
78
+ logger.info "VixDiskLib.exit: DRb connection closed due to service shutdown. Continuing"
75
79
  end
76
80
  end
77
81
  end
@@ -95,8 +99,9 @@ class VixDiskLib
95
99
  end
96
100
 
97
101
  my_env["LD_LIBRARY_PATH"] = (my_env["LD_LIBRARY_PATH"].to_s.split(':') << VIXDISKLIB_PATH).compact.join(":")
98
- raise VixDiskLibError, "VixDiskLib.connect() failed: No $vim_log defined" unless $vim_log
99
- my_env["LOG_FILE"] = $vim_log.logdev.filename.to_s
102
+ raise VixDiskLibError, "VixDiskLib.connect() failed: No logger defined" unless logger
103
+ my_env["LOG_FILE"] = logger.logdev.filename.to_s if logger.logdev.kind_of?(Logger::LogDevice)
104
+
100
105
  my_env
101
106
  end
102
107
 
@@ -109,16 +114,19 @@ class VixDiskLib
109
114
  proc_reader, @proc_writer = IO.pipe
110
115
 
111
116
  server_cmd = "ruby #{SERVER_PATH}/VixDiskLibServer.rb"
112
- $vim_log.info "VixDiskLib.start_service: running command = #{server_cmd}"
117
+ log_target = my_env["LOG_FILE"] ? [my_env["LOG_FILE"], "a"] : $stdout
118
+
119
+ logger.info "VixDiskLib.start_service: running command = #{server_cmd}"
120
+
113
121
  pid = Kernel.spawn(my_env, server_cmd,
114
- [:out, :err] => [my_env["LOG_FILE"], "a"],
122
+ [:out, :err] => log_target,
115
123
  :unsetenv_others => true,
116
124
  3 => uri_writer,
117
125
  4 => proc_reader)
118
126
  uri_writer.close
119
127
  proc_reader.close
120
128
  Process.detach(pid)
121
- $vim_log.info "VixDiskLibServer Process #{pid} started" if $vim_log
129
+ logger.info "VixDiskLibServer Process #{pid} started"
122
130
  DRb.start_service
123
131
  retry_num = 5
124
132
  uri = get_uri(uri_reader)