[Commotion-admin] [commotiond] Update OpenWRT shell bindings for new command return format (#62)

Josh King notifications at github.com
Fri Dec 13 16:41:59 UTC 2013


OpenWRT's scripting interface for network configuration primarily utilizes shell script wrapper functions around the commotion command-line client in order to interact with commotiond. Those functions are included in https://github.com/opentechinstitute/commotiond/blob/master/openwrt/lib/functions/commotion.sh (installed as /lib/functions/commotion.sh on a node). Currently the functions are written assuming that they're using the old-format output from the daemon, as opposed to the new key-value JSON format. These functions need to be updated against the new output format and new commands.

Output is of an arbitrary key-value format:
```
{ "key": "value", "key": "value" }
```
with unique keys. Exact output per command is still being determined. Also, unlike before, the commotion client returns true or false correctly depending on whether the command succeeds. So for some commands, it may be as easy as running the command and interpreting $? in order to echo "Command succeeded!" or "Command failed!". Output can be parsed through grep, sed and the like, but ideal would be proper JSON parsing. OpenWRT has a shell script JSON parser in a shell library called jsn.sh or something similar, which they use for parsing JSON output.

The shell functions should retain their current output format to the extent possible so as to keep from having to update things in other Commotion scripts that utilize the functions. We shouldn't need to add any additional commands unless needed, even though commotiond now supports additional ones. Below is a list of all commotiond commands:

up <iface> <profile> -same as before
down <iface> -same as before
status <iface> -same as before
state <iface> <property> -same as before
profiles -replaces list_profiles
set <profile> <property> <value> -allows you to set profile values
get <profile> <property> <value> -allows you to get profile values
save <profile> <file> -allows you to save a profile to a new file in the
profiles.d directory
new <profile> -allows you to create a new profile
delete <profile> -allows you to delete a profile
ipgen <ip address> <netmask> -allows you to generate an arbitrary IP
address from the nodeid
nodeid <id> -run without arguments, prints the nodeid. Can also set the
nodeid.

---
Reply to this email directly or view it on GitHub:
https://github.com/opentechinstitute/commotiond/issues/62
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.chambana.net/pipermail/commotion-admin/attachments/20131213/6f7ace5c/attachment.html>


More information about the Commotion-admin mailing list