Class: Vcloud::Fog::ModelInterface

Inherits:
Object
  • Object
show all
Defined in:
lib/vcloud/fog/model_interface.rb

Instance Method Summary collapse

Constructor Details

#initializeModelInterface

Returns a new instance of ModelInterface.



4
5
6
# File 'lib/vcloud/fog/model_interface.rb', line 4

def initialize
  @vcloud = ::Fog::Compute::VcloudDirector.new
end

Instance Method Details

#current_organizationObject



12
13
14
# File 'lib/vcloud/fog/model_interface.rb', line 12

def current_organization
  @vcloud.organizations.get_by_name org_name
end

#current_vdc(vdc_id) ⇒ Object



16
17
18
# File 'lib/vcloud/fog/model_interface.rb', line 16

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

#get_vm_by_href(href) ⇒ Object



20
21
22
23
24
25
26
27
28
29
# File 'lib/vcloud/fog/model_interface.rb', line 20

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

#org_nameObject



8
9
10
# File 'lib/vcloud/fog/model_interface.rb', line 8

def org_name
  @vcloud.org_name
end