Class: OsTplController

Inherits:
ApplicationController show all
Defined in:
app/controllers/os_tpl_controller.rb

Overview

Controller class handling all os_tpl-related requests. Implements listing and triggering actions on mixin-tagged instances.

Constant Summary

Constants inherited from ApplicationController

ApplicationController::INDEX_LINK_FORMATS

Instance Method Summary collapse

Methods inherited from ApplicationController

#authenticate!, #current_user, #request_occi_collection, #warden

Methods included from Mixins::ErrorHandling

#handle_auth_err, #handle_authz_err, #handle_backend_unavailable_err, #handle_internal_backend_err, #handle_invalid_resource_err, #handle_not_impl_err, #handle_parser_input_err, #handle_parser_type_err, #handle_resource_not_found_err, #handle_wrong_args_err

Instance Method Details

#indexObject

GET /mixin/os_tpl/:term*/


5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/os_tpl_controller.rb', line 5

def index
  # TODO: work with :term*
  mixins = Occi::Core::Mixins.new << Occi::Infrastructure::OsTpl.mixin

  if INDEX_LINK_FORMATS.include?(request.format)
    @computes = backend_instance.compute_list_ids(mixins)
    @computes.map! { |c| "#{server_url}/compute/#{c}" }
    options = { flag: :links_only }
  else
    @computes = Occi::Collection.new
    @computes.resources = backend_instance.compute_list(mixins)
    update_mixins_in_coll(@computes)
    options = {}
  end

  respond_with(@computes, options)
end

#triggerObject

POST /mixin/os_tpl/:term*/?action=:action


24
25
26
27
28
# File 'app/controllers/os_tpl_controller.rb', line 24

def trigger
  # TODO: impl
  collection = Occi::Collection.new
  respond_with(collection, status: 501)
end