mirror of
https://github.com/Telecominfraproject/wlan-cloud-owprov.git
synced 2025-10-30 02:02:36 +00:00
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
This commit is contained in:
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
#include "Poco/JSON/Parser.h"
|
#include "Poco/JSON/Parser.h"
|
||||||
#include "Poco/StringTokenizer.h"
|
#include "Poco/StringTokenizer.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
|
|
||||||
@@ -214,29 +215,22 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
// Apply overrides...
|
// Apply overrides...
|
||||||
ProvObjects::ConfigurationOverrideList COL;
|
ProvObjects::ConfigurationOverrideList COL;
|
||||||
std::cout << __LINE__ << std::endl;
|
|
||||||
if(StorageService()->OverridesDB().GetRecord("serialNumber", SerialNumber_, COL)) {
|
if(StorageService()->OverridesDB().GetRecord("serialNumber", SerialNumber_, COL)) {
|
||||||
std::cout << __LINE__ << std::endl;
|
|
||||||
for (const auto &col: COL.overrides) {
|
for (const auto &col: COL.overrides) {
|
||||||
std::cout << __LINE__ << std::endl;
|
|
||||||
const auto Tokens = Poco::StringTokenizer(col.parameterName, ".");
|
const auto Tokens = Poco::StringTokenizer(col.parameterName, ".");
|
||||||
std::cout << __LINE__ << std::endl;
|
|
||||||
if (Tokens[0] == "radios" && Tokens.count() == 3) {
|
if (Tokens[0] == "radios" && Tokens.count() == 3) {
|
||||||
std::cout << __LINE__ << std::endl;
|
|
||||||
std::uint64_t RadioIndex = std::strtoull(Tokens[1].c_str(), nullptr, 10);
|
std::uint64_t RadioIndex = std::strtoull(Tokens[1].c_str(), nullptr, 10);
|
||||||
if (RadioIndex < MaximumPossibleRadios) {
|
if (RadioIndex < MaximumPossibleRadios) {
|
||||||
std::cout << __LINE__ << std::endl;
|
|
||||||
auto RadioArray = Configuration->getArray("radios");
|
auto RadioArray = Configuration->getArray("radios");
|
||||||
if (RadioIndex < RadioArray->size()) {
|
if (RadioIndex < RadioArray->size()) {
|
||||||
std::cout << __LINE__ << std::endl;
|
|
||||||
auto IndexedRadio = RadioArray->get(RadioIndex).extract<Poco::JSON::Object::Ptr>();
|
auto IndexedRadio = RadioArray->get(RadioIndex).extract<Poco::JSON::Object::Ptr>();
|
||||||
std::cout << __LINE__ << std::endl;
|
|
||||||
if (Tokens[2] == "tx-power") {
|
if (Tokens[2] == "tx-power") {
|
||||||
std::cout << __LINE__ << std::endl;
|
IndexedRadio->set("rx-power",
|
||||||
IndexedRadio->set("rx-power", std::strtoull(col.parameterValue.c_str(), nullptr,10));
|
std::strtoull(col.parameterValue.c_str(), nullptr, 10));
|
||||||
if (Explain_) {
|
if (Explain_) {
|
||||||
Poco::JSON::Object ExObj;
|
Poco::JSON::Object ExObj;
|
||||||
ExObj.set("overrides", col.parameterName);
|
ExObj.set("from-name", "overrides");
|
||||||
|
ExObj.set("override", col.parameterName);
|
||||||
ExObj.set("source", col.source);
|
ExObj.set("source", col.source);
|
||||||
ExObj.set("reason", col.reason);
|
ExObj.set("reason", col.reason);
|
||||||
ExObj.set("value", col.parameterValue);
|
ExObj.set("value", col.parameterValue);
|
||||||
@@ -245,12 +239,13 @@ namespace OpenWifi {
|
|||||||
RadioArray->set(RadioIndex, IndexedRadio);
|
RadioArray->set(RadioIndex, IndexedRadio);
|
||||||
Configuration->set("radios", RadioArray);
|
Configuration->set("radios", RadioArray);
|
||||||
} else if (Tokens[2] == "channel") {
|
} else if (Tokens[2] == "channel") {
|
||||||
std::cout << __LINE__ << std::endl;
|
IndexedRadio->set("channel",
|
||||||
IndexedRadio->set("channel", std::strtoull(col.parameterValue.c_str(), nullptr,10));
|
std::strtoull(col.parameterValue.c_str(), nullptr, 10));
|
||||||
std::cout << "Setting channel in radio " << RadioIndex << std::endl;
|
std::cout << "Setting channel in radio " << RadioIndex << std::endl;
|
||||||
if (Explain_) {
|
if (Explain_) {
|
||||||
Poco::JSON::Object ExObj;
|
Poco::JSON::Object ExObj;
|
||||||
ExObj.set("overrides", col.parameterName);
|
ExObj.set("from-name", "overrides");
|
||||||
|
ExObj.set("override", col.parameterName);
|
||||||
ExObj.set("source", col.source);
|
ExObj.set("source", col.source);
|
||||||
ExObj.set("reason", col.reason);
|
ExObj.set("reason", col.reason);
|
||||||
ExObj.set("value", col.parameterValue);
|
ExObj.set("value", col.parameterValue);
|
||||||
@@ -259,10 +254,16 @@ namespace OpenWifi {
|
|||||||
RadioArray->set(RadioIndex, IndexedRadio);
|
RadioArray->set(RadioIndex, IndexedRadio);
|
||||||
Configuration->set("radios", RadioArray);
|
Configuration->set("radios", RadioArray);
|
||||||
} else {
|
} else {
|
||||||
std::cout << __LINE__ << std::endl;
|
poco_error(Logger(), fmt::format("{}: Unsupported override variable name {}",
|
||||||
|
col.parameterName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
poco_error(Logger(), fmt::format("{}: radio index out of range in {}", col.parameterName));
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
poco_error(Logger(),
|
||||||
|
fmt::format("{}: Unsupported override variable name {}", col.parameterName));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -575,7 +575,7 @@ listoverrides() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
addoverride() {
|
addoverride() {
|
||||||
payload="{ \"serialNumber\" : \"$1\" , \"overrides\" : [ { \"reason\" : \"test\" , \"parameterName\" : \"radio.0.channel\" , \"parameterType\" : \"string\" , \"parameterValue\" : \"16\"} ] }"
|
payload="{ \"serialNumber\" : \"$1\" , \"overrides\" : [ { \"reason\" : \"test\" , \"parameterName\" : \"radios.0.channel\" , \"parameterType\" : \"string\" , \"parameterValue\" : \"14\"} ] }"
|
||||||
curl ${FLAGS} -X PUT "https://${OWPROV}/api/v1/configurationOverrides/$1?source=test" \
|
curl ${FLAGS} -X PUT "https://${OWPROV}/api/v1/configurationOverrides/$1?source=test" \
|
||||||
-H "Content-Type: application/json" \
|
-H "Content-Type: application/json" \
|
||||||
-H "Authorization: Bearer ${token}" \
|
-H "Authorization: Bearer ${token}" \
|
||||||
|
|||||||
Reference in New Issue
Block a user