Class: MiqVim

Inherits:
MiqVimInventory show all
Includes:
MiqVimUpdate, MiqVimVdlConnectionMod
Defined in:
lib/VMwareWebService/MiqVim.rb

Direct Known Subclasses

DMiqVim

Constant Summary

Constants included from VimPropMaps

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

Instance Attribute Summary collapse

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 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, #conditionalCopy, #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, #connect, #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, cacheScope = nil, monitor_updates = false, preLoad = false, debugUpdates = false, notifyMethod = nil, maxWait = 60, maxObjects = 250) ⇒ MiqVim

Returns a new instance of MiqVim.

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

  • cacheScope (Symbol) (defaults to: nil)

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

  • monitor_updates (Bool) (defaults to: false)

    Should a thread be started to monitor updates (default: false)

  • 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)

  • 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)



33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/VMwareWebService/MiqVim.rb', line 33

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

  @monitor_updates    = monitor_updates
  @updateMonitorReady = false
  @error              = nil
  @notifyMethod       = notifyMethod
  @debugUpdates       = debugUpdates
  @maxWait            = maxWait
  @maxObjects         = maxObjects

  start_monitor_updates_thread(preLoad) if @monitor_updates
end

Instance Attribute Details

#monitor_updatesObject (readonly)

Returns the value of attribute monitor_updates.



21
22
23
# File 'lib/VMwareWebService/MiqVim.rb', line 21

def monitor_updates
  @monitor_updates
end

#updateThreadObject (readonly)

Returns the value of attribute updateThread.



21
22
23
# File 'lib/VMwareWebService/MiqVim.rb', line 21

def updateThread
  @updateThread
end

Instance Method Details

#disconnectObject



249
250
251
252
253
# File 'lib/VMwareWebService/MiqVim.rb', line 249

def disconnect
  shutdown_monitor_updates_thread if @monitor_updates

  super
end

#getMiqCustomFieldsManagerObject



231
232
233
234
235
# File 'lib/VMwareWebService/MiqVim.rb', line 231

def getMiqCustomFieldsManager
  miqVimCfm = MiqCustomFieldsManager.new(self)
  $vim_log.info "MiqVimMod.getMiqCustomFieldsManager: returning object #{miqVimCfm.object_id}"
  (miqVimCfm)
end

#getVimAlarmManagerObject



237
238
239
240
241
# File 'lib/VMwareWebService/MiqVim.rb', line 237

def getVimAlarmManager
  miqVimAm = MiqVimAlarmManager.new(self)
  $vim_log.info "MiqVimMod.getVimAlarmManager: returning object #{miqVimAm.object_id}"
  (miqVimAm)
end

#getVimCluster(name) ⇒ Object

Cluster



160
161
162
163
164
165
166
167
168
169
# File 'lib/VMwareWebService/MiqVim.rb', line 160

def getVimCluster(name)
  $vim_log.info "MiqVimMod.getVimCluster: called"
  miqVimCluster = nil
  @cacheLock.synchronize(:SH) do
    raise MiqException::MiqVimResourceNotFound, "Could not find Cluster: #{name}" unless (ch = clusterComputeResources_locked[name])
    miqVimCluster = MiqVimCluster.new(self, conditionalCopy(ch))
  end
  $vim_log.info "MiqVimMod.getVimCluster: returning object #{miqVimCluster.object_id}"
  (miqVimCluster)
end

#getVimClusterByFilter(filter) ⇒ Object

def getVimClusterByMor



182
183
184
185
186
187
188
189
190
191
192
# File 'lib/VMwareWebService/MiqVim.rb', line 182

def getVimClusterByFilter(filter)
  $vim_log.info "MiqVimMod.getVimClusterByFilter: called"
  miqVimCluster = nil
  @cacheLock.synchronize(:SH) do
    clusters = applyFilter(clusterComputeResourcesByMor_locked.values, filter)
    raise MiqException::MiqVimResourceNotFound, "getVimClusterByFilter: Could not find Cluster matching filter" if clusters.empty?
    miqVimCluster = MiqVimCluster.new(self, conditionalCopy(clusters[0]))
  end
  $vim_log.info "MiqVimMod.getVimClusterByFilter: returning object #{miqVimCluster.object_id}"
  (miqVimCluster)
end

#getVimClusterByMor(cMor) ⇒ Object

def getVimCluster



171
172
173
174
175
176
177
178
179
180
# File 'lib/VMwareWebService/MiqVim.rb', line 171

def getVimClusterByMor(cMor)
  $vim_log.info "MiqVimMod.getVimClusterByMor: called"
  miqVimCluster = nil
  @cacheLock.synchronize(:SH) do
    raise MiqException::MiqVimResourceNotFound, "Could not find Cluster: #{cMor}" unless (ch = clusterComputeResourcesByMor_locked[cMor])
    miqVimCluster = MiqVimCluster.new(self, conditionalCopy(ch))
  end
  $vim_log.info "MiqVimMod.getVimClusterByMor: returning object #{miqVimCluster.object_id}"
  (miqVimCluster)
end

#getVimCustomizationSpecManagerObject



243
244
245
246
247
# File 'lib/VMwareWebService/MiqVim.rb', line 243

def getVimCustomizationSpecManager
  miqVimCsm = MiqVimCustomizationSpecManager.new(self)
  $vim_log.info "MiqVimMod.getVimCustomizationSpecManager: returning object #{miqVimCsm.object_id}"
  (miqVimCsm)
end

#getVimDataStore(dsName) ⇒ Object

DataStore



197
198
199
200
201
202
203
204
205
206
# File 'lib/VMwareWebService/MiqVim.rb', line 197

def getVimDataStore(dsName)
  $vim_log.info "MiqVimMod.getVimDataStore: called"
  miqVimDs = nil
  @cacheLock.synchronize(:SH) do
    raise MiqException::MiqVimResourceNotFound, "Could not find datastore: #{dsName}" unless (dsh = dataStores_locked[dsName])
    miqVimDs = MiqVimDataStore.new(self, conditionalCopy(dsh))
  end
  $vim_log.info "MiqVimMod.getVimDataStore: returning object #{miqVimDs.object_id}"
  (miqVimDs)
end

#getVimDataStoreByMor(dsMor) ⇒ Object



208
209
210
211
212
213
214
215
216
217
# File 'lib/VMwareWebService/MiqVim.rb', line 208

def getVimDataStoreByMor(dsMor)
  $vim_log.info "MiqVimMod.getVimDataStoreByMor: called"
  miqVimDs = nil
  @cacheLock.synchronize(:SH) do
    raise MiqException::MiqVimResourceNotFound, "Could not find datastore: #{dsMor}" unless (dsh = dataStoresByMor_locked[dsMor])
    miqVimDs = MiqVimDataStore.new(self, conditionalCopy(dsh))
  end
  $vim_log.info "MiqVimMod.getVimDataStoreByMor: returning object #{miqVimDs.object_id}"
  (miqVimDs)
end

#getVimEventHistory(eventFilterSpec = nil, pgSize = 20) ⇒ Object



225
226
227
228
229
# File 'lib/VMwareWebService/MiqVim.rb', line 225

def getVimEventHistory(eventFilterSpec = nil, pgSize = 20)
  miqVimEh = MiqVimEventHistoryCollector.new(self, eventFilterSpec, pgSize)
  $vim_log.info "MiqVimMod.getVimEventHistory: returning object #{miqVimEh.object_id}"
  (miqVimEh)
end

#getVimFolder(name) ⇒ Object

def getVimHostByFilter



123
124
125
126
127
128
129
130
131
132
# File 'lib/VMwareWebService/MiqVim.rb', line 123

def getVimFolder(name)
  $vim_log.info "MiqVimMod.getVimFolder: called"
  miqVimFolder = nil
  @cacheLock.synchronize(:SH) do
    raise MiqException::MiqVimResourceNotFound, "Could not find Folder: #{name}" unless (fh = folders_locked[name])
    miqVimFolder = MiqVimFolder.new(self, conditionalCopy(fh))
  end
  $vim_log.info "MiqVimMod.getVimFolder: returning object #{miqVimFolder.object_id}"
  (miqVimFolder)
end

#getVimFolderByFilter(filter) ⇒ Object

def getVimFolderByMor



145
146
147
148
149
150
151
152
153
154
155
# File 'lib/VMwareWebService/MiqVim.rb', line 145

def getVimFolderByFilter(filter)
  $vim_log.info "MiqVimMod.getVimFolderByFilter: called"
  miqVimFolder = nil
  @cacheLock.synchronize(:SH) do
    folders = applyFilter(foldersByMor_locked.values, filter)
    raise MiqException::MiqVimResourceNotFound, "getVimFolderByFilter: Could not find folder matching filter" if folders.empty?
    miqVimFolder = MiqVimFolder.new(self, conditionalCopy(folders[0]))
  end
  $vim_log.info "MiqVimMod.getVimFolderByFilter: returning object #{miqVimFolder.object_id}"
  (miqVimFolder)
end

#getVimFolderByMor(fMor) ⇒ Object

def getVimFolder



134
135
136
137
138
139
140
141
142
143
# File 'lib/VMwareWebService/MiqVim.rb', line 134

def getVimFolderByMor(fMor)
  $vim_log.info "MiqVimMod.getVimFolderByMor: called"
  miqVimFolder = nil
  @cacheLock.synchronize(:SH) do
    raise MiqException::MiqVimResourceNotFound, "Could not find Folder: #{fMor}" unless (fh = foldersByMor_locked[fMor])
    miqVimFolder = MiqVimFolder.new(self, conditionalCopy(fh))
  end
  $vim_log.info "MiqVimMod.getVimFolderByMor: returning object #{miqVimFolder.object_id}"
  (miqVimFolder)
end

#getVimHost(name) ⇒ Object

def getVimVmByFilter



85
86
87
88
89
90
91
92
93
94
# File 'lib/VMwareWebService/MiqVim.rb', line 85

def getVimHost(name)
  $vim_log.info "MiqVimMod.getVimHost: called"
  miqVimHost = nil
  @cacheLock.synchronize(:SH) do
    raise MiqException::MiqVimResourceNotFound, "Could not find Host: #{name}" unless (hh = hostSystems_locked[name])
    miqVimHost = MiqVimHost.new(self, conditionalCopy(hh))
  end
  $vim_log.info "MiqVimMod.getVimHost: returning object #{miqVimHost.object_id}"
  (miqVimHost)
end

#getVimHostByFilter(filter) ⇒ Object

Returns a MiqVimHost object for the first Host found that matches the criteria defined by the filter.



111
112
113
114
115
116
117
118
119
120
121
# File 'lib/VMwareWebService/MiqVim.rb', line 111

def getVimHostByFilter(filter)
  $vim_log.info "MiqVimMod.getVimHostByFilter: called"
  miqVimHost = nil
  @cacheLock.synchronize(:SH) do
    ha = applyFilter(hostSystemsByMor_locked.values, filter)
    raise MiqException::MiqVimResourceNotFound, "getVimHostByFilter: Could not find Host matching filter" if ha.empty?
    miqVimHost = MiqVimHost.new(self, conditionalCopy(ha[0]))
  end
  $vim_log.info "MiqVimMod.getVimHostByFilter: returning object #{miqVimHost.object_id}"
  (miqVimHost)
end

#getVimHostByMor(hMor) ⇒ Object

def getVimHost



96
97
98
99
100
101
102
103
104
105
# File 'lib/VMwareWebService/MiqVim.rb', line 96

def getVimHostByMor(hMor)
  $vim_log.info "MiqVimMod.getVimHostByMor: called"
  miqVimHost = nil
  @cacheLock.synchronize(:SH) do
    raise MiqException::MiqVimResourceNotFound, "Could not find Host: #{hMor}" unless (hh = hostSystemsByMor_locked[hMor])
    miqVimHost = MiqVimHost.new(self, conditionalCopy(hh))
  end
  $vim_log.info "MiqVimMod.getVimHostByMor: returning object #{miqVimHost.object_id}"
  (miqVimHost)
end

#getVimPerfHistoryObject



219
220
221
222
223
# File 'lib/VMwareWebService/MiqVim.rb', line 219

def getVimPerfHistory
  miqVimPh = MiqVimPerfHistory.new(self)
  $vim_log.info "MiqVimMod.getVimPerfHistory: returning object #{miqVimPh.object_id}"
  (miqVimPh)
end

#getVimVm(path) ⇒ Object



47
48
49
50
51
52
53
54
55
56
# File 'lib/VMwareWebService/MiqVim.rb', line 47

def getVimVm(path)
  $vim_log.info "MiqVimMod.getVimVm: called"
  miqVimVm = nil
  @cacheLock.synchronize(:SH) do
    raise MiqException::MiqVimResourceNotFound, "Could not find VM: #{path}" unless (vmh = virtualMachines_locked[path])
    miqVimVm = MiqVimVm.new(self, conditionalCopy(vmh))
  end
  $vim_log.info "MiqVimMod.getVimVm: returning object #{miqVimVm.object_id}"
  (miqVimVm)
end

#getVimVmByFilter(filter) ⇒ Object

Returns a MiqVimVm object for the first VM found that matches the criteria defined by the filter.



73
74
75
76
77
78
79
80
81
82
83
# File 'lib/VMwareWebService/MiqVim.rb', line 73

def getVimVmByFilter(filter)
  $vim_log.info "MiqVimMod.getVimVmByFilter: called"
  miqVimVm = nil
  @cacheLock.synchronize(:SH) do
    vms = applyFilter(virtualMachinesByMor_locked.values, filter)
    raise MiqException::MiqVimResourceNotFound, "getVimVmByFilter: Could not find VM matching filter" if vms.empty?
    miqVimVm = MiqVimVm.new(self, conditionalCopy(vms[0]))
  end
  $vim_log.info "MiqVimMod.getVimVmByFilter: returning object #{miqVimVm.object_id}"
  (miqVimVm)
end

#getVimVmByMor(vmMor) ⇒ Object

def getVimVm



58
59
60
61
62
63
64
65
66
67
# File 'lib/VMwareWebService/MiqVim.rb', line 58

def getVimVmByMor(vmMor)
  $vim_log.info "MiqVimMod.getVimVmByMor: called"
  miqVimVm = nil
  @cacheLock.synchronize(:SH) do
    raise MiqException::MiqVimResourceNotFound, "Could not find VM: #{vmMor}" unless (vmh = virtualMachinesByMor_locked[vmMor])
    miqVimVm = MiqVimVm.new(self, conditionalCopy(vmh))
  end
  $vim_log.info "MiqVimMod.getVimVmByMor: returning object #{miqVimVm.object_id}"
  (miqVimVm)
end