Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SDSTOR-13146 : Update AM's /api/v1/utilization endpoint #362

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion conanfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

class HomestoreConan(ConanFile):
name = "homestore"
version = "3.8.1"
version = "3.8.2"

homepage = "https://github.corp.ebay.com/SDS/homestore"
description = "HomeStore"
Expand Down
17 changes: 11 additions & 6 deletions src/homeblks/homeblks_http_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,13 @@ void HomeBlksHttpServer::set_log_level(const Pistache::Rest::Request& request,

response.send(Pistache::Http::Code::Ok, resp);
}
void HomeBlksHttpServer::get_utilization(const Pistache::Rest::Request& request, Pistache::Http::ResponseWriter response)
{
const std::string vol_uuid = request.hasParam(":volumeUUID") ? request.param(":volumeUUID").as<std::string>():"";
void HomeBlksHttpServer::get_utilization(const Pistache::Rest::Request& request,
Pistache::Http::ResponseWriter response) {
const std::string vol_uuid =
request.hasParam(":volumeUUID") ? request.param(":volumeUUID").as< std::string >() : "";

VolumePtr vol = nullptr;
if (vol_uuid.length() != 0) {
if (vol_uuid.length()) {
boost::uuids::string_generator gen;
boost::uuids::uuid uuid = gen(vol_uuid);
vol = VolInterface::get_instance()->lookup_volume(uuid);
Expand All @@ -170,10 +171,14 @@ void HomeBlksHttpServer::get_utilization(const Pistache::Rest::Request& request,
}
}
nlohmann::json resp;
const auto total_data_size = VolInterface::get_instance()->get_system_capacity().initial_total_data_meta_size;
nlohmann::json partitions = nlohmann::json::array();
for (auto [uuid, vol_used] : VolInterface::get_instance()->get_used_size(vol)) {
resp[boost::uuids::to_string(uuid)] = std::to_string(static_cast<double> (vol_used)/ total_data_size);
nlohmann::json partition;
partition["id"] = boost::uuids::to_string(uuid);
partition["usedCapacity"] = vol_used;
partitions.push_back(partition);
}
resp["partitions"] = partitions;
response.send(Pistache::Http::Code::Ok, resp.dump());
}
void HomeBlksHttpServer::get_log_level(const Pistache::Rest::Request& request,
Expand Down
Loading