mirror of
https://github.com/Telecominfraproject/wlan-cloud-owprov.git
synced 2025-10-29 17:52:28 +00:00
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
This commit is contained in:
@@ -276,21 +276,19 @@ namespace OpenWifi {
|
|||||||
auto testUpdateOnly = GetBoolParameter("testUpdateOnly");
|
auto testUpdateOnly = GetBoolParameter("testUpdateOnly");
|
||||||
if (testUpdateOnly) {
|
if (testUpdateOnly) {
|
||||||
ProvObjects::SerialNumberList SNL;
|
ProvObjects::SerialNumberList SNL;
|
||||||
|
StorageService()->InventoryDB().GetDevicesForVenue(UUID, SNL.serialNumbers);
|
||||||
Poco::JSON::Object Answer;
|
Poco::JSON::Object Answer;
|
||||||
SNL.serialNumbers = Existing.devices;
|
|
||||||
SNL.to_json(Answer);
|
SNL.to_json(Answer);
|
||||||
return ReturnObject(Answer);
|
return ReturnObject(Answer);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GetBoolParameter("updateAllDevices")) {
|
if (GetBoolParameter("updateAllDevices")) {
|
||||||
ProvObjects::SerialNumberList SNL;
|
ProvObjects::SerialNumberList SNL;
|
||||||
|
StorageService()->InventoryDB().GetDevicesForVenue(UUID, SNL.serialNumbers);
|
||||||
|
|
||||||
Poco::JSON::Object Answer;
|
Poco::JSON::Object Answer;
|
||||||
SNL.serialNumbers = Existing.devices;
|
|
||||||
auto JobId = MicroServiceCreateUUID();
|
auto JobId = MicroServiceCreateUUID();
|
||||||
Types::StringVec Parameters{UUID};
|
Types::StringVec Parameters{UUID};
|
||||||
;
|
|
||||||
auto NewJob = new VenueConfigUpdater(JobId, "VenueConfigurationUpdater", Parameters, 0,
|
auto NewJob = new VenueConfigUpdater(JobId, "VenueConfigurationUpdater", Parameters, 0,
|
||||||
UserInfo_.userinfo, Logger());
|
UserInfo_.userinfo, Logger());
|
||||||
JobController()->AddJob(dynamic_cast<Job *>(NewJob));
|
JobController()->AddJob(dynamic_cast<Job *>(NewJob));
|
||||||
@@ -302,11 +300,10 @@ namespace OpenWifi {
|
|||||||
if (GetBoolParameter("upgradeAllDevices")) {
|
if (GetBoolParameter("upgradeAllDevices")) {
|
||||||
if (GetBoolParameter("revisionsAvailable")) {
|
if (GetBoolParameter("revisionsAvailable")) {
|
||||||
std::set<std::string> DeviceTypes;
|
std::set<std::string> DeviceTypes;
|
||||||
for (const auto &serialNumber : Existing.devices) {
|
std::vector<ProvObjects::InventoryTag> ExistingDevices;
|
||||||
ProvObjects::InventoryTag Device;
|
StorageService()->InventoryDB().GetDevicesForVenue(UUID, ExistingDevices);
|
||||||
if (StorageService()->InventoryDB().GetRecord("id", serialNumber, Device)) {
|
for (const auto &device : ExistingDevices) {
|
||||||
DeviceTypes.insert(Device.deviceType);
|
DeviceTypes.insert(device.deviceType);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get all the revisions for all the device types
|
// Get all the revisions for all the device types
|
||||||
@@ -374,18 +371,17 @@ namespace OpenWifi {
|
|||||||
return ReturnObject(Answer);
|
return ReturnObject(Answer);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProvObjects::SerialNumberList SNL;
|
|
||||||
|
|
||||||
auto Revision = GetParameter("revision", "");
|
auto Revision = GetParameter("revision", "");
|
||||||
if (Revision.empty()) {
|
if (Revision.empty()) {
|
||||||
return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
|
return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ProvObjects::SerialNumberList SNL;
|
||||||
|
StorageService()->InventoryDB().GetDevicesForVenue(UUID, SNL.serialNumbers);
|
||||||
|
|
||||||
Poco::JSON::Object Answer;
|
Poco::JSON::Object Answer;
|
||||||
SNL.serialNumbers = Existing.devices;
|
|
||||||
auto JobId = MicroServiceCreateUUID();
|
auto JobId = MicroServiceCreateUUID();
|
||||||
Types::StringVec Parameters{UUID, Revision};
|
Types::StringVec Parameters{UUID, Revision};
|
||||||
;
|
|
||||||
auto NewJob = new VenueUpgrade(JobId, "VenueFirmwareUpgrade", Parameters, 0,
|
auto NewJob = new VenueUpgrade(JobId, "VenueFirmwareUpgrade", Parameters, 0,
|
||||||
UserInfo_.userinfo, Logger());
|
UserInfo_.userinfo, Logger());
|
||||||
JobController()->AddJob(dynamic_cast<Job *>(NewJob));
|
JobController()->AddJob(dynamic_cast<Job *>(NewJob));
|
||||||
@@ -396,9 +392,9 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
if (GetBoolParameter("rebootAllDevices")) {
|
if (GetBoolParameter("rebootAllDevices")) {
|
||||||
ProvObjects::SerialNumberList SNL;
|
ProvObjects::SerialNumberList SNL;
|
||||||
|
StorageService()->InventoryDB().GetDevicesForVenue(UUID, SNL.serialNumbers);
|
||||||
|
|
||||||
Poco::JSON::Object Answer;
|
Poco::JSON::Object Answer;
|
||||||
SNL.serialNumbers = Existing.devices;
|
|
||||||
auto JobId = MicroServiceCreateUUID();
|
auto JobId = MicroServiceCreateUUID();
|
||||||
Types::StringVec Parameters{UUID};
|
Types::StringVec Parameters{UUID};
|
||||||
;
|
;
|
||||||
|
|||||||
@@ -232,6 +232,47 @@ namespace OpenWifi {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool InventoryDB::GetDevicesForVenue(const std::string &venue_uuid, std::vector<std::string> &devices) {
|
||||||
|
try {
|
||||||
|
std::vector<ProvObjects::InventoryTag> device_list;
|
||||||
|
if(GetRecords(1, 1000, device_list, fmt::format(" venue='{}' ", venue_uuid))) {
|
||||||
|
for(auto &i:device_list) {
|
||||||
|
devices.push_back(i.serialNumber);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} catch(const Poco::Exception &E) {
|
||||||
|
Logger().log(E);
|
||||||
|
return false;
|
||||||
|
} catch(const std::exception &E) {
|
||||||
|
Logger().error(fmt::format("std::exception: {}",E.what()));
|
||||||
|
return false;
|
||||||
|
} catch(...) {
|
||||||
|
Logger().error("Unknown exception");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool InventoryDB::GetDevicesForVenue(const std::string &venue_uuid, std::vector<ProvObjects::InventoryTag> &devices) {
|
||||||
|
try {
|
||||||
|
return GetRecords(1, 1000, devices, fmt::format(" venue='{}' ", venue_uuid));
|
||||||
|
} catch(const Poco::Exception &E) {
|
||||||
|
Logger().log(E);
|
||||||
|
return false;
|
||||||
|
} catch(const std::exception &E) {
|
||||||
|
Logger().error(fmt::format("std::exception: {}",E.what()));
|
||||||
|
return false;
|
||||||
|
} catch(...) {
|
||||||
|
Logger().error("Unknown exception");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
} // namespace OpenWifi
|
} // namespace OpenWifi
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
|
|||||||
@@ -38,6 +38,9 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
bool Upgrade(uint32_t from, uint32_t &to) override;
|
bool Upgrade(uint32_t from, uint32_t &to) override;
|
||||||
|
|
||||||
|
bool GetDevicesForVenue(const std::string &uuid, std::vector<std::string> &devices);
|
||||||
|
bool GetDevicesForVenue(const std::string &uuid, std::vector<ProvObjects::InventoryTag> &devices);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool EvaluateDeviceRules(const ProvObjects::InventoryTag &T,
|
bool EvaluateDeviceRules(const ProvObjects::InventoryTag &T,
|
||||||
ProvObjects::DeviceRules &Rules);
|
ProvObjects::DeviceRules &Rules);
|
||||||
|
|||||||
Reference in New Issue
Block a user