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

Inherits:
Compute::Terremark::Real
  • Object
show all
Defined in:
lib/fog/terremark/vcloud/real.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) ⇒ Real

Returns a new instance of Real.



5
6
7
8
9
10
11
12
13
14
15
# File 'lib/fog/terremark/vcloud/real.rb', line 5

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::HOST
  @path       = options[:path]        || Fog::Terremark::Vcloud::PATH
  @persistent = options[:persistent]  || false
  @port       = options[:port]        || Fog::Terremark::Vcloud::PORT
  @scheme     = options[:scheme]      || Fog::Terremark::Vcloud::SCHEME
  @connection = Fog::XML::Connection.new("#{@scheme}://#{@host}:#{@port}", @persistent, @connection_options)
end

Instance Method Details

#default_network_idObject



34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/fog/terremark/vcloud/real.rb', line 34

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



49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/fog/terremark/vcloud/real.rb', line 49

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



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/fog/terremark/vcloud/real.rb', line 17

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