Class: RbVmomi::VIM
- Inherits:
-
Connection
- Object
- Connection
- RbVmomi::VIM
- Defined in:
- lib/rbvmomi/vim.rb
Overview
A connection to one vSphere SDK endpoint.
Defined Under Namespace
Classes: ComputeResource, Datacenter, Datastore, DynamicTypeMgrAllTypeInfo, DynamicTypeMgrDataTypeInfo, DynamicTypeMgrManagedTypeInfo, EsxcliCommand, EsxcliNamespace, Folder, HostSystem, ManagedEntity, ManagedObject, ObjectContent, ObjectUpdate, OvfManager, PerfCounterInfo, PerformanceManager, PropertyCollector, ReflectManagedMethodExecuter, ResourcePool, ServiceInstance, Task, VirtualMachine
Class Method Summary collapse
-
.connect(opts) ⇒ Object
Connect to a vSphere SDK endpoint.
Instance Method Summary collapse
- #close ⇒ Object
- #get_log_keys(host = nil) ⇒ Object
- #get_log_lines(logKey, lines = 5, start = nil, host = nil) ⇒ Object
- #instanceUuid ⇒ Object
-
#propertyCollector ⇒ Object
Alias to serviceContent.propertyCollector.
- #rev=(x) ⇒ Object
-
#rootFolder ⇒ Object
(also: #root)
Alias to serviceContent.rootFolder.
-
#searchIndex ⇒ Object
Alias to serviceContent.searchIndex.
-
#serviceContent ⇒ Object
Alias to serviceInstance.RetrieveServiceContent.
-
#serviceInstance ⇒ Object
Return the ServiceInstance.
Class Method Details
.connect(opts) ⇒ Object
Connect to a vSphere SDK endpoint
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/rbvmomi/vim.rb', line 21 def self.connect opts fail unless opts.is_a? Hash fail "host option required" unless opts[:host] opts[:cookie] ||= nil opts[:user] ||= 'root' opts[:password] ||= '' opts[:ssl] = true unless opts.member? :ssl or opts[:"no-ssl"] opts[:insecure] ||= false opts[:port] ||= (opts[:ssl] ? 443 : 80) opts[:path] ||= '/sdk' opts[:ns] ||= 'urn:vim25' rev_given = opts[:rev] != nil opts[:rev] = '4.0' unless rev_given opts[:debug] = (!ENV['RBVMOMI_DEBUG'].empty? rescue false) unless opts.member? :debug new(opts).tap do |vim| unless opts[:cookie] vim.serviceContent.sessionManager.Login :userName => opts[:user], :password => opts[:password] end unless rev_given rev = vim.serviceContent.about.apiVersion vim.rev = [rev, '5.5'].min end end end |
Instance Method Details
#close ⇒ Object
47 48 49 50 51 |
# File 'lib/rbvmomi/vim.rb', line 47 def close VIM::SessionManager(self, 'SessionManager').Logout rescue RbVmomi::Fault self. = nil super end |
#get_log_keys(host = nil) ⇒ Object
113 114 115 116 117 118 119 120 |
# File 'lib/rbvmomi/vim.rb', line 113 def get_log_keys host=nil diagMgr = self.serviceContent.diagnosticManager keys = [] diagMgr.QueryDescriptions(:host => host).each do |desc| keys << "#{desc.key}" end keys end |
#get_log_lines(logKey, lines = 5, start = nil, host = nil) ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 |
# File 'lib/rbvmomi/vim.rb', line 97 def get_log_lines logKey, lines=5, start=nil, host=nil diagMgr = self.serviceContent.diagnosticManager if !start log = diagMgr.BrowseDiagnosticLog(:host => host, :key => logKey, :start => 999999999) lineEnd = log.lineEnd start = lineEnd - lines end start = start < 0 ? 0 : start log = diagMgr.BrowseDiagnosticLog(:host => host, :key => logKey, :start => start) if log.lineText.size > 0 [log.lineText.slice(-lines, log.lineText.size), log.lineEnd] else [log.lineText, log.lineEnd] end end |
#instanceUuid ⇒ Object
93 94 95 |
# File 'lib/rbvmomi/vim.rb', line 93 def instanceUuid serviceContent.about.instanceUuid end |
#propertyCollector ⇒ Object
Alias to serviceContent.propertyCollector
79 80 81 |
# File 'lib/rbvmomi/vim.rb', line 79 def propertyCollector serviceContent.propertyCollector end |
#rev=(x) ⇒ Object
53 54 55 56 |
# File 'lib/rbvmomi/vim.rb', line 53 def rev= x super @serviceContent = nil end |
#rootFolder ⇒ Object Also known as: root
Alias to serviceContent.rootFolder
72 73 74 |
# File 'lib/rbvmomi/vim.rb', line 72 def rootFolder serviceContent.rootFolder end |
#searchIndex ⇒ Object
Alias to serviceContent.searchIndex
84 85 86 |
# File 'lib/rbvmomi/vim.rb', line 84 def searchIndex serviceContent.searchIndex end |
#serviceContent ⇒ Object
Alias to serviceInstance.RetrieveServiceContent
67 68 69 |
# File 'lib/rbvmomi/vim.rb', line 67 def serviceContent @serviceContent ||= serviceInstance.RetrieveServiceContent end |
#serviceInstance ⇒ Object
Return the ServiceInstance
The ServiceInstance is the root of the vSphere inventory.
62 63 64 |
# File 'lib/rbvmomi/vim.rb', line 62 def serviceInstance VIM::ServiceInstance self, 'ServiceInstance' end |