From 5a8d5a1fa1504a9b20111ed574d7307ebe291e6f Mon Sep 17 00:00:00 2001 From: stephb9959 Date: Fri, 15 Dec 2023 08:47:07 -0800 Subject: [PATCH] https://telecominfraproject.atlassian.net/browse/WIFI-13200 Signed-off-by: stephb9959 --- src/Tasks/VenueUpgrade.h | 27 ++++++++++++++++++-------- src/UI_Prov_WebSocketNotifications.cpp | 2 ++ src/UI_Prov_WebSocketNotifications.h | 2 +- src/sdks/SDK_gw.cpp | 3 ++- src/sdks/SDK_gw.h | 2 +- 5 files changed, 25 insertions(+), 11 deletions(-) diff --git a/src/Tasks/VenueUpgrade.h b/src/Tasks/VenueUpgrade.h index a03b169..14393e4 100644 --- a/src/Tasks/VenueUpgrade.h +++ b/src/Tasks/VenueUpgrade.h @@ -36,10 +36,15 @@ namespace OpenWifi { FMSObjects::Firmware F; if (SDK::FMS::Firmware::GetFirmware(Device.deviceType, revision_, F)) { - if (SDK::GW::Device::Upgrade(nullptr, Device.serialNumber, 0, F.uri)) { - Logger().debug( - fmt::format("{}: Upgraded to {}.", Device.serialNumber, revision_)); - upgraded_++; + std::string Status; + if (SDK::GW::Device::Upgrade(nullptr, Device.serialNumber, 0, F.uri, Status)) { + if(Status=="pending") { + pending_++; + poco_debug(Logger(), fmt::format("Upgrade Pending: {} : {}", Device.serialNumber, Status)); + } else { + upgraded_++; + poco_debug(Logger(), fmt::format("Upgrade Success: {} : {}", Device.serialNumber, Status)); + } } else { poco_information(Logger(), fmt::format("{}: Not Upgraded to {}.", Device.serialNumber, revision_)); @@ -55,7 +60,7 @@ namespace OpenWifi { done_ = true; } - std::uint64_t upgraded_ = 0, not_connected_ = 0, skipped_ = 0, no_firmware_ = 0; + std::uint64_t upgraded_ = 0, not_connected_ = 0, skipped_ = 0, no_firmware_ = 0, pending_ = 0; bool started_ = false, done_ = false; std::string SerialNumber; @@ -84,7 +89,7 @@ namespace OpenWifi { ProvWebSocketNotifications::VenueFWUpgradeList_t N; ProvObjects::Venue Venue; - uint64_t upgraded_ = 0, not_connected_ = 0, skipped_ = 0, no_firmware_ = 0; + uint64_t upgraded_ = 0, not_connected_ = 0, skipped_ = 0, no_firmware_ = 0, pending_=0; if (StorageService()->VenueDB().GetRecord("id", VenueUUID_, Venue)) { N.content.title = fmt::format("Upgrading {} devices.", Venue.info.name); @@ -126,10 +131,13 @@ namespace OpenWifi { N.content.not_connected.push_back(current_job->SerialNumber); else if (current_job->no_firmware_) N.content.no_firmware.push_back(current_job->SerialNumber); + else if (current_job->pending_) + N.content.pending.push_back(current_job->SerialNumber); upgraded_ += current_job->upgraded_; skipped_ += current_job->skipped_; no_firmware_ += current_job->no_firmware_; not_connected_ += current_job->not_connected_; + pending_ += current_job->pending_; job_it = JobList.erase(job_it); delete current_job; } else { @@ -151,10 +159,13 @@ namespace OpenWifi { N.content.not_connected.push_back(current_job->SerialNumber); else if (current_job->no_firmware_) N.content.no_firmware.push_back(current_job->SerialNumber); + else if (current_job->pending_) + N.content.pending.push_back(current_job->SerialNumber); upgraded_ += current_job->upgraded_; skipped_ += current_job->skipped_; no_firmware_ += current_job->no_firmware_; not_connected_ += current_job->not_connected_; + pending_ += current_job->pending_; job_it = JobList.erase(job_it); delete current_job; } else { @@ -163,8 +174,8 @@ namespace OpenWifi { } N.content.details = fmt::format( - "Job {} Completed: {} upgraded, {} not connected, {} skipped, {} no firmware.", - JobId(), upgraded_, not_connected_, skipped_, no_firmware_); + "Job {} Completed: {} upgraded, {} not connected, {} skipped, {} no firmware, {} pending.", + JobId(), upgraded_, not_connected_, skipped_, no_firmware_, pending_); } else { N.content.details = fmt::format("Venue {} no longer exists.", VenueUUID_); Logger().warning(N.content.details); diff --git a/src/UI_Prov_WebSocketNotifications.cpp b/src/UI_Prov_WebSocketNotifications.cpp index c05341e..37e25e0 100644 --- a/src/UI_Prov_WebSocketNotifications.cpp +++ b/src/UI_Prov_WebSocketNotifications.cpp @@ -60,6 +60,7 @@ namespace OpenWifi::ProvWebSocketNotifications { RESTAPI_utils::field_to_json(Obj, "success", success); RESTAPI_utils::field_to_json(Obj, "notConnected", not_connected); RESTAPI_utils::field_to_json(Obj, "noFirmware", no_firmware); + RESTAPI_utils::field_to_json(Obj, "pending", pending); RESTAPI_utils::field_to_json(Obj, "skipped", skipped); RESTAPI_utils::field_to_json(Obj, "timeStamp", timeStamp); RESTAPI_utils::field_to_json(Obj, "details", details); @@ -71,6 +72,7 @@ namespace OpenWifi::ProvWebSocketNotifications { RESTAPI_utils::field_from_json(Obj, "jobId", jobId); RESTAPI_utils::field_from_json(Obj, "success", success); RESTAPI_utils::field_from_json(Obj, "notConnected", not_connected); + RESTAPI_utils::field_from_json(Obj, "pending", pending); RESTAPI_utils::field_from_json(Obj, "noFirmware", no_firmware); RESTAPI_utils::field_from_json(Obj, "skipped", skipped); RESTAPI_utils::field_from_json(Obj, "timeStamp", timeStamp); diff --git a/src/UI_Prov_WebSocketNotifications.h b/src/UI_Prov_WebSocketNotifications.h index 29fcbcd..1aa61f4 100644 --- a/src/UI_Prov_WebSocketNotifications.h +++ b/src/UI_Prov_WebSocketNotifications.h @@ -32,7 +32,7 @@ namespace OpenWifi::ProvWebSocketNotifications { struct FWUpgradeList { std::string title, details, jobId; - std::vector success, skipped, no_firmware, not_connected; + std::vector success, skipped, no_firmware, not_connected, pending; uint64_t timeStamp = OpenWifi::Utils::Now(); void to_json(Poco::JSON::Object &Obj) const; diff --git a/src/sdks/SDK_gw.cpp b/src/sdks/SDK_gw.cpp index 03fe70b..9e4a79c 100644 --- a/src/sdks/SDK_gw.cpp +++ b/src/sdks/SDK_gw.cpp @@ -79,7 +79,7 @@ namespace OpenWifi::SDK::GW { } bool Upgrade(RESTAPIHandler *client, const std::string &SerialNumber, uint64_t When, - const std::string &ImageName) { + const std::string &ImageName, std::string &status) { Poco::JSON::Object Body; Body.set(RESTAPI::Protocol::SERIALNUMBER, SerialNumber); @@ -92,6 +92,7 @@ namespace OpenWifi::SDK::GW { auto ResponseStatus = API.Do(CallResponse, client ? client->UserInfo_.webtoken.access_token_ : ""); if (ResponseStatus == Poco::Net::HTTPResponse::HTTP_OK) { + status = CallResponse->get("status").toString(); return true; } return false; diff --git a/src/sdks/SDK_gw.h b/src/sdks/SDK_gw.h index b3c3048..6d300c9 100644 --- a/src/sdks/SDK_gw.h +++ b/src/sdks/SDK_gw.h @@ -23,7 +23,7 @@ namespace OpenWifi::SDK::GW { bool Configure(RESTAPIHandler *client, const std::string &Mac, Poco::JSON::Object::Ptr &Configuration, Poco::JSON::Object::Ptr &Response); bool Upgrade(RESTAPIHandler *client, const std::string &Mac, uint64_t When, - const std::string &ImageName); + const std::string &ImageName, std::string &status); bool SetVenue(RESTAPIHandler *client, const std::string &SerialNumber, const std::string &uuid);