Class: Fog::Rackspace::Orchestration::Real

Inherits:
Service
  • Object
show all
Defined in:
lib/fog/rackspace/orchestration.rb,
lib/fog/rackspace/requests/orchestration/build_info.rb,
lib/fog/rackspace/requests/orchestration/create_stack.rb,
lib/fog/rackspace/requests/orchestration/delete_stack.rb,
lib/fog/rackspace/requests/orchestration/update_stack.rb,
lib/fog/rackspace/requests/orchestration/abandon_stack.rb,
lib/fog/rackspace/requests/orchestration/preview_stack.rb,
lib/fog/rackspace/requests/orchestration/list_resources.rb,
lib/fog/rackspace/requests/orchestration/list_stack_data.rb,
lib/fog/rackspace/requests/orchestration/list_stack_events.rb,
lib/fog/rackspace/requests/orchestration/validate_template.rb,
lib/fog/rackspace/requests/orchestration/get_stack_template.rb,
lib/fog/rackspace/requests/orchestration/show_event_details.rb,
lib/fog/rackspace/requests/orchestration/show_resource_data.rb,
lib/fog/rackspace/requests/orchestration/show_stack_details.rb,
lib/fog/rackspace/requests/orchestration/list_resource_types.rb,
lib/fog/rackspace/requests/orchestration/list_resource_events.rb,
lib/fog/rackspace/requests/orchestration/show_resource_schema.rb,
lib/fog/rackspace/requests/orchestration/show_resource_metadata.rb,
lib/fog/rackspace/requests/orchestration/show_resource_template.rb

Instance Method Summary collapse

Methods inherited from Service

#request_without_retry, #service_net?

Constructor Details

#initialize(options = {}) ⇒ Real

Returns a new instance of Real.



114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
# File 'lib/fog/rackspace/orchestration.rb', line 114

def initialize(options = {})
  @rackspace_api_key = options[:rackspace_api_key]
  @rackspace_username = options[:rackspace_username]
  @rackspace_auth_url = options[:rackspace_auth_url]
  setup_custom_endpoint(options)
  @rackspace_must_reauthenticate = false
  @connection_options = options[:connection_options] || {}

  authenticate

  deprecation_warnings(options)

  @persistent = options[:persistent] || false
  @connection = Fog::Core::Connection.new(endpoint_uri.to_s, @persistent, @connection_options)
end

Instance Method Details

#abandon_stack(stack) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/fog/rackspace/requests/orchestration/abandon_stack.rb', line 5

def abandon_stack(stack)
  request(
    :expects => [200],
    :method  => 'DELETE',
    :path    => "stacks/#{stack.stack_name}/#{stack.id}/abandon"
  )
end

#authenticate(options = {}) ⇒ Object



142
143
144
145
146
147
148
149
# File 'lib/fog/rackspace/orchestration.rb', line 142

def authenticate(options={})
  super({
    :rackspace_api_key => @rackspace_api_key,
    :rackspace_username => @rackspace_username,
    :rackspace_auth_url => @rackspace_auth_url,
    :connection_options => @connection_options
  })
end

#build_infoObject



5
6
7
8
9
10
11
# File 'lib/fog/rackspace/requests/orchestration/build_info.rb', line 5

def build_info
  request(
    :expects => [200],
    :method  => 'GET',
    :path    => 'build_info'
  )
end

#create_stack(options = {}) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/fog/rackspace/requests/orchestration/create_stack.rb', line 5

def create_stack(options={})
  request(
    :body     => Fog::JSON.encode(options),
    :expects  => [201],
    :method   => 'POST',
    :path     => "stacks"
  )
end

#delete_stack(stack) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/fog/rackspace/requests/orchestration/delete_stack.rb', line 5

def delete_stack(stack)
  request(
    :expects => [204],
    :method  => 'DELETE',
    :path    => "stacks/#{stack.stack_name}/#{stack.id}"
  )
end

#endpoint_uri(service_endpoint_url = nil) ⇒ Object



163
164
165
# File 'lib/fog/rackspace/orchestration.rb', line 163

def endpoint_uri(service_endpoint_url=nil)
  @uri = super(@rackspace_endpoint || service_endpoint_url, :rackspace_orchestration_url)
end

#get_stack_template(stack) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/fog/rackspace/requests/orchestration/get_stack_template.rb', line 5

def get_stack_template(stack)
  request(
    :method  => 'GET',
    :path    => "stacks/#{stack.stack_name}/#{stack.id}/template",
    :expects => 200
  )
end

#list_resource_events(stack, resource, options = {}) ⇒ Object



5
6
7
8
# File 'lib/fog/rackspace/requests/orchestration/list_resource_events.rb', line 5

def list_resource_events(stack, resource, options={})
  uri = request_uri("stacks/#{stack.stack_name}/#{stack.id}/resources/#{resource.resource_name}/events", options)
  request(:method => 'GET', :path => uri, :expects => 200)
end

#list_resource_typesObject



5
6
7
8
9
10
11
# File 'lib/fog/rackspace/requests/orchestration/list_resource_types.rb', line 5

def list_resource_types
  request(
    :method  => 'GET',
    :path    => "resource_types",
    :expects => 200
  )
end

#list_resources(stack, options = {}) ⇒ Object



5
6
7
8
# File 'lib/fog/rackspace/requests/orchestration/list_resources.rb', line 5

def list_resources(stack, options={})
  uri = request_uri("stacks/#{stack.stack_name}/#{stack.id}/resources", options)
  request(:method => 'GET', :path => uri, :expects => 200)
end

#list_stack_data(options = {}) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/fog/rackspace/requests/orchestration/list_stack_data.rb', line 5

def list_stack_data(options={})
  request(
    :method  => 'GET',
    :path    => request_uri("stacks", options),
    :expects => 200
  )
end

#list_stack_events(stack, options = {}) ⇒ Object



5
6
7
8
# File 'lib/fog/rackspace/requests/orchestration/list_stack_events.rb', line 5

def list_stack_events(stack, options={})
  uri = request_uri("stacks/#{stack.stack_name}/#{stack.id}/events", options)
  request(:method => 'GET', :path => uri, :expects => 200)
end

#preview_stack(options = {}) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/fog/rackspace/requests/orchestration/preview_stack.rb', line 5

def preview_stack(options = {})
  request(
    :body     => Fog::JSON.encode(options),
    :expects  => [200],
    :method   => 'POST',
    :path     => 'stacks/preview'
  )
end

#regionObject



159
160
161
# File 'lib/fog/rackspace/orchestration.rb', line 159

def region
  @rackspace_region
end

#request(params, parse_json = true) ⇒ Object



130
131
132
133
134
135
136
137
138
139
140
# File 'lib/fog/rackspace/orchestration.rb', line 130

def request(params, parse_json = true)
  super
rescue Excon::Errors::NotFound => error
  raise NotFound.slurp(error, self)
rescue Excon::Errors::BadRequest => error
  raise BadRequest.slurp(error, self)
rescue Excon::Errors::InternalServerError => error
  raise InternalServerError.slurp(error, self)
rescue Excon::Errors::HTTPStatusError => error
  raise ServiceError.slurp(error, self)
end

#request_id_headerObject



155
156
157
# File 'lib/fog/rackspace/orchestration.rb', line 155

def request_id_header
  "x-orchestration-request-id"
end

#request_uri(path, options = {}) ⇒ Object



167
168
169
170
171
# File 'lib/fog/rackspace/orchestration.rb', line 167

def request_uri(path, options={})
  return path if options == {}
  require "addressable/uri"
  Addressable::URI.new({:path=>path, :query_values=>options}).request_uri
end

#service_nameObject



151
152
153
# File 'lib/fog/rackspace/orchestration.rb', line 151

def service_name
  :cloudOrchestration
end

#show_event_details(stack, resource, event_id) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/fog/rackspace/requests/orchestration/show_event_details.rb', line 5

def show_event_details(stack, resource, event_id)
  request(
    :method  => 'GET',
    :path    => "stacks/#{stack.stack_name}/#{stack.id}/resources/#{resource.resource_name}/events/#{event_id}",
    :expects => 200
  )
end

#show_resource_data(stack_name, stack_id, resource_name) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/fog/rackspace/requests/orchestration/show_resource_data.rb', line 5

def show_resource_data(stack_name, stack_id, resource_name)
  request(
    :method  => 'GET',
    :path    => "stacks/#{stack_name}/#{stack_id}/resources/#{resource_name}",
    :expects => 200
  )
end

#show_resource_metadata(stack, resource_name) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/fog/rackspace/requests/orchestration/show_resource_metadata.rb', line 5

def (stack, resource_name)
  request(
    :method  => 'GET',
    :path    => "stacks/#{stack.stack_name}/#{stack.id}/resources/#{resource_name}/metadata",
    :expects => 200
  )
end

#show_resource_schema(name) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/fog/rackspace/requests/orchestration/show_resource_schema.rb', line 5

def show_resource_schema(name)
  request(
    :method  => 'GET',
    :path    => "resource_types/#{name}",
    :expects => 200
  )
end

#show_resource_template(name) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/fog/rackspace/requests/orchestration/show_resource_template.rb', line 5

def show_resource_template(name)
  request(
    :method  => 'GET',
    :path    => "resource_types/#{name}/template",
    :expects => 200
  )
end

#show_stack_details(name, id) ⇒ Object



5
6
7
8
9
10
11
# File 'lib/fog/rackspace/requests/orchestration/show_stack_details.rb', line 5

def show_stack_details(name, id)
  request(
    :method  => 'GET',
    :path    => "stacks/#{name}/#{id}",
    :expects => 200
  )
end

#update_stack(stack, options = {}) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/fog/rackspace/requests/orchestration/update_stack.rb', line 5

def update_stack(stack, options = {})
  request(
    :body     => Fog::JSON.encode(options),
    :expects  => [202],
    :method   => 'PUT',
    :path     => "stacks/#{stack.stack_name}/#{stack.id}"
  )
end

#validate_template(options = {}) ⇒ Object



5
6
7
8
9
10
11
12
# File 'lib/fog/rackspace/requests/orchestration/validate_template.rb', line 5

def validate_template(options = {})
  request(
    :body     => Fog::JSON.encode(options),
    :expects  => [200],
    :method   => 'POST',
    :path     => 'validate'
  )
end