mirror of
https://dev.iopsys.eu/bbf/bbfdm.git
synced 2025-12-10 07:44:39 +01:00
Add a new tool to validate json plugin
This commit is contained in:
parent
323149c4e1
commit
0fe5d86703
3 changed files with 41 additions and 39 deletions
17
README.md
17
README.md
|
|
@ -816,13 +816,6 @@ The application should bring its JSON file under **'/etc/bbfdm/json/'** path wit
|
|||
|
||||
> Note4: Each object definition in JSON file must begin with "Device." and should have the full parent path if it is under another object
|
||||
|
||||
> Note5: You can validate any JSON file using [Validate_JSON_Plugin](/test/tools/validate_json_plugin.py) python script.
|
||||
|
||||
```bash
|
||||
$ ./test/tools/validate_json_plugin.py test/files/etc/bbfdm/json/UserInterface.json
|
||||
$ ./test/tools/validate_json_plugin.py test/files/etc/bbfdm/json/X_IOPSYS_EU_TEST.json
|
||||
```
|
||||
|
||||
- For more examples on JSON files, you can see these links: [X_IOPSYS_EU_MCPD](https://dev.iopsys.eu/feed/broadcom/-/blob/devel/mcpd/files/etc/bbfdm/json/X_IOPSYS_EU_MCPD.json), [UserInterface](/test/files/etc/bbfdm/json/UserInterface.json), [X_IOPSYS_EU_Dropbear](/test/files/etc/bbfdm/json/X_IOPSYS_EU_Dropbear.json), [X_IOPSYS_EU_TEST](/test/files/etc/bbfdm/json/X_IOPSYS_EU_TEST.json)
|
||||
|
||||
## BBFDM Tools
|
||||
|
|
@ -845,6 +838,7 @@ $ pip3 install jsonschema xlwt
|
|||
|generate_dm.py | Generate list of supported/un-supported parameters based of json input|
|
||||
|generate_dm_xml.py | Generate list of supported/un-supported parameters in xml format |
|
||||
|generate_dm_excel.py | Generate list of supported/un-supported parameters in xls format |
|
||||
|validate_json_plugin.py | Validate json plugin files for dynamic library or standard data model |
|
||||
|
||||
> Note: Currently all the tools needs to be executed in tools directory.
|
||||
|
||||
|
|
@ -942,6 +936,15 @@ $ ./generate_dm_excel.py -d tr181 -v iopsys -v openwrt -o datamodel.xls
|
|||
$ ./generate_dm_excel.py -d tr181 -d tr104 -v iopsys -o datamodel.xls
|
||||
$ ./generate_dm_excel.py -d tr181 -v iopsys -p X_IOPSYS_EU_ -r git^https://dev.iopsys.eu/iopsys/xmppc.git^devel -o datamodel_iopsys.xls
|
||||
```
|
||||
### Validate JSON plugin
|
||||
It is a [python script](./tools/validate_json_plugin.py) to validate JSON plugin files for dynamic library or standard data model [TR181](./dmtree/json/tr181.json), [TR104](./dmtree/json/tr104.json), etc..
|
||||
|
||||
```bash
|
||||
$ ./tools/validate_json_plugin.py test/files/etc/bbfdm/json/UserInterface.json
|
||||
$ ./tools/validate_json_plugin.py test/files/etc/bbfdm/json/X_IOPSYS_EU_TEST.json
|
||||
$ ./tools/validate_json_plugin.py dmtree/json/tr181.json
|
||||
```
|
||||
|
||||
### Data Model generator
|
||||
|
||||
This is a pipeline friendly master script to generate the list of supported and un-supported datamodels in xml and xls formats based on provided input in a json file.
|
||||
|
|
|
|||
|
|
@ -18,46 +18,46 @@ exec_cmd_verbose pylint -d R,C,W0603 tools/*.py
|
|||
echo "********* Validate JSON Plugin *********"
|
||||
|
||||
echo "Validate BBF TR-181 JSON Plugin"
|
||||
./test/tools/validate_json_plugin.py dmtree/json/tr181.json
|
||||
./tools/validate_json_plugin.py dmtree/json/tr181.json
|
||||
check_ret $?
|
||||
|
||||
echo "Validate BBF TR-104 JSON Plugin"
|
||||
./test/tools/validate_json_plugin.py dmtree/json/tr104.json
|
||||
./tools/validate_json_plugin.py dmtree/json/tr104.json
|
||||
check_ret $?
|
||||
|
||||
echo "Validate BBF TR-135 JSON Plugin"
|
||||
./test/tools/validate_json_plugin.py dmtree/json/tr135.json
|
||||
./tools/validate_json_plugin.py dmtree/json/tr135.json
|
||||
check_ret $?
|
||||
|
||||
echo "Validate X_IOPSYS_EU_Dropbear JSON Plugin"
|
||||
./test/tools/validate_json_plugin.py test/files/etc/bbfdm/json/X_IOPSYS_EU_Dropbear.json
|
||||
./tools/validate_json_plugin.py test/files/etc/bbfdm/json/X_IOPSYS_EU_Dropbear.json
|
||||
check_ret $?
|
||||
|
||||
echo "Validate UserInterface JSON Plugin"
|
||||
./test/tools/validate_json_plugin.py test/files/etc/bbfdm/json/UserInterface.json
|
||||
./tools/validate_json_plugin.py test/files/etc/bbfdm/json/UserInterface.json
|
||||
check_ret $?
|
||||
|
||||
echo "Validate X_IOPSYS_EU_TEST JSON Plugin"
|
||||
./test/tools/validate_json_plugin.py test/files/etc/bbfdm/json/X_IOPSYS_EU_TEST.json
|
||||
./tools/validate_json_plugin.py test/files/etc/bbfdm/json/X_IOPSYS_EU_TEST.json
|
||||
check_ret $?
|
||||
|
||||
echo "Validate X_IOPSYS_EU_WiFi JSON Plugin"
|
||||
./test/tools/validate_json_plugin.py test/files/etc/bbfdm/json/X_IOPSYS_EU_WiFi.json
|
||||
./tools/validate_json_plugin.py test/files/etc/bbfdm/json/X_IOPSYS_EU_WiFi.json
|
||||
check_ret $?
|
||||
|
||||
echo "Validate TR-181 JSON Plugin after generating from XML"
|
||||
json_path=$(./tools/convert_dm_xml_to_json.py test/tools/tr-181-2-14-1-cwmp-full.xml test/tools/tr-181-2-14-1-usp-full.xml Device.)
|
||||
./test/tools/validate_json_plugin.py $json_path
|
||||
./tools/validate_json_plugin.py $json_path
|
||||
check_ret $?
|
||||
|
||||
echo "Validate TR-104 JSON Plugin after generating from XML"
|
||||
json_path=$(./tools/convert_dm_xml_to_json.py test/tools/tr-104-2-0-2-cwmp-full.xml test/tools/tr-104-2-0-2-usp-full.xml Device.Services.VoiceService.)
|
||||
./test/tools/validate_json_plugin.py $json_path
|
||||
./tools/validate_json_plugin.py $json_path
|
||||
check_ret $?
|
||||
|
||||
echo "Validate TR-135 JSON Plugin after generating from XML"
|
||||
json_path=$(./tools/convert_dm_xml_to_json.py test/tools/tr-135-1-4-1-cwmp-full.xml test/tools/tr-135-1-4-1-usp-full.xml Device.Services.STBService.)
|
||||
./test/tools/validate_json_plugin.py $json_path
|
||||
./tools/validate_json_plugin.py $json_path
|
||||
check_ret $?
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@
|
|||
# Copyright (C) 2021 iopsys Software Solutions AB
|
||||
# Author: Amin Ben Ramdhane <amin.benramdhane@pivasoftware.com>
|
||||
|
||||
import os
|
||||
import sys
|
||||
import json
|
||||
from jsonschema import validate
|
||||
|
|
@ -243,10 +242,10 @@ def parse_value( key , value ):
|
|||
if len(sys.argv) < 2:
|
||||
print_validate_json_usage()
|
||||
|
||||
json_file = open(sys.argv[1], "r")
|
||||
json_file = open(sys.argv[1], "r", encoding='utf-8')
|
||||
json_data = json.loads(json_file.read())
|
||||
|
||||
for key, value in json_data.items():
|
||||
parse_value(key , value)
|
||||
for __key, __value in json_data.items():
|
||||
parse_value(__key , __value)
|
||||
|
||||
print("JSON File is Valid")
|
||||
Loading…
Add table
Reference in a new issue