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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7e574683780708a47c577b3917ed87bf1557bc5cf74754a316779dbf22078e41
4
- data.tar.gz: adaf9d2ceee9103c3f1f523c09741f851265b3a751b3bc4485f2d94f778c6dcf
3
+ metadata.gz: 6f5cfe645f59b74bbc745d9b8ca87f3f812ef66825ed97d1ae9e9ff90581f78b
4
+ data.tar.gz: 4159afd750db2f67f086ee758e92f30b9af934003471f6d0e7f721e352e7c1b1
5
5
  SHA512:
6
- metadata.gz: 8bbd90473121a7d542350232dca9525e33c836e84274e41574550e4dd2123b317d23345a73ff8cf5bc6e8f98b849358571288aef91a44d5fbc076a979c0ac7ca
7
- data.tar.gz: c423d660ce2d62115449de15b130495794625344b58a1ba7d7d331155b62e4d29738a69c55991931050a0dba29ddbad318b367189edf990113ca5745c983fbe3
6
+ metadata.gz: 6e6d105b56f251292a513a69f077fe65636fe54d46df9d92739c008a1d8dbfb4a793edb546bc55f67a8f7fcb2dd53f23aa90cc8234bb5c717d9a569fece53bc4
7
+ data.tar.gz: fbac5ac0d635a9233fe35195247fdca265e506c4da997f6aa072daad516c160ef9a040b87ab478e6b425b6a0728b7d7674468907abac9df2fb384a748ae81cd4
@@ -1,4 +1,8 @@
1
+ require 'VMwareWebService/logging'
2
+
1
3
  class MiqHostDatastoreSystem
4
+ include VMwareWebService::Logging
5
+
2
6
  attr_reader :invObj
3
7
 
4
8
  def initialize(dssMor, invObj)
@@ -44,7 +48,7 @@ class MiqHostDatastoreSystem
44
48
  localPath = dsh.info.nas.name
45
49
  type = dsh.info.nas.type
46
50
 
47
- $vim_log.info "MiqHostDatastoreSystem.addNasDatastoreByName: remoteHost = #{remoteHost}, remotePath = #{remotePath}, localPath = #{localPath}"
51
+ logger.info "MiqHostDatastoreSystem.addNasDatastoreByName: remoteHost = #{remoteHost}, remotePath = #{remotePath}, localPath = #{localPath}"
48
52
  createNasDatastore(remoteHost, remotePath, localPath, accessMode, type)
49
53
  end
50
54
  end # class MiqHostDatastoreSystem
@@ -20,49 +20,73 @@ class MiqVim < MiqVimInventory
20
20
 
21
21
  attr_reader :updateThread, :monitor_updates
22
22
 
23
- # @param server [String] DNS name or IP address of the vCenter Server
23
+ # @param server [String] DNS name or IP address of the vCenter Server
24
24
  # @param username [String] Username to connect to the vCenter Server
25
25
  # @param password [String] Password to connect to the vCenter Server
26
- # @param cacheScope [Symbol] A pre-defined set of properties to cache (default: nil)
26
+ # @param port [Integer] Port to connect to the vCenter Server (default: 443)
27
+ # @param ssl_options [Hash] SSL connection options, :verify_mode and :ca_file
28
+ # @param cache_scope [Symbol] A pre-defined set of properties to cache (default: nil)
27
29
  # @param monitor_updates [Bool] Should a thread be started to monitor updates (default: false)
28
- # @param preLoad [Bool] Should the cache be built before returning the connection (default: false)
29
- # @param debugUpdates [Bool] Should we print debug info for each update (default: false)
30
- # @param notifyMethod [Method] A optional method to call for each update (default: nil)
31
- # @param maxWait [Integer] How many seconds to wait before breaking out of WaitForUpdates (default: 60)
32
- # @param maxObjects [Integer] How many objects to return from each WaitForUpdates page (default: 250)
33
- def initialize(server, username, password, cacheScope = nil, monitor_updates = false, preLoad = false, debugUpdates = false, notifyMethod = nil, maxWait = 60, maxObjects = 250)
34
- super(server, username, password, cacheScope)
30
+ # @param pre_load [Bool] Should the cache be built before returning the connection (default: false)
31
+ # @param debug_updates [Bool] Should we print debug info for each update (default: false)
32
+ # @param notify_method [Method] A optional method to call for each update (default: nil)
33
+ # @param max_wait [Integer] How many seconds to wait before breaking out of WaitForUpdates (default: 60)
34
+ # @param max_objects [Integer] How many objects to return from each WaitForUpdates page (default: 250)
35
+ def initialize(server:, username:, password:, port: 443, ssl_options: {}, cache_scope: nil, monitor_updates: nil, pre_load: nil, debug_updates: false, notify_method: nil, max_wait: 60, max_objects: 250)
36
+ super(:server => server, :port => port, :ssl_options => ssl_options, :username => username, :password => password, :cache_scope => cache_scope)
37
+
38
+ monitor_updates = self.class.monitor_updates if monitor_updates.nil?
39
+ pre_load = self.class.pre_load if pre_load.nil?
35
40
 
36
41
  @monitor_updates = monitor_updates
37
42
  @updateMonitorReady = false
38
43
  @error = nil
39
- @notifyMethod = notifyMethod
40
- @debugUpdates = debugUpdates
41
- @maxWait = maxWait
42
- @maxObjects = maxObjects
44
+ @notifyMethod = notify_method
45
+ @debugUpdates = debug_updates
46
+ @maxWait = max_wait
47
+ @maxObjects = max_objects
48
+
49
+ start_monitor_updates_thread(pre_load) if @monitor_updates
50
+ end
51
+
52
+ @@monitor_updates = false
53
+ @@pre_load = false
54
+
55
+ def self.monitor_updates
56
+ @@monitor_updates
57
+ end
58
+
59
+ def self.monitor_updates=(val)
60
+ @@monitor_updates = val
61
+ end
62
+
63
+ def self.pre_load
64
+ @@pre_load
65
+ end
43
66
 
44
- start_monitor_updates_thread(preLoad) if @monitor_updates
67
+ def self.pre_load=(val)
68
+ @@pre_load = val
45
69
  end
46
70
 
47
71
  def getVimVm(path)
48
- $vim_log.info "MiqVimMod.getVimVm: called"
72
+ logger.info "MiqVimMod.getVimVm: called"
49
73
  miqVimVm = nil
50
74
  @cacheLock.synchronize(:SH) do
51
75
  raise MiqException::MiqVimResourceNotFound, "Could not find VM: #{path}" unless (vmh = virtualMachines_locked[path])
52
76
  miqVimVm = MiqVimVm.new(self, conditionalCopy(vmh))
53
77
  end
54
- $vim_log.info "MiqVimMod.getVimVm: returning object #{miqVimVm.object_id}"
78
+ logger.info "MiqVimMod.getVimVm: returning object #{miqVimVm.object_id}"
55
79
  (miqVimVm)
56
80
  end # def getVimVm
57
81
 
58
82
  def getVimVmByMor(vmMor)
59
- $vim_log.info "MiqVimMod.getVimVmByMor: called"
83
+ logger.info "MiqVimMod.getVimVmByMor: called"
60
84
  miqVimVm = nil
61
85
  @cacheLock.synchronize(:SH) do
62
86
  raise MiqException::MiqVimResourceNotFound, "Could not find VM: #{vmMor}" unless (vmh = virtualMachinesByMor_locked[vmMor])
63
87
  miqVimVm = MiqVimVm.new(self, conditionalCopy(vmh))
64
88
  end
65
- $vim_log.info "MiqVimMod.getVimVmByMor: returning object #{miqVimVm.object_id}"
89
+ logger.info "MiqVimMod.getVimVmByMor: returning object #{miqVimVm.object_id}"
66
90
  (miqVimVm)
67
91
  end # def getVimVmByMor
68
92
 
@@ -71,36 +95,36 @@ class MiqVim < MiqVimInventory
71
95
  # matches the criteria defined by the filter.
72
96
  #
73
97
  def getVimVmByFilter(filter)
74
- $vim_log.info "MiqVimMod.getVimVmByFilter: called"
98
+ logger.info "MiqVimMod.getVimVmByFilter: called"
75
99
  miqVimVm = nil
76
100
  @cacheLock.synchronize(:SH) do
77
101
  vms = applyFilter(virtualMachinesByMor_locked.values, filter)
78
102
  raise MiqException::MiqVimResourceNotFound, "getVimVmByFilter: Could not find VM matching filter" if vms.empty?
79
103
  miqVimVm = MiqVimVm.new(self, conditionalCopy(vms[0]))
80
104
  end
81
- $vim_log.info "MiqVimMod.getVimVmByFilter: returning object #{miqVimVm.object_id}"
105
+ logger.info "MiqVimMod.getVimVmByFilter: returning object #{miqVimVm.object_id}"
82
106
  (miqVimVm)
83
107
  end # def getVimVmByFilter
84
108
 
85
109
  def getVimHost(name)
86
- $vim_log.info "MiqVimMod.getVimHost: called"
110
+ logger.info "MiqVimMod.getVimHost: called"
87
111
  miqVimHost = nil
88
112
  @cacheLock.synchronize(:SH) do
89
113
  raise MiqException::MiqVimResourceNotFound, "Could not find Host: #{name}" unless (hh = hostSystems_locked[name])
90
114
  miqVimHost = MiqVimHost.new(self, conditionalCopy(hh))
91
115
  end
92
- $vim_log.info "MiqVimMod.getVimHost: returning object #{miqVimHost.object_id}"
116
+ logger.info "MiqVimMod.getVimHost: returning object #{miqVimHost.object_id}"
93
117
  (miqVimHost)
94
118
  end # def getVimHost
95
119
 
96
120
  def getVimHostByMor(hMor)
97
- $vim_log.info "MiqVimMod.getVimHostByMor: called"
121
+ logger.info "MiqVimMod.getVimHostByMor: called"
98
122
  miqVimHost = nil
99
123
  @cacheLock.synchronize(:SH) do
100
124
  raise MiqException::MiqVimResourceNotFound, "Could not find Host: #{hMor}" unless (hh = hostSystemsByMor_locked[hMor])
101
125
  miqVimHost = MiqVimHost.new(self, conditionalCopy(hh))
102
126
  end
103
- $vim_log.info "MiqVimMod.getVimHostByMor: returning object #{miqVimHost.object_id}"
127
+ logger.info "MiqVimMod.getVimHostByMor: returning object #{miqVimHost.object_id}"
104
128
  (miqVimHost)
105
129
  end # def getVimHostByMor
106
130
 
@@ -109,48 +133,48 @@ class MiqVim < MiqVimInventory
109
133
  # matches the criteria defined by the filter.
110
134
  #
111
135
  def getVimHostByFilter(filter)
112
- $vim_log.info "MiqVimMod.getVimHostByFilter: called"
136
+ logger.info "MiqVimMod.getVimHostByFilter: called"
113
137
  miqVimHost = nil
114
138
  @cacheLock.synchronize(:SH) do
115
139
  ha = applyFilter(hostSystemsByMor_locked.values, filter)
116
140
  raise MiqException::MiqVimResourceNotFound, "getVimHostByFilter: Could not find Host matching filter" if ha.empty?
117
141
  miqVimHost = MiqVimHost.new(self, conditionalCopy(ha[0]))
118
142
  end
119
- $vim_log.info "MiqVimMod.getVimHostByFilter: returning object #{miqVimHost.object_id}"
143
+ logger.info "MiqVimMod.getVimHostByFilter: returning object #{miqVimHost.object_id}"
120
144
  (miqVimHost)
121
145
  end # def getVimHostByFilter
122
146
 
123
147
  def getVimFolder(name)
124
- $vim_log.info "MiqVimMod.getVimFolder: called"
148
+ logger.info "MiqVimMod.getVimFolder: called"
125
149
  miqVimFolder = nil
126
150
  @cacheLock.synchronize(:SH) do
127
151
  raise MiqException::MiqVimResourceNotFound, "Could not find Folder: #{name}" unless (fh = folders_locked[name])
128
152
  miqVimFolder = MiqVimFolder.new(self, conditionalCopy(fh))
129
153
  end
130
- $vim_log.info "MiqVimMod.getVimFolder: returning object #{miqVimFolder.object_id}"
154
+ logger.info "MiqVimMod.getVimFolder: returning object #{miqVimFolder.object_id}"
131
155
  (miqVimFolder)
132
156
  end # def getVimFolder
133
157
 
134
158
  def getVimFolderByMor(fMor)
135
- $vim_log.info "MiqVimMod.getVimFolderByMor: called"
159
+ logger.info "MiqVimMod.getVimFolderByMor: called"
136
160
  miqVimFolder = nil
137
161
  @cacheLock.synchronize(:SH) do
138
162
  raise MiqException::MiqVimResourceNotFound, "Could not find Folder: #{fMor}" unless (fh = foldersByMor_locked[fMor])
139
163
  miqVimFolder = MiqVimFolder.new(self, conditionalCopy(fh))
140
164
  end
141
- $vim_log.info "MiqVimMod.getVimFolderByMor: returning object #{miqVimFolder.object_id}"
165
+ logger.info "MiqVimMod.getVimFolderByMor: returning object #{miqVimFolder.object_id}"
142
166
  (miqVimFolder)
143
167
  end # def getVimFolderByMor
144
168
 
145
169
  def getVimFolderByFilter(filter)
146
- $vim_log.info "MiqVimMod.getVimFolderByFilter: called"
170
+ logger.info "MiqVimMod.getVimFolderByFilter: called"
147
171
  miqVimFolder = nil
148
172
  @cacheLock.synchronize(:SH) do
149
173
  folders = applyFilter(foldersByMor_locked.values, filter)
150
174
  raise MiqException::MiqVimResourceNotFound, "getVimFolderByFilter: Could not find folder matching filter" if folders.empty?
151
175
  miqVimFolder = MiqVimFolder.new(self, conditionalCopy(folders[0]))
152
176
  end
153
- $vim_log.info "MiqVimMod.getVimFolderByFilter: returning object #{miqVimFolder.object_id}"
177
+ logger.info "MiqVimMod.getVimFolderByFilter: returning object #{miqVimFolder.object_id}"
154
178
  (miqVimFolder)
155
179
  end # def getVimFolderByFilter
156
180
 
@@ -158,36 +182,36 @@ class MiqVim < MiqVimInventory
158
182
  # Cluster
159
183
  #
160
184
  def getVimCluster(name)
161
- $vim_log.info "MiqVimMod.getVimCluster: called"
185
+ logger.info "MiqVimMod.getVimCluster: called"
162
186
  miqVimCluster = nil
163
187
  @cacheLock.synchronize(:SH) do
164
188
  raise MiqException::MiqVimResourceNotFound, "Could not find Cluster: #{name}" unless (ch = clusterComputeResources_locked[name])
165
189
  miqVimCluster = MiqVimCluster.new(self, conditionalCopy(ch))
166
190
  end
167
- $vim_log.info "MiqVimMod.getVimCluster: returning object #{miqVimCluster.object_id}"
191
+ logger.info "MiqVimMod.getVimCluster: returning object #{miqVimCluster.object_id}"
168
192
  (miqVimCluster)
169
193
  end # def getVimCluster
170
194
 
171
195
  def getVimClusterByMor(cMor)
172
- $vim_log.info "MiqVimMod.getVimClusterByMor: called"
196
+ logger.info "MiqVimMod.getVimClusterByMor: called"
173
197
  miqVimCluster = nil
174
198
  @cacheLock.synchronize(:SH) do
175
199
  raise MiqException::MiqVimResourceNotFound, "Could not find Cluster: #{cMor}" unless (ch = clusterComputeResourcesByMor_locked[cMor])
176
200
  miqVimCluster = MiqVimCluster.new(self, conditionalCopy(ch))
177
201
  end
178
- $vim_log.info "MiqVimMod.getVimClusterByMor: returning object #{miqVimCluster.object_id}"
202
+ logger.info "MiqVimMod.getVimClusterByMor: returning object #{miqVimCluster.object_id}"
179
203
  (miqVimCluster)
180
204
  end # def getVimClusterByMor
181
205
 
182
206
  def getVimClusterByFilter(filter)
183
- $vim_log.info "MiqVimMod.getVimClusterByFilter: called"
207
+ logger.info "MiqVimMod.getVimClusterByFilter: called"
184
208
  miqVimCluster = nil
185
209
  @cacheLock.synchronize(:SH) do
186
210
  clusters = applyFilter(clusterComputeResourcesByMor_locked.values, filter)
187
211
  raise MiqException::MiqVimResourceNotFound, "getVimClusterByFilter: Could not find Cluster matching filter" if clusters.empty?
188
212
  miqVimCluster = MiqVimCluster.new(self, conditionalCopy(clusters[0]))
189
213
  end
190
- $vim_log.info "MiqVimMod.getVimClusterByFilter: returning object #{miqVimCluster.object_id}"
214
+ logger.info "MiqVimMod.getVimClusterByFilter: returning object #{miqVimCluster.object_id}"
191
215
  (miqVimCluster)
192
216
  end # def getVimClusterByFilter
193
217
 
@@ -195,54 +219,54 @@ class MiqVim < MiqVimInventory
195
219
  # DataStore
196
220
  #
197
221
  def getVimDataStore(dsName)
198
- $vim_log.info "MiqVimMod.getVimDataStore: called"
222
+ logger.info "MiqVimMod.getVimDataStore: called"
199
223
  miqVimDs = nil
200
224
  @cacheLock.synchronize(:SH) do
201
225
  raise MiqException::MiqVimResourceNotFound, "Could not find datastore: #{dsName}" unless (dsh = dataStores_locked[dsName])
202
226
  miqVimDs = MiqVimDataStore.new(self, conditionalCopy(dsh))
203
227
  end
204
- $vim_log.info "MiqVimMod.getVimDataStore: returning object #{miqVimDs.object_id}"
228
+ logger.info "MiqVimMod.getVimDataStore: returning object #{miqVimDs.object_id}"
205
229
  (miqVimDs)
206
230
  end
207
231
 
208
232
  def getVimDataStoreByMor(dsMor)
209
- $vim_log.info "MiqVimMod.getVimDataStoreByMor: called"
233
+ logger.info "MiqVimMod.getVimDataStoreByMor: called"
210
234
  miqVimDs = nil
211
235
  @cacheLock.synchronize(:SH) do
212
236
  raise MiqException::MiqVimResourceNotFound, "Could not find datastore: #{dsMor}" unless (dsh = dataStoresByMor_locked[dsMor])
213
237
  miqVimDs = MiqVimDataStore.new(self, conditionalCopy(dsh))
214
238
  end
215
- $vim_log.info "MiqVimMod.getVimDataStoreByMor: returning object #{miqVimDs.object_id}"
239
+ logger.info "MiqVimMod.getVimDataStoreByMor: returning object #{miqVimDs.object_id}"
216
240
  (miqVimDs)
217
241
  end
218
242
 
219
243
  def getVimPerfHistory
220
244
  miqVimPh = MiqVimPerfHistory.new(self)
221
- $vim_log.info "MiqVimMod.getVimPerfHistory: returning object #{miqVimPh.object_id}"
245
+ logger.info "MiqVimMod.getVimPerfHistory: returning object #{miqVimPh.object_id}"
222
246
  (miqVimPh)
223
247
  end
224
248
 
225
249
  def getVimEventHistory(eventFilterSpec = nil, pgSize = 20)
226
250
  miqVimEh = MiqVimEventHistoryCollector.new(self, eventFilterSpec, pgSize)
227
- $vim_log.info "MiqVimMod.getVimEventHistory: returning object #{miqVimEh.object_id}"
251
+ logger.info "MiqVimMod.getVimEventHistory: returning object #{miqVimEh.object_id}"
228
252
  (miqVimEh)
229
253
  end
230
254
 
231
255
  def getMiqCustomFieldsManager
232
256
  miqVimCfm = MiqCustomFieldsManager.new(self)
233
- $vim_log.info "MiqVimMod.getMiqCustomFieldsManager: returning object #{miqVimCfm.object_id}"
257
+ logger.info "MiqVimMod.getMiqCustomFieldsManager: returning object #{miqVimCfm.object_id}"
234
258
  (miqVimCfm)
235
259
  end
236
260
 
237
261
  def getVimAlarmManager
238
262
  miqVimAm = MiqVimAlarmManager.new(self)
239
- $vim_log.info "MiqVimMod.getVimAlarmManager: returning object #{miqVimAm.object_id}"
263
+ logger.info "MiqVimMod.getVimAlarmManager: returning object #{miqVimAm.object_id}"
240
264
  (miqVimAm)
241
265
  end
242
266
 
243
267
  def getVimCustomizationSpecManager
244
268
  miqVimCsm = MiqVimCustomizationSpecManager.new(self)
245
- $vim_log.info "MiqVimMod.getVimCustomizationSpecManager: returning object #{miqVimCsm.object_id}"
269
+ logger.info "MiqVimMod.getVimCustomizationSpecManager: returning object #{miqVimCsm.object_id}"
246
270
  (miqVimCsm)
247
271
  end
248
272
 
@@ -257,28 +281,28 @@ class MiqVim < MiqVimInventory
257
281
  def start_monitor_updates_thread(preLoad)
258
282
  checkForOrphanedMonitors
259
283
  log_prefix = "MiqVim.initialize (#{@connId})"
260
- $vim_log.info "#{log_prefix}: starting update monitor thread" if $vim_log
284
+ logger.info "#{log_prefix}: starting update monitor thread"
261
285
  @updateThread = Thread.new { monitor(preLoad) }
262
286
  @updateThread[:vim_connection_id] = connId
263
- $vim_log.info "#{log_prefix}: waiting for update monitor to become ready" if $vim_log
287
+ logger.info "#{log_prefix}: waiting for update monitor to become ready"
264
288
  until @updateMonitorReady
265
289
  raise @error unless @error.nil?
266
290
  break unless @updateThread.alive?
267
291
  Thread.pass
268
292
  end
269
- $vim_log.info "#{log_prefix}: update monitor ready" if $vim_log
293
+ logger.info "#{log_prefix}: update monitor ready"
270
294
  end
271
295
 
272
296
  def checkForOrphanedMonitors
273
297
  log_prefix = "MiqVim.checkForOrphanedMonitors (#{@connId})"
274
- $vim_log.debug "#{log_prefix}: called..."
298
+ logger.debug "#{log_prefix}: called..."
275
299
  Thread.list.each do |thr|
276
300
  next unless thr[:vim_connection_id] == connId
277
- $vim_log.error "#{log_prefix}: Terminating orphaned update monitor <#{thr.object_id}>"
301
+ logger.error "#{log_prefix}: Terminating orphaned update monitor <#{thr.object_id}>"
278
302
  thr.raise "Orphaned update monitor (#{@connId}) <#{thr.object_id}>, terminated by <#{Thread.current.object_id}>"
279
303
  thr.wakeup
280
304
  end
281
- $vim_log.debug "#{log_prefix}: done."
305
+ logger.debug "#{log_prefix}: done."
282
306
  end
283
307
 
284
308
  def monitor(preLoad)
@@ -286,7 +310,7 @@ class MiqVim < MiqVimInventory
286
310
  begin
287
311
  monitorUpdates(preLoad)
288
312
  rescue Exception => err
289
- $vim_log.info "#{log_prefix}: returned from monitorUpdates via #{err.class} exception" if $vim_log
313
+ logger.info "#{log_prefix}: returned from monitorUpdates via #{err.class} exception"
290
314
  @error = err
291
315
  end
292
316
  end
@@ -296,9 +320,9 @@ class MiqVim < MiqVimInventory
296
320
  stopUpdateMonitor
297
321
  begin
298
322
  if @updateThread != Thread.current && @updateThread.alive?
299
- $vim_log.info "#{log_prefix}: waiting for Update Monitor Thread...Starting" if $vim_log
323
+ logger.info "#{log_prefix}: waiting for Update Monitor Thread...Starting"
300
324
  @updateThread.join
301
- $vim_log.info "#{log_prefix}: waiting for Update Monitor Thread...Complete" if $vim_log
325
+ logger.info "#{log_prefix}: waiting for Update Monitor Thread...Complete"
302
326
  end
303
327
  rescue
304
328
  end
@@ -8,10 +8,11 @@ require 'VMwareWebService/VimService'
8
8
  class MiqVimClientBase < VimService
9
9
  @@receiveTimeout = 120
10
10
 
11
- attr_reader :server, :username, :password, :connId
11
+ attr_reader :server, :port, :username, :password, :connId
12
12
 
13
- def initialize(server, username, password)
13
+ def initialize(server:, username:, password:, port: 443, ssl_options: {})
14
14
  @server = server
15
+ @port = port
15
16
  @username = username
16
17
  @password = password
17
18
  @connId = "#{@server}_#{@username}"
@@ -19,13 +20,13 @@ class MiqVimClientBase < VimService
19
20
  @receiveTimeout = @@receiveTimeout
20
21
 
21
22
  on_http_client_init do |http_client, _headers|
22
- http_client.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE
23
- http_client.ssl_config.verify_callback = method(:verify_callback).to_proc
24
- http_client.receive_timeout = @receiveTimeout
23
+ http_client.receive_timeout = @receiveTimeout
24
+ http_client.ssl_config.verify_mode = ssl_options[:verify_ssl] || OpenSSL::SSL::VERIFY_NONE
25
+ http_client.ssl_config.cert_store.add_cert(OpenSSL::X509::Certificate.new(ssl_options[:ca_file])) if ssl_options[:ca_file]
25
26
  end
26
27
 
27
- on_log_header { |msg| $vim_log.info msg }
28
- on_log_body { |msg| $vim_log.debug msg } if $miq_wiredump
28
+ on_log_header { |msg| logger.info msg }
29
+ on_log_body { |msg| logger.debug msg } if $miq_wiredump
29
30
 
30
31
  super(:uri => sdk_uri, :version => 1)
31
32
 
@@ -34,7 +35,7 @@ class MiqVimClientBase < VimService
34
35
  end
35
36
 
36
37
  def sdk_uri
37
- URI::HTTPS.build(:host => server, :path => "/sdk")
38
+ URI::HTTPS.build(:host => server, :port => port, :path => "/sdk")
38
39
  end
39
40
 
40
41
  def self.receiveTimeout=(val)
@@ -59,7 +60,7 @@ class MiqVimClientBase < VimService
59
60
  end
60
61
 
61
62
  def connect
62
- $vim_log.debug "#{self.class.name}.connect(#{@connId}): #{$PROGRAM_NAME} #{ARGV.join(' ')}" if $vim_log.debug?
63
+ logger.debug { "#{self.class.name}.connect(#{@connId}): #{$PROGRAM_NAME} #{ARGV.join(' ')}" }
63
64
  @connLock.synchronize(:EX) do
64
65
  return if @connected
65
66
  login(@sic.sessionManager, @username, @password)
@@ -68,7 +69,7 @@ class MiqVimClientBase < VimService
68
69
  end
69
70
 
70
71
  def disconnect
71
- $vim_log.debug "#{self.class.name}.disconnect(#{@connId}): #{$PROGRAM_NAME} #{ARGV.join(' ')}" if $vim_log.debug?
72
+ logger.debug { "#{self.class.name}.disconnect(#{@connId}): #{$PROGRAM_NAME} #{ARGV.join(' ')}" }
72
73
  @connLock.synchronize(:EX) do
73
74
  return unless @connected
74
75
  logout(@sic.sessionManager)
@@ -1,4 +1,8 @@
1
+ require 'VMwareWebService/logging'
2
+
1
3
  class MiqVimCluster
4
+ include VMwareWebService::Logging
5
+
2
6
  attr_reader :name, :invObj
3
7
 
4
8
  def initialize(invObj, ch)
@@ -44,9 +48,9 @@ class MiqVimCluster
44
48
  cs.vmFolder = ah[:vmFolder] unless ah[:vmFolder].nil?
45
49
  end
46
50
 
47
- $vim_log.info "MiqVimCluster(#{@invObj.server}, #{@invObj.username}).addHost: calling addHost_Task" if $vim_log
51
+ logger.info "MiqVimCluster(#{@invObj.server}, #{@invObj.username}).addHost: calling addHost_Task"
48
52
  taskMor = @invObj.addHost_Task(@cMor, cspec, ah[:asConnected].to_s, ah[:resourcePool], ah[:license])
49
- $vim_log.info "MiqVimCluster(#{@invObj.server}, #{@invObj.username}).addHost: returned from addHost_Task" if $vim_log
53
+ logger.info "MiqVimCluster(#{@invObj.server}, #{@invObj.username}).addHost: returned from addHost_Task"
50
54
  return taskMor unless ah[:wait]
51
55
  waitForTask(taskMor)
52
56
  end # def addHost
@@ -1,7 +1,10 @@
1
1
  require 'sync'
2
2
  require 'util/miq-extensions' # Required patch to open-uri for get_file_content
3
+ require 'VMwareWebService/logging'
3
4
 
4
5
  class MiqVimDataStore
6
+ include VMwareWebService::Logging
7
+
5
8
  attr_reader :accessible, :multipleHostAccess, :name, :dsType, :url, :freeBytes, :capacityBytes, :uncommitted, :invObj
6
9
 
7
10
  def initialize(invObj, dsh)
@@ -127,13 +130,13 @@ class MiqVimDataStore
127
130
 
128
131
  taskMor = nil
129
132
  if recurse
130
- $vim_log.info "MiqVimDataStore(#{@invObj.server}, #{@invObj.username}).dsSearch: calling searchDatastoreSubFolders_Task" if $vim_log
133
+ logger.info "MiqVimDataStore(#{@invObj.server}, #{@invObj.username}).dsSearch: calling searchDatastoreSubFolders_Task"
131
134
  taskMor = @invObj.searchDatastoreSubFolders_Task(browserMor, dsPath, searchSpec)
132
- $vim_log.info "MiqVimDataStore(#{@invObj.server}, #{@invObj.username}).dsSearch: returned from searchDatastoreSubFolders_Task" if $vim_log
135
+ logger.info "MiqVimDataStore(#{@invObj.server}, #{@invObj.username}).dsSearch: returned from searchDatastoreSubFolders_Task"
133
136
  else
134
- $vim_log.info "MiqVimDataStore(#{@invObj.server}, #{@invObj.username}).dsSearch: calling searchDatastore_Task" if $vim_log
137
+ logger.info "MiqVimDataStore(#{@invObj.server}, #{@invObj.username}).dsSearch: calling searchDatastore_Task"
135
138
  taskMor = @invObj.searchDatastore_Task(browserMor, dsPath, searchSpec)
136
- $vim_log.info "MiqVimDataStore(#{@invObj.server}, #{@invObj.username}).dsSearch: returned from searchDatastore_Task" if $vim_log
139
+ logger.info "MiqVimDataStore(#{@invObj.server}, #{@invObj.username}).dsSearch: returned from searchDatastore_Task"
137
140
  end
138
141
 
139
142
  retObj = waitForTask(taskMor)
@@ -200,9 +203,9 @@ class MiqVimDataStore
200
203
  hdbs.sortFoldersFirst = "true"
201
204
  end
202
205
 
203
- $vim_log.info "MiqVimDataStore(#{@invObj.server}, #{@invObj.username}).dsHash_locked: calling searchDatastoreSubFolders_Task" if $vim_log
206
+ logger.info "MiqVimDataStore(#{@invObj.server}, #{@invObj.username}).dsHash_locked: calling searchDatastoreSubFolders_Task"
204
207
  taskMor = @invObj.searchDatastoreSubFolders_Task(browser_locked, "[#{@name}]", searchSpec)
205
- $vim_log.info "MiqVimDataStore(#{@invObj.server}, #{@invObj.username}).dsHash_locked: returned from searchDatastoreSubFolders_Task" if $vim_log
208
+ logger.info "MiqVimDataStore(#{@invObj.server}, #{@invObj.username}).dsHash_locked: returned from searchDatastoreSubFolders_Task"
206
209
 
207
210
  retObj = waitForTask(taskMor)
208
211
  retObj = [retObj] unless retObj.kind_of?(Array)
@@ -60,7 +60,7 @@ module MiqVimDump
60
60
 
61
61
  def indentedPrint(s, i)
62
62
  if @dumpToLog
63
- $vim_log.debug @globalIndent + (" " * i) + s.to_s
63
+ logger.debug @globalIndent + (" " * i) + s.to_s
64
64
  else
65
65
  print @globalIndent + " " * i
66
66
  puts s
@@ -1,4 +1,8 @@
1
+ require 'VMwareWebService/logging'
2
+
1
3
  class MiqVimEventHistoryCollector
4
+ include VMwareWebService::Logging
5
+
2
6
  attr_reader :invObj
3
7
 
4
8
  def initialize(invObj, eventFilterSpec = nil, pgSize = 20)
@@ -14,7 +18,7 @@ class MiqVimEventHistoryCollector
14
18
 
15
19
  def release
16
20
  return unless @eventHistoryCollector
17
- $vim_log.info "MiqVimEventHistoryCollector.release: destroying #{@eventHistoryCollector}"
21
+ logger.info "MiqVimEventHistoryCollector.release: destroying #{@eventHistoryCollector}"
18
22
  @invObj.destroyCollector(@eventHistoryCollector)
19
23
  @eventHistoryCollector = nil
20
24
  end
@@ -1,15 +1,17 @@
1
- require 'enumerator'
1
+ require 'VMwareWebService/logging'
2
2
  require 'VMwareWebService/MiqVimInventory'
3
3
 
4
4
  class MiqVimEventMonitor < MiqVimInventory
5
- def initialize(server, username, password, eventFilterSpec = nil, pgSize = 100, maxWait = 60)
6
- super(server, username, password, :cache_scope_event_monitor)
5
+ include VMwareWebService::Logging
7
6
 
8
- @eventFilterSpec = eventFilterSpec || VimHash.new("EventFilterSpec")
9
- @pgSize = pgSize
10
- @maxWait = maxWait
11
- @_monitorEvents = true
12
- @emPropCol = nil
7
+ def initialize(server:, username:, password:, port: 443, ssl_options: {}, event_filter_spec: nil, page_size: 100, max_wait: 60)
8
+ super(:server => server, :port => port, :ssl_options => ssl_options, :username => username, :password => password, :cache_scope => :cache_scope_event_monitor)
9
+
10
+ @eventFilterSpec = event_filter_spec || VimHash.new("EventFilterSpec")
11
+ @pgSize = page_size
12
+ @maxWait = max_wait
13
+ @_monitorEvents = true
14
+ @emPropCol = nil
13
15
 
14
16
  hostSystemsByMor
15
17
  # datacentersByMor
@@ -73,25 +75,25 @@ class MiqVimEventMonitor < MiqVimInventory
73
75
  end
74
76
  rescue HTTPClient::ReceiveTimeoutError => terr
75
77
  retry if isAlive?
76
- $vim_log.debug "MiqVimEventMonitor.monitorEvents: connection lost"
78
+ logger.debug "MiqVimEventMonitor.monitorEvents: connection lost"
77
79
  raise
78
80
  end
79
81
  rescue SignalException => err
80
82
  ensure
81
- $vim_log.info "MiqVimEventMonitor: calling destroyPropertyFilter"
83
+ logger.info "MiqVimEventMonitor: calling destroyPropertyFilter"
82
84
  destroyPropertyFilter(filterSpecRef) if filterSpecRef
83
- $vim_log.info "MiqVimEventMonitor: returned from destroyPropertyFilter"
85
+ logger.info "MiqVimEventMonitor: returned from destroyPropertyFilter"
84
86
  disconnect
85
87
  end
86
88
  end # def monitorEvents
87
89
 
88
90
  def stop
89
- $vim_log.info "MiqVimEventMonitor stopping..."
91
+ logger.info "MiqVimEventMonitor stopping..."
90
92
  @_monitorEvents = false
91
93
  if @emPropCol
92
- $vim_log.info "MiqVimEventMonitor: calling cancelWaitForUpdates"
94
+ logger.info "MiqVimEventMonitor: calling cancelWaitForUpdates"
93
95
  cancelWaitForUpdates(@emPropCol)
94
- $vim_log.info "MiqVimEventMonitor: returned from cancelWaitForUpdates"
96
+ logger.info "MiqVimEventMonitor: returned from cancelWaitForUpdates"
95
97
  end
96
98
  end
97
99
 
@@ -100,14 +102,14 @@ class MiqVimEventMonitor < MiqVimInventory
100
102
 
101
103
  def fixupEvent(event)
102
104
  unless event.kind_of?(Hash)
103
- $vim_log.error "MiqVimEventMonitor.fixupEvent: Expecting Hash, got #{event.class}"
105
+ logger.error "MiqVimEventMonitor.fixupEvent: Expecting Hash, got #{event.class}"
104
106
  if event.kind_of?(Array)
105
107
  event.each_index do |i|
106
- $vim_log.error "MiqVimEventMonitor.fixupEvent: event[#{i}] is a #{event[i].class}"
107
- $vim_log.error "\tMiqVimEventMonitor.fixupEvent: event[#{i}] = #{event[i].inspect}"
108
+ logger.error "MiqVimEventMonitor.fixupEvent: event[#{i}] is a #{event[i].class}"
109
+ logger.error "\tMiqVimEventMonitor.fixupEvent: event[#{i}] = #{event[i].inspect}"
108
110
  end
109
111
  else
110
- $vim_log.error "\tMiqVimEventMonitor.fixupEvent: event = #{event.inspect}"
112
+ logger.error "\tMiqVimEventMonitor.fixupEvent: event = #{event.inspect}"
111
113
  end
112
114
  raise "MiqVimEventMonitor.fixupEvent: Expecting Hash, got #{event.class}"
113
115
  end
@@ -164,8 +166,8 @@ class MiqVimEventMonitor < MiqVimInventory
164
166
  begin
165
167
  cancelTask(String.new(e['info']['task'].to_str))
166
168
  rescue => err
167
- $vim_log.error err.to_s
168
- $vim_log.error err.backtrace.join("\n")
169
+ logger.error err.to_s
170
+ logger.error err.backtrace.join("\n")
169
171
  end
170
172
  end
171
173
  end # module MiqVimEventMonitor