Board Action.
New board-action command. Change-Id: I2adb06ed15cd49c9b9e95e688b5c5442c802c63b
This commit is contained in:
parent
6b8018ccf1
commit
3e8ed1db87
|
@ -103,3 +103,10 @@ class BoardManager(base.CreateManager):
|
||||||
def update(self, board_id, patch, http_method='PATCH'):
|
def update(self, board_id, patch, http_method='PATCH'):
|
||||||
return self._update(resource_id=board_id, patch=patch,
|
return self._update(resource_id=board_id, patch=patch,
|
||||||
method=http_method)
|
method=http_method)
|
||||||
|
|
||||||
|
def board_action(self, board_ident, action, params={}):
|
||||||
|
path = "%(board)s/action" % {'board': board_ident}
|
||||||
|
body = {"action": action,
|
||||||
|
"parameters": params
|
||||||
|
}
|
||||||
|
return self._update(path, body, method='POST')
|
||||||
|
|
|
@ -15,6 +15,7 @@ from iotronicclient.common import cliutils
|
||||||
from iotronicclient.common.i18n import _
|
from iotronicclient.common.i18n import _
|
||||||
from iotronicclient.common import utils
|
from iotronicclient.common import utils
|
||||||
from iotronicclient.v1 import resource_fields as res_fields
|
from iotronicclient.v1 import resource_fields as res_fields
|
||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
def _print_board_show(board, fields=None, json=False):
|
def _print_board_show(board, fields=None, json=False):
|
||||||
|
@ -225,3 +226,32 @@ def do_board_update(cc, args):
|
||||||
|
|
||||||
board = cc.board.update(args.board, patch)
|
board = cc.board.update(args.board, patch)
|
||||||
_print_board_show(board, json=args.json)
|
_print_board_show(board, json=args.json)
|
||||||
|
|
||||||
|
|
||||||
|
@cliutils.arg('board',
|
||||||
|
metavar='<board>',
|
||||||
|
help="Name or UUID of the board.")
|
||||||
|
@cliutils.arg('action',
|
||||||
|
metavar='<action>',
|
||||||
|
help="action of the plugin.")
|
||||||
|
@cliutils.arg(
|
||||||
|
'--params',
|
||||||
|
metavar='<parameter=value>',
|
||||||
|
nargs='+',
|
||||||
|
action='append',
|
||||||
|
default=[],
|
||||||
|
help="Parameters of the action")
|
||||||
|
@cliutils.arg(
|
||||||
|
'--params-file',
|
||||||
|
metavar='<params_file>',
|
||||||
|
help="Json file of parameters")
|
||||||
|
def do_board_action(cc, args):
|
||||||
|
"""Execute an action on the board."""
|
||||||
|
params = {}
|
||||||
|
if args.params_file:
|
||||||
|
with open(args.params_file, 'r') as fil:
|
||||||
|
params = json.load(fil)
|
||||||
|
elif args.params:
|
||||||
|
params = {k: v for k, v in (x.split('=') for x in args.params[0])}
|
||||||
|
result = cc.board.board_action(args.board, args.action, params)
|
||||||
|
print(_('%s') % result)
|
||||||
|
|
Loading…
Reference in New Issue