View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0000054 | easycwmp | General | public | 2015-05-20 11:59 | 2015-06-09 17:38 |
Reporter | shasta | Assigned To | |||
Priority | low | Severity | minor | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
Summary | 0000054: Some issues in script file lan_device | ||||
Description | I want to add TR-181 data models, so I studied lan_device to understand how to add data models. Here are some issues I met during study: 1. Cannot add more than one LANDevice.1.WLANConfiguration. object because in function lan_device_get_wlan_max_instance() { local max=`$UCI_SHOW wireless | grep "wireless\.@wifi-iface\[[0-9]\+\].instance=" | cut -d'=' -f2 | sort -ru | head -1` echo ${max:-0} } If LANDevice.1. exists, max's value is '1', not 1; and instance=`lan_device_get_wlan_max_instance` $UCI_SET wireless.$iface.instance=$((++instance)) won't work correctly when I try to add another LANDevice..1.WLANConfiguration. object. solution: local max=`$UCI_SHOW wireless | grep "wireless\.@wifi-iface\[[0-9]\+\].instance=" | cut -d'=' -f2 | sort -ru | head -1 | sed 's/.//;s/.$//'` Just cut first and last charactor to make $((++instance)) work. 2. Cannot delete LANDevice.1.WLANConfiguration. object because in lan_device_delete_wlan_iface() { local instance="$1" local iface=`$UCI_SHOW wireless | grep "wireless\.@wifi-iface\[[0-9]\+\].instance=$instance$" | head -1 | cut -d'.' -f2` [ -z "$iface" ] && return $E_INVALID_PARAMETER_NAME $UCI_DELETE wireless.$iface $UCI_COMMIT common_execute_command_in_apply_service "wifi" return 0 } local iface=`$UCI_SHOW wireless | grep "wireless\.@wifi-iface\[[0-9]\+\].instance=$instance$" | head -1 | cut -d'.' -f2` I found iface is null, so I modified it to local iface=`$UCI_SHOW wireless | grep "wireless\.@wifi-iface\[[0-9]\+\].instance='$instance'$" | head -1 | cut -d'.' -f2` to solve it. 3. Sort problem when add more than ten LANDevice.1.WLANConfiguration. object If I added 10 object, and try to add one more object, local max=`$UCI_SHOW wireless | grep "wireless\.@wifi-iface\[[0-9]\+\].instance=" | cut -d'=' -f2 | sort -ru | head -1 | sed 's/.//;s/.$//'` max's value is not correct. Sort -v option solves the problem but my busybox doesn't support this option, so I use for loop to find max instance number... local instance instances=`$UCI_SHOW wireless | grep "wireless\.@wifi-iface\[[0-9]\+\].instance=" | cut -d'=' -f2 | sed 's/.//;s/.$//'` for instance in $instances; do if [ "$instance" -gt "$max" ]; then max=$instance fi done | ||||
Steps To Reproduce | 1. Add LANDevice.1.WLANConfiguration. issue: >bash /usr/sbin/easycwmp --json add object InternetGatewayDevice.LANDevice.1.WLANConfiguration. { "status": "1", "instance": "1" } >bash /usr/sbin/easycwmp --json add object InternetGatewayDevice.LANDevice.1.WLANConfiguration. { "status": "1" } >uci -c ${UCI_CONFIG_DIR} show wireless wireless.@wifi-iface[0]=wifi-iface wireless.@wifi-iface[0].device='wl0' wireless.@wifi-iface[0].encryption='none' wireless.@wifi-iface[0].mode='ap' wireless.@wifi-iface[0].ssid='DefaultSSID' wireless.@wifi-iface[0].instance='1' wireless.@wifi-iface[1]=wifi-iface wireless.@wifi-iface[1].device='wl0' wireless.@wifi-iface[1].encryption='none' wireless.@wifi-iface[1].mode='ap' wireless.@wifi-iface[1].ssid='DefaultSSID' //option "wireless.@wifi-iface[1].instance" doesn't exist and that's why how many times I tried to add object it always returns '1' 2. Cannot delete InternetGateway.LANDevice.1.WLANConfiguration.1. >bash /usr/sbin/easycwmp --json add object InternetGatewayDevice.LANDevice.1.WLANConfiguration. { "status": "1", "instance": "1" } >bash /usr/sbin/easycwmp --json delete object InternetGatewayDevice.LANDevice.1.WLANConfiguration.1. { "fault_code": "9005" } 3. After issue 1 is fixed, do >bash /usr/sbin/easycwmp --json add object InternetGatewayDevice.LANDevice.1.WLANConfiguration. 11 times: >bash /usr/sbin/easycwmp --json add object InternetGatewayDevice.LANDevice.1.WLANConfiguration. { "status": "1", "instance": "1" } >bash /usr/sbin/easycwmp --json add object InternetGatewayDevice.LANDevice.1.WLANConfiguration. { "status": "1", "instance": "2" } >bash /usr/sbin/easycwmp --json add object InternetGatewayDevice.LANDevice.1.WLANConfiguration. { "status": "1", "instance": "3" } >bash /usr/sbin/easycwmp --json add object InternetGatewayDevice.LANDevice.1.WLANConfiguration. { "status": "1", "instance": "4" } >bash /usr/sbin/easycwmp --json add object InternetGatewayDevice.LANDevice.1.WLANConfiguration. { "status": "1", "instance": "5" } >bash /usr/sbin/easycwmp --json add object InternetGatewayDevice.LANDevice.1.WLANConfiguration. { "status": "1", "instance": "6" } >bash /usr/sbin/easycwmp --json add object InternetGatewayDevice.LANDevice.1.WLANConfiguration. { "status": "1", "instance": "7" } >bash /usr/sbin/easycwmp --json add object InternetGatewayDevice.LANDevice.1.WLANConfiguration. { "status": "1", "instance": "8" } >bash /usr/sbin/easycwmp --json add object InternetGatewayDevice.LANDevice.1.WLANConfiguration. { "status": "1", "instance": "9" } >bash /usr/sbin/easycwmp --json add object InternetGatewayDevice.LANDevice.1.WLANConfiguration. { "status": "1", "instance": "10" } >bash /usr/sbin/easycwmp --json add object InternetGatewayDevice.LANDevice.1.WLANConfiguration. { "status": "1", "instance": "10" } // instance always = 10 when add more than 10 objects | ||||
Tags | No tags attached. | ||||
e-mail notification | |||||
Date Modified | Username | Field | Change |
---|---|---|---|
2015-05-20 11:59 | shasta | New Issue | |
2015-06-09 17:38 |
|
Note Added: 0000198 | |
2015-06-09 17:38 |
|
Status | new => resolved |
2015-06-09 17:38 |
|
Resolution | open => fixed |
2015-06-09 17:38 |
|
Assigned To | => user55 |