Class: RbVmomi::VIM::Datastore::FakeDatastoreFile

Inherits:
Object
  • Object
show all
Includes:
RVC::InventoryObject
Defined in:
lib/rvc/extensions/Datastore.rb

Instance Attribute Summary collapse

Attributes included from RVC::InventoryObject

#rvc_arc, #rvc_parent

Instance Method Summary collapse

Methods included from RVC::InventoryObject

#children, included, #ls_text, #rvc_link, #rvc_path, #rvc_path_str, #rvc_relative_path, #rvc_relative_path_str, #traverse_one

Methods included from RVC::ObjectWithFields::ClassMethods

#field, #fields

Methods included from RVC::ObjectWithFields

#field, #field_properties, #perfmetrics

Constructor Details

#initialize(datastore, path, info) ⇒ FakeDatastoreFile

Returns a new instance of FakeDatastoreFile.



159
160
161
162
163
# File 'lib/rvc/extensions/Datastore.rb', line 159

def initialize datastore, path, info
  @datastore = datastore
  @path = path
  @info = info
end

Instance Attribute Details

#datastoreObject (readonly)

Returns the value of attribute datastore.



157
158
159
# File 'lib/rvc/extensions/Datastore.rb', line 157

def datastore
  @datastore
end

#pathObject (readonly)

Returns the value of attribute path.



157
158
159
# File 'lib/rvc/extensions/Datastore.rb', line 157

def path
  @path
end

Instance Method Details

#datastore_pathObject



165
166
167
168
# File 'lib/rvc/extensions/Datastore.rb', line 165

def datastore_path
  @ds_name ||= @datastore.name
  "[#{@ds_name}] #{@path}"
end

#display_infoObject



176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/rvc/extensions/Datastore.rb', line 176

def display_info
  puts "Datastore File"
  puts "datastore: #{@datastore.name}"
  puts "path: #{@path}"
  puts "size: #{@info.fileSize} bytes"
  case @info
  when RbVmomi::VIM::VmConfigFileInfo
    puts "config version: #{@info.configVersion}"
  when RbVmomi::VIM::VmDiskFileInfo
    puts "capacity: #{@info.capacityKb} KB"
    puts "hardware version: #{@info.hardwareVersion}"
    puts "controller type: #{@info.controllerType}"
    puts "thin provisioned: #{@info.thin}"
    puts "type: #{@info.diskType}"
    puts "extents:\n#{@info.diskExtents.map { |x| "  #{x}" } * "\n"}"
  end
end

#parentObject



170
171
172
173
174
# File 'lib/rvc/extensions/Datastore.rb', line 170

def parent
  els = path.split '/'
  parent_path = els[0...-1].join '/'
  RbVmomi::VIM::Datastore::FakeDatastoreFolder.new(@datastore, parent_path)
end