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,7 +1,6 @@
#pragma once
#include "kubecontrol/KubernetesAPI.hpp"
#include "kubecontrol/PodInfo.hpp"
#include "nlohmann/json_fwd.hpp"
#include "yaml-cpp/node/node.h"
#include <map>
@@ -26,11 +25,13 @@ namespace kubecontrol
class KubePod
{
public:
KubePod(std::string Owner, std::string Uuid, std::string ContainerImage,std::string Namespace = "simulator");
KubePod(std::string Owner, std::string Uuid, std::string ContainerImage,std::string Namespace = "simulator") ;
KubePod(std::string Owner, std::string Uuid, std::string Component, std::string ContainerImage,std::string Namespace = "simulator");
std::string getUUID();
std::string getOwner();
std::string getIp();
std::string getStatus();
void setEnvironmentVar(std::string key, std::string val);
std::map<std::string, std::string> GetEnvironmentVars();
@@ -44,37 +45,20 @@ namespace kubecontrol
void setComponent(std::string component);
std::string getComponent();
// [[deprecated("replace with start(KubernetesAPI APIInterface)")]]
// std::string start(std::string apiAddress,std::string token,bool WaitTillRunning = true);
std::string start(KubernetesAPI APIInterface,bool WaitTillRunning = true);
[[deprecated("replace with stop(KubernetesAPI APIInterface)")]]
std::string stop(std::string apiAddress,std::string token);
std::string stop(KubernetesAPI APIInterface);
// [[deprecated("replace with getInfo(KubernetesAPI APIInterface)")]]
// std::string getInfo(std::string apiAddress,std::string token);
std::string getInfoForThisPod(KubernetesAPI APIInterface);
std::string getInfoForRelatedPods(KubernetesAPI APIInterface);
int start(KubernetesAPI APIInterface,bool WaitTillRunning = true);
int stop(KubernetesAPI APIInterface);
int stopChilds(KubernetesAPI APIInterface);
int updateInfoForThisPod(KubernetesAPI APIInterface);
std::vector<std::string> getUUIDForRelatedPods(KubernetesAPI APIInterface);
std::vector<std::string> getUUIDsForChildPods(KubernetesAPI APIInterface);
PodInfo InfoPod;
private:
static const int MaxWaitTimeInSeconds;
std::string Owner_;
std::string Uuid_;
@@ -98,10 +82,14 @@ namespace kubecontrol
std::string createYAML();
// std::string read;
/**
* @brief extracts the asked inforamtion from the kubernetes response
*
*
*/
int extractInformationFromResopnse(std::string response);
std::string StopChilds(std::string apiAddress,std::string token,std::string uuid);
};
}