mirror of
https://github.com/Telecominfraproject/wlan-cloud-owprov.git
synced 2025-10-29 09:42:38 +00:00
Compare commits
23 Commits
v3.1.0-RC1
...
v4.1.0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1d8df22092 | ||
|
|
d109c0cd7e | ||
|
|
8b06a65d5b | ||
|
|
3e7c72831f | ||
|
|
069b60a6c6 | ||
|
|
1832d2c1cb | ||
|
|
0ef1dad4dc | ||
|
|
d001c44a81 | ||
|
|
fe6023b18d | ||
|
|
1bd1cf0af6 | ||
|
|
6ce0f2fb51 | ||
|
|
020ff8641a | ||
|
|
342c6900ef | ||
|
|
a549024a29 | ||
|
|
6f84eeb901 | ||
|
|
c44dabe2f3 | ||
|
|
c78888372c | ||
|
|
4ae0b99f55 | ||
|
|
41e172be25 | ||
|
|
d7e05eac60 | ||
|
|
fd25e19095 | ||
|
|
3b8a8bafff | ||
|
|
da23ff1192 |
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@@ -21,7 +21,7 @@ defaults:
|
||||
|
||||
jobs:
|
||||
docker:
|
||||
runs-on: ubuntu-20.04
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
DOCKER_REGISTRY_URL: tip-tip-wlan-cloud-ucentral.jfrog.io
|
||||
DOCKER_REGISTRY_USERNAME: ucentral
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
cmake_minimum_required(VERSION 3.13)
|
||||
project(owprov VERSION 3.1.0)
|
||||
project(owprov VERSION 4.1.0)
|
||||
|
||||
set(CMAKE_CXX_STANDARD 17)
|
||||
|
||||
@@ -242,4 +242,3 @@ target_link_libraries(owprov PUBLIC
|
||||
CppKafka::cppkafka
|
||||
resolv
|
||||
fmt::fmt)
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ fullnameOverride: ""
|
||||
images:
|
||||
owprov:
|
||||
repository: tip-tip-wlan-cloud-ucentral.jfrog.io/owprov
|
||||
tag: main
|
||||
tag: v4.1.0
|
||||
pullPolicy: Always
|
||||
# regcred:
|
||||
# registry: tip-tip-wlan-cloud-ucentral.jfrog.io
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
#include "AutoDiscovery.h"
|
||||
#include "Poco/JSON/Parser.h"
|
||||
#include "StorageService.h"
|
||||
#include "Tasks/VenueConfigUpdater.h"
|
||||
#include "framework/KafkaManager.h"
|
||||
#include "framework/KafkaTopics.h"
|
||||
#include "framework/ow_constants.h"
|
||||
@@ -107,6 +108,11 @@ namespace OpenWifi {
|
||||
if (!SerialNumber.empty() && Connected) {
|
||||
StorageService()->InventoryDB().CreateFromConnection(
|
||||
SerialNumber, ConnectedIP, Compatible, Locale, isConnection);
|
||||
// Now that the entry has been created, we can try to push a config if
|
||||
// the connection was a capabilities message.
|
||||
if (isConnection){
|
||||
ComputeAndPushConfig(SerialNumber, Compatible, Logger());
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (const Poco::Exception &E) {
|
||||
|
||||
@@ -14,28 +14,13 @@
|
||||
#include "RESTAPI/RESTAPI_db_helpers.h"
|
||||
#include "SerialNumberCache.h"
|
||||
#include "StorageService.h"
|
||||
#include "Tasks/VenueConfigUpdater.h"
|
||||
#include "framework/utils.h"
|
||||
#include "sdks/SDK_gw.h"
|
||||
#include "sdks/SDK_sec.h"
|
||||
|
||||
namespace OpenWifi {
|
||||
|
||||
void GetRejectedLines(const Poco::JSON::Object::Ptr &Response, Types::StringVec &Warnings) {
|
||||
try {
|
||||
if (Response->has("results")) {
|
||||
auto Results = Response->get("results").extract<Poco::JSON::Object::Ptr>();
|
||||
auto Status = Results->get("status").extract<Poco::JSON::Object::Ptr>();
|
||||
auto Rejected = Status->getArray("rejected");
|
||||
std::transform(
|
||||
Rejected->begin(), Rejected->end(), std::back_inserter(Warnings),
|
||||
[](auto i) -> auto { return i.toString(); });
|
||||
// for(const auto &i:*Rejected)
|
||||
// Warnings.push_back(i.toString());
|
||||
}
|
||||
} catch (...) {
|
||||
}
|
||||
}
|
||||
|
||||
void RESTAPI_inventory_handler::DoGet() {
|
||||
|
||||
ProvObjects::InventoryTag Existing;
|
||||
@@ -314,6 +299,8 @@ namespace OpenWifi {
|
||||
return NotFound();
|
||||
}
|
||||
|
||||
std::string previous_venue = Existing.venue;
|
||||
|
||||
auto RemoveSubscriber = GetParameter("removeSubscriber");
|
||||
if (!RemoveSubscriber.empty()) {
|
||||
if (Existing.subscriber == RemoveSubscriber) {
|
||||
@@ -471,6 +458,13 @@ namespace OpenWifi {
|
||||
SDK::GW::Device::SetOwnerShip(this, SerialNumber, Existing.entity, Existing.venue,
|
||||
Existing.subscriber);
|
||||
|
||||
// Attempt an automatic config push when the venue is set and different than what is
|
||||
// in DB.
|
||||
poco_information(Logger(), fmt::format("New Venue {} Old Venue {}", NewObject.venue, previous_venue));
|
||||
if (!NewObject.venue.empty() && NewObject.venue != previous_venue) {
|
||||
ComputeAndPushConfig(SerialNumber, NewObject.deviceType, Logger());
|
||||
}
|
||||
|
||||
ProvObjects::InventoryTag NewObjectCreated;
|
||||
DB_.GetRecord("id", Existing.info.id, NewObjectCreated);
|
||||
Poco::JSON::Object Answer;
|
||||
|
||||
@@ -28,6 +28,42 @@ namespace OpenWifi {
|
||||
}
|
||||
}
|
||||
|
||||
[[maybe_unused]] static void ComputeAndPushConfig(const std::string &SerialNumber, const std::string &DeviceType, Poco::Logger &Logger) {
|
||||
/*
|
||||
Generic Helper to compute a device's config and push it down to the device.
|
||||
*/
|
||||
poco_information(Logger, fmt::format("Attempting to push venue config for device {}", SerialNumber));
|
||||
auto DeviceConfig = std::make_shared<APConfig>(SerialNumber,
|
||||
DeviceType, Logger, false);
|
||||
auto Configuration = Poco::makeShared<Poco::JSON::Object>();
|
||||
try {
|
||||
if (DeviceConfig->Get(Configuration)) {
|
||||
std::ostringstream OS;
|
||||
Configuration->stringify(OS);
|
||||
auto Response = Poco::makeShared<Poco::JSON::Object>();
|
||||
poco_debug(Logger,
|
||||
fmt::format("{}: Pushing configuration.", SerialNumber));
|
||||
if (SDK::GW::Device::Configure(nullptr, SerialNumber, Configuration,
|
||||
Response)) {
|
||||
Logger.debug(
|
||||
fmt::format("{}: Configuration pushed.", SerialNumber));
|
||||
poco_information(Logger,
|
||||
fmt::format("{}: Updated.", SerialNumber));
|
||||
} else {
|
||||
poco_information(Logger,
|
||||
fmt::format("{}: Not updated.", SerialNumber));
|
||||
}
|
||||
} else {
|
||||
poco_debug(Logger,
|
||||
fmt::format("{}: Configuration is bad.", SerialNumber));
|
||||
}
|
||||
} catch (...) {
|
||||
poco_debug(Logger,
|
||||
fmt::format("{}: Configuration is bad (caused an exception).",
|
||||
SerialNumber));
|
||||
}
|
||||
}
|
||||
|
||||
class VenueDeviceConfigUpdater : public Poco::Runnable {
|
||||
public:
|
||||
VenueDeviceConfigUpdater(const std::string &UUID, const std::string &venue, Poco::Logger &L)
|
||||
|
||||
@@ -67,9 +67,9 @@ namespace OpenWifi {
|
||||
|
||||
bool Get(const char *key, std::vector<std::string> &Value) {
|
||||
if(Registry_->has(key) && !Registry_->isNull(key) && Registry_->isArray(key)) {
|
||||
auto Arr = Registry_->get(key);
|
||||
for(const auto &v:Arr) {
|
||||
Value.emplace_back(v);
|
||||
auto pArr = Registry_->getArray(key);
|
||||
for(const auto &v : *pArr) {
|
||||
Value.emplace_back(v.toString());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -91,4 +91,4 @@ namespace OpenWifi {
|
||||
|
||||
inline auto AppServiceRegistry() { return AppServiceRegistry::instance(); }
|
||||
|
||||
} // namespace OpenWifi
|
||||
} // namespace OpenWifi
|
||||
|
||||
@@ -107,6 +107,19 @@ namespace OpenWifi {
|
||||
NewMessage.partition(0);
|
||||
NewMessage.payload(Msg->Payload());
|
||||
Producer.produce(NewMessage);
|
||||
if (Queue_.size() < 100) {
|
||||
// use flush when internal queue is lightly loaded, i.e. flush after each
|
||||
// message
|
||||
Producer.flush();
|
||||
}
|
||||
else {
|
||||
// use poll when internal queue is loaded to allow messages to be sent in
|
||||
// batches
|
||||
Producer.poll((std::chrono::milliseconds) 0);
|
||||
}
|
||||
}
|
||||
if (Queue_.size() == 0) {
|
||||
// message queue is empty, flush all previously sent messages
|
||||
Producer.flush();
|
||||
}
|
||||
} catch (const cppkafka::HandleException &E) {
|
||||
@@ -119,6 +132,7 @@ namespace OpenWifi {
|
||||
}
|
||||
Note = Queue_.waitDequeueNotification();
|
||||
}
|
||||
Producer.flush();
|
||||
poco_information(Logger_, "Stopped...");
|
||||
}
|
||||
|
||||
@@ -324,4 +338,4 @@ namespace OpenWifi {
|
||||
partitions.front().get_partition()));
|
||||
}
|
||||
|
||||
} // namespace OpenWifi
|
||||
} // namespace OpenWifi
|
||||
|
||||
Reference in New Issue
Block a user