Class: OcciModelController

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

Overview

Controller class handling all model-related requests. Implements listing of resources, retrieval of the model and creation/deletion of mixins.

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

#createObject

POST /-/ POST /.well-known/org/ogf/occi/-/


35
36
37
38
39
# File 'app/controllers/occi_model_controller.rb', line 35

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

#deleteObject

DELETE /-/ DELETE /.well-known/org/ogf/occi/-/


43
44
45
46
47
# File 'app/controllers/occi_model_controller.rb', line 43

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

#indexObject

GET /


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

def index
  if INDEX_LINK_FORMATS.include?(request.format)
    @resources = []

    @resources.concat(backend_instance.compute_list_ids.map { |c| "#{server_url}/compute/#{c}" })
    @resources.concat(backend_instance.network_list_ids.map { |n| "#{server_url}/network/#{n}" })
    @resources.concat(backend_instance.storage_list_ids.map { |s| "#{server_url}/storage/#{s}" })
    options = { flag: :links_only }
  else
    @resources = Occi::Collection.new

    @resources.resources.merge backend_instance.compute_list
    @resources.resources.merge backend_instance.network_list
    @resources.resources.merge backend_instance.storage_list
    options = {}
  end

  respond_with(@resources, options)
end

#showObject

GET /-/ GET /.well-known/org/ogf/occi/-/


28
29
30
31
# File 'app/controllers/occi_model_controller.rb', line 28

def show
  @model = OcciModel.get(backend_instance, request_occi_collection)
  respond_with(@model)
end