Add automatic configuration creation.

This commit is contained in:
stephb9959
2022-03-10 15:12:24 -08:00
parent 20070a060f
commit 7bc4766c35
5 changed files with 78 additions and 48 deletions

View File

@@ -98,7 +98,7 @@ namespace OpenWifi{
std::ostringstream OS;
Configuration->stringify(OS);
Results.appliedConfiguration = OS.str();
Poco::JSON::Object::Ptr Response;
auto Response=Poco::makeShared<Poco::JSON::Object>();
Logger().debug(Poco::format("%s: Sending configuration push.",Existing.serialNumber));
if (SDK::GW::Device::Configure(this, SerialNumber, Configuration, Response)) {
Logger().debug(Poco::format("%s: Sending configuration pushed.",Existing.serialNumber));
@@ -259,6 +259,12 @@ namespace OpenWifi{
}
*/
std::string ErrorText;
auto ObjectsCreated = CreateObjects(NewObject,*this,ErrorText);
if(!ErrorText.empty()) {
return BadRequest(ErrorText);
}
__DBG__
if(DB_.CreateRecord(NewObject)) {
__DBG__
@@ -414,6 +420,12 @@ namespace OpenWifi{
Existing.state = NewObject.state;
}
std::string ErrorText;
auto ObjectsCreated = CreateObjects(NewObject,*this,ErrorText);
if(!ErrorText.empty()) {
return BadRequest(ErrorText);
}
if(StorageService()->InventoryDB().UpdateRecord("id", Existing.info.id, Existing)) {
MoveUsage(StorageService()->PolicyDB(),DB_,FromPolicy,ToPolicy,Existing.info.id);
MoveUsage(StorageService()->LocationDB(),DB_,FromLocation,ToLocation,Existing.info.id);