Parent

Class/Module Index [+]

Quicksearch

Fog::Orchestration::OpenStack::Mock

Attributes

auth_token[R]
auth_token_expiration[R]
current_tenant[R]
current_user[R]

Public Class Methods

data() click to toggle source
# File lib/fog/openstack/orchestration.rb, line 30
def self.data
  @data ||= Hash.new do |hash, key|
    hash[key] = {
      :stacks => {}
    }
  end
end
new(options={}) click to toggle source
# File lib/fog/openstack/orchestration.rb, line 42
def initialize(options={})
  @openstack_username = options[:openstack_username]
  @openstack_auth_uri = URI.parse(options[:openstack_auth_url])

  @current_tenant = options[:openstack_tenant]

  @auth_token = Fog::Mock.random_base64(64)
  @auth_token_expiration = (Time.now.utc + 86400).iso8601

  management_url = URI.parse(options[:openstack_auth_url])
  management_url.port = 8774
  management_url.path = '/v1'
  @openstack_management_url = management_url.to_s

  identity_public_endpoint = URI.parse(options[:openstack_auth_url])
  identity_public_endpoint.port = 5000
  @openstack_identity_public_endpoint = identity_public_endpoint.to_s
end
reset() click to toggle source
# File lib/fog/openstack/orchestration.rb, line 38
def self.reset
  @data = nil
end

Public Instance Methods

create_stack(stack_name, options = {}) click to toggle source
# File lib/fog/openstack/requests/orchestration/create_stack.rb, line 33
def create_stack(stack_name, options = {})
  stack_id = Fog::Mock.random_hex(32)
  stack = self.data[:stacks][stack_id] = {
    'id' => stack_id,
    'stack_name' => stack_name,
    'links' => [],
    'description' => options[:description],
    'stack_status' => 'CREATE_COMPLETE',
    'stack_status_reason' => 'Stack successfully created',
    'creation_time' => Time.now,
    'updated_time' => Time.now
  }

  response = Excon::Response.new
  response.status = 201
  response.body = {
    'id' => stack_id,
    'links'=>[{"href"=>"http://localhost:8004/v1/fake_tenant_id/stacks/#{stack_name}/#{stack_id}", "rel"=>"self"}]}
  response
end
credentials() click to toggle source
# File lib/fog/openstack/orchestration.rb, line 69
def credentials
  { :provider                 => 'openstack',
    :openstack_auth_url       => @openstack_auth_uri.to_s,
    :openstack_auth_token     => @auth_token,
    :openstack_management_url => @openstack_management_url,
    :openstack_identity_endpoint => @openstack_identity_public_endpoint }
end
data() click to toggle source
# File lib/fog/openstack/orchestration.rb, line 61
def data
  self.class.data["#{@openstack_username}-#{@current_tenant}"]
end
delete_stack(stack_name, stack_id) click to toggle source
# File lib/fog/openstack/requests/orchestration/delete_stack.rb, line 24
def delete_stack(stack_name, stack_id)
  self.data[:stacks].delete(stack_id)

  response = Excon::Response.new
  response.status = 204
  response.body = {}
  response
end
list_stacks(options = {}) click to toggle source
# File lib/fog/openstack/requests/orchestration/list_stacks.rb, line 36
def list_stacks(options = {})
  stacks = self.data[:stacks].values

  Excon::Response.new(
    :body   => { 'stacks' => stacks },
    :status => 200
  )
end
reset_data() click to toggle source
# File lib/fog/openstack/orchestration.rb, line 65
def reset_data
  self.class.data.delete("#{@openstack_username}-#{@current_tenant}")
end
update_stack(stack_name, options = {}) click to toggle source
# File lib/fog/openstack/requests/orchestration/update_stack.rb, line 30
def update_stack(stack_name, options = {})
  response = Excon::Response.new
  response.status = 202
  response.body = {}
  response
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.