Sha256: 9f951e43ca4e7076ef416d94424d2b63df2797323ea5f65156d16c32d293015d

Contents?: true

Size: 1.33 KB

Versions: 14

Compression:

Stored size: 1.33 KB

Contents

module Vcloud
  module Core
    class Vdc

      attr_reader :id

      # Initialize a Vcloud::Core::Vdc
      #
      # @param id [String] the vDC ID
      # @return [Vcloud::Core::Vdc]
      def initialize(id)
        unless id =~ /^[-0-9a-f]+$/
          raise "vdc id : #{id} is not in correct format"
        end
        @id = id
      end

      # Get the ID of a named vDC
      #
      # @param name [String] The name of the vDC
      # @return [String] The ID of the vDC
      def self.get_by_name(name)
        q = Vcloud::Core::QueryRunner.new
        query_results = q.run('orgVdc', :filter => "name==#{name}")
        raise "Error finding vDC by name #{name}" unless query_results
        raise "vDc #{name} not found" unless query_results.size == 1
        return self.new(query_results.first[:href].split('/').last)
      end

      # Return the vCloud data associated with vDC
      #
      # @return [Hash] the complete vCloud data for vDC
      def vcloud_attributes
        Vcloud::Core::Fog::ServiceInterface.new.get_vdc(id)
      end

      # Return the name of vDC
      #
      # @return [String] the name of instance
      def name
        vcloud_attributes[:name]
      end

      # Return the href of vDC
      #
      # @return [String] the href of instance
      def href
        vcloud_attributes[:href]
      end

    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
vcloud-core-2.2.0 lib/vcloud/core/vdc.rb
vcloud-core-2.1.1 lib/vcloud/core/vdc.rb
vcloud-core-2.1.0 lib/vcloud/core/vdc.rb
vcloud-core-2.0.1 lib/vcloud/core/vdc.rb
vcloud-core-2.0.0 lib/vcloud/core/vdc.rb
vcloud-core-1.2.0 lib/vcloud/core/vdc.rb
vcloud-core-1.1.0 lib/vcloud/core/vdc.rb
vcloud-core-1.0.2 lib/vcloud/core/vdc.rb
vcloud-core-1.0.1 lib/vcloud/core/vdc.rb
vcloud-core-1.0.0 lib/vcloud/core/vdc.rb
vcloud-core-0.16.1 lib/vcloud/core/vdc.rb
vcloud-core-0.16.0 lib/vcloud/core/vdc.rb
vcloud-core-0.15.0 lib/vcloud/core/vdc.rb
vcloud-core-0.14.0 lib/vcloud/core/vdc.rb