Class: VCenterDriver::VirtualMachineFolder
- Inherits:
-
Object
- Object
- VCenterDriver::VirtualMachineFolder
- Defined in:
- lib/vm_folder.rb
Overview
VirtualMachineFolder class
Instance Attribute Summary collapse
-
#item ⇒ Object
Returns the value of attribute item.
-
#items ⇒ Object
Returns the value of attribute items.
Instance Method Summary collapse
-
#fetch! ⇒ Hash
Builds a hash with Datastore-Ref / Datastore to be used as a cache.
- #fetch_templates! ⇒ Object
-
#get(ref) ⇒ Object
Returns a Datastore.
-
#initialize(item) ⇒ VirtualMachineFolder
constructor
A new instance of VirtualMachineFolder.
Constructor Details
#initialize(item) ⇒ VirtualMachineFolder
Returns a new instance of VirtualMachineFolder.
24 25 26 27 28 |
# File 'lib/vm_folder.rb', line 24 def initialize(item) @item = item check_item(@item, nil) @items = {} end |
Instance Attribute Details
#item ⇒ Object
Returns the value of attribute item.
22 23 24 |
# File 'lib/vm_folder.rb', line 22 def item @item end |
#items ⇒ Object
Returns the value of attribute items.
22 23 24 |
# File 'lib/vm_folder.rb', line 22 def items @items end |
Instance Method Details
#fetch! ⇒ Hash
Builds a hash with Datastore-Ref / Datastore to be used as a cache
36 37 38 39 40 41 |
# File 'lib/vm_folder.rb', line 36 def fetch! VIClient.get_entities(@item, 'VirtualMachine').each do |item| item_name = item._ref @items[item_name.to_sym] = VirtualMachine.new_with_item(item) end end |
#fetch_templates! ⇒ Object
43 44 45 46 47 48 49 50 |
# File 'lib/vm_folder.rb', line 43 def fetch_templates! VIClient.get_entities(@item, 'VirtualMachine').each do |item| if item.config.template item_name = item._ref @items[item_name.to_sym] = Template.new(item) end end end |
#get(ref) ⇒ Object
Returns a Datastore. Uses the cache if available.
58 59 60 61 62 63 64 65 |
# File 'lib/vm_folder.rb', line 58 def get(ref) if !@items[ref.to_sym] rbvmomi_dc = RbVmomi::VIM::Datastore.new(@item._connection, ref) @items[ref.to_sym] = Datastore.new(rbvmomi_dc) end @items[ref.to_sym] end |