Sha256: 9231ba9cbc63d3a8a1e2fea080a7937fc5c3a7671993f06edf31caef834badaf

Contents?: true

Size: 753 Bytes

Versions: 20

Compression:

Stored size: 753 Bytes

Contents

module Vcloud
  module Fog
    class ModelInterface
      def initialize
        @vcloud = ::Fog::Compute::VcloudDirector.new
      end

      def org_name
        @vcloud.org_name
      end

      def current_organization
        @vcloud.organizations.get_by_name org_name
      end

      def current_vdc vdc_id
        current_organization.vdcs.detect { |v| v.id == vdc_id }
      end

      def get_vm_by_href href
        vm = @vcloud.get_vms_in_lease_from_query(
            {
                :filter => "href==#{href}"
            }).body[:VMRecord].first
        return nil unless vm
        vdc = current_vdc(vm[:vdc].split('/').last)
        vapp = vdc.vapps.get_by_name(vm[:containerName])
        vapp.vms.first
      end

    end
  end
end

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
vcloud-core-0.7.0 lib/vcloud/fog/model_interface.rb
vcloud-core-0.6.0 lib/vcloud/fog/model_interface.rb
vcloud-core-0.5.0 lib/vcloud/fog/model_interface.rb
vcloud-core-0.4.0 lib/vcloud/fog/model_interface.rb
vcloud-core-0.3.0 lib/vcloud/fog/model_interface.rb
vcloud-core-0.2.0 lib/vcloud/fog/model_interface.rb
vcloud-core-0.1.0 lib/vcloud/fog/model_interface.rb
vcloud-core-0.0.13 lib/vcloud/fog/model_interface.rb
vcloud-core-0.0.12 lib/vcloud/fog/model_interface.rb
vcloud-core-0.0.11 lib/vcloud/fog/model_interface.rb
vcloud-core-0.0.10 lib/vcloud/fog/model_interface.rb
vcloud-core-0.0.9 lib/vcloud/fog/model_interface.rb
vcloud-core-0.0.8 lib/vcloud/fog/model_interface.rb
vcloud-core-0.0.7 lib/vcloud/fog/model_interface.rb
vcloud-core-0.0.6 lib/vcloud/fog/model_interface.rb
vcloud-core-0.0.5 lib/vcloud/fog/model_interface.rb
vcloud-core-0.0.4 lib/vcloud/fog/model_interface.rb
vcloud-core-0.0.3 lib/vcloud/fog/model_interface.rb
vcloud-core-0.0.2 lib/vcloud/fog/model_interface.rb
vcloud-core-0.0.1 lib/vcloud/fog/model_interface.rb