mirror of
https://github.com/Telecominfraproject/wlan-cloud-owprov.git
synced 2025-10-30 02:02:36 +00:00
Adding tree import.
This commit is contained in:
@@ -91,32 +91,24 @@ namespace OpenWifi {
|
||||
}
|
||||
|
||||
|
||||
bool APConfig::Get(std::string &Config) {
|
||||
bool APConfig::Get(Poco::JSON::Object &Configuration) {
|
||||
|
||||
if(Config_.empty()) {
|
||||
try {
|
||||
std::cout << __LINE__ << std::endl;
|
||||
ProvObjects::InventoryTag D;
|
||||
std::cout << __LINE__ << std::endl;
|
||||
if(Storage()->InventoryDB().GetRecord("serialNumber", SerialNumber_, D)) {
|
||||
std::cout << __LINE__ << std::endl;
|
||||
|
||||
if(!D.deviceConfiguration.empty()) {
|
||||
std::cout << __LINE__ << std::endl;
|
||||
AddConfiguration(D.deviceConfiguration);
|
||||
}
|
||||
if(!D.entity.empty()) {
|
||||
std::cout << __LINE__ << std::endl;
|
||||
AddEntityConfig(D.entity);
|
||||
} else if(!D.venue.empty()) {
|
||||
std::cout << __LINE__ << std::endl;
|
||||
AddVenueConfig(D.venue);
|
||||
}
|
||||
}
|
||||
|
||||
// Now we have all the config we need.
|
||||
} catch (const Poco::Exception &E ) {
|
||||
std::cout << __LINE__ << std::endl;
|
||||
Logger_.log(E);
|
||||
}
|
||||
}
|
||||
@@ -131,30 +123,19 @@ namespace OpenWifi {
|
||||
|
||||
Poco::JSON::Object CFG;
|
||||
for(const auto &i:Config_) {
|
||||
std::cout << __LINE__ << std::endl;
|
||||
for(const auto &ConfigElement:i.configuration) {
|
||||
std::cout << __LINE__ << std::endl;
|
||||
Poco::JSON::Parser P;
|
||||
std::cout << __LINE__ << std::endl;
|
||||
auto O = P.parse(ConfigElement.configuration).extract<Poco::JSON::Object::Ptr>();
|
||||
for(const auto &j:*O) {
|
||||
std::cout << __LINE__ << std::endl;
|
||||
CFG.set(j.first,j.second);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
std::stringstream O;
|
||||
Poco::JSON::Stringifier::stringify(CFG,O);
|
||||
|
||||
std::cout << __LINE__ << std::endl;
|
||||
Config = O.str();
|
||||
std::cout << __LINE__ << std::endl;
|
||||
Configuration = CFG;
|
||||
|
||||
if(Config_.empty())
|
||||
return false;
|
||||
|
||||
std::cout << __LINE__ << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ namespace OpenWifi {
|
||||
explicit APConfig(const std::string & SerialNumber, const std::string & DeviceType, Poco::Logger & L);
|
||||
|
||||
|
||||
[[nodiscard]] bool Get(std::string &Config);
|
||||
[[nodiscard]] bool Get(Poco::JSON::Object &Configuration);
|
||||
|
||||
void AddConfiguration(const std::string &UUID);
|
||||
void AddVenueConfig(const std::string &UUID);
|
||||
|
||||
@@ -40,41 +40,28 @@ namespace OpenWifi{
|
||||
void RESTAPI_inventory_handler::DoGet(Poco::Net::HTTPServerRequest &Request,
|
||||
Poco::Net::HTTPServerResponse &Response) {
|
||||
try {
|
||||
std::cout << __LINE__ << std::endl;
|
||||
std::string SerialNumber = GetBinding(RESTAPI::Protocol::SERIALNUMBER,"");
|
||||
std::cout << __LINE__ << std::endl;
|
||||
if(SerialNumber.empty()) {
|
||||
std::cout << __LINE__ << std::endl;
|
||||
BadRequest(Request, Response, "Missing SerialNumber.");
|
||||
return;
|
||||
}
|
||||
|
||||
ProvObjects::InventoryTag IT;
|
||||
std::cout << __LINE__ << std::endl;
|
||||
if(Storage()->InventoryDB().GetRecord(RESTAPI::Protocol::SERIALNUMBER,SerialNumber,IT)) {
|
||||
std::string Arg;
|
||||
std::cout << __LINE__ << std::endl;
|
||||
if(HasParameter("config",Arg) && Arg=="true") {
|
||||
std::cout << __LINE__ << std::endl;
|
||||
APConfig Device(SerialNumber,IT.deviceType,Logger_);
|
||||
std::cout << __LINE__ << std::endl;
|
||||
|
||||
Poco::JSON::Object Answer;
|
||||
std::string C;
|
||||
if(Device.Get(C)) {
|
||||
std::cout << __LINE__ << std::endl;
|
||||
Answer.set("config", C);
|
||||
std::cout << __LINE__ << std::endl;
|
||||
Poco::JSON::Object Configuration;
|
||||
if(Device.Get(Configuration)) {
|
||||
Answer.set("config", Configuration);
|
||||
} else {
|
||||
std::cout << __LINE__ << std::endl;
|
||||
Answer.set("config","none");
|
||||
std::cout << __LINE__ << std::endl;
|
||||
}
|
||||
ReturnObject(Request, Answer, Response);
|
||||
std::cout << __LINE__ << std::endl;
|
||||
return;
|
||||
} else {
|
||||
std::cout << __LINE__ << std::endl;
|
||||
Poco::JSON::Object Answer;
|
||||
IT.to_json(Answer);
|
||||
ReturnObject(Request, Answer, Response);
|
||||
|
||||
@@ -332,13 +332,11 @@ listconfigs() {
|
||||
}
|
||||
|
||||
deviceconfig() {
|
||||
gettag() {
|
||||
curl ${FLAGS} "https://${OWPROV}/api/v1/inventory/$1?config=true" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer ${token}" \
|
||||
-H "accept: application/json" > ${result_file}
|
||||
jq < ${result_file}
|
||||
}
|
||||
curl ${FLAGS} "https://${OWPROV}/api/v1/inventory/$1?config=true" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer ${token}" \
|
||||
-H "accept: application/json" > ${result_file}
|
||||
jq < ${result_file}
|
||||
}
|
||||
|
||||
shopt -s nocasematch
|
||||
|
||||
Reference in New Issue
Block a user