Class: RbVmomi::VIM::ManagedObject
- Inherits:
-
Object
- Object
- RbVmomi::VIM::ManagedObject
- Defined in:
- lib/rbvmomi/vim/ManagedObject.rb
Overview
Copyright © 2011-2017 VMware, Inc. All Rights Reserved. SPDX-License-Identifier: MIT
Instance Method Summary collapse
-
#collect(*pathSet) {|*values| ... } ⇒ Array
Efficiently retrieve multiple properties from an object.
-
#collect!(*pathSet) ⇒ Hash
Efficiently retrieve multiple properties from an object.
-
#wait_until(*pathSet) { ... } ⇒ Object
Wait for updates on an object until a condition becomes true.
Instance Method Details
#collect(*pathSet) {|*values| ... } ⇒ Array
Efficiently retrieve multiple properties from an object.
55 56 57 58 59 60 61 62 63 |
# File 'lib/rbvmomi/vim/ManagedObject.rb', line 55 def collect *pathSet h = collect!(*pathSet) a = pathSet.map { |k| h[k.to_s] } if block_given? yield a else a end end |
#collect!(*pathSet) ⇒ Hash
Efficiently retrieve multiple properties from an object.
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/rbvmomi/vim/ManagedObject.rb', line 34 def collect! *pathSet spec = { objectSet: [{ obj: self }], propSet: [{ pathSet: pathSet, type: self.class.wsdl_name }] } ret = _connection.propertyCollector.RetrieveProperties(specSet: [spec]) if ret && ret.length > 0 ret[0].to_hash else {} end end |
#wait_until(*pathSet) { ... } ⇒ Object
TODO:
Pass the current property values to the block.
Wait for updates on an object until a condition becomes true.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rbvmomi/vim/ManagedObject.rb', line 13 def wait_until *pathSet, &b all = pathSet.empty? filter = _connection.propertyCollector.CreateFilter spec: { propSet: [{ type: self.class.wsdl_name, all: all, pathSet: pathSet }], objectSet: [{ obj: self }], }, partialUpdates: false ver = '' loop do result = _connection.propertyCollector.WaitForUpdates(version: ver) ver = result.version if x = b.call return x end end ensure filter.DestroyPropertyFilter if filter end |