From 675e1dd0bf43f4cdf621d263172aa5ddc8b2a04f Mon Sep 17 00:00:00 2001 From: Robbie Tu Date: Sun, 26 May 2024 23:34:45 -0700 Subject: [PATCH] fix the label register issue --- CMakeLists.txt | 2 +- src/daemonManager.cpp | 33 +++++++++++++-------------------- 2 files changed, 14 insertions(+), 21 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1a86dcb6..1bbda020 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -16,7 +16,7 @@ endif () # set PKTMINERG_MAJOR_VERSION, PKTMINERG_MINOR_VERSION, etc. set(PKTMINERG_MAJOR_VERSION "0") set(PKTMINERG_MINOR_VERSION "7") -set(PKTMINERG_PATCH_VERSION "3") +set(PKTMINERG_PATCH_VERSION "4") set(PKTMINERG_VERSION_STRING "${PKTMINERG_MAJOR_VERSION}.${PKTMINERG_MINOR_VERSION}.${PKTMINERG_PATCH_VERSION}") if (WIN32) diff --git a/src/daemonManager.cpp b/src/daemonManager.cpp index 4f68ca43..d45c467b 100644 --- a/src/daemonManager.cpp +++ b/src/daemonManager.cpp @@ -186,6 +186,7 @@ void DaemonManager::getDaemonImpl() { LOG(ERROR) << output_buffer; return; } + ::curl_easy_getinfo(curl.get(), CURLINFO_RESPONSE_CODE, &statusCode); if (statusCode == 200) { @@ -317,16 +318,6 @@ void DaemonManager::getDaemonImpl() { struct timeval tv; gettimeofday(&tv,NULL); daemon_.setStartTime(tv); - - std::vector strs; - strs.resize(0); - std::string labels = vm_["labels"].as(); - split(strs, labels, boost::algorithm::is_any_of(",")); - for (const auto& str:strs) { - std::shared_ptr newItem(new io::swagger::server::model::Label()); - newItem->setValue(str); - daemon_.getLabels().push_back(newItem); - } interfaces_.clear(); } @@ -1074,7 +1065,6 @@ bool DaemonManager::delAgent() { DaemonManager::DaemonManager(const boost::program_options::variables_map &vm, timer_tasks_t* tasks, LogFileContext& ctx) :vm_(vm),tasks_(tasks), ctx_(ctx) { - std::vector strs; daemon_.setLogFileContext(ctx); daemon_.setName(vm_["name"].as()); const auto uuid = boost::uuids::random_generator()(); @@ -1128,8 +1118,8 @@ DaemonManager::DaemonManager(const boost::program_options::variables_map &vm, ti } } - daemon_.setClientVersion("0.7.3"); - + daemon_.setClientVersion("0.7.4"); + std::vector strs; split(strs, SUPPORT_API_VERSIONS, boost::algorithm::is_any_of(",")); for (const auto& str:strs) { daemon_.getSupportApiVersions().push_back(str); @@ -1142,13 +1132,6 @@ DaemonManager::DaemonManager(const boost::program_options::variables_map &vm, ti daemon_.setSyncMode("pull"); strs.resize(0); - std::string labels = vm_["labels"].as(); - split(strs, labels, boost::algorithm::is_any_of(",")); - for (const auto& str:strs) { - std::shared_ptr newItem(new io::swagger::server::model::Label()); - newItem->setValue(str); - daemon_.getLabels().push_back(newItem); - } daemon_.setPlatformId (vm_["platformId"].as()); strs.resize(0); @@ -1265,6 +1248,16 @@ int DaemonManager::daemonReg() { CURLcode res; long statusCode; std::string body; + std::vector strs; + + daemon_.getLabels().clear(); + std::string labels = vm_["labels"].as(); + split(strs, labels, boost::algorithm::is_any_of(",")); + for (const auto& str:strs) { + std::shared_ptr newItem(new io::swagger::server::model::Label()); + newItem->setValue(str); + daemon_.getLabels().push_back(newItem); + } url = vm_["manager"].as(); ::curl_easy_setopt(curl.get(), CURLOPT_URL, url.c_str());