class VCloudSdk::OVFDirectory

Public Class Methods

new(directory) click to toggle source
# File lib/ruby_vcloud_sdk/ovf_directory.rb, line 4
def initialize(directory)
  raise CloudError, "Requires string-like object for directory" unless
    directory.respond_to?(:to_s)
  @directory = directory
  @logger = Config.logger

  # Quick sanity check.  Raise an exception if OVF file not there
  self.ovf_file
end

Public Instance Methods

ovf_file() click to toggle source
# File lib/ruby_vcloud_sdk/ovf_directory.rb, line 27
def ovf_file
  File.new(ovf_file_path)
end
ovf_file_path() click to toggle source
# File lib/ruby_vcloud_sdk/ovf_directory.rb, line 14
def ovf_file_path
  ovf_files = Dir[File.join(@directory, "*.ovf")]
  if ovf_files.length > 1
    @logger.error "More than one OVF file found in dir #{@directory}"
    raise "More than one OVF file found in directory #{@directory}"
  end
  if ovf_files.length < 1
    @logger.error "No OVF file found in directory #{@directory}"
    raise "No OVF file found in directory #{@directory}"
  end
  ovf_files.pop
end
vmdk_file(filename) click to toggle source
# File lib/ruby_vcloud_sdk/ovf_directory.rb, line 40
def vmdk_file(filename)
  File.new(self.vmdk_file_path(filename), "rb")
end
vmdk_file_path(filename) click to toggle source
# File lib/ruby_vcloud_sdk/ovf_directory.rb, line 31
def vmdk_file_path(filename)
  file_path = File.join(@directory, filename)
  unless File.exist? file_path
    @logger.error "#{filename} not found in #{@directory}"
    raise "#{filename} not found in #{@directory}"
  end
  file_path
end