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");
|
||||
if (testUpdateOnly) {
|
||||
ProvObjects::SerialNumberList SNL;
|
||||
|
||||
StorageService()->InventoryDB().GetDevicesForVenue(UUID, SNL.serialNumbers);
|
||||
Poco::JSON::Object Answer;
|
||||
SNL.serialNumbers = Existing.devices;
|
||||
SNL.to_json(Answer);
|
||||
return ReturnObject(Answer);
|
||||
}
|
||||
|
||||
if (GetBoolParameter("updateAllDevices")) {
|
||||
ProvObjects::SerialNumberList SNL;
|
||||
StorageService()->InventoryDB().GetDevicesForVenue(UUID, SNL.serialNumbers);
|
||||
|
||||
Poco::JSON::Object Answer;
|
||||
SNL.serialNumbers = Existing.devices;
|
||||
auto JobId = MicroServiceCreateUUID();
|
||||
Types::StringVec Parameters{UUID};
|
||||
;
|
||||
auto NewJob = new VenueConfigUpdater(JobId, "VenueConfigurationUpdater", Parameters, 0,
|
||||
UserInfo_.userinfo, Logger());
|
||||
JobController()->AddJob(dynamic_cast<Job *>(NewJob));
|
||||
@@ -302,11 +300,10 @@ namespace OpenWifi {
|
||||
if (GetBoolParameter("upgradeAllDevices")) {
|
||||
if (GetBoolParameter("revisionsAvailable")) {
|
||||
std::set<std::string> DeviceTypes;
|
||||
for (const auto &serialNumber : Existing.devices) {
|
||||
ProvObjects::InventoryTag Device;
|
||||
if (StorageService()->InventoryDB().GetRecord("id", serialNumber, Device)) {
|
||||
DeviceTypes.insert(Device.deviceType);
|
||||
}
|
||||
std::vector<ProvObjects::InventoryTag> ExistingDevices;
|
||||
StorageService()->InventoryDB().GetDevicesForVenue(UUID, ExistingDevices);
|
||||
for (const auto &device : ExistingDevices) {
|
||||
DeviceTypes.insert(device.deviceType);
|
||||
}
|
||||
|
||||
// Get all the revisions for all the device types
|
||||
@@ -374,18 +371,17 @@ namespace OpenWifi {
|
||||
return ReturnObject(Answer);
|
||||
}
|
||||
|
||||
ProvObjects::SerialNumberList SNL;
|
||||
|
||||
auto Revision = GetParameter("revision", "");
|
||||
if (Revision.empty()) {
|
||||
return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
|
||||
}
|
||||
|
||||
ProvObjects::SerialNumberList SNL;
|
||||
StorageService()->InventoryDB().GetDevicesForVenue(UUID, SNL.serialNumbers);
|
||||
|
||||
Poco::JSON::Object Answer;
|
||||
SNL.serialNumbers = Existing.devices;
|
||||
auto JobId = MicroServiceCreateUUID();
|
||||
Types::StringVec Parameters{UUID, Revision};
|
||||
;
|
||||
auto NewJob = new VenueUpgrade(JobId, "VenueFirmwareUpgrade", Parameters, 0,
|
||||
UserInfo_.userinfo, Logger());
|
||||
JobController()->AddJob(dynamic_cast<Job *>(NewJob));
|
||||
@@ -396,9 +392,9 @@ namespace OpenWifi {
|
||||
|
||||
if (GetBoolParameter("rebootAllDevices")) {
|
||||
ProvObjects::SerialNumberList SNL;
|
||||
StorageService()->InventoryDB().GetDevicesForVenue(UUID, SNL.serialNumbers);
|
||||
|
||||
Poco::JSON::Object Answer;
|
||||
SNL.serialNumbers = Existing.devices;
|
||||
auto JobId = MicroServiceCreateUUID();
|
||||
Types::StringVec Parameters{UUID};
|
||||
;
|
||||
|
||||
@@ -232,6 +232,47 @@ namespace OpenWifi {
|
||||
}
|
||||
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
|
||||
|
||||
template <>
|
||||
|
||||
@@ -38,6 +38,9 @@ namespace OpenWifi {
|
||||
|
||||
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:
|
||||
bool EvaluateDeviceRules(const ProvObjects::InventoryTag &T,
|
||||
ProvObjects::DeviceRules &Rules);
|
||||
|
||||
Reference in New Issue
Block a user