diff options
author | Diego Schulz <dschulz@gmail.com> | 2018-08-02 17:13:55 -0400 |
---|---|---|
committer | Diego Schulz <dschulz@gmail.com> | 2018-08-02 17:13:55 -0400 |
commit | fc6dba079795d9e0c7a053b5539d157c615c68d6 (patch) | |
tree | edc4299b99ea26d92e4462e7f2b806bb7ef5777f | |
parent | 352ec3430f50da47132e741c4bb19ca194e324f6 (diff) | |
download | infinitytier-fc6dba079795d9e0c7a053b5539d157c615c68d6.tar.gz infinitytier-fc6dba079795d9e0c7a053b5539d157c615c68d6.zip |
Add functionality to erase members from networks using file backend in controller microservice
Signed-off-by: Diego Schulz <dschulz@gmail.com>
-rw-r--r-- | controller/EmbeddedNetworkController.cpp | 1 | ||||
-rw-r--r-- | controller/FileDB.cpp | 14 |
2 files changed, 14 insertions, 1 deletions
diff --git a/controller/EmbeddedNetworkController.cpp b/controller/EmbeddedNetworkController.cpp index ef52f6e0..f4d1c958 100644 --- a/controller/EmbeddedNetworkController.cpp +++ b/controller/EmbeddedNetworkController.cpp @@ -1042,6 +1042,7 @@ unsigned int EmbeddedNetworkController::handleControlPlaneHttpDELETE( json network,member; _db->get(nwid,network,address,member); + _db->eraseMember(nwid, address); { std::lock_guard<std::mutex> l(_memberStatus_l); diff --git a/controller/FileDB.cpp b/controller/FileDB.cpp index a7b59cbf..d4bc16ad 100644 --- a/controller/FileDB.cpp +++ b/controller/FileDB.cpp @@ -134,12 +134,24 @@ void FileDB::eraseNetwork(const uint64_t networkId) get(networkId,network); char p[16384]; OSUtils::ztsnprintf(p,sizeof(p),"%s" ZT_PATH_SEPARATOR_S "%.16llx.json",_networksPath.c_str(),networkId); - OSUtils::rm(p); + + if (OSUtils::fileExists(p,false)){ + OSUtils::rm(p); + } _networkChanged(network,nullJson,true); } void FileDB::eraseMember(const uint64_t networkId,const uint64_t memberId) { + nlohmann::json network,member,nullJson; + get(networkId,network); + get(memberId,member); + char p[16384]; + OSUtils::ztsnprintf(p,sizeof(p),"%s" ZT_PATH_SEPARATOR_S "%.16llx" ZT_PATH_SEPARATOR_S "member" ZT_PATH_SEPARATOR_S "%.10llx.json",_networksPath.c_str(),networkId,memberId); + if (OSUtils::fileExists(p,false)){ + OSUtils::rm(p); + } + _memberChanged(member,nullJson,true); } void FileDB::nodeIsOnline(const uint64_t networkId,const uint64_t memberId,const InetAddress &physicalAddress) |