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);
|
||||
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 stop(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);
|
||||
|
||||
std::vector<std::string> getUUIDsForChildPods(KubernetesAPI APIInterface);
|
||||
@@ -62,6 +80,7 @@ namespace kubecontrol
|
||||
|
||||
std::string Owner_;
|
||||
std::string Uuid_;
|
||||
std::string Name_;
|
||||
std::string Component_;
|
||||
std::string ContainerImage_;
|
||||
std::string ContainerRegistry_;
|
||||
|
||||
@@ -27,6 +27,8 @@ namespace kubecontrol
|
||||
std::string getServerAddress();
|
||||
|
||||
void startPod(KubePod Pod,bool WaitTillRunning = true );
|
||||
void startPod(std::shared_ptr<KubePod> Pod,bool WaitTillRunning = true );
|
||||
|
||||
void stopPod(std::string uuid);
|
||||
void stopAllPods();
|
||||
|
||||
|
||||
@@ -136,9 +136,19 @@ namespace kubecontrol
|
||||
return this->Component_;
|
||||
}
|
||||
|
||||
void KubePod::setName(std::string name)
|
||||
{
|
||||
this->Name_ = name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::string KubePod::getName()
|
||||
{
|
||||
return this->Name_;
|
||||
}
|
||||
|
||||
|
||||
std::string KubePod::createYAML()
|
||||
{
|
||||
YAML::Node node;
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include <list>
|
||||
#include <curlpp/Options.hpp>
|
||||
#include <sstream>
|
||||
#include <yaml-cpp/yaml.h>
|
||||
|
||||
#include <loguru.hpp>
|
||||
|
||||
|
||||
@@ -50,6 +50,18 @@ namespace kubecontrol
|
||||
// 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)
|
||||
{
|
||||
std::lock_guard<std::mutex>lock(mx_);
|
||||
|
||||
@@ -20,6 +20,7 @@ SCENARIO("Testing the SimCore Sensor")
|
||||
|
||||
std::string uuid = name;
|
||||
kubecontrol::KubePod ShipPod1("controller",uuid,"ship","ship:latest","simulator");
|
||||
ShipPod1.setName(name);
|
||||
|
||||
nlohmann::json vars;
|
||||
vars["ENTITY_ID"] = uuid;
|
||||
@@ -55,6 +56,8 @@ std::this_thread::sleep_for(std::chrono::milliseconds(5000));
|
||||
THEN("check if Track attributes are correct")
|
||||
{
|
||||
REQUIRE(ShipPod1.getUUID() == "hamburg");
|
||||
REQUIRE(ShipPod1.getName() == name);
|
||||
|
||||
REQUIRE(ShipPod1.getComponent() == "ship");
|
||||
REQUIRE(ShipPod1.getOwner() == "controller");
|
||||
REQUIRE(ShipPod1.getStatus() == "Running");
|
||||
|
||||
Reference in New Issue
Block a user