vmware_web_service 2.1.1 → 3.0.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 +58 -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 +10 -6
  19. data/lib/VMwareWebService/VixDiskLib/VixDiskLibServer.rb +15 -13
  20. data/lib/VMwareWebService/VixDiskLib/vdl_wrapper.rb +26 -25
  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 +6 -25
  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: dec8c1bf5bd2dd9fc8d00e057e146cf7dea54c2cbcfe5c500f71389e333d6de4
4
- data.tar.gz: 331dbc8f7400e12b2a3a5c1c3dd7b474db1880be659a9e182112b23c8278b817
3
+ metadata.gz: 1288852b072deb0fafe3ad1283dc4f82937da979aafdb8408a4f2938e93525bb
4
+ data.tar.gz: 980e17603b753629a0dfbffa4c7c9141b347da64492e39400bb4feca1c129bda
5
5
  SHA512:
6
- metadata.gz: 73e001def303f702ad26815843ec3b0fc25cbdfa26fb4c796cdec1e333e4a6fb8c0357cf86ce8ea31e076401b9e1729d41555d1668e296d46a4aea7bd59bdf1b
7
- data.tar.gz: 5e91e171b1d568f6b1920a29ef69161eeebc9accd1261e3e93b7cab58a126f890266013552f23e98c24c1088646512dd97e91b7b08ee52ff4e959f011e33b192
6
+ metadata.gz: 4fa9b4c773f5868376fd9d1d816146c614d4ecd6f05bcdc17db918df45cdb39a07cea91cc329db3d7601dece163d63b63bb14820bd8ad1fa1415849df05a0a5d
7
+ data.tar.gz: 15156757e0bdfecd73a1199eb0d7fbc6f514c61f7c530a2528a21608ae34fce966badbe9e2b6141e4ff7d16a60c0dc86e0f7e27f9fbc878e697cb3094ffe047f
@@ -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
@@ -23,28 +23,30 @@ class MiqVim < MiqVimInventory
23
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 = nil, preLoad = nil, 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)
35
37
 
36
38
  monitor_updates = self.class.monitor_updates if monitor_updates.nil?
37
- preLoad = self.class.pre_load if preLoad.nil?
39
+ pre_load = self.class.pre_load if pre_load.nil?
38
40
 
39
41
  @monitor_updates = monitor_updates
40
42
  @updateMonitorReady = false
41
43
  @error = nil
42
- @notifyMethod = notifyMethod
43
- @debugUpdates = debugUpdates
44
- @maxWait = maxWait
45
- @maxObjects = maxObjects
44
+ @notifyMethod = notify_method
45
+ @debugUpdates = debug_updates
46
+ @maxWait = max_wait
47
+ @maxObjects = max_objects
46
48
 
47
- start_monitor_updates_thread(preLoad) if @monitor_updates
49
+ start_monitor_updates_thread(pre_load) if @monitor_updates
48
50
  end
49
51
 
50
52
  @@monitor_updates = false
@@ -67,24 +69,24 @@ class MiqVim < MiqVimInventory
67
69
  end
68
70
 
69
71
  def getVimVm(path)
70
- $vim_log.info "MiqVimMod.getVimVm: called"
72
+ logger.info "MiqVimMod.getVimVm: called"
71
73
  miqVimVm = nil
72
74
  @cacheLock.synchronize(:SH) do
73
75
  raise MiqException::MiqVimResourceNotFound, "Could not find VM: #{path}" unless (vmh = virtualMachines_locked[path])
74
76
  miqVimVm = MiqVimVm.new(self, conditionalCopy(vmh))
75
77
  end
76
- $vim_log.info "MiqVimMod.getVimVm: returning object #{miqVimVm.object_id}"
78
+ logger.info "MiqVimMod.getVimVm: returning object #{miqVimVm.object_id}"
77
79
  (miqVimVm)
78
80
  end # def getVimVm
79
81
 
80
82
  def getVimVmByMor(vmMor)
81
- $vim_log.info "MiqVimMod.getVimVmByMor: called"
83
+ logger.info "MiqVimMod.getVimVmByMor: called"
82
84
  miqVimVm = nil
83
85
  @cacheLock.synchronize(:SH) do
84
86
  raise MiqException::MiqVimResourceNotFound, "Could not find VM: #{vmMor}" unless (vmh = virtualMachinesByMor_locked[vmMor])
85
87
  miqVimVm = MiqVimVm.new(self, conditionalCopy(vmh))
86
88
  end
87
- $vim_log.info "MiqVimMod.getVimVmByMor: returning object #{miqVimVm.object_id}"
89
+ logger.info "MiqVimMod.getVimVmByMor: returning object #{miqVimVm.object_id}"
88
90
  (miqVimVm)
89
91
  end # def getVimVmByMor
90
92
 
@@ -93,36 +95,36 @@ class MiqVim < MiqVimInventory
93
95
  # matches the criteria defined by the filter.
94
96
  #
95
97
  def getVimVmByFilter(filter)
96
- $vim_log.info "MiqVimMod.getVimVmByFilter: called"
98
+ logger.info "MiqVimMod.getVimVmByFilter: called"
97
99
  miqVimVm = nil
98
100
  @cacheLock.synchronize(:SH) do
99
101
  vms = applyFilter(virtualMachinesByMor_locked.values, filter)
100
102
  raise MiqException::MiqVimResourceNotFound, "getVimVmByFilter: Could not find VM matching filter" if vms.empty?
101
103
  miqVimVm = MiqVimVm.new(self, conditionalCopy(vms[0]))
102
104
  end
103
- $vim_log.info "MiqVimMod.getVimVmByFilter: returning object #{miqVimVm.object_id}"
105
+ logger.info "MiqVimMod.getVimVmByFilter: returning object #{miqVimVm.object_id}"
104
106
  (miqVimVm)
105
107
  end # def getVimVmByFilter
106
108
 
107
109
  def getVimHost(name)
108
- $vim_log.info "MiqVimMod.getVimHost: called"
110
+ logger.info "MiqVimMod.getVimHost: called"
109
111
  miqVimHost = nil
110
112
  @cacheLock.synchronize(:SH) do
111
113
  raise MiqException::MiqVimResourceNotFound, "Could not find Host: #{name}" unless (hh = hostSystems_locked[name])
112
114
  miqVimHost = MiqVimHost.new(self, conditionalCopy(hh))
113
115
  end
114
- $vim_log.info "MiqVimMod.getVimHost: returning object #{miqVimHost.object_id}"
116
+ logger.info "MiqVimMod.getVimHost: returning object #{miqVimHost.object_id}"
115
117
  (miqVimHost)
116
118
  end # def getVimHost
117
119
 
118
120
  def getVimHostByMor(hMor)
119
- $vim_log.info "MiqVimMod.getVimHostByMor: called"
121
+ logger.info "MiqVimMod.getVimHostByMor: called"
120
122
  miqVimHost = nil
121
123
  @cacheLock.synchronize(:SH) do
122
124
  raise MiqException::MiqVimResourceNotFound, "Could not find Host: #{hMor}" unless (hh = hostSystemsByMor_locked[hMor])
123
125
  miqVimHost = MiqVimHost.new(self, conditionalCopy(hh))
124
126
  end
125
- $vim_log.info "MiqVimMod.getVimHostByMor: returning object #{miqVimHost.object_id}"
127
+ logger.info "MiqVimMod.getVimHostByMor: returning object #{miqVimHost.object_id}"
126
128
  (miqVimHost)
127
129
  end # def getVimHostByMor
128
130
 
@@ -131,48 +133,48 @@ class MiqVim < MiqVimInventory
131
133
  # matches the criteria defined by the filter.
132
134
  #
133
135
  def getVimHostByFilter(filter)
134
- $vim_log.info "MiqVimMod.getVimHostByFilter: called"
136
+ logger.info "MiqVimMod.getVimHostByFilter: called"
135
137
  miqVimHost = nil
136
138
  @cacheLock.synchronize(:SH) do
137
139
  ha = applyFilter(hostSystemsByMor_locked.values, filter)
138
140
  raise MiqException::MiqVimResourceNotFound, "getVimHostByFilter: Could not find Host matching filter" if ha.empty?
139
141
  miqVimHost = MiqVimHost.new(self, conditionalCopy(ha[0]))
140
142
  end
141
- $vim_log.info "MiqVimMod.getVimHostByFilter: returning object #{miqVimHost.object_id}"
143
+ logger.info "MiqVimMod.getVimHostByFilter: returning object #{miqVimHost.object_id}"
142
144
  (miqVimHost)
143
145
  end # def getVimHostByFilter
144
146
 
145
147
  def getVimFolder(name)
146
- $vim_log.info "MiqVimMod.getVimFolder: called"
148
+ logger.info "MiqVimMod.getVimFolder: called"
147
149
  miqVimFolder = nil
148
150
  @cacheLock.synchronize(:SH) do
149
151
  raise MiqException::MiqVimResourceNotFound, "Could not find Folder: #{name}" unless (fh = folders_locked[name])
150
152
  miqVimFolder = MiqVimFolder.new(self, conditionalCopy(fh))
151
153
  end
152
- $vim_log.info "MiqVimMod.getVimFolder: returning object #{miqVimFolder.object_id}"
154
+ logger.info "MiqVimMod.getVimFolder: returning object #{miqVimFolder.object_id}"
153
155
  (miqVimFolder)
154
156
  end # def getVimFolder
155
157
 
156
158
  def getVimFolderByMor(fMor)
157
- $vim_log.info "MiqVimMod.getVimFolderByMor: called"
159
+ logger.info "MiqVimMod.getVimFolderByMor: called"
158
160
  miqVimFolder = nil
159
161
  @cacheLock.synchronize(:SH) do
160
162
  raise MiqException::MiqVimResourceNotFound, "Could not find Folder: #{fMor}" unless (fh = foldersByMor_locked[fMor])
161
163
  miqVimFolder = MiqVimFolder.new(self, conditionalCopy(fh))
162
164
  end
163
- $vim_log.info "MiqVimMod.getVimFolderByMor: returning object #{miqVimFolder.object_id}"
165
+ logger.info "MiqVimMod.getVimFolderByMor: returning object #{miqVimFolder.object_id}"
164
166
  (miqVimFolder)
165
167
  end # def getVimFolderByMor
166
168
 
167
169
  def getVimFolderByFilter(filter)
168
- $vim_log.info "MiqVimMod.getVimFolderByFilter: called"
170
+ logger.info "MiqVimMod.getVimFolderByFilter: called"
169
171
  miqVimFolder = nil
170
172
  @cacheLock.synchronize(:SH) do
171
173
  folders = applyFilter(foldersByMor_locked.values, filter)
172
174
  raise MiqException::MiqVimResourceNotFound, "getVimFolderByFilter: Could not find folder matching filter" if folders.empty?
173
175
  miqVimFolder = MiqVimFolder.new(self, conditionalCopy(folders[0]))
174
176
  end
175
- $vim_log.info "MiqVimMod.getVimFolderByFilter: returning object #{miqVimFolder.object_id}"
177
+ logger.info "MiqVimMod.getVimFolderByFilter: returning object #{miqVimFolder.object_id}"
176
178
  (miqVimFolder)
177
179
  end # def getVimFolderByFilter
178
180
 
@@ -180,36 +182,36 @@ class MiqVim < MiqVimInventory
180
182
  # Cluster
181
183
  #
182
184
  def getVimCluster(name)
183
- $vim_log.info "MiqVimMod.getVimCluster: called"
185
+ logger.info "MiqVimMod.getVimCluster: called"
184
186
  miqVimCluster = nil
185
187
  @cacheLock.synchronize(:SH) do
186
188
  raise MiqException::MiqVimResourceNotFound, "Could not find Cluster: #{name}" unless (ch = clusterComputeResources_locked[name])
187
189
  miqVimCluster = MiqVimCluster.new(self, conditionalCopy(ch))
188
190
  end
189
- $vim_log.info "MiqVimMod.getVimCluster: returning object #{miqVimCluster.object_id}"
191
+ logger.info "MiqVimMod.getVimCluster: returning object #{miqVimCluster.object_id}"
190
192
  (miqVimCluster)
191
193
  end # def getVimCluster
192
194
 
193
195
  def getVimClusterByMor(cMor)
194
- $vim_log.info "MiqVimMod.getVimClusterByMor: called"
196
+ logger.info "MiqVimMod.getVimClusterByMor: called"
195
197
  miqVimCluster = nil
196
198
  @cacheLock.synchronize(:SH) do
197
199
  raise MiqException::MiqVimResourceNotFound, "Could not find Cluster: #{cMor}" unless (ch = clusterComputeResourcesByMor_locked[cMor])
198
200
  miqVimCluster = MiqVimCluster.new(self, conditionalCopy(ch))
199
201
  end
200
- $vim_log.info "MiqVimMod.getVimClusterByMor: returning object #{miqVimCluster.object_id}"
202
+ logger.info "MiqVimMod.getVimClusterByMor: returning object #{miqVimCluster.object_id}"
201
203
  (miqVimCluster)
202
204
  end # def getVimClusterByMor
203
205
 
204
206
  def getVimClusterByFilter(filter)
205
- $vim_log.info "MiqVimMod.getVimClusterByFilter: called"
207
+ logger.info "MiqVimMod.getVimClusterByFilter: called"
206
208
  miqVimCluster = nil
207
209
  @cacheLock.synchronize(:SH) do
208
210
  clusters = applyFilter(clusterComputeResourcesByMor_locked.values, filter)
209
211
  raise MiqException::MiqVimResourceNotFound, "getVimClusterByFilter: Could not find Cluster matching filter" if clusters.empty?
210
212
  miqVimCluster = MiqVimCluster.new(self, conditionalCopy(clusters[0]))
211
213
  end
212
- $vim_log.info "MiqVimMod.getVimClusterByFilter: returning object #{miqVimCluster.object_id}"
214
+ logger.info "MiqVimMod.getVimClusterByFilter: returning object #{miqVimCluster.object_id}"
213
215
  (miqVimCluster)
214
216
  end # def getVimClusterByFilter
215
217
 
@@ -217,54 +219,54 @@ class MiqVim < MiqVimInventory
217
219
  # DataStore
218
220
  #
219
221
  def getVimDataStore(dsName)
220
- $vim_log.info "MiqVimMod.getVimDataStore: called"
222
+ logger.info "MiqVimMod.getVimDataStore: called"
221
223
  miqVimDs = nil
222
224
  @cacheLock.synchronize(:SH) do
223
225
  raise MiqException::MiqVimResourceNotFound, "Could not find datastore: #{dsName}" unless (dsh = dataStores_locked[dsName])
224
226
  miqVimDs = MiqVimDataStore.new(self, conditionalCopy(dsh))
225
227
  end
226
- $vim_log.info "MiqVimMod.getVimDataStore: returning object #{miqVimDs.object_id}"
228
+ logger.info "MiqVimMod.getVimDataStore: returning object #{miqVimDs.object_id}"
227
229
  (miqVimDs)
228
230
  end
229
231
 
230
232
  def getVimDataStoreByMor(dsMor)
231
- $vim_log.info "MiqVimMod.getVimDataStoreByMor: called"
233
+ logger.info "MiqVimMod.getVimDataStoreByMor: called"
232
234
  miqVimDs = nil
233
235
  @cacheLock.synchronize(:SH) do
234
236
  raise MiqException::MiqVimResourceNotFound, "Could not find datastore: #{dsMor}" unless (dsh = dataStoresByMor_locked[dsMor])
235
237
  miqVimDs = MiqVimDataStore.new(self, conditionalCopy(dsh))
236
238
  end
237
- $vim_log.info "MiqVimMod.getVimDataStoreByMor: returning object #{miqVimDs.object_id}"
239
+ logger.info "MiqVimMod.getVimDataStoreByMor: returning object #{miqVimDs.object_id}"
238
240
  (miqVimDs)
239
241
  end
240
242
 
241
243
  def getVimPerfHistory
242
244
  miqVimPh = MiqVimPerfHistory.new(self)
243
- $vim_log.info "MiqVimMod.getVimPerfHistory: returning object #{miqVimPh.object_id}"
245
+ logger.info "MiqVimMod.getVimPerfHistory: returning object #{miqVimPh.object_id}"
244
246
  (miqVimPh)
245
247
  end
246
248
 
247
249
  def getVimEventHistory(eventFilterSpec = nil, pgSize = 20)
248
250
  miqVimEh = MiqVimEventHistoryCollector.new(self, eventFilterSpec, pgSize)
249
- $vim_log.info "MiqVimMod.getVimEventHistory: returning object #{miqVimEh.object_id}"
251
+ logger.info "MiqVimMod.getVimEventHistory: returning object #{miqVimEh.object_id}"
250
252
  (miqVimEh)
251
253
  end
252
254
 
253
255
  def getMiqCustomFieldsManager
254
256
  miqVimCfm = MiqCustomFieldsManager.new(self)
255
- $vim_log.info "MiqVimMod.getMiqCustomFieldsManager: returning object #{miqVimCfm.object_id}"
257
+ logger.info "MiqVimMod.getMiqCustomFieldsManager: returning object #{miqVimCfm.object_id}"
256
258
  (miqVimCfm)
257
259
  end
258
260
 
259
261
  def getVimAlarmManager
260
262
  miqVimAm = MiqVimAlarmManager.new(self)
261
- $vim_log.info "MiqVimMod.getVimAlarmManager: returning object #{miqVimAm.object_id}"
263
+ logger.info "MiqVimMod.getVimAlarmManager: returning object #{miqVimAm.object_id}"
262
264
  (miqVimAm)
263
265
  end
264
266
 
265
267
  def getVimCustomizationSpecManager
266
268
  miqVimCsm = MiqVimCustomizationSpecManager.new(self)
267
- $vim_log.info "MiqVimMod.getVimCustomizationSpecManager: returning object #{miqVimCsm.object_id}"
269
+ logger.info "MiqVimMod.getVimCustomizationSpecManager: returning object #{miqVimCsm.object_id}"
268
270
  (miqVimCsm)
269
271
  end
270
272
 
@@ -279,28 +281,28 @@ class MiqVim < MiqVimInventory
279
281
  def start_monitor_updates_thread(preLoad)
280
282
  checkForOrphanedMonitors
281
283
  log_prefix = "MiqVim.initialize (#{@connId})"
282
- $vim_log.info "#{log_prefix}: starting update monitor thread" if $vim_log
284
+ logger.info "#{log_prefix}: starting update monitor thread"
283
285
  @updateThread = Thread.new { monitor(preLoad) }
284
286
  @updateThread[:vim_connection_id] = connId
285
- $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"
286
288
  until @updateMonitorReady
287
289
  raise @error unless @error.nil?
288
290
  break unless @updateThread.alive?
289
291
  Thread.pass
290
292
  end
291
- $vim_log.info "#{log_prefix}: update monitor ready" if $vim_log
293
+ logger.info "#{log_prefix}: update monitor ready"
292
294
  end
293
295
 
294
296
  def checkForOrphanedMonitors
295
297
  log_prefix = "MiqVim.checkForOrphanedMonitors (#{@connId})"
296
- $vim_log.debug "#{log_prefix}: called..."
298
+ logger.debug "#{log_prefix}: called..."
297
299
  Thread.list.each do |thr|
298
300
  next unless thr[:vim_connection_id] == connId
299
- $vim_log.error "#{log_prefix}: Terminating orphaned update monitor <#{thr.object_id}>"
301
+ logger.error "#{log_prefix}: Terminating orphaned update monitor <#{thr.object_id}>"
300
302
  thr.raise "Orphaned update monitor (#{@connId}) <#{thr.object_id}>, terminated by <#{Thread.current.object_id}>"
301
303
  thr.wakeup
302
304
  end
303
- $vim_log.debug "#{log_prefix}: done."
305
+ logger.debug "#{log_prefix}: done."
304
306
  end
305
307
 
306
308
  def monitor(preLoad)
@@ -308,7 +310,7 @@ class MiqVim < MiqVimInventory
308
310
  begin
309
311
  monitorUpdates(preLoad)
310
312
  rescue Exception => err
311
- $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"
312
314
  @error = err
313
315
  end
314
316
  end
@@ -318,9 +320,9 @@ class MiqVim < MiqVimInventory
318
320
  stopUpdateMonitor
319
321
  begin
320
322
  if @updateThread != Thread.current && @updateThread.alive?
321
- $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"
322
324
  @updateThread.join
323
- $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"
324
326
  end
325
327
  rescue
326
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)