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,5 +1,4 @@
1
1
  require 'sync'
2
- require 'enumerator'
3
2
  require 'VMwareWebService/MiqVimClientBase'
4
3
  require 'VMwareWebService/MiqVimDump'
5
4
  require 'VMwareWebService/VimPropMaps'
@@ -18,31 +17,31 @@ class MiqVimInventory < MiqVimClientBase
18
17
  @@selectorHash = {}
19
18
  @@cacheScope = :cache_scope_full
20
19
 
21
- def initialize(server, username, password, cacheScope = nil)
22
- super(server, username, password)
20
+ def initialize(server:, username:, password:, port: 443, ssl_options: {}, cache_scope: nil)
21
+ super(:server => server, :port => port, :ssl_options => ssl_options, :username => username, :password => password)
23
22
 
24
- cacheScope ||= @@cacheScope
23
+ cache_scope ||= @@cacheScope
25
24
 
26
- case cacheScope
25
+ case cache_scope
27
26
  when :cache_scope_full
28
27
  @propMap = FullPropMap
29
- $vim_log.info "MiqVimInventory: using property map FullPropMap"
28
+ logger.info "MiqVimInventory: using property map FullPropMap"
30
29
  when :cache_scope_ems_refresh
31
30
  @propMap = EmsRefreshPropMap
32
- $vim_log.info "MiqVimInventory: using property map EmsRefreshPropMap"
31
+ logger.info "MiqVimInventory: using property map EmsRefreshPropMap"
33
32
  when :cache_scope_core
34
33
  @propMap = CorePropMap
35
- $vim_log.info "MiqVimInventory: using property map CorePropMap"
34
+ logger.info "MiqVimInventory: using property map CorePropMap"
36
35
  when :cache_scope_event_monitor
37
36
  @propMap = EventMonitorPropMap
38
- $vim_log.info "MiqVimInventory: using property map EventMonitorPropMap"
37
+ logger.info "MiqVimInventory: using property map EventMonitorPropMap"
39
38
  else
40
39
  @propMap = FullPropMap
41
- $vim_log.info "MiqVimInventory: unrecognized cache scope #{cacheScope}, using FullPropMap"
40
+ logger.info "MiqVimInventory: unrecognized cache scope #{cacheScope}, using FullPropMap"
42
41
  end
43
42
 
44
43
  # If we are connected to a virtual center then we can access additional properties
45
- @propMap.merge!(PropMapVCenter) if isVirtualCenter && cacheScope != :cache_scope_event_monitor
44
+ @propMap.merge!(PropMapVCenter) if isVirtualCenter && cache_scope != :cache_scope_event_monitor
46
45
 
47
46
  @propCol = @sic.propertyCollector
48
47
  @rootFolder = @sic.rootFolder
@@ -88,11 +87,11 @@ class MiqVimInventory < MiqVimClientBase
88
87
 
89
88
  unless instance_variable_get(hnm).nil?
90
89
  hnmc = instance_variable_get(hnm).keys.length
91
- $vim_log.info "#{pref}#{hnm}: #{hnmc}"
90
+ logger.info "#{pref}#{hnm}: #{hnmc}"
92
91
  end
93
92
  unless instance_variable_get(hn).nil?
94
93
  hnc = instance_variable_get(hn).keys.length
95
- $vim_log.info "#{pref}#{hn}: #{hnc}"
94
+ logger.info "#{pref}#{hn}: #{hnc}"
96
95
  end
97
96
  end
98
97
  end
@@ -108,37 +107,37 @@ class MiqVimInventory < MiqVimClientBase
108
107
  hashByKey = pm[:keyPath] ? instance_variable_get(hn) : nil
109
108
 
110
109
  if hashByMor.nil?
111
- $vim_log.info "#{pref}#{hnm}: is nil"
110
+ logger.info "#{pref}#{hnm}: is nil"
112
111
  next
113
112
  end
114
113
 
115
114
  keya = hashByMor.keys
116
115
  obja = hashByMor.values
117
- $vim_log.info "#{pref}#{hnm}: #keys = #{keya.length}"
118
- $vim_log.info "#{pref}#{hnm}: #objects = #{obja.length}"
116
+ logger.info "#{pref}#{hnm}: #keys = #{keya.length}"
117
+ logger.info "#{pref}#{hnm}: #objects = #{obja.length}"
119
118
  obja.compact!
120
119
  obja.uniq!
121
- $vim_log.info "#{pref}#{hnm}: #unique non-nill objects = #{obja.length}"
120
+ logger.info "#{pref}#{hnm}: #unique non-nill objects = #{obja.length}"
122
121
 
123
122
  unless hashByKey.nil?
124
123
  keyb = hashByKey.keys
125
124
  objb = hashByKey.values
126
- $vim_log.info "#{pref}#{hn}: #keys = #{keyb.length}"
127
- $vim_log.info "#{pref}#{hn}: #objects = #{objb.length}"
125
+ logger.info "#{pref}#{hn}: #keys = #{keyb.length}"
126
+ logger.info "#{pref}#{hn}: #objects = #{objb.length}"
128
127
  objb.compact!
129
128
  objb.uniq!
130
- $vim_log.info "#{pref}#{hn}: #unique non-nill objects = #{objb.length}"
129
+ logger.info "#{pref}#{hn}: #unique non-nill objects = #{objb.length}"
131
130
  obja.concat(objb).uniq!
132
131
  end
133
- $vim_log.info "#{pref}TOTAL: #unique non-nill objects = #{obja.length}"
132
+ logger.info "#{pref}TOTAL: #unique non-nill objects = #{obja.length}"
134
133
  cacheSz = Marshal.dump(obja).length
135
- $vim_log.info "#{pref}TOTAL: size of objects = #{cacheSz}"
136
- $vim_log.info "#{pref}****"
134
+ logger.info "#{pref}TOTAL: size of objects = #{cacheSz}"
135
+ logger.info "#{pref}****"
137
136
  totalCacheSz += cacheSz
138
137
  end
139
- $vim_log.info "#{pref}****************"
140
- $vim_log.info "#{pref}TOTAL: cache size = #{totalCacheSz}"
141
- $vim_log.info "#{pref}****************"
138
+ logger.info "#{pref}****************"
139
+ logger.info "#{pref}TOTAL: cache size = #{totalCacheSz}"
140
+ logger.info "#{pref}****************"
142
141
  end
143
142
  totalCacheSz
144
143
  end
@@ -219,7 +218,7 @@ class MiqVimInventory < MiqVimClientBase
219
218
  end
220
219
 
221
220
  def resetCache
222
- $vim_log.info "MiqVimInventory.resetCache: clearing cache for #{@connId}"
221
+ logger.info "MiqVimInventory.resetCache: clearing cache for #{@connId}"
223
222
  @cacheLock.synchronize(:EX) do
224
223
  @inventoryHash = nil
225
224
 
@@ -228,7 +227,7 @@ class MiqVimInventory < MiqVimClientBase
228
227
  instance_variable_set(pm[:baseName], nil)
229
228
  end
230
229
  end
231
- $vim_log.info "MiqVimInventory.resetCache: cleared cache for #{@connId}"
230
+ logger.info "MiqVimInventory.resetCache: cleared cache for #{@connId}"
232
231
  end # def resetCache
233
232
 
234
233
  def currentSession
@@ -239,11 +238,11 @@ class MiqVimInventory < MiqVimClientBase
239
238
  return false unless @alive
240
239
  begin
241
240
  unless currentSession
242
- $vim_log.info "MiqVimInventory.isAlive?: Current session no longer exists."
241
+ logger.info "MiqVimInventory.isAlive?: Current session no longer exists."
243
242
  @alive = false
244
243
  end
245
244
  rescue Exception => err
246
- $vim_log.info "MiqVimInventory.isAlive?: Could not access connection - #{err}"
245
+ logger.info "MiqVimInventory.isAlive?: Could not access connection - #{err}"
247
246
  @alive = false
248
247
  end
249
248
  @alive
@@ -278,9 +277,9 @@ class MiqVimInventory < MiqVimClientBase
278
277
  if keyPath
279
278
  key = props.fetch_path(keyPath)
280
279
  if !key
281
- $vim_log.debug "hashObj: key is nil for #{mor}: #{keyPath}"
280
+ logger.debug "hashObj: key is nil for #{mor}: #{keyPath}"
282
281
  elsif key.empty?
283
- $vim_log.debug "hashObj: key is empty for #{mor}: #{keyPath}"
282
+ logger.debug "hashObj: key is empty for #{mor}: #{keyPath}"
284
283
  key = nil
285
284
  props.store_path(keyPath, nil)
286
285
  end
@@ -491,7 +490,7 @@ class MiqVimInventory < MiqVimClientBase
491
490
  raise "virtualMachines_locked: cache lock not held" unless @cacheLock.sync_locked?
492
491
  return(@virtualMachines) if @virtualMachines
493
492
 
494
- $vim_log.info "MiqVimInventory.virtualMachines_locked: loading VirtualMachine cache for #{@connId}"
493
+ logger.info "MiqVimInventory.virtualMachines_locked: loading VirtualMachine cache for #{@connId}"
495
494
  begin
496
495
  @cacheLock.sync_lock(:EX) if (unlock = @cacheLock.sync_shared?)
497
496
 
@@ -505,7 +504,7 @@ class MiqVimInventory < MiqVimClientBase
505
504
  ensure
506
505
  @cacheLock.sync_unlock if unlock
507
506
  end
508
- $vim_log.info "MiqVimInventory.virtualMachines_locked: loaded VirtualMachine cache for #{@connId}"
507
+ logger.info "MiqVimInventory.virtualMachines_locked: loaded VirtualMachine cache for #{@connId}"
509
508
 
510
509
  @virtualMachines
511
510
  end # def virtualMachines_locked
@@ -617,7 +616,7 @@ class MiqVimInventory < MiqVimClientBase
617
616
  raise "computeResources_locked: cache lock not held" unless @cacheLock.sync_locked?
618
617
  return(@computeResources) if @computeResources
619
618
 
620
- $vim_log.info "MiqVimInventory.computeResources_locked: loading ComputeResource cache for #{@connId}"
619
+ logger.info "MiqVimInventory.computeResources_locked: loading ComputeResource cache for #{@connId}"
621
620
  begin
622
621
  @cacheLock.sync_lock(:EX) if (unlock = @cacheLock.sync_shared?)
623
622
 
@@ -631,7 +630,7 @@ class MiqVimInventory < MiqVimClientBase
631
630
  ensure
632
631
  @cacheLock.sync_unlock if unlock
633
632
  end
634
- $vim_log.info "MiqVimInventory.computeResources_locked: loaded ComputeResource cache for #{@connId}"
633
+ logger.info "MiqVimInventory.computeResources_locked: loaded ComputeResource cache for #{@connId}"
635
634
 
636
635
  @computeResources
637
636
  end # def computeResources_locked
@@ -720,7 +719,7 @@ class MiqVimInventory < MiqVimClientBase
720
719
  raise "clusterComputeResources_locked: cache lock not held" unless @cacheLock.sync_locked?
721
720
  return(@clusterComputeResources) if @clusterComputeResources
722
721
 
723
- $vim_log.info "MiqVimInventory.clusterComputeResources_locked: loading ClusterComputeResource cache for #{@connId}"
722
+ logger.info "MiqVimInventory.clusterComputeResources_locked: loading ClusterComputeResource cache for #{@connId}"
724
723
  begin
725
724
  @cacheLock.sync_lock(:EX) if (unlock = @cacheLock.sync_shared?)
726
725
 
@@ -734,7 +733,7 @@ class MiqVimInventory < MiqVimClientBase
734
733
  ensure
735
734
  @cacheLock.sync_unlock if unlock
736
735
  end
737
- $vim_log.info "MiqVimInventory.clusterComputeResources_locked: loaded ClusterComputeResource cache for #{@connId}"
736
+ logger.info "MiqVimInventory.clusterComputeResources_locked: loaded ClusterComputeResource cache for #{@connId}"
738
737
 
739
738
  @clusterComputeResources
740
739
  end # def clusterComputeResources_locked
@@ -823,7 +822,7 @@ class MiqVimInventory < MiqVimClientBase
823
822
  raise "resourcePools_locked: cache lock not held" unless @cacheLock.sync_locked?
824
823
  return(@resourcePools) if @resourcePools
825
824
 
826
- $vim_log.info "MiqVimInventory.resourcePools_locked: loading ResourcePool cache for #{@connId}"
825
+ logger.info "MiqVimInventory.resourcePools_locked: loading ResourcePool cache for #{@connId}"
827
826
  begin
828
827
  @cacheLock.sync_lock(:EX) if (unlock = @cacheLock.sync_shared?)
829
828
 
@@ -837,7 +836,7 @@ class MiqVimInventory < MiqVimClientBase
837
836
  ensure
838
837
  @cacheLock.sync_unlock if unlock
839
838
  end
840
- $vim_log.info "MiqVimInventory.resourcePools_locked: loaded ResourcePool cache for #{@connId}"
839
+ logger.info "MiqVimInventory.resourcePools_locked: loaded ResourcePool cache for #{@connId}"
841
840
 
842
841
  @resourcePools
843
842
  end # def resourcePools_locked
@@ -935,7 +934,7 @@ class MiqVimInventory < MiqVimClientBase
935
934
 
936
935
  return(@virtualApps) if @virtualApps
937
936
 
938
- $vim_log.info "MiqVimInventory.virtualApps_locked: loading VirtualApp cache for #{@connId}"
937
+ logger.info "MiqVimInventory.virtualApps_locked: loading VirtualApp cache for #{@connId}"
939
938
  begin
940
939
  @cacheLock.sync_lock(:EX) if (unlock = @cacheLock.sync_shared?)
941
940
 
@@ -949,7 +948,7 @@ class MiqVimInventory < MiqVimClientBase
949
948
  ensure
950
949
  @cacheLock.sync_unlock if unlock
951
950
  end
952
- $vim_log.info "MiqVimInventory.virtualApps_locked: loaded VirtualApp cache for #{@connId}"
951
+ logger.info "MiqVimInventory.virtualApps_locked: loaded VirtualApp cache for #{@connId}"
953
952
 
954
953
  @virtualApps
955
954
  end # def virtualApps_locked
@@ -1038,7 +1037,7 @@ class MiqVimInventory < MiqVimClientBase
1038
1037
  raise "folders_locked: cache lock not held" unless @cacheLock.sync_locked?
1039
1038
  return(@folders) if @folders
1040
1039
 
1041
- $vim_log.info "MiqVimInventory.folders_locked: loading Folder cache for #{@connId}"
1040
+ logger.info "MiqVimInventory.folders_locked: loading Folder cache for #{@connId}"
1042
1041
  begin
1043
1042
  @cacheLock.sync_lock(:EX) if (unlock = @cacheLock.sync_shared?)
1044
1043
 
@@ -1052,7 +1051,7 @@ class MiqVimInventory < MiqVimClientBase
1052
1051
  ensure
1053
1052
  @cacheLock.sync_unlock if unlock
1054
1053
  end
1055
- $vim_log.info "MiqVimInventory.folders_locked: loaded Folder cache for #{@connId}"
1054
+ logger.info "MiqVimInventory.folders_locked: loaded Folder cache for #{@connId}"
1056
1055
 
1057
1056
  @folders
1058
1057
  end # def folders_locked
@@ -1141,7 +1140,7 @@ class MiqVimInventory < MiqVimClientBase
1141
1140
  raise "datacenters_locked: cache lock not held" unless @cacheLock.sync_locked?
1142
1141
  return(@datacenters) if @datacenters
1143
1142
 
1144
- $vim_log.info "MiqVimInventory.datacenters_locked: loading Datacenter cache for #{@connId}"
1143
+ logger.info "MiqVimInventory.datacenters_locked: loading Datacenter cache for #{@connId}"
1145
1144
  begin
1146
1145
  @cacheLock.sync_lock(:EX) if (unlock = @cacheLock.sync_shared?)
1147
1146
 
@@ -1155,7 +1154,7 @@ class MiqVimInventory < MiqVimClientBase
1155
1154
  ensure
1156
1155
  @cacheLock.sync_unlock if unlock
1157
1156
  end
1158
- $vim_log.info "MiqVimInventory.datacenters_locked: loaded Datacenter cache for #{@connId}"
1157
+ logger.info "MiqVimInventory.datacenters_locked: loaded Datacenter cache for #{@connId}"
1159
1158
 
1160
1159
  @datacenters
1161
1160
  end # def datacenters_locked
@@ -1244,7 +1243,7 @@ class MiqVimInventory < MiqVimClientBase
1244
1243
  raise "hostSystems_locked: cache lock not held" unless @cacheLock.sync_locked?
1245
1244
  return(@hostSystems) if @hostSystems
1246
1245
 
1247
- $vim_log.info "MiqVimInventory.hostSystems_locked: loading HostSystem cache for #{@connId}"
1246
+ logger.info "MiqVimInventory.hostSystems_locked: loading HostSystem cache for #{@connId}"
1248
1247
  begin
1249
1248
  @cacheLock.sync_lock(:EX) if (unlock = @cacheLock.sync_shared?)
1250
1249
 
@@ -1258,7 +1257,7 @@ class MiqVimInventory < MiqVimClientBase
1258
1257
  ensure
1259
1258
  @cacheLock.sync_unlock if unlock
1260
1259
  end
1261
- $vim_log.info "MiqVimInventory.hostSystems_locked: loaded HostSystem cache for #{@connId}"
1260
+ logger.info "MiqVimInventory.hostSystems_locked: loaded HostSystem cache for #{@connId}"
1262
1261
 
1263
1262
  @hostSystems
1264
1263
  end # def hostSystems_locked
@@ -1369,7 +1368,7 @@ class MiqVimInventory < MiqVimClientBase
1369
1368
  raise "dataStores_locked: cache lock not held" unless @cacheLock.sync_locked?
1370
1369
  return(@dataStores) if @dataStores
1371
1370
 
1372
- $vim_log.info "MiqVimInventory.dataStores_locked: loading Datastore cache for #{@connId}"
1371
+ logger.info "MiqVimInventory.dataStores_locked: loading Datastore cache for #{@connId}"
1373
1372
  begin
1374
1373
  @cacheLock.sync_lock(:EX) if (unlock = @cacheLock.sync_shared?)
1375
1374
 
@@ -1383,7 +1382,7 @@ class MiqVimInventory < MiqVimClientBase
1383
1382
  ensure
1384
1383
  @cacheLock.sync_unlock if unlock
1385
1384
  end
1386
- $vim_log.info "MiqVimInventory.dataStores_locked: loaded Datastore cache for #{@connId}"
1385
+ logger.info "MiqVimInventory.dataStores_locked: loaded Datastore cache for #{@connId}"
1387
1386
 
1388
1387
  @dataStores
1389
1388
  end # def dataStores_locked
@@ -1488,7 +1487,7 @@ class MiqVimInventory < MiqVimClientBase
1488
1487
  raise "dvPortgroups_locked: cache lock not held" unless @cacheLock.sync_locked?
1489
1488
  return(@dvPortgroups) if @dvPortgroups
1490
1489
 
1491
- $vim_log.info "MiqVimInventory.dvPortgroups_locked: loading DV Portgroup cache for #{@connId}"
1490
+ logger.info "MiqVimInventory.dvPortgroups_locked: loading DV Portgroup cache for #{@connId}"
1492
1491
  begin
1493
1492
  @cacheLock.sync_lock(:EX) if (unlock = @cacheLock.sync_shared?)
1494
1493
 
@@ -1502,7 +1501,7 @@ class MiqVimInventory < MiqVimClientBase
1502
1501
  ensure
1503
1502
  @cacheLock.sync_unlock if unlock
1504
1503
  end
1505
- $vim_log.info "MiqVimInventory.dvPortgroups_locked: loaded DV Portgroup cache for #{@connId}"
1504
+ logger.info "MiqVimInventory.dvPortgroups_locked: loaded DV Portgroup cache for #{@connId}"
1506
1505
 
1507
1506
  @dvPortgroups
1508
1507
  end # def dvPortgroups_locked
@@ -1576,7 +1575,7 @@ class MiqVimInventory < MiqVimClientBase
1576
1575
  raise "dvSwitches_locked: cache lock not held" unless @cacheLock.sync_locked?
1577
1576
  return(@dvSwithces) if @dvSwitches
1578
1577
 
1579
- $vim_log.info "MiqVimInventory.dvSwitches_locked: loading DV Switch cache for #{@connId}"
1578
+ logger.info "MiqVimInventory.dvSwitches_locked: loading DV Switch cache for #{@connId}"
1580
1579
 
1581
1580
  base_class = 'DistributedVirtualSwitch'.freeze
1582
1581
  child_classes = VimClass.child_classes(base_class)
@@ -1596,7 +1595,7 @@ class MiqVimInventory < MiqVimClientBase
1596
1595
  ensure
1597
1596
  @cacheLock.sync_unlock if unlock
1598
1597
  end
1599
- $vim_log.info "MiqVimInventory.dvSwitches_locked: loaded DV Switch cache for #{@connId}"
1598
+ logger.info "MiqVimInventory.dvSwitches_locked: loaded DV Switch cache for #{@connId}"
1600
1599
 
1601
1600
  @dvSwitches
1602
1601
  end # def dvSwitches_locked
@@ -1669,7 +1668,7 @@ class MiqVimInventory < MiqVimClientBase
1669
1668
  raise "storagePods_locked: cache lock not held" unless @cacheLock.sync_locked?
1670
1669
  return(@storagePods) if @storagePods
1671
1670
 
1672
- $vim_log.info "MiqVimInventory.storagePods_locked: loading Datastore Cluster cache for #{@connId}"
1671
+ logger.info "MiqVimInventory.storagePods_locked: loading Datastore Cluster cache for #{@connId}"
1673
1672
  begin
1674
1673
  @cacheLock.sync_lock(:EX) if (unlock = @cacheLock.sync_shared?)
1675
1674
 
@@ -1683,7 +1682,7 @@ class MiqVimInventory < MiqVimClientBase
1683
1682
  ensure
1684
1683
  @cacheLock.sync_unlock if unlock
1685
1684
  end
1686
- $vim_log.info "MiqVimInventory.storagePods_locked: loaded Datastore Cluster cache for #{@connId}"
1685
+ logger.info "MiqVimInventory.storagePods_locked: loaded Datastore Cluster cache for #{@connId}"
1687
1686
 
1688
1687
  @storagePods
1689
1688
  end # def storagePods_locked
@@ -1761,7 +1760,7 @@ class MiqVimInventory < MiqVimClientBase
1761
1760
  raise "licenseManagers_locked: cache lock not held" unless @cacheLock.sync_locked?
1762
1761
  return(@licenseManagers) if @licenseManagers
1763
1762
 
1764
- $vim_log.info "MiqVimInventory.licenseManagers_locked: loading LicenseManager cache for #{@connId}"
1763
+ logger.info "MiqVimInventory.licenseManagers_locked: loading LicenseManager cache for #{@connId}"
1765
1764
  begin
1766
1765
  @cacheLock.sync_lock(:EX) if (unlock = @cacheLock.sync_shared?)
1767
1766
 
@@ -1775,7 +1774,7 @@ class MiqVimInventory < MiqVimClientBase
1775
1774
  ensure
1776
1775
  @cacheLock.sync_unlock if unlock
1777
1776
  end
1778
- $vim_log.info "MiqVimInventory.licenseManagers_locked: loaded LicenseManager cache for #{@connId}"
1777
+ logger.info "MiqVimInventory.licenseManagers_locked: loaded LicenseManager cache for #{@connId}"
1779
1778
 
1780
1779
  @licenseManagers
1781
1780
  end # def licenseManagers_locked
@@ -1871,7 +1870,7 @@ class MiqVimInventory < MiqVimClientBase
1871
1870
  raise "extensionManagers_locked: cache lock not held" unless @cacheLock.sync_locked?
1872
1871
  return(@extensionManagers) if @extensionManagers
1873
1872
 
1874
- $vim_log.info "MiqVimInventory.extensionManagers_locked: loading ExtensionManager cache for #{@connId}"
1873
+ logger.info "MiqVimInventory.extensionManagers_locked: loading ExtensionManager cache for #{@connId}"
1875
1874
  begin
1876
1875
  @cacheLock.sync_lock(:EX) if (unlock = @cacheLock.sync_shared?)
1877
1876
 
@@ -1885,7 +1884,7 @@ class MiqVimInventory < MiqVimClientBase
1885
1884
  ensure
1886
1885
  @cacheLock.sync_unlock if unlock
1887
1886
  end
1888
- $vim_log.info "MiqVimInventory.extensionManagers_locked: loaded ExtensionManager cache for #{@connId}"
1887
+ logger.info "MiqVimInventory.extensionManagers_locked: loaded ExtensionManager cache for #{@connId}"
1889
1888
 
1890
1889
  @extensionManagers
1891
1890
  end # def extensionManagers_locked
@@ -1977,22 +1976,22 @@ class MiqVimInventory < MiqVimClientBase
1977
1976
  raise "inventoryHash_locked: cache lock not held" unless @cacheLock.sync_locked?
1978
1977
  return(@inventoryHash) if @inventoryHash
1979
1978
 
1980
- $vim_log.info "MiqVimInventory.inventoryHash_locked: loading inventoryHash for #{@connId}"
1979
+ logger.info "MiqVimInventory.inventoryHash_locked: loading inventoryHash for #{@connId}"
1981
1980
  begin
1982
1981
  @cacheLock.sync_lock(:EX) if (unlock = @cacheLock.sync_shared?)
1983
1982
 
1984
- $vim_log.info "MiqVimInventory(#{@server}, #{@username}).inventoryHash_locked: calling retrieveProperties" if $vim_log
1983
+ logger.info "MiqVimInventory(#{@server}, #{@username}).inventoryHash_locked: calling retrieveProperties"
1985
1984
 
1986
1985
  @inventoryHash = {}
1987
1986
  retrievePropertiesIter(@propCol, @spec) do |oc|
1988
1987
  (@inventoryHash[oc.obj.vimType] ||= []) << oc.obj
1989
1988
  end
1990
1989
 
1991
- $vim_log.info "MiqVimInventory(#{@server}, #{@username}).inventoryHash_locked: returned from retrieveProperties" if $vim_log
1990
+ logger.info "MiqVimInventory(#{@server}, #{@username}).inventoryHash_locked: returned from retrieveProperties"
1992
1991
  ensure
1993
1992
  @cacheLock.sync_unlock if unlock
1994
1993
  end
1995
- $vim_log.info "MiqVimInventory.inventoryHash_locked: loaded inventoryHash for #{@connId}"
1994
+ logger.info "MiqVimInventory.inventoryHash_locked: loaded inventoryHash for #{@connId}"
1996
1995
 
1997
1996
  @inventoryHash
1998
1997
  end
@@ -2009,9 +2008,9 @@ class MiqVimInventory < MiqVimClientBase
2009
2008
  # Generate a user event associated with the given managed object.
2010
2009
  #
2011
2010
  def logUserEvent(entity, msg)
2012
- $vim_log.info "MiqVimInventory(#{@server}, #{@username}).logUserEvent: calling logUserEvent" if $vim_log
2011
+ logger.info "MiqVimInventory(#{@server}, #{@username}).logUserEvent: calling logUserEvent"
2013
2012
  super(@sic.eventManager, entity, msg)
2014
- $vim_log.info "MiqVimInventory(#{@server}, #{@username}).logUserEvent: returned from logUserEvent" if $vim_log
2013
+ logger.info "MiqVimInventory(#{@server}, #{@username}).logUserEvent: returned from logUserEvent"
2015
2014
  end
2016
2015
 
2017
2016
  ##################################
@@ -2184,13 +2183,13 @@ class MiqVimInventory < MiqVimClientBase
2184
2183
 
2185
2184
  def getTaskMor(tmor)
2186
2185
  if tmor.respond_to?(:vimType)
2187
- $vim_log.debug "getTaskMor: returning #{tmor}, no search"
2186
+ logger.debug "getTaskMor: returning #{tmor}, no search"
2188
2187
  return tmor
2189
2188
  else
2190
- $vim_log.debug "getTaskMor: searching for task #{tmor}"
2189
+ logger.debug "getTaskMor: searching for task #{tmor}"
2191
2190
  getTasks.each do |tmo|
2192
2191
  if tmo.to_str == tmor
2193
- $vim_log.debug "getTaskMor: returning #{tmo} (#{tmo.vimType})"
2192
+ logger.debug "getTaskMor: returning #{tmo} (#{tmo.vimType})"
2194
2193
  return tmo
2195
2194
  end
2196
2195
  end
@@ -2205,7 +2204,7 @@ class MiqVimInventory < MiqVimClientBase
2205
2204
  def waitForTask(tmor, className = nil)
2206
2205
  className ||= self.class.to_s
2207
2206
 
2208
- $vim_log.info "#{className}(#{@server}, #{@username})::waitForTask(#{tmor})" if $vim_log
2207
+ logger.info "#{className}(#{@server}, #{@username})::waitForTask(#{tmor})"
2209
2208
  args = VimArray.new("ArrayOfPropertyFilterSpec") do |pfsa|
2210
2209
  pfsa << VimHash.new("PropertyFilterSpec") do |pfs|
2211
2210
  pfs.propSet = VimArray.new("ArrayOfPropertySpec") do |psa|
@@ -2241,14 +2240,14 @@ class MiqVimInventory < MiqVimClientBase
2241
2240
  end
2242
2241
 
2243
2242
  raise VimFault.new(error) if state == TaskInfoState::Error
2244
- $vim_log.info "#{className}(#{@server}, #{@username})::waitForTask: result = #{result}" if $vim_log
2243
+ logger.info "#{className}(#{@server}, #{@username})::waitForTask: result = #{result}"
2245
2244
  result
2246
2245
  end # def waitForTask
2247
2246
 
2248
2247
  def pollTask(tmor, className = nil)
2249
2248
  className ||= self.class.to_s
2250
2249
 
2251
- $vim_log.info "#{className}(#{@server}, #{@username})::pollTask(#{tmor})" if $vim_log
2250
+ logger.info "#{className}(#{@server}, #{@username})::pollTask(#{tmor})"
2252
2251
  args = VimArray.new("ArrayOfPropertyFilterSpec") do |pfsa|
2253
2252
  pfsa << VimHash.new("PropertyFilterSpec") do |pfs|
2254
2253
  pfs.propSet = VimArray.new("ArrayOfPropertySpec") do |psa|
@@ -2324,9 +2323,9 @@ class MiqVimInventory < MiqVimClientBase
2324
2323
  end
2325
2324
  end
2326
2325
 
2327
- $vim_log.info "MiqVimInventory(#{@server}, #{@username}).getMoProp_local: calling retrieveProperties(#{mo.vimType})" if $vim_log
2326
+ logger.info "MiqVimInventory(#{@server}, #{@username}).getMoProp_local: calling retrieveProperties(#{mo.vimType})"
2328
2327
  oca = retrievePropertiesCompat(@propCol, pfSpec)
2329
- $vim_log.info "MiqVimInventory(#{@server}, #{@username}).getMoProp_local: return from retrieveProperties(#{mo.vimType})" if $vim_log
2328
+ logger.info "MiqVimInventory(#{@server}, #{@username}).getMoProp_local: return from retrieveProperties(#{mo.vimType})"
2330
2329
 
2331
2330
  return nil if !oca || !oca[0] || !oca[0].propSet
2332
2331
 
@@ -2442,9 +2441,9 @@ class MiqVimInventory < MiqVimClientBase
2442
2441
  end
2443
2442
 
2444
2443
  def self.setSelector(selSpec)
2445
- raise "MiqVimBroker.setSelector: selSpec must be a hash, received #{selSpec.class}" unless selSpec.kind_of?(Hash)
2444
+ raise "MiqVimInventory.setSelector: selSpec must be a hash, received #{selSpec.class}" unless selSpec.kind_of?(Hash)
2446
2445
  selSpec.each_key do |k|
2447
- raise "MiqVimBroker.setSelector: selSpec keys must be symbols, received #{k.class}" unless k.kind_of?(Symbol)
2446
+ raise "MiqVimInventory.setSelector: selSpec keys must be symbols, received #{k.class}" unless k.kind_of?(Symbol)
2448
2447
  end
2449
2448
  ov = nil
2450
2449
  selSpec.each_value do |v|
@@ -2458,7 +2457,7 @@ class MiqVimInventory < MiqVimClientBase
2458
2457
  else
2459
2458
  ov = v unless v.kind_of?(String)
2460
2459
  end
2461
- raise "MiqVimBroker.setSelector: selSpec values must be strings or arrays of strings, received #{ov.class}" unless ov.nil?
2460
+ raise "MiqVimInventory.setSelector: selSpec values must be strings or arrays of strings, received #{ov.class}" unless ov.nil?
2462
2461
  end
2463
2462
  @@selectorHash.merge!(selSpec)
2464
2463
  end
@@ -2472,10 +2471,10 @@ class MiqVimInventory < MiqVimClientBase
2472
2471
  elsif selName.kind_of?(Array)
2473
2472
  remKeys = selName
2474
2473
  else
2475
- raise "MiqVimBroker.removeSelector: selName must be a symbol, hash or array, received #{selName.class}"
2474
+ raise "MiqVimInventory.removeSelector: selName must be a symbol, hash or array, received #{selName.class}"
2476
2475
  end
2477
2476
  remKeys.each do |rk|
2478
- raise "MiqVimBroker.removeSelector: keys must be symbols, received #{rk.class}" unless rk.kind_of?(Symbol)
2477
+ raise "MiqVimInventory.removeSelector: keys must be symbols, received #{rk.class}" unless rk.kind_of?(Symbol)
2479
2478
  end
2480
2479
 
2481
2480
  remKeys.each do |rk|
@@ -1,6 +1,9 @@
1
1
  require 'date'
2
+ require 'VMwareWebService/logging'
2
3
 
3
4
  class MiqVimPerfHistory
5
+ include VMwareWebService::Logging
6
+
4
7
  attr_reader :invObj
5
8
 
6
9
  def initialize(invObj)
@@ -95,9 +98,9 @@ class MiqVimPerfHistory
95
98
  end
96
99
 
97
100
  def queryProviderSummary(mor)
98
- $vim_log.info "MiqVimPerfHistory(#{@invObj.server}, #{@invObj.username}).queryProviderSummary: calling queryPerfProviderSummary" if $vim_log
101
+ logger.info "MiqVimPerfHistory(#{@invObj.server}, #{@invObj.username}).queryProviderSummary: calling queryPerfProviderSummary"
99
102
  psum = @invObj.queryPerfProviderSummary(@perfManager, mor)
100
- $vim_log.info "MiqVimPerfHistory(#{@invObj.server}, #{@invObj.username}).queryProviderSummary: returned from queryPerfProviderSummary" if $vim_log
103
+ logger.info "MiqVimPerfHistory(#{@invObj.server}, #{@invObj.username}).queryProviderSummary: returned from queryPerfProviderSummary"
101
104
  (psum)
102
105
  end
103
106
 
@@ -108,9 +111,9 @@ class MiqVimPerfHistory
108
111
  beginTime = ah[:beginTime] || nil
109
112
  endTime = ah[:endTime] || nil
110
113
  end
111
- $vim_log.info "MiqVimPerfHistory(#{@invObj.server}, #{@invObj.username}).availMetricsForEntity: calling queryAvailablePerfMetric" if $vim_log
114
+ logger.info "MiqVimPerfHistory(#{@invObj.server}, #{@invObj.username}).availMetricsForEntity: calling queryAvailablePerfMetric"
112
115
  pmids = @invObj.queryAvailablePerfMetric(@perfManager, mor, beginTime, endTime, intervalId)
113
- $vim_log.info "MiqVimPerfHistory(#{@invObj.server}, #{@invObj.username}).availMetricsForEntity: returned from queryAvailablePerfMetric" if $vim_log
116
+ logger.info "MiqVimPerfHistory(#{@invObj.server}, #{@invObj.username}).availMetricsForEntity: returned from queryAvailablePerfMetric"
114
117
  (pmids)
115
118
  end
116
119
 
@@ -121,9 +124,9 @@ class MiqVimPerfHistory
121
124
  ah[:entity] = entnty
122
125
  pqs = getPerfQuerySpec(ah)
123
126
 
124
- $vim_log.info "MiqVimPerfHistory(#{@invObj.server}, #{@invObj.username}).queryPerf: calling queryPerf" if $vim_log
127
+ logger.info "MiqVimPerfHistory(#{@invObj.server}, #{@invObj.username}).queryPerf: calling queryPerf"
125
128
  umPem = @invObj.queryPerf(@perfManager, pqs)[0]
126
- $vim_log.info "MiqVimPerfHistory(#{@invObj.server}, #{@invObj.username}).queryPerf: returned from queryPerf" if $vim_log
129
+ logger.info "MiqVimPerfHistory(#{@invObj.server}, #{@invObj.username}).queryPerf: returned from queryPerf"
127
130
 
128
131
  #
129
132
  # Construct an array of (timestamp, value) pairs.
@@ -151,9 +154,9 @@ class MiqVimPerfHistory
151
154
  aa.each { |ah| pqsa << getPerfQuerySpec(ah) }
152
155
  end
153
156
 
154
- $vim_log.info "MiqVimPerfHistory(#{@invObj.server}, #{@invObj.username}).queryPerfMulti: calling queryPerf" if $vim_log
157
+ logger.info "MiqVimPerfHistory(#{@invObj.server}, #{@invObj.username}).queryPerfMulti: calling queryPerf"
155
158
  pema = @invObj.queryPerf(@perfManager, querySpec)
156
- $vim_log.info "MiqVimPerfHistory(#{@invObj.server}, #{@invObj.username}).queryPerfMulti: returned from queryPerf" if $vim_log
159
+ logger.info "MiqVimPerfHistory(#{@invObj.server}, #{@invObj.username}).queryPerfMulti: returned from queryPerf"
157
160
 
158
161
  return(nil) unless pema
159
162
 
@@ -165,9 +168,9 @@ class MiqVimPerfHistory
165
168
  ah[:entity] = entnty
166
169
  pqs = getPerfQuerySpec(ah)
167
170
 
168
- $vim_log.info "MiqVimPerfHistory(#{@invObj.server}, #{@invObj.username}).queryPerfComposite: calling queryPerfComposite" if $vim_log
171
+ logger.info "MiqVimPerfHistory(#{@invObj.server}, #{@invObj.username}).queryPerfComposite: calling queryPerfComposite"
169
172
  umPem = @invObj.queryPerfComposite(@perfManager, pqs)
170
- $vim_log.info "MiqVimPerfHistory(#{@invObj.server}, #{@invObj.username}).queryPerfComposite: returned from queryPerfComposite" if $vim_log
173
+ logger.info "MiqVimPerfHistory(#{@invObj.server}, #{@invObj.username}).queryPerfComposite: returned from queryPerfComposite"
171
174
 
172
175
  umPem['childEntity'] = [umPem['childEntity']] if umPem['childEntity'].kind_of? Hash
173
176