mirror of
https://github.com/Telecominfraproject/wlan-cloud-owprov.git
synced 2025-11-02 03:27:51 +00:00
Adding configuration validation.
This commit is contained in:
@@ -107,16 +107,25 @@ namespace OpenWifi{
|
|||||||
|
|
||||||
std::string Arg;
|
std::string Arg;
|
||||||
if(HasParameter("validateOnly",Arg) && Arg=="true") {
|
if(HasParameter("validateOnly",Arg) && Arg=="true") {
|
||||||
|
std::cout << __LINE__ << std::endl;
|
||||||
auto Body = ParseStream();
|
auto Body = ParseStream();
|
||||||
|
std::cout << __LINE__ << std::endl;
|
||||||
if(!Body->has("configuration")) {
|
if(!Body->has("configuration")) {
|
||||||
|
std::cout << __LINE__ << std::endl;
|
||||||
BadRequest("Must have 'configuration' element.");
|
BadRequest("Must have 'configuration' element.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
std::cout << __LINE__ << std::endl;
|
||||||
auto Config=Body->get("configuration").toString();
|
auto Config=Body->get("configuration").toString();
|
||||||
|
std::cout << __LINE__ << std::endl;
|
||||||
Poco::JSON::Object Answer;
|
Poco::JSON::Object Answer;
|
||||||
|
std::cout << __LINE__ << std::endl;
|
||||||
auto Res = ValidateUCentralConfiguration(Config);
|
auto Res = ValidateUCentralConfiguration(Config);
|
||||||
|
std::cout << __LINE__ << std::endl;
|
||||||
Answer.set("valid",Res);
|
Answer.set("valid",Res);
|
||||||
|
std::cout << __LINE__ << std::endl;
|
||||||
ReturnObject(Answer);
|
ReturnObject(Answer);
|
||||||
|
std::cout << __LINE__ << std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -380,6 +380,15 @@ adddeviceconfig() {
|
|||||||
jq < ${result_file}
|
jq < ${result_file}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
validateconfig() {
|
||||||
|
curl ${FLAGS} -X POST "https://${OWPROV}/api/v1/configurations/1?validateOnly=true" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-H "Authorization: Bearer ${token}" \
|
||||||
|
-H "accept: application/json" \
|
||||||
|
-d @"$1" > ${result_file}
|
||||||
|
jq < ${result_file}
|
||||||
|
}
|
||||||
|
|
||||||
shopt -s nocasematch
|
shopt -s nocasematch
|
||||||
case "$1" in
|
case "$1" in
|
||||||
"login") login; help ; logout ;;
|
"login") login; help ; logout ;;
|
||||||
@@ -413,6 +422,7 @@ case "$1" in
|
|||||||
"adddeviceconfig") login; adddeviceconfig "$2" "$3"; logout;;
|
"adddeviceconfig") login; adddeviceconfig "$2" "$3"; logout;;
|
||||||
"addconfigmetrics") login; addconfigmetrics "$2" ; logout;;
|
"addconfigmetrics") login; addconfigmetrics "$2" ; logout;;
|
||||||
"addconfigfile") login; addconfigfile "$2" ; logout;;
|
"addconfigfile") login; addconfigfile "$2" ; logout;;
|
||||||
|
"validateconfig") login; validateconfig "$2"; logout;;
|
||||||
*) help ;;
|
*) help ;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
|||||||
96
test_scripts/curl/test-config-1.json
Normal file
96
test_scripts/curl/test-config-1.json
Normal file
@@ -0,0 +1,96 @@
|
|||||||
|
{
|
||||||
|
"configuration" : {
|
||||||
|
"radios": [
|
||||||
|
{
|
||||||
|
"band": "5G",
|
||||||
|
"channel": 52,
|
||||||
|
"channel-mode": "HE",
|
||||||
|
"channel-width": 80,
|
||||||
|
"country": "CA"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"band": "2G",
|
||||||
|
"channel": 11,
|
||||||
|
"channel-mode": "HE",
|
||||||
|
"channel-width": 20,
|
||||||
|
"country": "CA"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
|
||||||
|
"interfaces": [
|
||||||
|
{
|
||||||
|
"name": "WAN",
|
||||||
|
"role": "upstream",
|
||||||
|
"services": [ "lldp" ],
|
||||||
|
"ethernet": [
|
||||||
|
{
|
||||||
|
"select-ports": [
|
||||||
|
"WAN*"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"ipv4": {
|
||||||
|
"addressing": "dynamic"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "LAN",
|
||||||
|
"role": "downstream",
|
||||||
|
"services": [ "ssh", "lldp" ],
|
||||||
|
"ethernet": [
|
||||||
|
{
|
||||||
|
"select-ports": [
|
||||||
|
"LAN*"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"ipv4": {
|
||||||
|
"addressing": "static",
|
||||||
|
"subnet": "192.168.1.1/24",
|
||||||
|
"dhcp": {
|
||||||
|
"lease-first": 10,
|
||||||
|
"lease-count": 100,
|
||||||
|
"lease-time": "6h"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"ssids": [
|
||||||
|
{
|
||||||
|
"name": "OpenWifi",
|
||||||
|
"role": "downstream",
|
||||||
|
"wifi-bands": [
|
||||||
|
"2G", "5G"
|
||||||
|
],
|
||||||
|
"bss-mode": "ap",
|
||||||
|
"encryption": {
|
||||||
|
"proto": "psk2",
|
||||||
|
"key": "OpenWifi",
|
||||||
|
"ieee80211w": "optional"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"metrics": {
|
||||||
|
"statistics": {
|
||||||
|
"interval": 120,
|
||||||
|
"types": [ "ssids", "lldp", "clients" ]
|
||||||
|
},
|
||||||
|
"health": {
|
||||||
|
"interval": 120
|
||||||
|
},
|
||||||
|
"wifi-frames": {
|
||||||
|
"filters": [ "probe", "auth" ]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"services": {
|
||||||
|
"lldp": {
|
||||||
|
"describe": "uCentral",
|
||||||
|
"location": "universe"
|
||||||
|
},
|
||||||
|
"ssh": {
|
||||||
|
"port": 22
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user