Sha256: 073a479f6b25d9e0d88c0f1c99757569fa32dfe49359f5b4898cd8225f1c9599

Contents?: true

Size: 1.56 KB

Versions: 22

Compression:

Stored size: 1.56 KB

Contents

module VirtualBox
  # Represents a description of a virtual system in an {Appliance}. This contains
  # the values that are in the OVF files as well as recommend values from VirtualBox.
  class VirtualSystemDescription < AbstractModel
    attribute :interface, :readonly => true
    attribute :descriptions, :readonly => true, :default => {}

    class << self
      def populate_relationship(caller, data)
        result = Proxies::Collection.new(caller)

        data.each do |vsd|
          result << new(vsd)
        end

        result
      end
    end

    def initialize(ivsd)
      write_attribute(:interface, ivsd)
      initialize_attributes(ivsd)
    end

    def initialize_attributes(ivsd)
      # Grab all the descriptions, iterate over each, and add to the hash of
      # descriptions. This multiple loop method is used instead of `get_description` since
      # that method doesn't work well with MSCOM.
      COM::Util.versioned_interface(:VirtualSystemDescriptionType).each_with_index do |type, index|
        COM::Util.versioned_interface(:VirtualSystemDescriptionValueType).each_with_index do |value_type, value_index|
          value = ivsd.get_values_by_type(type, value_type)
          if value && value != [] && value != [nil]
            descriptions[type] ||= {}
            descriptions[type][value_type] = value.first
          end
        end
      end

      # Clear dirtiness, since this should only be called initially and
      # therefore shouldn't affect dirtiness
      clear_dirty!

      # But this is an existing record
      existing_record!
    end
  end
end

Version data entries

22 entries across 22 versions & 3 rubygems

Version Path
virtualbox-0.9.2 lib/virtualbox/virtual_system_description.rb
virtualbox-0.9.1 lib/virtualbox/virtual_system_description.rb
virtualbox-0.9.0 lib/virtualbox/virtual_system_description.rb
virtualbox-0.8.6 lib/virtualbox/virtual_system_description.rb
virtualbox-0.8.5 lib/virtualbox/virtual_system_description.rb
virtualbox-0.8.4 lib/virtualbox/virtual_system_description.rb
velir_virtualbox-0.8.4 lib/virtualbox/virtual_system_description.rb
virtualbox-0.8.3 lib/virtualbox/virtual_system_description.rb
virtualbox-0.8.2 lib/virtualbox/virtual_system_description.rb
virtualbox-0.8.1 lib/virtualbox/virtual_system_description.rb
virtualbox-0.8.0 lib/virtualbox/virtual_system_description.rb
virtualbox-0.7.9 lib/virtualbox/virtual_system_description.rb
virtualbox-0.7.8 lib/virtualbox/virtual_system_description.rb
virtualbox-0.7.7 lib/virtualbox/virtual_system_description.rb
virtualbox-0.7.6 lib/virtualbox/virtual_system_description.rb
bbrowning-virtualbox-0.7.6.dev lib/virtualbox/virtual_system_description.rb
virtualbox-0.7.5 lib/virtualbox/virtual_system_description.rb
virtualbox-0.7.4 lib/virtualbox/virtual_system_description.rb
virtualbox-0.7.3 lib/virtualbox/virtual_system_description.rb
virtualbox-0.7.2 lib/virtualbox/virtual_system_description.rb