From 9caab12c6571d9ba9efcb5d543bbb63e4bda26cb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Fern=C3=A1ndez=20Rojas?= Date: Wed, 17 Feb 2021 13:29:41 +0100 Subject: [PATCH] ubus: add support for system calls MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Álvaro Fernández Rojas --- openwrt/ubus/const.py | 4 ++++ openwrt/ubus/interface.py | 20 ++++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/openwrt/ubus/const.py b/openwrt/ubus/const.py index 0ac87b1..45d02da 100644 --- a/openwrt/ubus/const.py +++ b/openwrt/ubus/const.py @@ -9,10 +9,13 @@ API_ERROR = "error" API_GET = "get" API_MESSAGE = "message" +API_METHOD_BOARD = "board" API_METHOD_GET = "get" API_METHOD_GET_CLIENTS = "get_clients" +API_METHOD_INFO = "info" API_METHOD_LOGIN = "login" API_METHOD_READ = "read" +API_METHOD_REBOOT = "reboot" API_PARAM_CONFIG = "config" API_PARAM_PASSWORD = "password" API_PARAM_PATH = "path" @@ -27,6 +30,7 @@ API_SUBSYS_FILE = "file" API_SUBSYS_HOSTAPD = "hostapd.*" API_SUBSYS_SESSION = "session" +API_SUBSYS_SYSTEM = "system" API_SUBSYS_UCI = "uci" API_UBUS_RPC_SESSION = "ubus_rpc_session" diff --git a/openwrt/ubus/interface.py b/openwrt/ubus/interface.py index 2e87149..a0f76af 100644 --- a/openwrt/ubus/interface.py +++ b/openwrt/ubus/interface.py @@ -13,10 +13,13 @@ API_DEF_VERIFY, API_ERROR, API_MESSAGE, + API_METHOD_BOARD, API_METHOD_GET, API_METHOD_GET_CLIENTS, + API_METHOD_INFO, API_METHOD_LOGIN, API_METHOD_READ, + API_METHOD_REBOOT, API_PARAM_CONFIG, API_PARAM_PASSWORD, API_PARAM_PATH, @@ -31,6 +34,7 @@ API_SUBSYS_FILE, API_SUBSYS_HOSTAPD, API_SUBSYS_SESSION, + API_SUBSYS_SYSTEM, API_SUBSYS_UCI, API_UBUS_RPC_SESSION, HTTP_STATUS_OK, @@ -199,3 +203,19 @@ def get_uci_config(self, _config, _type): API_PARAM_TYPE: _type, }, ) + + def get_system_method(self, method): + """Get system method.""" + return self.api_call(API_RPC_CALL, API_SUBSYS_SYSTEM, method) + + def system_board(self): + """System board.""" + return self.get_system_method(API_METHOD_BOARD) + + def system_info(self): + """System info.""" + return self.get_system_method(API_METHOD_INFO) + + def system_reboot(self): + """System reboot.""" + return self.get_system_method(API_METHOD_REBOOT)