Class: Fog::TerremarkEcloud::Compute::Real
- Inherits:
-
Object
- Object
- Fog::TerremarkEcloud::Compute::Real
- Defined in:
- lib/fog/compute/terremark_ecloud.rb,
lib/fog/compute/requests/terremark_ecloud/get_vdc.rb,
lib/fog/compute/requests/terremark_ecloud/get_catalog.rb,
lib/fog/compute/requests/terremark_ecloud/get_network.rb,
lib/fog/compute/requests/terremark_ecloud/get_versions.rb,
lib/fog/compute/requests/terremark_ecloud/get_catalog_item.rb,
lib/fog/compute/requests/terremark_ecloud/get_ip_addresses.rb,
lib/fog/compute/requests/terremark_ecloud/get_organization.rb
Instance Method Summary collapse
- #get_catalog(href) ⇒ Object
- #get_catalog_item(href) ⇒ Object
- #get_ip_addresses(href) ⇒ Object
- #get_network(href) ⇒ Object
- #get_organization(href = organization_href) ⇒ Object
- #get_vdc(href) ⇒ Object
- #get_versions ⇒ Object
-
#initialize(options = {}) ⇒ Real
constructor
A new instance of Real.
- #organization_href ⇒ Object
- #request(params) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Real
Returns a new instance of Real.
31 32 33 34 35 36 37 38 39 |
# File 'lib/fog/compute/terremark_ecloud.rb', line 31 def initialize( = {}) require 'fog/compute/parsers/terremark_ecloud/get_versions' require 'fog/compute/parsers/terremark_ecloud/login' @username = [:terremark_ecloud_username] @password = [:terremark_ecloud_password] @version = '0.8b-ext2.6' @versions_endpoint = [:versions_endpoint] || 'https://services.enterprisecloud.terremark.com/api/versions' end |
Instance Method Details
#get_catalog(href) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/fog/compute/requests/terremark_ecloud/get_catalog.rb', line 8 def get_catalog(href) request({ :href => href, :idempotent => true, :parser => Fog::Parsers::TerremarkEcloud::Compute::GetCatalog.new }) end |
#get_catalog_item(href) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/fog/compute/requests/terremark_ecloud/get_catalog_item.rb', line 8 def get_catalog_item(href) request({ :href => href, :idempotent => true, :parser => Fog::Parsers::TerremarkEcloud::Compute::GetCatalogItem.new }) end |
#get_ip_addresses(href) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/fog/compute/requests/terremark_ecloud/get_ip_addresses.rb', line 8 def get_ip_addresses(href) request({ :href => href, :idempotent => true, :parser => Fog::Parsers::TerremarkEcloud::Compute::GetIpAddresses.new }) end |
#get_network(href) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/fog/compute/requests/terremark_ecloud/get_network.rb', line 8 def get_network(href) request({ :href => href, :idempotent => true, :parser => Fog::Parsers::TerremarkEcloud::Compute::GetNetwork.new }) end |
#get_organization(href = organization_href) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/fog/compute/requests/terremark_ecloud/get_organization.rb', line 8 def get_organization(href = organization_href) request({ :href => href, :idempotent => true, :parser => Fog::Parsers::TerremarkEcloud::Compute::GetOrganization.new }) end |
#get_vdc(href) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/fog/compute/requests/terremark_ecloud/get_vdc.rb', line 8 def get_vdc(href) request({ :href => href, :idempotent => true, :parser => Fog::Parsers::TerremarkEcloud::Compute::GetVdc.new }) end |
#get_versions ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'lib/fog/compute/requests/terremark_ecloud/get_versions.rb', line 8 def get_versions connection = Fog::Connection.new(@versions_endpoint) response = connection.request({ :expects => 200, :method => 'GET', :parser => Fog::Parsers::TerremarkEcloud::Compute::GetVersions.new }); version_info = response.body['SupportedVersions'].detect {|version_info| version_info['Version'] == @version} unless login_url = version_info && version_info['LoginUrl'] raise "TerremarkEcloud does not support version #{@version}" end end |
#organization_href ⇒ Object
41 42 43 44 45 46 |
# File 'lib/fog/compute/terremark_ecloud.rb', line 41 def organization_href unless @organization_href get_token_and_organization end @organization_href end |
#request(params) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/fog/compute/terremark_ecloud.rb', line 48 def request(params) raise ArgumentError.new('Need :href in params') unless params[:href] # set auth token if @token.nil? get_token_and_organization end begin Fog::Connection.new(params[:href]).request({ :parser => params[:parser], :expects => params[:expects] || 200, :method => params[:method] || 'GET', :body => params[:body], :headers => { 'Cookie' => @token }.merge(params[:headers] || {}) }) rescue Excon::Errors::Unauthorized # expired token get_token_and_organization retry end end |