From d1024de907ee38e75a7b13375da9f9fe3aaa7a71 Mon Sep 17 00:00:00 2001 From: Henry Winkel Date: Thu, 21 Dec 2023 09:15:33 +0100 Subject: [PATCH] ADD: added function to podcontroller to get number of childpods --- include/kubecontrol/PodController.hpp | 4 ++++ src/kubecontrol/PodController.cpp | 11 ++++++++++- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/include/kubecontrol/PodController.hpp b/include/kubecontrol/PodController.hpp index 5ff0749..d9a48d4 100644 --- a/include/kubecontrol/PodController.hpp +++ b/include/kubecontrol/PodController.hpp @@ -1,7 +1,9 @@ #pragma once #include "kubecontrol/PodInfo.hpp" +#include #include #include +#include #include #include @@ -21,6 +23,7 @@ namespace kubecontrol std::string getPodsInfo(); std::string getInfoForOwnPod(); std::string getInfoForPod(std::string Label); + size_t getListOfChildPods(); void checkPodsHierarchy(); @@ -43,6 +46,7 @@ namespace kubecontrol std::shared_ptr getPodInfo(std::string uuid); std::vector> podsInfoList_; + mutable std::mutex mx_; }; } // namespace ku diff --git a/src/kubecontrol/PodController.cpp b/src/kubecontrol/PodController.cpp index 33183b2..15a38ac 100644 --- a/src/kubecontrol/PodController.cpp +++ b/src/kubecontrol/PodController.cpp @@ -75,8 +75,10 @@ namespace kubecontrol void PodController::stopAllPods() { checkPodsHierarchy(); + for (auto item : PodList_) { + LOG_S(INFO)<(j["items"][a].dump()); + auto item = std::make_unique(j["items"][a].dump()); + // LOG_S(INFO)<ToString(); // item->Uuid = j["items"][a]["metadata"]["labels"]["app.kubernetes.io/name"].get(); // item->Component = j["items"][a]["metadata"]["labels"]["app.kubernetes.io/component"].get(); // item->Image = j["items"][a]["spec"]["containers"][0]["image"].get(); @@ -281,6 +285,11 @@ namespace kubecontrol return nullptr; } + size_t PodController::getListOfChildPods() + { + return PodList_.size(); + } + std::string PodController::performRequest(std::string curlURL)