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
-
#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
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/rbvmomi/vim.rb', line 20 def self.connect opts fail unless opts.is_a? Hash fail "host option required" unless opts[:host] 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| vim.serviceContent.sessionManager.Login :userName => opts[:user], :password => opts[:password] unless rev_given rev = vim.serviceContent.about.apiVersion vim.rev = [rev, '5.0'].min end end end |
Instance Method Details
#close ⇒ Object
43 44 45 46 47 |
# File 'lib/rbvmomi/vim.rb', line 43 def close VIM::SessionManager(self, 'SessionManager').Logout rescue RbVmomi::Fault self. = nil super end |
#propertyCollector ⇒ Object
Alias to serviceContent.propertyCollector
75 76 77 |
# File 'lib/rbvmomi/vim.rb', line 75 def propertyCollector serviceContent.propertyCollector end |
#rev=(x) ⇒ Object
49 50 51 52 |
# File 'lib/rbvmomi/vim.rb', line 49 def rev= x super @serviceContent = nil end |
#rootFolder ⇒ Object Also known as: root
Alias to serviceContent.rootFolder
68 69 70 |
# File 'lib/rbvmomi/vim.rb', line 68 def rootFolder serviceContent.rootFolder end |
#searchIndex ⇒ Object
Alias to serviceContent.searchIndex
80 81 82 |
# File 'lib/rbvmomi/vim.rb', line 80 def searchIndex serviceContent.searchIndex end |
#serviceContent ⇒ Object
Alias to serviceInstance.RetrieveServiceContent
63 64 65 |
# File 'lib/rbvmomi/vim.rb', line 63 def serviceContent @serviceContent ||= serviceInstance.RetrieveServiceContent end |
#serviceInstance ⇒ Object
Return the ServiceInstance
The ServiceInstance is the root of the vSphere inventory.
58 59 60 |
# File 'lib/rbvmomi/vim.rb', line 58 def serviceInstance VIM::ServiceInstance self, 'ServiceInstance' end |