mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2025-12-10 07:44:39 +01:00
Ticket refs #3769: bbf: add support for dynamic obj/param when generating excel file
- improve the generator excel - add support for dynamic obj/param when generating xml data model tree
This commit is contained in:
parent
d27c4137f7
commit
57c1a3372e
10 changed files with 297 additions and 72 deletions
|
|
@ -20,13 +20,13 @@
|
|||
/*** /UPnP/DM/Configuration/ objects ***/
|
||||
DMOBJ upnpConfigurationObj[] = {
|
||||
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
|
||||
{"Network",&DMREAD, NULL, NULL, NULL, NULL, NULL, upnpConfigurationNetworkObj, upnpConfigurationNetworkParams, NULL},
|
||||
{"Network", &DMREAD, NULL, NULL, NULL, NULL, NULL, upnpConfigurationNetworkObj, upnpConfigurationNetworkParams, NULL},
|
||||
{0}
|
||||
};
|
||||
|
||||
/*** /UPnP/DM/Configuration/Network objects ***/
|
||||
DMOBJ upnpConfigurationNetworkObj[] = {
|
||||
{"IPInterface",&DMWRITE, upnp_configuration_ipinterface_createinstance, upnp_configuration_ipinterface_deleteinstance, NULL, upnp_browseIPInterfaceInst, NULL, upnpConfigurationNetworkIPInterfaceObj, upnpConfigurationNetworkIPInterfaceParams, NULL},
|
||||
{"IPInterface", &DMWRITE, upnp_configuration_ipinterface_createinstance, upnp_configuration_ipinterface_deleteinstance, NULL, upnp_browseIPInterfaceInst, NULL, upnpConfigurationNetworkIPInterfaceObj, upnpConfigurationNetworkIPInterfaceParams, NULL},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
|
@ -39,7 +39,7 @@ DMLEAF upnpConfigurationNetworkParams[]= {
|
|||
|
||||
/*** /UPnP/DM/Configuration/Network/IPInterface/#/ objects ***/
|
||||
DMOBJ upnpConfigurationNetworkIPInterfaceObj[]= {
|
||||
{"IPv4",&DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, upnpConfigurationNetworkIPInterfaceIpv4Params, NULL},
|
||||
{"IPv4", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, upnpConfigurationNetworkIPInterfaceIpv4Params, NULL},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ DMOBJ tRoot181ObjUPNPDM[] = {
|
|||
DMOBJ tRoot181ObjUPNPBBF[] = {
|
||||
/* OBJ, permission, addobj, delobj, checkdep, browseinstobj, nextdynamicobj, nextobj, leaf, linker, bbfdm_type, uniqueKeys*/
|
||||
{"DeviceInfo", &DMREAD, NULL, NULL, NULL, NULL, NULL,tDeviceInfoObj, tDeviceInfoParams, NULL, BBFDM_BOTH},
|
||||
{"ManagementServer", &DMREAD, NULL, NULL, NULL, NULL, NULL,NULL, tManagementServerParams, NULL, BBFDM_BOTH},
|
||||
{"ManagementServer", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tManagementServerParams, NULL, BBFDM_BOTH},
|
||||
{"Time", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, tTimeParams, NULL, BBFDM_BOTH},
|
||||
{"UPnP", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, tUPnPObj, NULL, NULL, BBFDM_BOTH},
|
||||
/*
|
||||
|
|
@ -100,12 +100,12 @@ DMOBJ tRoot181ObjUPNPBBF[] = {
|
|||
{CUSTOM_PREFIX"OWSD", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL,X_IOPSYS_EU_OWSDObj, X_IOPSYS_EU_OWSDParams, NULL, BBFDM_BOTH},
|
||||
{CUSTOM_PREFIX"Dropbear", &DMWRITE, add_dropbear_instance, delete_dropbear_instance, NULL, browseXIopsysEuDropbear, NULL, NULL, X_IOPSYS_EU_DropbearParams, NULL, BBFDM_BOTH},
|
||||
{CUSTOM_PREFIX"Buttons", &DMREAD, NULL, NULL, NULL, browseXIopsysEuButton, NULL, NULL, X_IOPSYS_EU_ButtonParams, NULL, BBFDM_BOTH},
|
||||
{"Bridging",&DMREAD, NULL, NULL, NULL, NULL, NULL, tBridgingObj, NULL, NULL, BBFDM_BOTH},
|
||||
{"WiFi",&DMREAD, NULL, NULL, NULL, NULL, NULL, tWiFiObj, NULL, NULL, BBFDM_BOTH},
|
||||
{"IP",&DMREAD, NULL, NULL, NULL, NULL, NULL, tIPObj, NULL, NULL, BBFDM_BOTH},
|
||||
{"Bridging", &DMREAD, NULL, NULL, NULL, NULL, NULL, tBridgingObj, NULL, NULL, BBFDM_BOTH},
|
||||
{"WiFi", &DMREAD, NULL, NULL, NULL, NULL, NULL, tWiFiObj, NULL, NULL, BBFDM_BOTH},
|
||||
{"IP", &DMREAD, NULL, NULL, NULL, NULL, NULL, tIPObj, NULL, NULL, BBFDM_BOTH},
|
||||
{"Ethernet", &DMREAD, NULL, NULL, NULL, NULL, NULL, tEthernetObj, NULL, NULL, BBFDM_BOTH},
|
||||
{"DSL",&DMREAD, NULL, NULL, NULL, NULL, NULL, tDSLObj, NULL, NULL, BBFDM_BOTH},
|
||||
{"ATM",&DMREAD, NULL, NULL, NULL, NULL, NULL, tATMObj, NULL, NULL, BBFDM_BOTH},
|
||||
{"DSL", &DMREAD, NULL, NULL, NULL, NULL, NULL, tDSLObj, NULL, NULL, BBFDM_BOTH},
|
||||
{"ATM", &DMREAD, NULL, NULL, NULL, NULL, NULL, tATMObj, NULL, NULL, BBFDM_BOTH},
|
||||
{"PTM", &DMREAD, NULL, NULL, NULL, NULL, NULL, tPTMObj, NULL, NULL, BBFDM_BOTH},
|
||||
{"DHCPv4", &DMREAD, NULL, NULL, NULL, NULL, NULL, tDHCPv4Obj, NULL, NULL, BBFDM_BOTH},
|
||||
{"Hosts", &DMREAD, NULL, NULL, NULL, NULL, NULL, tHostsObj, tHostsParams, NULL, BBFDM_BOTH},
|
||||
|
|
|
|||
|
|
@ -24,9 +24,9 @@ int upnp_browseNetworkInterfaceInst(struct dmctx *dmctx, DMNODE *parent_node, vo
|
|||
|
||||
/*** /UPnP/DM/DeviceInfo/ objects ***/
|
||||
DMOBJ upnpDeviceInfoObj[] ={
|
||||
{"PhysicalDevice", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL,upnpPhysicalDeviceObj, upnpPhysicalDeviceParams, NULL},
|
||||
{"OperatingSystem",&DMREAD, NULL, NULL, NULL, NULL, NULL, NULL,NULL, upnpOperatingSystemParams, NULL},
|
||||
{"ExecutionEnvironment",&DMREAD, NULL, NULL, NULL, NULL, NULL, NULL,NULL, upnpExecutionEnvironmentParams, NULL},
|
||||
{"PhysicalDevice", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, upnpPhysicalDeviceObj, upnpPhysicalDeviceParams, NULL},
|
||||
{"OperatingSystem", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, upnpOperatingSystemParams, NULL},
|
||||
{"ExecutionEnvironment", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, upnpExecutionEnvironmentParams, NULL},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
|
@ -41,7 +41,7 @@ DMLEAF upnpDeviceInfoParams[] = {
|
|||
|
||||
/*** /UPnP/DM/DeviceInfo/PhysicalDevice/ objects ***/
|
||||
DMOBJ upnpPhysicalDeviceObj[] = {
|
||||
{"DeviceID", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL,NULL, upnpDeviceIdParams, NULL},
|
||||
{"DeviceID", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, upnpDeviceIdParams, NULL},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -20,9 +20,9 @@
|
|||
|
||||
/*** /UPnP/DM/Monitoring/ objects ***/
|
||||
DMOBJ upnpMonitoringObj[] = {
|
||||
{"OperatingSystem",&DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, upnpMonitoringOperatingSystemParams, NULL},
|
||||
{"ExecutionEnvironment",&DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, upnpMonitoringExecutionEnvironmentParams, NULL},
|
||||
{"IPUsage",&DMREAD, NULL, NULL, NULL, upnp_BrowseIPUsage, NULL, NULL, NULL, upnpMonitoringIPUsageParams, NULL},
|
||||
{"OperatingSystem", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, upnpMonitoringOperatingSystemParams, NULL},
|
||||
{"ExecutionEnvironment", &DMREAD, NULL, NULL, NULL, NULL, NULL, NULL, NULL, upnpMonitoringExecutionEnvironmentParams, NULL},
|
||||
{"IPUsage", &DMREAD, NULL, NULL, NULL, upnp_BrowseIPUsage, NULL, NULL, NULL, upnpMonitoringIPUsageParams, NULL},
|
||||
{0}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -83,12 +83,12 @@ DMOBJ tDeviceObj[] = {
|
|||
{CUSTOM_PREFIX"MLD", &DMREAD, NULL, NULL, "file:/etc/config/mcast", NULL, NULL, X_IOPSYS_EU_MLDObj, X_IOPSYS_EU_MLDParams, NULL, BBFDM_BOTH},
|
||||
{CUSTOM_PREFIX"Dropbear", &DMWRITE, add_dropbear_instance, delete_dropbear_instance, "file:/etc/config/dropbear", browseXIopsysEuDropbear, NULL, NULL, X_IOPSYS_EU_DropbearParams, NULL, BBFDM_BOTH},
|
||||
{CUSTOM_PREFIX"Buttons", &DMREAD, NULL, NULL, "file:/etc/config/buttons", browseXIopsysEuButton, NULL, NULL, X_IOPSYS_EU_ButtonParams, NULL, BBFDM_BOTH},
|
||||
{"Bridging",&DMREAD, NULL, NULL, "file:/etc/config/network", NULL, NULL, tBridgingObj, tBridgingParams, NULL, BBFDM_BOTH},
|
||||
{"WiFi",&DMREAD, NULL, NULL, "file:/etc/config/wireless", NULL, NULL, tWiFiObj, tWiFiParams, NULL, BBFDM_BOTH},
|
||||
{"IP",&DMREAD, NULL, NULL, "file:/etc/config/network", NULL, NULL, tIPObj, tIPParams, NULL, BBFDM_BOTH},
|
||||
{"Bridging", &DMREAD, NULL, NULL, "file:/etc/config/network", NULL, NULL, tBridgingObj, tBridgingParams, NULL, BBFDM_BOTH},
|
||||
{"WiFi", &DMREAD, NULL, NULL, "file:/etc/config/wireless", NULL, NULL, tWiFiObj, tWiFiParams, NULL, BBFDM_BOTH},
|
||||
{"IP", &DMREAD, NULL, NULL, "file:/etc/config/network", NULL, NULL, tIPObj, tIPParams, NULL, BBFDM_BOTH},
|
||||
{"Ethernet", &DMREAD, NULL, NULL, "file:/etc/config/network", NULL, NULL, tEthernetObj, tEthernetParams, NULL, BBFDM_BOTH},
|
||||
{"DSL",&DMREAD, NULL, NULL, "file:/etc/config/dsl", NULL, NULL, tDSLObj, tDSLParams, NULL, BBFDM_BOTH},
|
||||
{"ATM",&DMREAD, NULL, NULL, "file:/etc/config/dsl", NULL, NULL, tATMObj, NULL, NULL, BBFDM_BOTH},
|
||||
{"DSL", &DMREAD, NULL, NULL, "file:/etc/config/dsl", NULL, NULL, tDSLObj, tDSLParams, NULL, BBFDM_BOTH},
|
||||
{"ATM", &DMREAD, NULL, NULL, "file:/etc/config/dsl", NULL, NULL, tATMObj, NULL, NULL, BBFDM_BOTH},
|
||||
{"PTM", &DMREAD, NULL, NULL, "file:/etc/config/dsl", NULL, NULL, tPTMObj, NULL, NULL, BBFDM_BOTH},
|
||||
{"DHCPv4", &DMREAD, NULL, NULL, "file:/lib/netifd/proto/dhcp.sh", NULL, NULL, tDHCPv4Obj, tDHCPv4Params, NULL, BBFDM_BOTH},
|
||||
{"DHCPv6", &DMREAD, NULL, NULL, "file:/lib/netifd/proto/dhcpv6.sh", NULL, NULL, tDHCPv6Obj, tDHCPv6Params, NULL, BBFDM_BOTH},
|
||||
|
|
|
|||
|
|
@ -2132,9 +2132,9 @@ DMLEAF IGMPProxyInterfaceParams[] = {
|
|||
DMLEAF X_IOPSYS_EU_IGMPProxyParams[] = {
|
||||
{"Enable", &DMWRITE, DMT_BOOL, get_mcast_proxy_enable, set_mcast_proxy_enable, BBFDM_BOTH},
|
||||
{"Version", &DMWRITE, DMT_STRING, get_igmp_proxy_version, set_igmp_proxy_version, BBFDM_BOTH},
|
||||
{"QueryInterval",&DMWRITE, DMT_UNINT, get_mcastp_query_interval, set_mcastp_query_interval, BBFDM_BOTH},
|
||||
{"QueryResponseInterval",&DMWRITE, DMT_UNINT, get_mcastp_q_response_interval, set_mcastp_q_response_interval, BBFDM_BOTH},
|
||||
{"LastMemberQueryInterval",&DMWRITE, DMT_UNINT, get_mcastp_last_mq_interval, set_mcastp_last_mq_interval, BBFDM_BOTH},
|
||||
{"QueryInterval", &DMWRITE, DMT_UNINT, get_mcastp_query_interval, set_mcastp_query_interval, BBFDM_BOTH},
|
||||
{"QueryResponseInterval", &DMWRITE, DMT_UNINT, get_mcastp_q_response_interval, set_mcastp_q_response_interval, BBFDM_BOTH},
|
||||
{"LastMemberQueryInterval", &DMWRITE, DMT_UNINT, get_mcastp_last_mq_interval, set_mcastp_last_mq_interval, BBFDM_BOTH},
|
||||
{"ImmediateLeave", &DMWRITE, DMT_BOOL, get_mcast_proxy_fast_leave, set_mcast_proxy_fast_leave, BBFDM_BOTH},
|
||||
{"Robustness", &DMWRITE, DMT_UNINT, get_mcast_proxy_robustness, set_mcast_proxy_robustness, BBFDM_BOTH},
|
||||
{"Aggregation", &DMWRITE, DMT_BOOL, get_mcast_proxy_aggregation, set_mcast_proxy_aggregation, BBFDM_BOTH},
|
||||
|
|
|
|||
|
|
@ -949,9 +949,9 @@ DMLEAF MLDProxyInterfaceParams[] = {
|
|||
DMLEAF X_IOPSYS_EU_MLDProxyParams[] = {
|
||||
{"Enable", &DMWRITE, DMT_BOOL, get_mcast_proxy_enable, set_mcast_proxy_enable, BBFDM_BOTH},
|
||||
{"Version", &DMWRITE, DMT_STRING, get_mld_proxy_version, set_mld_proxy_version, BBFDM_BOTH},
|
||||
{"QueryInterval",&DMWRITE, DMT_UNINT, get_mcastp_query_interval, set_mcastp_query_interval, BBFDM_BOTH},
|
||||
{"QueryResponseInterval",&DMWRITE, DMT_UNINT, get_mcastp_q_response_interval, set_mcastp_q_response_interval, BBFDM_BOTH},
|
||||
{"LastMemberQueryInterval",&DMWRITE, DMT_UNINT, get_mcastp_last_mq_interval, set_mcastp_last_mq_interval, BBFDM_BOTH},
|
||||
{"QueryInterval", &DMWRITE, DMT_UNINT, get_mcastp_query_interval, set_mcastp_query_interval, BBFDM_BOTH},
|
||||
{"QueryResponseInterval", &DMWRITE, DMT_UNINT, get_mcastp_q_response_interval, set_mcastp_q_response_interval, BBFDM_BOTH},
|
||||
{"LastMemberQueryInterval", &DMWRITE, DMT_UNINT, get_mcastp_last_mq_interval, set_mcastp_last_mq_interval, BBFDM_BOTH},
|
||||
{"ImmediateLeave", &DMWRITE, DMT_BOOL, get_mcast_proxy_fast_leave, set_mcast_proxy_fast_leave, BBFDM_BOTH},
|
||||
{"Robustness", &DMWRITE, DMT_UNINT, get_mcast_proxy_robustness, set_mcast_proxy_robustness, BBFDM_BOTH},
|
||||
{"Aggregation", &DMWRITE, DMT_BOOL, get_mcast_proxy_aggregation, set_mcast_proxy_aggregation, BBFDM_BOTH},
|
||||
|
|
|
|||
|
|
@ -139,18 +139,22 @@ def printOBJPARAM(obj, supported, protocols, types):
|
|||
|
||||
def printusage():
|
||||
print("Usage: " + sys.argv[0] + " <json data model> [options...] <urls>")
|
||||
print("JSON data models: ")
|
||||
print(" tr181.json or tr104.json The JSON data model to be parsed")
|
||||
print("Options: ")
|
||||
print(" -r, --remote-dm Check OBJ/PARAM under these repositories if it is not found under bbf repo")
|
||||
print(" -h, --help This help text")
|
||||
print(" -r, --remote-dm Check OBJ/PARAM under these repositories if it is not found under bbf repo")
|
||||
print(" -h, --help This help text")
|
||||
print("Urls: ")
|
||||
print(" url^(branch,hash,tag) The url with branch, hash or tag to be used")
|
||||
print("")
|
||||
print("Examples:")
|
||||
print("Examples: ")
|
||||
print(" - python " + sys.argv[0] + " tr181.json")
|
||||
print(" ==> Generate excel file in tr181.xls")
|
||||
print(" - python " + sys.argv[0] + " tr104.json")
|
||||
print(" ==> Generate excel file in tr104.xls")
|
||||
print(" - python " + sys.argv[0] + " tr181.json -r https://dev.iopsys.eu/feed/iopsys.git,https://dev.iopsys.eu/abc/def.git")
|
||||
print(" - python " + sys.argv[0] + " tr181.json -r https://dev.iopsys.eu/feed/iopsys.git^release-5.3,https://dev.iopsys.eu/iopsys/mydatamodel.git^5c8e7cb740dc5e425adf53ea574fb529d2823f88")
|
||||
print(" ==> Generate excel file in tr181.xls")
|
||||
print(" - python " + sys.argv[0] + " tr181.json --remote-dm https://dev.iopsys.eu/feed/iopsys.git")
|
||||
print(" - python " + sys.argv[0] + " tr181.json --remote-dm https://dev.iopsys.eu/feed/iopsys.git^6.0.0ALPHA1")
|
||||
print(" ==> Generate excel file in tr181.xls")
|
||||
|
||||
def object_parse_childs( dmobject , value ):
|
||||
|
|
@ -262,9 +266,12 @@ for opt, arg in opts:
|
|||
if remotedm != None:
|
||||
print("Start downloading remote data models...")
|
||||
print("Download in progress........")
|
||||
url = remotedm.split(",")
|
||||
dm_url = remotedm.split(",")
|
||||
for i in range(remotedm.count(',') + 1):
|
||||
subprocess.run(["git", "clone", url[i], ".repo" + str(i)], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
url = dm_url[i].split("^")
|
||||
subprocess.run(["git", "clone", url[0], ".repo" + str(i)], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
if url.count("^") == 1:
|
||||
subprocess.run(["git", "-C", ".repo" + str(i), "checkout", url[1]], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
||||
|
||||
if "tr181" in sys.argv[1]:
|
||||
excel_file = "tr181.xls"
|
||||
|
|
|
|||
|
|
@ -1,20 +1,12 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Copyright (C) 2019 iopsys Software Solutions AB
|
||||
# Copyright (C) 2020 iopsys Software Solutions AB
|
||||
# Author: Omar Kallel <omar.kallel@pivasoftware.com>
|
||||
# Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
|
||||
|
||||
# USAGE:
|
||||
# ./generate_xml.sh <data model> <scripts path> <product class> <device protocol> <model name> <software version>
|
||||
# If the input arguments are empty, then use the default values:
|
||||
|
||||
|
||||
# VARIABLES ####################################################################################################
|
||||
obj_look_obj_child_list=""
|
||||
obj_look_param_child_list=""
|
||||
obj_look_father_list=""
|
||||
param_look_father_list=""
|
||||
|
||||
|
||||
# FUNCTIONS ####################################################################################################
|
||||
set_node_name() {
|
||||
|
|
@ -108,8 +100,11 @@ remove_item_from_list(){
|
|||
#Tree.txt Generation ####################################
|
||||
gen_dm_tree(){
|
||||
file=$1
|
||||
dyn_obj=$2
|
||||
|
||||
#Get line number of lines containing Object or Param
|
||||
leaf_obj_line=`get_leaf_obj_line_number "$file"`
|
||||
|
||||
for line_number in $leaf_obj_line; do
|
||||
#Get table name
|
||||
table_name=`sed -n $line_number'p' $file | cut -d' ' -f2 | tr -d []`
|
||||
|
|
@ -128,6 +123,7 @@ gen_dm_tree(){
|
|||
break
|
||||
fi
|
||||
done
|
||||
|
||||
for param in $obj_look_param_child_list; do
|
||||
childs_params=`echo $param | awk -F ":" '{print $2}'`
|
||||
if [ "$childs_params" == "$table_name" ]; then #I found mum
|
||||
|
|
@ -142,37 +138,56 @@ gen_dm_tree(){
|
|||
name=`echo ${f1/CUSTOM_PREFIX/$CUSTOM_PREFIX} | sed 's/{//' | sed 's/"//g'`
|
||||
type=${f3// }
|
||||
multiinstance=${f5// }
|
||||
|
||||
if [ "$multiinstance" != "NULL" ]; then
|
||||
instance="true"
|
||||
else
|
||||
instance="false"
|
||||
fi
|
||||
|
||||
if [ "$dyn_obj" -eq "1" ];then
|
||||
echo "object,$instance,root,Device,$name," >> $TREE_TXT
|
||||
fi
|
||||
|
||||
if [ "$o_found" == "1" ]; then
|
||||
name=`set_obj_object_child "$father_name" "$name"`
|
||||
oname=`set_obj_object_line $instance "$name"`
|
||||
echo "$oname," >> $TREE_TXT
|
||||
fi
|
||||
|
||||
if [ "$p_found" == "1" ]; then
|
||||
name=`set_obj_param_child "$father_name" "$name"`
|
||||
otype=`get_param_type $type`
|
||||
pname=`set_obj_param_line "$otype" "$name"`
|
||||
echo $pname >> $TREE_TXT
|
||||
fi
|
||||
|
||||
if [ -n "$str" ]; then
|
||||
child_objects=${f7// }
|
||||
child_parameters=${f8// }
|
||||
obj_name=${name}
|
||||
|
||||
#Add the actual object to the list of objects looking for their children objects ########
|
||||
if [ "$child_objects" != "NULL" ]; then
|
||||
new_item=${obj_name}":"${child_objects}
|
||||
if [ "$dyn_obj" -eq "1" ];then
|
||||
new_item="Device,"${obj_name}":"${child_objects}
|
||||
else
|
||||
new_item=${obj_name}":"${child_objects}
|
||||
fi
|
||||
obj_look_obj_child_list=`add_item_to_list "$new_item" "$obj_look_obj_child_list"`
|
||||
fi
|
||||
|
||||
#Add the actual object to the list of objects looking for their children parameters #######
|
||||
if [ "$child_parameters" != "NULL" ]; then
|
||||
new_item=${obj_name}":"${child_parameters}
|
||||
if [ "$dyn_obj" -eq "1" ];then
|
||||
new_item="Device,"${obj_name}":"${child_parameters}
|
||||
else
|
||||
new_item=${obj_name}":"${child_parameters}
|
||||
fi
|
||||
obj_look_param_child_list=`add_item_to_list "$new_item" "$obj_look_param_child_list"`
|
||||
fi
|
||||
fi
|
||||
dyn_obj=0
|
||||
done <<<"`sed -n $line_number',/{0}/p' $file | cut -d \" \" -f 1-4,6- | sed '/#ifdef GENERIC_OPENWRT/,/#else/d' | sed -e '/{0}/d' | sed -e '/^{/!d'`"
|
||||
|
||||
######### Remove object from list of object looking there childs
|
||||
|
|
@ -245,7 +260,7 @@ xml_write_line() {
|
|||
local path="$3"
|
||||
local line=""
|
||||
|
||||
local LINES=`grep "$path[^,]\+$\|$path[^,]\+,$" tmp.txt`
|
||||
local LINES=`grep "$path[^,]\+$\|$path[^,]\+,$" $OUT_STREAM`
|
||||
|
||||
for line in $LINES; do
|
||||
local p=`echo "$line" | cut -d, -f$((level+2))`
|
||||
|
|
@ -256,7 +271,7 @@ xml_write_line() {
|
|||
if [ "$node" = "object" ]; then
|
||||
local isarray=`echo "$line" | cut -d, -f2`
|
||||
let cnt_obj++
|
||||
local has_child=`grep "$path$param,[a-zA-Z0-9_,]\+$" tmp.txt |wc -l`;
|
||||
local has_child=`grep "$path$param,[a-zA-Z0-9_,]\+$" $OUT_STREAM |wc -l`;
|
||||
xml_open_tag_object "$param" "$isarray" "$level" "$has_child"
|
||||
xml_write_line "$((level+1))" "$param" "$path$param,"
|
||||
xml_close_tag_object "$level" "$has_child"
|
||||
|
|
@ -305,16 +320,35 @@ echo " </dataModel>"
|
|||
echo "</deviceType>"
|
||||
}
|
||||
|
||||
display_usage() {
|
||||
echo "Usage: $0 [-r|--remote-dm urls] [-p|--product-class] [-d|--device-protocol] [-m|--model-name] [-s|--software-version] [-h|--help]"
|
||||
echo "Options: "
|
||||
echo " -r, --remote-dm generate data model tree using dynamic OBJ/PARAM under these repositories"
|
||||
echo " -p, --product-class generate data model tree using this product class, default:DG400PRIME"
|
||||
echo " -d, --device-protocol generate data model tree using this device protocol, default:DEVICE_PROTOCOL_DSLFTR069v1"
|
||||
echo " -m, --model-name generate data model tree using this model name, default:DG400PRIME-A"
|
||||
echo " -s, --software-version generate data model tree using this software version, default:1.2.3.4"
|
||||
echo " -h, --help This help text"
|
||||
echo ""
|
||||
echo "Examples: "
|
||||
echo " - sh $0"
|
||||
echo " - sh $0 --remote-dm https://dev.iopsys.eu/feed/iopsys.git^devel,https://dev.iopsys.eu/iopsys/mydatamodel.git^5c8e7cb740dc5e425adf53ea574fb529d2823f88"
|
||||
echo " - sh $0 -p DG300 -s BETA5.3.4 -r https://dev.iopsys.eu/feed/iopsys.git^6.0.0ALPHA1"
|
||||
echo ""
|
||||
}
|
||||
|
||||
############################################### MAIN ######################################################
|
||||
|
||||
# set initial values
|
||||
CURRENT_PATH=`pwd`
|
||||
OUT_STREAM="tmp.txt"
|
||||
OUT_STREAM=".tmp.txt"
|
||||
ROOT_FILE="device.c"
|
||||
TREE_TXT=$CURRENT_PATH"/"$OUT_STREAM
|
||||
DM_PATH=${2:-"$(pwd)/../dmtree/"}
|
||||
PRODUCT_CLASS=${3:-"DG400PRIME"}
|
||||
DEVICE_PROTOCOL=${4:-"DEVICE_PROTOCOL_DSLFTR069v1"}
|
||||
MODEL_NAME=${5:-"DG400PRIME-A"}
|
||||
SOFTWARE_VERSION=${6:-"1.2.3.4B"}
|
||||
DM_PATH="$(pwd)/../dmtree"
|
||||
PRODUCT_CLASS="DG400PRIME"
|
||||
DEVICE_PROTOCOL="DEVICE_PROTOCOL_DSLFTR069v1"
|
||||
MODEL_NAME="DG400PRIME-A"
|
||||
SOFTWARE_VERSION="1.2.3.4"
|
||||
cnt_obj=0
|
||||
cnt_param=0
|
||||
DM_TR181="tr181"
|
||||
|
|
@ -330,31 +364,114 @@ XML_OUT_STREAM_BBF="iopsys.xml"
|
|||
ROOT_PATH="Device"
|
||||
CUSTOM_PREFIX="X_IOPSYS_EU_"
|
||||
|
||||
# read the options
|
||||
OPTS=$(getopt --options r:p:d:m:s:h --long remote-dm:,product-class:,device-protocol:,model-name:,software-version:,help --name "$0" -- "$@")
|
||||
|
||||
if [ $? != 0 ]; then echo "Failed to parse options...exiting." >&2 ; exit 1 ; fi
|
||||
|
||||
eval set -- "$OPTS"
|
||||
|
||||
# extract options and their arguments into variables.
|
||||
while true ; do
|
||||
case "$1" in
|
||||
-r | --remote-dm )
|
||||
REMOTEDM="$2"
|
||||
shift 2
|
||||
;;
|
||||
-p | --product-class )
|
||||
PRODUCT_CLASS="$2"
|
||||
shift 2
|
||||
;;
|
||||
-d | --device-protocol )
|
||||
DEVICE_PROTOCOL="$2"
|
||||
shift 2
|
||||
;;
|
||||
-m | --model-name )
|
||||
MODEL_NAME="$2"
|
||||
shift 2
|
||||
;;
|
||||
-s | --software-version )
|
||||
SOFTWARE_VERSION="$2"
|
||||
shift 2
|
||||
;;
|
||||
-h | --help )
|
||||
display_usage
|
||||
exit 0
|
||||
;;
|
||||
-- )
|
||||
shift
|
||||
break
|
||||
;;
|
||||
*)
|
||||
echo "Internal error!"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# download remote data models if exists
|
||||
if [ -n "$REMOTEDM" ]; then
|
||||
echo "Start downloading remote data models..."
|
||||
echo "Download in progress........"
|
||||
i=0
|
||||
for dm_url in $(echo $REMOTEDM | tr "," "\n"); do
|
||||
URL="${dm_url%^*}"
|
||||
BRANCH="${dm_url#*^}"
|
||||
git clone $URL ".repo$i" > /dev/null 2>&1
|
||||
git -C ".repo$i" checkout $BRANCH > /dev/null 2>&1
|
||||
let "i++"
|
||||
done
|
||||
fi
|
||||
|
||||
############## GEN BBF Data Models TREE ##############
|
||||
echo "Start Generation of BBF Data Models..."
|
||||
echo "Please wait..."
|
||||
|
||||
rm -rf $OUT_STREAM
|
||||
rm -rf $XML_OUT_STREAM_BBF
|
||||
|
||||
echo "object,false,root,$ROOT_PATH," > $OUT_STREAM
|
||||
|
||||
cd "$SCRIPTS_PATH_TR181"
|
||||
gen_dm_tree $ROOT_FILE
|
||||
gen_dm_tree $ROOT_FILE "0"
|
||||
for dir in $DIR_LIST; do
|
||||
cd $dir
|
||||
files=`ls *.c |grep -v $ROOT_FILE`
|
||||
for file in $files; do
|
||||
gen_dm_tree "$file"
|
||||
gen_dm_tree "$file" "0"
|
||||
done
|
||||
done
|
||||
|
||||
cd $CURRENT_PATH
|
||||
if [ -n "$REMOTEDM" ]; then
|
||||
i=0
|
||||
for dm_url in $(echo $REMOTEDM | tr "," "\n"); do
|
||||
files=`find .repo$i -name datamodel.c`
|
||||
for file in $files; do
|
||||
gen_dm_tree "$file" "1"
|
||||
done
|
||||
let "i++"
|
||||
done
|
||||
fi
|
||||
|
||||
sort -k 4 $OUT_STREAM > tmp2.txt
|
||||
cat tmp2.txt | tr -d "[:blank:]" > $OUT_STREAM
|
||||
rm -rf tmp2.txt
|
||||
gen_data_model_xml_file > $XML_OUT_STREAM_BBF
|
||||
cnt_obj=`grep -c "object," tmp.txt`
|
||||
cnt_param=`grep -c "parameter," tmp.txt`
|
||||
|
||||
cnt_obj=`grep -c "object," $OUT_STREAM`
|
||||
cnt_param=`grep -c "parameter," $OUT_STREAM`
|
||||
|
||||
echo "Number of BBF Data Models objects is $cnt_obj"
|
||||
echo "Number of BBF Data Models parameters is $cnt_param"
|
||||
echo "End of BBF Data Models Generation"
|
||||
rm -rf tmp.txt
|
||||
|
||||
if [ -n "$REMOTEDM" ]; then
|
||||
i=0
|
||||
for dm_url in $(echo $REMOTEDM | tr "," "\n"); do
|
||||
rm -rf ".repo$i"
|
||||
let "i++"
|
||||
done
|
||||
fi
|
||||
|
||||
rm -rf $OUT_STREAM
|
||||
|
|
|
|||
|
|
@ -1,15 +1,11 @@
|
|||
#!/bin/sh
|
||||
|
||||
# Copyright (C) 2019 iopsys Software Solutions AB
|
||||
# Copyright (C) 2020 iopsys Software Solutions AB
|
||||
# Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
|
||||
|
||||
# USAGE:
|
||||
# ./generate_xml.sh
|
||||
|
||||
|
||||
############################################ VARIABLES #########################################################
|
||||
CURRENT_PATH=`pwd`
|
||||
OUT_STREAM="tmp.txt"
|
||||
OUT_STREAM=".tmp.txt"
|
||||
ROOT_FILE="device.c"
|
||||
TREE_TXT=$CURRENT_PATH"/"$OUT_STREAM
|
||||
obj_look_obj_child_list=""
|
||||
|
|
@ -136,6 +132,8 @@ file_filter(){
|
|||
################# Tree.txt Generation ####################
|
||||
gen_dm_tree(){
|
||||
file=$1
|
||||
dyn_obj=$2
|
||||
|
||||
#Get line number of lines containing Object or Param
|
||||
leaf_obj_line=`get_leaf_obj_line_number "$file"`
|
||||
|
||||
|
|
@ -181,6 +179,7 @@ gen_dm_tree(){
|
|||
######## Create Childs list
|
||||
while IFS=, read -r f1 f2 f3 f4 f5 f6 f7 f8 f9 f10 f11; do
|
||||
name=`echo ${f1//{} | sed 's/^"\(.*\)"$/\1/'`
|
||||
|
||||
permission=${f2// &}
|
||||
type=${f3// }
|
||||
browse=${f5// }
|
||||
|
|
@ -191,6 +190,15 @@ gen_dm_tree(){
|
|||
instance="readOnly"
|
||||
fi
|
||||
|
||||
if [ "$dyn_obj" -eq "1" ];then
|
||||
oname="object, $instance, , , , root, Device.$name"
|
||||
if [ "$browse" != "NULL" ]; then
|
||||
echo "$oname.{i}." >> $TREE_TXT
|
||||
else
|
||||
echo "$oname." >> $TREE_TXT
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$o_found" == "1" ]; then
|
||||
name=`set_obj_object_child "$father_name" "$name"`
|
||||
oname=`set_obj_object_line $instance "$name"`
|
||||
|
|
@ -212,18 +220,28 @@ gen_dm_tree(){
|
|||
child_objects=${f7// }
|
||||
child_parameters=${f8// }
|
||||
obj_name=${name}
|
||||
|
||||
#Add the actual object to the list of objects looking for their children objects ########
|
||||
if [ "$child_objects" != "NULL" ]; then
|
||||
new_item=${obj_name}":"${browse}":"${child_objects}
|
||||
if [ "$dyn_obj" -eq "1" ];then
|
||||
new_item="Device."${obj_name}":"${browse}":"${child_objects}
|
||||
else
|
||||
new_item=${obj_name}":"${browse}":"${child_objects}
|
||||
fi
|
||||
obj_look_obj_child_list=`add_item_to_list "$new_item" "$obj_look_obj_child_list"`
|
||||
fi
|
||||
|
||||
#Add the actual object to the list of objects looking for their children parameters #######
|
||||
if [ "$child_parameters" != "NULL" ]; then
|
||||
new_item=${obj_name}":"${browse}":"${child_parameters}
|
||||
if [ "$dyn_obj" -eq "1" ];then
|
||||
new_item="Device."${obj_name}":"${browse}":"${child_parameters}
|
||||
else
|
||||
new_item=${obj_name}":"${browse}":"${child_parameters}
|
||||
fi
|
||||
obj_look_param_child_list=`add_item_to_list "$new_item" "$obj_look_param_child_list"`
|
||||
fi
|
||||
fi
|
||||
|
||||
dyn_obj=0
|
||||
done <<<"`sed -n $line_number',/{0}/p' $file | cut -d \" \" -f 1-4,6- | sed '/#ifdef GENERIC_OPENWRT/,/#else/d' | sed -e '/{0}/d' | sed -e '/^{/!d'`"
|
||||
|
||||
######### Remove object from list of object looking there childs
|
||||
|
|
@ -321,7 +339,7 @@ add_dm_xml() {
|
|||
gen_data_model_xml_file() {
|
||||
echo "<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
|
||||
echo "<dm:document xmlns:dm=\"urn:broadband-forum-org:cwmp:datamodel-1-6\" xmlns:dmr=\"urn:broadband-forum-org:cwmp:datamodel-report-0-1\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"urn:broadband-forum-org:cwmp:datamodel-1-6 http://www.broadband-forum.org/cwmp/cwmp-datamodel-1-6.xsd urn:broadband-forum-org:cwmp:datamodel-report-0-1 http://www.broadband-forum.org/cwmp/cwmp-datamodel-report.xsd\" spec=\"urn:broadband-forum-org:$DM_VERSION\" file=\"$DM_FILE\">"
|
||||
echo " <model name=\"$model_name\">"
|
||||
echo " <model name=\"$MODEL_NAME\">"
|
||||
echo " <object name=\"$ROOT_PATH\" access=\"readOnly\" minEntries=\"1\" maxEntries=\"1\">"
|
||||
echo " <description>"
|
||||
echo " The top-level for $DM_TR181"
|
||||
|
|
@ -332,14 +350,29 @@ gen_data_model_xml_file() {
|
|||
echo "</dm:document>"
|
||||
}
|
||||
|
||||
display_usage() {
|
||||
echo "Usage: $0 [-r|--remote-dm urls] [-h|--help]"
|
||||
echo "Options: "
|
||||
echo " -r, --remote-dm generate data model tree using dynamic OBJ/PARAM under these repositories"
|
||||
echo " -h, --help This help text"
|
||||
echo ""
|
||||
echo "Examples: "
|
||||
echo " - sh $0"
|
||||
echo " - sh $0 --remote-dm https://dev.iopsys.eu/feed/iopsys.git^devel,https://dev.iopsys.eu/iopsys/mydatamodel.git^5c8e7cb740dc5e425adf53ea574fb529d2823f88"
|
||||
echo " - sh $0 -r https://dev.iopsys.eu/feed/iopsys.git^6.0.0ALPHA1"
|
||||
echo ""
|
||||
}
|
||||
|
||||
############################################### MAIN ######################################################
|
||||
|
||||
# set initial values
|
||||
cnt_obj=1
|
||||
cnt_param=0
|
||||
DM_TR181="tr181"
|
||||
DM_TR104="tr104"
|
||||
DM_TR143="tr143"
|
||||
DM_TR157="tr157"
|
||||
DM_PATH=${2:-"$(pwd)/../dmtree"}
|
||||
DM_PATH="$(pwd)/../dmtree"
|
||||
SCRIPTS_PATH_TR181=${DM_PATH}/${DM_TR181}
|
||||
SCRIPTS_PATH_TR104=${DM_PATH}/${DM_TR104}
|
||||
SCRIPTS_PATH_TR143=${DM_PATH}/${DM_TR143}
|
||||
|
|
@ -349,27 +382,95 @@ ROOT_PATH="Device"
|
|||
DM_HEAD="$ROOT_PATH-2.13"
|
||||
DM_FILE="tr-181-2-13-0-cwmp-full.xml"
|
||||
DM_VERSION="tr-181-2-13-0-cwmp"
|
||||
model_name="$ROOT_PATH:2.13"
|
||||
MODEL_NAME="$ROOT_PATH:2.13"
|
||||
XML_OUT_STREAM_BBF="iopsys_bbf.xml"
|
||||
|
||||
# read the options
|
||||
OPTS=$(getopt --options r:h --long remote-dm:,help --name "$0" -- "$@")
|
||||
|
||||
if [ $? != 0 ]; then echo "Failed to parse options...exiting." >&2 ; exit 1 ; fi
|
||||
|
||||
eval set -- "$OPTS"
|
||||
|
||||
# extract options and their arguments into variables.
|
||||
while true ; do
|
||||
case "$1" in
|
||||
-r | --remote-dm )
|
||||
REMOTEDM="$2"
|
||||
shift 2
|
||||
;;
|
||||
-h | --help )
|
||||
display_usage
|
||||
exit 0
|
||||
;;
|
||||
-- )
|
||||
shift
|
||||
break
|
||||
;;
|
||||
*)
|
||||
echo "Internal error!"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# download remote data models if exists
|
||||
if [ -n "$REMOTEDM" ]; then
|
||||
echo "Start downloading remote data models..."
|
||||
echo "Download in progress........"
|
||||
i=0
|
||||
for dm_url in $(echo $REMOTEDM | tr "," "\n"); do
|
||||
URL="${dm_url%^*}"
|
||||
BRANCH="${dm_url#*^}"
|
||||
git clone $URL ".repo$i" > /dev/null 2>&1
|
||||
git -C ".repo$i" checkout $BRANCH > /dev/null 2>&1
|
||||
let "i++"
|
||||
done
|
||||
fi
|
||||
|
||||
############## GEN BBF Data Models TREE ##############
|
||||
echo "Start Generation of BBF Data Models..."
|
||||
echo "Please wait..."
|
||||
|
||||
rm -rf $OUT_STREAM
|
||||
rm -rf $XML_OUT_STREAM_BBF
|
||||
|
||||
cd "$SCRIPTS_PATH_TR181"
|
||||
gen_dm_tree $ROOT_FILE
|
||||
gen_dm_tree $ROOT_FILE "0"
|
||||
|
||||
for dir in $DIR_LIST; do
|
||||
cd $dir
|
||||
files=`ls *.c |grep -v $ROOT_FILE`
|
||||
for file in $files; do
|
||||
gen_dm_tree "$file"
|
||||
gen_dm_tree "$file" "0"
|
||||
done
|
||||
done
|
||||
|
||||
cd $CURRENT_PATH
|
||||
if [ -n "$REMOTEDM" ]; then
|
||||
i=0
|
||||
for dm_url in $(echo $REMOTEDM | tr "," "\n"); do
|
||||
files=`find .repo$i -name datamodel.c`
|
||||
for file in $files; do
|
||||
gen_dm_tree "$file" "1"
|
||||
done
|
||||
let "i++"
|
||||
done
|
||||
fi
|
||||
|
||||
file_filter $OUT_STREAM
|
||||
gen_data_model_xml_file > $XML_OUT_STREAM_BBF
|
||||
|
||||
echo "Number of BBF Data Models objects is $cnt_obj"
|
||||
echo "Number of BBF Data Models parameters is $cnt_param"
|
||||
echo "End of BBF Data Models Generation"
|
||||
|
||||
if [ -n "$REMOTEDM" ]; then
|
||||
i=0
|
||||
for dm_url in $(echo $REMOTEDM | tr "," "\n"); do
|
||||
rm -rf ".repo$i"
|
||||
let "i++"
|
||||
done
|
||||
fi
|
||||
|
||||
rm -rf $OUT_STREAM
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue