diff --git a/.gitmodules b/.gitmodules index b12cde2..1b7dc98 100644 --- a/.gitmodules +++ b/.gitmodules @@ -7,3 +7,6 @@ [submodule "build/libs/SimCore/libs/whisper-comm"] path = build/libs/SimCore/libs/whisper-comm url = ssh://git@dev-gitea.ftewa.ti.unibw-hamburg.de:12000/hwinkel/whisper-com.git +[submodule "libs/OrderLibrary"] + path = libs/OrderLibrary + url = ssh://git@dev-gitea.ftewa.ti.unibw-hamburg.de:12000/hwinkel/OrderLibrary.git diff --git a/.vscode/launch.json b/.vscode/launch.json index 8fe10ca..2beab5f 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -8,8 +8,8 @@ "type": "gdb", "request": "launch", "name": "Launch Program", - "target": "./build/SimControlApplication", - "cwd": "${workspaceRoot}", + "target": "./SimControlApplication", + "cwd": "${workspaceRoot}/build", "valuesFormatting": "parseText" } diff --git a/CMakeLists.txt b/CMakeLists.txt index f45352c..29c7d40 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,12 @@ include(defaultOptions) #find_package(Eigen3 REQUIRED NO_MODULE) + +IF(NOT TARGET Catch2) + add_subdirectory(libs/Catch2 EXCLUDE_FROM_ALL) + include(libs/Catch2/contrib/Catch.cmake) +ENDIF() + IF (NOT TARGET CLI11) set(CLI11_TESTING OFF CACHE BOOL "disable testing") add_subdirectory(libs/CLI11 EXCLUDE_FROM_ALL) @@ -17,18 +23,25 @@ IF(NOT TARGET loguru) ENDIF() -IF(NOT TARGET EntityLibrary) - add_subdirectory(libs/EntityLibrary EXCLUDE_FROM_ALL) +IF(NOT TARGET SimCore) + add_subdirectory(libs/SimCore EXCLUDE_FROM_ALL) ENDIF() +IF(NOT TARGET KubeControl) + add_subdirectory(libs/KubeControl EXCLUDE_FROM_ALL) +ENDIF() + +IF(NOT TARGET OrderLibrary) + add_subdirectory(libs/OrderLibrary EXCLUDE_FROM_ALL) +ENDIF() - add_library(SimControl STATIC include/SimControl/SimControl.hpp src/SimControl/SimControl.cpp - + include/SimControl/PodList.hpp + src/SimControl/PodList.cpp ) @@ -36,8 +49,10 @@ target_link_libraries(SimControl PUBLIC CLI11 pthread - EntityLibrary + SimCore + kubecontrol loguru + OrderLibrary ) target_include_directories(SimControl @@ -61,7 +76,7 @@ target_link_libraries(SimControlApplication add_custom_command(TARGET SimControlApplication POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_directory - ${CMAKE_CURRENT_SOURCE_DIR}/libs/EntityLibrary/libs/KubeControl/docs $/docs) + ${CMAKE_CURRENT_SOURCE_DIR}/libs/KubeControl/docs $/docs) # target_include_directories(EntitiyManagerApplication # PRIVATE @@ -70,4 +85,16 @@ add_custom_command(TARGET SimControlApplication POST_BUILD # # Everything TEST related # +option(TEST_SIMCONTROLLER_LIBRARY "Turn running of application template specific tests off" ON) +IF (${TEST_SIMCONTROLLER_LIBRARY}) + + + +add_executable(test_podlist tests/test_podlist.cpp) +target_link_libraries(test_podlist Catch2::Catch2 SimControl loguru) +catch_discover_tests(test_podlist) + + + +ENDIF() diff --git a/Dockerfile b/Dockerfile index a2a315b..87df1d6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,14 +16,14 @@ RUN apt-get upgrade RUN apt-get -y install libsodium23 libuuid1 libstdc++5 libcurl4 # copy all custom buld libs -COPY build/libs/EntityLibrary/libs/SimCore/libs/whisper-com/libs/libzmq/lib/libzmq.so.5 /usr/lib/ +COPY build/libs/SimCore/libs/whisper-com/libs/libzmq/lib/libzmq.so.5 /usr/lib/ # COPY build/libs/EntityLibrary/libs/SimCore/libs/whisper-com/libs/protobuf/libprotobuf.so.32 /usr/lib/ -COPY build/libs/EntityLibrary/libs/SimCore/libs/whisper-com/libs/protobuf/libprotobufd.so.32 /usr/lib/ -COPY build/libs/EntityLibrary/libs/SimCore/libs/geographiclib/src/libGeographicLib.so.23 /usr/lib/ -COPY build/libs/EntityLibrary/libs/KubeControl/libs/yaml-cpp/libyaml-cpp.so.0.7 /usr/lib/ -COPY build/libs/EntityLibrary/libs/KubeControl/libs/curlpp/libcurlpp.so.1 /usr/lib/ +COPY build/libs/SimCore/libs/whisper-com/libs/protobuf/libprotobufd.so.32 /usr/lib/ +COPY build/libs/SimCore/libs/geographiclib/src/libGeographicLib.so.23 /usr/lib/ +COPY build/libs/KubeControl/libs/yaml-cpp/libyaml-cpp.so.0.8 /usr/lib/ +COPY build/libs/KubeControl/libs/curlpp/libcurlpp.so.1 /usr/lib/ # COPY build/libs/EntityLibrary/libs/SimCore/libs/crossguid/libcrossguid.so.0 /usr/lib/ -COPY build/libs/EntityLibrary/libs/SimCore/libs/crossguid/libcrossguid-dgb.so.0 /usr/lib/ +COPY build/libs/SimCore/libs/crossguid/libcrossguid-dgb.so.0 /usr/lib/ # Copy the current folder which contains C++ source code to the Docker image under /usr/src @@ -37,6 +37,6 @@ WORKDIR /usr/local/bin/ # RUN clang++ -o Test Test.cpp # Run the output program from the previous step -CMD ["SimControlApplication"] +# CMD ["SimControlApplication"] -# CMD ["bin/bash"] \ No newline at end of file +CMD ["bin/bash"] \ No newline at end of file diff --git a/cmake/Modules/protobuf.cmake b/cmake/Modules/protobuf.cmake index d1d120f..09e39a3 100644 --- a/cmake/Modules/protobuf.cmake +++ b/cmake/Modules/protobuf.cmake @@ -15,7 +15,7 @@ function(protobuf_generate_cpp) ${ARGN}) FILE(GLOB PROTO_FILES ${protobuf_PROTO_PATH}/*.proto) - set(PROTOC ${CMAKE_BINARY_DIR}/libs/EntityLibrary/libs/SimCore/libs/whisper-com/libs/protobuf/protoc) + set(PROTOC ${CMAKE_BINARY_DIR}/libs/SimCore/libs/whisper-com/libs/protobuf/protoc) message(STATUS "protoc path: " ${PROTOC}) FOREACH(proto ${PROTO_FILES}) @@ -28,7 +28,7 @@ function(protobuf_generate_cpp) add_custom_command( OUTPUT "${protoDIR}/${protoFILENAME}.pb.cc" DEPENDS "${protoDIR}/${protoFILENAME}.proto" - COMMAND ${PROTOC} --cpp_out=${protoDIR} --proto_path=${protoDIR} --proto_path="${CMAKE_SOURCE_DIR}/libs/EntityLibrary/libs/SimCore/include/SimCore/Messages/Protos" --proto_path="${CMAKE_SOURCE_DIR}/libs/EntityLibrary/libs/SimCore/libs/whisper-com/libs/protobuf/src" "${protoDIR}/${protoFILENAME}.proto" + COMMAND ${PROTOC} --cpp_out=${protoDIR} --proto_path=${protoDIR} --proto_path="${CMAKE_SOURCE_DIR}/libs/SimCore/include/SimCore/Messages/Protos" --proto_path="${CMAKE_SOURCE_DIR}/libs/SimCore/libs/whisper-com/libs/protobuf/src" "${protoDIR}/${protoFILENAME}.proto" ) diff --git a/docs/info.json b/docs/info.json new file mode 100644 index 0000000..c68cbeb --- /dev/null +++ b/docs/info.json @@ -0,0 +1,47 @@ + + + + + + + +{"apiVersion":"v1","kind":"Pod","metadata":{"creationTimestamp":"2023-08-11T11:36:22Z","labels":{"app.kubernetes.io/name":"hamburg"},"managedFields":[{"apiVersion":"v1","fieldsType":"FieldsV1","fieldsV1":{"f:metadata":{"f:labels":{".":{},"f:app.kubernetes.io/name":{}}},"f:spec":{"f:containers":{"k:{\"name\":\"hamburg-container\"}":{".":{},"f:env":{".":{},"k:{\"name\":\"COMMAND_PORT\"}":{".":{},"f:name":{},"f:value":{}},"k:{\"name\":\"ENTITY_ID\"}":{".":{},"f:name":{},"f:value":{}},"k:{\"name\":\"ENTITY_NAME\"}":{".":{},"f:name":{},"f:value":{}},"k:{\"name\":\"GROUNDTRUTH_PORT\"}":{".":{},"f:name":{},"f:value":{}},"k:{\"name\":\"POS_HEIGHT\"}":{".":{},"f:name":{},"f:value":{}},"k:{\"name\":\"POS_LAT\"}":{".":{},"f:name":{},"f:value":{}},"k:{\"name\":\"POS_LONG\"}":{".":{},"f:name":{},"f:value":{}}},"f:image":{},"f:imagePullPolicy":{},"f:name":{},"f:resources":{},"f:terminationMessagePath":{},"f:terminationMessagePolicy":{}}},"f:dnsPolicy":{},"f:enableServiceLinks":{},"f:restartPolicy":{},"f:schedulerName":{},"f:securityContext":{},"f:terminationGracePeriodSeconds":{}}}, +"manager":"unknown","operation":"Update","time":"2023-08-11T11:36:22Z"}, +{"apiVersion":"v1","fieldsType":"FieldsV1", +"fieldsV1":{"f:status":{"f:conditions":{"k:{\"type\":\"ContainersReady\"}":{".":{},"f:lastProbeTime":{},"f:lastTransitionTime":{},"f:status":{},"f:type":{}},"k:{\"type\":\"Initialized\"}":{".":{},"f:lastProbeTime":{},"f:lastTransitionTime":{},"f:status":{},"f:type":{}},"k:{\"type\":\"Ready\"}":{".":{},"f:lastProbeTime":{},"f:lastTransitionTime":{},"f:status":{},"f:type":{}}}, +"f:containerStatuses":{},"f:hostIP":{},"f:phase":{},"f:podIP":{}, +"f:podIPs":{".":{},"k:{\"ip\":\"10.0.3.98\"}":{".":{},"f:ip":{}}},"f:startTime":{}}}, +"manager":"kubelet","operation":"Update","subresource":"status","time":"2023-08-11T11:36:23Z"}], +"name":"ship1","namespace":"hwinkel","resourceVersion":"171734008","uid":"68ef8a8c-33c9-4160-89ea-7f51d5e6735a"}, +"spec":{"containers":[{"env":[{"name":"COMMAND_PORT","value":"\"5555\""}, +{"name":"ENTITY_ID","value":"ship1"}, +{"name":"ENTITY_NAME","value":"hamburg"}, +{"name":"GROUNDTRUTH_PORT","value":"\"8000\""}, +{"name":"POS_HEIGHT","value":"\"0\""}, +{"name":"POS_LAT","value":"\"55\""}, +{"name":"POS_LONG","value":"\"8\""}], +"image":"kmaster.ti.unibw-hamburg.de:30808/ship:latest", +"imagePullPolicy":"Always", +"name":"hamburg-container", +"resources":{}, +"terminationMessagePath":"/dev/termination-log", +"terminationMessagePolicy":"File", +"volumeMounts":[{"mountPath":"/var/run/secrets/kubernetes.io/serviceaccount","name":"kube-api-access-92lpt","readOnly":true}]}], +"dnsPolicy":"ClusterFirst", +"enableServiceLinks":true, +"nodeName":"kslave02.ti.unibw-hamburg.de", +"preemptionPolicy":"PreemptLowerPriority", +"priority":0, +"restartPolicy":"Never", +"schedulerName":"default-scheduler", +"securityContext":{}, +"serviceAccount":"default", +"serviceAccountName":"default", +"terminationGracePeriodSeconds":30, +"tolerations":[ + {"effect":"NoExecute","key":"node.kubernetes.io/not-ready","operator":"Exists","tolerationSeconds":300}, + {"effect":"NoExecute","key":"node.kubernetes.io/unreachable","operator":"Exists","tolerationSeconds":300}], + "volumes":[ + {"name":"kube-api-access-92lpt", + "projected":{ + "defaultMode":420,"sources":[{"serviceAccountToken":{"expirationSeconds":3607,"path":"token"}},{"configMap":{"items":[{"key":"ca.crt","path":"ca.crt"}],"name":"kube-root-ca.crt"}},{"downwardAPI":{"items":[{"fieldRef":{"apiVersion":"v1","fieldPath":"metadata.namespace"},"path":"namespace"}]}}]}}]},"status":{"conditions":[{"lastProbeTime":null,"lastTransitionTime":"2023-08-11T11:36:22Z","status":"True","type":"Initialized"},{"lastProbeTime":null,"lastTransitionTime":"2023-08-11T11:36:23Z","status":"True","type":"Ready"},{"lastProbeTime":null,"lastTransitionTime":"2023-08-11T11:36:23Z","status":"True","type":"ContainersReady"},{"lastProbeTime":null,"lastTransitionTime":"2023-08-11T11:36:22Z","status":"True","type":"PodScheduled"}],"containerStatuses":[{"containerID":"cri-o://c2632fb622a89b099c566b83a81de28e665176ea4f91f8ad1b17b97945c9450a","image":"kmaster.ti.unibw-hamburg.de:30808/ship:latest","imageID":"kmaster.ti.unibw-hamburg.de:30808/ship@sha256:53032573b5777e4ec30764b4700aa5b7ec3ba5b9c035cdecf5c8abe8f0e30279","lastState":{},"name":"hamburg-container","ready":true,"restartCount":0,"started":true,"state":{"running":{"startedAt":"2023-08-11T11:36:23Z"}}}],"hostIP":"192.168.252.8","phase":"Running","podIP":"10.0.3.98","podIPs":[{"ip":"10.0.3.98"}],"qosClass":"BestEffort","startTime":"2023-08-11T11:36:22Z"}} \ No newline at end of file diff --git a/include/SimControl/PodList.hpp b/include/SimControl/PodList.hpp new file mode 100644 index 0000000..f864867 --- /dev/null +++ b/include/SimControl/PodList.hpp @@ -0,0 +1,64 @@ +#pragma once + + +#include "nlohmann/json_fwd.hpp" +#include +#include +#include +#include +#include +#include + +namespace SimControl +{ + struct PodListItem + { + std::string Uuid; + std::string Image; + std::string Ip; + std::string Component; + std::string Status; + std::string PartOf; + std::vector>> relatedPods; + + bool operator==(PodListItem const &rhs ) + { + if (Uuid == rhs.Uuid) { + return true; + } + return false; + } + }; + + + + + + class PodList + { + public: + PodList(); + PodList(std::string jsonstring); + + + void addPodToList(std::shared_ptr pod); + void addPodToList(std::string respond); + + std::shared_ptr getPod(std::string uuid); + + bool removePod(std::string uuid); + + std::vector getPodsUUID(); + + nlohmann::json getPodTree(std::string uuid); + + size_t size(); + + private: + + void addPodsFromString(std::string respond); + + std::map> podList_; + + }; +} \ No newline at end of file diff --git a/include/SimControl/SimControl.hpp b/include/SimControl/SimControl.hpp index 652a618..46647f8 100644 --- a/include/SimControl/SimControl.hpp +++ b/include/SimControl/SimControl.hpp @@ -2,6 +2,7 @@ #define __SIMCONTROL__ #include "DirectCommunicationClient.hpp" +#include "DirectCommunicationServer.hpp" #include "SimCore/Identifier.hpp" #include "crossguid/guid.hpp" #include "kubecontrol/PodController.hpp" @@ -26,24 +27,33 @@ namespace SimControl { class SimControl{ public: - SimControl(ushort CommandPort); + SimControl(std::string CommandPort); ~SimControl(); void stop(); private: + + const SimCore::Identifier ID_; - ushort CommandPort_; + std::string CommandPort_; void MainFunction_(); void HandleMessage(std::string msg); + void HandleExternalMessage(std::string msg); + + + void startShip(std::string name); + + std::unique_ptr PodController_; std::thread MainThread_; std::atomic stopMainThread_ = false; - std::unique_ptr TCPClient_; + std::shared_ptr TCPClient_ = nullptr; + std::shared_ptr ExternalTCPServer_ = nullptr; diff --git a/libs/OrderLibrary b/libs/OrderLibrary new file mode 160000 index 0000000..88aa0d0 --- /dev/null +++ b/libs/OrderLibrary @@ -0,0 +1 @@ +Subproject commit 88aa0d0eff299aca8919945b25610e4e956b0a40 diff --git a/src/SimControl/PodList.cpp b/src/SimControl/PodList.cpp new file mode 100644 index 0000000..611e3b9 --- /dev/null +++ b/src/SimControl/PodList.cpp @@ -0,0 +1,171 @@ +#include + +#include +#include +#include +#include + + + +namespace SimControl +{ + PodList::PodList() + { + + + } + + + + PodList::PodList(std::string jsonstring) + { + + addPodsFromString(jsonstring); + + + } + + void PodList::addPodsFromString(std::string respond) + { + nlohmann::json j; + try + { + j = nlohmann::json::parse(respond); + if (j.contains("items")) + { + int i = j["items"].size(); + for (int a = 0; a(); + 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(); + item->Ip = j["items"][a]["status"]["podIP"].get(); + item->Status = j["items"][a]["status"]["phase"].get(); + item->PartOf = j["items"][a]["metadata"]["labels"]["app.kubernetes.io/part-of"].get(); + // LOG_S(INFO)<addPodToList(item); + } + + + i = j["items"].size(); + for (int a = 0; a(); + std::string uuid = j["items"][a]["metadata"]["labels"]["app.kubernetes.io/name"].get(); + std::string parentName= j["items"][a]["metadata"]["labels"]["app.kubernetes.io/part-of"].get(); + + auto self = this->getPod(uuid); + auto parent = this->getPod(parentName); + if (parent != nullptr && self != nullptr) { + parent->relatedPods.emplace_back(std::make_pair(self->Uuid, self)); + }else if (parent== nullptr) + { + self->PartOf = parentName; + } + + } + } + + + } catch (std::exception& e) + { + LOG_S(ERROR)< pod) + { + + podList_.insert_or_assign(pod->Uuid,pod); + + } + + void PodList::addPodToList(std::string respond) + { + + addPodsFromString(respond); + } + + + + std::shared_ptr PodList::getPod(std::string uuid) + { + for(auto item : podList_) + { + if (item.first == uuid) + { + return item.second; + } + } + return nullptr; + } + + bool PodList::removePod(std::string uuid) + { + for(auto it = podList_.begin(); it != podList_.end();) + { + if (it->first == uuid) + { + it = podList_.erase(it); + return true; + } + } + return false; + } + + std::vector PodList::getPodsUUID() + { + std::vector list; + LOG_S(INFO)<< podList_.size(); + for(auto item : podList_) + { + list.emplace_back(item.first); + } + return list; + } + + + nlohmann::json PodList::getPodTree(std::string uuid) + { + LOG_S(INFO)<getPod(uuid); + if (pod!= nullptr) + { + j["UUID"] = pod->Uuid; + j["IMAGE"] = pod->Image; + j["IP"] = pod->Ip; + j["COMPONENT"] = pod->Component; + + int i = 0; + for (auto item:pod->relatedPods) + { + + j["RELATIVES"][i]["UUID"] = item.second->Uuid; + j["RELATIVES"][i]["IMAGE"] = item.second->Image; + j["RELATIVES"][i]["IP"] = item.second->Ip; + j["RELATIVES"][i]["COMPONENT"] = item.second->Component; + j["RELATIVES"][i]["PART-OF"] = item.second->PartOf; + + i++; + } + } + + return j; + + } + + size_t PodList::size() + { + return podList_.size(); + } + + + + +} \ No newline at end of file diff --git a/src/SimControl/SimControl.cpp b/src/SimControl/SimControl.cpp index 6234f86..7a9d8b1 100644 --- a/src/SimControl/SimControl.cpp +++ b/src/SimControl/SimControl.cpp @@ -1,30 +1,39 @@ -#include "Orders/MoveOrder.hpp" -#include "SimCore/Identifier.hpp" +#include +#include +#include "DirectCommunicationServer.hpp" +#include "SimCore/Messages/Control.hpp" #include "SimCore/Messages/SimTrack.hpp" +#include "SimCore/SimCore.hpp" #include "WHISPER/Messages/Message.hpp" #include "crossguid/guid.hpp" #include "kubecontrol/KubePod.hpp" #include "kubecontrol/PodController.hpp" +#include "nlohmann/json_fwd.hpp" #include +#include #include #include #include #include + namespace SimControl { - SimControl::SimControl( ushort CommandPort):CommandPort_(CommandPort),ID_(SimCore::Identifier(xg::newGuid())) + SimControl::SimControl( std::string CommandPort):CommandPort_(CommandPort),ID_(SimCore::Identifier(xg::newGuid())) { PodController_ = std::make_unique("docs/config"); - - TCPClient_ = std::make_unique(30200,"192.168.252.6"); - TCPClient_->registerMessageCallback(std::bind(&SimControl::HandleMessage,this,std::placeholders::_1)); - TCPClient_->sendMessage("Hello Server"); + ExternalTCPServer_ = std::make_shared(5000); + ExternalTCPServer_->registerMessageCallback(std::bind(&SimControl::HandleExternalMessage,this,std::placeholders::_1)); + // TCPClient_ = std::make_unique(30200,"192.168.252.6"); + // TCPClient_ = std::make_unique(5555,"127.0.0.1"); + + // TCPClient_->registerMessageCallback(std::bind(&SimControl::HandleMessage,this,std::placeholders::_1)); + // TCPClient_->sendMessage("Hello Server"); this->stopMainThread_ = false; MainThread_ = std::thread(&SimControl::MainFunction_,this); @@ -33,26 +42,28 @@ namespace SimControl { SimControl::~SimControl() { + stop(); + stopMainThread_ = true; + while (!MainThread_.joinable()) { + // LOG_S(INFO)<< "waiting"; + std::this_thread::sleep_for(std::chrono::milliseconds(100)); + } + MainThread_.join(); - this->stopMainThread_ = true; + TCPClient_.reset(); - TCPClient_ = nullptr; } void SimControl::stop() { - PodController_->stopAllPods(); - this->stopMainThread_ = true; - TCPClient_.reset(); - + PodController_->stopAllPods(); } void SimControl::HandleMessage(std::string msg) { - TCPClient_->sendMessage("Hello Server") ; // LOG_S(INFO)<startPod(ShipPod1); + + + } + void SimControl::MainFunction_() { // std::string uuid = xg::newGuid().str(); - std::string uuid = "ship1"; - kubecontrol::KubePod ShipPod1("hamburg",uuid,"ship:latest"); - ShipPod1.setEnvironmentVar("ENTITY_ID", "ship1"); - ShipPod1.setEnvironmentVar("ENTITY_NAME", "hamburg"); - ShipPod1.setEnvironmentVar("POS_LAT", "\"55\""); - ShipPod1.setEnvironmentVar("POS_LONG", "\"8\""); - ShipPod1.setEnvironmentVar("POS_HEIGHT", "\"0\""); - ShipPod1.setEnvironmentVar("GROUNDTRUTH_PORT", "\"8000\""); - ShipPod1.setEnvironmentVar("COMMAND_PORT", "\"5555\""); + + startShip("hamburg"); - ShipPod1.createYAML(); - PodController_->startPod(ShipPod1); + LOG_S(INFO)<getInfoForPod("hamburg"); - std::this_thread::sleep_for(std::chrono::milliseconds(2000)); - - LOG_S(INFO)<getInfoForPod("hamburg"); - // LOG_S(INFO)<getPodsInfo(); + auto IP = PodController_->getPodsInfo("hamburg")->Ip; + TCPClient_ = std::make_shared(5555,IP); + // Orders::MoveOrder order(this->ID_); + // order.Speed.setValue(0); + // TCPClient_->sendMessage(order.buildMessage().serialize()); - Orders::MoveOrder order(this->ID_); - order.Speed.setValue(0); - TCPClient_->sendMessage(order.buildMessage().serialize()); - - - // std::this_thread::sleep_for(std::chrono::milliseconds(3000)); - // TCPClient_->disconnect(); - // TCPClient_.reset(); + // std::this_thread::sleep_for(std::chrono::milliseconds(10000)); + // SimCore::Control shutdown(this->ID_,SimCore::SHUT_DOWN,""); + // TCPClient_->sendMessage(shutdown.buildMessage().serialize()); + // // TCPClient_->disconnect(); + // // TCPClient_.reset(); while (!stopMainThread_) { @@ -107,8 +133,8 @@ namespace SimControl { } - // std::this_thread::sleep_for(std::chrono::milliseconds(3000)); - TCPClient_->disconnect(); + + LOG_S(INFO)<<"main func stopped"; } diff --git a/src/main.cpp b/src/main.cpp index 124d569..2fc5a93 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1,4 +1,4 @@ -#include "Orders/MoveOrder.hpp" +#include #include #include #include @@ -33,11 +33,10 @@ int main() sigIntHandler.sa_flags = 0; sigaction(SIGINT, &sigIntHandler, NULL); - const char* CommandPortChar = "31371"; + const char* CommandPortChar = "5555"; if (std::getenv("COMMAND_PORT") != nullptr) { CommandPortChar = std::getenv("COMMAND_PORT"); } - ushort commandPort_ = (unsigned short)strtol(CommandPortChar,NULL,0); const char *ServerAddress = nullptr; @@ -49,21 +48,20 @@ int main() LOG_S(INFO)< + +std::string ts = R"({ + "apiVersion": "v1", + "items": [{ + "metadata": { + "creationTimestamp": "2023-08-14T14:27:26Z", + "labels": { + "app.kubernetes.io/component": "movementcalculation", + "app.kubernetes.io/name": "19fe17f6-15ce-4f38-b36f-97da750604f7" + }, + "managedFields": [{ + "apiVersion": "v1", + "fieldsType": "FieldsV1", + "fieldsV1": { + "f:metadata": { + "f:labels": { + ".": {}, + "f:app.kubernetes.io/component": {}, + "f:app.kubernetes.io/name": {} + } + }, + "f:spec": { + "f:containers": { + "k:{\"name\":\"19fe17f6-15ce-4f38-b36f-97da750604f7-container\"}": { + ".": {}, + "f:env": { + ".": {}, + "k:{\"name\":\"SERVER_IP\"}": { + ".": {}, + "f:name": {}, + "f:value": {} + } + }, + "f:image": {}, + "f:imagePullPolicy": {}, + "f:name": {}, + "f:resources": {}, + "f:terminationMessagePath": {}, + "f:terminationMessagePolicy": {} + } + }, + "f:dnsPolicy": {}, + "f:enableServiceLinks": {}, + "f:restartPolicy": {}, + "f:schedulerName": {}, + "f:securityContext": {}, + "f:terminationGracePeriodSeconds": {} + } + }, + "manager": "unknown", + "operation": "Update", + "time": "2023-08-14T14:27:26Z" + }, { + "apiVersion": "v1", + "fieldsType": "FieldsV1", + "fieldsV1": { + "f:status": { + "f:conditions": { + "k:{\"type\":\"ContainersReady\"}": { + ".": {}, + "f:lastProbeTime": {}, + "f:lastTransitionTime": {}, + "f:status": {}, + "f:type": {} + }, + "k:{\"type\":\"Initialized\"}": { + ".": {}, + "f:lastProbeTime": {}, + "f:lastTransitionTime": {}, + "f:status": {}, + "f:type": {} + }, + "k:{\"type\":\"Ready\"}": { + ".": {}, + "f:lastProbeTime": {}, + "f:lastTransitionTime": {}, + "f:status": {}, + "f:type": {} + } + }, + "f:containerStatuses": {}, + "f:hostIP": {}, + "f:phase": {}, + "f:podIP": {}, + "f:podIPs": { + ".": {}, + "k:{\"ip\":\"10.0.3.116\"}": { + ".": {}, + "f:ip": {} + } + }, + "f:startTime": {} + } + }, + "manager": "kubelet", + "operation": "Update", + "subresource": "status", + "time": "2023-08-14T14:27:28Z" + }], + "name": "19fe17f6-15ce-4f38-b36f-97da750604f7", + "namespace": "hwinkel", + "resourceVersion": "172374042", + "uid": "276221fe-65d2-4131-92ba-9103e3bc344a" + }, + "spec": { + "containers": [{ + "env": [{ + "name": "SERVER_IP", + "value": "10.0.3.115" + }], + "image": "kmaster.ti.unibw-hamburg.de:30808/movementimage:latest", + "imagePullPolicy": "Always", + "name": "19fe17f6-15ce-4f38-b36f-97da750604f7-container", + "resources": {}, + "terminationMessagePath": "/dev/termination-log", + "terminationMessagePolicy": "File", + "volumeMounts": [{ + "mountPath": "/var/run/secrets/kubernetes.io/serviceaccount", + "name": "kube-api-access-xd5rh", + "readOnly": true + }] + }], + "dnsPolicy": "ClusterFirst", + "enableServiceLinks": true, + "nodeName": "kslave02.ti.unibw-hamburg.de", + "preemptionPolicy": "PreemptLowerPriority", + "priority": 0, + "restartPolicy": "Never", + "schedulerName": "default-scheduler", + "securityContext": {}, + "serviceAccount": "default", + "serviceAccountName": "default", + "terminationGracePeriodSeconds": 30, + "tolerations": [{ + "effect": "NoExecute", + "key": "node.kubernetes.io/not-ready", + "operator": "Exists", + "tolerationSeconds": 300 + }, { + "effect": "NoExecute", + "key": "node.kubernetes.io/unreachable", + "operator": "Exists", + "tolerationSeconds": 300 + }], + "volumes": [{ + "name": "kube-api-access-xd5rh", + "projected": { + "defaultMode": 420, + "sources": [{ + "serviceAccountToken": { + "expirationSeconds": 3607, + "path": "token" + } + }, { + "configMap": { + "items": [{ + "key": "ca.crt", + "path": "ca.crt" + }], + "name": "kube-root-ca.crt" + } + }, { + "downwardAPI": { + "items": [{ + "fieldRef": { + "apiVersion": "v1", + "fieldPath": "metadata.namespace" + }, + "path": "namespace" + }] + } + }] + } + }] + }, + "status": { + "conditions": [{ + "lastProbeTime": null, + "lastTransitionTime": "2023-08-14T14:27:26Z", + "status": "True", + "type": "Initialized" + }, { + "lastProbeTime": null, + "lastTransitionTime": "2023-08-14T14:27:28Z", + "status": "True", + "type": "Ready" + }, { + "lastProbeTime": null, + "lastTransitionTime": "2023-08-14T14:27:28Z", + "status": "True", + "type": "ContainersReady" + }, { + "lastProbeTime": null, + "lastTransitionTime": "2023-08-14T14:27:26Z", + "status": "True", + "type": "PodScheduled" + }], + "containerStatuses": [{ + "containerID": "cri-o://c68e06e965ece1976e201c1595615b293ea8c3cbb8abb620a3e0437e3fd7073c", + "image": "kmaster.ti.unibw-hamburg.de:30808/movementimage:latest", + "imageID": "kmaster.ti.unibw-hamburg.de:30808/movementimage@sha256:b40bd0944a21bc748b5fc077ea13cbe446a00f37a0cf0d4c9d4dd35ac568e3da", + "lastState": {}, + "name": "19fe17f6-15ce-4f38-b36f-97da750604f7-container", + "ready": true, + "restartCount": 0, + "started": true, + "state": { + "running": { + "startedAt": "2023-08-14T14:27:27Z" + } + } + }], + "hostIP": "192.168.252.8", + "phase": "Running", + "podIP": "10.0.3.116", + "podIPs": [{ + "ip": "10.0.3.116" + }], + "qosClass": "BestEffort", + "startTime": "2023-08-14T14:27:26Z" + } + }, { + "metadata": { + "creationTimestamp": "2023-08-14T14:05:27Z", + "labels": { + "app.kubernetes.io/component": "movementcalculation", + "app.kubernetes.io/name": "1ef9f27f-3f7f-41b7-add2-887f96e718ef" + }, + "managedFields": [{ + "apiVersion": "v1", + "fieldsType": "FieldsV1", + "fieldsV1": { + "f:metadata": { + "f:labels": { + ".": {}, + "f:app.kubernetes.io/component": {}, + "f:app.kubernetes.io/name": {} + } + }, + "f:spec": { + "f:containers": { + "k:{\"name\":\"1ef9f27f-3f7f-41b7-add2-887f96e718ef-container\"}": { + ".": {}, + "f:env": { + ".": {}, + "k:{\"name\":\"SERVER_IP\"}": { + ".": {}, + "f:name": {}, + "f:value": {} + } + }, + "f:image": {}, + "f:imagePullPolicy": {}, + "f:name": {}, + "f:resources": {}, + "f:terminationMessagePath": {}, + "f:terminationMessagePolicy": {} + } + }, + "f:dnsPolicy": {}, + "f:enableServiceLinks": {}, + "f:restartPolicy": {}, + "f:schedulerName": {}, + "f:securityContext": {}, + "f:terminationGracePeriodSeconds": {} + } + }, + "manager": "unknown", + "operation": "Update", + "time": "2023-08-14T14:05:27Z" + }, { + "apiVersion": "v1", + "fieldsType": "FieldsV1", + "fieldsV1": { + "f:status": { + "f:conditions": { + "k:{\"type\":\"ContainersReady\"}": { + ".": {}, + "f:lastProbeTime": {}, + "f:lastTransitionTime": {}, + "f:status": {}, + "f:type": {} + }, + "k:{\"type\":\"Initialized\"}": { + ".": {}, + "f:lastProbeTime": {}, + "f:lastTransitionTime": {}, + "f:status": {}, + "f:type": {} + }, + "k:{\"type\":\"Ready\"}": { + ".": {}, + "f:lastProbeTime": {}, + "f:lastTransitionTime": {}, + "f:status": {}, + "f:type": {} + } + }, + "f:containerStatuses": {}, + "f:hostIP": {}, + "f:phase": {}, + "f:podIP": {}, + "f:podIPs": { + ".": {}, + "k:{\"ip\":\"10.0.3.186\"}": { + ".": {}, + "f:ip": {} + } + }, + "f:startTime": {} + } + }, + "manager": "kubelet", + "operation": "Update", + "subresource": "status", + "time": "2023-08-14T14:05:29Z" + }], + "name": "1ef9f27f-3f7f-41b7-add2-887f96e718ef", + "namespace": "hwinkel", + "resourceVersion": "172370879", + "uid": "663527c6-92a0-4cc2-9fdc-1a1047115ed7" + }, + "spec": { + "containers": [{ + "env": [{ + "name": "SERVER_IP", + "value": "10.0.3.47" + }], + "image": "kmaster.ti.unibw-hamburg.de:30808/movementimage:latest", + "imagePullPolicy": "Always", + "name": "1ef9f27f-3f7f-41b7-add2-887f96e718ef-container", + "resources": {}, + "terminationMessagePath": "/dev/termination-log", + "terminationMessagePolicy": "File", + "volumeMounts": [{ + "mountPath": "/var/run/secrets/kubernetes.io/serviceaccount", + "name": "kube-api-access-c6jm6", + "readOnly": true + }] + }], + "dnsPolicy": "ClusterFirst", + "enableServiceLinks": true, + "nodeName": "kslave02.ti.unibw-hamburg.de", + "preemptionPolicy": "PreemptLowerPriority", + "priority": 0, + "restartPolicy": "Never", + "schedulerName": "default-scheduler", + "securityContext": {}, + "serviceAccount": "default", + "serviceAccountName": "default", + "terminationGracePeriodSeconds": 30, + "tolerations": [{ + "effect": "NoExecute", + "key": "node.kubernetes.io/not-ready", + "operator": "Exists", + "tolerationSeconds": 300 + }, { + "effect": "NoExecute", + "key": "node.kubernetes.io/unreachable", + "operator": "Exists", + "tolerationSeconds": 300 + }], + "volumes": [{ + "name": "kube-api-access-c6jm6", + "projected": { + "defaultMode": 420, + "sources": [{ + "serviceAccountToken": { + "expirationSeconds": 3607, + "path": "token" + } + }, { + "configMap": { + "items": [{ + "key": "ca.crt", + "path": "ca.crt" + }], + "name": "kube-root-ca.crt" + } + }, { + "downwardAPI": { + "items": [{ + "fieldRef": { + "apiVersion": "v1", + "fieldPath": "metadata.namespace" + }, + "path": "namespace" + }] + } + }] + } + }] + }, + "status": { + "conditions": [{ + "lastProbeTime": null, + "lastTransitionTime": "2023-08-14T14:05:27Z", + "status": "True", + "type": "Initialized" + }, { + "lastProbeTime": null, + "lastTransitionTime": "2023-08-14T14:05:29Z", + "status": "True", + "type": "Ready" + }, { + "lastProbeTime": null, + "lastTransitionTime": "2023-08-14T14:05:29Z", + "status": "True", + "type": "ContainersReady" + }, { + "lastProbeTime": null, + "lastTransitionTime": "2023-08-14T14:05:27Z", + "status": "True", + "type": "PodScheduled" + }], + "containerStatuses": [{ + "containerID": "cri-o://7440befbf81dcc4d99d671c1e18767cae488589b82231d45d10d2d6cfdcbffd5", + "image": "kmaster.ti.unibw-hamburg.de:30808/movementimage:latest", + "imageID": "kmaster.ti.unibw-hamburg.de:30808/movementimage@sha256:b40bd0944a21bc748b5fc077ea13cbe446a00f37a0cf0d4c9d4dd35ac568e3da", + "lastState": {}, + "name": "1ef9f27f-3f7f-41b7-add2-887f96e718ef-container", + "ready": true, + "restartCount": 0, + "started": true, + "state": { + "running": { + "startedAt": "2023-08-14T14:05:28Z" + } + } + }], + "hostIP": "192.168.252.8", + "phase": "Running", + "podIP": "10.0.3.186", + "podIPs": [{ + "ip": "10.0.3.186" + }], + "qosClass": "BestEffort", + "startTime": "2023-08-14T14:05:27Z" + } + }, { + "metadata": { + "creationTimestamp": "2023-08-14T12:47:02Z", + "labels": { + "app.kubernetes.io/component": "movementcalculation", + "app.kubernetes.io/name": "6540be84-e679-4a8e-9d3f-88c153a880de" + }, + "managedFields": [{ + "apiVersion": "v1", + "fieldsType": "FieldsV1", + "fieldsV1": { + "f:metadata": { + "f:labels": { + ".": {}, + "f:app.kubernetes.io/component": {}, + "f:app.kubernetes.io/name": {} + } + }, + "f:spec": { + "f:containers": { + "k:{\"name\":\"6540be84-e679-4a8e-9d3f-88c153a880de-container\"}": { + ".": {}, + "f:env": { + ".": {}, + "k:{\"name\":\"SERVER_IP\"}": { + ".": {}, + "f:name": {}, + "f:value": {} + } + }, + "f:image": {}, + "f:imagePullPolicy": {}, + "f:name": {}, + "f:resources": {}, + "f:terminationMessagePath": {}, + "f:terminationMessagePolicy": {} + } + }, + "f:dnsPolicy": {}, + "f:enableServiceLinks": {}, + "f:restartPolicy": {}, + "f:schedulerName": {}, + "f:securityContext": {}, + "f:terminationGracePeriodSeconds": {} + } + }, + "manager": "unknown", + "operation": "Update", + "time": "2023-08-14T12:47:02Z" + }, { + "apiVersion": "v1", + "fieldsType": "FieldsV1", + "fieldsV1": { + "f:status": { + "f:conditions": { + "k:{\"type\":\"ContainersReady\"}": { + ".": {}, + "f:lastProbeTime": {}, + "f:lastTransitionTime": {}, + "f:status": {}, + "f:type": {} + }, + "k:{\"type\":\"Initialized\"}": { + ".": {}, + "f:lastProbeTime": {}, + "f:lastTransitionTime": {}, + "f:status": {}, + "f:type": {} + }, + "k:{\"type\":\"Ready\"}": { + ".": {}, + "f:lastProbeTime": {}, + "f:lastTransitionTime": {}, + "f:status": {}, + "f:type": {} + } + }, + "f:containerStatuses": {}, + "f:hostIP": {}, + "f:phase": {}, + "f:podIP": {}, + "f:podIPs": { + ".": {}, + "k:{\"ip\":\"10.0.3.180\"}": { + ".": {}, + "f:ip": {} + } + }, + "f:startTime": {} + } + }, + "manager": "kubelet", + "operation": "Update", + "subresource": "status", + "time": "2023-08-14T12:47:03Z" + }], + "name": "6540be84-e679-4a8e-9d3f-88c153a880de", + "namespace": "hwinkel", + "resourceVersion": "172359605", + "uid": "819b44c6-450a-45b1-8655-c20fd754e82c" + }, + "spec": { + "containers": [{ + "env": [{ + "name": "SERVER_IP", + "value": "10.0.3.249" + }], + "image": "kmaster.ti.unibw-hamburg.de:30808/movementimage:latest", + "imagePullPolicy": "Always", + "name": "6540be84-e679-4a8e-9d3f-88c153a880de-container", + "resources": {}, + "terminationMessagePath": "/dev/termination-log", + "terminationMessagePolicy": "File", + "volumeMounts": [{ + "mountPath": "/var/run/secrets/kubernetes.io/serviceaccount", + "name": "kube-api-access-d2vlw", + "readOnly": true + }] + }], + "dnsPolicy": "ClusterFirst", + "enableServiceLinks": true, + "nodeName": "kslave02.ti.unibw-hamburg.de", + "preemptionPolicy": "PreemptLowerPriority", + "priority": 0, + "restartPolicy": "Never", + "schedulerName": "default-scheduler", + "securityContext": {}, + "serviceAccount": "default", + "serviceAccountName": "default", + "terminationGracePeriodSeconds": 30, + "tolerations": [{ + "effect": "NoExecute", + "key": "node.kubernetes.io/not-ready", + "operator": "Exists", + "tolerationSeconds": 300 + }, { + "effect": "NoExecute", + "key": "node.kubernetes.io/unreachable", + "operator": "Exists", + "tolerationSeconds": 300 + }], + "volumes": [{ + "name": "kube-api-access-d2vlw", + "projected": { + "defaultMode": 420, + "sources": [{ + "serviceAccountToken": { + "expirationSeconds": 3607, + "path": "token" + } + }, { + "configMap": { + "items": [{ + "key": "ca.crt", + "path": "ca.crt" + }], + "name": "kube-root-ca.crt" + } + }, { + "downwardAPI": { + "items": [{ + "fieldRef": { + "apiVersion": "v1", + "fieldPath": "metadata.namespace" + }, + "path": "namespace" + }] + } + }] + } + }] + }, + "status": { + "conditions": [{ + "lastProbeTime": null, + "lastTransitionTime": "2023-08-14T12:47:02Z", + "status": "True", + "type": "Initialized" + }, { + "lastProbeTime": null, + "lastTransitionTime": "2023-08-14T12:47:03Z", + "status": "True", + "type": "Ready" + }, { + "lastProbeTime": null, + "lastTransitionTime": "2023-08-14T12:47:03Z", + "status": "True", + "type": "ContainersReady" + }, { + "lastProbeTime": null, + "lastTransitionTime": "2023-08-14T12:47:02Z", + "status": "True", + "type": "PodScheduled" + }], + "containerStatuses": [{ + "containerID": "cri-o://a37194d7e802a93e8586e2b8211a3f493c11a16fe02c9bff3b3509c0c15d584a", + "image": "kmaster.ti.unibw-hamburg.de:30808/movementimage:latest", + "imageID": "kmaster.ti.unibw-hamburg.de:30808/movementimage@sha256:b40bd0944a21bc748b5fc077ea13cbe446a00f37a0cf0d4c9d4dd35ac568e3da", + "lastState": {}, + "name": "6540be84-e679-4a8e-9d3f-88c153a880de-container", + "ready": true, + "restartCount": 0, + "started": true, + "state": { + "running": { + "startedAt": "2023-08-14T12:47:03Z" + } + } + }], + "hostIP": "192.168.252.8", + "phase": "Running", + "podIP": "10.0.3.180", + "podIPs": [{ + "ip": "10.0.3.180" + }], + "qosClass": "BestEffort", + "startTime": "2023-08-14T12:47:02Z" + } + }, { + "metadata": { + "creationTimestamp": "2023-08-14T13:45:57Z", + "labels": { + "app.kubernetes.io/component": "movementcalculation", + "app.kubernetes.io/name": "b30c0114-194e-45b9-a6f1-b8911dfee811" + }, + "managedFields": [{ + "apiVersion": "v1", + "fieldsType": "FieldsV1", + "fieldsV1": { + "f:metadata": { + "f:labels": { + ".": {}, + "f:app.kubernetes.io/component": {}, + "f:app.kubernetes.io/name": {} + } + }, + "f:spec": { + "f:containers": { + "k:{\"name\":\"b30c0114-194e-45b9-a6f1-b8911dfee811-container\"}": { + ".": {}, + "f:env": { + ".": {}, + "k:{\"name\":\"SERVER_IP\"}": { + ".": {}, + "f:name": {}, + "f:value": {} + } + }, + "f:image": {}, + "f:imagePullPolicy": {}, + "f:name": {}, + "f:resources": {}, + "f:terminationMessagePath": {}, + "f:terminationMessagePolicy": {} + } + }, + "f:dnsPolicy": {}, + "f:enableServiceLinks": {}, + "f:restartPolicy": {}, + "f:schedulerName": {}, + "f:securityContext": {}, + "f:terminationGracePeriodSeconds": {} + } + }, + "manager": "unknown", + "operation": "Update", + "time": "2023-08-14T13:45:57Z" + }, { + "apiVersion": "v1", + "fieldsType": "FieldsV1", + "fieldsV1": { + "f:status": { + "f:conditions": { + "k:{\"type\":\"ContainersReady\"}": { + ".": {}, + "f:lastProbeTime": {}, + "f:lastTransitionTime": {}, + "f:status": {}, + "f:type": {} + }, + "k:{\"type\":\"Initialized\"}": { + ".": {}, + "f:lastProbeTime": {}, + "f:lastTransitionTime": {}, + "f:status": {}, + "f:type": {} + }, + "k:{\"type\":\"Ready\"}": { + ".": {}, + "f:lastProbeTime": {}, + "f:lastTransitionTime": {}, + "f:status": {}, + "f:type": {} + } + }, + "f:containerStatuses": {}, + "f:hostIP": {}, + "f:phase": {}, + "f:podIP": {}, + "f:podIPs": { + ".": {}, + "k:{\"ip\":\"10.0.3.107\"}": { + ".": {}, + "f:ip": {} + } + }, + "f:startTime": {} + } + }, + "manager": "kubelet", + "operation": "Update", + "subresource": "status", + "time": "2023-08-14T13:45:59Z" + }], + "name": "b30c0114-194e-45b9-a6f1-b8911dfee811", + "namespace": "hwinkel", + "resourceVersion": "172368067", + "uid": "c0d7c022-e875-4f0f-8317-13de0ea063de" + }, + "spec": { + "containers": [{ + "env": [{ + "name": "SERVER_IP", + "value": "10.0.3.216" + }], + "image": "kmaster.ti.unibw-hamburg.de:30808/movementimage:latest", + "imagePullPolicy": "Always", + "name": "b30c0114-194e-45b9-a6f1-b8911dfee811-container", + "resources": {}, + "terminationMessagePath": "/dev/termination-log", + "terminationMessagePolicy": "File", + "volumeMounts": [{ + "mountPath": "/var/run/secrets/kubernetes.io/serviceaccount", + "name": "kube-api-access-6fjct", + "readOnly": true + }] + }], + "dnsPolicy": "ClusterFirst", + "enableServiceLinks": true, + "nodeName": "kslave02.ti.unibw-hamburg.de", + "preemptionPolicy": "PreemptLowerPriority", + "priority": 0, + "restartPolicy": "Never", + "schedulerName": "default-scheduler", + "securityContext": {}, + "serviceAccount": "default", + "serviceAccountName": "default", + "terminationGracePeriodSeconds": 30, + "tolerations": [{ + "effect": "NoExecute", + "key": "node.kubernetes.io/not-ready", + "operator": "Exists", + "tolerationSeconds": 300 + }, { + "effect": "NoExecute", + "key": "node.kubernetes.io/unreachable", + "operator": "Exists", + "tolerationSeconds": 300 + }], + "volumes": [{ + "name": "kube-api-access-6fjct", + "projected": { + "defaultMode": 420, + "sources": [{ + "serviceAccountToken": { + "expirationSeconds": 3607, + "path": "token" + } + }, { + "configMap": { + "items": [{ + "key": "ca.crt", + "path": "ca.crt" + }], + "name": "kube-root-ca.crt" + } + }, { + "downwardAPI": { + "items": [{ + "fieldRef": { + "apiVersion": "v1", + "fieldPath": "metadata.namespace" + }, + "path": "namespace" + }] + } + }] + } + }] + }, + "status": { + "conditions": [{ + "lastProbeTime": null, + "lastTransitionTime": "2023-08-14T13:45:57Z", + "status": "True", + "type": "Initialized" + }, { + "lastProbeTime": null, + "lastTransitionTime": "2023-08-14T13:45:59Z", + "status": "True", + "type": "Ready" + }, { + "lastProbeTime": null, + "lastTransitionTime": "2023-08-14T13:45:59Z", + "status": "True", + "type": "ContainersReady" + }, { + "lastProbeTime": null, + "lastTransitionTime": "2023-08-14T13:45:57Z", + "status": "True", + "type": "PodScheduled" + }], + "containerStatuses": [{ + "containerID": "cri-o://d45b863e3026bf5e1c9c69be502ebc28f48997f733949ca55c1a93789198fc0a", + "image": "kmaster.ti.unibw-hamburg.de:30808/movementimage:latest", + "imageID": "kmaster.ti.unibw-hamburg.de:30808/movementimage@sha256:b40bd0944a21bc748b5fc077ea13cbe446a00f37a0cf0d4c9d4dd35ac568e3da", + "lastState": {}, + "name": "b30c0114-194e-45b9-a6f1-b8911dfee811-container", + "ready": true, + "restartCount": 0, + "started": true, + "state": { + "running": { + "startedAt": "2023-08-14T13:45:58Z" + } + } + }], + "hostIP": "192.168.252.8", + "phase": "Running", + "podIP": "10.0.3.107", + "podIPs": [{ + "ip": "10.0.3.107" + }], + "qosClass": "BestEffort", + "startTime": "2023-08-14T13:45:57Z" + } + }, { + "metadata": { + "creationTimestamp": "2023-08-14T14:27:25Z", + "deletionGracePeriodSeconds": 30, + "deletionTimestamp": "2023-08-14T14:28:01Z", + "labels": { + "app.kubernetes.io/name": "hamburg" + }, + "managedFields": [{ + "apiVersion": "v1", + "fieldsType": "FieldsV1", + "fieldsV1": { + "f:metadata": { + "f:labels": { + ".": {}, + "f:app.kubernetes.io/name": {} + } + }, + "f:spec": { + "f:containers": { + "k:{\"name\":\"hamburg-container\"}": { + ".": {}, + "f:env": { + ".": {}, + "k:{\"name\":\"COMMAND_PORT\"}": { + ".": {}, + "f:name": {}, + "f:value": {} + }, + "k:{\"name\":\"ENTITY_ID\"}": { + ".": {}, + "f:name": {}, + "f:value": {} + }, + "k:{\"name\":\"ENTITY_NAME\"}": { + ".": {}, + "f:name": {}, + "f:value": {} + }, + "k:{\"name\":\"GROUNDTRUTH_PORT\"}": { + ".": {}, + "f:name": {}, + "f:value": {} + }, + "k:{\"name\":\"POS_HEIGHT\"}": { + ".": {}, + "f:name": {}, + "f:value": {} + }, + "k:{\"name\":\"POS_LAT\"}": { + ".": {}, + "f:name": {}, + "f:value": {} + }, + "k:{\"name\":\"POS_LONG\"}": { + ".": {}, + "f:name": {}, + "f:value": {} + } + }, + "f:image": {}, + "f:imagePullPolicy": {}, + "f:name": {}, + "f:resources": {}, + "f:terminationMessagePath": {}, + "f:terminationMessagePolicy": {} + } + }, + "f:dnsPolicy": {}, + "f:enableServiceLinks": {}, + "f:restartPolicy": {}, + "f:schedulerName": {}, + "f:securityContext": {}, + "f:terminationGracePeriodSeconds": {} + } + }, + "manager": "unknown", + "operation": "Update", + "time": "2023-08-14T14:27:25Z" + }, { + "apiVersion": "v1", + "fieldsType": "FieldsV1", + "fieldsV1": { + "f:status": { + "f:conditions": { + "k:{\"type\":\"ContainersReady\"}": { + ".": {}, + "f:lastProbeTime": {}, + "f:lastTransitionTime": {}, + "f:status": {}, + "f:type": {} + }, + "k:{\"type\":\"Initialized\"}": { + ".": {}, + "f:lastProbeTime": {}, + "f:lastTransitionTime": {}, + "f:status": {}, + "f:type": {} + }, + "k:{\"type\":\"Ready\"}": { + ".": {}, + "f:lastProbeTime": {}, + "f:lastTransitionTime": {}, + "f:status": {}, + "f:type": {} + } + }, + "f:containerStatuses": {}, + "f:hostIP": {}, + "f:phase": {}, + "f:podIP": {}, + "f:podIPs": { + ".": {}, + "k:{\"ip\":\"10.0.3.115\"}": { + ".": {}, + "f:ip": {} + } + }, + "f:startTime": {} + } + }, + "manager": "kubelet", + "operation": "Update", + "subresource": "status", + "time": "2023-08-14T14:27:27Z" + }], + "name": "ship1", + "namespace": "hwinkel", + "resourceVersion": "172374050", + "uid": "00154fa1-0c7b-45b8-8bcf-330cbb35d6c4" + }, + "spec": { + "containers": [{ + "env": [{ + "name": "COMMAND_PORT", + "value": "\"5555\"" + }, { + "name": "ENTITY_ID", + "value": "ship1" + }, { + "name": "ENTITY_NAME", + "value": "hamburg" + }, { + "name": "GROUNDTRUTH_PORT", + "value": "\"8000\"" + }, { + "name": "POS_HEIGHT", + "value": "\"0\"" + }, { + "name": "POS_LAT", + "value": "\"55\"" + }, { + "name": "POS_LONG", + "value": "\"8\"" + }], + "image": "kmaster.ti.unibw-hamburg.de:30808/ship:latest", + "imagePullPolicy": "Always", + "name": "hamburg-container", + "resources": {}, + "terminationMessagePath": "/dev/termination-log", + "terminationMessagePolicy": "File", + "volumeMounts": [{ + "mountPath": "/var/run/secrets/kubernetes.io/serviceaccount", + "name": "kube-api-access-64485", + "readOnly": true + }] + }], + "dnsPolicy": "ClusterFirst", + "enableServiceLinks": true, + "nodeName": "kslave02.ti.unibw-hamburg.de", + "preemptionPolicy": "PreemptLowerPriority", + "priority": 0, + "restartPolicy": "Never", + "schedulerName": "default-scheduler", + "securityContext": {}, + "serviceAccount": "default", + "serviceAccountName": "default", + "terminationGracePeriodSeconds": 30, + "tolerations": [{ + "effect": "NoExecute", + "key": "node.kubernetes.io/not-ready", + "operator": "Exists", + "tolerationSeconds": 300 + }, { + "effect": "NoExecute", + "key": "node.kubernetes.io/unreachable", + "operator": "Exists", + "tolerationSeconds": 300 + }], + "volumes": [{ + "name": "kube-api-access-64485", + "projected": { + "defaultMode": 420, + "sources": [{ + "serviceAccountToken": { + "expirationSeconds": 3607, + "path": "token" + } + }, { + "configMap": { + "items": [{ + "key": "ca.crt", + "path": "ca.crt" + }], + "name": "kube-root-ca.crt" + } + }, { + "downwardAPI": { + "items": [{ + "fieldRef": { + "apiVersion": "v1", + "fieldPath": "metadata.namespace" + }, + "path": "namespace" + }] + } + }] + } + }] + }, + "status": { + "conditions": [{ + "lastProbeTime": null, + "lastTransitionTime": "2023-08-14T14:27:25Z", + "status": "True", + "type": "Initialized" + }, { + "lastProbeTime": null, + "lastTransitionTime": "2023-08-14T14:27:27Z", + "status": "True", + "type": "Ready" + }, { + "lastProbeTime": null, + "lastTransitionTime": "2023-08-14T14:27:27Z", + "status": "True", + "type": "ContainersReady" + }, { + "lastProbeTime": null, + "lastTransitionTime": "2023-08-14T14:27:25Z", + "status": "True", + "type": "PodScheduled" + }], + "containerStatuses": [{ + "containerID": "cri-o://aaa67dbe8acbf6841d115e790c04b9aff9131314f9e93943fb5505ef33c479ce", + "image": "kmaster.ti.unibw-hamburg.de:30808/ship:latest", + "imageID": "kmaster.ti.unibw-hamburg.de:30808/ship@sha256:842cf35f29e1e8139a990b02ec7d64195307f789e03e52e7fb3b8c9cfb13ded5", + "lastState": {}, + "name": "hamburg-container", + "ready": true, + "restartCount": 0, + "started": true, + "state": { + "running": { + "startedAt": "2023-08-14T14:27:26Z" + } + } + }], + "hostIP": "192.168.252.8", + "phase": "Running", + "podIP": "10.0.3.115", + "podIPs": [{ + "ip": "10.0.3.115" + }], + "qosClass": "BestEffort", + "startTime": "2023-08-14T14:27:25Z" + } + }], + "kind": "PodList", + "metadata": { + "resourceVersion": "172374124" + } +})"; \ No newline at end of file diff --git a/tests/test_podlist.cpp b/tests/test_podlist.cpp new file mode 100644 index 0000000..2f75854 --- /dev/null +++ b/tests/test_podlist.cpp @@ -0,0 +1,77 @@ + + +#include "kubecontrol/PodController.hpp" +#include "nlohmann/json_fwd.hpp" +#include +#include +#include +#define CATCH_CONFIG_MAIN +#include "SimControl/PodList.hpp" +#include +#include + +#include "string.cpp" + +// SimCore::Identifier OwnID, SimCore::Identifier ParentID, SimCore::SensorKinds SensorKind,std::uint32_t GroundTruthPort, std::uint32_t ParentPort,std::string ParentIPAddress + +SCENARIO("Testing the the podlist") +{ + +auto control = kubecontrol::PodController("docs/config"); + + + + +// std::ifstream ifs("info.json"); +nlohmann::json j = nlohmann::json::parse(control.getPodsInfo()); + +LOG_S(INFO)<(); + + // auto item2 = std::make_shared(); + // item2->Uuid= "movement"; + + + // item1->Uuid= "test"; + // item1->relatedPods.emplace_back(item2); + + + // podlist.addPodToList(item1); + // podlist.addPodToList(item2); + + + + // LOG_S(INFO)<