Class: Fog::XenServer::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/chef/provisioning/fog_driver/providers/xenserver.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#credentialsObject (readonly)

Returns the value of attribute credentials.



171
172
173
# File 'lib/chef/provisioning/fog_driver/providers/xenserver.rb', line 171

def credentials
  @credentials
end

Instance Method Details

#request(options, *params) ⇒ Object



173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
# File 'lib/chef/provisioning/fog_driver/providers/xenserver.rb', line 173

def request(options, *params)
  begin
    parser = options.delete(:parser)
    method = options.delete(:method)

    if params.empty?
      response = @factory.call_async(method, @credentials)
    else
      if params.length.eql?(1) and params.first.is_a?(Hash)
        response = @factory.call_async(method, @credentials, params.first)
      elsif params.length.eql?(2) and params.last.is_a?(Array)
        response = @factory.call_async(method, @credentials, params.first, params.last)
      else
        response = eval("@factory.call_async('#{method}', '#{@credentials}', #{params.map { |p| p.is_a?(String) ? "'#{p}'" : p }.join(',')})")
      end
    end
    raise RequestFailed.new("#{method}: " + response["ErrorDescription"].to_s) unless response["Status"].eql? "Success"
    if parser
      parser.parse(response["Value"])
      response = parser.response
    end

    response
  end
end