Module: Miasma::Contrib::OpenStackApiCore::ApiCommon

Included in:
Models::Compute::OpenStack, Models::Orchestration::OpenStack
Defined in:
lib/miasma/contrib/open_stack.rb

Overview

Common API methods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object

Set attributes into model

Parameters:

  • klass (Class)


212
213
214
215
216
217
218
219
220
221
222
223
224
225
# File 'lib/miasma/contrib/open_stack.rb', line 212

def self.included(klass)
  klass.class_eval do
    attribute :open_stack_identity_url, String, :required => true
    attribute :open_stack_username, String
    attribute :open_stack_user_id, String
    attribute :open_stack_password, String
    attribute :open_stack_token, String
    attribute :open_stack_region, String
    attribute :open_stack_tenant_name, String
    attribute :open_stack_domain, String
    attribute :open_stack_project, String

  end
end

Instance Method Details

#connectionHTTP

Returns with auth token provided.

Returns:

  • (HTTP)

    with auth token provided



228
229
230
# File 'lib/miasma/contrib/open_stack.rb', line 228

def connection
  super.with_headers('X-Auth-Token' => token)
end

#endpointString

Returns endpoint URL.

Returns:

  • (String)

    endpoint URL



233
234
235
236
237
238
# File 'lib/miasma/contrib/open_stack.rb', line 233

def endpoint
  open_stack_api.endpoint_for(
    Utils.snake(self.class.to_s.split('::')[-2]).to_sym,
    open_stack_region
  )
end

#open_stack_apiMiasma::Contrib::OpenStackApiCore



246
247
248
249
250
251
# File 'lib/miasma/contrib/open_stack.rb', line 246

def open_stack_api
  key = "miasma_open_stack_api_#{attributes.checksum}".to_sym
  memoize(key, :direct) do
    Miasma::Contrib::OpenStackApiCore.new(attributes)
  end
end

#tokenString

Returns valid API token.

Returns:

  • (String)

    valid API token



241
242
243
# File 'lib/miasma/contrib/open_stack.rb', line 241

def token
  open_stack_api.api_token
end