mirror of
https://github.com/Telecominfraproject/wlan-cloud-owprov.git
synced 2025-11-02 11:37:54 +00:00
Compare commits
4 Commits
v2.11.0-RC
...
release/v2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a63dec7f8b | ||
|
|
9c5ed40d57 | ||
|
|
e1ec4d9491 | ||
|
|
f925ce12be |
@@ -1,5 +1,5 @@
|
|||||||
cmake_minimum_required(VERSION 3.13)
|
cmake_minimum_required(VERSION 3.13)
|
||||||
project(owprov VERSION 2.11.0)
|
project(owprov VERSION 2.10.0)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ fullnameOverride: ""
|
|||||||
images:
|
images:
|
||||||
owprov:
|
owprov:
|
||||||
repository: tip-tip-wlan-cloud-ucentral.jfrog.io/owprov
|
repository: tip-tip-wlan-cloud-ucentral.jfrog.io/owprov
|
||||||
tag: v2.11.0-RC1
|
tag: v2.10.0
|
||||||
pullPolicy: Always
|
pullPolicy: Always
|
||||||
# regcred:
|
# regcred:
|
||||||
# registry: tip-tip-wlan-cloud-ucentral.jfrog.io
|
# registry: tip-tip-wlan-cloud-ucentral.jfrog.io
|
||||||
|
|||||||
@@ -1331,6 +1331,12 @@ components:
|
|||||||
- $ref: '#/components/schemas/StringList'
|
- $ref: '#/components/schemas/StringList'
|
||||||
- $ref: '#/components/schemas/TagValuePairList'
|
- $ref: '#/components/schemas/TagValuePairList'
|
||||||
|
|
||||||
|
SystemCommandResults:
|
||||||
|
type: object
|
||||||
|
oneOf:
|
||||||
|
- $ref: '#/components/schemas/StringList'
|
||||||
|
- $ref: '#/components/schemas/TagValuePairList'
|
||||||
|
|
||||||
NoteInfo:
|
NoteInfo:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
@@ -1370,33 +1376,6 @@ components:
|
|||||||
type: integer
|
type: integer
|
||||||
format: int64
|
format: int64
|
||||||
|
|
||||||
SystemResources:
|
|
||||||
type: object
|
|
||||||
properties:
|
|
||||||
numberOfFileDescriptors:
|
|
||||||
type: integer
|
|
||||||
format: int64
|
|
||||||
currRealMem:
|
|
||||||
type: integer
|
|
||||||
format: int64
|
|
||||||
peakRealMem:
|
|
||||||
type: integer
|
|
||||||
format: int64
|
|
||||||
currVirtMem:
|
|
||||||
type: integer
|
|
||||||
format: int64
|
|
||||||
peakVirtMem:
|
|
||||||
type: integer
|
|
||||||
format: int64
|
|
||||||
|
|
||||||
SystemCommandResults:
|
|
||||||
type: object
|
|
||||||
oneOf:
|
|
||||||
- $ref: '#/components/schemas/SystemResources'
|
|
||||||
- $ref: '#/components/schemas/SystemInfoResults'
|
|
||||||
- $ref: '#/components/schemas/StringList'
|
|
||||||
- $ref: '#/components/schemas/TagValuePairList'
|
|
||||||
|
|
||||||
Dashboard:
|
Dashboard:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
@@ -4444,12 +4423,15 @@ paths:
|
|||||||
type: string
|
type: string
|
||||||
enum:
|
enum:
|
||||||
- info
|
- info
|
||||||
- extraConfiguration
|
|
||||||
- resources
|
|
||||||
required: true
|
required: true
|
||||||
responses:
|
responses:
|
||||||
200:
|
200:
|
||||||
$ref: '#/components/schemas/SystemCommandResults'
|
description: Successful command execution
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
oneOf:
|
||||||
|
- $ref: '#/components/schemas/SystemInfoResults'
|
||||||
403:
|
403:
|
||||||
$ref: '#/components/responses/Unauthorized'
|
$ref: '#/components/responses/Unauthorized'
|
||||||
404:
|
404:
|
||||||
|
|||||||
@@ -90,9 +90,9 @@ namespace OpenWifi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!Existing.contacts.empty()) {
|
if (!Existing.contacts.empty()) {
|
||||||
for (const auto &contact_uuid : Existing.contacts)
|
for (const auto &i : Existing.contacts)
|
||||||
StorageService()->ContactDB().DeleteInUse(
|
StorageService()->ContactDB().DeleteInUse(
|
||||||
"id", contact_uuid, StorageService()->VenueDB().Prefix(), UUID);
|
"id", i, StorageService()->VenueDB().Prefix(), UUID);
|
||||||
}
|
}
|
||||||
if (!Existing.location.empty())
|
if (!Existing.location.empty())
|
||||||
StorageService()->LocationDB().DeleteInUse("id", Existing.location,
|
StorageService()->LocationDB().DeleteInUse("id", Existing.location,
|
||||||
@@ -101,9 +101,9 @@ namespace OpenWifi {
|
|||||||
StorageService()->PolicyDB().DeleteInUse("id", Existing.managementPolicy,
|
StorageService()->PolicyDB().DeleteInUse("id", Existing.managementPolicy,
|
||||||
StorageService()->VenueDB().Prefix(), UUID);
|
StorageService()->VenueDB().Prefix(), UUID);
|
||||||
if (!Existing.deviceConfiguration.empty()) {
|
if (!Existing.deviceConfiguration.empty()) {
|
||||||
for (auto &configuration_uuid : Existing.deviceConfiguration)
|
for (auto &i : Existing.deviceConfiguration)
|
||||||
StorageService()->ConfigurationDB().DeleteInUse(
|
StorageService()->ConfigurationDB().DeleteInUse(
|
||||||
"id", configuration_uuid, StorageService()->VenueDB().Prefix(), UUID);
|
"id", i, StorageService()->VenueDB().Prefix(), UUID);
|
||||||
}
|
}
|
||||||
if (!Existing.parent.empty())
|
if (!Existing.parent.empty())
|
||||||
StorageService()->VenueDB().DeleteChild("id", Existing.parent, UUID);
|
StorageService()->VenueDB().DeleteChild("id", Existing.parent, UUID);
|
||||||
@@ -157,10 +157,6 @@ namespace OpenWifi {
|
|||||||
return BadRequest(RESTAPI::Errors::EntityMustExist);
|
return BadRequest(RESTAPI::Errors::EntityMustExist);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(StorageService()->VenueDB().DoesVenueNameAlreadyExist(NewObject.info.name,NewObject.entity, NewObject.parent)) {
|
|
||||||
return BadRequest(RESTAPI::Errors::VenuesNameAlreadyExists);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!NewObject.contacts.empty()) {
|
if (!NewObject.contacts.empty()) {
|
||||||
for (const auto &i : NewObject.contacts) {
|
for (const auto &i : NewObject.contacts) {
|
||||||
if (!StorageService()->ContactDB().Exists("id", i)) {
|
if (!StorageService()->ContactDB().Exists("id", i)) {
|
||||||
@@ -436,7 +432,7 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
std::string MoveFromEntity, MoveToEntity;
|
std::string MoveFromEntity, MoveToEntity;
|
||||||
if (AssignIfPresent(RawObject, "entity", MoveToEntity)) {
|
if (AssignIfPresent(RawObject, "entity", MoveToEntity)) {
|
||||||
if (MoveToEntity.empty() || !StorageService()->EntityDB().Exists("id", MoveToEntity)) {
|
if (!MoveToEntity.empty() && !StorageService()->EntityDB().Exists("id", MoveToEntity)) {
|
||||||
return BadRequest(RESTAPI::Errors::EntityMustExist);
|
return BadRequest(RESTAPI::Errors::EntityMustExist);
|
||||||
}
|
}
|
||||||
MoveFromEntity = Existing.entity;
|
MoveFromEntity = Existing.entity;
|
||||||
@@ -445,7 +441,7 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
std::string MoveToVenue, MoveFromVenue;
|
std::string MoveToVenue, MoveFromVenue;
|
||||||
if (AssignIfPresent(RawObject, "venue", MoveToVenue)) {
|
if (AssignIfPresent(RawObject, "venue", MoveToVenue)) {
|
||||||
if (MoveToVenue.empty() || !StorageService()->VenueDB().Exists("id", MoveToVenue)) {
|
if (!MoveToVenue.empty() && !StorageService()->VenueDB().Exists("id", MoveToVenue)) {
|
||||||
return BadRequest(RESTAPI::Errors::VenueMustExist);
|
return BadRequest(RESTAPI::Errors::VenueMustExist);
|
||||||
}
|
}
|
||||||
MoveFromVenue = Existing.parent;
|
MoveFromVenue = Existing.parent;
|
||||||
@@ -454,7 +450,7 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
std::string MoveFromLocation, MoveToLocation;
|
std::string MoveFromLocation, MoveToLocation;
|
||||||
if (AssignIfPresent(RawObject, "location", MoveToLocation)) {
|
if (AssignIfPresent(RawObject, "location", MoveToLocation)) {
|
||||||
if (MoveToLocation.empty() ||
|
if (!MoveToLocation.empty() &&
|
||||||
!StorageService()->LocationDB().Exists("id", MoveToLocation)) {
|
!StorageService()->LocationDB().Exists("id", MoveToLocation)) {
|
||||||
return BadRequest(RESTAPI::Errors::LocationMustExist);
|
return BadRequest(RESTAPI::Errors::LocationMustExist);
|
||||||
}
|
}
|
||||||
@@ -464,8 +460,8 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
Types::UUIDvec_t MoveFromContacts, MoveToContacts;
|
Types::UUIDvec_t MoveFromContacts, MoveToContacts;
|
||||||
if (AssignIfPresent(RawObject, "contacts", MoveToContacts)) {
|
if (AssignIfPresent(RawObject, "contacts", MoveToContacts)) {
|
||||||
for (const auto &contact : NewObject.contacts) {
|
for (const auto &i : NewObject.contacts) {
|
||||||
if (!StorageService()->ContactDB().Exists("id", contact)) {
|
if (!StorageService()->ContactDB().Exists("id", i)) {
|
||||||
return BadRequest(RESTAPI::Errors::ContactMustExist);
|
return BadRequest(RESTAPI::Errors::ContactMustExist);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -475,7 +471,7 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
std::string MoveFromPolicy, MoveToPolicy;
|
std::string MoveFromPolicy, MoveToPolicy;
|
||||||
if (AssignIfPresent(RawObject, "managementPolicy", MoveToPolicy)) {
|
if (AssignIfPresent(RawObject, "managementPolicy", MoveToPolicy)) {
|
||||||
if (MoveToPolicy.empty() || !StorageService()->PolicyDB().Exists("id", MoveToPolicy)) {
|
if (!MoveToPolicy.empty() && !StorageService()->PolicyDB().Exists("id", MoveToPolicy)) {
|
||||||
return BadRequest(RESTAPI::Errors::UnknownManagementPolicyUUID);
|
return BadRequest(RESTAPI::Errors::UnknownManagementPolicyUUID);
|
||||||
}
|
}
|
||||||
MoveFromPolicy = Existing.managementPolicy;
|
MoveFromPolicy = Existing.managementPolicy;
|
||||||
@@ -485,8 +481,8 @@ namespace OpenWifi {
|
|||||||
Types::UUIDvec_t MoveToConfigurations, MoveFromConfigurations;
|
Types::UUIDvec_t MoveToConfigurations, MoveFromConfigurations;
|
||||||
if (RawObject->has("deviceConfiguration")) {
|
if (RawObject->has("deviceConfiguration")) {
|
||||||
MoveToConfigurations = NewObject.deviceConfiguration;
|
MoveToConfigurations = NewObject.deviceConfiguration;
|
||||||
for (auto &configuration : MoveToConfigurations) {
|
for (auto &i : MoveToConfigurations) {
|
||||||
if (!StorageService()->ConfigurationDB().Exists("id", configuration)) {
|
if (!StorageService()->ConfigurationDB().Exists("id", i)) {
|
||||||
return BadRequest(RESTAPI::Errors::ConfigurationMustExist);
|
return BadRequest(RESTAPI::Errors::ConfigurationMustExist);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace OpenWifi {
|
|||||||
Response.set("Connection", "keep-alive");
|
Response.set("Connection", "keep-alive");
|
||||||
Response.setVersion(Poco::Net::HTTPMessage::HTTP_1_1);
|
Response.setVersion(Poco::Net::HTTPMessage::HTTP_1_1);
|
||||||
std::ostream &Answer = Response.send();
|
std::ostream &Answer = Response.send();
|
||||||
Answer << ALBHealthCheckServer()->CallbackText();
|
Answer << "process Alive and kicking!";
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -37,8 +37,6 @@ namespace OpenWifi {
|
|||||||
inline static std::atomic_uint64_t req_id_ = 1;
|
inline static std::atomic_uint64_t req_id_ = 1;
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef std::string ALBHealthMessageCallback();
|
|
||||||
|
|
||||||
class ALBHealthCheckServer : public SubSystemServer {
|
class ALBHealthCheckServer : public SubSystemServer {
|
||||||
public:
|
public:
|
||||||
ALBHealthCheckServer();
|
ALBHealthCheckServer();
|
||||||
@@ -50,22 +48,10 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
int Start() override;
|
int Start() override;
|
||||||
void Stop() override;
|
void Stop() override;
|
||||||
inline void RegisterExtendedHealthMessage(ALBHealthMessageCallback *F) {
|
|
||||||
Callback_=F;
|
|
||||||
};
|
|
||||||
|
|
||||||
inline std::string CallbackText() {
|
|
||||||
if(Callback_== nullptr) {
|
|
||||||
return "process Alive and kicking!";
|
|
||||||
} else {
|
|
||||||
return Callback_();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<Poco::Net::HTTPServer> Server_;
|
std::unique_ptr<Poco::Net::HTTPServer> Server_;
|
||||||
std::unique_ptr<Poco::Net::ServerSocket> Socket_;
|
std::unique_ptr<Poco::Net::ServerSocket> Socket_;
|
||||||
ALBHealthMessageCallback *Callback_= nullptr;
|
|
||||||
int Port_ = 0;
|
int Port_ = 0;
|
||||||
mutable std::atomic_bool Running_ = false;
|
mutable std::atomic_bool Running_ = false;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -2235,17 +2235,6 @@ static std::string DefaultUCentralSchema = R"foo(
|
|||||||
]
|
]
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"vlan-awareness": {
|
|
||||||
"type": "object",
|
|
||||||
"properties": {
|
|
||||||
"first": {
|
|
||||||
"type": "integer"
|
|
||||||
},
|
|
||||||
"last": {
|
|
||||||
"type": "integer"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"vlan": {
|
"vlan": {
|
||||||
"$ref": "#/$defs/interface.vlan"
|
"$ref": "#/$defs/interface.vlan"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -213,7 +213,7 @@ namespace OpenWifi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void KafkaProducer::Produce(const char *Topic, const std::string &Key,
|
void KafkaProducer::Produce(const char *Topic, const std::string &Key,
|
||||||
std::shared_ptr<std::string> Payload) {
|
const std::shared_ptr<std::string> Payload) {
|
||||||
std::lock_guard G(Mutex_);
|
std::lock_guard G(Mutex_);
|
||||||
Queue_.enqueueNotification(new KafkaMessage(Topic, Key, Payload));
|
Queue_.enqueueNotification(new KafkaMessage(Topic, Key, Payload));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
class KafkaMessage : public Poco::Notification {
|
class KafkaMessage : public Poco::Notification {
|
||||||
public:
|
public:
|
||||||
KafkaMessage(const char * Topic, const std::string &Key, std::shared_ptr<std::string> Payload)
|
KafkaMessage(const char * Topic, const std::string &Key, const std::shared_ptr<std::string> Payload)
|
||||||
: Topic_(Topic), Key_(Key), Payload_(Payload) {}
|
: Topic_(Topic), Key_(Key), Payload_(std::move(Payload)) {}
|
||||||
|
|
||||||
inline const char * Topic() { return Topic_; }
|
inline const char * Topic() { return Topic_; }
|
||||||
inline const std::string &Key() { return Key_; }
|
inline const std::string &Key() { return Key_; }
|
||||||
@@ -36,7 +36,7 @@ namespace OpenWifi {
|
|||||||
void run() override;
|
void run() override;
|
||||||
void Start();
|
void Start();
|
||||||
void Stop();
|
void Stop();
|
||||||
void Produce(const char *Topic, const std::string &Key, std::shared_ptr<std::string> Payload);
|
void Produce(const char *Topic, const std::string &Key, const std::shared_ptr<std::string> Payload);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::recursive_mutex Mutex_;
|
std::recursive_mutex Mutex_;
|
||||||
@@ -92,9 +92,9 @@ namespace OpenWifi {
|
|||||||
void Stop() override;
|
void Stop() override;
|
||||||
|
|
||||||
void PostMessage(const char *topic, const std::string &key,
|
void PostMessage(const char *topic, const std::string &key,
|
||||||
std::shared_ptr<std::string> PayLoad, bool WrapMessage = true);
|
const std::shared_ptr<std::string> PayLoad, bool WrapMessage = true);
|
||||||
void Dispatch(const char *Topic, const std::string &Key, std::shared_ptr<std::string> Payload);
|
void Dispatch(const char *Topic, const std::string &Key, const std::shared_ptr<std::string> Payload);
|
||||||
[[nodiscard]] const std::shared_ptr<std::string> WrapSystemId(std::shared_ptr<std::string> PayLoad);
|
[[nodiscard]] const std::shared_ptr<std::string> WrapSystemId(const std::shared_ptr<std::string> PayLoad);
|
||||||
[[nodiscard]] inline bool Enabled() const { return KafkaEnabled_; }
|
[[nodiscard]] inline bool Enabled() const { return KafkaEnabled_; }
|
||||||
uint64_t RegisterTopicWatcher(const std::string &Topic, Types::TopicNotifyFunction &F);
|
uint64_t RegisterTopicWatcher(const std::string &Topic, Types::TopicNotifyFunction &F);
|
||||||
void UnregisterTopicWatcher(const std::string &Topic, uint64_t Id);
|
void UnregisterTopicWatcher(const std::string &Topic, uint64_t Id);
|
||||||
|
|||||||
@@ -129,8 +129,6 @@ namespace OpenWifi {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
poco_error(logger(), "Bad bus message.");
|
poco_error(logger(), "Bad bus message.");
|
||||||
std::ostringstream os;
|
|
||||||
Object->stringify(std::cout);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto i = Services_.begin();
|
auto i = Services_.begin();
|
||||||
|
|||||||
@@ -5,8 +5,6 @@
|
|||||||
#include "framework/MicroServiceFuncs.h"
|
#include "framework/MicroServiceFuncs.h"
|
||||||
#include "framework/MicroService.h"
|
#include "framework/MicroService.h"
|
||||||
|
|
||||||
#include "framework/ALBserver.h"
|
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
const std::string &MicroServiceDataDirectory() { return MicroService::instance().DataDir(); }
|
const std::string &MicroServiceDataDirectory() { return MicroService::instance().DataDir(); }
|
||||||
|
|
||||||
@@ -125,8 +123,4 @@ namespace OpenWifi {
|
|||||||
return MicroService::instance().AllowExternalMicroServices();
|
return MicroService::instance().AllowExternalMicroServices();
|
||||||
}
|
}
|
||||||
|
|
||||||
void MicroServiceALBCallback( std::string Callback()) {
|
|
||||||
return ALBHealthCheckServer()->RegisterExtendedHealthMessage(Callback);
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace OpenWifi
|
} // namespace OpenWifi
|
||||||
|
|||||||
@@ -53,5 +53,4 @@ namespace OpenWifi {
|
|||||||
std::string MicroServiceGetPublicAPIEndPoint();
|
std::string MicroServiceGetPublicAPIEndPoint();
|
||||||
void MicroServiceDeleteOverrideConfiguration();
|
void MicroServiceDeleteOverrideConfiguration();
|
||||||
bool AllowExternalMicroServices();
|
bool AllowExternalMicroServices();
|
||||||
void MicroServiceALBCallback( std::string Callback());
|
|
||||||
} // namespace OpenWifi
|
} // namespace OpenWifi
|
||||||
|
|||||||
@@ -28,9 +28,6 @@ namespace OpenWifi::Types {
|
|||||||
typedef std::string UUID_t;
|
typedef std::string UUID_t;
|
||||||
typedef std::vector<UUID_t> UUIDvec_t;
|
typedef std::vector<UUID_t> UUIDvec_t;
|
||||||
typedef std::map<std::string, std::map<uint32_t, uint64_t>> Counted3DMapSII;
|
typedef std::map<std::string, std::map<uint32_t, uint64_t>> Counted3DMapSII;
|
||||||
typedef std::vector<int64_t> IntList;
|
|
||||||
typedef std::vector<uint64_t> UIntList;
|
|
||||||
typedef std::vector<double> DoubleList;
|
|
||||||
|
|
||||||
struct MicroServiceMeta {
|
struct MicroServiceMeta {
|
||||||
uint64_t Id = 0;
|
uint64_t Id = 0;
|
||||||
|
|||||||
@@ -24,63 +24,50 @@ namespace OpenWifi {
|
|||||||
Server, TransactionId, Internal) {}
|
Server, TransactionId, Internal) {}
|
||||||
static auto PathName() { return std::list<std::string>{"/api/v1/system"}; }
|
static auto PathName() { return std::list<std::string>{"/api/v1/system"}; }
|
||||||
|
|
||||||
inline void DoGet() final {
|
inline void DoGet() {
|
||||||
std::string Arg;
|
std::string Arg;
|
||||||
if (HasParameter("command", Arg)) {
|
if (HasParameter("command", Arg) && Arg == "info") {
|
||||||
if (Arg == "info") {
|
Poco::JSON::Object Answer;
|
||||||
Poco::JSON::Object Answer;
|
Answer.set(RESTAPI::Protocol::VERSION, MicroServiceVersion());
|
||||||
Answer.set(RESTAPI::Protocol::VERSION, MicroServiceVersion());
|
Answer.set(RESTAPI::Protocol::UPTIME, MicroServiceUptimeTotalSeconds());
|
||||||
Answer.set(RESTAPI::Protocol::UPTIME, MicroServiceUptimeTotalSeconds());
|
Answer.set(RESTAPI::Protocol::START, MicroServiceStartTimeEpochTime());
|
||||||
Answer.set(RESTAPI::Protocol::START, MicroServiceStartTimeEpochTime());
|
Answer.set(RESTAPI::Protocol::OS, Poco::Environment::osName());
|
||||||
Answer.set(RESTAPI::Protocol::OS, Poco::Environment::osName());
|
Answer.set(RESTAPI::Protocol::PROCESSORS, Poco::Environment::processorCount());
|
||||||
Answer.set(RESTAPI::Protocol::PROCESSORS, Poco::Environment::processorCount());
|
Answer.set(RESTAPI::Protocol::HOSTNAME, Poco::Environment::nodeName());
|
||||||
Answer.set(RESTAPI::Protocol::HOSTNAME, Poco::Environment::nodeName());
|
Answer.set(RESTAPI::Protocol::UI, MicroServiceGetUIURI());
|
||||||
Answer.set(RESTAPI::Protocol::UI, MicroServiceGetUIURI());
|
|
||||||
|
|
||||||
Poco::JSON::Array Certificates;
|
Poco::JSON::Array Certificates;
|
||||||
auto SubSystems = MicroServiceGetFullSubSystems();
|
auto SubSystems = MicroServiceGetFullSubSystems();
|
||||||
std::set<std::string> CertNames;
|
std::set<std::string> CertNames;
|
||||||
|
|
||||||
for (const auto &i : SubSystems) {
|
for (const auto &i : SubSystems) {
|
||||||
auto Hosts = i->HostSize();
|
auto Hosts = i->HostSize();
|
||||||
for (uint64_t j = 0; j < Hosts; ++j) {
|
for (uint64_t j = 0; j < Hosts; ++j) {
|
||||||
auto CertFileName = i->Host(j).CertFile();
|
auto CertFileName = i->Host(j).CertFile();
|
||||||
if (!CertFileName.empty()) {
|
if (!CertFileName.empty()) {
|
||||||
Poco::File F1(CertFileName);
|
Poco::File F1(CertFileName);
|
||||||
if (F1.exists()) {
|
if (F1.exists()) {
|
||||||
auto InsertResult = CertNames.insert(CertFileName);
|
auto InsertResult = CertNames.insert(CertFileName);
|
||||||
if (InsertResult.second) {
|
if (InsertResult.second) {
|
||||||
Poco::JSON::Object Inner;
|
Poco::JSON::Object Inner;
|
||||||
Poco::Path F(CertFileName);
|
Poco::Path F(CertFileName);
|
||||||
Inner.set("filename", F.getFileName());
|
Inner.set("filename", F.getFileName());
|
||||||
Poco::Crypto::X509Certificate C(CertFileName);
|
Poco::Crypto::X509Certificate C(CertFileName);
|
||||||
auto ExpiresOn = C.expiresOn();
|
auto ExpiresOn = C.expiresOn();
|
||||||
Inner.set("expiresOn", ExpiresOn.timestamp().epochTime());
|
Inner.set("expiresOn", ExpiresOn.timestamp().epochTime());
|
||||||
Certificates.add(Inner);
|
Certificates.add(Inner);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Answer.set("certificates", Certificates);
|
|
||||||
return ReturnObject(Answer);
|
|
||||||
}
|
|
||||||
if (Arg == "extraConfiguration") {
|
|
||||||
Poco::JSON::Object Answer;
|
|
||||||
MicroServiceGetExtraConfiguration(Answer);
|
|
||||||
return ReturnObject(Answer);
|
|
||||||
}
|
|
||||||
if (Arg == "resources") {
|
|
||||||
Poco::JSON::Object Answer;
|
|
||||||
Answer.set("numberOfFileDescriptors", Utils::get_open_fds());
|
|
||||||
std::uint64_t currRealMem, peakRealMem, currVirtMem, peakVirtMem;
|
|
||||||
Utils::getMemory(currRealMem, peakRealMem, currVirtMem, peakVirtMem);
|
|
||||||
Answer.set("currRealMem", currRealMem);
|
|
||||||
Answer.set("peakRealMem", peakRealMem);
|
|
||||||
Answer.set("currVirtMem", currVirtMem);
|
|
||||||
Answer.set("peakVirtMem", peakVirtMem);
|
|
||||||
return ReturnObject(Answer);
|
|
||||||
}
|
}
|
||||||
|
Answer.set("certificates", Certificates);
|
||||||
|
return ReturnObject(Answer);
|
||||||
|
}
|
||||||
|
if (GetBoolParameter("extraConfiguration")) {
|
||||||
|
Poco::JSON::Object Answer;
|
||||||
|
MicroServiceGetExtraConfiguration(Answer);
|
||||||
|
return ReturnObject(Answer);
|
||||||
}
|
}
|
||||||
BadRequest(RESTAPI::Errors::InvalidCommand);
|
BadRequest(RESTAPI::Errors::InvalidCommand);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,20 +102,6 @@ namespace OpenWifi::RESTAPI_utils {
|
|||||||
Obj.set(Field, A);
|
Obj.set(Field, A);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void field_to_json(Poco::JSON::Object &Obj, const char *Field, const Types::DoubleList &V) {
|
|
||||||
Poco::JSON::Array A;
|
|
||||||
for (const auto &i : V)
|
|
||||||
A.add(i);
|
|
||||||
Obj.set(Field, A);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void field_to_json(Poco::JSON::Object &Obj, const char *Field, const Types::IntList &V) {
|
|
||||||
Poco::JSON::Array A;
|
|
||||||
for (const auto &i : V)
|
|
||||||
A.add(i);
|
|
||||||
Obj.set(Field, A);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void field_to_json(Poco::JSON::Object &Obj, const char *Field, const Types::TagList &V) {
|
inline void field_to_json(Poco::JSON::Object &Obj, const char *Field, const Types::TagList &V) {
|
||||||
Poco::JSON::Array A;
|
Poco::JSON::Array A;
|
||||||
for (const auto &i : V)
|
for (const auto &i : V)
|
||||||
@@ -298,28 +284,6 @@ namespace OpenWifi::RESTAPI_utils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void field_from_json(const Poco::JSON::Object::Ptr &Obj, const char *Field,
|
|
||||||
Types::DoubleList &Value) {
|
|
||||||
if (Obj->isArray(Field) && !Obj->isNull(Field)) {
|
|
||||||
Value.clear();
|
|
||||||
Poco::JSON::Array::Ptr A = Obj->getArray(Field);
|
|
||||||
for (const auto &i : *A) {
|
|
||||||
Value.push_back(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void field_from_json(const Poco::JSON::Object::Ptr &Obj, const char *Field,
|
|
||||||
Types::IntList &Value) {
|
|
||||||
if (Obj->isArray(Field) && !Obj->isNull(Field)) {
|
|
||||||
Value.clear();
|
|
||||||
Poco::JSON::Array::Ptr A = Obj->getArray(Field);
|
|
||||||
for (const auto &i : *A) {
|
|
||||||
Value.push_back(i);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
template <class T>
|
template <class T>
|
||||||
void field_from_json(const Poco::JSON::Object::Ptr &Obj, const char *Field,
|
void field_from_json(const Poco::JSON::Object::Ptr &Obj, const char *Field,
|
||||||
std::vector<T> &Value) {
|
std::vector<T> &Value) {
|
||||||
|
|||||||
@@ -22,8 +22,9 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
class StorageClass : public SubSystemServer {
|
class StorageClass : public SubSystemServer {
|
||||||
public:
|
public:
|
||||||
|
StorageClass() noexcept : SubSystemServer("StorageClass", "STORAGE-SVR", "storage") {}
|
||||||
|
|
||||||
inline int Start() override {
|
int Start() override {
|
||||||
std::lock_guard Guard(Mutex_);
|
std::lock_guard Guard(Mutex_);
|
||||||
|
|
||||||
Logger().notice("Starting.");
|
Logger().notice("Starting.");
|
||||||
@@ -39,22 +40,17 @@ namespace OpenWifi {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Stop() override { Pool_->shutdown(); }
|
void Stop() override { Pool_->shutdown(); }
|
||||||
|
|
||||||
DBType Type() const { return dbType_; };
|
DBType Type() const { return dbType_; };
|
||||||
|
|
||||||
StorageClass() noexcept : SubSystemServer("StorageClass", "STORAGE-SVR", "storage") {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
inline int Setup_SQLite();
|
inline int Setup_SQLite();
|
||||||
inline int Setup_MySQL();
|
inline int Setup_MySQL();
|
||||||
inline int Setup_PostgreSQL();
|
inline int Setup_PostgreSQL();
|
||||||
|
|
||||||
|
protected:
|
||||||
protected:
|
std::unique_ptr<Poco::Data::SessionPool> Pool_;
|
||||||
std::shared_ptr<Poco::Data::SessionPool> Pool_;
|
|
||||||
Poco::Data::SQLite::Connector SQLiteConn_;
|
Poco::Data::SQLite::Connector SQLiteConn_;
|
||||||
Poco::Data::PostgreSQL::Connector PostgresConn_;
|
Poco::Data::PostgreSQL::Connector PostgresConn_;
|
||||||
Poco::Data::MySQL::Connector MySQLConn_;
|
Poco::Data::MySQL::Connector MySQLConn_;
|
||||||
@@ -85,7 +81,7 @@ namespace OpenWifi {
|
|||||||
// Poco::Data::SessionPool(SQLiteConn_.name(), DBName, 8,
|
// Poco::Data::SessionPool(SQLiteConn_.name(), DBName, 8,
|
||||||
// (int)NumSessions,
|
// (int)NumSessions,
|
||||||
// (int)IdleTime));
|
// (int)IdleTime));
|
||||||
Pool_ = std::make_shared<Poco::Data::SessionPool>(SQLiteConn_.name(), DBName, 8,
|
Pool_ = std::make_unique<Poco::Data::SessionPool>(SQLiteConn_.name(), DBName, 8,
|
||||||
(int)NumSessions, (int)IdleTime);
|
(int)NumSessions, (int)IdleTime);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -106,7 +102,7 @@ namespace OpenWifi {
|
|||||||
";compress=true;auto-reconnect=true";
|
";compress=true;auto-reconnect=true";
|
||||||
|
|
||||||
Poco::Data::MySQL::Connector::registerConnector();
|
Poco::Data::MySQL::Connector::registerConnector();
|
||||||
Pool_ = std::make_shared<Poco::Data::SessionPool>(MySQLConn_.name(), ConnectionStr, 8,
|
Pool_ = std::make_unique<Poco::Data::SessionPool>(MySQLConn_.name(), ConnectionStr, 8,
|
||||||
NumSessions, IdleTime);
|
NumSessions, IdleTime);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@@ -130,7 +126,7 @@ namespace OpenWifi {
|
|||||||
" connect_timeout=" + ConnectionTimeout;
|
" connect_timeout=" + ConnectionTimeout;
|
||||||
|
|
||||||
Poco::Data::PostgreSQL::Connector::registerConnector();
|
Poco::Data::PostgreSQL::Connector::registerConnector();
|
||||||
Pool_ = std::make_shared<Poco::Data::SessionPool>(PostgresConn_.name(), ConnectionStr, 8,
|
Pool_ = std::make_unique<Poco::Data::SessionPool>(PostgresConn_.name(), ConnectionStr, 8,
|
||||||
NumSessions, IdleTime);
|
NumSessions, IdleTime);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|||||||
@@ -401,12 +401,6 @@ namespace OpenWifi::RESTAPI::Errors {
|
|||||||
1171, "Command not supported on simulated device."
|
1171, "Command not supported on simulated device."
|
||||||
};
|
};
|
||||||
|
|
||||||
static const struct msg VenuesNameAlreadyExists {
|
|
||||||
1172, "The venue name already exists."
|
|
||||||
};
|
|
||||||
|
|
||||||
static const struct msg DefFirmwareNameExists { 1172, "Firmware name already exists." };
|
|
||||||
|
|
||||||
static const struct msg SimulationDoesNotExist {
|
static const struct msg SimulationDoesNotExist {
|
||||||
7000, "Simulation Instance ID does not exist."
|
7000, "Simulation Instance ID does not exist."
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -132,15 +132,6 @@ namespace OpenWifi::Utils {
|
|||||||
return std::regex_match(Hostname, HostNameRegex);
|
return std::regex_match(Hostname, HostNameRegex);
|
||||||
}
|
}
|
||||||
|
|
||||||
[[nodiscard]] bool ValidNumber(const std::string &number, bool isSigned)
|
|
||||||
{
|
|
||||||
static std::regex IntRegex("^-?[0-9]\\d*(\\.\\d+)?$");
|
|
||||||
if(!isSigned) {
|
|
||||||
IntRegex = "^[0-9]\\d*(\\.\\d+)?$";
|
|
||||||
}
|
|
||||||
return std::regex_match(number, IntRegex);
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] std::string ToHex(const std::vector<unsigned char> &B) {
|
[[nodiscard]] std::string ToHex(const std::vector<unsigned char> &B) {
|
||||||
std::string R;
|
std::string R;
|
||||||
R.reserve(B.size() * 2);
|
R.reserve(B.size() * 2);
|
||||||
|
|||||||
@@ -13,8 +13,6 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
|
||||||
#include <dirent.h>
|
|
||||||
|
|
||||||
#include "Poco/Base64Decoder.h"
|
#include "Poco/Base64Decoder.h"
|
||||||
#include "Poco/Base64Encoder.h"
|
#include "Poco/Base64Encoder.h"
|
||||||
#include "Poco/File.h"
|
#include "Poco/File.h"
|
||||||
@@ -73,7 +71,6 @@ namespace OpenWifi::Utils {
|
|||||||
[[nodiscard]] bool ValidSerialNumbers(const std::vector<std::string> &Serial);
|
[[nodiscard]] bool ValidSerialNumbers(const std::vector<std::string> &Serial);
|
||||||
[[nodiscard]] bool ValidUUID(const std::string &UUID);
|
[[nodiscard]] bool ValidUUID(const std::string &UUID);
|
||||||
[[nodiscard]] bool ValidHostname(const std::string &hostname);
|
[[nodiscard]] bool ValidHostname(const std::string &hostname);
|
||||||
[[nodiscard]] bool ValidNumber(const std::string &number, bool isSigned);
|
|
||||||
|
|
||||||
template <typename... Args> std::string ComputeHash(Args &&...args) {
|
template <typename... Args> std::string ComputeHash(Args &&...args) {
|
||||||
Poco::SHA2Engine E;
|
Poco::SHA2Engine E;
|
||||||
@@ -184,67 +181,4 @@ namespace OpenWifi::Utils {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline std::uint64_t GetValue(FILE *file) {
|
|
||||||
unsigned long v=0;
|
|
||||||
char factor[32];
|
|
||||||
if(fscanf(file, " %lu %31s", &v, factor)==2) {
|
|
||||||
switch (factor[0]) {
|
|
||||||
case 'k':
|
|
||||||
return v * 1000;
|
|
||||||
case 'M':
|
|
||||||
return v * 1000000;
|
|
||||||
case 'G':
|
|
||||||
return v * 1000000000;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return v;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool getMemory(
|
|
||||||
std::uint64_t &currRealMem, std::uint64_t &peakRealMem,
|
|
||||||
std::uint64_t &currVirtMem, std::uint64_t &peakVirtMem) {
|
|
||||||
|
|
||||||
// stores each word in status file
|
|
||||||
char buffer[1024] = "";
|
|
||||||
|
|
||||||
currRealMem = peakRealMem = currVirtMem = peakVirtMem = 0;
|
|
||||||
|
|
||||||
// linux file contains this-process info
|
|
||||||
FILE * file = std::fopen("/proc/self/status", "r");
|
|
||||||
if (file == nullptr) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// read the entire file, recording mems in kB
|
|
||||||
while (fscanf(file, " %1023s", buffer) == 1) {
|
|
||||||
|
|
||||||
if (strcmp(buffer, "VmRSS:") == 0) {
|
|
||||||
currRealMem= GetValue(file);
|
|
||||||
} else if (strcmp(buffer, "VmHWM:") == 0) {
|
|
||||||
peakRealMem= GetValue(file);
|
|
||||||
} else if (strcmp(buffer, "VmSize:") == 0) {
|
|
||||||
currVirtMem= GetValue(file);
|
|
||||||
} else if (strcmp(buffer, "VmPeak:") == 0) {
|
|
||||||
peakVirtMem= GetValue(file);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
fclose(file);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline int get_open_fds() {
|
|
||||||
DIR *dp = opendir("/proc/self/fd");
|
|
||||||
struct dirent *de;
|
|
||||||
int count = -3; // '.', '..', dp
|
|
||||||
|
|
||||||
if (dp == nullptr)
|
|
||||||
return -1;
|
|
||||||
while ((de = readdir(dp)) != nullptr)
|
|
||||||
count++;
|
|
||||||
(void)closedir(dp);
|
|
||||||
|
|
||||||
return count;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace OpenWifi::Utils
|
} // namespace OpenWifi::Utils
|
||||||
|
|||||||
@@ -112,31 +112,6 @@ namespace OpenWifi {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool VenueDB::DoesVenueNameAlreadyExist(const std::string &name, const std::string &entity_uuid, const std::string &parent_uuid) {
|
|
||||||
|
|
||||||
std::string Statement;
|
|
||||||
if(!entity_uuid.empty()) {
|
|
||||||
Statement = fmt::format("select count(*) from venues where entity='{}' and upper(name)='{}'",
|
|
||||||
entity_uuid, Poco::toUpper(name));
|
|
||||||
} else {
|
|
||||||
Statement = fmt::format("select count(*) from venues where parent='{}' and upper(name)='{}'",
|
|
||||||
parent_uuid, Poco::toUpper(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
std::uint64_t RecordCount = 0;
|
|
||||||
try {
|
|
||||||
Poco::Data::Session Session = Pool_.get();
|
|
||||||
Poco::Data::Statement Command(Session);
|
|
||||||
|
|
||||||
Command << Statement,
|
|
||||||
Poco::Data::Keywords::into(RecordCount);
|
|
||||||
Command.execute();
|
|
||||||
} catch (...) {
|
|
||||||
|
|
||||||
}
|
|
||||||
return RecordCount!=0;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace OpenWifi
|
} // namespace OpenWifi
|
||||||
|
|
||||||
template <>
|
template <>
|
||||||
|
|||||||
@@ -26,7 +26,6 @@ namespace OpenWifi {
|
|||||||
bool GetByIP(const std::string &IP, std::string &uuid);
|
bool GetByIP(const std::string &IP, std::string &uuid);
|
||||||
bool Upgrade(uint32_t from, uint32_t &to) override;
|
bool Upgrade(uint32_t from, uint32_t &to) override;
|
||||||
bool EvaluateDeviceRules(const std::string &id, ProvObjects::DeviceRules &Rules);
|
bool EvaluateDeviceRules(const std::string &id, ProvObjects::DeviceRules &Rules);
|
||||||
bool DoesVenueNameAlreadyExist(const std::string &name, const std::string &entity_uuid, const std::string &parent_uuid);
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user