Class: Backends::Ec2::Base

Inherits:
Object
  • Object
show all
Includes:
Helpers::ExtensionsHelper, Helpers::JsonCollectionHelper
Defined in:
lib/backends/ec2/base.rb

Direct Known Subclasses

Compute, Network, Storage

Constant Summary collapse

API_VERSION =
'1.0.0'
IMAGE_FILTERING_POLICIES =
['all', 'only_owned', 'only_listed', 'owned_and_listed'].freeze

Instance Method Summary collapse

Methods included from Helpers::ExtensionsHelper

#read_extensions

Methods included from Helpers::JsonCollectionHelper

#read_from_json

Constructor Details

#initialize(delegated_user, options, server_properties, logger, dalli_cache) ⇒ Base


10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/backends/ec2/base.rb', line 10

def initialize(delegated_user, options, server_properties, logger, dalli_cache)
  @delegated_user = Hashie::Mash.new(delegated_user)
  @options = Hashie::Mash.new(options)
  @server_properties = Hashie::Mash.new(server_properties)
  @logger = logger || Rails.logger
  @dalli_cache = dalli_cache
  @other_backends = {}
  @ec2_client = nil

  # establish connection with AWS
  ::Aws.config[:region] = @options.aws_region || "eu-west-1"
  ::Aws.config[:endpoint] = @options.aws_endpoint unless @options.aws_endpoint.blank?
  run_authn unless Rails.env.test? # disable early auth for tests

  @options.backend_scheme ||= "http://occi.#{@server_properties.hostname || 'localhost'}"

  path = @options.fixtures_dir || ''
  read_resource_tpl_fixtures(path)

  set_image_filtering_policy
end

Instance Method Details

#add_other_backend(backend_type, backend_instance) ⇒ Object


32
33
34
35
# File 'lib/backends/ec2/base.rb', line 32

def add_other_backend(backend_type, backend_instance)
  fail 'Type and instance must be provided!' unless backend_type && backend_instance
  @other_backends[backend_type] = backend_instance
end