mirror of
https://github.com/Telecominfraproject/wlan-cloud-owprov.git
synced 2025-11-02 03:27:51 +00:00
Adding 'updateAllDevices' for venue configuration push.
This commit is contained in:
@@ -17,8 +17,6 @@
|
||||
#include "SerialNumberCache.h"
|
||||
#include "DeviceTypeCache.h"
|
||||
|
||||
#define __DBG__ std::cout << __LINE__ << std::endl;
|
||||
|
||||
namespace OpenWifi{
|
||||
|
||||
void GetRejectedLines(const Poco::JSON::Object::Ptr &Response, Types::StringVec & Warnings) {
|
||||
@@ -38,41 +36,27 @@ namespace OpenWifi{
|
||||
void RESTAPI_inventory_handler::DoGet() {
|
||||
|
||||
ProvObjects::InventoryTag Existing;
|
||||
__DBG__
|
||||
std::string SerialNumber = GetBinding(RESTAPI::Protocol::SERIALNUMBER,"");
|
||||
__DBG__
|
||||
Logger().debug(Poco::format("%s: Retrieving inventory information.",SerialNumber));
|
||||
__DBG__
|
||||
if(SerialNumber.empty() || !DB_.GetRecord(RESTAPI::Protocol::SERIALNUMBER,SerialNumber,Existing)) {
|
||||
return NotFound();
|
||||
}
|
||||
__DBG__
|
||||
Logger().debug(Poco::format("%s,%s: Retrieving inventory information.", Existing.serialNumber, Existing.info.id ));
|
||||
|
||||
__DBG__
|
||||
Poco::JSON::Object Answer;
|
||||
std::string Arg;
|
||||
__DBG__
|
||||
if(HasParameter("config",Arg) && Arg=="true") {
|
||||
__DBG__
|
||||
bool Explain = (HasParameter("explain",Arg) && Arg == "true");
|
||||
__DBG__
|
||||
APConfig Device(SerialNumber,Existing.deviceType,Logger(), Explain);
|
||||
|
||||
__DBG__
|
||||
auto Configuration = Poco::makeShared<Poco::JSON::Object>();
|
||||
if(Device.Get(Configuration)) {
|
||||
__DBG__
|
||||
Answer.set("config", Configuration);
|
||||
if(Explain)
|
||||
__DBG__
|
||||
Answer.set("explanation", Device.Explanation());
|
||||
} else {
|
||||
__DBG__
|
||||
Answer.set("config","none");
|
||||
__DBG__
|
||||
}
|
||||
__DBG__
|
||||
return ReturnObject(Answer);
|
||||
} else if(HasParameter("firmwareOptions", Arg) && Arg=="true") {
|
||||
ProvObjects::FIRMWARE_UPGRADE_RULES Rules;
|
||||
@@ -246,9 +230,6 @@ namespace OpenWifi{
|
||||
InternalError(RESTAPI::Errors::RecordNotCreated);
|
||||
}
|
||||
|
||||
|
||||
#define __DBG__ std::cout << __LINE__ << std::endl;
|
||||
|
||||
void RESTAPI_inventory_handler::DoPut() {
|
||||
|
||||
std::string SerialNumber = GetBinding(RESTAPI::Protocol::SERIALNUMBER,"");
|
||||
|
@@ -37,7 +37,7 @@ namespace OpenWifi {
|
||||
|
||||
}
|
||||
|
||||
std::string Start() {
|
||||
inline std::string Start() {
|
||||
JobId_ = MicroService::CreateUUID();
|
||||
Worker_.start(*this);
|
||||
return JobId_;
|
||||
@@ -53,7 +53,7 @@ namespace OpenWifi {
|
||||
|
||||
inline Poco::Logger & Logger() { return Logger_; }
|
||||
|
||||
void run() final {
|
||||
inline void run() final {
|
||||
|
||||
if(When_ && When_>OpenWifi::Now())
|
||||
Poco::Thread::trySleep( (long) (When_ - OpenWifi::Now()) * 1000 );
|
||||
@@ -68,7 +68,6 @@ namespace OpenWifi {
|
||||
|
||||
if(StorageService()->InventoryDB().GetRecord("id",uuid,Device)) {
|
||||
Logger().debug(fmt::format("{}: Computing configuration.",Device.serialNumber));
|
||||
std::cout << "Updating device: " << Device.serialNumber << std::endl;
|
||||
auto DeviceConfig = std::make_shared<APConfig>(Device.serialNumber, Device.deviceType, Logger(), false);
|
||||
auto Configuration = Poco::makeShared<Poco::JSON::Object>();
|
||||
Poco::JSON::Object ErrorsObj, WarningsObj;
|
||||
@@ -81,7 +80,6 @@ namespace OpenWifi {
|
||||
Logger().debug(fmt::format("{}: Sending configuration push.",Device.serialNumber));
|
||||
if (SDK::GW::Device::Configure(nullptr, Device.serialNumber, Configuration, Response)) {
|
||||
Logger().debug(fmt::format("{}: Sending configuration pushed.",Device.serialNumber));
|
||||
std::cout << "Updated: " << Device.serialNumber << std::endl;
|
||||
GetRejectedLines(Response, Results.warnings);
|
||||
Results.errorCode = 0;
|
||||
Logger().information(fmt::format("Device {} updated.", Device.serialNumber));
|
||||
|
Reference in New Issue
Block a user