Class: Fog::Terremark::Vcloud::Real

Inherits:
Object
  • Object
show all
Includes:
Shared::Parser, Shared::Real
Defined in:
lib/fog/terremark/vcloud.rb

Instance Method Summary collapse

Methods included from Shared::Parser

#parse

Methods included from Shared::Real

#add_internet_service, #add_node_service, #addresses, #configure_vapp, #create_internet_service, #delete_internet_service, #delete_node_service, #delete_public_ip, #delete_vapp, #deploy_vapp, #get_catalog, #get_catalog_item, #get_internet_services, #get_keys_list, #get_network, #get_network_ips, #get_node_services, #get_organization, #get_organizations, #get_public_ip, #get_public_ips, #get_task, #get_tasks_list, #get_vapp, #get_vapp_template, #get_vdc, #images, #instantiate_vapp_template, #internetservices, #networks, #nodeservices, #power_off, #power_on, #power_reset, #power_shutdown, #servers, #tasks, #vdcs

Methods included from Shared::Common

#default_organization_id

Constructor Details

#initialize(options = {}) ⇒ Real

Returns a new instance of Real.



40
41
42
43
44
45
46
47
48
49
50
# File 'lib/fog/terremark/vcloud.rb', line 40

def initialize(options={})
  @terremark_password = options[:terremark_vcloud_password]
  @terremark_username = options[:terremark_vcloud_username]
  @connection_options = options[:connection_options] || {}
  @host       = options[:host]        || Fog::Terremark::Vcloud::Defaults::HOST
  @path       = options[:path]        || Fog::Terremark::Vcloud::Defaults::PATH
  @persistent = options[:persistent]  || false
  @port       = options[:port]        || Fog::Terremark::Vcloud::Defaults::PORT
  @scheme     = options[:scheme]      || Fog::Terremark::Vcloud::Defaults::SCHEME
  @connection = Fog::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end

Instance Method Details

#default_network_idObject



69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/fog/terremark/vcloud.rb', line 69

def default_network_id
  if default_vdc_id
    @default_network_id ||= begin
      networks = get_vdc(default_vdc_id).body['AvailableNetworks']
      if networks.length == 1
        networks.first['href'].split('/').last.to_i
      else
        nil
      end
    end
  else
    nil
  end
end

#default_public_ip_idObject



84
85
86
87
88
89
90
91
92
93
94
95
96
97
# File 'lib/fog/terremark/vcloud.rb', line 84

def default_public_ip_id
  if default_vdc_id
    @default_public_ip_id ||= begin
      ips = get_public_ips(default_vdc_id).body['PublicIpAddresses']
      if ips.length == 1
        ips.first['href'].split('/').last.to_i
      else
        nil
      end
    end
  else
    nil
  end
end

#default_vdc_idObject



52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/fog/terremark/vcloud.rb', line 52

def default_vdc_id
  if default_organization_id
    @default_vdc_id ||= begin
      vdcs = get_organization(default_organization_id).body['Links'].select {|link|
        link['type'] == 'application/vnd.vmware.vcloud.vdc+xml'
      }
      if vdcs.length == 1
        vdcs.first['href'].split('/').last.to_i
      else
        nil
      end
    end
  else
    nil
  end
end