Compare commits

..

6 Commits

Author SHA1 Message Date
TIP Automation User
af7cbf0ce1 Chg: update image tag in helm values to v2.7.0-RC6 2022-10-05 02:46:05 +00:00
Stephane Bourque
d50e8c0c44 Merge pull request #74 from Telecominfraproject/main
Fix for WIFI-10942
2022-10-04 19:41:23 -07:00
Dmitry Dunaev
698b467d3f Merge pull request #72 from Telecominfraproject/main
[WIFI-10581] Fix: securityContext fsGroup in helm
2022-10-03 15:54:01 +03:00
TIP Automation User
693814de1c Chg: update image tag in helm values to v2.7.0-RC5 2022-10-03 11:14:26 +00:00
Dmitry Dunaev
0394369410 Merge pull request #71 from Telecominfraproject/main
[WIFI-10581] Add: postgresql-client in Dockerfile
2022-10-03 14:06:07 +03:00
Stephane Bourque
0b6d68def5 Merge pull request #69 from Telecominfraproject/main
https://telecominfraproject.atlassian.net/browse/WIFI-10942
2022-10-02 11:30:41 -07:00
179 changed files with 9084 additions and 10853 deletions

View File

@@ -27,7 +27,7 @@ jobs:
DOCKER_REGISTRY_USERNAME: ucentral
steps:
- name: Checkout actions repo
uses: actions/checkout@v3
uses: actions/checkout@v2
with:
repository: Telecominfraproject/.github
path: github
@@ -58,11 +58,11 @@ jobs:
- name: Get base branch name and set as output
id: get_base_branch
run: |
echo "branch=$(echo ${GITHUB_BASE_REF##*/})" >> $GITHUB_OUTPUT
echo "owgw_branch=$(echo ${GITHUB_BASE_REF##*/} | sed 's/main/master/g')" >> $GITHUB_OUTPUT
echo ::set-output name=branch::$(echo ${GITHUB_BASE_REF##*/})
echo ::set-output name=owgw_branch::$(echo ${GITHUB_BASE_REF##*/} | sed 's/main/master/g')
- name: Checkout actions repo
uses: actions/checkout@v3
uses: actions/checkout@v2
with:
repository: Telecominfraproject/.github
path: github

View File

@@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout actions repo
uses: actions/checkout@v3
uses: actions/checkout@v2
with:
repository: Telecominfraproject/.github
path: github

View File

@@ -1,41 +0,0 @@
name: Update OpenAPI docs on GitHub Pages
on:
push:
paths:
- 'openapi/**'
branches:
- main
workflow_dispatch:
defaults:
run:
shell: bash
jobs:
docsgen:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Generate static HTML page with docs from OpenAPI definition
run: |
docker run --rm -v "${PWD}:/local" openapitools/openapi-generator-cli:v6.2.1 generate -i https://raw.githubusercontent.com/Telecominfraproject/wlan-cloud-owprov/main/openapi/owprov.yaml -g html2 --skip-validate-spec -o /local/
- name: Update OpenAPI docs
run: |
mkdir tmp-docs
mv index.html tmp-docs/index.html
mkdir -p ~/.ssh
ssh-keyscan -H github.com >> ~/.ssh/known_hosts
echo https://tip-automation:${{ secrets.GIT_PUSH_PAT }}@github.com > ~/.git-credentials
git config --global credential.helper store
git config --global user.email "tip-automation@telecominfraproject.com"
git config --global user.name "TIP Automation User"
git pull
git checkout gh-pages || git checkout -b gh-pages
rm -rf docs
mv tmp-docs docs
git add docs
git commit -m'Update OpenAPI docs for GitHub pages'
git push --set-upstream origin gh-pages

View File

@@ -17,7 +17,7 @@ jobs:
HELM_REPO_USERNAME: ucentral
steps:
- name: Checkout uCentral assembly chart repo
uses: actions/checkout@v3
uses: actions/checkout@v2
with:
path: wlan-cloud-owprov

View File

@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.13)
project(owprov VERSION 2.8.0)
project(owprov VERSION 2.7.0)
set(CMAKE_CXX_STANDARD 17)
@@ -27,12 +27,12 @@ endif()
find_package(Git QUIET)
if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
execute_process(COMMAND ${GIT_EXECUTABLE} describe --always --tags
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
RESULT_VARIABLE GIT_RESULT
OUTPUT_VARIABLE GIT_HASH)
if(NOT GIT_RESULT EQUAL "0")
message(FATAL_ERROR "git rev-parse --short HEAD failed with ${GIT_RESULT}")
message(FATAL_ERROR "git describe --always --tags failed with ${GIT_RESULT}")
endif()
string(REGEX REPLACE "\n$" "" GIT_HASH "${GIT_HASH}")
endif()
@@ -40,7 +40,6 @@ endif()
add_definitions(-DAWS_CUSTOM_MEMORY_MANAGEMENT)
find_package(OpenSSL REQUIRED)
find_package(ZLIB REQUIRED)
find_package(Poco REQUIRED COMPONENTS Crypto JWT Net Util NetSSL Data DataSQLite)
find_package(nlohmann_json REQUIRED)
find_package(nlohmann_json_schema_validator REQUIRED)
@@ -76,58 +75,16 @@ add_executable(owprov
src/framework/OpenWifiTypes.h
src/framework/orm.h
src/framework/StorageClass.h
src/framework/MicroServiceErrorHandler.h
src/framework/UI_WebSocketClientServer.cpp
src/framework/UI_WebSocketClientServer.h
src/framework/utils.h
src/framework/utils.cpp
src/framework/AppServiceRegistry.h
src/framework/SubSystemServer.cpp
src/framework/SubSystemServer.h
src/framework/RESTAPI_utils.h
src/framework/UI_WebSocketClientNotifications.cpp
src/framework/AuthClient.cpp
src/framework/AuthClient.h
src/framework/MicroServiceNames.h
src/framework/MicroServiceFuncs.h
src/framework/OpenAPIRequests.cpp
src/framework/OpenAPIRequests.h
src/framework/MicroServiceFuncs.cpp
src/framework/ALBserver.cpp
src/framework/ALBserver.h
src/framework/KafkaManager.cpp
src/framework/KafkaManager.h
src/framework/RESTAPI_RateLimiter.h
src/framework/WebSocketLogger.h
src/framework/RESTAPI_GenericServerAccounting.h
src/framework/CIDR.h
src/framework/RESTAPI_Handler.cpp
src/framework/RESTAPI_Handler.h
src/framework/RESTAPI_ExtServer.h
src/framework/RESTAPI_ExtServer.cpp
src/framework/RESTAPI_IntServer.cpp
src/framework/RESTAPI_IntServer.h
src/framework/RESTAPI_SystemCommand.h
src/framework/RESTAPI_WebSocketServer.h
src/framework/RESTAPI_SystemConfiguration.h
src/framework/EventBusManager.cpp
src/framework/EventBusManager.h
src/framework/RESTAPI_PartHandler.h
src/framework/MicroService.cpp
src/framework/MicroServiceExtra.h
src/framework/ConfigurationValidator.cpp
src/framework/ConfigurationValidator.h
src/UI_Prov_WebSocketNotifications.h
src/UI_Prov_WebSocketNotifications.cpp
src/framework/ow_constants.h
src/framework/MicroServiceErrorHandler.h
src/framework/WebSocketClientNotifications.h
src/framework/MicroServiceErrorHandler.h
src/RESTObjects/RESTAPI_SecurityObjects.h src/RESTObjects/RESTAPI_SecurityObjects.cpp
src/RESTObjects/RESTAPI_ProvObjects.cpp src/RESTObjects/RESTAPI_ProvObjects.h
src/RESTObjects/RESTAPI_GWobjects.h src/RESTObjects/RESTAPI_GWobjects.cpp
src/RESTObjects/RESTAPI_FMSObjects.h src/RESTObjects/RESTAPI_FMSObjects.cpp
src/RESTObjects/RESTAPI_CertObjects.cpp src/RESTObjects/RESTAPI_CertObjects.h
src/RESTObjects/RESTAPI_OWLSobjects.cpp src/RESTObjects/RESTAPI_OWLSobjects.h
src/RESTObjects/RESTAPI_ProvObjects.cpp src/RESTObjects/RESTAPI_ProvObjects.h
src/RESTObjects/RESTAPI_AnalyticsObjects.cpp src/RESTObjects/RESTAPI_AnalyticsObjects.h
src/RESTObjects/RESTAPI_SubObjects.cpp src/RESTObjects/RESTAPI_SubObjects.h
src/RESTAPI/RESTAPI_routers.cpp
src/Daemon.cpp src/Daemon.h
src/Dashboard.h src/Dashboard.cpp
@@ -188,22 +145,7 @@ add_executable(owprov
src/storage/storage_operataor.cpp src/storage/storage_operataor.h
src/storage/storage_sub_devices.cpp src/storage/storage_sub_devices.h
src/storage/storage_service_class.cpp src/storage/storage_service_class.h
src/RESTAPI/RESTAPI_sub_devices_list_handler.cpp src/RESTAPI/RESTAPI_sub_devices_list_handler.h
src/RESTAPI/RESTAPI_sub_devices_handler.cpp src/RESTAPI/RESTAPI_sub_devices_handler.h
src/RESTAPI/RESTAPI_service_class_list_handler.cpp src/RESTAPI/RESTAPI_service_class_list_handler.h
src/RESTAPI/RESTAPI_service_class_handler.cpp src/RESTAPI/RESTAPI_service_class_handler.h
src/RESTAPI/RESTAPI_operators_list_handler.cpp src/RESTAPI/RESTAPI_operators_list_handler.h
src/RESTAPI/RESTAPI_operators_handler.cpp src/RESTAPI/RESTAPI_operators_handler.h
src/storage/storage_op_contacts.cpp src/storage/storage_op_contacts.h
src/storage/storage_op_locations.cpp src/storage/storage_op_locations.h
src/RESTAPI/RESTAPI_op_contact_list_handler.cpp src/RESTAPI/RESTAPI_op_contact_list_handler.h
src/RESTAPI/RESTAPI_op_contact_handler.cpp src/RESTAPI/RESTAPI_op_contact_handler.h
src/RESTAPI/RESTAPI_op_location_list_handler.cpp src/RESTAPI/RESTAPI_op_location_list_handler.h
src/RESTAPI/RESTAPI_op_location_handler.cpp src/RESTAPI/RESTAPI_op_location_handler.h
src/ProvWebSocketClient.cpp src/ProvWebSocketClient.h
src/Tasks/VenueRebooter.h src/Tasks/VenueUpgrade.h
src/sdks/SDK_fms.cpp src/sdks/SDK_fms.h
src/storage/storage_overrides.cpp src/storage/storage_overrides.h src/RESTAPI/RESTAPI_overrides_handler.cpp src/RESTAPI/RESTAPI_overrides_handler.h)
src/RESTAPI/RESTAPI_sub_devices_list_handler.cpp src/RESTAPI/RESTAPI_sub_devices_list_handler.h src/RESTAPI/RESTAPI_sub_devices_handler.cpp src/RESTAPI/RESTAPI_sub_devices_handler.h src/RESTAPI/RESTAPI_service_class_list_handler.cpp src/RESTAPI/RESTAPI_service_class_list_handler.h src/RESTAPI/RESTAPI_service_class_handler.cpp src/RESTAPI/RESTAPI_service_class_handler.h src/RESTAPI/RESTAPI_operators_list_handler.cpp src/RESTAPI/RESTAPI_operators_list_handler.h src/RESTAPI/RESTAPI_operators_handler.cpp src/RESTAPI/RESTAPI_operators_handler.h src/storage/storage_op_contacts.cpp src/storage/storage_op_contacts.h src/storage/storage_op_locations.cpp src/storage/storage_op_locations.h src/RESTAPI/RESTAPI_op_contact_list_handler.cpp src/RESTAPI/RESTAPI_op_contact_list_handler.h src/RESTAPI/RESTAPI_op_contact_handler.cpp src/RESTAPI/RESTAPI_op_contact_handler.h src/RESTAPI/RESTAPI_op_location_list_handler.cpp src/RESTAPI/RESTAPI_op_location_list_handler.h src/RESTAPI/RESTAPI_op_location_handler.cpp src/RESTAPI/RESTAPI_op_location_handler.h src/ProvWebSocketClient.cpp src/ProvWebSocketClient.h src/Tasks/VenueRebooter.h src/Tasks/VenueUpgrade.h src/sdks/SDK_fms.cpp src/sdks/SDK_fms.h)
target_link_libraries(owprov PUBLIC
${Poco_LIBRARIES}

View File

@@ -1,5 +1,6 @@
ARG DEBIAN_VERSION=11.5-slim
ARG POCO_VERSION=poco-tip-v2
ARG DEBIAN_VERSION=11.4-slim
ARG POCO_VERSION=poco-tip-v1
ARG FMTLIB_VERSION=9.0.0
ARG CPPKAFKA_VERSION=tip-v1
ARG JSON_VALIDATOR_VERSION=2.1.0
@@ -9,7 +10,7 @@ RUN apt-get update && apt-get install --no-install-recommends -y \
make cmake g++ git \
libpq-dev libmariadb-dev libmariadbclient-dev-compat \
librdkafka-dev libboost-all-dev libssl-dev \
zlib1g-dev nlohmann-json3-dev ca-certificates libcurl4-openssl-dev libfmt-dev
zlib1g-dev nlohmann-json3-dev ca-certificates libcurl4-openssl-dev
FROM build-base AS poco-build
@@ -25,6 +26,20 @@ RUN cmake ..
RUN cmake --build . --config Release -j8
RUN cmake --build . --target install
FROM build-base AS fmtlib-build
ARG FMTLIB_VERSION
ADD https://api.github.com/repos/fmtlib/fmt/git/refs/tags/${FMTLIB_VERSION} version.json
RUN git clone https://github.com/fmtlib/fmt --branch ${FMTLIB_VERSION} /fmtlib
WORKDIR /fmtlib
RUN mkdir cmake-build
WORKDIR cmake-build
RUN cmake ..
RUN make
RUN make install
FROM build-base AS cppkafka-build
ARG CPPKAFKA_VERSION
@@ -66,6 +81,8 @@ COPY --from=cppkafka-build /usr/local/include /usr/local/include
COPY --from=cppkafka-build /usr/local/lib /usr/local/lib
COPY --from=json-schema-validator-build /usr/local/include /usr/local/include
COPY --from=json-schema-validator-build /usr/local/lib /usr/local/lib
COPY --from=fmtlib-build /usr/local/include /usr/local/include
COPY --from=fmtlib-build /usr/local/lib /usr/local/lib
WORKDIR /owprov
RUN mkdir cmake-build
@@ -87,7 +104,7 @@ RUN mkdir -p "$OWPROV_ROOT" "$OWPROV_CONFIG" && \
RUN apt-get update && apt-get install --no-install-recommends -y \
librdkafka++1 gosu gettext ca-certificates bash jq curl wget \
libmariadb-dev-compat libpq5 postgresql-client libfmt7
libmariadb-dev-compat libpq5 unixodbc postgresql-client
COPY readiness_check /readiness_check
COPY test_scripts/curl/cli /cli
@@ -99,8 +116,8 @@ RUN wget https://raw.githubusercontent.com/Telecominfraproject/wlan-cloud-ucentr
-O /usr/local/share/ca-certificates/restapi-ca-selfsigned.crt
COPY --from=owprov-build /owprov/cmake-build/owprov /openwifi/owprov
COPY --from=cppkafka-build /cppkafka/cmake-build/src/lib/* /usr/local/lib/
COPY --from=poco-build /poco/cmake-build/lib/* /usr/local/lib/
COPY --from=cppkafka-build /cppkafka/cmake-build/src/lib/* /usr/local/lib
COPY --from=poco-build /poco/cmake-build/lib/* /usr/local/lib
RUN ldconfig

View File

@@ -1,10 +1,5 @@
# OpenWiFi Provisioning
## OpenAPI
You may get static page with OpenAPI docs generated from the definition on [GitHub Page](https://telecominfraproject.github.io/wlan-cloud-owprov/).
Also you may use [Swagger UI](https://petstore.swagger.io/#/) with OpenAPI definition file raw link (i.e. [latest version file](https://raw.githubusercontent.com/Telecominfraproject/wlan-cloud-owprov/main/openapi/owprov.yaml)) to get interactive docs page.
## Build from source.
You need:
- https://github.com/pboettch/json-schema-validator.git
@@ -71,4 +66,4 @@ firmware.updater.releaseonly = <true/false>
Should FMS attempt to upgrade devices by default.
### firmware.updater.releaseonly
Should only RC software be used during upgrades.
Should only RC software be used during upgrades.

2
build
View File

@@ -1 +1 @@
34
28

View File

@@ -9,7 +9,7 @@ fullnameOverride: ""
images:
owprov:
repository: tip-tip-wlan-cloud-ucentral.jfrog.io/owprov
tag: v2.8.0
tag: v2.7.0-RC6
pullPolicy: Always
# regcred:
# registry: tip-tip-wlan-cloud-ucentral.jfrog.io

View File

@@ -1220,40 +1220,6 @@ components:
items:
$ref: '#/components/schemas/SubscriberDevice'
ConfigurationOverride:
type: object
properties:
source:
type: string
reason:
type: string
parameterName:
type: string
parameterType:
enum:
- string
- integer
- boolean
parameterValue:
type: string
modified:
type: integer
format: int64
ConfigurationOverrideList:
type: object
properties:
serialNumber:
type: string
managementPolicy:
type: string
format: uuid
overrides:
type: array
items:
$ref: '#/components/schemas/ConfigurationOverride'
#########################################################################################
##
## These are endpoints that all services in the OPenWiFI stack must provide
@@ -2245,94 +2211,6 @@ paths:
404:
$ref: '#/components/responses/NotFound'
/configurationOverrides/{serialNumber}:
get:
tags:
- Configuration Overrides
operationId: getCponfigurationOverrides
summary: retrieve a list of configuration overrides for a given device
parameters:
- in: path
name: serialNumber
schema:
type: string
required: true
responses:
200:
description: Return a list of configuration overrides.
content:
application/json:
schema:
$ref: '#/components/schemas/ConfigurationOverrideList'
400:
$ref: '#/components/responses/BadRequest'
403:
$ref: '#/components/responses/Unauthorized'
404:
$ref: '#/components/responses/NotFound'
delete:
tags:
- Configuration Overrides
operationId: deleteCponfigurationOverrides
summary: delete all configuration overrides for a given device from a given source
parameters:
- in: path
name: serialNumber
schema:
type: string
required: true
- in: query
name: source
schema:
type: string
required: true
responses:
200:
$ref: '#/components/responses/Success'
400:
$ref: '#/components/responses/BadRequest'
403:
$ref: '#/components/responses/Unauthorized'
404:
$ref: '#/components/responses/NotFound'
put:
tags:
- Configuration Overrides
operationId: modifyConfigurationOverrides
summary: modify configuration overrides for a given device for a given source
parameters:
- in: path
name: serialNumber
schema:
type: string
required: true
- in: query
name: source
schema:
type: string
required: true
requestBody:
description: Information used to modify the override list
content:
application/json:
schema:
$ref: '#/components/schemas/ConfigurationOverrideList'
responses:
200:
description: Return the modified configuration overrides.
content:
application/json:
schema:
$ref: '#/components/schemas/ConfigurationOverrideList'
400:
$ref: '#/components/responses/BadRequest'
403:
$ref: '#/components/responses/Unauthorized'
404:
$ref: '#/components/responses/NotFound'
/venue:
get:
tags:

View File

@@ -5,10 +5,6 @@
#include "APConfig.h"
#include "StorageService.h"
#include "Poco/JSON/Parser.h"
#include "Poco/StringTokenizer.h"
#include "fmt/format.h"
namespace OpenWifi {
APConfig::APConfig(const std::string &SerialNumber, const std::string &DeviceType, Poco::Logger &L, bool Explain)
@@ -135,10 +131,7 @@ namespace OpenWifi {
ProvObjects::InventoryTag D;
if (StorageService()->InventoryDB().GetRecord("serialNumber", SerialNumber_, D)) {
if (!D.deviceConfiguration.empty()) {
std::cout << "Adding device specific configuration: " << D.deviceConfiguration.size() << std::endl;
AddConfiguration(D.deviceConfiguration);
} else {
std::cout << "No device specific configuration." << std::endl;
}
if (!D.entity.empty()) {
AddEntityConfig(D.entity);
@@ -212,65 +205,6 @@ namespace OpenWifi {
}
}
}
// Apply overrides...
ProvObjects::ConfigurationOverrideList COL;
if(StorageService()->OverridesDB().GetRecord("serialNumber", SerialNumber_, COL)) {
for (const auto &col: COL.overrides) {
const auto Tokens = Poco::StringTokenizer(col.parameterName, ".");
if (Tokens[0] == "radios" && Tokens.count() == 3) {
std::uint64_t RadioIndex = std::strtoull(Tokens[1].c_str(), nullptr, 10);
if (RadioIndex < MaximumPossibleRadios) {
auto RadioArray = Configuration->getArray("radios");
if (RadioIndex < RadioArray->size()) {
auto IndexedRadio = RadioArray->get(RadioIndex).extract<Poco::JSON::Object::Ptr>();
if (Tokens[2] == "tx-power") {
IndexedRadio->set("rx-power",
std::strtoull(col.parameterValue.c_str(), nullptr, 10));
if (Explain_) {
Poco::JSON::Object ExObj;
ExObj.set("from-name", "overrides");
ExObj.set("override", col.parameterName);
ExObj.set("source", col.source);
ExObj.set("reason", col.reason);
ExObj.set("value", col.parameterValue);
Explanation_.add(ExObj);
}
RadioArray->set(RadioIndex, IndexedRadio);
Configuration->set("radios", RadioArray);
} else if (Tokens[2] == "channel") {
if(col.parameterValue=="auto") {
IndexedRadio->set("channel", "auto");
} else {
IndexedRadio->set("channel",
std::strtoull(col.parameterValue.c_str(), nullptr, 10));
}
std::cout << "Setting channel in radio " << RadioIndex << std::endl;
if (Explain_) {
Poco::JSON::Object ExObj;
ExObj.set("from-name", "overrides");
ExObj.set("override", col.parameterName);
ExObj.set("source", col.source);
ExObj.set("reason", col.reason);
ExObj.set("value", col.parameterValue);
Explanation_.add(ExObj);
}
RadioArray->set(RadioIndex, IndexedRadio);
Configuration->set("radios", RadioArray);
} else {
poco_error(Logger(), fmt::format("{}: Unsupported override variable name {}",
col.parameterName));
}
}
} else {
poco_error(Logger(), fmt::format("{}: radio index out of range in {}", col.parameterName));
}
} else {
poco_error(Logger(),
fmt::format("{}: Unsupported override variable name {}", col.parameterName));
}
}
}
} catch (...) {
}
@@ -335,11 +269,7 @@ namespace OpenWifi {
ExObj.set("reason", "deviceType mismatch");
Explanation_.add(ExObj);
}
} else {
poco_error(Logger(),fmt::format("Device configuration for {} is empty.", SerialNumber_));
}
} else {
poco_error(Logger(),fmt::format("Invalid device configuration UUID for {}.", SerialNumber_));
}
}

View File

@@ -10,8 +10,6 @@
namespace OpenWifi {
constexpr std::uint64_t MaximumPossibleRadios=6;
struct VerboseElement {
ProvObjects::DeviceConfigurationElement element;
ProvObjects::ObjectInfo info;

View File

@@ -5,14 +5,11 @@
#include "AutoDiscovery.h"
#include "framework/ow_constants.h"
#include "framework/KafkaTopics.h"
#include "framework/KafkaManager.h"
#include "StorageService.h"
#include "Poco/JSON/Parser.h"
namespace OpenWifi {
int AutoDiscovery::Start() {
poco_information(Logger(),"Starting...");
Running_ = true;
Types::TopicNotifyFunction F = [this](const std::string &Key, const std::string &Payload) { this->ConnectionReceived(Key,Payload); };
ConnectionWatcherId_ = KafkaManager()->RegisterTopicWatcher(KafkaTopics::CONNECTION, F);
@@ -21,12 +18,10 @@ namespace OpenWifi {
};
void AutoDiscovery::Stop() {
poco_information(Logger(),"Stopping...");
Running_ = false;
KafkaManager()->UnregisterTopicWatcher(KafkaTopics::CONNECTION, ConnectionWatcherId_);
Queue_.wakeUpAll();
Worker_.join();
poco_information(Logger(),"Stopped...");
};
void AutoDiscovery::run() {

View File

@@ -4,11 +4,8 @@
#pragma once
#include "framework/MicroService.h"
#include "framework/OpenWifiTypes.h"
#include "framework/SubSystemServer.h"
#include "Poco/NotificationQueue.h"
#include "Poco/Notification.h"
namespace OpenWifi {
@@ -36,7 +33,7 @@ namespace OpenWifi {
void Stop() override;
void ConnectionReceived( const std::string & Key, const std::string & Payload) {
std::lock_guard G(Mutex_);
poco_trace(Logger(),Poco::format("Device(%s): Connection/Ping message.", Key));
poco_debug(Logger(),Poco::format("Device(%s): Connection/Ping message.", Key));
Queue_.enqueueNotification( new DiscoveryMessage(Key,Payload));
}
void run() override;

View File

@@ -9,7 +9,6 @@
#include "Poco/Util/Application.h"
#include "Poco/Util/Option.h"
#include "Poco/Environment.h"
#include "Poco/Net/SSLManager.h"
#include "Daemon.h"
#include "StorageService.h"
@@ -21,8 +20,6 @@
#include "Signup.h"
#include "DeviceTypeCache.h"
#include "FileDownloader.h"
#include "framework/UI_WebSocketClientServer.h"
#include "UI_Prov_WebSocketNotifications.h"
namespace OpenWifi {
class Daemon *Daemon::instance_ = nullptr;
@@ -41,7 +38,7 @@ namespace OpenWifi {
SerialNumberCache(),
AutoDiscovery(),
JobController(),
UI_WebSocketClientServer(),
WebSocketClientServer(),
FindCountryFromIP(),
Signup(),
FileDownloader()
@@ -73,12 +70,6 @@ namespace OpenWifi {
}
}
}
void DaemonPostInitialization(Poco::Util::Application &self) {
Daemon()->PostInitialization(self);
ProvWebSocketNotifications::Register();
}
}
int main(int argc, char **argv) {

View File

@@ -16,7 +16,6 @@
#include "Dashboard.h"
#include "framework/MicroService.h"
#include "framework/MicroServiceNames.h"
#include "framework/OpenWifiTypes.h"
#include "RESTObjects/RESTAPI_ProvObjects.h"
#include "ProvWebSocketClient.h"
@@ -55,6 +54,8 @@ namespace OpenWifi {
};
inline Daemon * Daemon() { return Daemon::instance(); }
void DaemonPostInitialization(Poco::Util::Application &self);
inline void DaemonPostInitialization(Poco::Util::Application &self) {
Daemon()->PostInitialization(self);
}
}

View File

@@ -6,11 +6,11 @@
// Arilia Wireless Inc.
//
#include "Dashboard.h"
#include "framework/utils.h"
#include "StorageService.h"
namespace OpenWifi {
void ProvisioningDashboard::Create() {
uint64_t Now = Utils::Now();
uint64_t Now = OpenWifi::Now();
if(LastRun_==0 || (Now-LastRun_)>120) {
DB_.reset();
// Todo: call dashboard creation code.

View File

@@ -6,11 +6,7 @@
#include <set>
#include "framework/SubSystemServer.h"
#include "framework/AppServiceRegistry.h"
#include "framework/OpenAPIRequests.h"
#include "framework/MicroServiceNames.h"
#include "framework/MicroService.h"
#include "Poco/Timer.h"
namespace OpenWifi {

View File

@@ -7,7 +7,6 @@
namespace OpenWifi {
int FileDownloader::Start() {
poco_information(Logger(),"Starting...");
TimerCallback_ = std::make_unique<Poco::TimerCallback<FileDownloader>>(*this,&FileDownloader::onTimer);
Timer_.setStartInterval( 20 * 1000); // first run in 20 seconds
Timer_.setPeriodicInterval(2 * 60 * 60 * 1000); // 1 hours
@@ -16,9 +15,8 @@ namespace OpenWifi {
}
void FileDownloader::Stop() {
poco_information(Logger(),"Stopping...");
Timer_.stop();
poco_information(Logger(),"Stopped...");
Logger().notice("Stopping.");
}
void FileDownloader::onTimer([[maybe_unused]] Poco::Timer &timer) {

View File

@@ -3,7 +3,7 @@
//
#pragma once
#include "framework/SubSystemServer.h"
#include "framework/MicroService.h"
#include "Poco/Timer.h"
namespace OpenWifi {

View File

@@ -4,11 +4,8 @@
#pragma once
#include "framework/MicroService.h"
#include "Poco/Net/IPAddress.h"
#include "framework/SubSystemServer.h"
#include "framework/MicroServiceFuncs.h"
#include "nlohmann/json.hpp"
namespace OpenWifi {
@@ -26,7 +23,7 @@ namespace OpenWifi {
public:
static std::string Name() { return "ipinfo"; }
inline bool Init() override {
Key_ = MicroServiceConfigGetString("iptocountry.ipinfo.token", "");
Key_ = MicroService::instance().ConfigGetString("iptocountry.ipinfo.token", "");
return !Key_.empty();
}
@@ -58,7 +55,7 @@ namespace OpenWifi {
public:
static std::string Name() { return "ipdata"; }
inline bool Init() override {
Key_ = MicroServiceConfigGetString("iptocountry.ipdata.apikey", "");
Key_ = MicroService::instance().ConfigGetString("iptocountry.ipdata.apikey", "");
return !Key_.empty();
}
@@ -88,7 +85,7 @@ namespace OpenWifi {
public:
static std::string Name() { return "ip2location"; }
inline bool Init() override {
Key_ = MicroServiceConfigGetString("iptocountry.ip2location.apikey", "");
Key_ = MicroService::instance().ConfigGetString("iptocountry.ip2location.apikey", "");
return !Key_.empty();
}
@@ -136,22 +133,18 @@ namespace OpenWifi {
}
inline int Start() final {
poco_notice(Logger(),"Starting...");
ProviderName_ = MicroServiceConfigGetString("iptocountry.provider","");
ProviderName_ = MicroService::instance().ConfigGetString("iptocountry.provider","");
if(!ProviderName_.empty()) {
Provider_ = IPLocationProvider<IPToCountryProvider, IPInfo, IPData, IP2Location>(ProviderName_);
if(Provider_!= nullptr) {
Enabled_ = Provider_->Init();
}
}
Default_ = MicroServiceConfigGetString("iptocountry.default", "US");
Default_ = MicroService::instance().ConfigGetString("iptocountry.default", "US");
return 0;
}
inline void Stop() final {
poco_notice(Logger(),"Stopping...");
// Nothing to do - just to provide the same look at the others.
poco_notice(Logger(),"Stopped...");
}
[[nodiscard]] static inline std::string ReformatAddress(const std::string & I )

View File

@@ -3,16 +3,15 @@
//
#include "JobController.h"
#include "framework/utils.h"
#include "fmt/format.h"
namespace OpenWifi {
void RegisterJobTypes();
int JobController::Start() {
poco_information(Logger(),"Starting...");
RegisterJobTypes();
if(!Running_)
Thr_.start(*this);
@@ -21,10 +20,8 @@ namespace OpenWifi {
void JobController::Stop() {
if(Running_) {
poco_information(Logger(),"Stopping...");
Running_ = false;
Thr_.join();
poco_information(Logger(),"Stopped...");
}
}
@@ -39,7 +36,7 @@ namespace OpenWifi {
for(auto &current_job:jobs_) {
if(current_job!=nullptr) {
if(current_job->Started()==0 && Pool_.used()<Pool_.available()) {
poco_information(current_job->Logger(),fmt::format("Starting {}: {}",current_job->JobId(),current_job->Name()));
current_job->Logger().information(fmt::format("Starting {}: {}",current_job->JobId(),current_job->Name()));
current_job->Start();
Pool_.start(*current_job);
}
@@ -49,7 +46,7 @@ namespace OpenWifi {
for(auto it = jobs_.begin(); it!=jobs_.end();) {\
auto current_job = *it;
if(current_job!=nullptr && current_job->Completed()!=0) {
poco_information(current_job->Logger(),fmt::format("Completed {}: {}",current_job->JobId(),current_job->Name()));
current_job->Logger().information(fmt::format("Completed {}: {}",current_job->JobId(),current_job->Name()));
it = jobs_.erase(it);
delete current_job;
} else {

View File

@@ -8,9 +8,7 @@
#include <utility>
#include <functional>
#include <list>
#include "framework/SubSystemServer.h"
#include "RESTObjects/RESTAPI_SecurityObjects.h"
#include "framework/utils.h"
#include "framework/MicroService.h"
namespace OpenWifi {
@@ -32,10 +30,10 @@ namespace OpenWifi {
const std::string & JobId() const { return jobId_; }
const std::string & Parameter(int x) const { return parameters_[x];}
uint64_t When() const { return when_; }
void Start() { started_ = Utils::Now(); }
void Start() { started_ = OpenWifi::Now(); }
uint64_t Started() const { return started_; }
uint64_t Completed() const { return completed_;}
void Complete() { completed_ = Utils::Now(); }
void Complete() { completed_ = OpenWifi::Now(); }
private:
std::string jobId_;

View File

@@ -4,8 +4,7 @@
#pragma once
#include "framework/KafkaTopics.h"
#include "framework/KafkaManager.h"
#include "framework/MicroService.h"
#include "RESTObjects/RESTAPI_ProvObjects.h"
namespace OpenWifi {

View File

@@ -7,17 +7,16 @@
#include "StorageService.h"
#include "SerialNumberCache.h"
#include "sdks/SDK_sec.h"
#include "framework/UI_WebSocketClientServer.h"
namespace OpenWifi {
ProvWebSocketClient::ProvWebSocketClient(Poco::Logger &Logger) :
Logger_(Logger){
UI_WebSocketClientServer()->SetProcessor(this);
WebSocketClientServer()->SetProcessor(this);
}
ProvWebSocketClient::~ProvWebSocketClient() {
UI_WebSocketClientServer()->SetProcessor(nullptr);
WebSocketClientServer()->SetProcessor(nullptr);
}
void ProvWebSocketClient::ws_command_serial_number_search(const Poco::JSON::Object::Ptr &O,
@@ -118,11 +117,11 @@ namespace OpenWifi {
auto Command = O->get("command").toString();
if (Command == "serial_number_search" && O->has("serial_prefix")) {
ws_command_serial_number_search(O,Done,Answer);
} else if (UI_WebSocketClientServer()->GeoCodeEnabled() && Command == "address_completion" && O->has("address")) {
} else if (WebSocketClientServer()->GeoCodeEnabled() && Command == "address_completion" && O->has("address")) {
ws_command_address_completion(O,Done,Answer);
} else if (UI_WebSocketClientServer()->GeoCodeEnabled() && Command == "subuser_search" && O->has("operatorId")) {
} else if (WebSocketClientServer()->GeoCodeEnabled() && Command == "subuser_search" && O->has("operatorId")) {
ws_command_subuser_search(O,Done,Answer);
} else if (UI_WebSocketClientServer()->GeoCodeEnabled() && Command == "subdevice_search" && O->has("operatorId") && O->has("serial_prefix")) {
} else if (WebSocketClientServer()->GeoCodeEnabled() && Command == "subdevice_search" && O->has("operatorId") && O->has("serial_prefix")) {
ws_command_subdevice_search(O,Done,Answer);
} else if (Command=="exit") {
ws_command_exit(O,Done,Answer);
@@ -143,7 +142,7 @@ namespace OpenWifi {
Poco::URI uri(URI);
uri.addQueryParameter("address",A);
uri.addQueryParameter("key", UI_WebSocketClientServer()->GoogleApiKey());
uri.addQueryParameter("key", WebSocketClientServer()->GoogleApiKey());
Poco::Net::HTTPSClientSession session(uri.getHost(), uri.getPort());
Poco::Net::HTTPRequest req(Poco::Net::HTTPRequest::HTTP_GET, uri.getPathAndQuery(), Poco::Net::HTTPMessage::HTTP_1_1);

View File

@@ -4,11 +4,11 @@
#pragma once
#include "framework/UI_WebSocketClientServer.h"
#include "framework/MicroService.h"
namespace OpenWifi {
class ProvWebSocketClient : public UI_WebSocketClientProcessor {
class ProvWebSocketClient : public WebSocketClientProcessor {
public:
explicit ProvWebSocketClient(Poco::Logger &Logger);
virtual ~ProvWebSocketClient();

View File

@@ -3,13 +3,13 @@
//
#pragma once
#include "framework/RESTAPI_Handler.h"
#include "StorageService.h"
#include "../framework/MicroService.h"
namespace OpenWifi {
class RESTAPI_asset_server : public RESTAPIHandler {
public:
RESTAPI_asset_server(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting &Server, uint64_t TransactionId, bool Internal)
RESTAPI_asset_server(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer &Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L,
std::vector<std::string>
{

View File

@@ -6,6 +6,8 @@
// Arilia Wireless Inc.
//
#include "framework/MicroService.h"
#include "RESTAPI_configurations_handler.h"
#include "RESTObjects/RESTAPI_ProvObjects.h"
#include "StorageService.h"

View File

@@ -5,15 +5,16 @@
// Created by Stephane Bourque on 2021-03-04.
// Arilia Wireless Inc.
//
#pragma once
#include "framework/RESTAPI_Handler.h"
#include "framework/MicroService.h"
#include "RESTObjects/RESTAPI_ProvObjects.h"
#include "StorageService.h"
namespace OpenWifi {
class RESTAPI_configurations_handler : public RESTAPIHandler {
public:
RESTAPI_configurations_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
RESTAPI_configurations_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L,
std::vector<std::string>{
Poco::Net::HTTPRequest::HTTP_GET, Poco::Net::HTTPRequest::HTTP_POST,

View File

@@ -3,14 +3,15 @@
//
#pragma once
#include "framework/RESTAPI_Handler.h"
#include "framework/MicroService.h"
#include "StorageService.h"
namespace OpenWifi {
class RESTAPI_configurations_list_handler : public RESTAPIHandler {
public:
RESTAPI_configurations_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
RESTAPI_configurations_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L,
std::vector<std::string>{
Poco::Net::HTTPRequest::HTTP_GET,

View File

@@ -7,13 +7,14 @@
//
#pragma once
#include "framework/RESTAPI_Handler.h"
#include "framework/MicroService.h"
#include "StorageService.h"
namespace OpenWifi {
class RESTAPI_contact_handler : public RESTAPIHandler {
public:
RESTAPI_contact_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
RESTAPI_contact_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L,
std::vector<std::string>{
Poco::Net::HTTPRequest::HTTP_GET, Poco::Net::HTTPRequest::HTTP_POST,

View File

@@ -3,14 +3,16 @@
//
#pragma once
#include "framework/RESTAPI_Handler.h"
#include "framework/MicroService.h"
#include "RESTObjects/RESTAPI_ProvObjects.h"
#include "StorageService.h"
namespace OpenWifi {
class RESTAPI_contact_list_handler : public RESTAPIHandler {
public:
RESTAPI_contact_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
RESTAPI_contact_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L,
std::vector<std::string>{
Poco::Net::HTTPRequest::HTTP_GET,

View File

@@ -6,6 +6,7 @@
#include "RESTObjects/RESTAPI_ProvObjects.h"
#include "StorageService.h"
#include "framework/MicroService.h"
#include "framework/ConfigurationValidator.h"
#include "sdks/SDK_sec.h"
#include "Poco/StringTokenizer.h"

View File

@@ -14,8 +14,6 @@
#include "StorageService.h"
#include "RESTAPI_db_helpers.h"
#include "framework/CIDR.h"
namespace OpenWifi{
void RESTAPI_entity_handler::DoGet() {
@@ -80,7 +78,7 @@ namespace OpenWifi{
// When creating an entity, it cannot have any relations other that parent, notes, name, description. Everything else
// must be conveyed through PUT.
NewEntity.info.id = (UUID==EntityDB::RootUUID()) ? UUID : MicroServiceCreateUUID();
NewEntity.info.id = (UUID==EntityDB::RootUUID()) ? UUID : MicroService::CreateUUID();
if(UUID==EntityDB::RootUUID()) {
NewEntity.parent="";

View File

@@ -7,13 +7,14 @@
//
#pragma once
#include "framework/RESTAPI_Handler.h"
#include "framework/MicroService.h"
#include "StorageService.h"
namespace OpenWifi {
class RESTAPI_entity_handler : public RESTAPIHandler {
public:
RESTAPI_entity_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
RESTAPI_entity_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L,
std::vector<std::string>{
Poco::Net::HTTPRequest::HTTP_GET,

View File

@@ -6,6 +6,7 @@
// Arilia Wireless Inc.
//
#include "framework/MicroService.h"
#include "RESTAPI_entity_list_handler.h"
#include "StorageService.h"
#include "RESTAPI_db_helpers.h"

View File

@@ -8,13 +8,14 @@
#pragma once
#include "framework/RESTAPI_Handler.h"
#include "framework/MicroService.h"
#include "StorageService.h"
namespace OpenWifi {
class RESTAPI_entity_list_handler : public RESTAPIHandler {
public:
RESTAPI_entity_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
RESTAPI_entity_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L,
std::vector<std::string>{
Poco::Net::HTTPRequest::HTTP_GET,

View File

@@ -16,7 +16,6 @@
#include "RESTAPI/RESTAPI_db_helpers.h"
#include "SerialNumberCache.h"
#include "DeviceTypeCache.h"
#include "framework/utils.h"
namespace OpenWifi{
@@ -38,17 +37,17 @@ namespace OpenWifi{
ProvObjects::InventoryTag Existing;
std::string SerialNumber = GetBinding(RESTAPI::Protocol::SERIALNUMBER, "");
poco_debug(Logger(),fmt::format("{}: Retrieving inventory information.", SerialNumber));
Logger().debug(Poco::format("%s: Retrieving inventory information.", SerialNumber));
if (SerialNumber.empty() || !DB_.GetRecord(RESTAPI::Protocol::SERIALNUMBER, SerialNumber, Existing)) {
return NotFound();
}
poco_debug(Logger(), fmt::format("{},{}: Retrieving inventory information.", Existing.serialNumber, Existing.info.id));
Logger().debug(
Poco::format("%s,%s: Retrieving inventory information.", Existing.serialNumber, Existing.info.id));
Poco::JSON::Object Answer;
std::string Arg;
if (GetBoolParameter("config", false)) {
bool Explain = GetBoolParameter("explain", false);
if (HasParameter("config", Arg) && Arg == "true") {
bool Explain = (HasParameter("explain", Arg) && Arg == "true");
APConfig Device(SerialNumber, Existing.deviceType, Logger(), Explain);
auto Configuration = Poco::makeShared<Poco::JSON::Object>();
@@ -83,39 +82,39 @@ namespace OpenWifi{
}
return ReturnObject(Answer);
} else if(GetBoolParameter("applyConfiguration", false)) {
poco_debug(Logger(), fmt::format("{}: Retrieving configuration.",Existing.serialNumber));
Logger().debug(Poco::format("%s: Retrieving configuration.",Existing.serialNumber));
auto Device = std::make_shared<APConfig>(SerialNumber, Existing.deviceType, Logger(), false);
auto Configuration = Poco::makeShared<Poco::JSON::Object>();
Poco::JSON::Object ErrorsObj, WarningsObj;
ProvObjects::InventoryConfigApplyResult Results;
poco_debug(Logger(), fmt::format("{}: Computing configuration.",Existing.serialNumber));
Logger().debug(Poco::format("%s: Computing configuration.",Existing.serialNumber));
if (Device->Get(Configuration)) {
std::ostringstream OS;
Configuration->stringify(OS);
Results.appliedConfiguration = OS.str();
auto Response=Poco::makeShared<Poco::JSON::Object>();
poco_debug(Logger(), fmt::format("{}: Sending configuration push.",Existing.serialNumber));
Logger().debug(Poco::format("%s: Sending configuration push.",Existing.serialNumber));
if (SDK::GW::Device::Configure(this, SerialNumber, Configuration, Response)) {
poco_debug(Logger(), fmt::format("{}: Sending configuration pushed.",Existing.serialNumber));
Logger().debug(Poco::format("%s: Sending configuration pushed.",Existing.serialNumber));
GetRejectedLines(Response, Results.warnings);
Results.errorCode = 0;
} else {
poco_debug(Logger(), fmt::format("{}: Sending configuration failed.",Existing.serialNumber));
Logger().debug(Poco::format("%s: Sending configuration failed.",Existing.serialNumber));
Results.errorCode = 1;
}
} else {
poco_debug(Logger(), fmt::format("{}: Configuration is bad.",Existing.serialNumber));
Logger().debug(Poco::format("%s: Configuration is bad.",Existing.serialNumber));
Results.errorCode = 1;
}
Results.to_json(Answer);
return ReturnObject(Answer);
} else if(GetBoolParameter("resolveConfig", false)) {
poco_debug(Logger(),fmt::format("{}: Retrieving configuration.",Existing.serialNumber));
Logger().debug(Poco::format("%s: Retrieving configuration.",Existing.serialNumber));
auto Device = std::make_shared<APConfig>(SerialNumber, Existing.deviceType, Logger(), false);
auto Configuration = Poco::makeShared<Poco::JSON::Object>();
Poco::JSON::Object ErrorsObj, WarningsObj;
ProvObjects::InventoryConfigApplyResult Results;
poco_debug(Logger(),Poco::format("{}: Computing configuration.",Existing.serialNumber));
Logger().debug(Poco::format("%s: Computing configuration.",Existing.serialNumber));
if (Device->Get(Configuration)) {
Answer.set("configuration", Configuration);
} else {
@@ -279,23 +278,23 @@ namespace OpenWifi{
auto RemoveSubscriber = GetParameter("removeSubscriber");
if(!RemoveSubscriber.empty()) {
if(Existing.subscriber == RemoveSubscriber) {
poco_information(Logger(),fmt::format("{}: removing subscriber ({})", SerialNumber, RemoveSubscriber));
Logger().information(Poco::format("%s: removing subscriber (%s)", SerialNumber, RemoveSubscriber));
ProvObjects::DeviceConfiguration DC;
if(StorageService()->ConfigurationDB().GetRecord("id",Existing.deviceConfiguration,DC)) {
poco_information(Logger(),fmt::format("{}: removing configuration for subscriber ({})", SerialNumber, RemoveSubscriber));
Logger().information(Poco::format("%s: removing configuration for subscriber (%s)", SerialNumber, RemoveSubscriber));
if(DC.subscriberOnly) {
if(!StorageService()->ConfigurationDB().DeleteRecord("id", Existing.deviceConfiguration)) {
poco_debug(Logger(),"Could not delete the subscriber configuration");
Logger().debug("Could not delete the subscriber configuration");
}
}
else {
poco_debug(Logger(),"Configurations is not for a subscriber.");
Logger().debug("Configurations is not for a subscriber.");
}
Existing.deviceConfiguration = "";
}
Existing.subscriber = "";
Poco::JSON::Object state;
state.set("date",Utils::Now());
state.set("date",OpenWifi::Now());
state.set("method","auto-discovery");
state.set("last-operation", "returned to inventory");
std::ostringstream OO;
@@ -308,7 +307,7 @@ namespace OpenWifi{
SDK::GW::Device::SetSubscriber(nullptr, SerialNumber, "");
return ReturnObject(Answer);
} else {
poco_information(Logger(),fmt::format("{}: wrong subscriber ({})", SerialNumber, RemoveSubscriber));
Logger().information(Poco::format("%s: wrong subscriber (%s)", SerialNumber, RemoveSubscriber));
}
return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
}
@@ -386,8 +385,6 @@ namespace OpenWifi{
}
}
AssignIfPresent(RawObject, "doNotAllowOverrides", Existing.doNotAllowOverrides);
if( RawObject->has("devClass") && NewObject.devClass!= Existing.devClass) {
Existing.devClass = NewObject.devClass;
}

View File

@@ -7,13 +7,14 @@
//
#pragma once
#include "framework/RESTAPI_Handler.h"
#include "framework/MicroService.h"
#include "StorageService.h"
namespace OpenWifi {
class RESTAPI_inventory_handler : public RESTAPIHandler {
public:
RESTAPI_inventory_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
RESTAPI_inventory_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L,
std::vector<std::string>{
Poco::Net::HTTPRequest::HTTP_GET, Poco::Net::HTTPRequest::HTTP_POST,

View File

@@ -7,14 +7,15 @@
//
#pragma once
#include "framework/RESTAPI_Handler.h"
#include "StorageService.h"
#include "framework/MicroService.h"
namespace OpenWifi {
class RESTAPI_inventory_list_handler : public RESTAPIHandler {
public:
RESTAPI_inventory_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
RESTAPI_inventory_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L,
std::vector<std::string>{
Poco::Net::HTTPRequest::HTTP_GET,

View File

@@ -3,13 +3,13 @@
//
#pragma once
#include "framework/RESTAPI_Handler.h"
#include "StorageService.h"
#include "framework/MicroService.h"
namespace OpenWifi {
class RESTAPI_iptocountry_handler : public RESTAPIHandler {
public:
RESTAPI_iptocountry_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
RESTAPI_iptocountry_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L,
std::vector<std::string>{Poco::Net::HTTPRequest::HTTP_GET,
Poco::Net::HTTPRequest::HTTP_OPTIONS},

View File

@@ -12,7 +12,6 @@
#include "StorageService.h"
#include "Daemon.h"
#include "RESTAPI/RESTAPI_db_helpers.h"
#include "framework/utils.h"
namespace OpenWifi{
@@ -148,7 +147,7 @@ namespace OpenWifi{
Existing.phones = NewObject.phones;
if(RawObject->has("mobiles"))
Existing.mobiles = NewObject.mobiles;
Existing.info.modified = Utils::Now();
Existing.info.modified = OpenWifi::Now();
if(RawObject->has("type"))
Existing.type = NewObject.type;

View File

@@ -7,13 +7,14 @@
//
#pragma once
#include "framework/RESTAPI_Handler.h"
#include "framework/MicroService.h"
#include "StorageService.h"
namespace OpenWifi {
class RESTAPI_location_handler : public RESTAPIHandler {
public:
RESTAPI_location_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
RESTAPI_location_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L,
std::vector<std::string>{
Poco::Net::HTTPRequest::HTTP_GET, Poco::Net::HTTPRequest::HTTP_POST,

View File

@@ -3,14 +3,15 @@
//
#pragma once
#include "framework/RESTAPI_Handler.h"
#include "framework/MicroService.h"
#include "StorageService.h"
namespace OpenWifi {
class RESTAPI_location_list_handler : public RESTAPIHandler {
public:
RESTAPI_location_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
RESTAPI_location_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L,
std::vector<std::string>{
Poco::Net::HTTPRequest::HTTP_GET,

View File

@@ -7,14 +7,13 @@
//
#pragma once
#include "framework/RESTAPI_Handler.h"
#include "framework/MicroService.h"
#include "StorageService.h"
namespace OpenWifi {
class RESTAPI_managementPolicy_handler : public RESTAPIHandler {
public:
RESTAPI_managementPolicy_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
RESTAPI_managementPolicy_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L,
std::vector<std::string>{
Poco::Net::HTTPRequest::HTTP_GET, Poco::Net::HTTPRequest::HTTP_POST,

View File

@@ -2,15 +2,14 @@
// Created by stephane bourque on 2021-08-26.
//
#pragma once
#include "framework/RESTAPI_Handler.h"
#include "framework/MicroService.h"
#include "StorageService.h"
namespace OpenWifi {
class RESTAPI_managementPolicy_list_handler : public RESTAPIHandler {
public:
RESTAPI_managementPolicy_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
RESTAPI_managementPolicy_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L,
std::vector<std::string>{
Poco::Net::HTTPRequest::HTTP_GET,

View File

@@ -2,14 +2,13 @@
// Created by stephane bourque on 2021-08-26.
//
#pragma once
#include "framework/RESTAPI_Handler.h"
#include "framework/MicroService.h"
#include "StorageService.h"
namespace OpenWifi {
class RESTAPI_managementRole_handler : public RESTAPIHandler {
public:
RESTAPI_managementRole_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
RESTAPI_managementRole_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L,
std::vector<std::string>{
Poco::Net::HTTPRequest::HTTP_GET, Poco::Net::HTTPRequest::HTTP_POST,

View File

@@ -2,7 +2,10 @@
// Created by stephane bourque on 2021-08-26.
//
#include "framework/MicroService.h"
#include "RESTAPI_managementRole_list_handler.h"
#include "RESTObjects/RESTAPI_ProvObjects.h"
#include "StorageService.h"
#include "RESTAPI/RESTAPI_db_helpers.h"

View File

@@ -1,16 +1,16 @@
//
// Created by stephane bourque on 2021-08-26.
//
#pragma once
#include "framework/RESTAPI_Handler.h"
#include "framework/MicroService.h"
#include "StorageService.h"
namespace OpenWifi {
class RESTAPI_managementRole_list_handler : public RESTAPIHandler {
public:
RESTAPI_managementRole_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
RESTAPI_managementRole_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L,
std::vector<std::string>{
Poco::Net::HTTPRequest::HTTP_GET,

View File

@@ -2,13 +2,14 @@
// Created by stephane bourque on 2021-11-09.
//
#pragma once
#include "framework/RESTAPI_Handler.h"
#include "framework/MicroService.h"
#include "StorageService.h"
namespace OpenWifi {
class RESTAPI_map_handler : public RESTAPIHandler {
public:
RESTAPI_map_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
RESTAPI_map_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L,
std::vector<std::string>{
Poco::Net::HTTPRequest::HTTP_GET, Poco::Net::HTTPRequest::HTTP_POST,

View File

@@ -2,14 +2,15 @@
// Created by stephane bourque on 2021-11-09.
//
#pragma once
#include "framework/RESTAPI_Handler.h"
#include "framework/MicroService.h"
#include "StorageService.h"
namespace OpenWifi {
class RESTAPI_map_list_handler : public RESTAPIHandler {
public:
RESTAPI_map_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
RESTAPI_map_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L,
std::vector<std::string>{
Poco::Net::HTTPRequest::HTTP_GET,

View File

@@ -3,13 +3,14 @@
//
#pragma once
#include "framework/RESTAPI_Handler.h"
#include "framework/MicroService.h"
#include "StorageService.h"
namespace OpenWifi {
class RESTAPI_op_contact_handler : public RESTAPIHandler {
public:
RESTAPI_op_contact_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
RESTAPI_op_contact_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L,
std::vector<std::string>{
Poco::Net::HTTPRequest::HTTP_GET, Poco::Net::HTTPRequest::HTTP_POST,

View File

@@ -2,14 +2,15 @@
// Created by stephane bourque on 2022-04-07.
//
#pragma once
#include "framework/RESTAPI_Handler.h"
#include "framework/MicroService.h"
#include "StorageService.h"
namespace OpenWifi {
class RESTAPI_op_contact_list_handler : public RESTAPIHandler {
public:
RESTAPI_op_contact_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
RESTAPI_op_contact_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L,
std::vector<std::string>{
Poco::Net::HTTPRequest::HTTP_GET,

View File

@@ -3,13 +3,14 @@
//
#pragma once
#include "framework/RESTAPI_Handler.h"
#include "framework/MicroService.h"
#include "StorageService.h"
namespace OpenWifi {
class RESTAPI_op_location_handler : public RESTAPIHandler {
public:
RESTAPI_op_location_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
RESTAPI_op_location_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L,
std::vector<std::string>{
Poco::Net::HTTPRequest::HTTP_GET, Poco::Net::HTTPRequest::HTTP_POST,

View File

@@ -3,14 +3,15 @@
//
#pragma once
#include "framework/RESTAPI_Handler.h"
#include "framework/MicroService.h"
#include "StorageService.h"
namespace OpenWifi {
class RESTAPI_op_location_list_handler : public RESTAPIHandler {
public:
RESTAPI_op_location_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
RESTAPI_op_location_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L,
std::vector<std::string>{
Poco::Net::HTTPRequest::HTTP_GET,

View File

@@ -4,7 +4,6 @@
#include "RESTAPI_operators_handler.h"
#include "RESTAPI_db_helpers.h"
#include "framework/utils.h"
namespace OpenWifi {
@@ -84,10 +83,10 @@ namespace OpenWifi {
// Create the default service...
ProvObjects::ServiceClass DefSer;
DefSer.info.id = MicroServiceCreateUUID();
DefSer.info.id = MicroService::CreateUUID();
DefSer.info.name = "Default Service Class";
DefSer.defaultService = true;
DefSer.info.created = DefSer.info.modified = Utils::Now();
DefSer.info.created = DefSer.info.modified = OpenWifi::Now();
DefSer.operatorId = NewObject.info.id;
DefSer.period = "monthly";
DefSer.billingCode = "basic";

View File

@@ -3,13 +3,14 @@
//
#pragma once
#include "framework/RESTAPI_Handler.h"
#include "framework/MicroService.h"
#include "StorageService.h"
namespace OpenWifi {
class RESTAPI_operators_handler : public RESTAPIHandler {
public:
RESTAPI_operators_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
RESTAPI_operators_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L,
std::vector<std::string>{
Poco::Net::HTTPRequest::HTTP_GET, Poco::Net::HTTPRequest::HTTP_POST,

View File

@@ -2,14 +2,15 @@
// Created by stephane bourque on 2022-04-06.
//
#pragma once
#include "framework/RESTAPI_Handler.h"
#include "framework/MicroService.h"
#include "StorageService.h"
namespace OpenWifi {
class RESTAPI_operators_list_handler : public RESTAPIHandler {
public:
RESTAPI_operators_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
RESTAPI_operators_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L,
std::vector<std::string>{
Poco::Net::HTTPRequest::HTTP_GET,

View File

@@ -1,106 +0,0 @@
//
// Created by stephane bourque on 2022-11-03.
//
#include <algorithm>
#include "RESTAPI_overrides_handler.h"
#include "framework/utils.h"
namespace OpenWifi {
void RESTAPI_overrides_handler::DoGet() {
std::string SerialNumber = GetBinding(RESTAPI::Protocol::SERIALNUMBER, "");
if(!Utils::NormalizeMac(SerialNumber)) {
return BadRequest(RESTAPI::Errors::InvalidSerialNumber);
}
ProvObjects::ConfigurationOverrideList ExistingObject;
if(!DB_.GetRecord("serialNumber", SerialNumber, ExistingObject)) {
return NotFound();
}
Poco::JSON::Object Answer;
ExistingObject.to_json(Answer);
return ReturnObject(Answer);
}
void RESTAPI_overrides_handler::DoDelete() {
std::string SerialNumber = GetBinding(RESTAPI::Protocol::SERIALNUMBER, "");
if(!Utils::NormalizeMac(SerialNumber)) {
return BadRequest(RESTAPI::Errors::InvalidSerialNumber);
}
auto Source = GetParameter("source","");
if(Source.empty()) {
return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
}
ProvObjects::ConfigurationOverrideList ExistingObject;
if(!DB_.GetRecord("serialNumber", SerialNumber, ExistingObject)) {
return NotFound();
}
ExistingObject.overrides.erase( std::remove_if( ExistingObject.overrides.begin(), ExistingObject.overrides.end(),
[Source](const ProvObjects::ConfigurationOverride &O) ->bool {
return O.source==Source;
}),ExistingObject.overrides.end());
if(DB_.UpdateRecord("serialNumber", SerialNumber, ExistingObject)) {
return OK();
}
return BadRequest(RESTAPI::Errors::NoRecordsDeleted);
}
void RESTAPI_overrides_handler::DoPut() {
std::string SerialNumber = GetBinding(RESTAPI::Protocol::SERIALNUMBER, "");
if(!Utils::NormalizeMac(SerialNumber)) {
return BadRequest(RESTAPI::Errors::InvalidSerialNumber);
}
auto Source = GetParameter("source","");
if(Source.empty()) {
return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
}
ProvObjects::ConfigurationOverrideList NewObject;
if(!NewObject.from_json(ParsedBody_)) {
return BadRequest(RESTAPI::Errors::InvalidJSONDocument);
}
ProvObjects::ConfigurationOverrideList ExistingObject;
if(!DB_.GetRecord("serialNumber", SerialNumber, ExistingObject)) {
ExistingObject.serialNumber = SerialNumber;
DB_.CreateRecord(ExistingObject);
} else {
// remove all the old records with that source.
ExistingObject.overrides.erase( std::remove_if( ExistingObject.overrides.begin(), ExistingObject.overrides.end(),
[Source](const ProvObjects::ConfigurationOverride &O) ->bool {
return O.source==Source;
}),ExistingObject.overrides.end());
}
for(auto & override:NewObject.overrides) {
if(override.parameterName.empty()) {
continue;
}
if(override.parameterType!="string" && override.parameterType!="boolean" && override.parameterType!="integer") {
return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
}
override.source = Source;
override.modified = Utils::Now();
ExistingObject.overrides.emplace_back(override);
}
if(DB_.UpdateRecord("serialNumber",SerialNumber,ExistingObject)) {
Poco::JSON::Object Answer;
ExistingObject.to_json(Answer);
return ReturnObject(Answer);
}
return BadRequest(RESTAPI::Errors::RecordNotUpdated);
}
} // OpenWifi

View File

@@ -1,31 +0,0 @@
//
// Created by stephane bourque on 2022-11-03.
//
#pragma once
#include "framework/RESTAPI_Handler.h"
#include "StorageService.h"
namespace OpenWifi {
class RESTAPI_overrides_handler : public RESTAPIHandler {
public:
RESTAPI_overrides_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L,
std::vector<std::string>{
Poco::Net::HTTPRequest::HTTP_GET,
Poco::Net::HTTPRequest::HTTP_PUT, Poco::Net::HTTPRequest::HTTP_DELETE,
Poco::Net::HTTPRequest::HTTP_OPTIONS},
Server,
TransactionId,
Internal){}
static auto PathName() { return std::list<std::string>{"/api/v1/configurationOverrides/{serialNumber}"}; };
private:
OverridesDB &DB_=StorageService()->OverridesDB();
void DoGet() final ;
void DoPost() final {} ;
void DoPut() final ;
void DoDelete() final ;
};
}

View File

@@ -2,6 +2,8 @@
// Created by stephane bourque on 2021-10-23.
//
#include "framework/MicroService.h"
#include "RESTAPI/RESTAPI_entity_handler.h"
#include "RESTAPI/RESTAPI_contact_handler.h"
#include "RESTAPI/RESTAPI_location_handler.h"
@@ -34,15 +36,12 @@
#include "RESTAPI/RESTAPI_op_contact_list_handler.h"
#include "RESTAPI/RESTAPI_op_location_handler.h"
#include "RESTAPI/RESTAPI_op_location_list_handler.h"
#include "RESTAPI/RESTAPI_overrides_handler.h"
#include "framework/RESTAPI_SystemCommand.h"
#include "framework/RESTAPI_WebSocketServer.h"
namespace OpenWifi {
Poco::Net::HTTPRequestHandler * RESTAPI_ExtRouter(const std::string &Path, RESTAPIHandler::BindingMap &Bindings,
Poco::Logger & L, RESTAPI_GenericServerAccounting & S, uint64_t TransactionId) {
Poco::Logger & L, RESTAPI_GenericServer & S, uint64_t TransactionId) {
return RESTAPI_Router<
RESTAPI_system_command,
RESTAPI_entity_handler,
@@ -77,13 +76,12 @@ namespace OpenWifi {
RESTAPI_op_contact_list_handler,
RESTAPI_op_location_handler,
RESTAPI_op_location_list_handler,
RESTAPI_asset_server,
RESTAPI_overrides_handler
RESTAPI_asset_server
>(Path,Bindings,L, S, TransactionId);
}
Poco::Net::HTTPRequestHandler * RESTAPI_IntRouter(const std::string &Path, RESTAPIHandler::BindingMap &Bindings,
Poco::Logger & L, RESTAPI_GenericServerAccounting & S, uint64_t TransactionId) {
Poco::Logger & L, RESTAPI_GenericServer & S, uint64_t TransactionId) {
return RESTAPI_Router_I<
RESTAPI_system_command,
RESTAPI_entity_handler,
@@ -117,8 +115,7 @@ namespace OpenWifi {
RESTAPI_op_contact_handler,
RESTAPI_op_contact_list_handler,
RESTAPI_op_location_handler,
RESTAPI_op_location_list_handler,
RESTAPI_overrides_handler
RESTAPI_op_location_list_handler
>(Path, Bindings, L, S, TransactionId);
}
}

View File

@@ -3,13 +3,14 @@
//
#pragma once
#include "framework/RESTAPI_Handler.h"
#include "framework/MicroService.h"
#include "StorageService.h"
namespace OpenWifi {
class RESTAPI_service_class_handler : public RESTAPIHandler {
public:
RESTAPI_service_class_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
RESTAPI_service_class_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L,
std::vector<std::string>{
Poco::Net::HTTPRequest::HTTP_GET, Poco::Net::HTTPRequest::HTTP_POST,

View File

@@ -3,14 +3,15 @@
//
#pragma once
#include "framework/RESTAPI_Handler.h"
#include "framework/MicroService.h"
#include "StorageService.h"
namespace OpenWifi {
class RESTAPI_service_class_list_handler : public RESTAPIHandler {
public:
RESTAPI_service_class_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
RESTAPI_service_class_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L,
std::vector<std::string>{
Poco::Net::HTTPRequest::HTTP_GET,

View File

@@ -5,10 +5,6 @@
#include "RESTAPI_signup_handler.h"
#include "StorageService.h"
#include "Signup.h"
#include "framework/OpenAPIRequests.h"
#include "framework/MicroServiceNames.h"
#include "framework/MicroServiceFuncs.h"
#include "framework/utils.h"
namespace OpenWifi {
@@ -63,7 +59,7 @@ namespace OpenWifi {
if (i.statusCode == ProvObjects::SignupStatusCodes::SignupWaitingForEmail ||
i.statusCode == ProvObjects::SignupStatusCodes::SignupWaitingForDevice ||
i.statusCode == ProvObjects::SignupStatusCodes::SignupSuccess ) {
poco_debug(Logger(),fmt::format("SIGNUP: Returning existing signup record for '{}'",i.email));
Logger().information(fmt::format("SIGNUP: Returning existing signup record for '{}'",i.email));
Poco::JSON::Object Answer;
i.to_json(Answer);
return ReturnObject(Answer);
@@ -97,8 +93,8 @@ namespace OpenWifi {
// OK, we can claim this device, can we create a userid?
// Let's create one
// If sec.signup("email",uuid);
auto SignupUUID = MicroServiceCreateUUID();
poco_debug(Logger(),fmt::format("SIGNUP: Creating signup entry for '{}', uuid='{}'",UserName, SignupUUID));
auto SignupUUID = MicroService::instance().CreateUUID();
Logger().information(fmt::format("SIGNUP: Creating signup entry for '{}', uuid='{}'",UserName, SignupUUID));
Poco::JSON::Object Body;
OpenAPIRequestPost CreateUser( uSERVICE_SECURITY, "/api/v1/signup", {
@@ -115,12 +111,12 @@ namespace OpenWifi {
UI.from_json(Answer);
std::ostringstream os;
Answer->stringify(os);
poco_debug(Logger(),fmt::format("SIGNUP: email: '{}' signupID: '{}' userId: '{}'", UserName, SignupUUID, UI.id));
Logger().information(fmt::format("SIGNUP: email: '{}' signupID: '{}' userId: '{}'", UserName, SignupUUID, UI.id));
// so create the Signup entry and modify the inventory
ProvObjects::SignupEntry SE;
SE.info.id = SignupUUID;
SE.info.created = SE.info.modified = SE.submitted = Utils::Now();
SE.info.created = SE.info.modified = SE.submitted = OpenWifi::Now();
SE.completed = 0 ;
SE.macAddress = macAddress;
SE.error = 0 ;
@@ -141,13 +137,13 @@ namespace OpenWifi {
StateDoc.set("claimerId", UI.id);
StateDoc.set("signupUUID", SignupUUID);
StateDoc.set("errorCode",0);
StateDoc.set("date", Utils::Now());
StateDoc.set("date", OpenWifi::Now());
StateDoc.set("status", "waiting for email-verification");
std::ostringstream os2;
StateDoc.stringify(os2);
IT.realMacAddress = macAddress;
IT.state = os2.str();
IT.info.modified = Utils::Now();
IT.info.modified = OpenWifi::Now();
std::cout << "Updating inventory entry: " << SE.macAddress << std::endl;
StorageService()->InventoryDB().UpdateRecord("id",IT.info.id,IT);
}
@@ -164,22 +160,22 @@ namespace OpenWifi {
auto SignupUUID = GetParameter("signupUUID");
auto Operation = GetParameter("operation");
poco_information(Logger(),fmt::format("signup-progress: {} - {} ", SignupUUID, Operation));
Logger().information(fmt::format("signup-progress: {} - {} ", SignupUUID, Operation));
if(SignupUUID.empty() || Operation.empty()) {
return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
}
ProvObjects::SignupEntry SE;
poco_information(Logger(),fmt::format("signup-progress: {} - {} fetching entry", SignupUUID, Operation));
Logger().information(fmt::format("signup-progress: {} - {} fetching entry", SignupUUID, Operation));
if(!StorageService()->SignupDB().GetRecord("id",SignupUUID,SE)) {
return NotFound();
}
poco_debug(Logger(),fmt::format("signup-progress: {} - {} fetching entry", SignupUUID, Operation));
Logger().information(fmt::format("signup-progress: {} - {} fetching entry", SignupUUID, Operation));
if(Operation == "emailVerified" && SE.statusCode==ProvObjects::SignupStatusCodes::SignupWaitingForEmail) {
poco_information(Logger(),fmt::format("{}: email {} verified.",SE.info.id, SE.email));
Logger().information(fmt::format("{}: email {} verified.",SE.info.id, SE.email));
std::cout << "Verified email for : " << SE.email << std::endl;
SE.info.modified = Utils::Now();
SE.info.modified = OpenWifi::Now();
SE.status = "emailVerified";
SE.statusCode = ProvObjects::SignupStatusCodes::SignupWaitingForDevice;
StorageService()->SignupDB().UpdateRecord("id", SE.info.id, SE);
@@ -188,7 +184,7 @@ namespace OpenWifi {
SE.to_json(Answer);
return ReturnObject(Answer);
}
poco_information(Logger(),fmt::format("signup-progress: {} - {} something is bad", SignupUUID, Operation));
Logger().information(fmt::format("signup-progress: {} - {} something is bad", SignupUUID, Operation));
return BadRequest(RESTAPI::Errors::UnknownId);
}
@@ -199,11 +195,11 @@ namespace OpenWifi {
auto macAddress = GetParameter("macAddress");
auto List = GetBoolParameter("listOnly",false);
poco_information(Logger(),fmt::format("Looking for signup for {}",EMail));
Logger().information(fmt::format("Looking for signup for {}",EMail));
Poco::JSON::Object Answer;
ProvObjects::SignupEntry SE;
if(!SignupUUID.empty()) {
poco_information(Logger(),fmt::format("Looking for signup for {}: Signup {}",EMail, SignupUUID));
Logger().information(fmt::format("Looking for signup for {}: Signup {}",EMail, SignupUUID));
if(StorageService()->SignupDB().GetRecord("id", SignupUUID, SE)) {
SE.to_json(Answer);
return ReturnObject(Answer);
@@ -211,25 +207,25 @@ namespace OpenWifi {
return NotFound();
} else if(!EMail.empty()) {
SignupDB::RecordVec SEs;
poco_information(Logger(),fmt::format("Looking for signup for {}: Signup {}",EMail, SignupUUID));
Logger().information(fmt::format("Looking for signup for {}: Signup {}",EMail, SignupUUID));
if(StorageService()->SignupDB().GetRecords(0,100,SEs, " email='"+EMail+"' ")) {
return ReturnObject("signups",SEs);
}
return NotFound();
} else if(!macAddress.empty()) {
SignupDB::RecordVec SEs;
poco_information(Logger(),fmt::format("Looking for signup for {}: Mac {}",EMail, macAddress));
Logger().information(fmt::format("Looking for signup for {}: Mac {}",EMail, macAddress));
if(StorageService()->SignupDB().GetRecords(0,100,SEs, " serialNumber='"+macAddress+"' ")) {
return ReturnObject("signups",SEs);
}
return NotFound();
} else if(List) {
poco_information(Logger(),fmt::format("Returning list of signups...",EMail, macAddress));
Logger().information(fmt::format("Returning list of signups...",EMail, macAddress));
SignupDB::RecordVec SEs;
StorageService()->SignupDB().GetRecords(0,100,SEs);
return ReturnObject("signups",SEs);
}
poco_information(Logger(),fmt::format("Bad signup get",EMail, macAddress));
Logger().information(fmt::format("Bad signup get",EMail, macAddress));
return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
}

View File

@@ -3,13 +3,13 @@
//
#pragma once
#include "framework/RESTAPI_Handler.h"
#include "StorageService.h"
#include "framework/MicroService.h"
namespace OpenWifi {
class RESTAPI_signup_handler : public RESTAPIHandler {
public:
RESTAPI_signup_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
RESTAPI_signup_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L,
std::vector<std::string>{
Poco::Net::HTTPRequest::HTTP_POST,

View File

@@ -3,13 +3,14 @@
//
#pragma once
#include "framework/RESTAPI_Handler.h"
#include "framework/MicroService.h"
#include "StorageService.h"
namespace OpenWifi {
class RESTAPI_sub_devices_handler : public RESTAPIHandler {
public:
RESTAPI_sub_devices_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
RESTAPI_sub_devices_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L,
std::vector<std::string>{
Poco::Net::HTTPRequest::HTTP_GET, Poco::Net::HTTPRequest::HTTP_POST,

View File

@@ -3,14 +3,15 @@
//
#pragma once
#include "framework/RESTAPI_Handler.h"
#include "framework/MicroService.h"
#include "StorageService.h"
namespace OpenWifi {
class RESTAPI_sub_devices_list_handler : public RESTAPIHandler {
public:
RESTAPI_sub_devices_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
RESTAPI_sub_devices_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L,
std::vector<std::string>{
Poco::Net::HTTPRequest::HTTP_GET,

View File

@@ -1,15 +1,15 @@
//
// Created by stephane bourque on 2022-02-23.
//
#pragma once
#include "framework/RESTAPI_Handler.h"
#include "framework/MicroService.h"
#include "StorageService.h"
namespace OpenWifi {
class RESTAPI_variables_handler : public RESTAPIHandler {
public:
RESTAPI_variables_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
RESTAPI_variables_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L,
std::vector<std::string>{
Poco::Net::HTTPRequest::HTTP_GET, Poco::Net::HTTPRequest::HTTP_POST,

View File

@@ -3,14 +3,15 @@
//
#pragma once
#include "framework/RESTAPI_Handler.h"
#include "framework/MicroService.h"
#include "StorageService.h"
namespace OpenWifi {
class RESTAPI_variables_list_handler : public RESTAPIHandler {
public:
RESTAPI_variables_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
RESTAPI_variables_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L,
std::vector<std::string>{
Poco::Net::HTTPRequest::HTTP_GET,

View File

@@ -15,8 +15,6 @@
#include "Tasks/VenueConfigUpdater.h"
#include "Tasks/VenueRebooter.h"
#include "Tasks/VenueUpgrade.h"
#include "framework/CIDR.h"
#include "framework/MicroServiceFuncs.h"
#include "Kafka_ProvUpdater.h"
@@ -230,7 +228,7 @@ namespace OpenWifi{
Poco::JSON::Object Answer;
SNL.serialNumbers = Existing.devices;
auto JobId = MicroServiceCreateUUID();
auto JobId = MicroService::instance().CreateUUID();
Types::StringVec Parameters{UUID};;
auto NewJob = new VenueConfigUpdater(JobId,"VenueConfigurationUpdater", Parameters, 0, UserInfo_.userinfo, Logger());
JobController()->AddJob(dynamic_cast<Job*>(NewJob));
@@ -244,7 +242,7 @@ namespace OpenWifi{
Poco::JSON::Object Answer;
SNL.serialNumbers = Existing.devices;
auto JobId = MicroServiceCreateUUID();
auto JobId = MicroService::instance().CreateUUID();
Types::StringVec Parameters{UUID};;
auto NewJob = new VenueUpgrade(JobId,"VenueFirmwareUpgrade", Parameters, 0, UserInfo_.userinfo, Logger());
JobController()->AddJob(dynamic_cast<Job*>(NewJob));
@@ -258,7 +256,7 @@ namespace OpenWifi{
Poco::JSON::Object Answer;
SNL.serialNumbers = Existing.devices;
auto JobId = MicroServiceCreateUUID();
auto JobId = MicroService::instance().CreateUUID();
Types::StringVec Parameters{UUID};;
auto NewJob = new VenueRebooter(JobId,"VenueRebooter", Parameters, 0, UserInfo_.userinfo, Logger());
JobController()->AddJob(dynamic_cast<Job*>(NewJob));

View File

@@ -7,13 +7,14 @@
//
#pragma once
#include "framework/RESTAPI_Handler.h"
#include "framework/MicroService.h"
#include "StorageService.h"
namespace OpenWifi {
class RESTAPI_venue_handler : public RESTAPIHandler {
public:
RESTAPI_venue_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
RESTAPI_venue_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L,
std::vector<std::string>{
Poco::Net::HTTPRequest::HTTP_GET, Poco::Net::HTTPRequest::HTTP_POST,

View File

@@ -3,14 +3,15 @@
//
#pragma once
#include "framework/RESTAPI_Handler.h"
#include "framework/MicroService.h"
#include "StorageService.h"
namespace OpenWifi {
class RESTAPI_venue_list_handler : public RESTAPIHandler {
public:
RESTAPI_venue_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
RESTAPI_venue_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
: RESTAPIHandler(bindings, L,
std::vector<std::string>{
Poco::Net::HTTPRequest::HTTP_GET,

View File

@@ -4,7 +4,7 @@
#include "RESTAPI_AnalyticsObjects.h"
#include "RESTAPI_ProvObjects.h"
#include "framework/RESTAPI_utils.h"
#include "framework/MicroService.h"
using OpenWifi::RESTAPI_utils::field_to_json;
using OpenWifi::RESTAPI_utils::field_from_json;

View File

@@ -5,7 +5,6 @@
#pragma once
#include "RESTAPI_ProvObjects.h"
#include "framework/utils.h"
#include <vector>
namespace OpenWifi {
@@ -376,7 +375,7 @@ namespace OpenWifi {
};
struct WifiClientHistory {
uint64_t timestamp=Utils::Now();
uint64_t timestamp=OpenWifi::Now();
std::string station_id;
std::string bssid;
std::string ssid;

View File

@@ -3,7 +3,7 @@
//
#include "RESTAPI_CertObjects.h"
#include "framework/RESTAPI_utils.h"
#include "framework/MicroService.h"
using OpenWifi::RESTAPI_utils::field_to_json;
using OpenWifi::RESTAPI_utils::field_from_json;
@@ -154,7 +154,6 @@ namespace OpenWifi::CertObjects {
field_to_json(Obj,"submitted", submitted);
field_to_json(Obj,"started", started);
field_to_json(Obj,"completed", completed);
field_to_json(Obj,"requesterUsername", requesterUsername);
}
bool JobEntry::from_json(const Poco::JSON::Object::Ptr &Obj) {
@@ -172,7 +171,6 @@ namespace OpenWifi::CertObjects {
field_from_json(Obj,"submitted", submitted);
field_from_json(Obj,"started", started);
field_from_json(Obj,"completed", completed);
field_from_json(Obj,"requesterUsername", requesterUsername);
return true;
} catch (...) {
}

View File

@@ -91,7 +91,6 @@ namespace OpenWifi::CertObjects {
uint64_t submitted=0;
uint64_t started=0;
uint64_t completed=0;
std::string requesterUsername;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);

View File

@@ -3,8 +3,7 @@
//
#include "RESTAPI_FMSObjects.h"
#include "framework/RESTAPI_utils.h"
#include "framework/utils.h"
#include "framework/MicroService.h"
using OpenWifi::RESTAPI_utils::field_to_json;
using OpenWifi::RESTAPI_utils::field_from_json;
@@ -234,7 +233,7 @@ namespace OpenWifi::FMSObjects {
UnknownFirmwares_.clear();
totalSecondsOld_.clear();
numberOfDevices = 0 ;
snapshot = Utils::Now();
snapshot = OpenWifi::Now();
}
bool DeviceReport::from_json([[maybe_unused]] const Poco::JSON::Object::Ptr &Obj) {

View File

@@ -11,13 +11,12 @@
#include "Daemon.h"
#ifdef TIP_GATEWAY_SERVICE
#include "AP_WS_Server.h"
#include "DeviceRegistry.h"
#include "CapabilitiesCache.h"
#endif
#include "RESTAPI_GWobjects.h"
#include "framework/RESTAPI_utils.h"
#include "framework/utils.h"
#include "framework/MicroService.h"
using OpenWifi::RESTAPI_utils::field_to_json;
using OpenWifi::RESTAPI_utils::field_from_json;
@@ -50,10 +49,6 @@ namespace OpenWifi::GWObjects {
field_to_json(Obj,"entity", entity);
field_to_json(Obj,"modified", modified);
field_to_json(Obj,"locale", locale);
field_to_json(Obj,"restrictedDevice", restrictedDevice);
field_to_json(Obj,"pendingConfiguration", pendingConfiguration);
field_to_json(Obj,"pendingConfigurationCmd", pendingConfigurationCmd);
field_to_json(Obj,"restrictionDetails", restrictionDetails);
}
void Device::to_json_with_status(Poco::JSON::Object &Obj) const {
@@ -62,7 +57,7 @@ namespace OpenWifi::GWObjects {
#ifdef TIP_GATEWAY_SERVICE
ConnectionState ConState;
if (AP_WS_Server()->GetState(SerialNumber, ConState)) {
if (DeviceRegistry()->GetState(SerialNumber, ConState)) {
ConState.to_json(Obj);
} else {
field_to_json(Obj,"ipAddress", "");
@@ -74,7 +69,6 @@ namespace OpenWifi::GWObjects {
field_to_json(Obj,"verifiedCertificate", "NO_CERTIFICATE");
field_to_json(Obj,"associations_2G", (uint64_t) 0);
field_to_json(Obj,"associations_5G", (uint64_t) 0);
field_to_json(Obj,"associations_6G", (uint64_t) 0);
}
#endif
}
@@ -94,10 +88,6 @@ namespace OpenWifi::GWObjects {
field_from_json(Obj,"subscriber", subscriber);
field_from_json(Obj,"entity", entity);
field_from_json(Obj,"locale", locale);
field_from_json(Obj,"restrictedDevice", restrictedDevice);
field_from_json(Obj,"pendingConfiguration", pendingConfiguration);
field_from_json(Obj,"pendingConfigurationCmd", pendingConfigurationCmd);
field_from_json(Obj,"restrictionDetails", restrictionDetails);
return true;
} catch (const Poco::Exception &E) {
}
@@ -208,7 +198,6 @@ namespace OpenWifi::GWObjects {
field_to_json(Obj,"lastContact", LastContact);
field_to_json(Obj,"associations_2G", Associations_2G);
field_to_json(Obj,"associations_5G", Associations_5G);
field_to_json(Obj,"associations_6G", Associations_6G);
field_to_json(Obj,"webSocketClients", webSocketClients);
field_to_json(Obj,"websocketPackets", websocketPackets);
field_to_json(Obj,"kafkaClients", kafkaClients);
@@ -217,8 +206,7 @@ namespace OpenWifi::GWObjects {
field_to_json(Obj,"started", started);
field_to_json(Obj,"sessionId", sessionId);
field_to_json(Obj,"connectionCompletionTime", connectionCompletionTime);
field_to_json(Obj,"totalConnectionTime", Utils::Now() - started);
field_to_json(Obj,"certificateExpiryDate", certificateExpiryDate);
field_to_json(Obj,"totalConnectionTime", OpenWifi::Now() - started);
switch(VerifiedCertificate) {
case NO_CERTIFICATE:
@@ -237,14 +225,12 @@ namespace OpenWifi::GWObjects {
void DeviceConnectionStatistics::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj,"averageConnectionTime", averageConnectionTime);
field_to_json(Obj,"connectedDevices", connectedDevices );
field_to_json(Obj,"connectingDevices", connectingDevices );
}
bool DeviceConnectionStatistics::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
field_from_json(Obj,"averageConnectionTime", averageConnectionTime);
field_from_json(Obj,"connectedDevices", connectedDevices );
field_from_json(Obj,"connectingDevices", connectingDevices );
return true;
} catch (const Poco::Exception &E) {
}
@@ -297,7 +283,7 @@ namespace OpenWifi::GWObjects {
lastContact.clear();
associations.clear();
numberOfDevices = 0 ;
snapshot = Utils::Now();
snapshot = OpenWifi::Now();
}
void CapabilitiesModel::to_json(Poco::JSON::Object &Obj) const{
@@ -309,12 +295,9 @@ namespace OpenWifi::GWObjects {
field_to_json(Obj,"serialNumber",serialNumber);
field_to_json(Obj,"timeout",timeout);
field_to_json(Obj,"type",type);
field_to_json(Obj,"scriptId",scriptId);
field_to_json(Obj,"script",script);
field_to_json(Obj,"scriptId",scriptId);
field_to_json(Obj,"when",when);
field_to_json(Obj,"signature", signature);
field_to_json(Obj,"deferred", deferred);
field_to_json(Obj,"uri", uri);
}
bool ScriptRequest::from_json(const Poco::JSON::Object::Ptr &Obj) {
@@ -325,9 +308,6 @@ namespace OpenWifi::GWObjects {
field_from_json(Obj,"script",script);
field_from_json(Obj,"scriptId",scriptId);
field_from_json(Obj,"when",when);
field_from_json(Obj,"signature", signature);
field_from_json(Obj,"deferred", deferred);
field_from_json(Obj,"uri", uri);
return true;
} catch (const Poco::Exception &E) {
}
@@ -399,7 +379,6 @@ namespace OpenWifi::GWObjects {
field_to_json(Obj,"secret",secret);
field_to_json(Obj,"certificate",certificate);
field_to_json(Obj,"radsec",radsec);
field_to_json(Obj,"allowSelfSigned",allowSelfSigned);
field_to_json(Obj,"radsecPort",radsecPort);
field_to_json(Obj,"radsecSecret",radsecSecret);
field_to_json(Obj,"radsecCacerts",radsecCacerts);
@@ -418,7 +397,6 @@ namespace OpenWifi::GWObjects {
field_from_json(Obj,"secret",secret);
field_from_json(Obj,"certificate",certificate);
field_from_json(Obj,"radsec",radsec);
field_from_json(Obj,"allowSelfSigned",allowSelfSigned);
field_from_json(Obj,"radsecSecret",radsecSecret);
field_from_json(Obj,"radsecPort",radsecPort);
field_from_json(Obj,"radsecCacerts",radsecCacerts);
@@ -431,117 +409,5 @@ namespace OpenWifi::GWObjects {
}
return false;
}
void ScriptEntry::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj,"id", id);
field_to_json(Obj,"name", name);
field_to_json(Obj,"description", description);
field_to_json(Obj,"uri", uri);
field_to_json(Obj,"content", content);
field_to_json(Obj,"version", version);
field_to_json(Obj,"type", type);
field_to_json(Obj,"created", created);
field_to_json(Obj,"modified", modified);
field_to_json(Obj,"author", author);
field_to_json(Obj,"restricted", restricted);
field_to_json(Obj,"deferred", deferred);
field_to_json(Obj,"timeout", timeout);
field_to_json(Obj,"defaultUploadURI", defaultUploadURI);
}
bool ScriptEntry::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
field_from_json(Obj,"id", id);
field_from_json(Obj,"name", name);
field_from_json(Obj,"description", description);
field_from_json(Obj,"uri", uri);
field_from_json(Obj,"content", content);
field_from_json(Obj,"version", version);
field_from_json(Obj,"type", type);
field_from_json(Obj,"created", created);
field_from_json(Obj,"modified", modified);
field_from_json(Obj,"author", author);
field_from_json(Obj,"restricted", restricted);
field_from_json(Obj,"deferred", deferred);
field_from_json(Obj,"timeout", timeout);
field_from_json(Obj,"defaultUploadURI", defaultUploadURI);
return true;
} catch (const Poco::Exception &E) {
}
return false;
}
void ScriptEntryList::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj,"scripts",scripts);
}
bool ScriptEntryList::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
field_from_json(Obj,"scripts",scripts);
return true;
} catch (const Poco::Exception &E) {
}
return false;
}
void DeviceRestrictionsKeyInfo::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj,"vendor", vendor);
field_to_json(Obj,"algo", algo);
}
bool DeviceRestrictionsKeyInfo::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
field_from_json(Obj,"vendor", vendor);
field_from_json(Obj,"algo", algo);
return true;
} catch (const Poco::Exception &E) {
}
return false;
}
void DeviceRestrictions::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj,"dfs", dfs);
field_to_json(Obj,"ssh", ssh);
field_to_json(Obj,"rtty", rtty);
field_to_json(Obj,"tty", tty);
field_to_json(Obj,"developer", developer);
field_to_json(Obj,"upgrade", upgrade);
field_to_json(Obj,"commands", commands);
field_to_json(Obj,"country", country);
field_to_json(Obj,"key_info", key_info);
}
bool DeviceRestrictions::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
field_from_json(Obj,"dfs", dfs);
field_from_json(Obj,"ssh", ssh);
field_from_json(Obj,"rtty", rtty);
field_from_json(Obj,"tty", tty);
field_from_json(Obj,"developer", developer);
field_from_json(Obj,"upgrade", upgrade);
field_from_json(Obj,"commands", commands);
field_from_json(Obj,"country", country);
field_from_json(Obj,"key_info", key_info);
return true;
} catch (const Poco::Exception &E) {
}
return false;
}
bool DeviceRestrictionsKeyInfo::operator!=(const OpenWifi::GWObjects::DeviceRestrictionsKeyInfo &T) const {
return (T.algo!=algo) || (T.vendor!=vendor);
}
bool DeviceRestrictions::operator!=(const OpenWifi::GWObjects::DeviceRestrictions &T) const {
return ( (T.dfs!=dfs) ||
(T.rtty!=rtty) ||
(T.upgrade!=upgrade) ||
(T.commands != commands) ||
(T.developer != developer) ||
(T.ssh !=ssh) ||
(T.key_info != key_info) ||
(T.country != country) );
}
}

View File

@@ -28,52 +28,23 @@ namespace OpenWifi::GWObjects {
uint64_t TX = 0, RX = 0;
uint64_t Associations_2G=0;
uint64_t Associations_5G=0;
uint64_t Associations_6G=0;
bool Connected = false;
uint64_t LastContact=0;
std::string Firmware;
CertificateValidation VerifiedCertificate = NO_CERTIFICATE;
std::string Compatible;
uint64_t kafkaClients=0;
uint64_t webSocketClients=0;
uint64_t kafkaPackets=0;
uint64_t websocketPackets=0;
std::string locale;
uint64_t started=0;
uint64_t sessionId=0;
double connectionCompletionTime=0.0;
std::uint64_t certificateExpiryDate=0;
std::string Compatible;
uint64_t kafkaClients=0;
uint64_t webSocketClients=0;
uint64_t kafkaPackets=0;
uint64_t websocketPackets=0;
std::string locale;
uint64_t started=0;
uint64_t sessionId=0;
double connectionCompletionTime=0.0;
void to_json(Poco::JSON::Object &Obj) const;
};
struct DeviceRestrictionsKeyInfo {
std::string vendor;
std::string algo;
bool operator !=(const DeviceRestrictionsKeyInfo &b) const;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
struct DeviceRestrictions {
bool dfs = false;
bool ssh = false;
bool rtty = false;
bool tty = false;
bool developer = false;
bool upgrade = false;
bool commands = false;
std::vector<std::string> country;
DeviceRestrictionsKeyInfo key_info;
bool operator !=(const DeviceRestrictions &D) const;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
struct Device {
std::string SerialNumber;
std::string DeviceType;
@@ -97,10 +68,6 @@ namespace OpenWifi::GWObjects {
std::string entity;
uint64_t modified=0;
std::string locale;
bool restrictedDevice=false;
std::string pendingConfiguration;
std::string pendingConfigurationCmd;
DeviceRestrictions restrictionDetails;
void to_json(Poco::JSON::Object &Obj) const;
void to_json_with_status(Poco::JSON::Object &Obj) const;
@@ -111,8 +78,6 @@ namespace OpenWifi::GWObjects {
struct DeviceConnectionStatistics {
std::uint64_t connectedDevices = 0;
std::uint64_t averageConnectionTime = 0;
std::uint64_t connectingDevices = 0;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
@@ -246,44 +211,13 @@ namespace OpenWifi::GWObjects {
void to_json(Poco::JSON::Object &Obj) const;
};
struct ScriptEntry {
std::string id;
std::string name;
std::string description;
std::string uri;
std::string content;
std::string version;
std::string type;
std::uint64_t created;
std::uint64_t modified;
std::string author;
Types::StringVec restricted;
bool deferred=false;
std::uint64_t timeout=30;
std::string defaultUploadURI;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
struct ScriptEntryList {
std::vector<ScriptEntry> scripts;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
struct ScriptRequest {
std::string serialNumber;
uint64_t timeout=30;
std::string serialNumber;
std::string type;
std::string script;
std::string scriptId;
std::uint64_t when;
std::string signature;
bool deferred;
std::string uri;
uint64_t when=0;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
@@ -296,7 +230,6 @@ namespace OpenWifi::GWObjects {
std::string secret;
std::string certificate;
bool radsec=false;
bool allowSelfSigned=false;
uint16_t radsecPort=2083;
std::string radsecSecret;
std::string radsecKey;
@@ -338,5 +271,4 @@ namespace OpenWifi::GWObjects {
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
}

View File

@@ -2,7 +2,7 @@
// Created by stephane bourque on 2021-08-31.
//
#include "framework/RESTAPI_utils.h"
#include "framework/MicroService.h"
using OpenWifi::RESTAPI_utils::field_to_json;
using OpenWifi::RESTAPI_utils::field_from_json;

View File

@@ -8,9 +8,7 @@
#include "RESTAPI_ProvObjects.h"
#include "framework/RESTAPI_utils.h"
#include "framework/MicroServiceFuncs.h"
#include "framework/utils.h"
#include "framework/MicroService.h"
using OpenWifi::RESTAPI_utils::field_to_json;
using OpenWifi::RESTAPI_utils::field_from_json;
@@ -602,7 +600,6 @@ namespace OpenWifi::ProvObjects {
field_to_json( Obj, "devClass",devClass);
field_to_json( Obj, "locale",locale);
field_to_json( Obj, "realMacAddress",realMacAddress);
field_to_json( Obj, "doNotAllowOverrides",doNotAllowOverrides);
}
bool InventoryTag::from_json(const Poco::JSON::Object::Ptr &Obj) {
@@ -624,7 +621,6 @@ namespace OpenWifi::ProvObjects {
field_from_json( Obj,"devClass",devClass);
field_from_json( Obj,"locale",locale);
field_from_json( Obj,"realMacAddress",realMacAddress);
field_from_json( Obj, "doNotAllowOverrides",doNotAllowOverrides);
return true;
} catch(...) {
@@ -1095,7 +1091,7 @@ namespace OpenWifi::ProvObjects {
}
bool UpdateObjectInfo(const Poco::JSON::Object::Ptr &O, const SecurityObjects::UserInfo &U, ObjectInfo &I) {
uint64_t Now = Utils::Now();
uint64_t Now = OpenWifi::Now();
if(O->has("name"))
I.name = O->get("name").toString();
@@ -1116,7 +1112,7 @@ namespace OpenWifi::ProvObjects {
}
bool CreateObjectInfo(const Poco::JSON::Object::Ptr &O, const SecurityObjects::UserInfo &U, ObjectInfo &I) {
uint64_t Now = Utils::Now();
uint64_t Now = OpenWifi::Now();
if(O->has("name"))
I.name = O->get("name").toString();
@@ -1134,14 +1130,14 @@ namespace OpenWifi::ProvObjects {
}
I.notes = N;
I.modified = I.created = Now;
I.id = MicroServiceCreateUUID();
I.id = MicroService::CreateUUID();
return true;
}
bool CreateObjectInfo([[maybe_unused]] const SecurityObjects::UserInfo &U, ObjectInfo &I) {
I.modified = I.created = Utils::Now();
I.id = MicroServiceCreateUUID();
I.modified = I.created = OpenWifi::Now();
I.id = MicroService::CreateUUID();
return true;
}
@@ -1197,48 +1193,6 @@ namespace OpenWifi::ProvObjects {
return false;
}
void ConfigurationOverride::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj,"source",source);
field_to_json(Obj,"reason",reason);
field_to_json(Obj,"parameterName",parameterName);
field_to_json(Obj,"parameterType",parameterType);
field_to_json(Obj,"parameterValue",parameterValue);
field_to_json(Obj,"modified",modified);
}
bool ConfigurationOverride::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
field_from_json(Obj,"source",source);
field_from_json(Obj,"reason",reason);
field_from_json(Obj,"parameterName",parameterName);
field_from_json(Obj,"parameterType",parameterType);
field_from_json(Obj,"parameterValue",parameterValue);
field_from_json(Obj,"modified",modified);
return true;
} catch(...) {
}
return false;
}
void ConfigurationOverrideList::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj,"serialNumber",serialNumber);
field_to_json(Obj,"managementPolicy",managementPolicy);
field_to_json(Obj,"overrides",overrides);
}
bool ConfigurationOverrideList::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
field_from_json(Obj,"serialNumber",serialNumber);
field_from_json(Obj,"managementPolicy",managementPolicy);
field_from_json(Obj,"overrides",overrides);
return true;
} catch(...) {
}
return false;
}
}

View File

@@ -8,7 +8,8 @@
#pragma once
#include "RESTObjects/RESTAPI_SecurityObjects.h"
#include <string>
#include "RESTAPI_SecurityObjects.h"
namespace OpenWifi::ProvObjects {
@@ -428,7 +429,6 @@ namespace OpenWifi::ProvObjects {
std::string devClass;
std::string locale;
std::string realMacAddress;
bool doNotAllowOverrides=false;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
@@ -694,27 +694,6 @@ namespace OpenWifi::ProvObjects {
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
struct ConfigurationOverride {
std::string source;
std::string reason;
std::string parameterName;
std::string parameterType;
std::string parameterValue;
std::uint64_t modified;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
struct ConfigurationOverrideList {
std::string serialNumber;
Types::UUID_t managementPolicy;
std::vector<ConfigurationOverride> overrides;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
bool UpdateObjectInfo(const Poco::JSON::Object::Ptr &O, const SecurityObjects::UserInfo &U, ObjectInfo &I);
bool CreateObjectInfo(const Poco::JSON::Object::Ptr &O, const SecurityObjects::UserInfo &U, ObjectInfo &I);
bool CreateObjectInfo(const SecurityObjects::UserInfo &U, ObjectInfo &I);

View File

@@ -9,7 +9,7 @@
#include "Poco/JSON/Parser.h"
#include "Poco/JSON/Stringifier.h"
#include "framework/RESTAPI_utils.h"
#include "framework/MicroService.h"
#include "RESTAPI_SecurityObjects.h"
using OpenWifi::RESTAPI_utils::field_to_json;
@@ -433,7 +433,7 @@ namespace OpenWifi::SecurityObjects {
SecurityObjects::NoteInfoVec NIV;
NIV = RESTAPI_utils::to_object_array<SecurityObjects::NoteInfo>(Obj->get("notes").toString());
for(auto const &i:NIV) {
SecurityObjects::NoteInfo ii{.created=(uint64_t)Utils::Now(), .createdBy=UInfo.email, .note=i.note};
SecurityObjects::NoteInfo ii{.created=(uint64_t)OpenWifi::Now(), .createdBy=UInfo.email, .note=i.note};
Notes.push_back(ii);
}
}
@@ -446,7 +446,7 @@ namespace OpenWifi::SecurityObjects {
bool MergeNotes(const NoteInfoVec & NewNotes, const UserInfo &UInfo, NoteInfoVec & ExistingNotes) {
for(auto const &i:NewNotes) {
SecurityObjects::NoteInfo ii{.created=(uint64_t)Utils::Now(), .createdBy=UInfo.email, .note=i.note};
SecurityObjects::NoteInfo ii{.created=(uint64_t)OpenWifi::Now(), .createdBy=UInfo.email, .note=i.note};
ExistingNotes.push_back(ii);
}
return true;
@@ -619,80 +619,5 @@ namespace OpenWifi::SecurityObjects {
field_to_json(Obj,"login",login);
field_to_json(Obj,"logout",logout);
}
void ApiKeyAccessRight::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj, "service", service);
field_to_json(Obj, "access", access);
}
bool ApiKeyAccessRight::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
field_from_json(Obj, "service", service);
field_from_json(Obj, "access", access);
return true;
} catch(...) {
std::cout << "Cannot parse: Token" << std::endl;
}
return false;
}
void ApiKeyAccessRightList::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj, "acls", acls);
}
bool ApiKeyAccessRightList::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
field_from_json(Obj, "acls", acls);
return true;
} catch(...) {
std::cout << "Cannot parse: Token" << std::endl;
}
return false;
}
void ApiKeyEntry::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj, "id", id);
field_to_json(Obj, "userUuid", userUuid);
field_to_json(Obj, "name", name);
field_to_json(Obj, "apiKey", apiKey);
field_to_json(Obj, "salt", salt);
field_to_json(Obj, "description", description);
field_to_json(Obj, "expiresOn", expiresOn);
field_to_json(Obj, "rights", rights);
field_to_json(Obj, "lastUse", lastUse);
}
bool ApiKeyEntry::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
field_from_json(Obj, "id", id);
field_from_json(Obj, "userUuid", userUuid);
field_from_json(Obj, "name", name);
field_from_json(Obj, "apiKey", apiKey);
field_from_json(Obj, "salt", salt);
field_from_json(Obj, "description", description);
field_from_json(Obj, "expiresOn", expiresOn);
field_from_json(Obj, "rights", rights);
field_from_json(Obj, "lastUse", lastUse);
return true;
} catch(...) {
std::cout << "Cannot parse: Token" << std::endl;
}
return false;
}
void ApiKeyEntryList::to_json(Poco::JSON::Object &Obj) const {
field_to_json(Obj, "apiKeys", apiKeys);
}
bool ApiKeyEntryList::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
field_from_json(Obj, "apiKeys", apiKeys);
return true;
} catch(...) {
std::cout << "Cannot parse: Token" << std::endl;
}
return false;
}
}

View File

@@ -14,7 +14,6 @@
#include "Poco/JSON/Object.h"
#include "Poco/Data/LOB.h"
#include "Poco/Data/LOBStream.h"
#include "framework/utils.h"
namespace OpenWifi {
uint64_t Now();
@@ -63,7 +62,7 @@ namespace OpenWifi {
std::string UserTypeToString(USER_ROLE U);
struct NoteInfo {
uint64_t created=0; // = Utils::Now();
uint64_t created=0; // = OpenWifi::Now();
std::string createdBy;
std::string note;
@@ -102,7 +101,7 @@ namespace OpenWifi {
std::string uuid;
std::string question;
std::string method;
uint64_t created = Utils::Now();
uint64_t created = OpenWifi::Now();
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
@@ -252,8 +251,7 @@ namespace OpenWifi {
VERIFY_EMAIL,
SUB_FORGOT_PASSWORD,
SUB_VERIFY_EMAIL,
SUB_SIGNUP,
EMAIL_INVITATION
SUB_SIGNUP
};
struct ActionLink {
@@ -265,7 +263,7 @@ namespace OpenWifi {
std::string locale;
std::string message;
uint64_t sent=0;
uint64_t created=Utils::Now();
uint64_t created=OpenWifi::Now();
uint64_t expires=0;
uint64_t completed=0;
uint64_t canceled=0;
@@ -325,44 +323,5 @@ namespace OpenWifi {
void to_json(Poco::JSON::Object &Obj) const;
};
struct ApiKeyAccessRight {
std::string service;
std::string access;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
struct ApiKeyAccessRightList {
std::vector<ApiKeyAccessRight> acls;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
struct ApiKeyEntry {
Types::UUID_t id;
Types::UUID_t userUuid;
std::string name;
std::string description;
std::string apiKey;
std::string salt;
std::uint64_t created;
std::uint64_t expiresOn=0;
ApiKeyAccessRightList rights;
std::uint64_t lastUse=0;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
struct ApiKeyEntryList {
std::vector<ApiKeyEntry> apiKeys;
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
}
}

View File

@@ -3,11 +3,12 @@
//
#include "RESTAPI_SubObjects.h"
#include "framework/RESTAPI_utils.h"
#include "framework/MicroService.h"
using OpenWifi::RESTAPI_utils::field_to_json;
using OpenWifi::RESTAPI_utils::field_from_json;
namespace OpenWifi::SubObjects {
void HomeDeviceMode::to_json(Poco::JSON::Object &Obj) const {

View File

@@ -2,9 +2,11 @@
// Created by stephane bourque on 2021-08-11.
//
#include "SerialNumberCache.h"
#include "framework/utils.h"
#include <mutex>
#include "StorageService.h"
#include "framework/MicroService.h"
namespace OpenWifi {

View File

@@ -4,8 +4,7 @@
#pragma once
#include <mutex>
#include "framework/SubSystemServer.h"
#include "framework/MicroService.h"
namespace OpenWifi {
class SerialNumberCache : public SubSystemServer {

View File

@@ -5,15 +5,12 @@
#include "Signup.h"
#include "StorageService.h"
#include "sdks/SDK_gw.h"
#include "framework/MicroServiceFuncs.h"
#include "framework/utils.h"
namespace OpenWifi {
int Signup::Start() {
poco_information(Logger(),"Starting...");
GracePeriod_ = MicroServiceConfigGetInt("signup.graceperiod", 60*60);
LingerPeriod_ = MicroServiceConfigGetInt("signup.lingerperiod", 24*60*60);
GracePeriod_ = MicroService::instance().ConfigGetInt("signup.graceperiod", 60*60);
LingerPeriod_ = MicroService::instance().ConfigGetInt("signup.lingerperiod", 24*60*60);
SignupDB::RecordVec Signups_;
StorageService()->SignupDB().GetIncompleteSignups(Signups_);
@@ -32,12 +29,10 @@ namespace OpenWifi {
}
void Signup::Stop() {
poco_information(Logger(),"Stopping...");
Running_ = false;
Timer_.stop();
Worker_.wakeUp();
Worker_.join();
poco_information(Logger(),"Stopped...");
}
void Signup::onTimer([[maybe_unused]] Poco::Timer &timer) {
@@ -73,7 +68,7 @@ namespace OpenWifi {
// We must now complete the device transfer to this new subscriber and complete the
// signup job.
IT.subscriber = SE.userId;
IT.info.modified = Utils::Now();
IT.info.modified = OpenWifi::Now();
IT.realMacAddress = SE.macAddress;
if(IT.entity.empty()) {
@@ -82,7 +77,7 @@ namespace OpenWifi {
}
Poco::JSON::Object NewState;
NewState.set("method", "signup");
NewState.set("date", Utils::Now());
NewState.set("date", OpenWifi::Now());
NewState.set("status", "completed");
std::ostringstream OS;
NewState.stringify(OS);
@@ -91,8 +86,8 @@ namespace OpenWifi {
// we need to move this device to the SubscriberDevice DB
ProvObjects::SubscriberDevice SD;
SD.info.id = MicroServiceCreateUUID();
SD.info.modified = SD.info.created = Utils::Now();
SD.info.id = MicroService::CreateUUID();
SD.info.modified = SD.info.created = OpenWifi::Now();
SD.info.name = IT.realMacAddress;
SD.operatorId = SE.operatorId;
SD.serialNumber = SerialNumber;
@@ -102,26 +97,26 @@ namespace OpenWifi {
SD.state = OS.str();
SD.subscriberId = SE.userId;
poco_information(Logger(),fmt::format("Setting service class for {}",SD.serialNumber));
Logger().information(fmt::format("Setting service class for {}",SD.serialNumber));
SD.serviceClass = StorageService()->ServiceClassDB().DefaultForOperator(SE.operatorId);
poco_information(Logger(),fmt::format("Removing old device information for {}",SD.serialNumber));
Logger().information(fmt::format("Removing old device information for {}",SD.serialNumber));
StorageService()->SubscriberDeviceDB().DeleteRecord("serialNumber", SD.serialNumber);
poco_information(Logger(),fmt::format("Creating subscriber device for {}",SD.serialNumber));
Logger().information(fmt::format("Creating subscriber device for {}",SD.serialNumber));
StorageService()->SubscriberDeviceDB().CreateRecord(SD);
poco_information(Logger(),fmt::format("Removing old inventory for {}",SD.serialNumber));
Logger().information(fmt::format("Removing old inventory for {}",SD.serialNumber));
StorageService()->InventoryDB().DeleteRecord("serialNumber", SD.serialNumber);
SE.status = "signup completed";
SE.serialNumber = SerialNumber;
SE.statusCode = ProvObjects::SignupStatusCodes::SignupSuccess;
SE.completed = Utils::Now();
SE.info.modified = Utils::Now();
SE.completed = OpenWifi::Now();
SE.info.modified = OpenWifi::Now();
SE.error = 0;
poco_information(Logger(),fmt::format("Completed signup for {}",SD.serialNumber));
Logger().information(fmt::format("Completed signup for {}",SD.serialNumber));
StorageService()->SignupDB().UpdateRecord("id", SE.info.id, SE);
poco_information(Logger(),fmt::format("Setting GW subscriber for {}",SD.serialNumber));
Logger().information(fmt::format("Setting GW subscriber for {}",SD.serialNumber));
SDK::GW::Device::SetSubscriber(SerialNumber, IT.subscriber);
poco_information(Logger(),fmt::format("Success for {}",SD.serialNumber));
Logger().information(fmt::format("Success for {}",SD.serialNumber));
break;
}
}

View File

@@ -4,7 +4,7 @@
#pragma once
#include "framework/SubSystemServer.h"
#include "framework/MicroService.h"
#include "RESTObjects/RESTAPI_ProvObjects.h"
#include "Poco/Timer.h"

View File

@@ -8,13 +8,10 @@
#include "StorageService.h"
#include "RESTObjects/RESTAPI_ProvObjects.h"
#include "framework/utils.h"
#include "fmt/format.h"
namespace OpenWifi {
int Storage::Start() {
poco_information(Logger(),"Starting...");
std::lock_guard Guard(Mutex_);
StorageClass::Start();
@@ -37,7 +34,6 @@ namespace OpenWifi {
SubscriberDeviceDB_ = std::make_unique<OpenWifi::SubscriberDeviceDB>(dbType_, *Pool_, Logger());
OpLocationDB_ = std::make_unique<OpenWifi::OpLocationDB>(dbType_, *Pool_, Logger());
OpContactDB_ = std::make_unique<OpenWifi::OpContactDB>(dbType_, *Pool_, Logger());
OverridesDB_ = std::make_unique<OpenWifi::OverridesDB>(dbType_, *Pool_, Logger());
EntityDB_->Create();
PolicyDB_->Create();
@@ -57,7 +53,6 @@ namespace OpenWifi {
SubscriberDeviceDB_->Create();
OpLocationDB_->Create();
OpContactDB_->Create();
OverridesDB_->Create();
ExistFunc_[EntityDB_->Prefix()] = [=](const char *F, std::string &V) -> bool { return EntityDB_->Exists(F,V); };
ExistFunc_[PolicyDB_->Prefix()] = [=](const char *F, std::string &V) -> bool { return PolicyDB_->Exists(F,V); };
@@ -77,7 +72,6 @@ namespace OpenWifi {
ExistFunc_[SubscriberDeviceDB_->Prefix()] = [=](const char *F, std::string &V) ->bool { return SubscriberDeviceDB_->Exists(F,V); };
ExistFunc_[OpLocationDB_->Prefix()] = [=](const char *F, std::string &V) ->bool { return OpLocationDB_->Exists(F,V); };
ExistFunc_[OpContactDB_->Prefix()] = [=](const char *F, std::string &V) ->bool { return OpContactDB_->Exists(F,V); };
ExistFunc_[OverridesDB_->Prefix()] = [=](const char *F, std::string &V) ->bool { return OverridesDB_->Exists(F,V); };
ExpandFunc_[EntityDB_->Prefix()] = [=](const char *F, std::string &V, std::string &Name, std::string & Description) -> bool { return EntityDB_->GetNameAndDescription(F,V, Name, Description); };
ExpandFunc_[PolicyDB_->Prefix()] = [=](const char *F, std::string &V, std::string &Name, std::string & Description) -> bool { return PolicyDB_->GetNameAndDescription(F,V, Name, Description); };
@@ -97,7 +91,6 @@ namespace OpenWifi {
ExpandFunc_[SubscriberDeviceDB_->Prefix()] = [=](const char *F, std::string &V, std::string &Name, std::string & Description) ->bool { return SubscriberDeviceDB_->GetNameAndDescription(F,V, Name, Description); };
ExpandFunc_[OpLocationDB_->Prefix()] = [=](const char *F, std::string &V, std::string &Name, std::string & Description) ->bool { return OpLocationDB_->GetNameAndDescription(F,V, Name, Description); };
ExpandFunc_[OpContactDB_->Prefix()] = [=](const char *F, std::string &V, std::string &Name, std::string & Description) ->bool { return OpContactDB_->GetNameAndDescription(F,V, Name, Description); };
ExpandFunc_[OverridesDB_->Prefix()] = [=]( [[maybe_unused]] const char *F, [[maybe_unused]] std::string &V, [[maybe_unused]] std::string &Name, [[maybe_unused]] std::string & Description) ->bool { return false; };
InventoryDB_->InitializeSerialCache();
@@ -116,9 +109,8 @@ namespace OpenWifi {
}
void Storage::Stop() {
poco_information(Logger(),"Stopping...");
Timer_.stop();
poco_information(Logger(),"Stopped...");
Logger().notice("Stopping.");
}
bool Storage::Validate(const Poco::URI::QueryParameters &P, RESTAPI::Errors::msg &Error) {
@@ -220,7 +212,7 @@ namespace OpenWifi {
}
if(modified) {
poco_warning(Logger(),fmt::format(" fixing venue: {}", V.info.name));
Logger().warning(fmt::format(" fixing venue: {}", V.info.name));
NewVenue.devices = NewDevices;
VenueDB().UpdateRecord("id", V.info.id, NewVenue);
}
@@ -289,7 +281,7 @@ namespace OpenWifi {
if(Modified)
{
poco_warning(Logger(),fmt::format(" fixing entity: {}",E.info.name));
Logger().warning(fmt::format(" fixing entity: {}",E.info.name));
NewEntity.devices = NewDevices;
NewEntity.contacts = NewContacts;
NewEntity.locations = NewLocations;
@@ -330,7 +322,7 @@ namespace OpenWifi {
}
if(modified) {
poco_warning(Logger(),fmt::format(" fixing entity: {}",T.info.name));
Logger().warning(fmt::format(" fixing entity: {}",T.info.name));
InventoryDB().UpdateRecord("id", T.info.id, NewTag);
}
return true;
@@ -347,7 +339,7 @@ namespace OpenWifi {
}
if (modified) {
poco_warning(Logger(),fmt::format(" fixing configuration: {}", C.info.name));
Logger().warning(fmt::format(" fixing configuration: {}", C.info.name));
ConfigurationDB().UpdateRecord("id", C.info.id, NewConfig);
}
return true;
@@ -363,7 +355,7 @@ namespace OpenWifi {
}
if (modified) {
poco_warning(Logger(),fmt::format(" fixing operator: {}", O.info.name));
Logger().warning(fmt::format(" fixing operator: {}", O.info.name));
OperatorDB().UpdateRecord("id", O.info.id, NewOp);
}
return true;
@@ -379,23 +371,23 @@ namespace OpenWifi {
}
if (modified) {
poco_warning(Logger(),fmt::format(" fixing subscriber: {}", O.info.name));
Logger().warning(fmt::format(" fixing subscriber: {}", O.info.name));
SubscriberDeviceDB().UpdateRecord("id", O.info.id, NewSub);
}
return true;
};
poco_information(Logger(),"Checking DB consistency: venues");
Logger().information("Checking DB consistency: venues");
VenueDB().Iterate(FixVenueDevices);
poco_information(Logger(),"Checking DB consistency: entities");
Logger().information("Checking DB consistency: entities");
EntityDB().Iterate(FixEntity);
poco_information(Logger(),"Checking DB consistency: inventory");
Logger().information("Checking DB consistency: inventory");
InventoryDB().Iterate(FixInventory);
poco_information(Logger(),"Checking DB consistency: configurations");
Logger().information("Checking DB consistency: configurations");
ConfigurationDB().Iterate(FixConfiguration);
poco_information(Logger(),"Checking DB consistency: operators");
Logger().information("Checking DB consistency: operators");
OperatorDB().Iterate(FixOperator);
poco_information(Logger(),"Checking DB consistency: subscribers");
Logger().information("Checking DB consistency: subscribers");
SubscriberDeviceDB().Iterate(FixSubscriber);
}
@@ -405,7 +397,7 @@ namespace OpenWifi {
Root.info.id = EntityDB::RootUUID();
Root.info.name = "Top Entity";
Root.info.created = Root.info.modified = Utils::Now();
Root.info.created = Root.info.modified = OpenWifi::Now();
Root.deviceRules.rrm = "off";
EntityDB().CreateRecord(Root);
}
@@ -413,18 +405,18 @@ namespace OpenWifi {
auto OperatorCount = OperatorDB().Count();
if(OperatorCount==0) {
ProvObjects::Operator DefOp;
DefOp.info.id = MicroServiceCreateUUID();
DefOp.info.id = MicroService::CreateUUID();
DefOp.info.name = "Default Operator";
DefOp.defaultOperator = true;
DefOp.info.created = DefOp.info.modified = Utils::Now();
DefOp.info.created = DefOp.info.modified = OpenWifi::Now();
DefOp.deviceRules.rrm = "inherit";
OperatorDB_->CreateRecord(DefOp);
ProvObjects::ServiceClass DefSer;
DefSer.info.id = MicroServiceCreateUUID();
DefSer.info.id = MicroService::CreateUUID();
DefSer.info.name = "Default Service Class";
DefSer.defaultService = true;
DefSer.info.created = DefSer.info.modified = Utils::Now();
DefSer.info.created = DefSer.info.modified = OpenWifi::Now();
DefSer.operatorId = DefOp.info.id;
DefSer.period = "monthly";
DefSer.billingCode = "basic";

View File

@@ -8,8 +8,9 @@
#pragma once
#include "framework/MicroService.h"
#include "framework/StorageClass.h"
#include "framework/MicroServiceFuncs.h"
#include "storage/storage_entity.h"
#include "storage/storage_policies.h"
#include "storage/storage_venue.h"
@@ -27,10 +28,6 @@
#include "storage/storage_operataor.h"
#include "storage/storage_service_class.h"
#include "storage/storage_sub_devices.h"
#include "storage/storage_overrides.h"
#include "Poco/URI.h"
#include "framework/ow_constants.h"
namespace OpenWifi {
@@ -65,7 +62,6 @@ namespace OpenWifi {
OpenWifi::SubscriberDeviceDB & SubscriberDeviceDB() { return *SubscriberDeviceDB_; };
OpenWifi::OpLocationDB & OpLocationDB() { return *OpLocationDB_; };
OpenWifi::OpContactDB & OpContactDB() { return *OpContactDB_; };
OpenWifi::OverridesDB & OverridesDB() { return *OverridesDB_; };
bool Validate(const Poco::URI::QueryParameters &P, RESTAPI::Errors::msg &Error);
bool Validate(const Types::StringVec &P, std::string &Error);
@@ -91,11 +87,11 @@ namespace OpenWifi {
static inline bool ApplyConfigRules(ProvObjects::DeviceRules & R_res) {
if(R_res.firmwareUpgrade=="inherit")
R_res.firmwareUpgrade=MicroServiceConfigGetString("firmware.updater.upgrade","yes");
R_res.firmwareUpgrade=MicroService::instance().ConfigGetString("firmware.updater.upgrade","yes");
if(R_res.rcOnly=="inherit")
R_res.rcOnly=MicroServiceConfigGetString("firmware.updater.releaseonly","yes");
R_res.rcOnly=MicroService::instance().ConfigGetString("firmware.updater.releaseonly","yes");
if(R_res.rrm=="inherit")
R_res.rrm=MicroServiceConfigGetString("rrm.default","no");
R_res.rrm=MicroService::instance().ConfigGetString("rrm.default","no");
return true;
}
@@ -118,7 +114,6 @@ namespace OpenWifi {
std::unique_ptr<OpenWifi::SubscriberDeviceDB> SubscriberDeviceDB_;
std::unique_ptr<OpenWifi::OpLocationDB> OpLocationDB_;
std::unique_ptr<OpenWifi::OpContactDB> OpContactDB_;
std::unique_ptr<OpenWifi::OverridesDB> OverridesDB_;
std::string DefaultOperator_;

View File

@@ -4,7 +4,6 @@
#include "TagServer.h"
#include "StorageService.h"
#include "framework/utils.h"
namespace OpenWifi {
int TagServer::Start() {

View File

@@ -4,7 +4,7 @@
#pragma once
#include "framework/SubSystemServer.h"
#include "framework/MicroService.h"
namespace OpenWifi {

View File

@@ -4,12 +4,12 @@
#pragma once
#include "framework/MicroService.h"
#include "StorageService.h"
#include "APConfig.h"
#include "sdks/SDK_gw.h"
#include "framework/WebSocketClientNotifications.h"
#include "JobController.h"
#include "framework/MicroServiceFuncs.h"
#include "UI_Prov_WebSocketNotifications.h"
namespace OpenWifi {
@@ -48,24 +48,24 @@ namespace OpenWifi {
std::ostringstream OS;
Configuration->stringify(OS);
auto Response = Poco::makeShared<Poco::JSON::Object>();
poco_debug(Logger(),fmt::format("{}: Pushing configuration.", Device.serialNumber));
Logger().debug(fmt::format("{}: Pushing configuration.", Device.serialNumber));
if (SDK::GW::Device::Configure(nullptr, Device.serialNumber, Configuration, Response)) {
Logger().debug(fmt::format("{}: Configuration pushed.", Device.serialNumber));
poco_information(Logger(),fmt::format("{}: Updated.", Device.serialNumber));
Logger().information(fmt::format("{}: Updated.", Device.serialNumber));
// std::cout << Device.serialNumber << ": Updated" << std::endl;
updated_++;
} else {
poco_information(Logger(),fmt::format("{}: Not updated.", Device.serialNumber));
Logger().information(fmt::format("{}: Not updated.", Device.serialNumber));
// std::cout << Device.serialNumber << ": Failed" << std::endl;
failed_++;
}
} else {
poco_debug(Logger(),fmt::format("{}: Configuration is bad.", Device.serialNumber));
Logger().debug(fmt::format("{}: Configuration is bad.", Device.serialNumber));
bad_config_++;
// std::cout << Device.serialNumber << ": Bad config" << std::endl;
}
} catch (...) {
poco_debug(Logger(),fmt::format("{}: Configuration is bad (caused an exception).", Device.serialNumber));
Logger().debug(fmt::format("{}: Configuration is bad (caused an exception).", Device.serialNumber));
bad_config_++;
}
}
@@ -99,7 +99,7 @@ namespace OpenWifi {
Utils::SetThreadName("venue-update");
VenueUUID_ = Parameter(0);
ProvWebSocketNotifications::ConfigUpdateList_t N;
WebSocketNotification<WebSocketNotificationJobContent> N;
ProvObjects::Venue Venue;
uint64_t Updated = 0, Failed = 0 , BadConfigs = 0 ;
@@ -145,7 +145,7 @@ namespace OpenWifi {
}
}
poco_debug(Logger(),"Waiting for outstanding update threads to finish.");
Logger().debug("Waiting for outstanding update threads to finish.");
Pool_.joinAll();
for(auto job_it = JobList.begin(); job_it !=JobList.end();) {
VenueDeviceConfigUpdater * current_job = *job_it;
@@ -172,12 +172,12 @@ namespace OpenWifi {
} else {
N.content.details = fmt::format("Venue {} no longer exists.",VenueUUID_);
poco_warning(Logger(),N.content.details);
Logger().warning(N.content.details);
}
// std::cout << N.content.details << std::endl;
ProvWebSocketNotifications::VenueConfigUpdateCompletion(UserInfo().email, N);
poco_information(Logger(),fmt::format("Job {} Completed: {} updated, {} failed to update , {} bad configurations.",
WebSocketClientNotificationVenueUpdateJobCompletionToUser(UserInfo().email, N);
Logger().information(fmt::format("Job {} Completed: {} updated, {} failed to update , {} bad configurations.",
JobId(), Updated ,Failed, BadConfigs));
Utils::SetThreadName("free");
Complete();

View File

@@ -2,12 +2,13 @@
// Created by stephane bourque on 2022-05-04.
//
#include "framework/MicroService.h"
#include "framework/WebSocketClientNotifications.h"
#include "StorageService.h"
#include "APConfig.h"
#include "sdks/SDK_gw.h"
#include "JobController.h"
#include "framework/MicroServiceFuncs.h"
#include "UI_Prov_WebSocketNotifications.h"
namespace OpenWifi {
@@ -28,7 +29,7 @@ namespace OpenWifi {
Logger().debug(fmt::format("{}: Rebooted.",Device.serialNumber));
rebooted_++;
} else {
poco_information(Logger(),fmt::format("{}: Not rebooted.", Device.serialNumber));
Logger().information(fmt::format("{}: Not rebooted.", Device.serialNumber));
failed_++;
}
}
@@ -59,7 +60,7 @@ namespace OpenWifi {
Utils::SetThreadName("venue-reboot");
ProvWebSocketNotifications::VenueRebootList_t N;
WebSocketClientNotificationVenueRebootList_t N;
auto VenueUUID_ = Parameter(0);
ProvObjects::Venue Venue;
@@ -127,8 +128,8 @@ namespace OpenWifi {
}
// std::cout << N.content.details << std::endl;
ProvWebSocketNotifications::VenueRebootCompletion(UserInfo().email,N);
poco_information(Logger(),fmt::format("Job {} Completed: {} rebooted, {} failed to reboot.",
WebSocketClientNotificationVenueRebootCompletionToUser(UserInfo().email,N);
Logger().information(fmt::format("Job {} Completed: {} rebooted, {} failed to reboot.",
JobId(), rebooted_ ,failed_));
Utils::SetThreadName("free");
Complete();

View File

@@ -4,13 +4,14 @@
#pragma once
#include "framework/MicroService.h"
#include "framework/WebSocketClientNotifications.h"
#include "StorageService.h"
#include "APConfig.h"
#include "sdks/SDK_gw.h"
#include "sdks/SDK_fms.h"
#include "JobController.h"
#include "framework/MicroServiceFuncs.h"
#include "UI_Prov_WebSocketNotifications.h"
namespace OpenWifi {
class VenueDeviceUpgrade : public Poco::Runnable {
@@ -42,11 +43,11 @@ namespace OpenWifi {
Logger().debug(fmt::format("{}: Upgraded.",Device.serialNumber));
upgraded_++;
} else {
poco_information(Logger(),fmt::format("{}: Not Upgraded.", Device.serialNumber));
Logger().information(fmt::format("{}: Not Upgraded.", Device.serialNumber));
not_connected_++;
}
} else {
poco_information(Logger(),fmt::format("{}: Not Upgraded. No firmware available.", Device.serialNumber));
Logger().information(fmt::format("{}: Not Upgraded. No firmware available.", Device.serialNumber));
no_firmware_++;
}
}
@@ -82,7 +83,7 @@ namespace OpenWifi {
Utils::SetThreadName("venue-upgr");
auto VenueUUID_ = Parameter(0);
ProvWebSocketNotifications::VenueFWUpgradeList_t N;
WebSocketClientNotificationVenueUpgradeList_t N;
ProvObjects::Venue Venue;
uint64_t upgraded_ = 0,
@@ -171,8 +172,8 @@ namespace OpenWifi {
}
// std::cout << N.content.details << std::endl;
ProvWebSocketNotifications::VenueFWUpgradeCompletion(UserInfo().email,N);
poco_information(Logger(),N.content.details);
WebSocketClientNotificationVenueUpgradeCompletionToUser(UserInfo().email,N);
Logger().information(N.content.details);
Utils::SetThreadName("free");
Complete();
}

View File

@@ -1,127 +0,0 @@
//
// Created by stephane bourque on 2022-10-29.
//
#include "UI_Prov_WebSocketNotifications.h"
namespace OpenWifi::ProvWebSocketNotifications {
void ConfigUpdateList::to_json(Poco::JSON::Object &Obj) const {
RESTAPI_utils::field_to_json(Obj,"title",title);
RESTAPI_utils::field_to_json(Obj,"jobId",jobId);
RESTAPI_utils::field_to_json(Obj,"success",success);
RESTAPI_utils::field_to_json(Obj,"error",error);
RESTAPI_utils::field_to_json(Obj,"warning",warning);
RESTAPI_utils::field_to_json(Obj,"timeStamp",timeStamp);
RESTAPI_utils::field_to_json(Obj,"details",details);
}
bool ConfigUpdateList::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
RESTAPI_utils::field_from_json(Obj,"title",title);
RESTAPI_utils::field_from_json(Obj,"jobId",jobId);
RESTAPI_utils::field_from_json(Obj,"success",success);
RESTAPI_utils::field_from_json(Obj,"error",error);
RESTAPI_utils::field_from_json(Obj,"warning",warning);
RESTAPI_utils::field_from_json(Obj,"timeStamp",timeStamp);
RESTAPI_utils::field_from_json(Obj,"details",details);
return true;
} catch(...) {
}
return false;
}
void RebootList::to_json(Poco::JSON::Object &Obj) const {
RESTAPI_utils::field_to_json(Obj,"title",title);
RESTAPI_utils::field_to_json(Obj,"jobId",jobId);
RESTAPI_utils::field_to_json(Obj,"success",success);
RESTAPI_utils::field_to_json(Obj,"warning",warning);
RESTAPI_utils::field_to_json(Obj,"timeStamp",timeStamp);
RESTAPI_utils::field_to_json(Obj,"details",details);
}
bool RebootList::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
RESTAPI_utils::field_from_json(Obj,"title",title);
RESTAPI_utils::field_from_json(Obj,"jobId",jobId);
RESTAPI_utils::field_from_json(Obj,"success",success);
RESTAPI_utils::field_from_json(Obj,"warning",warning);
RESTAPI_utils::field_from_json(Obj,"timeStamp",timeStamp);
RESTAPI_utils::field_from_json(Obj,"details",details);
return true;
} catch(...) {
}
return false;
}
void FWUpgradeList::to_json(Poco::JSON::Object &Obj) const {
RESTAPI_utils::field_to_json(Obj,"title",title);
RESTAPI_utils::field_to_json(Obj,"jobId",jobId);
RESTAPI_utils::field_to_json(Obj,"success",success);
RESTAPI_utils::field_to_json(Obj,"notConnected",not_connected);
RESTAPI_utils::field_to_json(Obj,"noFirmware",no_firmware);
RESTAPI_utils::field_to_json(Obj,"skipped",skipped);
RESTAPI_utils::field_to_json(Obj,"timeStamp",timeStamp);
RESTAPI_utils::field_to_json(Obj,"details",details);
}
bool FWUpgradeList::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
RESTAPI_utils::field_from_json(Obj,"title",title);
RESTAPI_utils::field_from_json(Obj,"jobId",jobId);
RESTAPI_utils::field_from_json(Obj,"success",success);
RESTAPI_utils::field_from_json(Obj,"notConnected",not_connected);
RESTAPI_utils::field_from_json(Obj,"noFirmware",no_firmware);
RESTAPI_utils::field_from_json(Obj,"skipped",skipped);
RESTAPI_utils::field_from_json(Obj,"timeStamp",timeStamp);
RESTAPI_utils::field_from_json(Obj,"details",details);
return true;
} catch(...) {
}
return false;
}
void Register() {
static const UI_WebSocketClientServer::NotificationTypeIdVec Notifications = {
{ 1000, "venue_fw_upgrade" },
{ 2000, "venue_config_update" },
{ 3000, "venue_rebooter" }
};
UI_WebSocketClientServer()->RegisterNotifications(Notifications);
}
void VenueFWUpgradeCompletion( VenueFWUpgradeList_t &N) {
N.type_id = 1000 ;
UI_WebSocketClientServer()->SendNotification(N);
}
void VenueFWUpgradeCompletion( const std::string & User, VenueFWUpgradeList_t &N) {
N.type_id = 1000 ;
UI_WebSocketClientServer()->SendUserNotification(User,N);
}
void VenueConfigUpdateCompletion( ConfigUpdateList_t &N) {
N.type_id = 2000 ;
UI_WebSocketClientServer()->SendNotification(N);
}
void VenueConfigUpdateCompletion( const std::string & User, ConfigUpdateList_t &N) {
N.type_id = 2000 ;
UI_WebSocketClientServer()->SendUserNotification(User,N);
}
void VenueRebootCompletion( VenueRebootList_t &N) {
N.type_id = 3000 ;
UI_WebSocketClientServer()->SendNotification(N);
}
void VenueRebootCompletion( const std::string & User, VenueRebootList_t &N) {
N.type_id = 3000 ;
UI_WebSocketClientServer()->SendUserNotification(User,N);
}
} // namespace OpenWifi

View File

@@ -1,68 +0,0 @@
//
// Created by stephane bourque on 2022-10-29.
//
#pragma once
#include "framework/UI_WebSocketClientNotifications.h"
#include "framework/UI_WebSocketClientServer.h"
namespace OpenWifi::ProvWebSocketNotifications {
struct ConfigUpdateList {
std::string title,
details,
jobId;
std::vector<std::string> success,
error,
warning;
uint64_t timeStamp=OpenWifi::Utils::Now();
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
typedef WebSocketNotification<ConfigUpdateList> ConfigUpdateList_t;
struct RebootList {
std::string title,
details,
jobId;
std::vector<std::string> success,
warning;
uint64_t timeStamp=OpenWifi::Utils::Now();
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
typedef WebSocketNotification<RebootList> VenueRebootList_t;
struct FWUpgradeList {
std::string title,
details,
jobId;
std::vector<std::string> success,
skipped,
no_firmware,
not_connected;
uint64_t timeStamp = OpenWifi::Utils::Now();
void to_json(Poco::JSON::Object &Obj) const;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
typedef WebSocketNotification<FWUpgradeList> VenueFWUpgradeList_t;
void Register();
void VenueFWUpgradeCompletion( const std::string & User, VenueFWUpgradeList_t &N);
void VenueFWUpgradeCompletion( VenueFWUpgradeList_t &N);
void VenueConfigUpdateCompletion( const std::string & User, ConfigUpdateList_t &N);
void VenueConfigUpdateCompletion( ConfigUpdateList_t &N);
void VenueRebootCompletion( const std::string & User, VenueRebootList_t &N);
void VenueRebootCompletion( VenueRebootList_t &N);
}
// namespace OpenWifi

View File

@@ -1,77 +0,0 @@
//
// Created by stephane bourque on 2022-10-25.
//
#include "ALBserver.h"
#include "framework/utils.h"
#include "framework/MicroServiceFuncs.h"
#include "fmt/format.h"
namespace OpenWifi {
void ALBRequestHandler::handleRequest([[maybe_unused]] Poco::Net::HTTPServerRequest& Request, Poco::Net::HTTPServerResponse& Response) {
Utils::SetThreadName("alb-request");
try {
if((id_ % 100) == 0) {
Logger_.debug(fmt::format("ALB-REQUEST({}): ALB Request {}.", Request.clientAddress().toString(), id_));
}
Response.setChunkedTransferEncoding(true);
Response.setContentType("text/html");
Response.setDate(Poco::Timestamp());
Response.setStatus(Poco::Net::HTTPResponse::HTTP_OK);
Response.setKeepAlive(true);
Response.set("Connection", "keep-alive");
Response.setVersion(Poco::Net::HTTPMessage::HTTP_1_1);
std::ostream &Answer = Response.send();
Answer << "process Alive and kicking!";
} catch (...) {
}
}
ALBRequestHandlerFactory::ALBRequestHandlerFactory(Poco::Logger & L):
Logger_(L) {
}
ALBRequestHandler* ALBRequestHandlerFactory::createRequestHandler(const Poco::Net::HTTPServerRequest& request) {
if (request.getURI() == "/")
return new ALBRequestHandler(Logger_, req_id_++);
else
return nullptr;
}
ALBHealthCheckServer::ALBHealthCheckServer() :
SubSystemServer("ALBHealthCheckServer", "ALB-SVR", "alb")
{
}
int ALBHealthCheckServer::Start() {
if(MicroServiceConfigGetBool("alb.enable",false)) {
poco_information(Logger(),"Starting...");
Running_=true;
Port_ = (int)MicroServiceConfigGetInt("alb.port",15015);
Poco::Net::IPAddress Addr(Poco::Net::IPAddress::wildcard(
Poco::Net::Socket::supportsIPv6() ? Poco::Net::AddressFamily::IPv6
: Poco::Net::AddressFamily::IPv4));
Poco::Net::SocketAddress SockAddr(Addr, Port_);
Poco::Net::ServerSocket ClientSocket(SockAddr, 64);
Socket_ = std::make_unique<Poco::Net::ServerSocket>(SockAddr, Port_);
auto Params = new Poco::Net::HTTPServerParams;
Params->setName("ws:alb");
Server_ = std::make_unique<Poco::Net::HTTPServer>(new ALBRequestHandlerFactory(Logger()), *Socket_, Params);
Server_->start();
}
return 0;
}
void ALBHealthCheckServer::Stop() {
poco_information(Logger(),"Stopping...");
if(Running_)
Server_->stopAll(true);
poco_information(Logger(),"Stopped...");
}
} // namespace OpenWifi

View File

@@ -1,63 +0,0 @@
//
// Created by stephane bourque on 2022-10-25.
//
#pragma once
#include "framework/SubSystemServer.h"
#include "Poco/Net/HTTPRequestHandler.h"
#include "Poco/Net/HTTPServerRequest.h"
#include "Poco/Net/HTTPServerResponse.h"
#include "Poco/Net/HTTPRequestHandlerFactory.h"
#include "Poco/Net/HTTPServer.h"
namespace OpenWifi {
class ALBRequestHandler: public Poco::Net::HTTPRequestHandler {
public:
explicit ALBRequestHandler(Poco::Logger & L, uint64_t id)
: Logger_(L), id_(id) {
}
void handleRequest([[maybe_unused]] Poco::Net::HTTPServerRequest& Request, Poco::Net::HTTPServerResponse& Response) override;
private:
Poco::Logger & Logger_;
uint64_t id_;
};
class ALBRequestHandlerFactory: public Poco::Net::HTTPRequestHandlerFactory
{
public:
explicit ALBRequestHandlerFactory(Poco::Logger & L);
ALBRequestHandler* createRequestHandler(const Poco::Net::HTTPServerRequest& request) override;
private:
Poco::Logger &Logger_;
inline static std::atomic_uint64_t req_id_=1;
};
class ALBHealthCheckServer : public SubSystemServer {
public:
ALBHealthCheckServer();
static auto instance() {
static auto instance = new ALBHealthCheckServer;
return instance;
}
int Start() override;
void Stop() override;
private:
std::unique_ptr<Poco::Net::HTTPServer> Server_;
std::unique_ptr<Poco::Net::ServerSocket> Socket_;
int Port_ = 0;
mutable std::atomic_bool Running_=false;
};
inline auto ALBHealthCheckServer() { return ALBHealthCheckServer::instance(); }
} // namespace OpenWifi

Some files were not shown because too many files have changed in this diff Show More