ADD: added a general kubenetes API and integrated that in the classes and remodeled the info management

This commit is contained in:
hwinkel
2023-12-22 13:14:40 +01:00
parent 351cf9ec69
commit 4045f21786
13 changed files with 363 additions and 833 deletions

View File

@@ -1,6 +1,5 @@
#pragma once
#include "kubecontrol/KubernetesAPI.hpp"
#include "kubecontrol/PodInfo.hpp"
#include <cstddef>
#include <kubecontrol/KubePod.hpp>
#include <memory>
@@ -10,6 +9,16 @@
namespace kubecontrol
{
struct PodInfos
{
std::string UUID;
std::string IP;
std::string Status;
std::string Component;
std::string Owner;
std::vector<std::string> UUIDOfChilds;
};
class PodController
{
public:
@@ -21,33 +30,21 @@ namespace kubecontrol
void stopPod(std::string uuid);
void stopAllPods();
std::string getInfoForAllPods();
// std::string getInfoForOwnPod();
std::string getInfoForPod(std::string uuid);
size_t getListOfChildPods();
std::vector<PodInfos> getInfoForAllPods();
PodInfos getInfoForPod(std::string uuid);
void checkPodsHierarchy();
KubernetesAPI getKubernetesAPI();
std::string getPodsInfoForAll();
std::shared_ptr<PodInfo> getPodsInfo(std::string uuid);
private:
KubernetesAPI APIInterface_;
std::vector<KubePod> PodList_;
std::vector<std::unique_ptr<KubePod>> PodList_;
std::string performRequest(std::string url);
void performForceStopRequest(std::string uuid);
std::string BearerToken_;
std::string ServerAddress_;
std::string Namespace_;
std::string ApiCall_;
// void addPodInfoToInfoList(std::shared_ptr<PodInfo> podinfo);
std::shared_ptr<PodInfo> getPodInfo(std::string uuid);
PodInfos extractInfosFromKubePod(KubePod *pod);
std::vector<std::shared_ptr<PodInfo>> podsInfoList_;
mutable std::mutex mx_;
};