Skip to content

Commit

Permalink
fix the label register issue
Browse files Browse the repository at this point in the history
  • Loading branch information
robbietu committed May 27, 2024
1 parent 7897b43 commit 675e1dd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 21 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
33 changes: 13 additions & 20 deletions src/daemonManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,7 @@ void DaemonManager::getDaemonImpl() {
LOG(ERROR) << output_buffer;
return;
}

::curl_easy_getinfo(curl.get(), CURLINFO_RESPONSE_CODE, &statusCode);

if (statusCode == 200) {
Expand Down Expand Up @@ -317,16 +318,6 @@ void DaemonManager::getDaemonImpl() {
struct timeval tv;
gettimeofday(&tv,NULL);
daemon_.setStartTime(tv);

std::vector<std::string> strs;
strs.resize(0);
std::string labels = vm_["labels"].as<std::string>();
split(strs, labels, boost::algorithm::is_any_of(","));
for (const auto& str:strs) {
std::shared_ptr<io::swagger::server::model::Label> newItem(new io::swagger::server::model::Label());
newItem->setValue(str);
daemon_.getLabels().push_back(newItem);
}

interfaces_.clear();
}
Expand Down Expand Up @@ -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<std::string> strs;
daemon_.setLogFileContext(ctx);
daemon_.setName(vm_["name"].as<std::string>());
const auto uuid = boost::uuids::random_generator()();
Expand Down Expand Up @@ -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<std::string> strs;
split(strs, SUPPORT_API_VERSIONS, boost::algorithm::is_any_of(","));
for (const auto& str:strs) {
daemon_.getSupportApiVersions().push_back(str);
Expand All @@ -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<std::string>();
split(strs, labels, boost::algorithm::is_any_of(","));
for (const auto& str:strs) {
std::shared_ptr<io::swagger::server::model::Label> newItem(new io::swagger::server::model::Label());
newItem->setValue(str);
daemon_.getLabels().push_back(newItem);
}

daemon_.setPlatformId (vm_["platformId"].as<std::string>());
strs.resize(0);
Expand Down Expand Up @@ -1265,6 +1248,16 @@ int DaemonManager::daemonReg() {
CURLcode res;
long statusCode;
std::string body;
std::vector<std::string> strs;

daemon_.getLabels().clear();
std::string labels = vm_["labels"].as<std::string>();
split(strs, labels, boost::algorithm::is_any_of(","));
for (const auto& str:strs) {
std::shared_ptr<io::swagger::server::model::Label> newItem(new io::swagger::server::model::Label());
newItem->setValue(str);
daemon_.getLabels().push_back(newItem);
}

url = vm_["manager"].as<std::string>();
::curl_easy_setopt(curl.get(), CURLOPT_URL, url.c_str());
Expand Down

0 comments on commit 675e1dd

Please sign in to comment.