Class: Fog::Vcloud::Real

Inherits:
Object
  • Object
show all
Extended by:
Generators
Defined in:
lib/fog/vcloud.rb,
lib/fog/vcloud/models/vdcs.rb,
lib/fog/vcloud/requests/login.rb,
lib/fog/vcloud/requests/get_vdc.rb,
lib/fog/vcloud/requests/get_network.rb,
lib/fog/vcloud/requests/get_versions.rb,
lib/fog/vcloud/requests/get_organization.rb

Direct Known Subclasses

Mock

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Generators

basic_request, unauthenticated_basic_request

Constructor Details

#initialize(options = {}) ⇒ Real

Returns a new instance of Real.



54
55
56
57
58
59
60
61
62
# File 'lib/fog/vcloud.rb', line 54

def initialize(options = {})
  @connections = {}
  @versions_uri = URI.parse(options[:versions_uri])
  @module = options[:module]
  @version = options[:version]
  @username = options[:username]
  @password = options[:password]
  @persistent = options[:persistent]
end

Instance Attribute Details

#login_uri=(value) ⇒ Object

Sets the attribute login_uri

Parameters:

  • value

    the value to set the attribute login_uri to.



47
48
49
# File 'lib/fog/vcloud.rb', line 47

def (value)
  @login_uri = value
end

#versions_uriObject (readonly)

Returns the value of attribute versions_uri.



48
49
50
# File 'lib/fog/vcloud.rb', line 48

def versions_uri
  @versions_uri
end

Instance Method Details

#default_organization_uriObject



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
# File 'lib/fog/vcloud.rb', line 64

def default_organization_uri
  @default_organization_uri ||= begin
    unless @login_results
      
    end
    case @login_results.body[:Org]
    when Array
      @login_results.body[:Org].first[:href]
    when Hash
      @login_results.body[:Org][:href]
    else
      nil
    end
  end
end

#loginObject



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/fog/vcloud/requests/login.rb', line 7

def 
  unauthenticated_request({
    :expects  => 200,
    :headers  => {
      'Authorization' => authorization_header
    },
    :method   => 'POST',
    :parse    => true,
    :uri      => 
  })
end

#reloadObject



86
87
88
# File 'lib/fog/vcloud.rb', line 86

def reload
  @connections.each_value { |k,v| v.reset if v }
end

#request(params) ⇒ Object

If the cookie isn’t set, do a get_organizations call to set it and try the request. If we get an Unauthorized error, we assume the token expired, re-auth and try again



93
94
95
96
97
98
99
100
101
102
103
# File 'lib/fog/vcloud.rb', line 93

def request(params)
  unless @cookie
    
  end
  begin
    do_request(params)
  rescue Excon::Errors::Unauthorized => e
    
    do_request(params)
  end
end

#supported_versionsObject



105
106
107
# File 'lib/fog/vcloud.rb', line 105

def supported_versions
  @supported_versions ||= get_versions(@versions_uri).body[:VersionInfo]
end

#supporting_versionsObject



50
51
52
# File 'lib/fog/vcloud.rb', line 50

def supporting_versions
  ["v0.8"]
end

#vdcs(options = {}) ⇒ Object



5
6
7
# File 'lib/fog/vcloud/models/vdcs.rb', line 5

def vdcs(options = {})
  @vdcs ||= Fog::Vcloud::Vdcs.new(options.merge(:connection => self))
end

#xmlnsObject



80
81
82
83
84
# File 'lib/fog/vcloud.rb', line 80

def xmlns
  { "xmlns" => "http://www.vmware.com/vcloud/v0.8",
    "xmlns:xsi" => "http://www.w3.org/2001/XMLSchema-instance",
    "xmlns:xsd" => "http://www.w3.org/2001/XMLSchema" }
end