Skip to content

Commit

Permalink
ubus: add support for system calls
Browse files Browse the repository at this point in the history
Signed-off-by: Álvaro Fernández Rojas <[email protected]>
  • Loading branch information
Noltari committed Feb 17, 2021
1 parent bcef4c4 commit 9caab12
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
4 changes: 4 additions & 0 deletions openwrt/ubus/const.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"

Expand Down
20 changes: 20 additions & 0 deletions openwrt/ubus/interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down Expand Up @@ -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)

0 comments on commit 9caab12

Please sign in to comment.