Class: NetworkinterfaceController

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

Overview

Controller class handling all networkinterface-related requests. Implements retrieval, creation and deletion of networkinterface 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

#createObject

POST /link/networkinterface/


18
19
20
21
22
23
# File 'app/controllers/networkinterface_controller.rb', line 18

def create
  networkinterface = request_occi_collection(Occi::Core::Link).links.first
  networkinterface_location = backend_instance.compute_attach_network(networkinterface)

  respond_with("#{server_url}/link/networkinterface/#{networkinterface_location}", status: 201, flag: :link_only)
end

#deleteObject

DELETE /link/networkinterface/:id


26
27
28
29
30
31
32
33
34
# File 'app/controllers/networkinterface_controller.rb', line 26

def delete
  result = backend_instance.compute_detach_network(params[:id])

  if result
    respond_with(Occi::Collection.new)
  else
    respond_with(Occi::Collection.new, status: 304)
  end
end

#showObject

GET /link/networkinterface/:id


5
6
7
8
9
10
11
12
13
14
15
# File 'app/controllers/networkinterface_controller.rb', line 5

def show
  @networkinterface = Occi::Collection.new
  @networkinterface << backend_instance.compute_get_network(params[:id])

  unless @networkinterface.empty?
    update_mixins_in_coll(@networkinterface)
    respond_with(@networkinterface)
  else
    respond_with(Occi::Collection.new, status: 404)
  end
end