summaryrefslogtreecommitdiff
path: root/iotronic/api/controllers/v1/board.py
diff options
context:
space:
mode:
Diffstat (limited to 'iotronic/api/controllers/v1/board.py')
-rw-r--r--iotronic/api/controllers/v1/board.py26
1 files changed, 23 insertions, 3 deletions
diff --git a/iotronic/api/controllers/v1/board.py b/iotronic/api/controllers/v1/board.py
index 054e7a3..d316be8 100644
--- a/iotronic/api/controllers/v1/board.py
+++ b/iotronic/api/controllers/v1/board.py
@@ -322,8 +322,10 @@ class BoardPluginsController(rest.RestController):
322 322
323 323
324class BoardServicesController(rest.RestController): 324class BoardServicesController(rest.RestController):
325
325 _custom_actions = { 326 _custom_actions = {
326 'action': ['POST'], 327 'action': ['POST'],
328 'restore': ['GET']
327 } 329 }
328 330
329 def __init__(self, board_ident): 331 def __init__(self, board_ident):
@@ -358,9 +360,6 @@ class BoardServicesController(rest.RestController):
358 raise exception.MissingParameterValue( 360 raise exception.MissingParameterValue(
359 ("Action is not specified.")) 361 ("Action is not specified."))
360 362
361 if not ServiceAction.parameters:
362 ServiceAction.parameters = {}
363
364 rpc_board = api_utils.get_rpc_board(self.board_ident) 363 rpc_board = api_utils.get_rpc_board(self.board_ident)
365 rpc_service = api_utils.get_rpc_service(service_ident) 364 rpc_service = api_utils.get_rpc_service(service_ident)
366 365
@@ -380,6 +379,27 @@ class BoardServicesController(rest.RestController):
380 ServiceAction.action) 379 ServiceAction.action)
381 return result 380 return result
382 381
382 @expose.expose(ExposedCollection,
383 status_code=200)
384 def restore(self):
385 rpc_board = api_utils.get_rpc_board(self.board_ident)
386
387 try:
388 cdict = pecan.request.context.to_policy_values()
389 cdict['owner'] = rpc_board.owner
390 policy.authorize('iot:service_action:post', cdict, cdict)
391
392 except exception:
393 return exception
394
395 rpc_board.check_if_online()
396
397 pecan.request.rpcapi.restore_services_on_board(
398 pecan.request.context,
399 rpc_board.uuid)
400
401 return self._get_services_on_board_collection(rpc_board.uuid)
402
383 403
384class BoardsController(rest.RestController): 404class BoardsController(rest.RestController):
385 """REST controller for Boards.""" 405 """REST controller for Boards."""