Skip to content

Commit

Permalink
https://telecominfraproject.atlassian.net/browse/WIFI-13200
Browse files Browse the repository at this point in the history
Signed-off-by: stephb9959 <[email protected]>
  • Loading branch information
stephb9959 committed Dec 11, 2023
1 parent 6eb50d1 commit 7972b7c
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 4 deletions.
5 changes: 3 additions & 2 deletions src/Tasks/VenueConfigUpdater.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,9 @@ namespace OpenWifi {

Poco::ThreadPool Pool_;
std::list<VenueDeviceConfigUpdater *> JobList;

for (const auto &uuid : Venue.devices) {
std::vector<std::string> DeviceList;
StorageService()->InventoryDB().GetDevicesUUIDForVenue(Venue.info.id, DeviceList);
for (const auto &uuid : DeviceList) {
auto NewTask = new VenueDeviceConfigUpdater(uuid, Venue.info.name, Logger());
bool TaskAdded = false;
while (!TaskAdded) {
Expand Down
4 changes: 3 additions & 1 deletion src/Tasks/VenueRebooter.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,10 @@ namespace OpenWifi {

Poco::ThreadPool Pool_;
std::list<VenueDeviceRebooter *> JobList;
std::vector<std::string> DeviceList;
StorageService()->InventoryDB().GetDevicesUUIDForVenue(Venue.info.id, DeviceList);

for (const auto &uuid : Venue.devices) {
for (const auto &uuid : DeviceList) {
auto NewTask = new VenueDeviceRebooter(uuid, Venue.info.name, Logger());
bool TaskAdded = false;
while (!TaskAdded) {
Expand Down
4 changes: 3 additions & 1 deletion src/Tasks/VenueUpgrade.h
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,10 @@ namespace OpenWifi {
ProvObjects::DeviceRules Rules;

StorageService()->VenueDB().EvaluateDeviceRules(Venue.info.id, Rules);
std::vector<std::string> DeviceList;
StorageService()->InventoryDB().GetDevicesUUIDForVenue(Venue.info.id, DeviceList);

for (const auto &uuid : Venue.devices) {
for (const auto &uuid : DeviceList) {
auto NewTask =
new VenueDeviceUpgrade(uuid, Venue.info.name, Revision_, Rules, Logger());
bool TaskAdded = false;
Expand Down
22 changes: 22 additions & 0 deletions src/storage/storage_inventory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,28 @@ namespace OpenWifi {
return false;
}

bool InventoryDB::GetDevicesUUIDForVenue(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.info.id);
}
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));
Expand Down
1 change: 1 addition & 0 deletions src/storage/storage_inventory.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ namespace OpenWifi {
bool Upgrade(uint32_t from, uint32_t &to) override;

bool GetDevicesForVenue(const std::string &uuid, std::vector<std::string> &devices);
bool GetDevicesUUIDForVenue(const std::string &uuid, std::vector<std::string> &devices);
bool GetDevicesForVenue(const std::string &uuid, std::vector<ProvObjects::InventoryTag> &devices);

private:
Expand Down

0 comments on commit 7972b7c

Please sign in to comment.