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.
- checksums.yaml +4 -4
- data/lib/VMwareWebService/MiqHostDatastoreSystem.rb +5 -1
- data/lib/VMwareWebService/MiqVim.rb +58 -56
- data/lib/VMwareWebService/MiqVimClientBase.rb +11 -10
- data/lib/VMwareWebService/MiqVimCluster.rb +6 -2
- data/lib/VMwareWebService/MiqVimDataStore.rb +9 -6
- data/lib/VMwareWebService/MiqVimDump.rb +1 -1
- data/lib/VMwareWebService/MiqVimEventHistoryCollector.rb +5 -1
- data/lib/VMwareWebService/MiqVimEventMonitor.rb +22 -20
- data/lib/VMwareWebService/MiqVimFolder.rb +15 -11
- data/lib/VMwareWebService/MiqVimHost.rb +15 -13
- data/lib/VMwareWebService/MiqVimInventory.rb +78 -79
- data/lib/VMwareWebService/MiqVimPerfHistory.rb +13 -10
- data/lib/VMwareWebService/MiqVimUpdate.rb +50 -50
- data/lib/VMwareWebService/MiqVimVdlMod.rb +7 -7
- data/lib/VMwareWebService/MiqVimVm.rb +102 -101
- data/lib/VMwareWebService/VimService.rb +5 -2
- data/lib/VMwareWebService/VixDiskLib/VixDiskLib.rb +10 -6
- data/lib/VMwareWebService/VixDiskLib/VixDiskLibServer.rb +15 -13
- data/lib/VMwareWebService/VixDiskLib/vdl_wrapper.rb +26 -25
- data/lib/VMwareWebService/exception.rb +0 -2
- data/lib/VMwareWebService/logging.rb +16 -0
- data/lib/VMwareWebService/version.rb +1 -1
- data/lib/vmware_web_service.rb +2 -0
- metadata +6 -25
- data/lib/VMwareWebService/DMiqVim.rb +0 -95
- data/lib/VMwareWebService/DMiqVimSync.rb +0 -45
- data/lib/VMwareWebService/MiqVimBroker.rb +0 -581
- data/lib/VMwareWebService/MiqVimBrokerMods.rb +0 -222
- data/lib/VMwareWebService/MiqVimCoreUpdater.rb +0 -269
- data/lib/VMwareWebService/miq_fault_tolerant_vim.rb +0 -246
@@ -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
|
-
|
101
|
+
logger.info "MiqVimPerfHistory(#{@invObj.server}, #{@invObj.username}).queryProviderSummary: calling queryPerfProviderSummary"
|
99
102
|
psum = @invObj.queryPerfProviderSummary(@perfManager, mor)
|
100
|
-
|
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
|
-
|
114
|
+
logger.info "MiqVimPerfHistory(#{@invObj.server}, #{@invObj.username}).availMetricsForEntity: calling queryAvailablePerfMetric"
|
112
115
|
pmids = @invObj.queryAvailablePerfMetric(@perfManager, mor, beginTime, endTime, intervalId)
|
113
|
-
|
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
|
-
|
127
|
+
logger.info "MiqVimPerfHistory(#{@invObj.server}, #{@invObj.username}).queryPerf: calling queryPerf"
|
125
128
|
umPem = @invObj.queryPerf(@perfManager, pqs)[0]
|
126
|
-
|
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
|
-
|
157
|
+
logger.info "MiqVimPerfHistory(#{@invObj.server}, #{@invObj.username}).queryPerfMulti: calling queryPerf"
|
155
158
|
pema = @invObj.queryPerf(@perfManager, querySpec)
|
156
|
-
|
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
|
-
|
171
|
+
logger.info "MiqVimPerfHistory(#{@invObj.server}, #{@invObj.username}).queryPerfComposite: calling queryPerfComposite"
|
169
172
|
umPem = @invObj.queryPerfComposite(@perfManager, pqs)
|
170
|
-
|
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
|
|
@@ -27,9 +27,9 @@ module MiqVimUpdate
|
|
27
27
|
|
28
28
|
while truncated
|
29
29
|
begin
|
30
|
-
|
30
|
+
logger.info "#{log_prefix}: call to waitForUpdates...Starting"
|
31
31
|
updateSet = waitForUpdatesEx(@umPropCol, version, wait_options)
|
32
|
-
|
32
|
+
logger.info "#{log_prefix}: call to waitForUpdates...Complete"
|
33
33
|
|
34
34
|
version = updateSet.version
|
35
35
|
truncated = updateSet.truncated
|
@@ -46,7 +46,7 @@ module MiqVimUpdate
|
|
46
46
|
# Help out the Ruby Garbage Collector by resetting variables pointing to large objects back to nil
|
47
47
|
updateSet = nil
|
48
48
|
rescue HTTPClient::ReceiveTimeoutError => terr
|
49
|
-
|
49
|
+
logger.info "#{log_prefix}: call to waitForUpdates...Timeout"
|
50
50
|
raise terr if !isAlive?
|
51
51
|
retry
|
52
52
|
end
|
@@ -58,9 +58,9 @@ module MiqVimUpdate
|
|
58
58
|
def monitorUpdatesSince(version)
|
59
59
|
log_prefix = "MiqVimUpdate.monitorUpdatesSince (#{@connId})"
|
60
60
|
begin
|
61
|
-
|
61
|
+
logger.info "#{log_prefix}: call to waitForUpdates...Starting (version = #{version})"
|
62
62
|
updateSet = waitForUpdatesEx(@umPropCol, version, :max_wait => @maxWait)
|
63
|
-
|
63
|
+
logger.info "#{log_prefix}: call to waitForUpdates...Complete (version = #{version})"
|
64
64
|
return version if updateSet.nil?
|
65
65
|
|
66
66
|
version = updateSet.version
|
@@ -70,11 +70,11 @@ module MiqVimUpdate
|
|
70
70
|
updateSet.filterSet.each do |fu|
|
71
71
|
next if fu.filter != @filterSpecRef
|
72
72
|
fu.objectSet.each do |objUpdate|
|
73
|
-
|
73
|
+
logger.info "#{log_prefix}: applying update...Starting (version = #{version})"
|
74
74
|
@cacheLock.synchronize(:EX) do
|
75
75
|
updateObject(objUpdate)
|
76
76
|
end
|
77
|
-
|
77
|
+
logger.info "#{log_prefix}: applying update...Complete (version = #{version})"
|
78
78
|
Thread.pass
|
79
79
|
end
|
80
80
|
end # updateSet.filterSet.each
|
@@ -82,9 +82,9 @@ module MiqVimUpdate
|
|
82
82
|
updateSet = nil
|
83
83
|
return version
|
84
84
|
rescue HTTPClient::ReceiveTimeoutError => terr
|
85
|
-
|
85
|
+
logger.info "#{log_prefix}: call to waitForUpdates...Timeout (version = #{version})"
|
86
86
|
retry if isAlive?
|
87
|
-
|
87
|
+
logger.warn "#{log_prefix}: connection lost"
|
88
88
|
raise terr
|
89
89
|
end
|
90
90
|
end
|
@@ -97,7 +97,7 @@ module MiqVimUpdate
|
|
97
97
|
@debugUpdates = false if @debugUpdates.nil?
|
98
98
|
@dumpToLog = true if @debugUpdates
|
99
99
|
|
100
|
-
|
100
|
+
logger.debug "#{log_prefix}: debugUpdates = #{@debugUpdates}"
|
101
101
|
|
102
102
|
begin
|
103
103
|
@umPropCol = @sic.propertyCollector
|
@@ -116,18 +116,18 @@ module MiqVimUpdate
|
|
116
116
|
# Ignore signals, except TERM
|
117
117
|
rescue => herr
|
118
118
|
if herr.respond_to?(:reason) && herr.reason == 'The task was canceled by a user.'
|
119
|
-
|
119
|
+
logger.info "#{log_prefix}: waitForUpdates canceled"
|
120
120
|
else
|
121
|
-
|
122
|
-
|
123
|
-
|
121
|
+
logger.error "******* #{herr.class}"
|
122
|
+
logger.error herr.to_s
|
123
|
+
logger.error herr.backtrace.join("\n") unless herr.kind_of?(HTTPClient::ReceiveTimeoutError) # already logged in monitorUpdatesInitial or monitorUpdatesSince
|
124
124
|
raise herr
|
125
125
|
end
|
126
126
|
ensure
|
127
127
|
if @filterSpecRef && isAlive?
|
128
|
-
|
128
|
+
logger.info "#{log_prefix}: calling destroyPropertyFilter...Starting"
|
129
129
|
destroyPropertyFilter(@filterSpecRef)
|
130
|
-
|
130
|
+
logger.info "#{log_prefix}: calling destroyPropertyFilter...Complete"
|
131
131
|
end
|
132
132
|
@filterSpecRef = nil
|
133
133
|
# @umPropCol = nil
|
@@ -137,18 +137,18 @@ module MiqVimUpdate
|
|
137
137
|
def stopUpdateMonitor
|
138
138
|
log_prefix = "MiqVimUpdate.stopUpdateMonitor (#{@connId})"
|
139
139
|
|
140
|
-
|
140
|
+
logger.info "#{log_prefix}: for address=<#{@server}>, username=<#{@username}>...Starting"
|
141
141
|
@monitor = false
|
142
142
|
if @umPropCol
|
143
143
|
if isAlive?
|
144
|
-
|
144
|
+
logger.info "#{log_prefix}: calling cancelWaitForUpdates...Starting"
|
145
145
|
cancelWaitForUpdates(@umPropCol)
|
146
|
-
|
146
|
+
logger.info "#{log_prefix}: calling cancelWaitForUpdates...Complete"
|
147
147
|
end
|
148
148
|
@umPropCol = nil
|
149
149
|
@updateThread.run if @updateThread.status == "sleep"
|
150
150
|
end
|
151
|
-
|
151
|
+
logger.info "#{log_prefix}: for address=<#{@server}>, username=<#{@username}>...Complete"
|
152
152
|
end
|
153
153
|
|
154
154
|
def forceFail
|
@@ -159,7 +159,7 @@ module MiqVimUpdate
|
|
159
159
|
def updateObject(objUpdate, initialUpdate = false)
|
160
160
|
unless @inventoryHash # no cache to update
|
161
161
|
return unless initialUpdate
|
162
|
-
|
162
|
+
logger.info "MiqVimUpdate.updateObject: setting @inventoryHash to empty hash"
|
163
163
|
@inventoryHash = {}
|
164
164
|
end
|
165
165
|
|
@@ -171,12 +171,12 @@ module MiqVimUpdate
|
|
171
171
|
when 'modify'
|
172
172
|
updateProps(objUpdate, initialUpdate)
|
173
173
|
else
|
174
|
-
|
174
|
+
logger.warn "MiqVimUpdate.updateObject (#{@connId}): unrecognized operation: #{objUpdate.kind}"
|
175
175
|
end
|
176
176
|
end
|
177
177
|
|
178
178
|
def updateProps(objUpdate, initialUpdate = false)
|
179
|
-
|
179
|
+
logger.debug "Update object (#{@connId}): #{objUpdate.obj.vimType}: #{objUpdate.obj}" if @debugUpdates
|
180
180
|
return if !objUpdate.changeSet || objUpdate.changeSet.empty?
|
181
181
|
|
182
182
|
#
|
@@ -191,7 +191,7 @@ module MiqVimUpdate
|
|
191
191
|
hashName = "#{pm[:baseName]}ByMor"
|
192
192
|
return unless (objHash = instance_variable_get(hashName)) # no cache to update
|
193
193
|
unless (obj = objHash[objUpdate.obj])
|
194
|
-
|
194
|
+
logger.warn "updateProps (#{@connId}): object #{objUpdate.obj} not found in #{hashName}"
|
195
195
|
return
|
196
196
|
end
|
197
197
|
|
@@ -234,8 +234,8 @@ module MiqVimUpdate
|
|
234
234
|
# Call the notify callback if enabled, defined and we are past the initial update
|
235
235
|
#
|
236
236
|
if @notifyMethod && !initialUpdate
|
237
|
-
|
238
|
-
|
237
|
+
logger.debug "MiqVimUpdate.updateProps (#{@connId}): server = #{@server}, mor = (#{objUpdate.obj.vimType}, #{objUpdate.obj})"
|
238
|
+
logger.debug "MiqVimUpdate.updateProps (#{@connId}): changedProps = [ #{changedProps.join(', ')} ]"
|
239
239
|
Thread.new do
|
240
240
|
@notifyMethod.call(:server => @server,
|
241
241
|
:username => @username,
|
@@ -251,9 +251,9 @@ module MiqVimUpdate
|
|
251
251
|
end
|
252
252
|
|
253
253
|
rescue => err
|
254
|
-
|
255
|
-
|
256
|
-
|
254
|
+
logger.warn "MiqVimUpdate::updateProps (#{@connId}): #{err}"
|
255
|
+
logger.warn "Clearing cache for (#{@connId}): #{pm[:baseName]}"
|
256
|
+
logger.debug err.backtrace.join("\n")
|
257
257
|
dumpCache("#{pm[:baseName]}ByMor")
|
258
258
|
|
259
259
|
instance_variable_set("#{pm[:baseName]}ByMor", nil)
|
@@ -266,9 +266,9 @@ module MiqVimUpdate
|
|
266
266
|
objBaseType = objUpdate.obj.vimBaseType
|
267
267
|
|
268
268
|
# always log additions to the inventory.
|
269
|
-
|
269
|
+
logger.info "MiqVimUpdate.addObject (#{@connId}): #{objType}: #{objUpdate.obj}"
|
270
270
|
return unless (pm = @propMap[objBaseType.to_sym]) # not an object type we cache
|
271
|
-
|
271
|
+
logger.info "MiqVimUpdate.addObject (#{@connId}): Adding object #{objType}: #{objUpdate.obj}"
|
272
272
|
|
273
273
|
#
|
274
274
|
# First, add the object's MOR to the @inventoryHash entry for the object's type.
|
@@ -283,7 +283,7 @@ module MiqVimUpdate
|
|
283
283
|
hashName = "#{pm[:baseName]}ByMor"
|
284
284
|
unless instance_variable_get(hashName) # no cache to update
|
285
285
|
return unless initialUpdate
|
286
|
-
|
286
|
+
logger.info "MiqVimUpdate.addObject: setting #{hashName} and #{pm[:baseName]} to empty hash"
|
287
287
|
instance_variable_set(hashName, {})
|
288
288
|
instance_variable_set(pm[:baseName], {})
|
289
289
|
end
|
@@ -298,7 +298,7 @@ module MiqVimUpdate
|
|
298
298
|
# Call the notify callback if enabled, defined and we are past the initial update
|
299
299
|
#
|
300
300
|
if @notifyMethod && !initialUpdate
|
301
|
-
|
301
|
+
logger.debug "MiqVimUpdate.addObject: server = #{@server}, mor = (#{objUpdate.obj.vimType}, #{objUpdate.obj})"
|
302
302
|
Thread.new do
|
303
303
|
@notifyMethod.call(:server => @server,
|
304
304
|
:username => @username,
|
@@ -310,9 +310,9 @@ module MiqVimUpdate
|
|
310
310
|
end
|
311
311
|
|
312
312
|
rescue => err
|
313
|
-
|
314
|
-
|
315
|
-
|
313
|
+
logger.warn "MiqVimUpdate::addObject: #{err}"
|
314
|
+
logger.warn "Clearing cache for: #{pm[:baseName]}"
|
315
|
+
logger.debug err.backtrace.join("\n")
|
316
316
|
dumpCache("#{pm[:baseName]}ByMor")
|
317
317
|
|
318
318
|
instance_variable_set("#{pm[:baseName]}ByMor", nil)
|
@@ -325,9 +325,9 @@ module MiqVimUpdate
|
|
325
325
|
objBaseType = objUpdate.obj.vimBaseType
|
326
326
|
|
327
327
|
# always log deletions from the inventory.
|
328
|
-
|
328
|
+
logger.info "MiqVimUpdate.deleteObject (#{@connId}): #{objType}: #{objUpdate.obj}"
|
329
329
|
return unless (pm = @propMap[objBaseType.to_sym]) # not an object type we cache
|
330
|
-
|
330
|
+
logger.info "MiqVimUpdate.deleteObject (#{@connId}): Deleting object: #{objType}: #{objUpdate.obj}"
|
331
331
|
|
332
332
|
ia = @inventoryHash[objType]
|
333
333
|
ia.delete(objUpdate.obj)
|
@@ -341,7 +341,7 @@ module MiqVimUpdate
|
|
341
341
|
# Call the notify callback if enabled, defined and we are past the initial update
|
342
342
|
#
|
343
343
|
if @notifyMethod && !initialUpdate
|
344
|
-
|
344
|
+
logger.debug "MiqVimUpdate.deleteObject: server = #{@server}, mor = (#{objUpdate.obj.vimType}, #{objUpdate.obj})"
|
345
345
|
Thread.new do
|
346
346
|
@notifyMethod.call(:server => @server,
|
347
347
|
:username => @username,
|
@@ -353,9 +353,9 @@ module MiqVimUpdate
|
|
353
353
|
end
|
354
354
|
|
355
355
|
rescue => err
|
356
|
-
|
357
|
-
|
358
|
-
|
356
|
+
logger.warn "MiqVimUpdate::deleteObject: #{err}"
|
357
|
+
logger.warn "Clearing cache for: #{pm[:baseName]}"
|
358
|
+
logger.debug err.backtrace.join("\n")
|
359
359
|
dumpCache("#{pm[:baseName]}ByMor")
|
360
360
|
|
361
361
|
instance_variable_set("#{pm[:baseName]}ByMor", nil)
|
@@ -367,17 +367,17 @@ module MiqVimUpdate
|
|
367
367
|
changedProps = [] if returnChangedProps
|
368
368
|
changeSet.each do |propChange|
|
369
369
|
if @debugUpdates
|
370
|
-
|
371
|
-
|
372
|
-
|
370
|
+
logger.debug "\tpropChange name (path): #{propChange.name}"
|
371
|
+
logger.debug "\tpropChange op: #{propChange.op}"
|
372
|
+
logger.debug "\tpropChange val (type): #{propChange.val.class}"
|
373
373
|
|
374
|
-
|
374
|
+
logger.debug "\t*** propChange val START:"
|
375
375
|
oGi = @globalIndent
|
376
376
|
@globalIndent = "\t\t"
|
377
377
|
dumpObj(propChange.val)
|
378
378
|
@globalIndent = oGi
|
379
|
-
|
380
|
-
|
379
|
+
logger.debug "\t*** propChange val END"
|
380
|
+
logger.debug "\t***"
|
381
381
|
end
|
382
382
|
|
383
383
|
#
|
@@ -424,9 +424,9 @@ module MiqVimUpdate
|
|
424
424
|
|
425
425
|
def dumpCache(cache)
|
426
426
|
return unless @debugUpdates
|
427
|
-
|
427
|
+
logger.debug "**** Dumping #{cache} cache"
|
428
428
|
dumbObj(instance_variable_get(cache))
|
429
|
-
|
429
|
+
logger.debug "**** #{cache} dump end"
|
430
430
|
end
|
431
431
|
private :dumpCache
|
432
432
|
|
@@ -5,9 +5,9 @@ module MiqVimVdlConnectionMod
|
|
5
5
|
#
|
6
6
|
def vdlConnection
|
7
7
|
require 'VMwareWebService/VixDiskLib/VixDiskLib'
|
8
|
-
VixDiskLib.init(->(s) {
|
9
|
-
->(s) {
|
10
|
-
->(s) {
|
8
|
+
VixDiskLib.init(->(s) { logger.info "VMware(VixDiskLib): #{s}" },
|
9
|
+
->(s) { logger.warn "VMware(VixDiskLib): #{s}" },
|
10
|
+
->(s) { logger.error "VMware(VixDiskLib): #{s}" })
|
11
11
|
$log.info "MiqVimVdlConnectionMod.vdlConnection: server - #{@server}"
|
12
12
|
VixDiskLib.connect(:serverName => server,
|
13
13
|
:port => 902,
|
@@ -17,7 +17,7 @@ module MiqVimVdlConnectionMod
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def closeVdlConnection(connection)
|
20
|
-
|
20
|
+
logger.info "MiqVimMod.closeVdlConnection: #{connection.serverName}"
|
21
21
|
connection.disconnect
|
22
22
|
end
|
23
23
|
end # module MiqVimVdlConnectionMod
|
@@ -31,9 +31,9 @@ module MiqVimVdlVcConnectionMod
|
|
31
31
|
def vdlVcConnection
|
32
32
|
require 'VMwareWebService/VixDiskLib/VixDiskLib'
|
33
33
|
|
34
|
-
VixDiskLib.init(->(s) {
|
35
|
-
->(s) {
|
36
|
-
->(s) {
|
34
|
+
VixDiskLib.init(->(s) { logger.info "VMware(VixDiskLib): #{s}" },
|
35
|
+
->(s) { logger.warn "VMware(VixDiskLib): #{s}" },
|
36
|
+
->(s) { logger.error "VMware(VixDiskLib): #{s}" })
|
37
37
|
|
38
38
|
$log.info "MiqVimVdlVcConnectionMod.vdlVcConnection: server - #{invObj.server}"
|
39
39
|
thumb_print = if invObj.isVirtualCenter?
|
@@ -1,17 +1,18 @@
|
|
1
1
|
require 'sync'
|
2
2
|
|
3
|
-
require 'enumerator'
|
4
3
|
require "ostruct"
|
5
4
|
|
6
5
|
require 'more_core_extensions/core_ext/hash'
|
7
6
|
require 'active_support/core_ext/object/try'
|
8
7
|
|
9
8
|
require 'VMwareWebService/exception'
|
9
|
+
require 'VMwareWebService/logging'
|
10
10
|
require 'VMwareWebService/MiqVimVdlMod'
|
11
11
|
require 'VMwareWebService/esx_thumb_print'
|
12
12
|
require 'VMwareWebService/vcenter_thumb_print'
|
13
13
|
|
14
14
|
class MiqVimVm
|
15
|
+
include VMwareWebService::Logging
|
15
16
|
include MiqVimVdlVcConnectionMod
|
16
17
|
|
17
18
|
EVM_SNAPSHOT_NAME = "EvmSnapshot".freeze # TODO: externalize - not VIM specific
|
@@ -92,53 +93,53 @@ class MiqVimVm
|
|
92
93
|
#######################
|
93
94
|
|
94
95
|
def start(wait = true)
|
95
|
-
|
96
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).start: calling powerOnVM_Task"
|
96
97
|
taskMor = @invObj.powerOnVM_Task(@vmMor)
|
97
|
-
|
98
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).start: returned from powerOnVM_Task"
|
98
99
|
return taskMor unless wait
|
99
100
|
waitForTask(taskMor)
|
100
101
|
end # def start
|
101
102
|
|
102
103
|
def stop(wait = true)
|
103
|
-
|
104
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).stop: calling powerOffVM_Task"
|
104
105
|
taskMor = @invObj.powerOffVM_Task(@vmMor)
|
105
|
-
|
106
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).stop: returned from powerOffVM_Task"
|
106
107
|
return taskMor unless wait
|
107
108
|
waitForTask(taskMor)
|
108
109
|
end # def stop
|
109
110
|
|
110
111
|
def suspend(wait = true)
|
111
|
-
|
112
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).suspend: calling suspendVM_Task"
|
112
113
|
taskMor = @invObj.suspendVM_Task(@vmMor)
|
113
|
-
|
114
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).suspend: returned from suspendVM_Task"
|
114
115
|
return taskMor unless wait
|
115
116
|
waitForTask(taskMor)
|
116
117
|
end # def suspend
|
117
118
|
|
118
119
|
def reset(wait = true)
|
119
|
-
|
120
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).reset: calling resetVM_Task"
|
120
121
|
taskMor = @invObj.resetVM_Task(@vmMor)
|
121
|
-
|
122
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).reset: returned from resetVM_Task"
|
122
123
|
return taskMor unless wait
|
123
124
|
waitForTask(taskMor)
|
124
125
|
end
|
125
126
|
|
126
127
|
def rebootGuest
|
127
|
-
|
128
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).rebootGuest: calling rebootGuest"
|
128
129
|
@invObj.rebootGuest(@vmMor)
|
129
|
-
|
130
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).rebootGuest: returned from rebootGuest"
|
130
131
|
end
|
131
132
|
|
132
133
|
def shutdownGuest
|
133
|
-
|
134
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).shutdownGuest: calling shutdownGuest"
|
134
135
|
@invObj.shutdownGuest(@vmMor)
|
135
|
-
|
136
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).shutdownGuest: returned from shutdownGuest"
|
136
137
|
end
|
137
138
|
|
138
139
|
def standbyGuest
|
139
|
-
|
140
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).standbyGuest: calling standbyGuest"
|
140
141
|
@invObj.standbyGuest(@vmMor)
|
141
|
-
|
142
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).standbyGuest: returned from standbyGuest"
|
142
143
|
end
|
143
144
|
|
144
145
|
def powerState
|
@@ -168,18 +169,18 @@ class MiqVimVm
|
|
168
169
|
############################
|
169
170
|
|
170
171
|
def markAsTemplate
|
171
|
-
|
172
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).markAsTemplate: calling markAsTemplate"
|
172
173
|
@invObj.markAsTemplate(@vmMor)
|
173
|
-
|
174
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).markAsTemplate: returned from markAsTemplate"
|
174
175
|
end
|
175
176
|
|
176
177
|
def markAsVm(pool, host = nil)
|
177
178
|
hmor = nil
|
178
179
|
hmor = (host.kind_of?(Hash) ? host['MOR'] : host) if host
|
179
180
|
pmor = (pool.kind_of?(Hash) ? pool['MOR'] : pool)
|
180
|
-
|
181
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).markAsVm: calling markAsVirtualMachine"
|
181
182
|
@invObj.markAsVirtualMachine(@vmMor, pmor, hmor)
|
182
|
-
|
183
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).markAsVm: returned from markAsVirtualMachine"
|
183
184
|
end
|
184
185
|
|
185
186
|
def template?
|
@@ -194,18 +195,18 @@ class MiqVimVm
|
|
194
195
|
hmor = (host.kind_of?(Hash) ? host['MOR'] : host)
|
195
196
|
pool = (pool.kind_of?(Hash) ? pool['MOR'] : pool) if pool
|
196
197
|
|
197
|
-
|
198
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).migrate: calling migrateVM_Task, vm=<#{@vmMor.inspect}>, host=<#{hmor.inspect}>, pool=<#{pool.inspect}>, priority=<#{priority.inspect}>, state=<#{state.inspect}>"
|
198
199
|
taskMor = @invObj.migrateVM_Task(@vmMor, pool, hmor, priority, state)
|
199
|
-
|
200
|
-
|
200
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).migrate: returned from migrateVM_Task"
|
201
|
+
logger.debug "MiqVimVm::migrate: taskMor = #{taskMor}"
|
201
202
|
waitForTask(taskMor)
|
202
203
|
end
|
203
204
|
|
204
205
|
def renameVM(newName)
|
205
|
-
|
206
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).renameVM: calling rename_Task, vm=<#{@vmMor.inspect}>, newName=<#{newName}>"
|
206
207
|
task_mor = @invObj.rename_Task(@vmMor, newName)
|
207
|
-
|
208
|
-
|
208
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).renameVM: returned from rename_Task"
|
209
|
+
logger.debug "MiqVimVm::renameVM: taskMor = #{task_mor}"
|
209
210
|
waitForTask(task_mor)
|
210
211
|
end
|
211
212
|
|
@@ -223,26 +224,26 @@ class MiqVimVm
|
|
223
224
|
rsl.transform = transform if transform
|
224
225
|
end
|
225
226
|
|
226
|
-
|
227
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).relocate: calling relocateVM_Task, vm=<#{@vmMor.inspect}>, host=<#{hmor.inspect}>, pool=<#{pool.inspect}>, datastore=<#{dsmor.inspect}>, priority=<#{priority.inspect}>"
|
227
228
|
taskMor = @invObj.relocateVM_Task(@vmMor, rspec, priority)
|
228
|
-
|
229
|
-
|
229
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).relocate: returned from relocateVM_Task"
|
230
|
+
logger.debug "MiqVimVm::relocate: taskMor = #{taskMor}"
|
230
231
|
waitForTask(taskMor)
|
231
232
|
end
|
232
233
|
|
233
234
|
def cloneVM_raw(folder, name, spec, wait = true)
|
234
|
-
|
235
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).cloneVM_raw: calling cloneVM_Task"
|
235
236
|
taskMor = @invObj.cloneVM_Task(@vmMor, folder, name, spec)
|
236
|
-
|
237
|
-
|
237
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).cloneVM_raw: returned from cloneVM_Task"
|
238
|
+
logger.debug "MiqVimVm::cloneVM_raw: taskMor = #{taskMor}"
|
238
239
|
|
239
240
|
if wait
|
240
241
|
rv = waitForTask(taskMor)
|
241
|
-
|
242
|
+
logger.debug "MiqVimVm::cloneVM_raw: rv = #{rv}"
|
242
243
|
return rv
|
243
244
|
end
|
244
245
|
|
245
|
-
|
246
|
+
logger.debug "MiqVimVm::cloneVM_raw - no wait: taskMor = #{taskMor}"
|
246
247
|
taskMor
|
247
248
|
end
|
248
249
|
|
@@ -288,15 +289,15 @@ class MiqVimVm
|
|
288
289
|
# end
|
289
290
|
|
290
291
|
def unregister
|
291
|
-
|
292
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).unregister: calling unregisterVM"
|
292
293
|
@invObj.unregisterVM(@vmMor)
|
293
|
-
|
294
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).unregister: returned from unregisterVM"
|
294
295
|
end
|
295
296
|
|
296
297
|
def destroy
|
297
|
-
|
298
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).destroy: calling destroy_Task"
|
298
299
|
taskMor = @invObj.destroy_Task(@vmMor)
|
299
|
-
|
300
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).destroy: returned from destroy_Task"
|
300
301
|
waitForTask(taskMor)
|
301
302
|
end
|
302
303
|
|
@@ -378,33 +379,33 @@ class MiqVimVm
|
|
378
379
|
end
|
379
380
|
|
380
381
|
def createSnapshot(name, desc, memory, quiesce, wait = true, free_space_percent = 100)
|
381
|
-
|
382
|
+
logger.debug "MiqVimVm::createSnapshot(#{name}, #{desc}, #{memory}, #{quiesce})"
|
382
383
|
cs = connectionState
|
383
384
|
raise "MiqVimVm(#{@invObj.server}, #{@invObj.username}).createSnapshot: VM is not connected, connectionState = #{cs}" if cs != "connected"
|
384
385
|
snapshot_free_space_check('create', free_space_percent)
|
385
|
-
|
386
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).createSnapshot: calling createSnapshot_Task"
|
386
387
|
taskMor = @invObj.createSnapshot_Task(@vmMor, name, desc, memory, quiesce)
|
387
|
-
|
388
|
-
|
388
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).createSnapshot: returned from createSnapshot_Task"
|
389
|
+
logger.debug "MiqVimVm::createSnapshot: taskMor = #{taskMor}"
|
389
390
|
|
390
391
|
if wait
|
391
392
|
snMor = waitForTask(taskMor)
|
392
|
-
|
393
|
+
logger.warn "MiqVimVm::createSnapshot: snMor = #{snMor}"
|
393
394
|
return snMor
|
394
395
|
end
|
395
396
|
|
396
|
-
|
397
|
+
logger.debug "MiqVimVm::createSnapshot - no wait: taskMor = #{taskMor}"
|
397
398
|
taskMor
|
398
399
|
end # def createSnapshot
|
399
400
|
|
400
401
|
def removeSnapshot(snMor, subTree = "false", wait = true, free_space_percent = 100)
|
401
|
-
|
402
|
+
logger.warn "MiqVimVm::removeSnapshot(#{snMor}, #{subTree})"
|
402
403
|
snMor = getSnapMor(snMor)
|
403
404
|
snapshot_free_space_check('remove', free_space_percent)
|
404
|
-
|
405
|
+
logger.warn "MiqVimVm(#{@invObj.server}, #{@invObj.username}).removeSnapshot: calling removeSnapshot_Task: snMor [#{snMor}] subtree [#{subTree}]"
|
405
406
|
taskMor = @invObj.removeSnapshot_Task(snMor, subTree)
|
406
|
-
|
407
|
-
|
407
|
+
logger.warn "MiqVimVm(#{@invObj.server}, #{@invObj.username}).removeSnapshot: returned from removeSnapshot_Task: snMor [#{snMor}]"
|
408
|
+
logger.debug "MiqVimVm::removeSnapshot: taskMor = #{taskMor}"
|
408
409
|
return taskMor unless wait
|
409
410
|
waitForTask(taskMor)
|
410
411
|
end # def removeSnapshot
|
@@ -422,40 +423,40 @@ class MiqVimVm
|
|
422
423
|
end # def removeSnapshotByDescription
|
423
424
|
|
424
425
|
def removeAllSnapshots(free_space_percent = 100)
|
425
|
-
|
426
|
-
|
426
|
+
logger.debug "MiqVimVm::removeAllSnapshots"
|
427
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).removeAllSnapshots: calling removeAllSnapshots_Task"
|
427
428
|
snapshot_free_space_check('remove_all', free_space_percent)
|
428
429
|
taskMor = @invObj.removeAllSnapshots_Task(@vmMor)
|
429
|
-
|
430
|
-
|
430
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).removeAllSnapshots: returned from removeAllSnapshots_Task"
|
431
|
+
logger.debug "MiqVimVm::removeAllSnapshots: taskMor = #{taskMor}"
|
431
432
|
waitForTask(taskMor)
|
432
433
|
end # def removeAllSnapshots
|
433
434
|
|
434
435
|
def revertToSnapshot(snMor)
|
435
|
-
|
436
|
+
logger.debug "MiqVimVm::revertToSnapshot(#{snMor})"
|
436
437
|
snMor = getSnapMor(snMor)
|
437
|
-
|
438
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).revertToSnapshot: calling revertToSnapshot_Task"
|
438
439
|
taskMor = @invObj.revertToSnapshot_Task(snMor)
|
439
|
-
|
440
|
-
|
440
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).revertToSnapshot: returned from revertToSnapshot_Task"
|
441
|
+
logger.debug "MiqVimVm::revertToSnapshot: taskMor = #{taskMor}"
|
441
442
|
waitForTask(taskMor)
|
442
443
|
end # def revertToSnapshot
|
443
444
|
|
444
445
|
def revertToCurrentSnapshot
|
445
|
-
|
446
|
-
|
446
|
+
logger.debug "MiqVimVm::revertToCurrentSnapshot"
|
447
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).revertToCurrentSnapshot: calling revertToCurrentSnapshot_Task"
|
447
448
|
taskMor = @invObj.revertToCurrentSnapshot_Task(@vmMor)
|
448
|
-
|
449
|
-
|
449
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).revertToCurrentSnapshot: returned from revertToCurrentSnapshot_Task"
|
450
|
+
logger.debug "MiqVimVm::revertToCurrentSnapshot: taskMor = #{taskMor}"
|
450
451
|
waitForTask(taskMor)
|
451
452
|
end # def revertToCurrentSnapshot
|
452
453
|
|
453
454
|
def renameSnapshot(snMor, name, desc)
|
454
|
-
|
455
|
+
logger.debug "MiqVimVm::renameSnapshot(#{snMor}, #{name}, #{desc})"
|
455
456
|
snMor = getSnapMor(snMor)
|
456
|
-
|
457
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).renameSnapshot: calling renameSnapshot"
|
457
458
|
@invObj.renameSnapshot(snMor, name, desc)
|
458
|
-
|
459
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).renameSnapshot: returned from renameSnapshot"
|
459
460
|
end # def renameSnapshot
|
460
461
|
|
461
462
|
def snapshot_free_space_check(action, free_space_percent = 100)
|
@@ -509,13 +510,13 @@ class MiqVimVm
|
|
509
510
|
|
510
511
|
def getSnapMor(snMor)
|
511
512
|
unless snMor.respond_to?(:vimType)
|
512
|
-
|
513
|
+
logger.debug "MiqVimVm::getSnapMor converting #{snMor} to MOR"
|
513
514
|
@cacheLock.synchronize(:SH) do
|
514
515
|
raise "getSnapMor: VM #{@dsPath} has no snapshots" unless (sni = snapshotInfo_locked(true))
|
515
516
|
raise "getSnapMor: snapshot #{snMor} not found" unless (snObj = sni['ssMorHash'][snMor])
|
516
517
|
snMor = snObj['snapshot']
|
517
518
|
end
|
518
|
-
|
519
|
+
logger.debug "MiqVimVm::getSnapMor new MOR: #{snMor}"
|
519
520
|
end
|
520
521
|
(snMor)
|
521
522
|
end # def getSnapMor
|
@@ -610,9 +611,9 @@ class MiqVimVm
|
|
610
611
|
end # def getCfg
|
611
612
|
|
612
613
|
def reconfig(vmConfigSpec)
|
613
|
-
|
614
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).reconfig: calling reconfigVM_Task"
|
614
615
|
taskMor = @invObj.reconfigVM_Task(@vmMor, vmConfigSpec)
|
615
|
-
|
616
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).reconfig: returned from reconfigVM_Task"
|
616
617
|
waitForTask(taskMor)
|
617
618
|
end
|
618
619
|
|
@@ -631,9 +632,9 @@ class MiqVimVm
|
|
631
632
|
|
632
633
|
def setMemory(memMB)
|
633
634
|
vmConfigSpec = VimHash.new("VirtualMachineConfigSpec") { |cs| cs.memoryMB = memMB }
|
634
|
-
|
635
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).setMemory: calling reconfigVM_Task"
|
635
636
|
taskMor = @invObj.reconfigVM_Task(@vmMor, vmConfigSpec)
|
636
|
-
|
637
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).setMemory: returned from reconfigVM_Task"
|
637
638
|
waitForTask(taskMor)
|
638
639
|
end
|
639
640
|
|
@@ -643,9 +644,9 @@ class MiqVimVm
|
|
643
644
|
|
644
645
|
def setNumCPUs(numCPUs)
|
645
646
|
vmConfigSpec = VimHash.new("VirtualMachineConfigSpec") { |cs| cs.numCPUs = numCPUs }
|
646
|
-
|
647
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).setNumCPUs: calling reconfigVM_Task"
|
647
648
|
taskMor = @invObj.reconfigVM_Task(@vmMor, vmConfigSpec)
|
648
|
-
|
649
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).setNumCPUs: returned from reconfigVM_Task"
|
649
650
|
waitForTask(taskMor)
|
650
651
|
end
|
651
652
|
|
@@ -667,9 +668,9 @@ class MiqVimVm
|
|
667
668
|
end
|
668
669
|
end
|
669
670
|
|
670
|
-
|
671
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).connectDevice: calling reconfigVM_Task"
|
671
672
|
taskMor = @invObj.reconfigVM_Task(@vmMor, vmConfigSpec)
|
672
|
-
|
673
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).connectDevice: returned from reconfigVM_Task"
|
673
674
|
waitForTask(taskMor)
|
674
675
|
end # def connectDevice
|
675
676
|
|
@@ -705,9 +706,9 @@ class MiqVimVm
|
|
705
706
|
end
|
706
707
|
end
|
707
708
|
|
708
|
-
|
709
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).attachIsoToCd: calling reconfigVM_Task"
|
709
710
|
taskMor = @invObj.reconfigVM_Task(@vmMor, vmConfigSpec)
|
710
|
-
|
711
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).attachIsoToCd: returned from reconfigVM_Task"
|
711
712
|
waitForTask(taskMor)
|
712
713
|
end
|
713
714
|
|
@@ -723,9 +724,9 @@ class MiqVimVm
|
|
723
724
|
end
|
724
725
|
end
|
725
726
|
|
726
|
-
|
727
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).resetCd: calling reconfigVM_Task"
|
727
728
|
taskMor = @invObj.reconfigVM_Task(@vmMor, vmConfigSpec)
|
728
|
-
|
729
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).resetCd: returned from reconfigVM_Task"
|
729
730
|
waitForTask(taskMor)
|
730
731
|
end
|
731
732
|
|
@@ -803,9 +804,9 @@ class MiqVimVm
|
|
803
804
|
end
|
804
805
|
end
|
805
806
|
|
806
|
-
|
807
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).addDisk: calling reconfigVM_Task"
|
807
808
|
taskMor = @invObj.reconfigVM_Task(@vmMor, vmConfigSpec)
|
808
|
-
|
809
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).addDisk: returned from reconfigVM_Task"
|
809
810
|
waitForTask(taskMor)
|
810
811
|
end # def addDisk
|
811
812
|
|
@@ -820,8 +821,8 @@ class MiqVimVm
|
|
820
821
|
raise "removeDiskByFile: false setting for deleteBacking not yet supported" if deleteBacking == false
|
821
822
|
controllerKey, key = getDeviceKeysByBacking(backingFile)
|
822
823
|
raise "removeDiskByFile: no virtual device associated with: #{backingFile}" unless key
|
823
|
-
|
824
|
-
|
824
|
+
logger.debug "MiqVimVm::MiqVimVm: backingFile = #{backingFile}"
|
825
|
+
logger.debug "MiqVimVm::MiqVimVm: controllerKey = #{controllerKey}, key = #{key}"
|
825
826
|
|
826
827
|
vmConfigSpec = VimHash.new("VirtualMachineConfigSpec") do |vmcs|
|
827
828
|
vmcs.deviceChange = VimArray.new("ArrayOfVirtualDeviceConfigSpec") do |vmcs_vca|
|
@@ -859,9 +860,9 @@ class MiqVimVm
|
|
859
860
|
end
|
860
861
|
end
|
861
862
|
|
862
|
-
|
863
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).removeDiskByFile: calling reconfigVM_Task"
|
863
864
|
taskMor = @invObj.reconfigVM_Task(@vmMor, vmConfigSpec)
|
864
|
-
|
865
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).removeDiskByFile: returned from reconfigVM_Task"
|
865
866
|
waitForTask(taskMor)
|
866
867
|
end # def removeDiskByFile
|
867
868
|
|
@@ -869,7 +870,7 @@ class MiqVimVm
|
|
869
870
|
disk = getDeviceByBacking(backingFile)
|
870
871
|
raise "resizeDisk: no virtual device associated with: #{backingFile}" unless disk
|
871
872
|
raise "resizeDisk: cannot reduce the size of a disk" unless newSizeInKb >= Integer(disk.capacityInKB)
|
872
|
-
|
873
|
+
logger.debug "MiqVimVm::resizeDisk: backingFile = #{backingFile} current size = #{device.capacityInKB} newSize = #{newSizeInKb} KB"
|
873
874
|
|
874
875
|
vmConfigSpec = VimHash.new("VirtualMachineConfigSpec") do |vmcs|
|
875
876
|
vmcs.deviceChange = VimArray.new("ArrayOfVirtualDeviceConfigSpec") do |vmcs_vca|
|
@@ -887,9 +888,9 @@ class MiqVimVm
|
|
887
888
|
end
|
888
889
|
end
|
889
890
|
|
890
|
-
|
891
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).resizeDisk: calling reconfigVM_Task"
|
891
892
|
taskMor = @invObj.reconfigVM_Task(@vmMor, vmConfigSpec)
|
892
|
-
|
893
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).resizeDisk: returned from reconfigVM_Task"
|
893
894
|
waitForTask(taskMor)
|
894
895
|
end
|
895
896
|
|
@@ -1041,9 +1042,9 @@ class MiqVimVm
|
|
1041
1042
|
else
|
1042
1043
|
aSpec = @miqAlarmSpecDisabled
|
1043
1044
|
end
|
1044
|
-
|
1045
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).addMiqAlarm_locked: calling createAlarm"
|
1045
1046
|
alarmMor = @invObj.createAlarm(alarmManager, @vmMor, aSpec)
|
1046
|
-
|
1047
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).addMiqAlarm_locked: returned from createAlarm"
|
1047
1048
|
@miqAlarmMor = alarmMor
|
1048
1049
|
ensure
|
1049
1050
|
@cacheLock.sync_unlock if unlock
|
@@ -1074,9 +1075,9 @@ class MiqVimVm
|
|
1074
1075
|
begin
|
1075
1076
|
@cacheLock.sync_lock(:EX) if (unlock = @cacheLock.sync_shared?)
|
1076
1077
|
|
1077
|
-
|
1078
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).getMiqAlarm_locked: calling getAlarm"
|
1078
1079
|
alarms = @invObj.getAlarm(@sic.alarmManager, @vmMor)
|
1079
|
-
|
1080
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).getMiqAlarm_locked: returned from getAlarm"
|
1080
1081
|
alarms.each do |aMor|
|
1081
1082
|
ap = @invObj.getMoProp(aMor, "info.name")
|
1082
1083
|
next unless ap['info']['name'][MIQ_ALARM_PFX]
|
@@ -1105,27 +1106,27 @@ class MiqVimVm
|
|
1105
1106
|
def disableMiqAlarm
|
1106
1107
|
@cacheLock.synchronize(:SH) do
|
1107
1108
|
raise "disableMiqAlarm: MiqAlarm not configured for VM #{@dsPath}" unless (aMor = getMiqAlarm_locked)
|
1108
|
-
|
1109
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).disableMiqAlarm: calling reconfigureAlarm"
|
1109
1110
|
@invObj.reconfigureAlarm(aMor, @miqAlarmSpecDisabled)
|
1110
|
-
|
1111
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).disableMiqAlarm: returned from reconfigureAlarm"
|
1111
1112
|
end
|
1112
1113
|
end
|
1113
1114
|
|
1114
1115
|
def enableMiqAlarm
|
1115
1116
|
@cacheLock.synchronize(:SH) do
|
1116
1117
|
raise "enableMiqAlarm: MiqAlarm not configured for VM #{@dsPath}" unless (aMor = getMiqAlarm_locked)
|
1117
|
-
|
1118
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).enableMiqAlarm: calling reconfigureAlarm"
|
1118
1119
|
@invObj.reconfigureAlarm(aMor, @miqAlarmSpecEnabled)
|
1119
|
-
|
1120
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).enableMiqAlarm: returned from reconfigureAlarm"
|
1120
1121
|
end
|
1121
1122
|
end
|
1122
1123
|
|
1123
1124
|
def removeMiqAlarm
|
1124
1125
|
@cacheLock.synchronize(:SH) do
|
1125
1126
|
return unless (aMor = getMiqAlarm_locked)
|
1126
|
-
|
1127
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).removeMiqAlarm: calling removeAlarm"
|
1127
1128
|
@invObj.removeAlarm(aMor)
|
1128
|
-
|
1129
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).removeMiqAlarm: returned from removeAlarm"
|
1129
1130
|
@miqAlarmMor = nil
|
1130
1131
|
end
|
1131
1132
|
end
|
@@ -1177,9 +1178,9 @@ class MiqVimVm
|
|
1177
1178
|
end
|
1178
1179
|
end
|
1179
1180
|
|
1180
|
-
|
1181
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).setExtraConfigAttributes: calling reconfigVM_Task"
|
1181
1182
|
taskMor = @invObj.reconfigVM_Task(@vmMor, vmConfigSpec)
|
1182
|
-
|
1183
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).setExtraConfigAttributes: returned from reconfigVM_Task"
|
1183
1184
|
waitForTask(taskMor)
|
1184
1185
|
|
1185
1186
|
@extraConfig = nil
|
@@ -1287,16 +1288,16 @@ class MiqVimVm
|
|
1287
1288
|
end
|
1288
1289
|
|
1289
1290
|
def acquireMksTicket
|
1290
|
-
|
1291
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).acquireMksTicket: calling acquireMksTicket"
|
1291
1292
|
rv = @invObj.acquireMksTicket(@vmMor)
|
1292
|
-
|
1293
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).acquireMksTicket: returned from acquireMksTicket"
|
1293
1294
|
(rv)
|
1294
1295
|
end # def acquireMksTicket
|
1295
1296
|
|
1296
1297
|
def acquireTicket(ticketType)
|
1297
|
-
|
1298
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).acquireTicket: calling acquireTicket"
|
1298
1299
|
rv = @invObj.acquireTicket(@vmMor, ticketType)
|
1299
|
-
|
1300
|
+
logger.info "MiqVimVm(#{@invObj.server}, #{@invObj.username}).acquireTicket: returned from acquireTicket"
|
1300
1301
|
(rv)
|
1301
1302
|
end # def acquireTicket
|
1302
1303
|
|