diff --git a/src/Tasks/VenueConfigUpdater.h b/src/Tasks/VenueConfigUpdater.h index baf1af4..c5aaae0 100644 --- a/src/Tasks/VenueConfigUpdater.h +++ b/src/Tasks/VenueConfigUpdater.h @@ -118,8 +118,9 @@ namespace OpenWifi { Poco::ThreadPool Pool_; std::list JobList; - - for (const auto &uuid : Venue.devices) { + std::vector 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) { diff --git a/src/Tasks/VenueRebooter.h b/src/Tasks/VenueRebooter.h index 1607f24..bd0e041 100644 --- a/src/Tasks/VenueRebooter.h +++ b/src/Tasks/VenueRebooter.h @@ -68,8 +68,10 @@ namespace OpenWifi { Poco::ThreadPool Pool_; std::list JobList; + std::vector 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) { diff --git a/src/Tasks/VenueUpgrade.h b/src/Tasks/VenueUpgrade.h index 87defb8..d433970 100644 --- a/src/Tasks/VenueUpgrade.h +++ b/src/Tasks/VenueUpgrade.h @@ -96,8 +96,10 @@ namespace OpenWifi { ProvObjects::DeviceRules Rules; StorageService()->VenueDB().EvaluateDeviceRules(Venue.info.id, Rules); + std::vector 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; diff --git a/src/storage/storage_inventory.cpp b/src/storage/storage_inventory.cpp index 27fa8fd..a38b3be 100644 --- a/src/storage/storage_inventory.cpp +++ b/src/storage/storage_inventory.cpp @@ -255,6 +255,28 @@ namespace OpenWifi { return false; } + bool InventoryDB::GetDevicesUUIDForVenue(const std::string &venue_uuid, std::vector &devices) { + try { + std::vector 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 &devices) { try { return GetRecords(1, 1000, devices, fmt::format(" venue='{}' ", venue_uuid)); diff --git a/src/storage/storage_inventory.h b/src/storage/storage_inventory.h index b96e271..e5750c0 100644 --- a/src/storage/storage_inventory.h +++ b/src/storage/storage_inventory.h @@ -39,6 +39,7 @@ namespace OpenWifi { bool Upgrade(uint32_t from, uint32_t &to) override; bool GetDevicesForVenue(const std::string &uuid, std::vector &devices); + bool GetDevicesUUIDForVenue(const std::string &uuid, std::vector &devices); bool GetDevicesForVenue(const std::string &uuid, std::vector &devices); private: