Class: DeltacloudVM::Client::Driver

Inherits:
Base
  • Object
show all
Defined in:
lib/deltacloud_vm/client/models/driver.rb

Defined Under Namespace

Classes: Provider

Instance Attribute Summary collapse

Attributes inherited from Base

#description, #name, #obj_id, #url

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#client, #connection, convert, #entrypoint, from_collection, #id, #initialize, #original_body, #to_s, #update_instance_variables!, validate_attrs!

Methods included from Helpers::XmlHelper

#extract_xml_body

Methods included from Methods::Api

#api_uri, #current_driver, #current_provider, #feature?, #features, #must_support!, #path, #support?, #supported_collections, #version

Methods included from Helpers::Model

#error, #from_collection, #from_resource, #model

Constructor Details

This class inherits a constructor from DeltacloudVM::Client::Base

Instance Attribute Details

#providersObject (readonly)

Returns the value of attribute providers.



20
21
22
# File 'lib/deltacloud_vm/client/models/driver.rb', line 20

def providers
  @providers
end

Class Method Details

.parse(xml_body) ⇒ Object



36
37
38
39
40
# File 'lib/deltacloud_vm/client/models/driver.rb', line 36

def self.parse(xml_body)
  {
    :providers => xml_body.xpath('provider').map { |p| Provider.parse(p) }
  }
end

Instance Method Details

#[](provider_id) ⇒ Object

Syntax sugar for returning provider from Driver instance:

client.driver(:ec2) # => List of endpoints

  • provider_id -> Provider ID, like ‘us-west-1’



29
30
31
32
33
34
# File 'lib/deltacloud_vm/client/models/driver.rb', line 29

def [](provider_id)
  @providers ||= []
  prov = @providers.find { |p| p.name == provider_id }
  prov.instance_variable_set('@client', @client)
  prov
end