Developing lightweight computation at the DSG edge

Commit 3020d557 authored by Roger Pueyo Centelles's avatar Roger Pueyo Centelles
Browse files

[qmp-system] Add qmp_get_openwrt_default_network function



The qmp_get_openwrt_default_network() function fetches the
/etc/board.json file to obtain the default interfaces for the
lan and wan network roles.
Signed-off-by: default avatarRoger Pueyo Centelles <roger.pueyo@guifi.net>
parent 319e0e3d
......@@ -43,6 +43,7 @@ qmp_check_device() {
ip link show $1 1> /dev/null 2>/dev/null
return $?
}
# Function qmp_set_vlan()
#
# This function creates a VLAN interface on top of an interface in order to
......@@ -284,6 +285,16 @@ qmp_configure_smart_network() {
qmp_uci_set interfaces.ignore_devices "$ignore_devs"
}
qmp_get_openwrt_default_network() {
local role=$1
local board_file="/etc/board.json"
local flen=$(wc -l $board_file | cut -d " " -f 1)
[ "$role" != "lan" ] && [ "$role" != "wan" ] && return
grep -A${flen} "network" $board_file | grep -A${flen} $role | grep -m 1 -B${flen} "}" | grep -m 1 "ifname" | cut -d ":" -f2 | sed -e 's/^[ \t]*//' | cut -d '"' -f 2
}
qmp_attach_device_to_interface() {
local device=$1
local interface=$2
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment