ADD: added function to podcontroller to get number of childpods
This commit is contained in:
@@ -1,7 +1,9 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "kubecontrol/PodInfo.hpp"
|
#include "kubecontrol/PodInfo.hpp"
|
||||||
|
#include <cstddef>
|
||||||
#include <kubecontrol/KubePod.hpp>
|
#include <kubecontrol/KubePod.hpp>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <mutex>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
@@ -21,6 +23,7 @@ namespace kubecontrol
|
|||||||
std::string getPodsInfo();
|
std::string getPodsInfo();
|
||||||
std::string getInfoForOwnPod();
|
std::string getInfoForOwnPod();
|
||||||
std::string getInfoForPod(std::string Label);
|
std::string getInfoForPod(std::string Label);
|
||||||
|
size_t getListOfChildPods();
|
||||||
|
|
||||||
void checkPodsHierarchy();
|
void checkPodsHierarchy();
|
||||||
|
|
||||||
@@ -43,6 +46,7 @@ namespace kubecontrol
|
|||||||
std::shared_ptr<PodInfo> getPodInfo(std::string uuid);
|
std::shared_ptr<PodInfo> getPodInfo(std::string uuid);
|
||||||
|
|
||||||
std::vector<std::shared_ptr<PodInfo>> podsInfoList_;
|
std::vector<std::shared_ptr<PodInfo>> podsInfoList_;
|
||||||
|
mutable std::mutex mx_;
|
||||||
|
|
||||||
};
|
};
|
||||||
} // namespace ku
|
} // namespace ku
|
||||||
|
|||||||
@@ -75,8 +75,10 @@ namespace kubecontrol
|
|||||||
void PodController::stopAllPods()
|
void PodController::stopAllPods()
|
||||||
{
|
{
|
||||||
checkPodsHierarchy();
|
checkPodsHierarchy();
|
||||||
|
|
||||||
for (auto item : PodList_)
|
for (auto item : PodList_)
|
||||||
{
|
{
|
||||||
|
LOG_S(INFO)<<item.InfoPod.Uuid;
|
||||||
item.InfoPod = *getPodInfo(item.getUUID()).get();
|
item.InfoPod = *getPodInfo(item.getUUID()).get();
|
||||||
item.stop(ServerAddress_+ApiCall_, BearerToken_);
|
item.stop(ServerAddress_+ApiCall_, BearerToken_);
|
||||||
LOG_S(INFO)<< "stopping pod: "<<item.getUUID();
|
LOG_S(INFO)<< "stopping pod: "<<item.getUUID();
|
||||||
@@ -181,10 +183,12 @@ namespace kubecontrol
|
|||||||
j = nlohmann::json::parse(response);
|
j = nlohmann::json::parse(response);
|
||||||
if (j.contains("items"))
|
if (j.contains("items"))
|
||||||
{
|
{
|
||||||
|
LOG_S(INFO)<<j["items"].size();
|
||||||
int i = j["items"].size();
|
int i = j["items"].size();
|
||||||
for (int a = 0; a<i; a++)
|
for (int a = 0; a<i; a++)
|
||||||
{
|
{
|
||||||
auto item = std::make_shared<PodInfo>(j["items"][a].dump());
|
auto item = std::make_unique<PodInfo>(j["items"][a].dump());
|
||||||
|
// LOG_S(INFO)<<item->ToString();
|
||||||
// item->Uuid = j["items"][a]["metadata"]["labels"]["app.kubernetes.io/name"].get<std::string>();
|
// item->Uuid = j["items"][a]["metadata"]["labels"]["app.kubernetes.io/name"].get<std::string>();
|
||||||
// item->Component = j["items"][a]["metadata"]["labels"]["app.kubernetes.io/component"].get<std::string>();
|
// item->Component = j["items"][a]["metadata"]["labels"]["app.kubernetes.io/component"].get<std::string>();
|
||||||
// item->Image = j["items"][a]["spec"]["containers"][0]["image"].get<std::string>();
|
// item->Image = j["items"][a]["spec"]["containers"][0]["image"].get<std::string>();
|
||||||
@@ -281,6 +285,11 @@ namespace kubecontrol
|
|||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size_t PodController::getListOfChildPods()
|
||||||
|
{
|
||||||
|
return PodList_.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::string PodController::performRequest(std::string curlURL)
|
std::string PodController::performRequest(std::string curlURL)
|
||||||
|
|||||||
Reference in New Issue
Block a user