EasyCwmp

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0000054easycwmp[All Projects] Generalpublic2015-05-20 11:592015-06-09 17:38
Reportershasta 
Assigned Toakram.chakchouk 
PrioritylowSeverityminorReproducibilityalways
StatusresolvedResolutionfixed 
PlatformOSOS Version
Summary0000054: Some issues in script file lan_device
DescriptionI 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 Reproduce1. 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
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
(0000198)
akram.chakchouk (developer)
2015-06-09 17:38

fixed in EasyCwmp-1.1.3

- Issue History
Date Modified Username Field Change
2015-05-20 11:59 shasta New Issue
2015-06-09 17:38 akram.chakchouk Note Added: 0000198
2015-06-09 17:38 akram.chakchouk Status new => resolved
2015-06-09 17:38 akram.chakchouk Resolution open => fixed
2015-06-09 17:38 akram.chakchouk Assigned To => akram.chakchouk


Copyright © 2000 - 2017 MantisBT Team
Powered by Mantis Bugtracker