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.
54 55 56 57 58 59 60 61 62 |
# File 'lib/rbvmomi/vim/ManagedObject.rb', line 54 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.
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/rbvmomi/vim/ManagedObject.rb', line 33 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.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/rbvmomi/vim/ManagedObject.rb', line 12 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 |