Class: DMiqVim

Inherits:
MiqVim show all
Includes:
DMiqVimSync, DRb::DRbUndumped
Defined in:
lib/VMwareWebService/DMiqVim.rb

Constant Summary

Constants included from VimPropMaps

VimPropMaps::CorePropMap, VimPropMaps::EmsRefreshPropMap, VimPropMaps::EventMonitorPropMap, VimPropMaps::FullPropMap, VimPropMaps::PropMapVCenter, VimPropMaps::UpdatePropMapsByType, VimPropMaps::VimCoreUpdaterPropMap

Instance Attribute Summary

Attributes inherited from MiqVim

#monitor_updates, #updateThread

Attributes inherited from MiqVimInventory

#cacheLock, #configLock

Attributes inherited from MiqVimClientBase

#connId, #password, #server, #username

Attributes inherited from VimService

#about, #apiVersion, #isVirtualCenter, #serviceInstanceMor, #session_cookie, #sic, #v2, #v20, #v4, #v5, #v6

Instance Method Summary collapse

Methods included from DMiqVimSync

#dupObj

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 MiqVimUpdate

#addObject, #debugUpdates=, #deleteObject, #forceFail, #monitorUpdates, #monitorUpdatesInitial, #monitorUpdatesSince, #notifyMethod=, #propUpdate, #stopUpdateMonitor, #updateDelay, #updateDelay=, #updateObject, #updateProps

Methods included from MiqVimVdlConnectionMod

#closeVdlConnection, #vdlConnection

Methods inherited from MiqVimInventory

#addDVPObj, #addDVSObj, #addDataStore, #addDataStoreObj, #addExtensionManager, #addHostSystem, #addHostSystemObj, #addLicenseManager, #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, #extensionManagerByMor, #extensionManagersByFilter, #extensionManagersByMor, #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, #licenseManagerByMor, #licenseManagersByFilter, #licenseManagersByMor, #loadCache, #localVmPath, #logCacheCounts, #logUserEvent, #objFixUp, path2dsName, #path2dsName, #pollTask, #propFromCache, #propValue, #queryLogDescriptions, #refreshExtensionManager, #refreshLicenseManager, #refreshVirtualMachine, #removeExtensionManager, #removeLicenseManager, #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

#objectSet

Methods included from MiqVimDump

#dumpAll, #dumpArray, #dumpClass, #dumpHash, #dumpHostInfo, #dumpMors, #dumpObj, #dumpToLog=, #globalIndent=, #indentedPrint

Methods included from VimPropMaps

#dupProps

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.

Parameters:

  • server (String)

    DNS name or IP address of the vCenter Server

  • username (String)

    Username to connect to the vCenter Server

  • password (String)

    Password to connect to the vCenter Server

  • broker (MiqVimBroker)

    Instance of the broker worker this connection belongs to

  • preLoad (Bool) (defaults to: false)

    Should the cache be built before returning the connection (default: false)

  • debugUpdates (Bool) (defaults to: false)

    Should we print debug info for each update (default: false)

  • notifyMethod (Method) (defaults to: nil)

    A optional method to call for each update (default: nil)

  • cacheScope (Symbol) (defaults to: nil)

    A pre-defined set of properties to cache (default: nil)

  • maxWait (Integer) (defaults to: 60)

    How many seconds to wait before breaking out of WaitForUpdates (default: 60)

  • maxObjects (Integer) (defaults to: 250)

    How many objects to return from each WaitForUpdates page (default: 250)



34
35
36
37
38
39
40
# File 'lib/VMwareWebService/DMiqVim.rb', line 34

def initialize(server, username, password, broker, preLoad = false, debugUpdates = false, notifyMethod = nil, cacheScope = nil, maxWait = 60, maxObjects = 250)
  super(server, username, password, cacheScope, monitor_updates = true, preLoad, debugUpdates, notifyMethod, maxWait, maxObjects)

  @broker                 = broker
  @connectionShuttingDown = false
  @connectionRemoved      = false
end

Instance Method Details

#connectObject



88
89
90
# File 'lib/VMwareWebService/DMiqVim.rb', line 88

def connect
  (true)
end

#connectionRemovedObject



84
85
86
# File 'lib/VMwareWebService/DMiqVim.rb', line 84

def connectionRemoved
  @connectionRemoved = true
end

#connectionRemoved?Boolean

Returns:

  • (Boolean)


80
81
82
# File 'lib/VMwareWebService/DMiqVim.rb', line 80

def connectionRemoved?
  @connectionRemoved
end

#disconnectObject



92
93
94
# File 'lib/VMwareWebService/DMiqVim.rb', line 92

def disconnect
  (true)
end

#monitor(preLoad) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/VMwareWebService/DMiqVim.rb', line 42

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

#serverPrivateConnectObject



17
# File 'lib/VMwareWebService/DMiqVim.rb', line 17

alias_method :serverPrivateConnect, :connect

#serverPrivateDisconnectObject



18
# File 'lib/VMwareWebService/DMiqVim.rb', line 18

alias_method :serverPrivateDisconnect, :disconnect

#shutdownConnectionObject



71
72
73
74
75
76
77
78
# File 'lib/VMwareWebService/DMiqVim.rb', line 71

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
  serverPrivateDisconnect if self.isAlive?
  $vim_log.info "#{log_prefix}: for address=<#{@server}>, username=<#{@username}>...Complete" if $vim_log
end