Sha256: b626ff0c7b0ca1a98f1c3e58cb959679c2b29c12d9b9639a625fbb295138dcae

Contents?: true

Size: 772 Bytes

Versions: 5

Compression:

Stored size: 772 Bytes

Contents

module Vcloud
  module Core
    class Vdc

      attr_reader :id

      def initialize(id)
        unless id =~ /^[-0-9a-f]+$/
          raise "vdc id : #{id} is not in correct format"
        end
        @id = id
      end

      def self.get_by_name(name)
        q = QueryRunner.new
        unless res = q.run('orgVdc', :filter => "name==#{name}")
          raise "Error finding vDC by name #{name}"
        end
        raise "vDc #{name} not found" unless res.size == 1
        return self.new(res.first[:href].split('/').last)
      end

      def vcloud_attributes
        Vcloud::Fog::ServiceInterface.new.get_vdc(id)
      end

      def name
        vcloud_attributes[:name]
      end

      def href
        vcloud_attributes[:href]
      end

    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
vcloud-core-0.1.0 lib/vcloud/core/vdc.rb
vcloud-core-0.0.13 lib/vcloud/core/vdc.rb
vcloud-core-0.0.12 lib/vcloud/core/vdc.rb
vcloud-core-0.0.11 lib/vcloud/core/vdc.rb
vcloud-core-0.0.10 lib/vcloud/core/vdc.rb