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 15, 2023
1 parent 4e92a19 commit 5a8d5a1
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 11 deletions.
27 changes: 19 additions & 8 deletions src/Tasks/VenueUpgrade.h
Original file line number Diff line number Diff line change
Expand Up @@ -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_));
Expand All @@ -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;

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand All @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions src/UI_Prov_WebSocketNotifications.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/UI_Prov_WebSocketNotifications.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ namespace OpenWifi::ProvWebSocketNotifications {

struct FWUpgradeList {
std::string title, details, jobId;
std::vector<std::string> success, skipped, no_firmware, not_connected;
std::vector<std::string> success, skipped, no_firmware, not_connected, pending;
uint64_t timeStamp = OpenWifi::Utils::Now();

void to_json(Poco::JSON::Object &Obj) const;
Expand Down
3 changes: 2 additions & 1 deletion src/sdks/SDK_gw.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/sdks/SDK_gw.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 5a8d5a1

Please sign in to comment.