Module: Deltacloud

Defined in:
lib/drivers.rb,
lib/deltacloud/state_machine.rb,
lib/deltacloud/hardware_profile.rb,
lib/deltacloud/base_driver/features.rb,
lib/deltacloud/drivers/ec2/ec2_driver.rb,
lib/deltacloud/base_driver/base_driver.rb,
lib/deltacloud/drivers/mock/mock_driver.rb,
lib/deltacloud/drivers/azure/azure_driver.rb,
lib/deltacloud/drivers/rhevm/rhevm_driver.rb,
lib/deltacloud/drivers/gogrid/gogrid_driver.rb,
lib/deltacloud/drivers/rackspace/rackspace_client.rb,
lib/deltacloud/drivers/rackspace/rackspace_driver.rb,
lib/deltacloud/drivers/terremark/terremark_driver.rb,
lib/deltacloud/drivers/opennebula/opennebula_driver.rb,
lib/deltacloud/drivers/rimuhosting/rimuhosting_client.rb,
lib/deltacloud/drivers/rimuhosting/rimuhosting_driver.rb

Overview

author: Michael Neale TODO: catch generic errors in JSON response and throw (probably)

Defined Under Namespace

Modules: BackendCapability, Drivers, Validation Classes: AuthException, BackendError, BackendFeatureUnsupported, BaseDriver, DuplicateFeatureDeclError, FeatureError, HardwareProfile, StateMachine, UndeclaredFeatureError

Constant Summary collapse

DRIVERS =
{
  :ec2 => { :name => "EC2" },
  :rackspace => { :name => "Rackspace" },
  :gogrid => { :name => "Gogrid" },
  :rhevm => { :name => "RHEVM" },
  :rimuhosting => { :name => "RimuHosting"},
  :opennebula => { :name => "Opennebula", :class => "OpennebulaDriver" },
  :terremark => { :name => "Terremark"},
  :azure => { :name => "Azure" },
  :mock => { :name => "Mock" }
}
DEFAULT_COLLECTIONS =
[
  :hardware_profiles,
  :images,
  :instances,
  :instance_states,
  :realms,
  :storage_volumes,
  :storage_snapshots
]
DRIVER =
ENV['API_DRIVER'] ? ENV['API_DRIVER'].to_sym : :mock

Instance Method Summary collapse

Instance Method Details

#driverObject



65
66
67
68
69
70
71
72
73
74
# File 'lib/drivers.rb', line 65

def driver
  require driver_source_name
  #require 'deltacloud/base_driver/mock_driver.rb'

  if Sinatra::Application.environment.eql? :test
    require driver_mock_source_name if driver_mock_source_name
  end

  @driver ||= eval( driver_class_name ).new
end

#driver_class_nameObject



51
52
53
54
# File 'lib/drivers.rb', line 51

def driver_class_name
  basename = DRIVERS[:"#{driver_symbol}"][:class] || "#{driver_name}Driver"
  "Deltacloud::Drivers::#{driver_name}::#{basename}"
end

#driver_mock_source_nameObject



60
61
62
63
# File 'lib/drivers.rb', line 60

def driver_mock_source_name
  return File.join('deltacloud', 'drivers', "#{driver_symbol}", 
                   "#{driver_symbol}_driver.rb") if driver_name.eql? 'Mock'
end

#driver_nameObject



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

def driver_name
  DRIVERS[:"#{driver_symbol}"][:name]
end

#driver_source_nameObject



56
57
58
# File 'lib/drivers.rb', line 56

def driver_source_name
  File.join("deltacloud", "drivers", "#{driver_symbol}", "#{driver_symbol}_driver.rb")
end

#driver_symbolObject



43
44
45
# File 'lib/drivers.rb', line 43

def driver_symbol
  (Thread.current[:driver] || DRIVER).to_sym
end