Class: VCenterDriver::DatastoreFolder
- Inherits:
-
Object
- Object
- VCenterDriver::DatastoreFolder
- Defined in:
- lib/datastore.rb
Overview
Class DatastoreFolder
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.
-
#get(ref) ⇒ Object
Returns a Datastore or StoragePod.
-
#initialize(item) ⇒ DatastoreFolder
constructor
A new instance of DatastoreFolder.
Constructor Details
#initialize(item) ⇒ DatastoreFolder
Returns a new instance of DatastoreFolder.
45 46 47 48 |
# File 'lib/datastore.rb', line 45 def initialize(item) @item = item @items = {} end |
Instance Attribute Details
#item ⇒ Object
Returns the value of attribute item.
43 44 45 |
# File 'lib/datastore.rb', line 43 def item @item end |
#items ⇒ Object
Returns the value of attribute items.
43 44 45 |
# File 'lib/datastore.rb', line 43 def items @items end |
Instance Method Details
#fetch! ⇒ Hash
Builds a hash with Datastore-Ref / Datastore to be used as a cache
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/datastore.rb', line 55 def fetch! VIClient.get_entities(@item, 'Datastore').each do |item| item_name = item._ref @items[item_name.to_sym] = Datastore.new(item) end VIClient.get_entities(@item, 'StoragePod').each do |sp| @items[sp._ref.to_sym] = StoragePod.new(sp) VIClient.get_entities(sp, 'Datastore').each do |item| item_name = item._ref @items[item_name.to_sym] = Datastore.new(item) end end @items end |
#get(ref) ⇒ Object
Returns a Datastore or StoragePod. Uses the cache if available.
76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 |
# File 'lib/datastore.rb', line 76 def get(ref) if !@items[ref.to_sym] if ref.start_with?('group-') rbvmomi_spod = RbVmomi::VIM::StoragePod .new( @item._connection, ref ) rescue nil @items[ref.to_sym] = StoragePod.new(rbvmomi_spod) else rbvmomi_ds = RbVmomi::VIM::Datastore .new( @item._connection, ref ) rescue nil @items[ref.to_sym] = Datastore.new(rbvmomi_ds) end end @items[ref.to_sym] end |