ADD: added name to KubePod and added the possibility to pass a shared pointer to start a pod
This commit is contained in:
@@ -46,11 +46,29 @@ namespace kubecontrol
|
|||||||
void setComponent(std::string component);
|
void setComponent(std::string component);
|
||||||
std::string getComponent();
|
std::string getComponent();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief sets the name of the pod
|
||||||
|
* @param string - term to be displayed
|
||||||
|
*/
|
||||||
|
void setName(std::string name);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief return the name of the pod
|
||||||
|
* @return std::string
|
||||||
|
*/
|
||||||
|
std::string getName();
|
||||||
|
|
||||||
|
|
||||||
int start(KubernetesAPI APIInterface,bool WaitTillRunning = true);
|
int start(KubernetesAPI APIInterface,bool WaitTillRunning = true);
|
||||||
int stop(KubernetesAPI APIInterface);
|
int stop(KubernetesAPI APIInterface);
|
||||||
int stopChilds(KubernetesAPI APIInterface);
|
int stopChilds(KubernetesAPI APIInterface);
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*@brief updates the infos for a pod from the give Kubernetes API
|
||||||
|
*@param KubernetesAPI - object of KubernetesAPI wich holds all necessary to perfom requests
|
||||||
|
*@return returns 1 on failure
|
||||||
|
*/
|
||||||
int updateInfoForThisPod(KubernetesAPI APIInterface);
|
int updateInfoForThisPod(KubernetesAPI APIInterface);
|
||||||
|
|
||||||
std::vector<std::string> getUUIDsForChildPods(KubernetesAPI APIInterface);
|
std::vector<std::string> getUUIDsForChildPods(KubernetesAPI APIInterface);
|
||||||
@@ -62,6 +80,7 @@ namespace kubecontrol
|
|||||||
|
|
||||||
std::string Owner_;
|
std::string Owner_;
|
||||||
std::string Uuid_;
|
std::string Uuid_;
|
||||||
|
std::string Name_;
|
||||||
std::string Component_;
|
std::string Component_;
|
||||||
std::string ContainerImage_;
|
std::string ContainerImage_;
|
||||||
std::string ContainerRegistry_;
|
std::string ContainerRegistry_;
|
||||||
|
|||||||
@@ -27,6 +27,8 @@ namespace kubecontrol
|
|||||||
std::string getServerAddress();
|
std::string getServerAddress();
|
||||||
|
|
||||||
void startPod(KubePod Pod,bool WaitTillRunning = true );
|
void startPod(KubePod Pod,bool WaitTillRunning = true );
|
||||||
|
void startPod(std::shared_ptr<KubePod> Pod,bool WaitTillRunning = true );
|
||||||
|
|
||||||
void stopPod(std::string uuid);
|
void stopPod(std::string uuid);
|
||||||
void stopAllPods();
|
void stopAllPods();
|
||||||
|
|
||||||
|
|||||||
@@ -136,9 +136,19 @@ namespace kubecontrol
|
|||||||
return this->Component_;
|
return this->Component_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void KubePod::setName(std::string name)
|
||||||
|
{
|
||||||
|
this->Name_ = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
std::string KubePod::getName()
|
||||||
|
{
|
||||||
|
return this->Name_;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string KubePod::createYAML()
|
std::string KubePod::createYAML()
|
||||||
{
|
{
|
||||||
YAML::Node node;
|
YAML::Node node;
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include <list>
|
#include <list>
|
||||||
#include <curlpp/Options.hpp>
|
#include <curlpp/Options.hpp>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <yaml-cpp/yaml.h>
|
||||||
|
|
||||||
#include <loguru.hpp>
|
#include <loguru.hpp>
|
||||||
|
|
||||||
|
|||||||
@@ -50,6 +50,18 @@ namespace kubecontrol
|
|||||||
// LOG_S(INFO)<<response;
|
// LOG_S(INFO)<<response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void PodController::startPod(std::shared_ptr<KubePod> Pod,bool WaitTillRunning )
|
||||||
|
{
|
||||||
|
LOG_S(INFO)<< "starting pod: "<<Pod->getUUID();
|
||||||
|
// auto response = Pod.start(ServerAddress_+ApiCall_, BearerToken_,WaitTillRunning);
|
||||||
|
auto response = Pod->start(APIInterface_,WaitTillRunning);
|
||||||
|
|
||||||
|
std::lock_guard<std::mutex>lock(mx_);
|
||||||
|
PodList_.emplace_back(std::make_unique<KubePod>(std::move(*Pod)));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void PodController::stopPod(std::string uuid)
|
void PodController::stopPod(std::string uuid)
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex>lock(mx_);
|
std::lock_guard<std::mutex>lock(mx_);
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ SCENARIO("Testing the SimCore Sensor")
|
|||||||
|
|
||||||
std::string uuid = name;
|
std::string uuid = name;
|
||||||
kubecontrol::KubePod ShipPod1("controller",uuid,"ship","ship:latest","simulator");
|
kubecontrol::KubePod ShipPod1("controller",uuid,"ship","ship:latest","simulator");
|
||||||
|
ShipPod1.setName(name);
|
||||||
|
|
||||||
nlohmann::json vars;
|
nlohmann::json vars;
|
||||||
vars["ENTITY_ID"] = uuid;
|
vars["ENTITY_ID"] = uuid;
|
||||||
@@ -55,6 +56,8 @@ std::this_thread::sleep_for(std::chrono::milliseconds(5000));
|
|||||||
THEN("check if Track attributes are correct")
|
THEN("check if Track attributes are correct")
|
||||||
{
|
{
|
||||||
REQUIRE(ShipPod1.getUUID() == "hamburg");
|
REQUIRE(ShipPod1.getUUID() == "hamburg");
|
||||||
|
REQUIRE(ShipPod1.getName() == name);
|
||||||
|
|
||||||
REQUIRE(ShipPod1.getComponent() == "ship");
|
REQUIRE(ShipPod1.getComponent() == "ship");
|
||||||
REQUIRE(ShipPod1.getOwner() == "controller");
|
REQUIRE(ShipPod1.getOwner() == "controller");
|
||||||
REQUIRE(ShipPod1.getStatus() == "Running");
|
REQUIRE(ShipPod1.getStatus() == "Running");
|
||||||
|
|||||||
Reference in New Issue
Block a user