Class: NodesController

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

Instance Method Summary collapse

Instance Method Details

#accept_new_tasksObject



49
50
51
52
53
# File 'app/controllers/nodes_controller.rb', line 49

def accept_new_tasks
  NodeTaskAcceptance.new(node: @node).accept!

  head :ok
end

#createObject



14
15
16
17
18
19
20
21
# File 'app/controllers/nodes_controller.rb', line 14

def create
  @node = Node.create!(node_params)

  FriendlyNameNodes.new.perform
  AdjustNodeSlotsJob.perform_later(node: @node)

  render json: @node, status: :created
end

#destroyObject



34
35
36
37
38
39
40
41
# File 'app/controllers/nodes_controller.rb', line 34

def destroy
  DeleteNode.new(node: @node).perform
  FriendlyNameNodes.new.perform

  head :ok
rescue DeleteNode::NodeWithRunningSlotsError
  head :not_acceptable
end

#indexObject



10
11
12
# File 'app/controllers/nodes_controller.rb', line 10

def index
  render json: Node.all
end

#kill_containersObject



55
56
57
58
59
# File 'app/controllers/nodes_controller.rb', line 55

def kill_containers
  KillNodeRunners.new(node: @node).perform

  head :ok
end

#reject_new_tasksObject



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

def reject_new_tasks
  NodeTaskAcceptance.new(node: @node).reject!

  head :ok
end

#showObject



23
24
25
# File 'app/controllers/nodes_controller.rb', line 23

def show
  render json: @node
end

#updateObject



27
28
29
30
31
32
# File 'app/controllers/nodes_controller.rb', line 27

def update
  @node.update!(node_params.slice(:slots_execution_types))
  AdjustNodeSlotsJob.perform_later(node: @node)

  render json: @node
end