Class: DMiqVim
- Inherits:
-
MiqVim
- Object
- Handsoap::Service
- VimService
- MiqVimClientBase
- MiqVimInventory
- MiqVim
- DMiqVim
- Includes:
- DMiqVimSync, DRb::DRbUndumped, MiqVimUpdate
- Defined in:
- lib/VMwareWebService/DMiqVim.rb
Constant Summary
Constants included from VimPropMaps
VimPropMaps::CorePropMap, VimPropMaps::EmsRefreshPropMap, VimPropMaps::EventMonitorPropMap, VimPropMaps::FullPropMap, VimPropMaps::PropMap4, VimPropMaps::UpdatePropMapsByType, VimPropMaps::VimCoreUpdaterPropMap
Instance Attribute Summary collapse
-
#updateThread ⇒ Object
readonly
Returns the value of attribute updateThread.
Attributes inherited from MiqVimInventory
Attributes inherited from MiqVimClientBase
#connId, #password, #server, #username
Attributes inherited from VimService
#about, #apiVersion, #isVirtualCenter, #serviceInstanceMor, #session_cookie, #sic, #v2, #v20, #v4
Instance Method Summary collapse
- #checkForOrphanedMonitors ⇒ Object
- #connect ⇒ Object
- #connectionRemoved ⇒ Object
- #connectionRemoved? ⇒ Boolean
- #disconnect ⇒ Object
-
#handleSessionNotAuthenticated(err) ⇒ Object
VC sometimes throws: Handsoap::Fault { :code => ‘ServerFaultCode’, :reason => ‘The session is not authenticated.’ } Handle this condition by reconnecting and monitoring again See communities.vmware.com/thread/190531.
-
#initialize(server, username, password, broker, preLoad = false, debugUpdates = false, notifyMethod = nil, cacheScope = nil, maxWait = 60, maxObjects = 250) ⇒ DMiqVim
constructor
A new instance of DMiqVim.
- #monitor(preLoad) ⇒ Object
- #serverPrivateConnect ⇒ Object
- #serverPrivateDisconnect ⇒ Object
- #shutdownConnection ⇒ Object
Methods included from DMiqVimSync
Methods included from MiqVimUpdate
#addObject, #debugUpdates=, #deleteObject, #forceFail, #monitorUpdates, #monitorUpdatesInitial, #monitorUpdatesSince, #notifyMethod=, #propUpdate, #stopUpdateMonitor, #updateDelay, #updateDelay=, #updateObject, #updateProps
Methods inherited from MiqVim
#getMiqCustomFieldsManager, #getVimAlarmManager, #getVimCluster, #getVimClusterByFilter, #getVimClusterByMor, #getVimCustomizationSpecManager, #getVimDataStore, #getVimDataStoreByMor, #getVimEventHistory, #getVimFolder, #getVimFolderByFilter, #getVimFolderByMor, #getVimHost, #getVimHostByFilter, #getVimHostByMor, #getVimPerfHistory, #getVimVm, #getVimVmByFilter, #getVimVmByMor
Methods included from MiqPbmInventory
#pbmProfilesByUid, #pbmQueryAssociatedEntity, #pbmQueryMatchingHub, #pbm_initialize
Methods included from MiqVimVdlConnectionMod
#closeVdlConnection, #vdlConnection
Methods inherited from MiqVimInventory
#addDVPObj, #addDVSObj, #addDataStore, #addDataStoreObj, #addHostSystem, #addHostSystemObj, #addObjByMor, #addObjHash, #addProperty, #addStoragePodObj, #addToCollection, #addVirtualMachine, #allPropsFromCache, #applyFilter, #applySelSpec, #applySelector, #assert_no_locks, #browseDiagnosticLog, #browseDiagnosticLogEx, cacheScope, cacheScope=, #cacheStats, #cancelTask, #clusterComputeResourceByMor, #clusterComputeResources, #clusterComputeResourcesByFilter, #clusterComputeResourcesByMor, #computeResourceByMor, #computeResources, #computeResourcesByFilter, #computeResourcesByMor, #currentSession, #dataStoreByMor, #dataStores, #dataStoresByFilter, #dataStoresByFilter_local, #dataStoresByMor, #datacenterByMor, #datacenters, #datacentersByFilter, #datacentersByMor, #datastorePath, #deepClone, #deleteProperty, #dsName2mo, #dsName2mo_local, #dsName2path, #dsPath?, dsPath?, #dsRelativePath, dsRelativePath, #dupObj, #dvPortgroupByMor, #dvPortgroups, #dvPortgroupsByMor, #dvSwitchByMor, #dvSwitches, #dvSwitchesByMor, #folderByMor, #folders, #foldersByFilter, #foldersByMor, #getMoProp, #getMoPropMulti, #getMoPropMultiIter, #getMoProp_local, #getSelSpec, #getSelector, #getTaskMor, #getTasks, #getTasksByFilter, #hasProp?, #hostSystemByMor, #hostSystems, #hostSystemsByFilter, #hostSystemsByMor, #hostSystemsStorageDevice, #inventoryHash, #inventoryHash_locked, #isAlive?, #isDead, #isHostAgent?, #isVirtualCenter?, #keyExistsInCache?, #keyFromCache, #loadCache, #localVmPath, #logCacheCounts, #logUserEvent, #objFixUp, #path2dsName, path2dsName, #pollTask, #propFromCache, #propValue, #queryLogDescriptions, #refreshVirtualMachine, #removeObjByMor, removeSelector, #removeSelector, #removeVirtualMachine, #resetCache, #resourcePoolByMor, #resourcePools, #resourcePoolsByFilter, #resourcePoolsByMor, #selSpecToPropPath, setSelector, #setSelector, #snapshotFixup, #spec, #storagePodByMor, #storagePods, #storagePodsByMor, #updateSpec, #updateSpecByPropMap, #virtualAppByMor, #virtualApps, #virtualAppsByFilter, #virtualAppsByMor, #virtualMachineByMor, #virtualMachines, #virtualMachinesByFilter, #virtualMachinesByMor, #vmDatacenterName, #waitForTask
Methods included from MiqVimObjectSet
Methods included from MiqVimDump
#dumpAll, #dumpArray, #dumpClass, #dumpHash, #dumpHostInfo, #dumpMors, #dumpObj, #dumpToLog=, #globalIndent=, #indentedPrint
Methods included from VimPropMaps
Methods inherited from MiqVimClientBase
#acquireCloneTicket, #currentServerTime, #receiveTimeout, receiveTimeout, #receiveTimeout=, receiveTimeout=, #sdk_uri, #verify_callback
Methods inherited from VimService
#acquireCloneTicket, #acquireMksTicket, #acquireTicket, #addHost_Task, #addInternetScsiSendTargets, #addInternetScsiStaticTargets, #addStandaloneHost_Task, #browseDiagnosticLog, #cancelTask, #cancelWaitForUpdates, #cloneVM_Task, #continueRetrievePropertiesEx, #createAlarm, #createCollectorForEvents, #createCustomizationSpec, #createFilter, #createFolder, #createNasDatastore, #createSnapshot_Task, #createVM_Task, #currentTime, #customizationSpecItemToXml, #deleteCustomizationSpec, #deselectVnicForNicType, #destroyCollector, #destroyPropertyFilter, #destroy_Task, #disableRuleset, #doesCustomizationSpecExist, #enableRuleset, #enterMaintenanceMode_Task, #exitMaintenanceMode_Task, #getAlarm, #getCustomizationSpec, #logUserEvent, #login, #logout, #markAsTemplate, #markAsVirtualMachine, #migrateVM_Task, #moveIntoFolder_Task, #powerDownHostToStandBy_Task, #powerOffVM_Task, #powerOnVM_Task, #powerUpHostFromStandBy_Task, #queryAvailablePerfMetric, #queryDescriptions, #queryDvsConfigTarget, #queryNetConfig, #queryOptions, #queryPerf, #queryPerfComposite, #queryPerfProviderSummary, #readNextEvents, #readPreviousEvents, #rebootGuest, #rebootHost_Task, #reconfigVM_Task, #reconfigureAlarm, #refreshFirewall, #refreshNetworkSystem, #refreshServices, #registerVM_Task, #relocateVM_Task, #removeAlarm, #removeAllSnapshots_Task, #removeSnapshot_Task, #renameSnapshot, #rename_Task, #resetCollector, #resetVM_Task, #restartService, #retrieveProperties, #retrievePropertiesCompat, #retrievePropertiesEx, #retrievePropertiesIter, #retrieveServiceContent, #revertToCurrentSnapshot_Task, #revertToSnapshot_Task, #rewindCollector, #searchDatastoreSubFolders_Task, #searchDatastore_Task, #selectVnicForNicType, #setCollectorPageSize, #setField, #setTaskDescription, #setTaskState, #shutdownGuest, #shutdownHost_Task, #standbyGuest, #startService, #stopService, #suspendVM_Task, #uninstallService, #unregisterVM, #updateDefaultPolicy, #updateServicePolicy, #updateSoftwareInternetScsiEnabled, #waitForUpdates, #waitForUpdatesEx, #xmlToCustomizationSpecItem
Constructor Details
#initialize(server, username, password, broker, preLoad = false, debugUpdates = false, notifyMethod = nil, cacheScope = nil, maxWait = 60, maxObjects = 250) ⇒ DMiqVim
Returns a new instance of DMiqVim.
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/VMwareWebService/DMiqVim.rb', line 28 def initialize(server, username, password, broker, preLoad = false, debugUpdates = false, notifyMethod = nil, cacheScope = nil, maxWait = 60, maxObjects = 250) super(server, username, password, cacheScope) log_prefix = "DMiqVim.initialize (#{@connId})" @broker = broker @updateMonitorReady = false @error = nil @notifyMethod = notifyMethod @connectionShuttingDown = false @connectionRemoved = false @debugUpdates = debugUpdates @maxWait = maxWait @maxObjects = maxObjects checkForOrphanedMonitors $vim_log.info "#{log_prefix}: starting update monitor thread" if $vim_log @updateThread = Thread.new { monitor(preLoad) } @updateThread[:vim_connection_id] = connId $vim_log.info "#{log_prefix}: waiting for update monitor to become ready" if $vim_log until @updateMonitorReady raise @error unless @error.nil? break unless @updateThread.alive? Thread.pass end $vim_log.info "#{log_prefix}: update monitor ready" if $vim_log end |
Instance Attribute Details
#updateThread ⇒ Object (readonly)
Returns the value of attribute updateThread.
26 27 28 |
# File 'lib/VMwareWebService/DMiqVim.rb', line 26 def updateThread @updateThread end |
Instance Method Details
#checkForOrphanedMonitors ⇒ Object
132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/VMwareWebService/DMiqVim.rb', line 132 def checkForOrphanedMonitors log_prefix = "DMiqVim.checkForOrphanedMonitors (#{@connId})" $vim_log.debug "#{log_prefix}: called..." Thread.list.each do |thr| next unless thr[:vim_connection_id] == connId $vim_log.error "#{log_prefix}: Terminating orphaned update monitor <#{thr.object_id}>" thr.raise "Orphaned update monitor (#{@connId}) <#{thr.object_id}>, terminated by <#{Thread.current.object_id}>" thr.wakeup end $vim_log.debug "#{log_prefix}: done." end |
#connect ⇒ Object
152 153 154 |
# File 'lib/VMwareWebService/DMiqVim.rb', line 152 def connect (true) end |
#connectionRemoved ⇒ Object
148 149 150 |
# File 'lib/VMwareWebService/DMiqVim.rb', line 148 def connectionRemoved @connectionRemoved = true end |
#connectionRemoved? ⇒ Boolean
144 145 146 |
# File 'lib/VMwareWebService/DMiqVim.rb', line 144 def connectionRemoved? @connectionRemoved end |
#disconnect ⇒ Object
156 157 158 |
# File 'lib/VMwareWebService/DMiqVim.rb', line 156 def disconnect (true) end |
#handleSessionNotAuthenticated(err) ⇒ Object
VC sometimes throws: Handsoap::Fault { :code => ‘ServerFaultCode’, :reason => ‘The session is not authenticated.’ } Handle this condition by reconnecting and monitoring again See communities.vmware.com/thread/190531
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/VMwareWebService/DMiqVim.rb', line 58 def handleSessionNotAuthenticated(err) return false unless err.respond_to?(:reason) && err.reason == 'The session is not authenticated.' log_prefix = "DMiqVim.handleSessionNotAuthenticated (#{@connId})" $vim_log.error "#{log_prefix}: Reconnecting Session because '#{err.reason}'" if $vim_log $vim_log.info "#{log_prefix}: Session(server=#{server}, username=#{username}) isAlive? => #{self.isAlive?.inspect}" if $vim_log begin $vim_log.info "#{log_prefix}: Disconnecting Session" if $vim_log serverPrivateDisconnect $vim_log.info "#{log_prefix}: Disconnecting Session...Complete" if $vim_log rescue => disconnect_err $vim_log.error "#{log_prefix}: Disconnecting Session...Error #{disconnect_err}" if $vim_log end begin $vim_log.info "#{log_prefix}: Connecting Session" if $vim_log serverPrivateConnect $vim_log.info "#{log_prefix}: Connecting Session...Complete" if $vim_log rescue => connect_err $vim_log.error "#{log_prefix}: Connecting Session...Error #{connect_err}" if $vim_log @error = err end @error.nil? end |
#monitor(preLoad) ⇒ Object
85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 |
# File 'lib/VMwareWebService/DMiqVim.rb', line 85 def monitor(preLoad) log_prefix = "DMiqVim.monitor (#{@connId})" begin monitorUpdates(preLoad) rescue Exception => err # if handleSessionNotAuthenticated(err) # $vim_log.info "#{log_prefix}: Restarting Update Monitor" if $vim_log # retry # end $vim_log.info "#{log_prefix}: returned from monitorUpdates via #{err.class} exception" if $vim_log @error = err ensure $vim_log.info "#{log_prefix}: returned from monitorUpdates" if $vim_log if @updateMonitorReady && !@broker.shuttingDown @broker.connTrySync(:EX, server, username) do |key| @broker.removeMiqVimSS(key, self) end if @notifyMethod @notifyMethod.call(:server => @server, :username => @username, :op => 'MiqVimRemoved', :error => @error ) end end end end |
#serverPrivateConnect ⇒ Object
18 |
# File 'lib/VMwareWebService/DMiqVim.rb', line 18 alias_method :serverPrivateConnect, :connect |
#serverPrivateDisconnect ⇒ Object
19 |
# File 'lib/VMwareWebService/DMiqVim.rb', line 19 alias_method :serverPrivateDisconnect, :disconnect |
#shutdownConnection ⇒ Object
114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/VMwareWebService/DMiqVim.rb', line 114 def shutdownConnection return if @connectionShuttingDown log_prefix = "DMiqVim.shutdownConnection (#{@connId})" $vim_log.info "#{log_prefix}: for address=<#{@server}>, username=<#{@username}>...Starting" if $vim_log @connectionShuttingDown = true stopUpdateMonitor begin if @updateThread != Thread.current && @updateThread.alive? $vim_log.info "#{log_prefix}: waiting for Update Monitor Thread...Starting" if $vim_log @updateThread.join $vim_log.info "#{log_prefix}: waiting for Update Monitor Thread...Complete" if $vim_log end rescue => err end serverPrivateDisconnect if self.isAlive? $vim_log.info "#{log_prefix}: for address=<#{@server}>, username=<#{@username}>...Complete" if $vim_log end |