mirror of
https://github.com/Telecominfraproject/wlan-cloud-owprov.git
synced 2025-10-30 18:18:03 +00:00
Compare commits
206 Commits
v2.6.0-RC1
...
v2.8.0-RC1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8e96afaf27 | ||
|
|
ba36df0182 | ||
|
|
ac5c8bf531 | ||
|
|
513fa9264b | ||
|
|
8d6a9f6d5b | ||
|
|
8b249f6f92 | ||
|
|
93da8d1229 | ||
|
|
4d3ed84e5c | ||
|
|
4b104c961a | ||
|
|
db367133a8 | ||
|
|
5baf3b1b19 | ||
|
|
6a923375ad | ||
|
|
39b1352d4e | ||
|
|
df9d05bd69 | ||
|
|
ca63e3cae6 | ||
|
|
fe14eaac58 | ||
|
|
5172d95aac | ||
|
|
5e2ab7a37b | ||
|
|
12ff4adc41 | ||
|
|
6e88403685 | ||
|
|
174b209065 | ||
|
|
0d380f9585 | ||
|
|
c249911f9c | ||
|
|
1cc9ef6466 | ||
|
|
6aee513a45 | ||
|
|
66ca992fee | ||
|
|
cd216c7949 | ||
|
|
1f0366335b | ||
|
|
38b4d82e79 | ||
|
|
601c75bccb | ||
|
|
325801b583 | ||
|
|
b1fba48ed1 | ||
|
|
9ab2b5ee60 | ||
|
|
7a5d484932 | ||
|
|
f623368923 | ||
|
|
188ecabd33 | ||
|
|
5326fbf390 | ||
|
|
6ee055adff | ||
|
|
5d66fe0d56 | ||
|
|
378ff98bfb | ||
|
|
01cbb382d1 | ||
|
|
1cba12b934 | ||
|
|
9b8de5efd2 | ||
|
|
01d7a048dd | ||
|
|
da31483c78 | ||
|
|
a22fac8b86 | ||
|
|
fe50daf627 | ||
|
|
711f1808d8 | ||
|
|
23aa41dd8d | ||
|
|
30385a5cc3 | ||
|
|
0145aa3e52 | ||
|
|
97575715a3 | ||
|
|
125800e78a | ||
|
|
606a806d62 | ||
|
|
46b5daed8f | ||
|
|
d1edab2bcf | ||
|
|
2bf972cec6 | ||
|
|
d706dba60a | ||
|
|
8b23197359 | ||
|
|
4f4dcc9071 | ||
|
|
a30b4e1dae | ||
|
|
21aa3ef685 | ||
|
|
a6a9daa8a1 | ||
|
|
5b546ea381 | ||
|
|
be8805e86d | ||
|
|
efe9076c35 | ||
|
|
4a55483f90 | ||
|
|
af336e5ddf | ||
|
|
222674ae1b | ||
|
|
ec684090ae | ||
|
|
c0004dc804 | ||
|
|
d08d64ae27 | ||
|
|
9a9d25f045 | ||
|
|
fdded83221 | ||
|
|
8a98844bac | ||
|
|
a9105f06aa | ||
|
|
ac885295ae | ||
|
|
5a0132e174 | ||
|
|
9daee84f88 | ||
|
|
d7469cf0b7 | ||
|
|
8d8d52adf2 | ||
|
|
c5e44f2a98 | ||
|
|
5c2937c7ec | ||
|
|
a8f1483362 | ||
|
|
5abe7a9909 | ||
|
|
0a3a9a4b20 | ||
|
|
9d4eb1e502 | ||
|
|
51ba962338 | ||
|
|
fef07e3150 | ||
|
|
03a6675359 | ||
|
|
19686da4d8 | ||
|
|
c5997a3511 | ||
|
|
3feb5fd666 | ||
|
|
d3cd3a1a21 | ||
|
|
5e6228b9d6 | ||
|
|
ad526ebf1d | ||
|
|
8de53277e6 | ||
|
|
93fbb3017a | ||
|
|
2e4d1ad3e8 | ||
|
|
109a9affc5 | ||
|
|
9c65813735 | ||
|
|
7d0bdf059d | ||
|
|
93e4b069c4 | ||
|
|
4fe1367651 | ||
|
|
5f5f2fd699 | ||
|
|
c2e0d32e0d | ||
|
|
cab81a3930 | ||
|
|
01395f11a3 | ||
|
|
250c12acf1 | ||
|
|
e23d04c1d0 | ||
|
|
b48955e791 | ||
|
|
e58eb38d53 | ||
|
|
791af9aeba | ||
|
|
67081917a9 | ||
|
|
3a33815096 | ||
|
|
f515bb8e30 | ||
|
|
02fd6d726a | ||
|
|
27ffb31a7c | ||
|
|
5fd9831d6b | ||
|
|
fed085cc4a | ||
|
|
121fee841e | ||
|
|
4c6f03ba14 | ||
|
|
0fb9478675 | ||
|
|
97c2af83fd | ||
|
|
599ba0793c | ||
|
|
6df780dba3 | ||
|
|
a00287ae85 | ||
|
|
c7a300b81e | ||
|
|
5dc507a82e | ||
|
|
8b3e1326b7 | ||
|
|
667f8bc4bd | ||
|
|
6cacebad28 | ||
|
|
e487b68945 | ||
|
|
ffddfa87d2 | ||
|
|
0168301d6b | ||
|
|
1a0b00e989 | ||
|
|
7c2229f3d6 | ||
|
|
541df429ec | ||
|
|
6f9fe6cd5d | ||
|
|
2594a2c5f2 | ||
|
|
2e02d96523 | ||
|
|
a1375f9468 | ||
|
|
777bc0f2aa | ||
|
|
bd0e99309c | ||
|
|
6cb6a60142 | ||
|
|
fc7947394d | ||
|
|
1341e15874 | ||
|
|
f065815df3 | ||
|
|
03ba51e869 | ||
|
|
efd7ef2a9b | ||
|
|
4b90a6e893 | ||
|
|
f5cb4a5a87 | ||
|
|
e3e4aac202 | ||
|
|
5945d02b3d | ||
|
|
0ac192cdc0 | ||
|
|
1b5eb87eef | ||
|
|
46db18d7cd | ||
|
|
30b8665d7d | ||
|
|
c8b3a3b060 | ||
|
|
096da35ff4 | ||
|
|
bd7f3af11c | ||
|
|
2a06021c4a | ||
|
|
bf18bb25ba | ||
|
|
e93f899b76 | ||
|
|
eda73038f6 | ||
|
|
953ca155a4 | ||
|
|
898806f232 | ||
|
|
7d97b19b85 | ||
|
|
d6c587fde6 | ||
|
|
58c9a7805b | ||
|
|
94dd4c84e9 | ||
|
|
2636715f6f | ||
|
|
f9f4624add | ||
|
|
cf441de197 | ||
|
|
158455a528 | ||
|
|
4d2ccec1a8 | ||
|
|
7dad5a9bdb | ||
|
|
cd2ac84c5b | ||
|
|
9735f709e9 | ||
|
|
ae5fd31818 | ||
|
|
2b46ad4a66 | ||
|
|
43d7078cb7 | ||
|
|
18f5d42f00 | ||
|
|
70622b2bb8 | ||
|
|
5b24aea47c | ||
|
|
e97617a0db | ||
|
|
ba63a7033f | ||
|
|
e9db2e1a0d | ||
|
|
d85fef7725 | ||
|
|
543c46bf68 | ||
|
|
73eec53fe4 | ||
|
|
8ad2d67c2c | ||
|
|
442f810688 | ||
|
|
2dca5204ea | ||
|
|
dc2abe2154 | ||
|
|
8c14bb5b3a | ||
|
|
6ec4bc7115 | ||
|
|
9883a40ec6 | ||
|
|
cc647b8108 | ||
|
|
3b0f2a0977 | ||
|
|
dfefe39188 | ||
|
|
7d65e19d29 | ||
|
|
1e16c59743 | ||
|
|
4582cbd133 | ||
|
|
18e4b68c1f | ||
|
|
46a11ebda2 |
8
.github/workflows/ci.yml
vendored
8
.github/workflows/ci.yml
vendored
@@ -27,7 +27,7 @@ jobs:
|
|||||||
DOCKER_REGISTRY_USERNAME: ucentral
|
DOCKER_REGISTRY_USERNAME: ucentral
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout actions repo
|
- name: Checkout actions repo
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
repository: Telecominfraproject/.github
|
repository: Telecominfraproject/.github
|
||||||
path: github
|
path: github
|
||||||
@@ -58,11 +58,11 @@ jobs:
|
|||||||
- name: Get base branch name and set as output
|
- name: Get base branch name and set as output
|
||||||
id: get_base_branch
|
id: get_base_branch
|
||||||
run: |
|
run: |
|
||||||
echo ::set-output name=branch::$(echo ${GITHUB_BASE_REF##*/})
|
echo "branch=$(echo ${GITHUB_BASE_REF##*/})" >> $GITHUB_OUTPUT
|
||||||
echo ::set-output name=owgw_branch::$(echo ${GITHUB_BASE_REF##*/} | sed 's/main/master/g')
|
echo "owgw_branch=$(echo ${GITHUB_BASE_REF##*/} | sed 's/main/master/g')" >> $GITHUB_OUTPUT
|
||||||
|
|
||||||
- name: Checkout actions repo
|
- name: Checkout actions repo
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
repository: Telecominfraproject/.github
|
repository: Telecominfraproject/.github
|
||||||
path: github
|
path: github
|
||||||
|
|||||||
8
.github/workflows/cleanup.yml
vendored
8
.github/workflows/cleanup.yml
vendored
@@ -17,4 +17,10 @@ jobs:
|
|||||||
steps:
|
steps:
|
||||||
- run: |
|
- run: |
|
||||||
export PR_BRANCH_TAG=$(echo ${GITHUB_HEAD_REF#refs/heads/} | tr '/' '-')
|
export PR_BRANCH_TAG=$(echo ${GITHUB_HEAD_REF#refs/heads/} | tr '/' '-')
|
||||||
curl -uucentral:${{ secrets.DOCKER_REGISTRY_PASSWORD }} -X DELETE "https://tip.jfrog.io/artifactory/tip-wlan-cloud-ucentral/owprov/$PR_BRANCH_TAG"
|
|
||||||
|
if [[ ! $PR_BRANCH_TAG =~ (main|master|release-*) ]]; then
|
||||||
|
echo "PR branch is $PR_BRANCH_TAG, deleting Docker image"
|
||||||
|
curl -s -uucentral:${{ secrets.DOCKER_REGISTRY_PASSWORD }} -X DELETE "https://tip.jfrog.io/artifactory/tip-wlan-cloud-ucentral/owprov/$PR_BRANCH_TAG"
|
||||||
|
else
|
||||||
|
echo "PR branch is $PR_BRANCH_TAG, not deleting Docker image"
|
||||||
|
fi
|
||||||
|
|||||||
2
.github/workflows/enforce-jira-issue-key.yml
vendored
2
.github/workflows/enforce-jira-issue-key.yml
vendored
@@ -11,7 +11,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout actions repo
|
- name: Checkout actions repo
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
repository: Telecominfraproject/.github
|
repository: Telecominfraproject/.github
|
||||||
path: github
|
path: github
|
||||||
|
|||||||
41
.github/workflows/openapi-pages.yml
vendored
Normal file
41
.github/workflows/openapi-pages.yml
vendored
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
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
|
||||||
2
.github/workflows/release.yml
vendored
2
.github/workflows/release.yml
vendored
@@ -17,7 +17,7 @@ jobs:
|
|||||||
HELM_REPO_USERNAME: ucentral
|
HELM_REPO_USERNAME: ucentral
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout uCentral assembly chart repo
|
- name: Checkout uCentral assembly chart repo
|
||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v3
|
||||||
with:
|
with:
|
||||||
path: wlan-cloud-owprov
|
path: wlan-cloud-owprov
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
cmake_minimum_required(VERSION 3.13)
|
cmake_minimum_required(VERSION 3.13)
|
||||||
project(owprov VERSION 2.6.0)
|
project(owprov VERSION 2.8.0)
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 17)
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
@@ -27,12 +27,12 @@ endif()
|
|||||||
|
|
||||||
find_package(Git QUIET)
|
find_package(Git QUIET)
|
||||||
if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
|
if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git")
|
||||||
execute_process(COMMAND ${GIT_EXECUTABLE} describe --always --tags
|
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD
|
||||||
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
||||||
RESULT_VARIABLE GIT_RESULT
|
RESULT_VARIABLE GIT_RESULT
|
||||||
OUTPUT_VARIABLE GIT_HASH)
|
OUTPUT_VARIABLE GIT_HASH)
|
||||||
if(NOT GIT_RESULT EQUAL "0")
|
if(NOT GIT_RESULT EQUAL "0")
|
||||||
message(FATAL_ERROR "git describe --always --tags failed with ${GIT_RESULT}")
|
message(FATAL_ERROR "git rev-parse --short HEAD failed with ${GIT_RESULT}")
|
||||||
endif()
|
endif()
|
||||||
string(REGEX REPLACE "\n$" "" GIT_HASH "${GIT_HASH}")
|
string(REGEX REPLACE "\n$" "" GIT_HASH "${GIT_HASH}")
|
||||||
endif()
|
endif()
|
||||||
@@ -40,6 +40,7 @@ endif()
|
|||||||
add_definitions(-DAWS_CUSTOM_MEMORY_MANAGEMENT)
|
add_definitions(-DAWS_CUSTOM_MEMORY_MANAGEMENT)
|
||||||
|
|
||||||
find_package(OpenSSL REQUIRED)
|
find_package(OpenSSL REQUIRED)
|
||||||
|
find_package(ZLIB REQUIRED)
|
||||||
find_package(Poco REQUIRED COMPONENTS Crypto JWT Net Util NetSSL Data DataSQLite)
|
find_package(Poco REQUIRED COMPONENTS Crypto JWT Net Util NetSSL Data DataSQLite)
|
||||||
find_package(nlohmann_json REQUIRED)
|
find_package(nlohmann_json REQUIRED)
|
||||||
find_package(nlohmann_json_schema_validator REQUIRED)
|
find_package(nlohmann_json_schema_validator REQUIRED)
|
||||||
@@ -58,6 +59,8 @@ include_directories(/usr/local/include /usr/local/opt/openssl/include src inclu
|
|||||||
|
|
||||||
configure_file(src/ow_version.h.in ${PROJECT_SOURCE_DIR}/src/ow_version.h @ONLY)
|
configure_file(src/ow_version.h.in ${PROJECT_SOURCE_DIR}/src/ow_version.h @ONLY)
|
||||||
|
|
||||||
|
add_definitions(-DPOCO_LOG_DEBUG="1")
|
||||||
|
|
||||||
add_compile_options(-Wall -Wextra)
|
add_compile_options(-Wall -Wextra)
|
||||||
if(ASAN)
|
if(ASAN)
|
||||||
add_compile_options(-fsanitize=address)
|
add_compile_options(-fsanitize=address)
|
||||||
@@ -73,14 +76,58 @@ add_executable(owprov
|
|||||||
src/framework/OpenWifiTypes.h
|
src/framework/OpenWifiTypes.h
|
||||||
src/framework/orm.h
|
src/framework/orm.h
|
||||||
src/framework/StorageClass.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.cpp
|
||||||
src/framework/ConfigurationValidator.h
|
src/framework/ConfigurationValidator.h
|
||||||
src/framework/ow_constants.h
|
src/UI_Prov_WebSocketNotifications.h
|
||||||
src/framework/WebSocketClientNotifications.h
|
src/UI_Prov_WebSocketNotifications.cpp
|
||||||
src/RESTObjects/RESTAPI_SecurityObjects.h src/RESTObjects/RESTAPI_SecurityObjects.cpp
|
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_GWobjects.h src/RESTObjects/RESTAPI_GWobjects.cpp
|
||||||
src/RESTObjects/RESTAPI_FMSObjects.h src/RESTObjects/RESTAPI_FMSObjects.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/RESTAPI/RESTAPI_routers.cpp
|
||||||
src/Daemon.cpp src/Daemon.h
|
src/Daemon.cpp src/Daemon.h
|
||||||
src/Dashboard.h src/Dashboard.cpp
|
src/Dashboard.h src/Dashboard.cpp
|
||||||
@@ -125,7 +172,6 @@ add_executable(owprov
|
|||||||
src/RESTAPI/RESTAPI_db_helpers.h
|
src/RESTAPI/RESTAPI_db_helpers.h
|
||||||
src/JobController.cpp src/JobController.h
|
src/JobController.cpp src/JobController.h
|
||||||
src/JobRegistrations.cpp
|
src/JobRegistrations.cpp
|
||||||
src/storage/storage_jobs.cpp src/storage/storage_jobs.h
|
|
||||||
src/storage/storage_maps.cpp src/storage/storage_maps.h
|
src/storage/storage_maps.cpp src/storage/storage_maps.h
|
||||||
src/RESTAPI/RESTAPI_map_handler.cpp src/RESTAPI/RESTAPI_map_handler.h
|
src/RESTAPI/RESTAPI_map_handler.cpp src/RESTAPI/RESTAPI_map_handler.h
|
||||||
src/RESTAPI/RESTAPI_map_list_handler.cpp src/RESTAPI/RESTAPI_map_list_handler.h
|
src/RESTAPI/RESTAPI_map_list_handler.cpp src/RESTAPI/RESTAPI_map_list_handler.h
|
||||||
@@ -135,7 +181,29 @@ add_executable(owprov
|
|||||||
src/storage/storage_variables.cpp src/storage/storage_variables.h
|
src/storage/storage_variables.cpp src/storage/storage_variables.h
|
||||||
src/RESTAPI/RESTAPI_variables_handler.cpp src/RESTAPI/RESTAPI_variables_handler.h
|
src/RESTAPI/RESTAPI_variables_handler.cpp src/RESTAPI/RESTAPI_variables_handler.h
|
||||||
src/RESTAPI/RESTAPI_variables_list_handler.cpp src/RESTAPI/RESTAPI_variables_list_handler.h
|
src/RESTAPI/RESTAPI_variables_list_handler.cpp src/RESTAPI/RESTAPI_variables_list_handler.h
|
||||||
src/FileDownloader.cpp src/FileDownloader.h src/Tasks/VenueConfigUpdater.h src/Kafka_ProvUpdater.cpp src/Kafka_ProvUpdater.h 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/FileDownloader.cpp src/FileDownloader.h
|
||||||
|
src/Tasks/VenueConfigUpdater.h
|
||||||
|
src/libs/croncpp.h
|
||||||
|
src/Kafka_ProvUpdater.cpp src/Kafka_ProvUpdater.h
|
||||||
|
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)
|
||||||
|
|
||||||
target_link_libraries(owprov PUBLIC
|
target_link_libraries(owprov PUBLIC
|
||||||
${Poco_LIBRARIES}
|
${Poco_LIBRARIES}
|
||||||
|
|||||||
66
Dockerfile
66
Dockerfile
@@ -1,16 +1,22 @@
|
|||||||
FROM alpine:3.15 AS build-base
|
ARG DEBIAN_VERSION=11.5-slim
|
||||||
|
ARG POCO_VERSION=poco-tip-v2
|
||||||
|
ARG CPPKAFKA_VERSION=tip-v1
|
||||||
|
ARG JSON_VALIDATOR_VERSION=2.1.0
|
||||||
|
|
||||||
RUN apk add --update --no-cache \
|
FROM debian:$DEBIAN_VERSION AS build-base
|
||||||
|
|
||||||
|
RUN apt-get update && apt-get install --no-install-recommends -y \
|
||||||
make cmake g++ git \
|
make cmake g++ git \
|
||||||
unixodbc-dev postgresql-dev mariadb-dev \
|
libpq-dev libmariadb-dev libmariadbclient-dev-compat \
|
||||||
librdkafka-dev boost-dev openssl-dev \
|
librdkafka-dev libboost-all-dev libssl-dev \
|
||||||
zlib-dev nlohmann-json \
|
zlib1g-dev nlohmann-json3-dev ca-certificates libcurl4-openssl-dev libfmt-dev
|
||||||
curl-dev
|
|
||||||
|
|
||||||
FROM build-base AS poco-build
|
FROM build-base AS poco-build
|
||||||
|
|
||||||
ADD https://api.github.com/repos/stephb9959/poco/git/refs/heads/master version.json
|
ARG POCO_VERSION
|
||||||
RUN git clone https://github.com/stephb9959/poco /poco
|
|
||||||
|
ADD https://api.github.com/repos/AriliaWireless/poco/git/refs/tags/${POCO_VERSION} version.json
|
||||||
|
RUN git clone https://github.com/AriliaWireless/poco --branch ${POCO_VERSION} /poco
|
||||||
|
|
||||||
WORKDIR /poco
|
WORKDIR /poco
|
||||||
RUN mkdir cmake-build
|
RUN mkdir cmake-build
|
||||||
@@ -21,8 +27,10 @@ RUN cmake --build . --target install
|
|||||||
|
|
||||||
FROM build-base AS cppkafka-build
|
FROM build-base AS cppkafka-build
|
||||||
|
|
||||||
ADD https://api.github.com/repos/stephb9959/cppkafka/git/refs/heads/master version.json
|
ARG CPPKAFKA_VERSION
|
||||||
RUN git clone https://github.com/stephb9959/cppkafka /cppkafka
|
|
||||||
|
ADD https://api.github.com/repos/AriliaWireless/cppkafka/git/refs/tags/${CPPKAFKA_VERSION} version.json
|
||||||
|
RUN git clone https://github.com/AriliaWireless/cppkafka --branch ${CPPKAFKA_VERSION} /cppkafka
|
||||||
|
|
||||||
WORKDIR /cppkafka
|
WORKDIR /cppkafka
|
||||||
RUN mkdir cmake-build
|
RUN mkdir cmake-build
|
||||||
@@ -33,8 +41,10 @@ RUN cmake --build . --target install
|
|||||||
|
|
||||||
FROM build-base AS json-schema-validator-build
|
FROM build-base AS json-schema-validator-build
|
||||||
|
|
||||||
ADD https://api.github.com/repos/pboettch/json-schema-validator/git/refs/heads/master version.json
|
ARG JSON_VALIDATOR_VERSION
|
||||||
RUN git clone https://github.com/pboettch/json-schema-validator /json-schema-validator
|
|
||||||
|
ADD https://api.github.com/repos/pboettch/json-schema-validator/git/refs/tags/${JSON_VALIDATOR_VERSION} version.json
|
||||||
|
RUN git clone https://github.com/pboettch/json-schema-validator --branch ${JSON_VALIDATOR_VERSION} /json-schema-validator
|
||||||
|
|
||||||
WORKDIR /json-schema-validator
|
WORKDIR /json-schema-validator
|
||||||
RUN mkdir cmake-build
|
RUN mkdir cmake-build
|
||||||
@@ -43,18 +53,6 @@ RUN cmake ..
|
|||||||
RUN make
|
RUN make
|
||||||
RUN make install
|
RUN make install
|
||||||
|
|
||||||
FROM build-base AS fmtlib-build
|
|
||||||
|
|
||||||
ADD https://api.github.com/repos/fmtlib/fmt/git/refs/heads/master version.json
|
|
||||||
RUN git clone https://github.com/fmtlib/fmt /fmtlib
|
|
||||||
|
|
||||||
WORKDIR /fmtlib
|
|
||||||
RUN mkdir cmake-build
|
|
||||||
WORKDIR cmake-build
|
|
||||||
RUN cmake ..
|
|
||||||
RUN make
|
|
||||||
RUN make install
|
|
||||||
|
|
||||||
FROM build-base AS owprov-build
|
FROM build-base AS owprov-build
|
||||||
|
|
||||||
ADD CMakeLists.txt build /owprov/
|
ADD CMakeLists.txt build /owprov/
|
||||||
@@ -68,8 +66,6 @@ COPY --from=cppkafka-build /usr/local/include /usr/local/include
|
|||||||
COPY --from=cppkafka-build /usr/local/lib /usr/local/lib
|
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/include /usr/local/include
|
||||||
COPY --from=json-schema-validator-build /usr/local/lib /usr/local/lib
|
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
|
WORKDIR /owprov
|
||||||
RUN mkdir cmake-build
|
RUN mkdir cmake-build
|
||||||
@@ -77,21 +73,21 @@ WORKDIR /owprov/cmake-build
|
|||||||
RUN cmake ..
|
RUN cmake ..
|
||||||
RUN cmake --build . --config Release -j8
|
RUN cmake --build . --config Release -j8
|
||||||
|
|
||||||
FROM alpine:3.15
|
FROM debian:$DEBIAN_VERSION
|
||||||
|
|
||||||
ENV OWPROV_USER=owprov \
|
ENV OWPROV_USER=owprov \
|
||||||
OWPROV_ROOT=/owprov-data \
|
OWPROV_ROOT=/owprov-data \
|
||||||
OWPROV_CONFIG=/owprov-data
|
OWPROV_CONFIG=/owprov-data
|
||||||
|
|
||||||
RUN addgroup -S "$OWPROV_USER" && \
|
RUN useradd "$OWPROV_USER"
|
||||||
adduser -S -G "$OWPROV_USER" "$OWPROV_USER"
|
|
||||||
|
|
||||||
RUN mkdir /openwifi
|
RUN mkdir /openwifi
|
||||||
RUN mkdir -p "$OWPROV_ROOT" "$OWPROV_CONFIG" && \
|
RUN mkdir -p "$OWPROV_ROOT" "$OWPROV_CONFIG" && \
|
||||||
chown "$OWPROV_USER": "$OWPROV_ROOT" "$OWPROV_CONFIG"
|
chown "$OWPROV_USER": "$OWPROV_ROOT" "$OWPROV_CONFIG"
|
||||||
|
|
||||||
RUN apk add --update --no-cache librdkafka su-exec gettext ca-certificates bash jq curl \
|
RUN apt-get update && apt-get install --no-install-recommends -y \
|
||||||
mariadb-connector-c libpq unixodbc postgresql-client
|
librdkafka++1 gosu gettext ca-certificates bash jq curl wget \
|
||||||
|
libmariadb-dev-compat libpq5 postgresql-client libfmt7
|
||||||
|
|
||||||
COPY readiness_check /readiness_check
|
COPY readiness_check /readiness_check
|
||||||
COPY test_scripts/curl/cli /cli
|
COPY test_scripts/curl/cli /cli
|
||||||
@@ -100,11 +96,13 @@ COPY owprov.properties.tmpl /
|
|||||||
COPY docker-entrypoint.sh /
|
COPY docker-entrypoint.sh /
|
||||||
COPY wait-for-postgres.sh /
|
COPY wait-for-postgres.sh /
|
||||||
RUN wget https://raw.githubusercontent.com/Telecominfraproject/wlan-cloud-ucentral-deploy/main/docker-compose/certs/restapi-ca.pem \
|
RUN wget https://raw.githubusercontent.com/Telecominfraproject/wlan-cloud-ucentral-deploy/main/docker-compose/certs/restapi-ca.pem \
|
||||||
-O /usr/local/share/ca-certificates/restapi-ca-selfsigned.pem
|
-O /usr/local/share/ca-certificates/restapi-ca-selfsigned.crt
|
||||||
|
|
||||||
COPY --from=owprov-build /owprov/cmake-build/owprov /openwifi/owprov
|
COPY --from=owprov-build /owprov/cmake-build/owprov /openwifi/owprov
|
||||||
COPY --from=cppkafka-build /cppkafka/cmake-build/src/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
|
COPY --from=poco-build /poco/cmake-build/lib/* /usr/local/lib/
|
||||||
|
|
||||||
|
RUN ldconfig
|
||||||
|
|
||||||
EXPOSE 16005 17005 16105
|
EXPOSE 16005 17005 16105
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,10 @@
|
|||||||
# OpenWiFi Provisioning
|
# 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.
|
## Build from source.
|
||||||
You need:
|
You need:
|
||||||
- https://github.com/pboettch/json-schema-validator.git
|
- https://github.com/pboettch/json-schema-validator.git
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
if [ "$SELFSIGNED_CERTS" = 'true' ]; then
|
if [ "$SELFSIGNED_CERTS" = 'true' ]; then
|
||||||
update-ca-certificates
|
update-ca-certificates
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ "$TEMPLATE_CONFIG" = 'true' && ! -f "$OWPROV_CONFIG"/owprov.properties ]]; then
|
if [[ "$TEMPLATE_CONFIG" = 'true' ]]; then
|
||||||
RESTAPI_HOST_ROOTCA=${RESTAPI_HOST_ROOTCA:-"\$OWPROV_ROOT/certs/restapi-ca.pem"} \
|
RESTAPI_HOST_ROOTCA=${RESTAPI_HOST_ROOTCA:-"\$OWPROV_ROOT/certs/restapi-ca.pem"} \
|
||||||
RESTAPI_HOST_PORT=${RESTAPI_HOST_PORT:-"16005"} \
|
RESTAPI_HOST_PORT=${RESTAPI_HOST_PORT:-"16005"} \
|
||||||
RESTAPI_HOST_CERT=${RESTAPI_HOST_CERT:-"\$OWPROV_ROOT/certs/restapi-cert.pem"} \
|
RESTAPI_HOST_CERT=${RESTAPI_HOST_CERT:-"\$OWPROV_ROOT/certs/restapi-cert.pem"} \
|
||||||
@@ -24,6 +24,7 @@ if [[ "$TEMPLATE_CONFIG" = 'true' && ! -f "$OWPROV_CONFIG"/owprov.properties ]];
|
|||||||
SYSTEM_URI_PRIVATE=${SYSTEM_URI_PRIVATE:-"https://localhost:17005"} \
|
SYSTEM_URI_PRIVATE=${SYSTEM_URI_PRIVATE:-"https://localhost:17005"} \
|
||||||
SYSTEM_URI_PUBLIC=${SYSTEM_URI_PUBLIC:-"https://localhost:16005"} \
|
SYSTEM_URI_PUBLIC=${SYSTEM_URI_PUBLIC:-"https://localhost:16005"} \
|
||||||
SYSTEM_URI_UI=${SYSTEM_URI_UI:-"http://localhost"} \
|
SYSTEM_URI_UI=${SYSTEM_URI_UI:-"http://localhost"} \
|
||||||
|
SECURITY_RESTAPI_DISABLE=${SECURITY_RESTAPI_DISABLE:-"false"} \
|
||||||
KAFKA_ENABLE=${KAFKA_ENABLE:-"true"} \
|
KAFKA_ENABLE=${KAFKA_ENABLE:-"true"} \
|
||||||
KAFKA_BROKERLIST=${KAFKA_BROKERLIST:-"localhost:9092"} \
|
KAFKA_BROKERLIST=${KAFKA_BROKERLIST:-"localhost:9092"} \
|
||||||
KAFKA_SSL_CA_LOCATION=${KAFKA_SSL_CA_LOCATION:-""} \
|
KAFKA_SSL_CA_LOCATION=${KAFKA_SSL_CA_LOCATION:-""} \
|
||||||
@@ -48,7 +49,7 @@ if [ "$1" = '/openwifi/owprov' -a "$(id -u)" = '0' ]; then
|
|||||||
if [ "$RUN_CHOWN" = 'true' ]; then
|
if [ "$RUN_CHOWN" = 'true' ]; then
|
||||||
chown -R "$OWPROV_USER": "$OWPROV_ROOT" "$OWPROV_CONFIG"
|
chown -R "$OWPROV_USER": "$OWPROV_ROOT" "$OWPROV_CONFIG"
|
||||||
fi
|
fi
|
||||||
exec su-exec "$OWPROV_USER" "$@"
|
exec gosu "$OWPROV_USER" "$@"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
exec "$@"
|
exec "$@"
|
||||||
|
|||||||
2
helm/.gitignore
vendored
2
helm/.gitignore
vendored
@@ -1 +1,3 @@
|
|||||||
*.swp
|
*.swp
|
||||||
|
Chart.lock
|
||||||
|
charts/
|
||||||
|
|||||||
@@ -70,8 +70,8 @@ The following table lists the configurable parameters of the chart and their def
|
|||||||
| persistence.size | string | Defines PV size | `'10Gi'` |
|
| persistence.size | string | Defines PV size | `'10Gi'` |
|
||||||
| public_env_variables | hash | Defines list of environment variables to be passed to the Provisioning | |
|
| public_env_variables | hash | Defines list of environment variables to be passed to the Provisioning | |
|
||||||
| configProperties | hash | Configuration properties that should be passed to the application in `owprov.properties`. May be passed by key in set (i.e. `configProperties."rtty\.token"`) | |
|
| configProperties | hash | Configuration properties that should be passed to the application in `owprov.properties`. May be passed by key in set (i.e. `configProperties."rtty\.token"`) | |
|
||||||
| certs | hash | Defines files (keys and certificates) that should be passed to the Provisioning (PEM format is adviced to be used) (see `volumes.owprov` on where it is mounted) | |
|
| existingCertsSecret | string | Existing Kubernetes secret containing all required certificates and private keys for microservice operation. If set, certificates from `certs` key are ignored | `""` |
|
||||||
|
| certs | hash | Defines files (keys and certificates) that should be passed to the Gateway (PEM format is adviced to be used) (see `volumes.owprov` on where it is mounted). If `existingCertsSecret` is set, certificates passed this way will not be used. | |
|
||||||
|
|
||||||
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example,
|
Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example,
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
{{- $root := . -}}
|
{{- $root := . -}}
|
||||||
|
{{- $storageType := index .Values.configProperties "storage.type" -}}
|
||||||
---
|
---
|
||||||
apiVersion: apps/v1
|
apiVersion: apps/v1
|
||||||
kind: Deployment
|
kind: Deployment
|
||||||
@@ -46,6 +47,39 @@ spec:
|
|||||||
- -timeout
|
- -timeout
|
||||||
- 600s
|
- 600s
|
||||||
|
|
||||||
|
{{- if eq $storageType "postgresql" }}
|
||||||
|
- name: wait-postgres
|
||||||
|
image: "{{ .Values.images.owprov.repository }}:{{ .Values.images.owprov.tag }}"
|
||||||
|
imagePullPolicy: {{ .Values.images.owprov.pullPolicy }}
|
||||||
|
command:
|
||||||
|
- /wait-for-postgres.sh
|
||||||
|
- {{ index .Values.configProperties "storage.type.postgresql.host" }}
|
||||||
|
- echo
|
||||||
|
- "PostgreSQL is ready"
|
||||||
|
env:
|
||||||
|
- name: KUBERNETES_DEPLOYED
|
||||||
|
value: "{{ now }}"
|
||||||
|
{{- range $key, $value := .Values.public_env_variables }}
|
||||||
|
- name: {{ $key }}
|
||||||
|
value: {{ $value | quote }}
|
||||||
|
{{- end }}
|
||||||
|
{{- range $key, $value := .Values.secret_env_variables }}
|
||||||
|
- name: {{ $key }}
|
||||||
|
valueFrom:
|
||||||
|
secretKeyRef:
|
||||||
|
name: {{ include "owprov.fullname" $root }}-env
|
||||||
|
key: {{ $key }}
|
||||||
|
{{- end }}
|
||||||
|
volumeMounts:
|
||||||
|
{{- range .Values.volumes.owprov }}
|
||||||
|
- name: {{ .name }}
|
||||||
|
mountPath: {{ .mountPath }}
|
||||||
|
{{- if .subPath }}
|
||||||
|
subPath: {{ .subPath }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
containers:
|
containers:
|
||||||
|
|
||||||
- name: owprov
|
- name: owprov
|
||||||
@@ -97,8 +131,10 @@ spec:
|
|||||||
{{- toYaml . | nindent 12 }}
|
{{- toYaml . | nindent 12 }}
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
|
{{- with .Values.securityContext }}
|
||||||
securityContext:
|
securityContext:
|
||||||
fsGroup: 101
|
{{- toYaml . | nindent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
|
||||||
imagePullSecrets:
|
imagePullSecrets:
|
||||||
{{- range $image, $imageValue := .Values.images }}
|
{{- range $image, $imageValue := .Values.images }}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ fullnameOverride: ""
|
|||||||
images:
|
images:
|
||||||
owprov:
|
owprov:
|
||||||
repository: tip-tip-wlan-cloud-ucentral.jfrog.io/owprov
|
repository: tip-tip-wlan-cloud-ucentral.jfrog.io/owprov
|
||||||
tag: v2.6.0-RC1
|
tag: v2.8.0-RC1
|
||||||
pullPolicy: Always
|
pullPolicy: Always
|
||||||
# regcred:
|
# regcred:
|
||||||
# registry: tip-tip-wlan-cloud-ucentral.jfrog.io
|
# registry: tip-tip-wlan-cloud-ucentral.jfrog.io
|
||||||
@@ -71,7 +71,7 @@ volumes:
|
|||||||
mountPath: /owprov-data/certs
|
mountPath: /owprov-data/certs
|
||||||
volumeDefinition: |
|
volumeDefinition: |
|
||||||
secret:
|
secret:
|
||||||
secretName: {{ include "owprov.fullname" . }}-certs
|
secretName: {{ if .Values.existingCertsSecret }}{{ .Values.existingCertsSecret }}{{ else }}{{ include "owprov.fullname" . }}-certs{{ end }}
|
||||||
# Change this if you want to use another volume type
|
# Change this if you want to use another volume type
|
||||||
- name: persist
|
- name: persist
|
||||||
mountPath: /owprov-data/persist
|
mountPath: /owprov-data/persist
|
||||||
@@ -91,6 +91,9 @@ resources: {}
|
|||||||
# cpu: 100m
|
# cpu: 100m
|
||||||
# memory: 128Mi
|
# memory: 128Mi
|
||||||
|
|
||||||
|
securityContext:
|
||||||
|
fsGroup: 1000
|
||||||
|
|
||||||
nodeSelector: {}
|
nodeSelector: {}
|
||||||
|
|
||||||
tolerations: []
|
tolerations: []
|
||||||
@@ -199,6 +202,9 @@ configProperties:
|
|||||||
storage.type.mysql.username: stephb
|
storage.type.mysql.username: stephb
|
||||||
storage.type.mysql.password: snoopy99
|
storage.type.mysql.password: snoopy99
|
||||||
|
|
||||||
|
# NOTE: List of required certificates may be found in "certs" key. Alternative way to pass required certificates is to create external secret with all required certificates and set secret name in "existingCertsSecret" key. Details may be found in https://github.com/Telecominfraproject/wlan-cloud-ucentral-deploy/tree/main/chart#tldr
|
||||||
|
existingCertsSecret: ""
|
||||||
|
|
||||||
certs:
|
certs:
|
||||||
# restapi-ca.pem: ""
|
# restapi-ca.pem: ""
|
||||||
# restapi-cert.pem: ""
|
# restapi-cert.pem: ""
|
||||||
|
|||||||
268
openapi/ow_or_ameriband.yaml
Normal file
268
openapi/ow_or_ameriband.yaml
Normal file
@@ -0,0 +1,268 @@
|
|||||||
|
openapi: 3.0.1
|
||||||
|
info:
|
||||||
|
title: OpenWiFi Open roaming Ameriband Provisioning Model
|
||||||
|
description: Registration of an OpenRoaming profile with Ameriband for TIP OpenWifi.
|
||||||
|
version: 1.0.0
|
||||||
|
license:
|
||||||
|
name: BSD3
|
||||||
|
url: https://github.com/Telecominfraproject/wlan-cloud-ucentralgw/blob/master/LICENSE
|
||||||
|
|
||||||
|
servers:
|
||||||
|
- url: 'https://tip.regiatration.ameriband.com:8001/api/v1'
|
||||||
|
|
||||||
|
security:
|
||||||
|
- bearerAuth: []
|
||||||
|
|
||||||
|
components:
|
||||||
|
securitySchemes:
|
||||||
|
bearerAuth:
|
||||||
|
type: http
|
||||||
|
scheme: bearer
|
||||||
|
|
||||||
|
responses:
|
||||||
|
NotFound:
|
||||||
|
description: The specified resource was not found.
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
properties:
|
||||||
|
ErrorCode:
|
||||||
|
type: integer
|
||||||
|
ErrorDetails:
|
||||||
|
type: string
|
||||||
|
ErrorDescription:
|
||||||
|
type: string
|
||||||
|
|
||||||
|
Unauthorized:
|
||||||
|
description: The requested does not have sufficient rights to perform the operation.
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
properties:
|
||||||
|
ErrorCode:
|
||||||
|
type: integer
|
||||||
|
enum:
|
||||||
|
- 0 # Success
|
||||||
|
- 8 # INVALID_TOKEN
|
||||||
|
- 9 # EXPIRED_TOKEN
|
||||||
|
ErrorDetails:
|
||||||
|
type: string
|
||||||
|
ErrorDescription:
|
||||||
|
type: string
|
||||||
|
|
||||||
|
Success:
|
||||||
|
description: The requested operation was performed.
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
properties:
|
||||||
|
Operation:
|
||||||
|
type: string
|
||||||
|
Details:
|
||||||
|
type: string
|
||||||
|
Code:
|
||||||
|
type: integer
|
||||||
|
|
||||||
|
BadRequest:
|
||||||
|
description: The requested operation failed.
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
properties:
|
||||||
|
ErrorCode:
|
||||||
|
type: integer
|
||||||
|
ErrorDetails:
|
||||||
|
type: string
|
||||||
|
ErrorDescription:
|
||||||
|
type: integer
|
||||||
|
|
||||||
|
schemas:
|
||||||
|
RegistrationRequest:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
orgRequestId:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
minLength: 36
|
||||||
|
maxLength: 36
|
||||||
|
example:
|
||||||
|
Client will generate a UUID that must be returned in the response.
|
||||||
|
orgAcceptedTermsAndConditions:
|
||||||
|
type: boolean
|
||||||
|
default: false
|
||||||
|
orgLegalName:
|
||||||
|
type: string
|
||||||
|
minLength: 1
|
||||||
|
orgWebSite:
|
||||||
|
type: string
|
||||||
|
format: url
|
||||||
|
minLength: 1
|
||||||
|
orgContact:
|
||||||
|
type: string
|
||||||
|
minLength: 1
|
||||||
|
example:
|
||||||
|
John Smith
|
||||||
|
orgEmail:
|
||||||
|
type: string
|
||||||
|
format: email
|
||||||
|
minLength: 1
|
||||||
|
orgPhone:
|
||||||
|
type: string
|
||||||
|
example:
|
||||||
|
(607)555-1234 or +1(223)555-1222
|
||||||
|
orgLocation:
|
||||||
|
type: string
|
||||||
|
example:
|
||||||
|
Boston, NH - LA, CA
|
||||||
|
orgCertificate:
|
||||||
|
type: string
|
||||||
|
minLength: 1
|
||||||
|
example:
|
||||||
|
This must be the entire PEM file content of the certificate, encoded using base64
|
||||||
|
|
||||||
|
RegistrationResponse:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
orgRequestId:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
minLength: 36
|
||||||
|
maxLength: 36
|
||||||
|
example:
|
||||||
|
This should be the same orgRequestId passed during registration.
|
||||||
|
orgNASID:
|
||||||
|
type: string
|
||||||
|
minLength: 10
|
||||||
|
description:
|
||||||
|
This is the NASID generated by Ameriband. It will be used by the operator as NASID when contacting Ameriband.
|
||||||
|
ameribandCertificate:
|
||||||
|
type: string
|
||||||
|
minLength: 1
|
||||||
|
example:
|
||||||
|
This must be the entire PEM file content of the certificate, encoded using base64
|
||||||
|
|
||||||
|
RegistrationInformationRequest:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
link:
|
||||||
|
description: This should be the link where a potential registrant can read the terms and conditions of registering with Ameriband.
|
||||||
|
type: string
|
||||||
|
format: url
|
||||||
|
minLength: 1
|
||||||
|
example:
|
||||||
|
https://ameriband.com/romain-registration.html
|
||||||
|
|
||||||
|
paths:
|
||||||
|
/termsAndConditions:
|
||||||
|
get:
|
||||||
|
summary: The registrant must be given a chance to view the terms and conditions of the relationship they are entering into
|
||||||
|
operationId: getTermsAndConditions
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: Sucessfully retrieved Terms and Conditions
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/RegistrationInformationRequest'
|
||||||
|
404:
|
||||||
|
$ref: '#/components/responses/Unauthorized'
|
||||||
|
|
||||||
|
/registration:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- Registration
|
||||||
|
operationId: getRegistrationInformation
|
||||||
|
summary: This should return the information from a registration based on the NASID
|
||||||
|
parameters:
|
||||||
|
- in: query
|
||||||
|
name: orgNASID
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
required: true
|
||||||
|
example:
|
||||||
|
This is the orgNASID returned during registration.
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
$ref: '#/components/schemas/RegistrationResponse'
|
||||||
|
403:
|
||||||
|
$ref: '#/components/responses/Unauthorized'
|
||||||
|
404:
|
||||||
|
$ref: '#/components/responses/NotFound'
|
||||||
|
|
||||||
|
post:
|
||||||
|
summary: Called when the registrant ahs read the T&Cs and iw willing to submit their information to enter in a partnership
|
||||||
|
tags:
|
||||||
|
- Registration
|
||||||
|
operationId: createRegistration
|
||||||
|
requestBody:
|
||||||
|
required: true
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/RegistrationRequest'
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: Succesfully registered
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/RegistrationResponse'
|
||||||
|
400:
|
||||||
|
description: Registration failed due to missing or incomplete information
|
||||||
|
$ref: '#/components/responses/BadRequest'
|
||||||
|
403:
|
||||||
|
$ref: '#/components/responses/Unauthorized'
|
||||||
|
|
||||||
|
put:
|
||||||
|
summary: Called when the registrant needs to update its information with Ameriband. The does not generate a new NASID.
|
||||||
|
tags:
|
||||||
|
- Registration
|
||||||
|
operationId: updateRegistration
|
||||||
|
parameters:
|
||||||
|
- in: query
|
||||||
|
name: orgNASID
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
required: true
|
||||||
|
example:
|
||||||
|
This is the orgNASID returned during registration.
|
||||||
|
requestBody:
|
||||||
|
required: true
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/RegistrationRequest'
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: Succesfully found the information based on the orgNASID
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
$ref: '#/components/schemas/RegistrationResponse'
|
||||||
|
400:
|
||||||
|
$ref: '#/components/responses/BadRequest'
|
||||||
|
403:
|
||||||
|
$ref: '#/components/responses/Unauthorized'
|
||||||
|
404:
|
||||||
|
$ref: '#/components/responses/NotFound'
|
||||||
|
|
||||||
|
delete:
|
||||||
|
tags:
|
||||||
|
- Registration
|
||||||
|
summary: When a registrant wants to terminate a relationship with Ameriband. Ameriband should also delete all information from the registrant
|
||||||
|
operationId: deleteRegistration
|
||||||
|
parameters:
|
||||||
|
- in: query
|
||||||
|
name: orgNASID
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
required: true
|
||||||
|
example:
|
||||||
|
This is the orgNASID returned during registration.
|
||||||
|
responses:
|
||||||
|
204:
|
||||||
|
$ref: '#/components/responses/Success'
|
||||||
|
403:
|
||||||
|
$ref: '#/components/responses/Unauthorized'
|
||||||
|
404:
|
||||||
|
$ref: '#/components/responses/NotFound'
|
||||||
@@ -27,71 +27,13 @@ components:
|
|||||||
|
|
||||||
responses:
|
responses:
|
||||||
NotFound:
|
NotFound:
|
||||||
description: The specified resource was not found.
|
$ref: 'https://github.com/Telecominfraproject/wlan-cloud-ucentralsec/blob/main/openpapi/owsec.yaml#/components/responses/NotFound'
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
properties:
|
|
||||||
ErrorCode:
|
|
||||||
type: integer
|
|
||||||
ErrorDetails:
|
|
||||||
type: string
|
|
||||||
ErrorDescription:
|
|
||||||
type: string
|
|
||||||
|
|
||||||
Unauthorized:
|
Unauthorized:
|
||||||
description: The requested does not have sufficient rights to perform the operation.
|
$ref: 'https://github.com/Telecominfraproject/wlan-cloud-ucentralsec/blob/main/openpapi/owsec.yaml#/components/responses/Unauthorized'
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
properties:
|
|
||||||
ErrorCode:
|
|
||||||
type: integer
|
|
||||||
enum:
|
|
||||||
- 0 # Success
|
|
||||||
- 1 # PASSWORD_CHANGE_REQUIRED,
|
|
||||||
- 2 # INVALID_CREDENTIALS,
|
|
||||||
- 3 # PASSWORD_ALREADY_USED,
|
|
||||||
- 4 # USERNAME_PENDING_VERIFICATION,
|
|
||||||
- 5 # PASSWORD_INVALID,
|
|
||||||
- 6 # INTERNAL_ERROR,
|
|
||||||
- 7 # ACCESS_DENIED,
|
|
||||||
- 8 # INVALID_TOKEN
|
|
||||||
- 9 # EXPIRED_TOKEN
|
|
||||||
- 10 # RATE_LIMIT_EXCEEDED
|
|
||||||
- 11 # BAD_MFA_TRANSACTION
|
|
||||||
- 12 # MFA_FAILURE
|
|
||||||
- 13 # SECURITY_SERVICE_UNREACHABLE
|
|
||||||
ErrorDetails:
|
|
||||||
type: string
|
|
||||||
ErrorDescription:
|
|
||||||
type: string
|
|
||||||
|
|
||||||
Success:
|
Success:
|
||||||
description: The requested operation was performed.
|
$ref: 'https://github.com/Telecominfraproject/wlan-cloud-ucentralsec/blob/main/openpapi/owsec.yaml#/components/responses/Success'
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
properties:
|
|
||||||
Operation:
|
|
||||||
type: string
|
|
||||||
Details:
|
|
||||||
type: string
|
|
||||||
Code:
|
|
||||||
type: integer
|
|
||||||
|
|
||||||
BadRequest:
|
BadRequest:
|
||||||
description: The requested operation failed.
|
$ref: 'https://github.com/Telecominfraproject/wlan-cloud-ucentralsec/blob/main/openpapi/owsec.yaml#/components/responses/BadRequest'
|
||||||
content:
|
|
||||||
application/json:
|
|
||||||
schema:
|
|
||||||
properties:
|
|
||||||
ErrorCode:
|
|
||||||
type: integer
|
|
||||||
ErrorDetails:
|
|
||||||
type: string
|
|
||||||
ErrorDescription:
|
|
||||||
type: integer
|
|
||||||
|
|
||||||
schemas:
|
schemas:
|
||||||
|
|
||||||
@@ -1278,6 +1220,40 @@ components:
|
|||||||
items:
|
items:
|
||||||
$ref: '#/components/schemas/SubscriberDevice'
|
$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
|
## These are endpoints that all services in the OPenWiFI stack must provide
|
||||||
@@ -2016,11 +1992,6 @@ paths:
|
|||||||
schema:
|
schema:
|
||||||
type: boolean
|
type: boolean
|
||||||
required: false
|
required: false
|
||||||
- in: query
|
|
||||||
name: deviceType
|
|
||||||
schema:
|
|
||||||
type: string
|
|
||||||
required: false
|
|
||||||
- in: query
|
- in: query
|
||||||
description: Pagination start (starts at 1. If not specified, 1 is assumed)
|
description: Pagination start (starts at 1. If not specified, 1 is assumed)
|
||||||
name: offset
|
name: offset
|
||||||
@@ -2092,6 +2063,21 @@ paths:
|
|||||||
type: string
|
type: string
|
||||||
format: uuid
|
format: uuid
|
||||||
required: false
|
required: false
|
||||||
|
- in: query
|
||||||
|
description: return RRM settings for a specific device
|
||||||
|
name: rrmSettings
|
||||||
|
schema:
|
||||||
|
type: boolean
|
||||||
|
default: false
|
||||||
|
required: false
|
||||||
|
- in: query
|
||||||
|
description: return the resolved configuration for a specific device
|
||||||
|
name: resolveConfig
|
||||||
|
schema:
|
||||||
|
type: boolean
|
||||||
|
default: false
|
||||||
|
required: false
|
||||||
|
|
||||||
responses:
|
responses:
|
||||||
200:
|
200:
|
||||||
description: Return a list of elements
|
description: Return a list of elements
|
||||||
@@ -2259,6 +2245,94 @@ paths:
|
|||||||
404:
|
404:
|
||||||
$ref: '#/components/responses/NotFound'
|
$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:
|
/venue:
|
||||||
get:
|
get:
|
||||||
tags:
|
tags:
|
||||||
@@ -2313,12 +2387,6 @@ paths:
|
|||||||
type: string
|
type: string
|
||||||
example: serial1,serial2,serial3
|
example: serial1,serial2,serial3
|
||||||
required: false
|
required: false
|
||||||
- in: query
|
|
||||||
description: only serial numbers of full device details
|
|
||||||
name: serialOnly
|
|
||||||
schema:
|
|
||||||
type: boolean
|
|
||||||
required: false
|
|
||||||
- in: query
|
- in: query
|
||||||
description: return the number of devices
|
description: return the number of devices
|
||||||
name: countOnly
|
name: countOnly
|
||||||
|
|||||||
174
openapi/rrm_provider.yaml
Normal file
174
openapi/rrm_provider.yaml
Normal file
@@ -0,0 +1,174 @@
|
|||||||
|
openapi: 3.0.1
|
||||||
|
info:
|
||||||
|
title: OpenWiFi RRM Provider Model
|
||||||
|
description: Definitions and APIs to manages an OpenWiFi RRM Providers.
|
||||||
|
version: 1.0.0
|
||||||
|
license:
|
||||||
|
name: BSD3
|
||||||
|
url: https://github.com/Telecominfraproject/wlan-cloud-ucentralgw/blob/master/LICENSE
|
||||||
|
|
||||||
|
servers:
|
||||||
|
- url: 'https://localhost:16022/api/v1'
|
||||||
|
|
||||||
|
security:
|
||||||
|
- bearerAuth: []
|
||||||
|
- ApiKeyAuth: []
|
||||||
|
|
||||||
|
components:
|
||||||
|
securitySchemes:
|
||||||
|
ApiKeyAuth:
|
||||||
|
type: apiKey
|
||||||
|
in: header
|
||||||
|
name: X-API-KEY
|
||||||
|
bearerAuth:
|
||||||
|
type: http
|
||||||
|
scheme: bearer
|
||||||
|
bearerFormat: JWT
|
||||||
|
|
||||||
|
responses:
|
||||||
|
NotFound:
|
||||||
|
$ref: 'https://github.com/Telecominfraproject/wlan-cloud-ucentralsec/blob/main/openpapi/owsec.yaml#/components/responses/NotFound'
|
||||||
|
Unauthorized:
|
||||||
|
$ref: 'https://github.com/Telecominfraproject/wlan-cloud-ucentralsec/blob/main/openpapi/owsec.yaml#/components/responses/Unauthorized'
|
||||||
|
Success:
|
||||||
|
$ref: 'https://github.com/Telecominfraproject/wlan-cloud-ucentralsec/blob/main/openpapi/owsec.yaml#/components/responses/Success'
|
||||||
|
BadRequest:
|
||||||
|
$ref: 'https://github.com/Telecominfraproject/wlan-cloud-ucentralsec/blob/main/openpapi/owsec.yaml#/components/responses/BadRequest'
|
||||||
|
|
||||||
|
schemas:
|
||||||
|
|
||||||
|
Provider:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
vendor:
|
||||||
|
description: The name of the vendor for display.
|
||||||
|
type: string
|
||||||
|
minLength: 1
|
||||||
|
maxLength: 128
|
||||||
|
vendorShortname:
|
||||||
|
description: A shortname for the vendor. Only letters and numbers are allowed. This is the name used internally.
|
||||||
|
type: string
|
||||||
|
minLength: 4
|
||||||
|
maxLength: 16
|
||||||
|
version:
|
||||||
|
description: An identifier that will help users identify the version of the RRM module they are using.
|
||||||
|
type: string
|
||||||
|
about:
|
||||||
|
description: A link to the Vendor page for this RRM Module
|
||||||
|
type: string
|
||||||
|
|
||||||
|
|
||||||
|
Algorithm:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
name:
|
||||||
|
description: A display for this algorithm.
|
||||||
|
type: string
|
||||||
|
minLength: 1
|
||||||
|
maxLength: 128
|
||||||
|
description:
|
||||||
|
description: A description of the algorithm.
|
||||||
|
type: string
|
||||||
|
shortName:
|
||||||
|
description: This is the name used internally.
|
||||||
|
type: string
|
||||||
|
minLength: 4
|
||||||
|
maxLength: 16
|
||||||
|
parameterFormat:
|
||||||
|
description: this is a Regex used to validate the input. If this is empty, no validation will be performed.
|
||||||
|
type: string
|
||||||
|
parameterSamples:
|
||||||
|
description: These samples will be displayed in the UI to the user trying to configure the options
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
helper:
|
||||||
|
description: A link to a web page or PDF document explaining the algorithm and its parameters
|
||||||
|
type: string
|
||||||
|
|
||||||
|
Algorithms:
|
||||||
|
description: The list of all algorithms supported by the vendor
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
$ref: '#/components/schemas/Algorithm'
|
||||||
|
|
||||||
|
paths:
|
||||||
|
/provider:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- RRM
|
||||||
|
operationId: getProvider
|
||||||
|
summary: Retrieve information about the provider for this RRM Module
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
$ref: '#/components/schemas/Provider'
|
||||||
|
400:
|
||||||
|
$ref: '#/components/responses/BadRequest'
|
||||||
|
403:
|
||||||
|
$ref: '#/components/responses/Unauthorized'
|
||||||
|
404:
|
||||||
|
$ref: '#/components/responses/NotFound'
|
||||||
|
|
||||||
|
/algorithms:
|
||||||
|
get:
|
||||||
|
tags:
|
||||||
|
- RRM
|
||||||
|
operationId: getAlgorithms
|
||||||
|
summary: Retrieve a lists of algorithms supported in the module.
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
$ref: '#/components/schemas/Algorithms'
|
||||||
|
400:
|
||||||
|
$ref: '#/components/responses/BadRequest'
|
||||||
|
403:
|
||||||
|
$ref: '#/components/responses/Unauthorized'
|
||||||
|
404:
|
||||||
|
$ref: '#/components/responses/NotFound'
|
||||||
|
|
||||||
|
/runRRM:
|
||||||
|
put:
|
||||||
|
tags:
|
||||||
|
- RRM
|
||||||
|
operationId: runRRMNow
|
||||||
|
summary: Run a specific or default RRM algorithm. The UI user or CLI user will have the ability to run an algorithm on demand.
|
||||||
|
parameters:
|
||||||
|
- in: query
|
||||||
|
description:
|
||||||
|
name: venue
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
format: uuid
|
||||||
|
required: true
|
||||||
|
- in: query
|
||||||
|
description: Perform RRM without updating anything. This may be used by an admin to see what RRM would do.
|
||||||
|
name: mock
|
||||||
|
schema:
|
||||||
|
type: boolean
|
||||||
|
default: false
|
||||||
|
required: false
|
||||||
|
- in: query
|
||||||
|
description: Specify the RRM algorithm to use. If omitted, select the default algorithm.
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
required: false
|
||||||
|
- in: query
|
||||||
|
description: Specify the parameters to use with the RRM algorithm to use. If omitted, select the default parameters.
|
||||||
|
schema:
|
||||||
|
type: string
|
||||||
|
required: false
|
||||||
|
responses:
|
||||||
|
200:
|
||||||
|
description: Return the list of actions that were or would be performed.
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
type: array
|
||||||
|
items:
|
||||||
|
type: string
|
||||||
|
400:
|
||||||
|
$ref: '#/components/responses/BadRequest'
|
||||||
|
403:
|
||||||
|
$ref: '#/components/responses/Unauthorized'
|
||||||
|
404:
|
||||||
|
$ref: '#/components/responses/NotFound'
|
||||||
|
|
||||||
@@ -34,6 +34,7 @@ openwifi.system.uri.private = https://localhost:17005
|
|||||||
openwifi.system.uri.public = https://ucentral.dpaas.arilia.com:16005
|
openwifi.system.uri.public = https://ucentral.dpaas.arilia.com:16005
|
||||||
openwifi.system.commandchannel = /tmp/app.owprov
|
openwifi.system.commandchannel = /tmp/app.owprov
|
||||||
openwifi.system.uri.ui = owprov-ui.arilia.com
|
openwifi.system.uri.ui = owprov-ui.arilia.com
|
||||||
|
openwifi.security.restapi.disable = false
|
||||||
|
|
||||||
firmware.updater.upgrade = false
|
firmware.updater.upgrade = false
|
||||||
firmware.updater.releaseonly = false
|
firmware.updater.releaseonly = false
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ openwifi.system.uri.private = ${SYSTEM_URI_PRIVATE}
|
|||||||
openwifi.system.uri.public = ${SYSTEM_URI_PUBLIC}
|
openwifi.system.uri.public = ${SYSTEM_URI_PUBLIC}
|
||||||
openwifi.system.commandchannel = /tmp/app.ucentralfms
|
openwifi.system.commandchannel = /tmp/app.ucentralfms
|
||||||
openwifi.system.uri.ui = ${SYSTEM_URI_UI}
|
openwifi.system.uri.ui = ${SYSTEM_URI_UI}
|
||||||
|
openwifi.security.restapi.disable = ${SECURITY_RESTAPI_DISABLE}
|
||||||
|
|
||||||
#############################
|
#############################
|
||||||
# Generic information for all micro services
|
# Generic information for all micro services
|
||||||
|
|||||||
@@ -5,6 +5,10 @@
|
|||||||
#include "APConfig.h"
|
#include "APConfig.h"
|
||||||
#include "StorageService.h"
|
#include "StorageService.h"
|
||||||
|
|
||||||
|
#include "Poco/JSON/Parser.h"
|
||||||
|
#include "Poco/StringTokenizer.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
|
|
||||||
APConfig::APConfig(const std::string &SerialNumber, const std::string &DeviceType, Poco::Logger &L, bool Explain)
|
APConfig::APConfig(const std::string &SerialNumber, const std::string &DeviceType, Poco::Logger &L, bool Explain)
|
||||||
@@ -131,7 +135,10 @@ namespace OpenWifi {
|
|||||||
ProvObjects::InventoryTag D;
|
ProvObjects::InventoryTag D;
|
||||||
if (StorageService()->InventoryDB().GetRecord("serialNumber", SerialNumber_, D)) {
|
if (StorageService()->InventoryDB().GetRecord("serialNumber", SerialNumber_, D)) {
|
||||||
if (!D.deviceConfiguration.empty()) {
|
if (!D.deviceConfiguration.empty()) {
|
||||||
|
std::cout << "Adding device specific configuration: " << D.deviceConfiguration.size() << std::endl;
|
||||||
AddConfiguration(D.deviceConfiguration);
|
AddConfiguration(D.deviceConfiguration);
|
||||||
|
} else {
|
||||||
|
std::cout << "No device specific configuration." << std::endl;
|
||||||
}
|
}
|
||||||
if (!D.entity.empty()) {
|
if (!D.entity.empty()) {
|
||||||
AddEntityConfig(D.entity);
|
AddEntityConfig(D.entity);
|
||||||
@@ -153,12 +160,13 @@ namespace OpenWifi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
std::set<std::string> Sections;
|
std::set<std::string> Sections;
|
||||||
for(const auto &i:Config_) {
|
for (const auto &i: Config_) {
|
||||||
Poco::JSON::Parser P;
|
Poco::JSON::Parser P;
|
||||||
auto O = P.parse(i.element.configuration).extract<Poco::JSON::Object::Ptr>();
|
auto O = P.parse(i.element.configuration).extract<Poco::JSON::Object::Ptr>();
|
||||||
auto Names = O->getNames();
|
auto Names = O->getNames();
|
||||||
for(const auto &SectionName:Names) {
|
for (const auto &SectionName: Names) {
|
||||||
auto InsertInfo = Sections.insert(SectionName);
|
auto InsertInfo = Sections.insert(SectionName);
|
||||||
if (InsertInfo.second) {
|
if (InsertInfo.second) {
|
||||||
if (O->isArray(SectionName)) {
|
if (O->isArray(SectionName)) {
|
||||||
@@ -188,7 +196,8 @@ namespace OpenWifi {
|
|||||||
ReplaceVariablesInObject(OriginalSection, ExpandedSection);
|
ReplaceVariablesInObject(OriginalSection, ExpandedSection);
|
||||||
Configuration->set(SectionName, ExpandedSection);
|
Configuration->set(SectionName, ExpandedSection);
|
||||||
} else {
|
} else {
|
||||||
std::cout << " --- unknown element type --- " << O->get(SectionName).toString() << std::endl;
|
std::cout << " --- unknown element type --- " << O->get(SectionName).toString()
|
||||||
|
<< std::endl;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (Explain_) {
|
if (Explain_) {
|
||||||
@@ -203,10 +212,69 @@ namespace OpenWifi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if(Config_.empty())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
// 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 (...) {
|
||||||
|
|
||||||
|
}
|
||||||
|
return !Config_.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool DeviceTypeMatch(const std::string &DeviceType, const Types::StringVec & Types) {
|
static bool DeviceTypeMatch(const std::string &DeviceType, const Types::StringVec & Types) {
|
||||||
@@ -267,7 +335,11 @@ namespace OpenWifi {
|
|||||||
ExObj.set("reason", "deviceType mismatch");
|
ExObj.set("reason", "deviceType mismatch");
|
||||||
Explanation_.add(ExObj);
|
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_));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,6 +10,8 @@
|
|||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
|
|
||||||
|
constexpr std::uint64_t MaximumPossibleRadios=6;
|
||||||
|
|
||||||
struct VerboseElement {
|
struct VerboseElement {
|
||||||
ProvObjects::DeviceConfigurationElement element;
|
ProvObjects::DeviceConfigurationElement element;
|
||||||
ProvObjects::ObjectInfo info;
|
ProvObjects::ObjectInfo info;
|
||||||
|
|||||||
@@ -5,11 +5,14 @@
|
|||||||
#include "AutoDiscovery.h"
|
#include "AutoDiscovery.h"
|
||||||
#include "framework/ow_constants.h"
|
#include "framework/ow_constants.h"
|
||||||
#include "framework/KafkaTopics.h"
|
#include "framework/KafkaTopics.h"
|
||||||
|
#include "framework/KafkaManager.h"
|
||||||
#include "StorageService.h"
|
#include "StorageService.h"
|
||||||
|
#include "Poco/JSON/Parser.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
|
|
||||||
int AutoDiscovery::Start() {
|
int AutoDiscovery::Start() {
|
||||||
|
poco_information(Logger(),"Starting...");
|
||||||
Running_ = true;
|
Running_ = true;
|
||||||
Types::TopicNotifyFunction F = [this](const std::string &Key, const std::string &Payload) { this->ConnectionReceived(Key,Payload); };
|
Types::TopicNotifyFunction F = [this](const std::string &Key, const std::string &Payload) { this->ConnectionReceived(Key,Payload); };
|
||||||
ConnectionWatcherId_ = KafkaManager()->RegisterTopicWatcher(KafkaTopics::CONNECTION, F);
|
ConnectionWatcherId_ = KafkaManager()->RegisterTopicWatcher(KafkaTopics::CONNECTION, F);
|
||||||
@@ -18,14 +21,17 @@ namespace OpenWifi {
|
|||||||
};
|
};
|
||||||
|
|
||||||
void AutoDiscovery::Stop() {
|
void AutoDiscovery::Stop() {
|
||||||
|
poco_information(Logger(),"Stopping...");
|
||||||
Running_ = false;
|
Running_ = false;
|
||||||
KafkaManager()->UnregisterTopicWatcher(KafkaTopics::CONNECTION, ConnectionWatcherId_);
|
KafkaManager()->UnregisterTopicWatcher(KafkaTopics::CONNECTION, ConnectionWatcherId_);
|
||||||
Queue_.wakeUpAll();
|
Queue_.wakeUpAll();
|
||||||
Worker_.join();
|
Worker_.join();
|
||||||
|
poco_information(Logger(),"Stopped...");
|
||||||
};
|
};
|
||||||
|
|
||||||
void AutoDiscovery::run() {
|
void AutoDiscovery::run() {
|
||||||
Poco::AutoPtr<Poco::Notification> Note(Queue_.waitDequeueNotification());
|
Poco::AutoPtr<Poco::Notification> Note(Queue_.waitDequeueNotification());
|
||||||
|
Utils::SetThreadName("auto-discovery");
|
||||||
while(Note && Running_) {
|
while(Note && Running_) {
|
||||||
auto Msg = dynamic_cast<DiscoveryMessage *>(Note.get());
|
auto Msg = dynamic_cast<DiscoveryMessage *>(Note.get());
|
||||||
if(Msg!= nullptr) {
|
if(Msg!= nullptr) {
|
||||||
|
|||||||
@@ -4,8 +4,11 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "framework/MicroService.h"
|
|
||||||
#include "framework/OpenWifiTypes.h"
|
#include "framework/OpenWifiTypes.h"
|
||||||
|
#include "framework/SubSystemServer.h"
|
||||||
|
|
||||||
|
#include "Poco/NotificationQueue.h"
|
||||||
|
#include "Poco/Notification.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
|
|
||||||
@@ -33,7 +36,7 @@ namespace OpenWifi {
|
|||||||
void Stop() override;
|
void Stop() override;
|
||||||
void ConnectionReceived( const std::string & Key, const std::string & Payload) {
|
void ConnectionReceived( const std::string & Key, const std::string & Payload) {
|
||||||
std::lock_guard G(Mutex_);
|
std::lock_guard G(Mutex_);
|
||||||
Logger().information(Poco::format("Device(%s): Connection/Ping message.", Key));
|
poco_trace(Logger(),Poco::format("Device(%s): Connection/Ping message.", Key));
|
||||||
Queue_.enqueueNotification( new DiscoveryMessage(Key,Payload));
|
Queue_.enqueueNotification( new DiscoveryMessage(Key,Payload));
|
||||||
}
|
}
|
||||||
void run() override;
|
void run() override;
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
#include "Poco/Util/Application.h"
|
#include "Poco/Util/Application.h"
|
||||||
#include "Poco/Util/Option.h"
|
#include "Poco/Util/Option.h"
|
||||||
#include "Poco/Environment.h"
|
#include "Poco/Environment.h"
|
||||||
|
#include "Poco/Net/SSLManager.h"
|
||||||
|
|
||||||
#include "Daemon.h"
|
#include "Daemon.h"
|
||||||
#include "StorageService.h"
|
#include "StorageService.h"
|
||||||
@@ -20,6 +21,8 @@
|
|||||||
#include "Signup.h"
|
#include "Signup.h"
|
||||||
#include "DeviceTypeCache.h"
|
#include "DeviceTypeCache.h"
|
||||||
#include "FileDownloader.h"
|
#include "FileDownloader.h"
|
||||||
|
#include "framework/UI_WebSocketClientServer.h"
|
||||||
|
#include "UI_Prov_WebSocketNotifications.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
class Daemon *Daemon::instance_ = nullptr;
|
class Daemon *Daemon::instance_ = nullptr;
|
||||||
@@ -38,7 +41,7 @@ namespace OpenWifi {
|
|||||||
SerialNumberCache(),
|
SerialNumberCache(),
|
||||||
AutoDiscovery(),
|
AutoDiscovery(),
|
||||||
JobController(),
|
JobController(),
|
||||||
WebSocketClientServer(),
|
UI_WebSocketClientServer(),
|
||||||
FindCountryFromIP(),
|
FindCountryFromIP(),
|
||||||
Signup(),
|
Signup(),
|
||||||
FileDownloader()
|
FileDownloader()
|
||||||
@@ -70,20 +73,34 @@ namespace OpenWifi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DaemonPostInitialization(Poco::Util::Application &self) {
|
||||||
|
Daemon()->PostInitialization(self);
|
||||||
|
ProvWebSocketNotifications::Register();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char **argv) {
|
int main(int argc, char **argv) {
|
||||||
|
int ExitCode;
|
||||||
try {
|
try {
|
||||||
|
Poco::Net::SSLManager::instance().initializeServer(nullptr, nullptr, nullptr);
|
||||||
auto App = OpenWifi::Daemon::instance();
|
auto App = OpenWifi::Daemon::instance();
|
||||||
auto ExitCode = App->run(argc, argv);
|
ExitCode = App->run(argc, argv);
|
||||||
delete App;
|
Poco::Net::SSLManager::instance().shutdown();
|
||||||
|
|
||||||
return ExitCode;
|
|
||||||
|
|
||||||
} catch (Poco::Exception &exc) {
|
} catch (Poco::Exception &exc) {
|
||||||
std::cerr << exc.displayText() << std::endl;
|
ExitCode = Poco::Util::Application::EXIT_SOFTWARE;
|
||||||
return Poco::Util::Application::EXIT_SOFTWARE;
|
std::cout << exc.displayText() << std::endl;
|
||||||
|
} catch (std::exception &exc) {
|
||||||
|
ExitCode = Poco::Util::Application::EXIT_TEMPFAIL;
|
||||||
|
std::cout << exc.what() << std::endl;
|
||||||
|
} catch (...) {
|
||||||
|
ExitCode = Poco::Util::Application::EXIT_TEMPFAIL;
|
||||||
|
std::cout << "Exception on closure" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::cout << "Exitcode: " << ExitCode << std::endl;
|
||||||
|
return ExitCode;
|
||||||
}
|
}
|
||||||
|
|
||||||
// end of namespace
|
// end of namespace
|
||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
#include "Dashboard.h"
|
#include "Dashboard.h"
|
||||||
#include "framework/MicroService.h"
|
#include "framework/MicroService.h"
|
||||||
|
#include "framework/MicroServiceNames.h"
|
||||||
#include "framework/OpenWifiTypes.h"
|
#include "framework/OpenWifiTypes.h"
|
||||||
#include "RESTObjects/RESTAPI_ProvObjects.h"
|
#include "RESTObjects/RESTAPI_ProvObjects.h"
|
||||||
#include "ProvWebSocketClient.h"
|
#include "ProvWebSocketClient.h"
|
||||||
@@ -54,8 +55,6 @@ namespace OpenWifi {
|
|||||||
};
|
};
|
||||||
|
|
||||||
inline Daemon * Daemon() { return Daemon::instance(); }
|
inline Daemon * Daemon() { return Daemon::instance(); }
|
||||||
inline void DaemonPostInitialization(Poco::Util::Application &self) {
|
void DaemonPostInitialization(Poco::Util::Application &self);
|
||||||
Daemon()->PostInitialization(self);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,11 +6,11 @@
|
|||||||
// Arilia Wireless Inc.
|
// Arilia Wireless Inc.
|
||||||
//
|
//
|
||||||
#include "Dashboard.h"
|
#include "Dashboard.h"
|
||||||
#include "StorageService.h"
|
#include "framework/utils.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
void ProvisioningDashboard::Create() {
|
void ProvisioningDashboard::Create() {
|
||||||
uint64_t Now = OpenWifi::Now();
|
uint64_t Now = Utils::Now();
|
||||||
if(LastRun_==0 || (Now-LastRun_)>120) {
|
if(LastRun_==0 || (Now-LastRun_)>120) {
|
||||||
DB_.reset();
|
DB_.reset();
|
||||||
// Todo: call dashboard creation code.
|
// Todo: call dashboard creation code.
|
||||||
|
|||||||
@@ -6,7 +6,11 @@
|
|||||||
|
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
||||||
#include "framework/MicroService.h"
|
#include "framework/SubSystemServer.h"
|
||||||
|
#include "framework/AppServiceRegistry.h"
|
||||||
|
#include "framework/OpenAPIRequests.h"
|
||||||
|
#include "framework/MicroServiceNames.h"
|
||||||
|
|
||||||
#include "Poco/Timer.h"
|
#include "Poco/Timer.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
|
|||||||
@@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
int FileDownloader::Start() {
|
int FileDownloader::Start() {
|
||||||
|
poco_information(Logger(),"Starting...");
|
||||||
TimerCallback_ = std::make_unique<Poco::TimerCallback<FileDownloader>>(*this,&FileDownloader::onTimer);
|
TimerCallback_ = std::make_unique<Poco::TimerCallback<FileDownloader>>(*this,&FileDownloader::onTimer);
|
||||||
Timer_.setStartInterval( 20 * 1000); // first run in 20 seconds
|
Timer_.setStartInterval( 20 * 1000); // first run in 20 seconds
|
||||||
Timer_.setPeriodicInterval(2 * 60 * 60 * 1000); // 1 hours
|
Timer_.setPeriodicInterval(2 * 60 * 60 * 1000); // 1 hours
|
||||||
@@ -15,8 +16,9 @@ namespace OpenWifi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FileDownloader::Stop() {
|
void FileDownloader::Stop() {
|
||||||
|
poco_information(Logger(),"Stopping...");
|
||||||
Timer_.stop();
|
Timer_.stop();
|
||||||
Logger().notice("Stopping.");
|
poco_information(Logger(),"Stopped...");
|
||||||
}
|
}
|
||||||
|
|
||||||
void FileDownloader::onTimer([[maybe_unused]] Poco::Timer &timer) {
|
void FileDownloader::onTimer([[maybe_unused]] Poco::Timer &timer) {
|
||||||
@@ -26,6 +28,8 @@ namespace OpenWifi {
|
|||||||
{"https://ucentral.io/ucentral.schema.pretty.json", "ucentral.schema.pretty.json" }
|
{"https://ucentral.io/ucentral.schema.pretty.json", "ucentral.schema.pretty.json" }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Utils::SetThreadName("file-dmnldr");
|
||||||
|
|
||||||
for(const auto &[url,filename]:Files) {
|
for(const auto &[url,filename]:Files) {
|
||||||
try {
|
try {
|
||||||
std::string FileContent;
|
std::string FileContent;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include "framework/MicroService.h"
|
#include "framework/SubSystemServer.h"
|
||||||
#include "Poco/Timer.h"
|
#include "Poco/Timer.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
|
|||||||
@@ -4,8 +4,11 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "framework/MicroService.h"
|
|
||||||
#include "Poco/Net/IPAddress.h"
|
#include "Poco/Net/IPAddress.h"
|
||||||
|
|
||||||
|
#include "framework/SubSystemServer.h"
|
||||||
|
#include "framework/MicroServiceFuncs.h"
|
||||||
|
|
||||||
#include "nlohmann/json.hpp"
|
#include "nlohmann/json.hpp"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
@@ -23,7 +26,7 @@ namespace OpenWifi {
|
|||||||
public:
|
public:
|
||||||
static std::string Name() { return "ipinfo"; }
|
static std::string Name() { return "ipinfo"; }
|
||||||
inline bool Init() override {
|
inline bool Init() override {
|
||||||
Key_ = MicroService::instance().ConfigGetString("iptocountry.ipinfo.token", "");
|
Key_ = MicroServiceConfigGetString("iptocountry.ipinfo.token", "");
|
||||||
return !Key_.empty();
|
return !Key_.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -55,7 +58,7 @@ namespace OpenWifi {
|
|||||||
public:
|
public:
|
||||||
static std::string Name() { return "ipdata"; }
|
static std::string Name() { return "ipdata"; }
|
||||||
inline bool Init() override {
|
inline bool Init() override {
|
||||||
Key_ = MicroService::instance().ConfigGetString("iptocountry.ipdata.apikey", "");
|
Key_ = MicroServiceConfigGetString("iptocountry.ipdata.apikey", "");
|
||||||
return !Key_.empty();
|
return !Key_.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -85,7 +88,7 @@ namespace OpenWifi {
|
|||||||
public:
|
public:
|
||||||
static std::string Name() { return "ip2location"; }
|
static std::string Name() { return "ip2location"; }
|
||||||
inline bool Init() override {
|
inline bool Init() override {
|
||||||
Key_ = MicroService::instance().ConfigGetString("iptocountry.ip2location.apikey", "");
|
Key_ = MicroServiceConfigGetString("iptocountry.ip2location.apikey", "");
|
||||||
return !Key_.empty();
|
return !Key_.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,18 +136,22 @@ namespace OpenWifi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline int Start() final {
|
inline int Start() final {
|
||||||
ProviderName_ = MicroService::instance().ConfigGetString("iptocountry.provider","");
|
poco_notice(Logger(),"Starting...");
|
||||||
|
ProviderName_ = MicroServiceConfigGetString("iptocountry.provider","");
|
||||||
if(!ProviderName_.empty()) {
|
if(!ProviderName_.empty()) {
|
||||||
Provider_ = IPLocationProvider<IPToCountryProvider, IPInfo, IPData, IP2Location>(ProviderName_);
|
Provider_ = IPLocationProvider<IPToCountryProvider, IPInfo, IPData, IP2Location>(ProviderName_);
|
||||||
if(Provider_!= nullptr) {
|
if(Provider_!= nullptr) {
|
||||||
Enabled_ = Provider_->Init();
|
Enabled_ = Provider_->Init();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Default_ = MicroService::instance().ConfigGetString("iptocountry.default", "US");
|
Default_ = MicroServiceConfigGetString("iptocountry.default", "US");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void Stop() final {
|
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 )
|
[[nodiscard]] static inline std::string ReformatAddress(const std::string & I )
|
||||||
|
|||||||
@@ -3,15 +3,16 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include "JobController.h"
|
#include "JobController.h"
|
||||||
|
#include "framework/utils.h"
|
||||||
|
#include "fmt/format.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
|
|
||||||
void RegisterJobTypes();
|
void RegisterJobTypes();
|
||||||
|
|
||||||
int JobController::Start() {
|
int JobController::Start() {
|
||||||
|
poco_information(Logger(),"Starting...");
|
||||||
RegisterJobTypes();
|
RegisterJobTypes();
|
||||||
|
|
||||||
if(!Running_)
|
if(!Running_)
|
||||||
Thr_.start(*this);
|
Thr_.start(*this);
|
||||||
|
|
||||||
@@ -20,18 +21,41 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
void JobController::Stop() {
|
void JobController::Stop() {
|
||||||
if(Running_) {
|
if(Running_) {
|
||||||
|
poco_information(Logger(),"Stopping...");
|
||||||
Running_ = false;
|
Running_ = false;
|
||||||
Thr_.join();
|
Thr_.join();
|
||||||
|
poco_information(Logger(),"Stopped...");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void JobController::run() {
|
void JobController::run() {
|
||||||
Running_ = true ;
|
Running_ = true ;
|
||||||
|
Utils::SetThreadName("job-controller");
|
||||||
while(Running_) {
|
while(Running_) {
|
||||||
Poco::Thread::trySleep(2000);
|
Poco::Thread::trySleep(2000);
|
||||||
|
|
||||||
|
std::lock_guard G(Mutex_);
|
||||||
|
|
||||||
|
for(auto ¤t_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->Start();
|
||||||
|
Pool_.start(*current_job);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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()));
|
||||||
|
it = jobs_.erase(it);
|
||||||
|
delete current_job;
|
||||||
|
} else {
|
||||||
|
++it;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -7,99 +7,47 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <utility>
|
#include <utility>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include "framework/MicroService.h"
|
#include <list>
|
||||||
|
#include "framework/SubSystemServer.h"
|
||||||
|
#include "RESTObjects/RESTAPI_SecurityObjects.h"
|
||||||
|
#include "framework/utils.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
|
|
||||||
class Job {
|
class Job : public Poco::Runnable {
|
||||||
public:
|
public:
|
||||||
struct Parameter {
|
Job(const std::string &JobID, const std::string &name, const std::vector<std::string> & parameters, uint64_t when, const SecurityObjects::UserInfo &UI, Poco::Logger &L) :
|
||||||
std::string name;
|
jobId_(JobID),
|
||||||
std::string value;
|
name_(name),
|
||||||
inline void to_json(Poco::JSON::Object &Obj) const {
|
parameters_(parameters),
|
||||||
RESTAPI_utils::field_to_json(Obj,"name",name);
|
when_(when),
|
||||||
RESTAPI_utils::field_to_json(Obj,"value",value);
|
userinfo_(UI),
|
||||||
}
|
Logger_(L)
|
||||||
|
{};
|
||||||
|
|
||||||
inline bool from_json(const Poco::JSON::Object::Ptr &Obj) {
|
virtual void run() = 0;
|
||||||
try {
|
[[nodiscard]] std::string Name() const { return name_; }
|
||||||
RESTAPI_utils::field_from_json(Obj,"name",name);
|
const SecurityObjects::UserInfo & UserInfo() const { return userinfo_; }
|
||||||
RESTAPI_utils::field_from_json(Obj,"value",value);
|
Poco::Logger & Logger() { return Logger_; }
|
||||||
return true;
|
const std::string & JobId() const { return jobId_; }
|
||||||
} catch (...) {
|
const std::string & Parameter(int x) const { return parameters_[x];}
|
||||||
|
uint64_t When() const { return when_; }
|
||||||
}
|
void Start() { started_ = Utils::Now(); }
|
||||||
return false;
|
uint64_t Started() const { return started_; }
|
||||||
}
|
uint64_t Completed() const { return completed_;}
|
||||||
};
|
void Complete() { completed_ = Utils::Now(); }
|
||||||
|
|
||||||
struct Status {
|
|
||||||
Types::UUID_t UUID;
|
|
||||||
uint64_t Start = 0 ;
|
|
||||||
uint64_t Progress = 0 ;
|
|
||||||
uint64_t Completed = 0 ;
|
|
||||||
std::string CurrentDisplay;
|
|
||||||
};
|
|
||||||
|
|
||||||
struct Result {
|
|
||||||
int Error=0;
|
|
||||||
std::string Reason;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef std::vector<Parameter> Parameters;
|
|
||||||
typedef std::vector<Parameters> ParametersVec;
|
|
||||||
typedef std::function<bool(const Parameters &Parameters, Result &Result, bool &Retry)> WorkerFunction;
|
|
||||||
typedef std::vector<Status> Statuses;
|
|
||||||
|
|
||||||
Job(std::string Title,
|
|
||||||
std::string Description,
|
|
||||||
std::string RegisteredName,
|
|
||||||
ParametersVec Parameters,
|
|
||||||
[[maybe_unused]] bool Parallel=true) :
|
|
||||||
Title_(std::move(Title)),
|
|
||||||
Description_(std::move(Description)),
|
|
||||||
RegisteredName_(std::move(RegisteredName)),
|
|
||||||
Parameters_(std::move(Parameters))
|
|
||||||
{
|
|
||||||
UUID_ = MicroService::instance().CreateUUID();
|
|
||||||
}
|
|
||||||
|
|
||||||
[[nodiscard]] inline const Types::UUID_t & ID() const { return UUID_; }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Types::UUID_t UUID_;
|
std::string jobId_;
|
||||||
std::string Title_;
|
std::string name_;
|
||||||
std::string Description_;
|
std::vector<std::string> parameters_;
|
||||||
std::string RegisteredName_;
|
uint64_t when_=0;
|
||||||
ParametersVec Parameters_;
|
SecurityObjects::UserInfo userinfo_;
|
||||||
|
Poco::Logger & Logger_;
|
||||||
|
uint64_t started_=0;
|
||||||
|
uint64_t completed_=0;
|
||||||
};
|
};
|
||||||
|
|
||||||
class JobRegistry {
|
|
||||||
public:
|
|
||||||
static auto instance() {
|
|
||||||
static auto instance_ = new JobRegistry;
|
|
||||||
return instance_;
|
|
||||||
}
|
|
||||||
|
|
||||||
inline void RegisterJobType( const std::string & JobType, Job::WorkerFunction Function) {
|
|
||||||
JobTypes_[JobType] = std::move(Function);
|
|
||||||
}
|
|
||||||
|
|
||||||
inline bool Execute(const std::string &JobType, const Job::Parameters & Params, Job::Result &Result, bool & Retry) {
|
|
||||||
auto Hint = JobTypes_.find(JobType);
|
|
||||||
if(Hint != end(JobTypes_)) {
|
|
||||||
Hint->second(Params, Result, Retry);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::map<std::string,Job::WorkerFunction> JobTypes_;
|
|
||||||
};
|
|
||||||
|
|
||||||
inline auto JobRegistry() { return JobRegistry::instance(); }
|
|
||||||
|
|
||||||
class JobController : public SubSystemServer, Poco::Runnable {
|
class JobController : public SubSystemServer, Poco::Runnable {
|
||||||
public:
|
public:
|
||||||
static auto instance() {
|
static auto instance() {
|
||||||
@@ -112,11 +60,16 @@ namespace OpenWifi {
|
|||||||
void run() override;
|
void run() override;
|
||||||
inline void wakeup() { Thr_.wakeUp(); }
|
inline void wakeup() { Thr_.wakeUp(); }
|
||||||
|
|
||||||
bool JobList(Job::Statuses & Statuses);
|
void AddJob( Job* newJob ) {
|
||||||
|
std::lock_guard G(Mutex_);
|
||||||
|
jobs_.push_back(newJob);
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Poco::Thread Thr_;
|
Poco::Thread Thr_;
|
||||||
std::atomic_bool Running_=false;
|
std::atomic_bool Running_=false;
|
||||||
|
std::list<Job *> jobs_;
|
||||||
|
Poco::ThreadPool Pool_;
|
||||||
|
|
||||||
JobController() noexcept:
|
JobController() noexcept:
|
||||||
SubSystemServer("JobController", "JOB-SVR", "job")
|
SubSystemServer("JobController", "JOB-SVR", "job")
|
||||||
|
|||||||
@@ -4,7 +4,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "framework/MicroService.h"
|
#include "framework/KafkaTopics.h"
|
||||||
|
#include "framework/KafkaManager.h"
|
||||||
#include "RESTObjects/RESTAPI_ProvObjects.h"
|
#include "RESTObjects/RESTAPI_ProvObjects.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
|
|||||||
@@ -7,22 +7,24 @@
|
|||||||
#include "StorageService.h"
|
#include "StorageService.h"
|
||||||
#include "SerialNumberCache.h"
|
#include "SerialNumberCache.h"
|
||||||
#include "sdks/SDK_sec.h"
|
#include "sdks/SDK_sec.h"
|
||||||
|
#include "framework/UI_WebSocketClientServer.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
|
|
||||||
ProvWebSocketClient::ProvWebSocketClient(Poco::Logger &Logger) :
|
ProvWebSocketClient::ProvWebSocketClient(Poco::Logger &Logger) :
|
||||||
Logger_(Logger){
|
Logger_(Logger){
|
||||||
WebSocketClientServer()->SetProcessor(this);
|
UI_WebSocketClientServer()->SetProcessor(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProvWebSocketClient::~ProvWebSocketClient() {
|
ProvWebSocketClient::~ProvWebSocketClient() {
|
||||||
WebSocketClientServer()->SetProcessor(nullptr);
|
UI_WebSocketClientServer()->SetProcessor(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProvWebSocketClient::ws_command_serial_number_search(const Poco::JSON::Object::Ptr &O,
|
void ProvWebSocketClient::ws_command_serial_number_search(const Poco::JSON::Object::Ptr &O,
|
||||||
bool &Done, std::string &Answer) {
|
bool &Done, std::string &Answer) {
|
||||||
Done = false;
|
Done = false;
|
||||||
auto Prefix = O->get("serial_prefix").toString();
|
auto Prefix = O->get("serial_prefix").toString();
|
||||||
|
Poco::toLowerInPlace(Prefix);
|
||||||
Logger().information(Poco::format("serial_number_search: %s", Prefix));
|
Logger().information(Poco::format("serial_number_search: %s", Prefix));
|
||||||
if (!Prefix.empty() && Prefix.length() < 13) {
|
if (!Prefix.empty() && Prefix.length() < 13) {
|
||||||
std::vector<uint64_t> Numbers;
|
std::vector<uint64_t> Numbers;
|
||||||
@@ -83,6 +85,7 @@ namespace OpenWifi {
|
|||||||
Done = false;
|
Done = false;
|
||||||
auto operatorId = O->get("operatorId").toString();
|
auto operatorId = O->get("operatorId").toString();
|
||||||
auto Prefix = O->get("serial_prefix").toString();
|
auto Prefix = O->get("serial_prefix").toString();
|
||||||
|
Poco::toLowerInPlace(Prefix);
|
||||||
std::string Query;
|
std::string Query;
|
||||||
|
|
||||||
if(Prefix[0]=='*') {
|
if(Prefix[0]=='*') {
|
||||||
@@ -115,11 +118,11 @@ namespace OpenWifi {
|
|||||||
auto Command = O->get("command").toString();
|
auto Command = O->get("command").toString();
|
||||||
if (Command == "serial_number_search" && O->has("serial_prefix")) {
|
if (Command == "serial_number_search" && O->has("serial_prefix")) {
|
||||||
ws_command_serial_number_search(O,Done,Answer);
|
ws_command_serial_number_search(O,Done,Answer);
|
||||||
} else if (WebSocketClientServer()->GeoCodeEnabled() && Command == "address_completion" && O->has("address")) {
|
} else if (UI_WebSocketClientServer()->GeoCodeEnabled() && Command == "address_completion" && O->has("address")) {
|
||||||
ws_command_address_completion(O,Done,Answer);
|
ws_command_address_completion(O,Done,Answer);
|
||||||
} else if (WebSocketClientServer()->GeoCodeEnabled() && Command == "subuser_search" && O->has("operatorId")) {
|
} else if (UI_WebSocketClientServer()->GeoCodeEnabled() && Command == "subuser_search" && O->has("operatorId")) {
|
||||||
ws_command_subuser_search(O,Done,Answer);
|
ws_command_subuser_search(O,Done,Answer);
|
||||||
} else if (WebSocketClientServer()->GeoCodeEnabled() && Command == "subdevice_search" && O->has("operatorId") && O->has("serial_prefix")) {
|
} else if (UI_WebSocketClientServer()->GeoCodeEnabled() && Command == "subdevice_search" && O->has("operatorId") && O->has("serial_prefix")) {
|
||||||
ws_command_subdevice_search(O,Done,Answer);
|
ws_command_subdevice_search(O,Done,Answer);
|
||||||
} else if (Command=="exit") {
|
} else if (Command=="exit") {
|
||||||
ws_command_exit(O,Done,Answer);
|
ws_command_exit(O,Done,Answer);
|
||||||
@@ -140,7 +143,7 @@ namespace OpenWifi {
|
|||||||
Poco::URI uri(URI);
|
Poco::URI uri(URI);
|
||||||
|
|
||||||
uri.addQueryParameter("address",A);
|
uri.addQueryParameter("address",A);
|
||||||
uri.addQueryParameter("key", WebSocketClientServer()->GoogleApiKey());
|
uri.addQueryParameter("key", UI_WebSocketClientServer()->GoogleApiKey());
|
||||||
|
|
||||||
Poco::Net::HTTPSClientSession session(uri.getHost(), uri.getPort());
|
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);
|
Poco::Net::HTTPRequest req(Poco::Net::HTTPRequest::HTTP_GET, uri.getPathAndQuery(), Poco::Net::HTTPMessage::HTTP_1_1);
|
||||||
|
|||||||
@@ -4,11 +4,11 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "framework/MicroService.h"
|
#include "framework/UI_WebSocketClientServer.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
|
|
||||||
class ProvWebSocketClient : public WebSocketClientProcessor {
|
class ProvWebSocketClient : public UI_WebSocketClientProcessor {
|
||||||
public:
|
public:
|
||||||
explicit ProvWebSocketClient(Poco::Logger &Logger);
|
explicit ProvWebSocketClient(Poco::Logger &Logger);
|
||||||
virtual ~ProvWebSocketClient();
|
virtual ~ProvWebSocketClient();
|
||||||
|
|||||||
@@ -3,13 +3,13 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "framework/RESTAPI_Handler.h"
|
||||||
#include "../framework/MicroService.h"
|
#include "StorageService.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
class RESTAPI_asset_server : public RESTAPIHandler {
|
class RESTAPI_asset_server : public RESTAPIHandler {
|
||||||
public:
|
public:
|
||||||
RESTAPI_asset_server(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer &Server, uint64_t TransactionId, bool Internal)
|
RESTAPI_asset_server(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting &Server, uint64_t TransactionId, bool Internal)
|
||||||
: RESTAPIHandler(bindings, L,
|
: RESTAPIHandler(bindings, L,
|
||||||
std::vector<std::string>
|
std::vector<std::string>
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -6,8 +6,6 @@
|
|||||||
// Arilia Wireless Inc.
|
// Arilia Wireless Inc.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "framework/MicroService.h"
|
|
||||||
|
|
||||||
#include "RESTAPI_configurations_handler.h"
|
#include "RESTAPI_configurations_handler.h"
|
||||||
#include "RESTObjects/RESTAPI_ProvObjects.h"
|
#include "RESTObjects/RESTAPI_ProvObjects.h"
|
||||||
#include "StorageService.h"
|
#include "StorageService.h"
|
||||||
|
|||||||
@@ -5,16 +5,15 @@
|
|||||||
// Created by Stephane Bourque on 2021-03-04.
|
// Created by Stephane Bourque on 2021-03-04.
|
||||||
// Arilia Wireless Inc.
|
// Arilia Wireless Inc.
|
||||||
//
|
//
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "framework/MicroService.h"
|
#pragma once
|
||||||
#include "RESTObjects/RESTAPI_ProvObjects.h"
|
#include "framework/RESTAPI_Handler.h"
|
||||||
#include "StorageService.h"
|
#include "StorageService.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
class RESTAPI_configurations_handler : public RESTAPIHandler {
|
class RESTAPI_configurations_handler : public RESTAPIHandler {
|
||||||
public:
|
public:
|
||||||
RESTAPI_configurations_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
|
RESTAPI_configurations_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
|
||||||
: RESTAPIHandler(bindings, L,
|
: RESTAPIHandler(bindings, L,
|
||||||
std::vector<std::string>{
|
std::vector<std::string>{
|
||||||
Poco::Net::HTTPRequest::HTTP_GET, Poco::Net::HTTPRequest::HTTP_POST,
|
Poco::Net::HTTPRequest::HTTP_GET, Poco::Net::HTTPRequest::HTTP_POST,
|
||||||
|
|||||||
@@ -3,15 +3,14 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "framework/RESTAPI_Handler.h"
|
||||||
#include "framework/MicroService.h"
|
|
||||||
#include "StorageService.h"
|
#include "StorageService.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
|
|
||||||
class RESTAPI_configurations_list_handler : public RESTAPIHandler {
|
class RESTAPI_configurations_list_handler : public RESTAPIHandler {
|
||||||
public:
|
public:
|
||||||
RESTAPI_configurations_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
|
RESTAPI_configurations_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
|
||||||
: RESTAPIHandler(bindings, L,
|
: RESTAPIHandler(bindings, L,
|
||||||
std::vector<std::string>{
|
std::vector<std::string>{
|
||||||
Poco::Net::HTTPRequest::HTTP_GET,
|
Poco::Net::HTTPRequest::HTTP_GET,
|
||||||
|
|||||||
@@ -7,14 +7,13 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "framework/RESTAPI_Handler.h"
|
||||||
#include "framework/MicroService.h"
|
|
||||||
#include "StorageService.h"
|
#include "StorageService.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
class RESTAPI_contact_handler : public RESTAPIHandler {
|
class RESTAPI_contact_handler : public RESTAPIHandler {
|
||||||
public:
|
public:
|
||||||
RESTAPI_contact_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
|
RESTAPI_contact_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
|
||||||
: RESTAPIHandler(bindings, L,
|
: RESTAPIHandler(bindings, L,
|
||||||
std::vector<std::string>{
|
std::vector<std::string>{
|
||||||
Poco::Net::HTTPRequest::HTTP_GET, Poco::Net::HTTPRequest::HTTP_POST,
|
Poco::Net::HTTPRequest::HTTP_GET, Poco::Net::HTTPRequest::HTTP_POST,
|
||||||
|
|||||||
@@ -3,16 +3,14 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "framework/RESTAPI_Handler.h"
|
||||||
#include "framework/MicroService.h"
|
|
||||||
#include "RESTObjects/RESTAPI_ProvObjects.h"
|
|
||||||
#include "StorageService.h"
|
#include "StorageService.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
|
|
||||||
class RESTAPI_contact_list_handler : public RESTAPIHandler {
|
class RESTAPI_contact_list_handler : public RESTAPIHandler {
|
||||||
public:
|
public:
|
||||||
RESTAPI_contact_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
|
RESTAPI_contact_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
|
||||||
: RESTAPIHandler(bindings, L,
|
: RESTAPIHandler(bindings, L,
|
||||||
std::vector<std::string>{
|
std::vector<std::string>{
|
||||||
Poco::Net::HTTPRequest::HTTP_GET,
|
Poco::Net::HTTPRequest::HTTP_GET,
|
||||||
|
|||||||
@@ -6,9 +6,11 @@
|
|||||||
|
|
||||||
#include "RESTObjects/RESTAPI_ProvObjects.h"
|
#include "RESTObjects/RESTAPI_ProvObjects.h"
|
||||||
#include "StorageService.h"
|
#include "StorageService.h"
|
||||||
#include "framework/MicroService.h"
|
|
||||||
#include "framework/ConfigurationValidator.h"
|
#include "framework/ConfigurationValidator.h"
|
||||||
#include "sdks/SDK_sec.h"
|
#include "sdks/SDK_sec.h"
|
||||||
|
#include "Poco/StringTokenizer.h"
|
||||||
|
|
||||||
|
#include "libs/croncpp.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
|
|
||||||
@@ -405,7 +407,9 @@ namespace OpenWifi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline bool ValidateConfigBlock(const ProvObjects::DeviceConfiguration &Config, RESTAPI::Errors::msg & Error) {
|
inline bool ValidateConfigBlock(const ProvObjects::DeviceConfiguration &Config, RESTAPI::Errors::msg & Error) {
|
||||||
static const std::vector<std::string> SectionNames{ "globals", "interfaces", "metrics", "radios", "services", "unit" };
|
static const std::vector<std::string> SectionNames{ "globals", "interfaces", "metrics", "radios", "services",
|
||||||
|
"unit", "definitions", "ethernet", "switch", "config-raw",
|
||||||
|
"third-party" };
|
||||||
|
|
||||||
for(const auto &i:Config.configuration) {
|
for(const auto &i:Config.configuration) {
|
||||||
Poco::JSON::Parser P;
|
Poco::JSON::Parser P;
|
||||||
@@ -521,12 +525,39 @@ namespace OpenWifi {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Result;
|
return Result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline bool ValidSchedule(const std::string &v) {
|
||||||
|
try
|
||||||
|
{
|
||||||
|
auto cron = cron::make_cron(v);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
catch (cron::bad_cronexpr const & ex)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline bool ValidRRM(const std::string &v) {
|
||||||
|
if((v=="no") || (v=="inherit")) return true;
|
||||||
|
try {
|
||||||
|
Poco::JSON::Parser P;
|
||||||
|
auto O = P.parse(v).extract<Poco::JSON::Object::Ptr>();
|
||||||
|
|
||||||
|
ProvObjects::RRMDetails D;
|
||||||
|
if(D.from_json(O)) {
|
||||||
|
return ValidSchedule(D.schedule);
|
||||||
|
}
|
||||||
|
} catch (...) {
|
||||||
|
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
inline bool ValidDeviceRules(const ProvObjects::DeviceRules & DR) {
|
inline bool ValidDeviceRules(const ProvObjects::DeviceRules & DR) {
|
||||||
return (DR.rrm=="yes" || DR.rrm=="no" || DR.rrm=="inherit") &&
|
return (ValidRRM(DR.rrm)) &&
|
||||||
(DR.firmwareUpgrade=="yes" || DR.firmwareUpgrade=="no" || DR.firmwareUpgrade=="inherit") &&
|
(DR.firmwareUpgrade=="yes" || DR.firmwareUpgrade=="no" || DR.firmwareUpgrade=="inherit") &&
|
||||||
(DR.rcOnly=="yes" || DR.rcOnly=="no" || DR.rcOnly=="inherit");
|
(DR.rcOnly=="yes" || DR.rcOnly=="no" || DR.rcOnly=="inherit");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,8 @@
|
|||||||
#include "StorageService.h"
|
#include "StorageService.h"
|
||||||
#include "RESTAPI_db_helpers.h"
|
#include "RESTAPI_db_helpers.h"
|
||||||
|
|
||||||
|
#include "framework/CIDR.h"
|
||||||
|
|
||||||
namespace OpenWifi{
|
namespace OpenWifi{
|
||||||
|
|
||||||
void RESTAPI_entity_handler::DoGet() {
|
void RESTAPI_entity_handler::DoGet() {
|
||||||
@@ -78,7 +80,7 @@ namespace OpenWifi{
|
|||||||
|
|
||||||
// When creating an entity, it cannot have any relations other that parent, notes, name, description. Everything else
|
// When creating an entity, it cannot have any relations other that parent, notes, name, description. Everything else
|
||||||
// must be conveyed through PUT.
|
// must be conveyed through PUT.
|
||||||
NewEntity.info.id = (UUID==EntityDB::RootUUID()) ? UUID : MicroService::CreateUUID();
|
NewEntity.info.id = (UUID==EntityDB::RootUUID()) ? UUID : MicroServiceCreateUUID();
|
||||||
|
|
||||||
if(UUID==EntityDB::RootUUID()) {
|
if(UUID==EntityDB::RootUUID()) {
|
||||||
NewEntity.parent="";
|
NewEntity.parent="";
|
||||||
|
|||||||
@@ -7,14 +7,13 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "framework/RESTAPI_Handler.h"
|
||||||
#include "framework/MicroService.h"
|
|
||||||
#include "StorageService.h"
|
#include "StorageService.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
class RESTAPI_entity_handler : public RESTAPIHandler {
|
class RESTAPI_entity_handler : public RESTAPIHandler {
|
||||||
public:
|
public:
|
||||||
RESTAPI_entity_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
|
RESTAPI_entity_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
|
||||||
: RESTAPIHandler(bindings, L,
|
: RESTAPIHandler(bindings, L,
|
||||||
std::vector<std::string>{
|
std::vector<std::string>{
|
||||||
Poco::Net::HTTPRequest::HTTP_GET,
|
Poco::Net::HTTPRequest::HTTP_GET,
|
||||||
|
|||||||
@@ -6,7 +6,6 @@
|
|||||||
// Arilia Wireless Inc.
|
// Arilia Wireless Inc.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "framework/MicroService.h"
|
|
||||||
#include "RESTAPI_entity_list_handler.h"
|
#include "RESTAPI_entity_list_handler.h"
|
||||||
#include "StorageService.h"
|
#include "StorageService.h"
|
||||||
#include "RESTAPI_db_helpers.h"
|
#include "RESTAPI_db_helpers.h"
|
||||||
|
|||||||
@@ -8,14 +8,13 @@
|
|||||||
|
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "framework/RESTAPI_Handler.h"
|
||||||
#include "framework/MicroService.h"
|
|
||||||
#include "StorageService.h"
|
#include "StorageService.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
class RESTAPI_entity_list_handler : public RESTAPIHandler {
|
class RESTAPI_entity_list_handler : public RESTAPIHandler {
|
||||||
public:
|
public:
|
||||||
RESTAPI_entity_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
|
RESTAPI_entity_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
|
||||||
: RESTAPIHandler(bindings, L,
|
: RESTAPIHandler(bindings, L,
|
||||||
std::vector<std::string>{
|
std::vector<std::string>{
|
||||||
Poco::Net::HTTPRequest::HTTP_GET,
|
Poco::Net::HTTPRequest::HTTP_GET,
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
#include "RESTAPI/RESTAPI_db_helpers.h"
|
#include "RESTAPI/RESTAPI_db_helpers.h"
|
||||||
#include "SerialNumberCache.h"
|
#include "SerialNumberCache.h"
|
||||||
#include "DeviceTypeCache.h"
|
#include "DeviceTypeCache.h"
|
||||||
|
#include "framework/utils.h"
|
||||||
|
|
||||||
namespace OpenWifi{
|
namespace OpenWifi{
|
||||||
|
|
||||||
@@ -36,61 +37,91 @@ namespace OpenWifi{
|
|||||||
void RESTAPI_inventory_handler::DoGet() {
|
void RESTAPI_inventory_handler::DoGet() {
|
||||||
|
|
||||||
ProvObjects::InventoryTag Existing;
|
ProvObjects::InventoryTag Existing;
|
||||||
std::string SerialNumber = GetBinding(RESTAPI::Protocol::SERIALNUMBER,"");
|
std::string SerialNumber = GetBinding(RESTAPI::Protocol::SERIALNUMBER, "");
|
||||||
Logger().debug(Poco::format("%s: Retrieving inventory information.",SerialNumber));
|
poco_debug(Logger(),fmt::format("{}: Retrieving inventory information.", SerialNumber));
|
||||||
if(SerialNumber.empty() || !DB_.GetRecord(RESTAPI::Protocol::SERIALNUMBER,SerialNumber,Existing)) {
|
if (SerialNumber.empty() || !DB_.GetRecord(RESTAPI::Protocol::SERIALNUMBER, SerialNumber, Existing)) {
|
||||||
return NotFound();
|
return NotFound();
|
||||||
}
|
}
|
||||||
Logger().debug(Poco::format("%s,%s: Retrieving inventory information.", Existing.serialNumber, Existing.info.id ));
|
poco_debug(Logger(), fmt::format("{},{}: Retrieving inventory information.", Existing.serialNumber, Existing.info.id));
|
||||||
|
|
||||||
Poco::JSON::Object Answer;
|
Poco::JSON::Object Answer;
|
||||||
std::string Arg;
|
std::string Arg;
|
||||||
if(HasParameter("config",Arg) && Arg=="true") {
|
if (GetBoolParameter("config", false)) {
|
||||||
bool Explain = (HasParameter("explain",Arg) && Arg == "true");
|
bool Explain = GetBoolParameter("explain", false);
|
||||||
APConfig Device(SerialNumber,Existing.deviceType,Logger(), Explain);
|
|
||||||
|
APConfig Device(SerialNumber, Existing.deviceType, Logger(), Explain);
|
||||||
|
|
||||||
auto Configuration = Poco::makeShared<Poco::JSON::Object>();
|
auto Configuration = Poco::makeShared<Poco::JSON::Object>();
|
||||||
if(Device.Get(Configuration)) {
|
if (Device.Get(Configuration)) {
|
||||||
Answer.set("config", Configuration);
|
Answer.set("config", Configuration);
|
||||||
if(Explain)
|
if (Explain)
|
||||||
Answer.set("explanation", Device.Explanation());
|
Answer.set("explanation", Device.Explanation());
|
||||||
} else {
|
} else {
|
||||||
Answer.set("config","none");
|
Answer.set("config", "none");
|
||||||
}
|
}
|
||||||
return ReturnObject(Answer);
|
return ReturnObject(Answer);
|
||||||
} else if(HasParameter("firmwareOptions", Arg) && Arg=="true") {
|
} else if (GetBoolParameter("firmwareOptions", false)) {
|
||||||
ProvObjects::DeviceRules Rules;
|
ProvObjects::DeviceRules Rules;
|
||||||
StorageService()->InventoryDB().EvaluateDeviceSerialNumberRules(SerialNumber,Rules);
|
StorageService()->InventoryDB().EvaluateDeviceSerialNumberRules(SerialNumber, Rules);
|
||||||
Answer.set("firmwareUpgrade",Rules.firmwareUpgrade);
|
Answer.set("firmwareUpgrade", Rules.firmwareUpgrade);
|
||||||
Answer.set("firmwareRCOnly", Rules.rcOnly == "yes" );
|
Answer.set("firmwareRCOnly", Rules.rcOnly == "yes");
|
||||||
return ReturnObject(Answer);
|
return ReturnObject(Answer);
|
||||||
} else if(HasParameter("applyConfiguration",Arg) && Arg=="true") {
|
} else if(GetBoolParameter("rrmSettings",false)) {
|
||||||
Logger().debug(Poco::format("%s: Retrieving configuration.",Existing.serialNumber));
|
ProvObjects::DeviceRules Rules;
|
||||||
|
StorageService()->InventoryDB().EvaluateDeviceSerialNumberRules(SerialNumber, Rules);
|
||||||
|
if(Rules.rrm=="no" || Rules.rrm=="inherit") {
|
||||||
|
Answer.set("rrm", Rules.rrm);
|
||||||
|
} else {
|
||||||
|
ProvObjects::RRMDetails D;
|
||||||
|
Poco::JSON::Parser P;
|
||||||
|
try {
|
||||||
|
auto Obj = P.parse(Rules.rrm).extract<Poco::JSON::Object::Ptr>();
|
||||||
|
Answer.set("rrm", Obj);
|
||||||
|
} catch (...) {
|
||||||
|
Answer.set("rrm", "invalid");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ReturnObject(Answer);
|
||||||
|
} else if(GetBoolParameter("applyConfiguration", false)) {
|
||||||
|
poco_debug(Logger(), fmt::format("{}: Retrieving configuration.",Existing.serialNumber));
|
||||||
auto Device = std::make_shared<APConfig>(SerialNumber, Existing.deviceType, Logger(), false);
|
auto Device = std::make_shared<APConfig>(SerialNumber, Existing.deviceType, Logger(), false);
|
||||||
auto Configuration = Poco::makeShared<Poco::JSON::Object>();
|
auto Configuration = Poco::makeShared<Poco::JSON::Object>();
|
||||||
Poco::JSON::Object ErrorsObj, WarningsObj;
|
Poco::JSON::Object ErrorsObj, WarningsObj;
|
||||||
ProvObjects::InventoryConfigApplyResult Results;
|
ProvObjects::InventoryConfigApplyResult Results;
|
||||||
Logger().debug(Poco::format("%s: Computing configuration.",Existing.serialNumber));
|
poco_debug(Logger(), fmt::format("{}: Computing configuration.",Existing.serialNumber));
|
||||||
if (Device->Get(Configuration)) {
|
if (Device->Get(Configuration)) {
|
||||||
std::ostringstream OS;
|
std::ostringstream OS;
|
||||||
Configuration->stringify(OS);
|
Configuration->stringify(OS);
|
||||||
Results.appliedConfiguration = OS.str();
|
Results.appliedConfiguration = OS.str();
|
||||||
auto Response=Poco::makeShared<Poco::JSON::Object>();
|
auto Response=Poco::makeShared<Poco::JSON::Object>();
|
||||||
Logger().debug(Poco::format("%s: Sending configuration push.",Existing.serialNumber));
|
poco_debug(Logger(), fmt::format("{}: Sending configuration push.",Existing.serialNumber));
|
||||||
if (SDK::GW::Device::Configure(this, SerialNumber, Configuration, Response)) {
|
if (SDK::GW::Device::Configure(this, SerialNumber, Configuration, Response)) {
|
||||||
Logger().debug(Poco::format("%s: Sending configuration pushed.",Existing.serialNumber));
|
poco_debug(Logger(), fmt::format("{}: Sending configuration pushed.",Existing.serialNumber));
|
||||||
GetRejectedLines(Response, Results.warnings);
|
GetRejectedLines(Response, Results.warnings);
|
||||||
Results.errorCode = 0;
|
Results.errorCode = 0;
|
||||||
} else {
|
} else {
|
||||||
Logger().debug(Poco::format("%s: Sending configuration failed.",Existing.serialNumber));
|
poco_debug(Logger(), fmt::format("{}: Sending configuration failed.",Existing.serialNumber));
|
||||||
Results.errorCode = 1;
|
Results.errorCode = 1;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Logger().debug(Poco::format("%s: Configuration is bad.",Existing.serialNumber));
|
poco_debug(Logger(), fmt::format("{}: Configuration is bad.",Existing.serialNumber));
|
||||||
Results.errorCode = 1;
|
Results.errorCode = 1;
|
||||||
}
|
}
|
||||||
Results.to_json(Answer);
|
Results.to_json(Answer);
|
||||||
return ReturnObject(Answer);
|
return ReturnObject(Answer);
|
||||||
|
} else if(GetBoolParameter("resolveConfig", false)) {
|
||||||
|
poco_debug(Logger(),fmt::format("{}: 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));
|
||||||
|
if (Device->Get(Configuration)) {
|
||||||
|
Answer.set("configuration", Configuration);
|
||||||
|
} else {
|
||||||
|
Answer.set("error", 1);
|
||||||
|
}
|
||||||
|
return ReturnObject(Answer);
|
||||||
} else if(QB_.AdditionalInfo) {
|
} else if(QB_.AdditionalInfo) {
|
||||||
AddExtendedInfo(Existing,Answer);
|
AddExtendedInfo(Existing,Answer);
|
||||||
}
|
}
|
||||||
@@ -136,6 +167,7 @@ namespace OpenWifi{
|
|||||||
|
|
||||||
void RESTAPI_inventory_handler::DoPost() {
|
void RESTAPI_inventory_handler::DoPost() {
|
||||||
std::string SerialNumber = GetBinding(RESTAPI::Protocol::SERIALNUMBER,"");
|
std::string SerialNumber = GetBinding(RESTAPI::Protocol::SERIALNUMBER,"");
|
||||||
|
Poco::toLowerInPlace(SerialNumber);
|
||||||
if(SerialNumber.empty()) {
|
if(SerialNumber.empty()) {
|
||||||
return BadRequest(RESTAPI::Errors::MissingSerialNumber);
|
return BadRequest(RESTAPI::Errors::MissingSerialNumber);
|
||||||
}
|
}
|
||||||
@@ -154,6 +186,11 @@ namespace OpenWifi{
|
|||||||
return BadRequest(RESTAPI::Errors::InvalidJSONDocument);
|
return BadRequest(RESTAPI::Errors::InvalidJSONDocument);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
NormalizeMac(NewObject.serialNumber);
|
||||||
|
if(SerialNumber!=NewObject.serialNumber) {
|
||||||
|
return BadRequest(RESTAPI::Errors::SerialNumberMismatch);
|
||||||
|
}
|
||||||
|
|
||||||
if((RawObject->has("deviceRules") && !ValidDeviceRules(NewObject.deviceRules,*this))) {
|
if((RawObject->has("deviceRules") && !ValidDeviceRules(NewObject.deviceRules,*this))) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -242,23 +279,23 @@ namespace OpenWifi{
|
|||||||
auto RemoveSubscriber = GetParameter("removeSubscriber");
|
auto RemoveSubscriber = GetParameter("removeSubscriber");
|
||||||
if(!RemoveSubscriber.empty()) {
|
if(!RemoveSubscriber.empty()) {
|
||||||
if(Existing.subscriber == RemoveSubscriber) {
|
if(Existing.subscriber == RemoveSubscriber) {
|
||||||
Logger().information(Poco::format("%s: removing subscriber (%s)", SerialNumber, RemoveSubscriber));
|
poco_information(Logger(),fmt::format("{}: removing subscriber ({})", SerialNumber, RemoveSubscriber));
|
||||||
ProvObjects::DeviceConfiguration DC;
|
ProvObjects::DeviceConfiguration DC;
|
||||||
if(StorageService()->ConfigurationDB().GetRecord("id",Existing.deviceConfiguration,DC)) {
|
if(StorageService()->ConfigurationDB().GetRecord("id",Existing.deviceConfiguration,DC)) {
|
||||||
Logger().information(Poco::format("%s: removing configuration for subscriber (%s)", SerialNumber, RemoveSubscriber));
|
poco_information(Logger(),fmt::format("{}: removing configuration for subscriber ({})", SerialNumber, RemoveSubscriber));
|
||||||
if(DC.subscriberOnly) {
|
if(DC.subscriberOnly) {
|
||||||
if(!StorageService()->ConfigurationDB().DeleteRecord("id", Existing.deviceConfiguration)) {
|
if(!StorageService()->ConfigurationDB().DeleteRecord("id", Existing.deviceConfiguration)) {
|
||||||
Logger().debug("Could not delete the subscriber configuration");
|
poco_debug(Logger(),"Could not delete the subscriber configuration");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Logger().debug("Configurations is not for a subscriber.");
|
poco_debug(Logger(),"Configurations is not for a subscriber.");
|
||||||
}
|
}
|
||||||
Existing.deviceConfiguration = "";
|
Existing.deviceConfiguration = "";
|
||||||
}
|
}
|
||||||
Existing.subscriber = "";
|
Existing.subscriber = "";
|
||||||
Poco::JSON::Object state;
|
Poco::JSON::Object state;
|
||||||
state.set("date",OpenWifi::Now());
|
state.set("date",Utils::Now());
|
||||||
state.set("method","auto-discovery");
|
state.set("method","auto-discovery");
|
||||||
state.set("last-operation", "returned to inventory");
|
state.set("last-operation", "returned to inventory");
|
||||||
std::ostringstream OO;
|
std::ostringstream OO;
|
||||||
@@ -271,7 +308,7 @@ namespace OpenWifi{
|
|||||||
SDK::GW::Device::SetSubscriber(nullptr, SerialNumber, "");
|
SDK::GW::Device::SetSubscriber(nullptr, SerialNumber, "");
|
||||||
return ReturnObject(Answer);
|
return ReturnObject(Answer);
|
||||||
} else {
|
} else {
|
||||||
Logger().information(Poco::format("%s: wrong subscriber (%s)", SerialNumber, RemoveSubscriber));
|
poco_information(Logger(),fmt::format("{}: wrong subscriber ({})", SerialNumber, RemoveSubscriber));
|
||||||
}
|
}
|
||||||
return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
|
return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
|
||||||
}
|
}
|
||||||
@@ -349,6 +386,8 @@ namespace OpenWifi{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
AssignIfPresent(RawObject, "doNotAllowOverrides", Existing.doNotAllowOverrides);
|
||||||
|
|
||||||
if( RawObject->has("devClass") && NewObject.devClass!= Existing.devClass) {
|
if( RawObject->has("devClass") && NewObject.devClass!= Existing.devClass) {
|
||||||
Existing.devClass = NewObject.devClass;
|
Existing.devClass = NewObject.devClass;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,14 +7,13 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "framework/RESTAPI_Handler.h"
|
||||||
#include "framework/MicroService.h"
|
|
||||||
#include "StorageService.h"
|
#include "StorageService.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
class RESTAPI_inventory_handler : public RESTAPIHandler {
|
class RESTAPI_inventory_handler : public RESTAPIHandler {
|
||||||
public:
|
public:
|
||||||
RESTAPI_inventory_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
|
RESTAPI_inventory_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
|
||||||
: RESTAPIHandler(bindings, L,
|
: RESTAPIHandler(bindings, L,
|
||||||
std::vector<std::string>{
|
std::vector<std::string>{
|
||||||
Poco::Net::HTTPRequest::HTTP_GET, Poco::Net::HTTPRequest::HTTP_POST,
|
Poco::Net::HTTPRequest::HTTP_GET, Poco::Net::HTTPRequest::HTTP_POST,
|
||||||
|
|||||||
@@ -7,15 +7,14 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "framework/RESTAPI_Handler.h"
|
||||||
#include "StorageService.h"
|
#include "StorageService.h"
|
||||||
#include "framework/MicroService.h"
|
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
|
|
||||||
class RESTAPI_inventory_list_handler : public RESTAPIHandler {
|
class RESTAPI_inventory_list_handler : public RESTAPIHandler {
|
||||||
public:
|
public:
|
||||||
RESTAPI_inventory_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
|
RESTAPI_inventory_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
|
||||||
: RESTAPIHandler(bindings, L,
|
: RESTAPIHandler(bindings, L,
|
||||||
std::vector<std::string>{
|
std::vector<std::string>{
|
||||||
Poco::Net::HTTPRequest::HTTP_GET,
|
Poco::Net::HTTPRequest::HTTP_GET,
|
||||||
|
|||||||
@@ -3,13 +3,13 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "framework/RESTAPI_Handler.h"
|
||||||
#include "framework/MicroService.h"
|
#include "StorageService.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
class RESTAPI_iptocountry_handler : public RESTAPIHandler {
|
class RESTAPI_iptocountry_handler : public RESTAPIHandler {
|
||||||
public:
|
public:
|
||||||
RESTAPI_iptocountry_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
|
RESTAPI_iptocountry_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
|
||||||
: RESTAPIHandler(bindings, L,
|
: RESTAPIHandler(bindings, L,
|
||||||
std::vector<std::string>{Poco::Net::HTTPRequest::HTTP_GET,
|
std::vector<std::string>{Poco::Net::HTTPRequest::HTTP_GET,
|
||||||
Poco::Net::HTTPRequest::HTTP_OPTIONS},
|
Poco::Net::HTTPRequest::HTTP_OPTIONS},
|
||||||
|
|||||||
@@ -12,6 +12,7 @@
|
|||||||
#include "StorageService.h"
|
#include "StorageService.h"
|
||||||
#include "Daemon.h"
|
#include "Daemon.h"
|
||||||
#include "RESTAPI/RESTAPI_db_helpers.h"
|
#include "RESTAPI/RESTAPI_db_helpers.h"
|
||||||
|
#include "framework/utils.h"
|
||||||
|
|
||||||
namespace OpenWifi{
|
namespace OpenWifi{
|
||||||
|
|
||||||
@@ -147,7 +148,7 @@ namespace OpenWifi{
|
|||||||
Existing.phones = NewObject.phones;
|
Existing.phones = NewObject.phones;
|
||||||
if(RawObject->has("mobiles"))
|
if(RawObject->has("mobiles"))
|
||||||
Existing.mobiles = NewObject.mobiles;
|
Existing.mobiles = NewObject.mobiles;
|
||||||
Existing.info.modified = OpenWifi::Now();
|
Existing.info.modified = Utils::Now();
|
||||||
if(RawObject->has("type"))
|
if(RawObject->has("type"))
|
||||||
Existing.type = NewObject.type;
|
Existing.type = NewObject.type;
|
||||||
|
|
||||||
|
|||||||
@@ -7,14 +7,13 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "framework/RESTAPI_Handler.h"
|
||||||
#include "framework/MicroService.h"
|
|
||||||
#include "StorageService.h"
|
#include "StorageService.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
class RESTAPI_location_handler : public RESTAPIHandler {
|
class RESTAPI_location_handler : public RESTAPIHandler {
|
||||||
public:
|
public:
|
||||||
RESTAPI_location_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
|
RESTAPI_location_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
|
||||||
: RESTAPIHandler(bindings, L,
|
: RESTAPIHandler(bindings, L,
|
||||||
std::vector<std::string>{
|
std::vector<std::string>{
|
||||||
Poco::Net::HTTPRequest::HTTP_GET, Poco::Net::HTTPRequest::HTTP_POST,
|
Poco::Net::HTTPRequest::HTTP_GET, Poco::Net::HTTPRequest::HTTP_POST,
|
||||||
|
|||||||
@@ -3,15 +3,14 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "framework/RESTAPI_Handler.h"
|
||||||
#include "framework/MicroService.h"
|
|
||||||
#include "StorageService.h"
|
#include "StorageService.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
|
|
||||||
class RESTAPI_location_list_handler : public RESTAPIHandler {
|
class RESTAPI_location_list_handler : public RESTAPIHandler {
|
||||||
public:
|
public:
|
||||||
RESTAPI_location_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
|
RESTAPI_location_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
|
||||||
: RESTAPIHandler(bindings, L,
|
: RESTAPIHandler(bindings, L,
|
||||||
std::vector<std::string>{
|
std::vector<std::string>{
|
||||||
Poco::Net::HTTPRequest::HTTP_GET,
|
Poco::Net::HTTPRequest::HTTP_GET,
|
||||||
|
|||||||
@@ -7,13 +7,14 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
#include "framework/MicroService.h"
|
#pragma once
|
||||||
|
#include "framework/RESTAPI_Handler.h"
|
||||||
#include "StorageService.h"
|
#include "StorageService.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
class RESTAPI_managementPolicy_handler : public RESTAPIHandler {
|
class RESTAPI_managementPolicy_handler : public RESTAPIHandler {
|
||||||
public:
|
public:
|
||||||
RESTAPI_managementPolicy_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
|
RESTAPI_managementPolicy_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
|
||||||
: RESTAPIHandler(bindings, L,
|
: RESTAPIHandler(bindings, L,
|
||||||
std::vector<std::string>{
|
std::vector<std::string>{
|
||||||
Poco::Net::HTTPRequest::HTTP_GET, Poco::Net::HTTPRequest::HTTP_POST,
|
Poco::Net::HTTPRequest::HTTP_GET, Poco::Net::HTTPRequest::HTTP_POST,
|
||||||
|
|||||||
@@ -2,14 +2,15 @@
|
|||||||
// Created by stephane bourque on 2021-08-26.
|
// Created by stephane bourque on 2021-08-26.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "framework/MicroService.h"
|
#pragma once
|
||||||
|
#include "framework/RESTAPI_Handler.h"
|
||||||
#include "StorageService.h"
|
#include "StorageService.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
|
|
||||||
class RESTAPI_managementPolicy_list_handler : public RESTAPIHandler {
|
class RESTAPI_managementPolicy_list_handler : public RESTAPIHandler {
|
||||||
public:
|
public:
|
||||||
RESTAPI_managementPolicy_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
|
RESTAPI_managementPolicy_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
|
||||||
: RESTAPIHandler(bindings, L,
|
: RESTAPIHandler(bindings, L,
|
||||||
std::vector<std::string>{
|
std::vector<std::string>{
|
||||||
Poco::Net::HTTPRequest::HTTP_GET,
|
Poco::Net::HTTPRequest::HTTP_GET,
|
||||||
|
|||||||
@@ -2,13 +2,14 @@
|
|||||||
// Created by stephane bourque on 2021-08-26.
|
// Created by stephane bourque on 2021-08-26.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "framework/MicroService.h"
|
#pragma once
|
||||||
|
#include "framework/RESTAPI_Handler.h"
|
||||||
#include "StorageService.h"
|
#include "StorageService.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
class RESTAPI_managementRole_handler : public RESTAPIHandler {
|
class RESTAPI_managementRole_handler : public RESTAPIHandler {
|
||||||
public:
|
public:
|
||||||
RESTAPI_managementRole_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
|
RESTAPI_managementRole_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
|
||||||
: RESTAPIHandler(bindings, L,
|
: RESTAPIHandler(bindings, L,
|
||||||
std::vector<std::string>{
|
std::vector<std::string>{
|
||||||
Poco::Net::HTTPRequest::HTTP_GET, Poco::Net::HTTPRequest::HTTP_POST,
|
Poco::Net::HTTPRequest::HTTP_GET, Poco::Net::HTTPRequest::HTTP_POST,
|
||||||
|
|||||||
@@ -2,10 +2,7 @@
|
|||||||
// Created by stephane bourque on 2021-08-26.
|
// Created by stephane bourque on 2021-08-26.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "framework/MicroService.h"
|
|
||||||
|
|
||||||
#include "RESTAPI_managementRole_list_handler.h"
|
#include "RESTAPI_managementRole_list_handler.h"
|
||||||
#include "RESTObjects/RESTAPI_ProvObjects.h"
|
|
||||||
#include "StorageService.h"
|
#include "StorageService.h"
|
||||||
#include "RESTAPI/RESTAPI_db_helpers.h"
|
#include "RESTAPI/RESTAPI_db_helpers.h"
|
||||||
|
|
||||||
|
|||||||
@@ -1,16 +1,16 @@
|
|||||||
//
|
//
|
||||||
// Created by stephane bourque on 2021-08-26.
|
// Created by stephane bourque on 2021-08-26.
|
||||||
//
|
//
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "framework/MicroService.h"
|
#pragma once
|
||||||
|
#include "framework/RESTAPI_Handler.h"
|
||||||
#include "StorageService.h"
|
#include "StorageService.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
|
|
||||||
class RESTAPI_managementRole_list_handler : public RESTAPIHandler {
|
class RESTAPI_managementRole_list_handler : public RESTAPIHandler {
|
||||||
public:
|
public:
|
||||||
RESTAPI_managementRole_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
|
RESTAPI_managementRole_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
|
||||||
: RESTAPIHandler(bindings, L,
|
: RESTAPIHandler(bindings, L,
|
||||||
std::vector<std::string>{
|
std::vector<std::string>{
|
||||||
Poco::Net::HTTPRequest::HTTP_GET,
|
Poco::Net::HTTPRequest::HTTP_GET,
|
||||||
|
|||||||
@@ -2,14 +2,13 @@
|
|||||||
// Created by stephane bourque on 2021-11-09.
|
// Created by stephane bourque on 2021-11-09.
|
||||||
//
|
//
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "framework/RESTAPI_Handler.h"
|
||||||
#include "framework/MicroService.h"
|
|
||||||
#include "StorageService.h"
|
#include "StorageService.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
class RESTAPI_map_handler : public RESTAPIHandler {
|
class RESTAPI_map_handler : public RESTAPIHandler {
|
||||||
public:
|
public:
|
||||||
RESTAPI_map_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
|
RESTAPI_map_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
|
||||||
: RESTAPIHandler(bindings, L,
|
: RESTAPIHandler(bindings, L,
|
||||||
std::vector<std::string>{
|
std::vector<std::string>{
|
||||||
Poco::Net::HTTPRequest::HTTP_GET, Poco::Net::HTTPRequest::HTTP_POST,
|
Poco::Net::HTTPRequest::HTTP_GET, Poco::Net::HTTPRequest::HTTP_POST,
|
||||||
|
|||||||
@@ -2,15 +2,14 @@
|
|||||||
// Created by stephane bourque on 2021-11-09.
|
// Created by stephane bourque on 2021-11-09.
|
||||||
//
|
//
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "framework/RESTAPI_Handler.h"
|
||||||
#include "framework/MicroService.h"
|
|
||||||
#include "StorageService.h"
|
#include "StorageService.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
|
|
||||||
class RESTAPI_map_list_handler : public RESTAPIHandler {
|
class RESTAPI_map_list_handler : public RESTAPIHandler {
|
||||||
public:
|
public:
|
||||||
RESTAPI_map_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
|
RESTAPI_map_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
|
||||||
: RESTAPIHandler(bindings, L,
|
: RESTAPIHandler(bindings, L,
|
||||||
std::vector<std::string>{
|
std::vector<std::string>{
|
||||||
Poco::Net::HTTPRequest::HTTP_GET,
|
Poco::Net::HTTPRequest::HTTP_GET,
|
||||||
|
|||||||
@@ -3,14 +3,13 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "framework/RESTAPI_Handler.h"
|
||||||
#include "framework/MicroService.h"
|
|
||||||
#include "StorageService.h"
|
#include "StorageService.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
class RESTAPI_op_contact_handler : public RESTAPIHandler {
|
class RESTAPI_op_contact_handler : public RESTAPIHandler {
|
||||||
public:
|
public:
|
||||||
RESTAPI_op_contact_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
|
RESTAPI_op_contact_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
|
||||||
: RESTAPIHandler(bindings, L,
|
: RESTAPIHandler(bindings, L,
|
||||||
std::vector<std::string>{
|
std::vector<std::string>{
|
||||||
Poco::Net::HTTPRequest::HTTP_GET, Poco::Net::HTTPRequest::HTTP_POST,
|
Poco::Net::HTTPRequest::HTTP_GET, Poco::Net::HTTPRequest::HTTP_POST,
|
||||||
|
|||||||
@@ -2,15 +2,14 @@
|
|||||||
// Created by stephane bourque on 2022-04-07.
|
// Created by stephane bourque on 2022-04-07.
|
||||||
//
|
//
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "framework/RESTAPI_Handler.h"
|
||||||
#include "framework/MicroService.h"
|
|
||||||
#include "StorageService.h"
|
#include "StorageService.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
|
|
||||||
class RESTAPI_op_contact_list_handler : public RESTAPIHandler {
|
class RESTAPI_op_contact_list_handler : public RESTAPIHandler {
|
||||||
public:
|
public:
|
||||||
RESTAPI_op_contact_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
|
RESTAPI_op_contact_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
|
||||||
: RESTAPIHandler(bindings, L,
|
: RESTAPIHandler(bindings, L,
|
||||||
std::vector<std::string>{
|
std::vector<std::string>{
|
||||||
Poco::Net::HTTPRequest::HTTP_GET,
|
Poco::Net::HTTPRequest::HTTP_GET,
|
||||||
|
|||||||
@@ -3,14 +3,13 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "framework/RESTAPI_Handler.h"
|
||||||
#include "framework/MicroService.h"
|
|
||||||
#include "StorageService.h"
|
#include "StorageService.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
class RESTAPI_op_location_handler : public RESTAPIHandler {
|
class RESTAPI_op_location_handler : public RESTAPIHandler {
|
||||||
public:
|
public:
|
||||||
RESTAPI_op_location_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
|
RESTAPI_op_location_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
|
||||||
: RESTAPIHandler(bindings, L,
|
: RESTAPIHandler(bindings, L,
|
||||||
std::vector<std::string>{
|
std::vector<std::string>{
|
||||||
Poco::Net::HTTPRequest::HTTP_GET, Poco::Net::HTTPRequest::HTTP_POST,
|
Poco::Net::HTTPRequest::HTTP_GET, Poco::Net::HTTPRequest::HTTP_POST,
|
||||||
|
|||||||
@@ -3,15 +3,14 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "framework/RESTAPI_Handler.h"
|
||||||
#include "framework/MicroService.h"
|
|
||||||
#include "StorageService.h"
|
#include "StorageService.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
|
|
||||||
class RESTAPI_op_location_list_handler : public RESTAPIHandler {
|
class RESTAPI_op_location_list_handler : public RESTAPIHandler {
|
||||||
public:
|
public:
|
||||||
RESTAPI_op_location_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
|
RESTAPI_op_location_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
|
||||||
: RESTAPIHandler(bindings, L,
|
: RESTAPIHandler(bindings, L,
|
||||||
std::vector<std::string>{
|
std::vector<std::string>{
|
||||||
Poco::Net::HTTPRequest::HTTP_GET,
|
Poco::Net::HTTPRequest::HTTP_GET,
|
||||||
|
|||||||
@@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include "RESTAPI_operators_handler.h"
|
#include "RESTAPI_operators_handler.h"
|
||||||
#include "RESTAPI_db_helpers.h"
|
#include "RESTAPI_db_helpers.h"
|
||||||
|
#include "framework/utils.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
|
|
||||||
@@ -83,10 +84,10 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
// Create the default service...
|
// Create the default service...
|
||||||
ProvObjects::ServiceClass DefSer;
|
ProvObjects::ServiceClass DefSer;
|
||||||
DefSer.info.id = MicroService::CreateUUID();
|
DefSer.info.id = MicroServiceCreateUUID();
|
||||||
DefSer.info.name = "Default Service Class";
|
DefSer.info.name = "Default Service Class";
|
||||||
DefSer.defaultService = true;
|
DefSer.defaultService = true;
|
||||||
DefSer.info.created = DefSer.info.modified = OpenWifi::Now();
|
DefSer.info.created = DefSer.info.modified = Utils::Now();
|
||||||
DefSer.operatorId = NewObject.info.id;
|
DefSer.operatorId = NewObject.info.id;
|
||||||
DefSer.period = "monthly";
|
DefSer.period = "monthly";
|
||||||
DefSer.billingCode = "basic";
|
DefSer.billingCode = "basic";
|
||||||
|
|||||||
@@ -3,14 +3,13 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "framework/RESTAPI_Handler.h"
|
||||||
#include "framework/MicroService.h"
|
|
||||||
#include "StorageService.h"
|
#include "StorageService.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
class RESTAPI_operators_handler : public RESTAPIHandler {
|
class RESTAPI_operators_handler : public RESTAPIHandler {
|
||||||
public:
|
public:
|
||||||
RESTAPI_operators_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
|
RESTAPI_operators_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
|
||||||
: RESTAPIHandler(bindings, L,
|
: RESTAPIHandler(bindings, L,
|
||||||
std::vector<std::string>{
|
std::vector<std::string>{
|
||||||
Poco::Net::HTTPRequest::HTTP_GET, Poco::Net::HTTPRequest::HTTP_POST,
|
Poco::Net::HTTPRequest::HTTP_GET, Poco::Net::HTTPRequest::HTTP_POST,
|
||||||
|
|||||||
@@ -2,15 +2,14 @@
|
|||||||
// Created by stephane bourque on 2022-04-06.
|
// Created by stephane bourque on 2022-04-06.
|
||||||
//
|
//
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "framework/RESTAPI_Handler.h"
|
||||||
#include "framework/MicroService.h"
|
|
||||||
#include "StorageService.h"
|
#include "StorageService.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
|
|
||||||
class RESTAPI_operators_list_handler : public RESTAPIHandler {
|
class RESTAPI_operators_list_handler : public RESTAPIHandler {
|
||||||
public:
|
public:
|
||||||
RESTAPI_operators_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
|
RESTAPI_operators_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
|
||||||
: RESTAPIHandler(bindings, L,
|
: RESTAPIHandler(bindings, L,
|
||||||
std::vector<std::string>{
|
std::vector<std::string>{
|
||||||
Poco::Net::HTTPRequest::HTTP_GET,
|
Poco::Net::HTTPRequest::HTTP_GET,
|
||||||
|
|||||||
106
src/RESTAPI/RESTAPI_overrides_handler.cpp
Normal file
106
src/RESTAPI/RESTAPI_overrides_handler.cpp
Normal file
@@ -0,0 +1,106 @@
|
|||||||
|
//
|
||||||
|
// 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
|
||||||
31
src/RESTAPI/RESTAPI_overrides_handler.h
Normal file
31
src/RESTAPI/RESTAPI_overrides_handler.h
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
//
|
||||||
|
// 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 ;
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -2,8 +2,6 @@
|
|||||||
// Created by stephane bourque on 2021-10-23.
|
// Created by stephane bourque on 2021-10-23.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "framework/MicroService.h"
|
|
||||||
|
|
||||||
#include "RESTAPI/RESTAPI_entity_handler.h"
|
#include "RESTAPI/RESTAPI_entity_handler.h"
|
||||||
#include "RESTAPI/RESTAPI_contact_handler.h"
|
#include "RESTAPI/RESTAPI_contact_handler.h"
|
||||||
#include "RESTAPI/RESTAPI_location_handler.h"
|
#include "RESTAPI/RESTAPI_location_handler.h"
|
||||||
@@ -36,12 +34,15 @@
|
|||||||
#include "RESTAPI/RESTAPI_op_contact_list_handler.h"
|
#include "RESTAPI/RESTAPI_op_contact_list_handler.h"
|
||||||
#include "RESTAPI/RESTAPI_op_location_handler.h"
|
#include "RESTAPI/RESTAPI_op_location_handler.h"
|
||||||
#include "RESTAPI/RESTAPI_op_location_list_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 {
|
namespace OpenWifi {
|
||||||
|
|
||||||
Poco::Net::HTTPRequestHandler * RESTAPI_ExtRouter(const std::string &Path, RESTAPIHandler::BindingMap &Bindings,
|
Poco::Net::HTTPRequestHandler * RESTAPI_ExtRouter(const std::string &Path, RESTAPIHandler::BindingMap &Bindings,
|
||||||
Poco::Logger & L, RESTAPI_GenericServer & S, uint64_t TransactionId) {
|
Poco::Logger & L, RESTAPI_GenericServerAccounting & S, uint64_t TransactionId) {
|
||||||
return RESTAPI_Router<
|
return RESTAPI_Router<
|
||||||
RESTAPI_system_command,
|
RESTAPI_system_command,
|
||||||
RESTAPI_entity_handler,
|
RESTAPI_entity_handler,
|
||||||
@@ -76,12 +77,13 @@ namespace OpenWifi {
|
|||||||
RESTAPI_op_contact_list_handler,
|
RESTAPI_op_contact_list_handler,
|
||||||
RESTAPI_op_location_handler,
|
RESTAPI_op_location_handler,
|
||||||
RESTAPI_op_location_list_handler,
|
RESTAPI_op_location_list_handler,
|
||||||
RESTAPI_asset_server
|
RESTAPI_asset_server,
|
||||||
|
RESTAPI_overrides_handler
|
||||||
>(Path,Bindings,L, S, TransactionId);
|
>(Path,Bindings,L, S, TransactionId);
|
||||||
}
|
}
|
||||||
|
|
||||||
Poco::Net::HTTPRequestHandler * RESTAPI_IntRouter(const std::string &Path, RESTAPIHandler::BindingMap &Bindings,
|
Poco::Net::HTTPRequestHandler * RESTAPI_IntRouter(const std::string &Path, RESTAPIHandler::BindingMap &Bindings,
|
||||||
Poco::Logger & L, RESTAPI_GenericServer & S, uint64_t TransactionId) {
|
Poco::Logger & L, RESTAPI_GenericServerAccounting & S, uint64_t TransactionId) {
|
||||||
return RESTAPI_Router_I<
|
return RESTAPI_Router_I<
|
||||||
RESTAPI_system_command,
|
RESTAPI_system_command,
|
||||||
RESTAPI_entity_handler,
|
RESTAPI_entity_handler,
|
||||||
@@ -115,7 +117,8 @@ namespace OpenWifi {
|
|||||||
RESTAPI_op_contact_handler,
|
RESTAPI_op_contact_handler,
|
||||||
RESTAPI_op_contact_list_handler,
|
RESTAPI_op_contact_list_handler,
|
||||||
RESTAPI_op_location_handler,
|
RESTAPI_op_location_handler,
|
||||||
RESTAPI_op_location_list_handler
|
RESTAPI_op_location_list_handler,
|
||||||
|
RESTAPI_overrides_handler
|
||||||
>(Path, Bindings, L, S, TransactionId);
|
>(Path, Bindings, L, S, TransactionId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3,14 +3,13 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "framework/RESTAPI_Handler.h"
|
||||||
#include "framework/MicroService.h"
|
|
||||||
#include "StorageService.h"
|
#include "StorageService.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
class RESTAPI_service_class_handler : public RESTAPIHandler {
|
class RESTAPI_service_class_handler : public RESTAPIHandler {
|
||||||
public:
|
public:
|
||||||
RESTAPI_service_class_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
|
RESTAPI_service_class_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
|
||||||
: RESTAPIHandler(bindings, L,
|
: RESTAPIHandler(bindings, L,
|
||||||
std::vector<std::string>{
|
std::vector<std::string>{
|
||||||
Poco::Net::HTTPRequest::HTTP_GET, Poco::Net::HTTPRequest::HTTP_POST,
|
Poco::Net::HTTPRequest::HTTP_GET, Poco::Net::HTTPRequest::HTTP_POST,
|
||||||
|
|||||||
@@ -3,15 +3,14 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "framework/RESTAPI_Handler.h"
|
||||||
#include "framework/MicroService.h"
|
|
||||||
#include "StorageService.h"
|
#include "StorageService.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
|
|
||||||
class RESTAPI_service_class_list_handler : public RESTAPIHandler {
|
class RESTAPI_service_class_list_handler : public RESTAPIHandler {
|
||||||
public:
|
public:
|
||||||
RESTAPI_service_class_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
|
RESTAPI_service_class_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
|
||||||
: RESTAPIHandler(bindings, L,
|
: RESTAPIHandler(bindings, L,
|
||||||
std::vector<std::string>{
|
std::vector<std::string>{
|
||||||
Poco::Net::HTTPRequest::HTTP_GET,
|
Poco::Net::HTTPRequest::HTTP_GET,
|
||||||
|
|||||||
@@ -5,6 +5,10 @@
|
|||||||
#include "RESTAPI_signup_handler.h"
|
#include "RESTAPI_signup_handler.h"
|
||||||
#include "StorageService.h"
|
#include "StorageService.h"
|
||||||
#include "Signup.h"
|
#include "Signup.h"
|
||||||
|
#include "framework/OpenAPIRequests.h"
|
||||||
|
#include "framework/MicroServiceNames.h"
|
||||||
|
#include "framework/MicroServiceFuncs.h"
|
||||||
|
#include "framework/utils.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
|
|
||||||
@@ -59,7 +63,7 @@ namespace OpenWifi {
|
|||||||
if (i.statusCode == ProvObjects::SignupStatusCodes::SignupWaitingForEmail ||
|
if (i.statusCode == ProvObjects::SignupStatusCodes::SignupWaitingForEmail ||
|
||||||
i.statusCode == ProvObjects::SignupStatusCodes::SignupWaitingForDevice ||
|
i.statusCode == ProvObjects::SignupStatusCodes::SignupWaitingForDevice ||
|
||||||
i.statusCode == ProvObjects::SignupStatusCodes::SignupSuccess ) {
|
i.statusCode == ProvObjects::SignupStatusCodes::SignupSuccess ) {
|
||||||
Logger().information(fmt::format("SIGNUP: Returning existing signup record for '{}'",i.email));
|
poco_debug(Logger(),fmt::format("SIGNUP: Returning existing signup record for '{}'",i.email));
|
||||||
Poco::JSON::Object Answer;
|
Poco::JSON::Object Answer;
|
||||||
i.to_json(Answer);
|
i.to_json(Answer);
|
||||||
return ReturnObject(Answer);
|
return ReturnObject(Answer);
|
||||||
@@ -93,15 +97,15 @@ namespace OpenWifi {
|
|||||||
// OK, we can claim this device, can we create a userid?
|
// OK, we can claim this device, can we create a userid?
|
||||||
// Let's create one
|
// Let's create one
|
||||||
// If sec.signup("email",uuid);
|
// If sec.signup("email",uuid);
|
||||||
auto SignupUUID = MicroService::instance().CreateUUID();
|
auto SignupUUID = MicroServiceCreateUUID();
|
||||||
Logger().information(fmt::format("SIGNUP: Creating signup entry for '{}', uuid='{}'",UserName, SignupUUID));
|
poco_debug(Logger(),fmt::format("SIGNUP: Creating signup entry for '{}', uuid='{}'",UserName, SignupUUID));
|
||||||
|
|
||||||
Poco::JSON::Object Body;
|
Poco::JSON::Object Body;
|
||||||
OpenAPIRequestPost CreateUser( uSERVICE_SECURITY, "/api/v1/signup", {
|
OpenAPIRequestPost CreateUser( uSERVICE_SECURITY, "/api/v1/signup", {
|
||||||
{ "email", UserName },
|
{ "email", UserName },
|
||||||
{ "signupUUID" , SignupUUID },
|
{ "signupUUID" , SignupUUID },
|
||||||
{ "owner" , SignupOperator.info.id },
|
{ "owner" , SignupOperator.info.id },
|
||||||
|
{ "operatorName", SignupOperator.registrationId }
|
||||||
}, Body, 30000);
|
}, Body, 30000);
|
||||||
|
|
||||||
Poco::JSON::Object::Ptr Answer;
|
Poco::JSON::Object::Ptr Answer;
|
||||||
@@ -111,12 +115,12 @@ namespace OpenWifi {
|
|||||||
UI.from_json(Answer);
|
UI.from_json(Answer);
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
Answer->stringify(os);
|
Answer->stringify(os);
|
||||||
Logger().information(fmt::format("SIGNUP: email: '{}' signupID: '{}' userId: '{}'", UserName, SignupUUID, UI.id));
|
poco_debug(Logger(),fmt::format("SIGNUP: email: '{}' signupID: '{}' userId: '{}'", UserName, SignupUUID, UI.id));
|
||||||
|
|
||||||
// so create the Signup entry and modify the inventory
|
// so create the Signup entry and modify the inventory
|
||||||
ProvObjects::SignupEntry SE;
|
ProvObjects::SignupEntry SE;
|
||||||
SE.info.id = SignupUUID;
|
SE.info.id = SignupUUID;
|
||||||
SE.info.created = SE.info.modified = SE.submitted = OpenWifi::Now();
|
SE.info.created = SE.info.modified = SE.submitted = Utils::Now();
|
||||||
SE.completed = 0 ;
|
SE.completed = 0 ;
|
||||||
SE.macAddress = macAddress;
|
SE.macAddress = macAddress;
|
||||||
SE.error = 0 ;
|
SE.error = 0 ;
|
||||||
@@ -137,13 +141,13 @@ namespace OpenWifi {
|
|||||||
StateDoc.set("claimerId", UI.id);
|
StateDoc.set("claimerId", UI.id);
|
||||||
StateDoc.set("signupUUID", SignupUUID);
|
StateDoc.set("signupUUID", SignupUUID);
|
||||||
StateDoc.set("errorCode",0);
|
StateDoc.set("errorCode",0);
|
||||||
StateDoc.set("date", OpenWifi::Now());
|
StateDoc.set("date", Utils::Now());
|
||||||
StateDoc.set("status", "waiting for email-verification");
|
StateDoc.set("status", "waiting for email-verification");
|
||||||
std::ostringstream os2;
|
std::ostringstream os2;
|
||||||
StateDoc.stringify(os2);
|
StateDoc.stringify(os2);
|
||||||
IT.realMacAddress = macAddress;
|
IT.realMacAddress = macAddress;
|
||||||
IT.state = os2.str();
|
IT.state = os2.str();
|
||||||
IT.info.modified = OpenWifi::Now();
|
IT.info.modified = Utils::Now();
|
||||||
std::cout << "Updating inventory entry: " << SE.macAddress << std::endl;
|
std::cout << "Updating inventory entry: " << SE.macAddress << std::endl;
|
||||||
StorageService()->InventoryDB().UpdateRecord("id",IT.info.id,IT);
|
StorageService()->InventoryDB().UpdateRecord("id",IT.info.id,IT);
|
||||||
}
|
}
|
||||||
@@ -160,22 +164,22 @@ namespace OpenWifi {
|
|||||||
auto SignupUUID = GetParameter("signupUUID");
|
auto SignupUUID = GetParameter("signupUUID");
|
||||||
auto Operation = GetParameter("operation");
|
auto Operation = GetParameter("operation");
|
||||||
|
|
||||||
Logger().information(fmt::format("signup-progress: {} - {} ", SignupUUID, Operation));
|
poco_information(Logger(),fmt::format("signup-progress: {} - {} ", SignupUUID, Operation));
|
||||||
if(SignupUUID.empty() || Operation.empty()) {
|
if(SignupUUID.empty() || Operation.empty()) {
|
||||||
return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
|
return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
ProvObjects::SignupEntry SE;
|
ProvObjects::SignupEntry SE;
|
||||||
Logger().information(fmt::format("signup-progress: {} - {} fetching entry", SignupUUID, Operation));
|
poco_information(Logger(),fmt::format("signup-progress: {} - {} fetching entry", SignupUUID, Operation));
|
||||||
if(!StorageService()->SignupDB().GetRecord("id",SignupUUID,SE)) {
|
if(!StorageService()->SignupDB().GetRecord("id",SignupUUID,SE)) {
|
||||||
return NotFound();
|
return NotFound();
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger().information(fmt::format("signup-progress: {} - {} fetching entry", SignupUUID, Operation));
|
poco_debug(Logger(),fmt::format("signup-progress: {} - {} fetching entry", SignupUUID, Operation));
|
||||||
if(Operation == "emailVerified" && SE.statusCode==ProvObjects::SignupStatusCodes::SignupWaitingForEmail) {
|
if(Operation == "emailVerified" && SE.statusCode==ProvObjects::SignupStatusCodes::SignupWaitingForEmail) {
|
||||||
Logger().information(fmt::format("{}: email {} verified.",SE.info.id, SE.email));
|
poco_information(Logger(),fmt::format("{}: email {} verified.",SE.info.id, SE.email));
|
||||||
std::cout << "Verified email for : " << SE.email << std::endl;
|
std::cout << "Verified email for : " << SE.email << std::endl;
|
||||||
SE.info.modified = OpenWifi::Now();
|
SE.info.modified = Utils::Now();
|
||||||
SE.status = "emailVerified";
|
SE.status = "emailVerified";
|
||||||
SE.statusCode = ProvObjects::SignupStatusCodes::SignupWaitingForDevice;
|
SE.statusCode = ProvObjects::SignupStatusCodes::SignupWaitingForDevice;
|
||||||
StorageService()->SignupDB().UpdateRecord("id", SE.info.id, SE);
|
StorageService()->SignupDB().UpdateRecord("id", SE.info.id, SE);
|
||||||
@@ -184,7 +188,7 @@ namespace OpenWifi {
|
|||||||
SE.to_json(Answer);
|
SE.to_json(Answer);
|
||||||
return ReturnObject(Answer);
|
return ReturnObject(Answer);
|
||||||
}
|
}
|
||||||
Logger().information(fmt::format("signup-progress: {} - {} something is bad", SignupUUID, Operation));
|
poco_information(Logger(),fmt::format("signup-progress: {} - {} something is bad", SignupUUID, Operation));
|
||||||
|
|
||||||
return BadRequest(RESTAPI::Errors::UnknownId);
|
return BadRequest(RESTAPI::Errors::UnknownId);
|
||||||
}
|
}
|
||||||
@@ -195,11 +199,11 @@ namespace OpenWifi {
|
|||||||
auto macAddress = GetParameter("macAddress");
|
auto macAddress = GetParameter("macAddress");
|
||||||
auto List = GetBoolParameter("listOnly",false);
|
auto List = GetBoolParameter("listOnly",false);
|
||||||
|
|
||||||
Logger().information(fmt::format("Looking for signup for {}",EMail));
|
poco_information(Logger(),fmt::format("Looking for signup for {}",EMail));
|
||||||
Poco::JSON::Object Answer;
|
Poco::JSON::Object Answer;
|
||||||
ProvObjects::SignupEntry SE;
|
ProvObjects::SignupEntry SE;
|
||||||
if(!SignupUUID.empty()) {
|
if(!SignupUUID.empty()) {
|
||||||
Logger().information(fmt::format("Looking for signup for {}: Signup {}",EMail, SignupUUID));
|
poco_information(Logger(),fmt::format("Looking for signup for {}: Signup {}",EMail, SignupUUID));
|
||||||
if(StorageService()->SignupDB().GetRecord("id", SignupUUID, SE)) {
|
if(StorageService()->SignupDB().GetRecord("id", SignupUUID, SE)) {
|
||||||
SE.to_json(Answer);
|
SE.to_json(Answer);
|
||||||
return ReturnObject(Answer);
|
return ReturnObject(Answer);
|
||||||
@@ -207,25 +211,25 @@ namespace OpenWifi {
|
|||||||
return NotFound();
|
return NotFound();
|
||||||
} else if(!EMail.empty()) {
|
} else if(!EMail.empty()) {
|
||||||
SignupDB::RecordVec SEs;
|
SignupDB::RecordVec SEs;
|
||||||
Logger().information(fmt::format("Looking for signup for {}: Signup {}",EMail, SignupUUID));
|
poco_information(Logger(),fmt::format("Looking for signup for {}: Signup {}",EMail, SignupUUID));
|
||||||
if(StorageService()->SignupDB().GetRecords(0,100,SEs, " email='"+EMail+"' ")) {
|
if(StorageService()->SignupDB().GetRecords(0,100,SEs, " email='"+EMail+"' ")) {
|
||||||
return ReturnObject("signups",SEs);
|
return ReturnObject("signups",SEs);
|
||||||
}
|
}
|
||||||
return NotFound();
|
return NotFound();
|
||||||
} else if(!macAddress.empty()) {
|
} else if(!macAddress.empty()) {
|
||||||
SignupDB::RecordVec SEs;
|
SignupDB::RecordVec SEs;
|
||||||
Logger().information(fmt::format("Looking for signup for {}: Mac {}",EMail, macAddress));
|
poco_information(Logger(),fmt::format("Looking for signup for {}: Mac {}",EMail, macAddress));
|
||||||
if(StorageService()->SignupDB().GetRecords(0,100,SEs, " serialNumber='"+macAddress+"' ")) {
|
if(StorageService()->SignupDB().GetRecords(0,100,SEs, " serialNumber='"+macAddress+"' ")) {
|
||||||
return ReturnObject("signups",SEs);
|
return ReturnObject("signups",SEs);
|
||||||
}
|
}
|
||||||
return NotFound();
|
return NotFound();
|
||||||
} else if(List) {
|
} else if(List) {
|
||||||
Logger().information(fmt::format("Returning list of signups...",EMail, macAddress));
|
poco_information(Logger(),fmt::format("Returning list of signups...",EMail, macAddress));
|
||||||
SignupDB::RecordVec SEs;
|
SignupDB::RecordVec SEs;
|
||||||
StorageService()->SignupDB().GetRecords(0,100,SEs);
|
StorageService()->SignupDB().GetRecords(0,100,SEs);
|
||||||
return ReturnObject("signups",SEs);
|
return ReturnObject("signups",SEs);
|
||||||
}
|
}
|
||||||
Logger().information(fmt::format("Bad signup get",EMail, macAddress));
|
poco_information(Logger(),fmt::format("Bad signup get",EMail, macAddress));
|
||||||
return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
|
return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,13 +3,13 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "framework/RESTAPI_Handler.h"
|
||||||
#include "framework/MicroService.h"
|
#include "StorageService.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
class RESTAPI_signup_handler : public RESTAPIHandler {
|
class RESTAPI_signup_handler : public RESTAPIHandler {
|
||||||
public:
|
public:
|
||||||
RESTAPI_signup_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
|
RESTAPI_signup_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
|
||||||
: RESTAPIHandler(bindings, L,
|
: RESTAPIHandler(bindings, L,
|
||||||
std::vector<std::string>{
|
std::vector<std::string>{
|
||||||
Poco::Net::HTTPRequest::HTTP_POST,
|
Poco::Net::HTTPRequest::HTTP_POST,
|
||||||
|
|||||||
@@ -3,14 +3,13 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "framework/RESTAPI_Handler.h"
|
||||||
#include "framework/MicroService.h"
|
|
||||||
#include "StorageService.h"
|
#include "StorageService.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
class RESTAPI_sub_devices_handler : public RESTAPIHandler {
|
class RESTAPI_sub_devices_handler : public RESTAPIHandler {
|
||||||
public:
|
public:
|
||||||
RESTAPI_sub_devices_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
|
RESTAPI_sub_devices_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
|
||||||
: RESTAPIHandler(bindings, L,
|
: RESTAPIHandler(bindings, L,
|
||||||
std::vector<std::string>{
|
std::vector<std::string>{
|
||||||
Poco::Net::HTTPRequest::HTTP_GET, Poco::Net::HTTPRequest::HTTP_POST,
|
Poco::Net::HTTPRequest::HTTP_GET, Poco::Net::HTTPRequest::HTTP_POST,
|
||||||
|
|||||||
@@ -3,15 +3,14 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "framework/RESTAPI_Handler.h"
|
||||||
#include "framework/MicroService.h"
|
|
||||||
#include "StorageService.h"
|
#include "StorageService.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
|
|
||||||
class RESTAPI_sub_devices_list_handler : public RESTAPIHandler {
|
class RESTAPI_sub_devices_list_handler : public RESTAPIHandler {
|
||||||
public:
|
public:
|
||||||
RESTAPI_sub_devices_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
|
RESTAPI_sub_devices_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
|
||||||
: RESTAPIHandler(bindings, L,
|
: RESTAPIHandler(bindings, L,
|
||||||
std::vector<std::string>{
|
std::vector<std::string>{
|
||||||
Poco::Net::HTTPRequest::HTTP_GET,
|
Poco::Net::HTTPRequest::HTTP_GET,
|
||||||
|
|||||||
@@ -1,15 +1,15 @@
|
|||||||
//
|
//
|
||||||
// Created by stephane bourque on 2022-02-23.
|
// Created by stephane bourque on 2022-02-23.
|
||||||
//
|
//
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include "framework/MicroService.h"
|
#pragma once
|
||||||
|
#include "framework/RESTAPI_Handler.h"
|
||||||
#include "StorageService.h"
|
#include "StorageService.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
class RESTAPI_variables_handler : public RESTAPIHandler {
|
class RESTAPI_variables_handler : public RESTAPIHandler {
|
||||||
public:
|
public:
|
||||||
RESTAPI_variables_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
|
RESTAPI_variables_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
|
||||||
: RESTAPIHandler(bindings, L,
|
: RESTAPIHandler(bindings, L,
|
||||||
std::vector<std::string>{
|
std::vector<std::string>{
|
||||||
Poco::Net::HTTPRequest::HTTP_GET, Poco::Net::HTTPRequest::HTTP_POST,
|
Poco::Net::HTTPRequest::HTTP_GET, Poco::Net::HTTPRequest::HTTP_POST,
|
||||||
|
|||||||
@@ -3,15 +3,14 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "framework/RESTAPI_Handler.h"
|
||||||
#include "framework/MicroService.h"
|
|
||||||
#include "StorageService.h"
|
#include "StorageService.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
|
|
||||||
class RESTAPI_variables_list_handler : public RESTAPIHandler {
|
class RESTAPI_variables_list_handler : public RESTAPIHandler {
|
||||||
public:
|
public:
|
||||||
RESTAPI_variables_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
|
RESTAPI_variables_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
|
||||||
: RESTAPIHandler(bindings, L,
|
: RESTAPIHandler(bindings, L,
|
||||||
std::vector<std::string>{
|
std::vector<std::string>{
|
||||||
Poco::Net::HTTPRequest::HTTP_GET,
|
Poco::Net::HTTPRequest::HTTP_GET,
|
||||||
|
|||||||
@@ -15,6 +15,8 @@
|
|||||||
#include "Tasks/VenueConfigUpdater.h"
|
#include "Tasks/VenueConfigUpdater.h"
|
||||||
#include "Tasks/VenueRebooter.h"
|
#include "Tasks/VenueRebooter.h"
|
||||||
#include "Tasks/VenueUpgrade.h"
|
#include "Tasks/VenueUpgrade.h"
|
||||||
|
#include "framework/CIDR.h"
|
||||||
|
#include "framework/MicroServiceFuncs.h"
|
||||||
|
|
||||||
#include "Kafka_ProvUpdater.h"
|
#include "Kafka_ProvUpdater.h"
|
||||||
|
|
||||||
@@ -27,6 +29,7 @@ namespace OpenWifi{
|
|||||||
for (const auto &i: V.children) {
|
for (const auto &i: V.children) {
|
||||||
ProvObjects::Venue V2;
|
ProvObjects::Venue V2;
|
||||||
if (StorageService()->VenueDB().GetRecord("id", i, V2)) {
|
if (StorageService()->VenueDB().GetRecord("id", i, V2)) {
|
||||||
|
std::copy(V2.devices.begin(),V2.devices.end(),std::back_inserter(R));
|
||||||
auto LowerDevs = GetDevices(V2, GetChildren);
|
auto LowerDevs = GetDevices(V2, GetChildren);
|
||||||
std::copy(LowerDevs.begin(), LowerDevs.end(), std::back_inserter(R));
|
std::copy(LowerDevs.begin(), LowerDevs.end(), std::back_inserter(R));
|
||||||
}
|
}
|
||||||
@@ -227,10 +230,10 @@ namespace OpenWifi{
|
|||||||
|
|
||||||
Poco::JSON::Object Answer;
|
Poco::JSON::Object Answer;
|
||||||
SNL.serialNumbers = Existing.devices;
|
SNL.serialNumbers = Existing.devices;
|
||||||
|
auto JobId = MicroServiceCreateUUID();
|
||||||
auto Task = new VenueConfigUpdater(UUID,UserInfo_.userinfo,0,Logger());
|
Types::StringVec Parameters{UUID};;
|
||||||
auto JobId = Task->Start();
|
auto NewJob = new VenueConfigUpdater(JobId,"VenueConfigurationUpdater", Parameters, 0, UserInfo_.userinfo, Logger());
|
||||||
|
JobController()->AddJob(dynamic_cast<Job*>(NewJob));
|
||||||
SNL.to_json(Answer);
|
SNL.to_json(Answer);
|
||||||
Answer.set("jobId",JobId);
|
Answer.set("jobId",JobId);
|
||||||
return ReturnObject(Answer);
|
return ReturnObject(Answer);
|
||||||
@@ -241,10 +244,10 @@ namespace OpenWifi{
|
|||||||
|
|
||||||
Poco::JSON::Object Answer;
|
Poco::JSON::Object Answer;
|
||||||
SNL.serialNumbers = Existing.devices;
|
SNL.serialNumbers = Existing.devices;
|
||||||
|
auto JobId = MicroServiceCreateUUID();
|
||||||
auto Task = new VenueUpgrade(UUID,UserInfo_.userinfo,0,Logger());
|
Types::StringVec Parameters{UUID};;
|
||||||
auto JobId = Task->Start();
|
auto NewJob = new VenueUpgrade(JobId,"VenueFirmwareUpgrade", Parameters, 0, UserInfo_.userinfo, Logger());
|
||||||
|
JobController()->AddJob(dynamic_cast<Job*>(NewJob));
|
||||||
SNL.to_json(Answer);
|
SNL.to_json(Answer);
|
||||||
Answer.set("jobId",JobId);
|
Answer.set("jobId",JobId);
|
||||||
return ReturnObject(Answer);
|
return ReturnObject(Answer);
|
||||||
@@ -255,10 +258,10 @@ namespace OpenWifi{
|
|||||||
|
|
||||||
Poco::JSON::Object Answer;
|
Poco::JSON::Object Answer;
|
||||||
SNL.serialNumbers = Existing.devices;
|
SNL.serialNumbers = Existing.devices;
|
||||||
|
auto JobId = MicroServiceCreateUUID();
|
||||||
auto Task = new VenueRebooter(UUID,UserInfo_.userinfo,0,Logger());
|
Types::StringVec Parameters{UUID};;
|
||||||
auto JobId = Task->Start();
|
auto NewJob = new VenueRebooter(JobId,"VenueRebooter", Parameters, 0, UserInfo_.userinfo, Logger());
|
||||||
|
JobController()->AddJob(dynamic_cast<Job*>(NewJob));
|
||||||
SNL.to_json(Answer);
|
SNL.to_json(Answer);
|
||||||
Answer.set("jobId",JobId);
|
Answer.set("jobId",JobId);
|
||||||
return ReturnObject(Answer);
|
return ReturnObject(Answer);
|
||||||
|
|||||||
@@ -7,14 +7,13 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "framework/RESTAPI_Handler.h"
|
||||||
#include "framework/MicroService.h"
|
|
||||||
#include "StorageService.h"
|
#include "StorageService.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
class RESTAPI_venue_handler : public RESTAPIHandler {
|
class RESTAPI_venue_handler : public RESTAPIHandler {
|
||||||
public:
|
public:
|
||||||
RESTAPI_venue_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
|
RESTAPI_venue_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
|
||||||
: RESTAPIHandler(bindings, L,
|
: RESTAPIHandler(bindings, L,
|
||||||
std::vector<std::string>{
|
std::vector<std::string>{
|
||||||
Poco::Net::HTTPRequest::HTTP_GET, Poco::Net::HTTPRequest::HTTP_POST,
|
Poco::Net::HTTPRequest::HTTP_GET, Poco::Net::HTTPRequest::HTTP_POST,
|
||||||
|
|||||||
@@ -3,15 +3,14 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "framework/RESTAPI_Handler.h"
|
||||||
#include "framework/MicroService.h"
|
|
||||||
#include "StorageService.h"
|
#include "StorageService.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
|
|
||||||
class RESTAPI_venue_list_handler : public RESTAPIHandler {
|
class RESTAPI_venue_list_handler : public RESTAPIHandler {
|
||||||
public:
|
public:
|
||||||
RESTAPI_venue_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServer & Server, uint64_t TransactionId, bool Internal)
|
RESTAPI_venue_list_handler(const RESTAPIHandler::BindingMap &bindings, Poco::Logger &L, RESTAPI_GenericServerAccounting & Server, uint64_t TransactionId, bool Internal)
|
||||||
: RESTAPIHandler(bindings, L,
|
: RESTAPIHandler(bindings, L,
|
||||||
std::vector<std::string>{
|
std::vector<std::string>{
|
||||||
Poco::Net::HTTPRequest::HTTP_GET,
|
Poco::Net::HTTPRequest::HTTP_GET,
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#include "RESTAPI_AnalyticsObjects.h"
|
#include "RESTAPI_AnalyticsObjects.h"
|
||||||
#include "RESTAPI_ProvObjects.h"
|
#include "RESTAPI_ProvObjects.h"
|
||||||
#include "framework/MicroService.h"
|
#include "framework/RESTAPI_utils.h"
|
||||||
|
|
||||||
using OpenWifi::RESTAPI_utils::field_to_json;
|
using OpenWifi::RESTAPI_utils::field_to_json;
|
||||||
using OpenWifi::RESTAPI_utils::field_from_json;
|
using OpenWifi::RESTAPI_utils::field_from_json;
|
||||||
@@ -538,8 +538,8 @@ namespace OpenWifi::AnalyticsObjects {
|
|||||||
|
|
||||||
void WifiClientHistory::to_json(Poco::JSON::Object &Obj) const {
|
void WifiClientHistory::to_json(Poco::JSON::Object &Obj) const {
|
||||||
field_to_json(Obj,"timestamp",timestamp);
|
field_to_json(Obj,"timestamp",timestamp);
|
||||||
field_to_json(Obj,"stationId",stationId);
|
field_to_json(Obj,"station_id",station_id);
|
||||||
field_to_json(Obj,"bssId",bssId);
|
field_to_json(Obj,"bssid",bssid);
|
||||||
field_to_json(Obj,"ssid",ssid);
|
field_to_json(Obj,"ssid",ssid);
|
||||||
field_to_json(Obj,"rssi",rssi);
|
field_to_json(Obj,"rssi",rssi);
|
||||||
field_to_json(Obj,"rx_bitrate",rx_bitrate);
|
field_to_json(Obj,"rx_bitrate",rx_bitrate);
|
||||||
@@ -573,13 +573,14 @@ namespace OpenWifi::AnalyticsObjects {
|
|||||||
field_to_json(Obj,"connected",connected);
|
field_to_json(Obj,"connected",connected);
|
||||||
field_to_json(Obj,"inactive",inactive);
|
field_to_json(Obj,"inactive",inactive);
|
||||||
field_to_json(Obj,"tx_retries",tx_retries);
|
field_to_json(Obj,"tx_retries",tx_retries);
|
||||||
|
field_to_json(Obj,"venue_id",venue_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool WifiClientHistory::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
bool WifiClientHistory::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
try {
|
try {
|
||||||
field_from_json(Obj,"timestamp",timestamp);
|
field_from_json(Obj,"timestamp",timestamp);
|
||||||
field_from_json(Obj,"stationId",stationId);
|
field_from_json(Obj,"station_id",station_id);
|
||||||
field_from_json(Obj,"bssId",bssId);
|
field_from_json(Obj,"bssid",bssid);
|
||||||
field_from_json(Obj,"ssid",ssid);
|
field_from_json(Obj,"ssid",ssid);
|
||||||
field_from_json(Obj,"rssi",rssi);
|
field_from_json(Obj,"rssi",rssi);
|
||||||
field_from_json(Obj,"rx_bitrate",rx_bitrate);
|
field_from_json(Obj,"rx_bitrate",rx_bitrate);
|
||||||
@@ -613,6 +614,7 @@ namespace OpenWifi::AnalyticsObjects {
|
|||||||
field_from_json(Obj,"connected",connected);
|
field_from_json(Obj,"connected",connected);
|
||||||
field_from_json(Obj,"inactive",inactive);
|
field_from_json(Obj,"inactive",inactive);
|
||||||
field_from_json(Obj,"tx_retries",tx_retries);
|
field_from_json(Obj,"tx_retries",tx_retries);
|
||||||
|
field_from_json(Obj,"venue_id",venue_id);
|
||||||
return true;
|
return true;
|
||||||
} catch(...) {
|
} catch(...) {
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "RESTAPI_ProvObjects.h"
|
#include "RESTAPI_ProvObjects.h"
|
||||||
|
#include "framework/utils.h"
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
@@ -375,9 +376,9 @@ namespace OpenWifi {
|
|||||||
};
|
};
|
||||||
|
|
||||||
struct WifiClientHistory {
|
struct WifiClientHistory {
|
||||||
uint64_t timestamp=OpenWifi::Now();
|
uint64_t timestamp=Utils::Now();
|
||||||
std::string stationId;
|
std::string station_id;
|
||||||
std::string bssId;
|
std::string bssid;
|
||||||
std::string ssid;
|
std::string ssid;
|
||||||
int64_t rssi=0;
|
int64_t rssi=0;
|
||||||
uint32_t rx_bitrate=0;
|
uint32_t rx_bitrate=0;
|
||||||
@@ -411,6 +412,7 @@ namespace OpenWifi {
|
|||||||
uint64_t connected=0;
|
uint64_t connected=0;
|
||||||
uint64_t inactive=0;
|
uint64_t inactive=0;
|
||||||
uint64_t tx_retries=0;
|
uint64_t tx_retries=0;
|
||||||
|
std::string venue_id;
|
||||||
|
|
||||||
void to_json(Poco::JSON::Object &Obj) const;
|
void to_json(Poco::JSON::Object &Obj) const;
|
||||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||||
|
|||||||
@@ -3,12 +3,12 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include "RESTAPI_CertObjects.h"
|
#include "RESTAPI_CertObjects.h"
|
||||||
|
#include "framework/RESTAPI_utils.h"
|
||||||
|
|
||||||
using OpenWifi::RESTAPI_utils::field_to_json;
|
using OpenWifi::RESTAPI_utils::field_to_json;
|
||||||
using OpenWifi::RESTAPI_utils::field_from_json;
|
using OpenWifi::RESTAPI_utils::field_from_json;
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi::CertObjects {
|
||||||
namespace CertObjects {
|
|
||||||
void CertificateEntry::to_json(Poco::JSON::Object &Obj) const {
|
void CertificateEntry::to_json(Poco::JSON::Object &Obj) const {
|
||||||
field_to_json(Obj,"id", id);
|
field_to_json(Obj,"id", id);
|
||||||
field_to_json(Obj,"entity", entity);
|
field_to_json(Obj,"entity", entity);
|
||||||
@@ -29,6 +29,7 @@ namespace OpenWifi {
|
|||||||
field_to_json(Obj,"modified", modified);
|
field_to_json(Obj,"modified", modified);
|
||||||
field_to_json(Obj,"revoked", revoked);
|
field_to_json(Obj,"revoked", revoked);
|
||||||
field_to_json(Obj,"revokeCount", revokeCount);
|
field_to_json(Obj,"revokeCount", revokeCount);
|
||||||
|
field_to_json(Obj,"synched", synched);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CertificateEntry::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
bool CertificateEntry::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
@@ -52,6 +53,7 @@ namespace OpenWifi {
|
|||||||
field_from_json(Obj,"modified", modified);
|
field_from_json(Obj,"modified", modified);
|
||||||
field_from_json(Obj,"revoked", revoked);
|
field_from_json(Obj,"revoked", revoked);
|
||||||
field_from_json(Obj,"revokeCount", revokeCount);
|
field_from_json(Obj,"revokeCount", revokeCount);
|
||||||
|
field_from_json(Obj,"synched", synched);
|
||||||
return true;
|
return true;
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
}
|
}
|
||||||
@@ -152,6 +154,7 @@ namespace OpenWifi {
|
|||||||
field_to_json(Obj,"submitted", submitted);
|
field_to_json(Obj,"submitted", submitted);
|
||||||
field_to_json(Obj,"started", started);
|
field_to_json(Obj,"started", started);
|
||||||
field_to_json(Obj,"completed", completed);
|
field_to_json(Obj,"completed", completed);
|
||||||
|
field_to_json(Obj,"requesterUsername", requesterUsername);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool JobEntry::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
bool JobEntry::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
@@ -169,10 +172,39 @@ namespace OpenWifi {
|
|||||||
field_from_json(Obj,"submitted", submitted);
|
field_from_json(Obj,"submitted", submitted);
|
||||||
field_from_json(Obj,"started", started);
|
field_from_json(Obj,"started", started);
|
||||||
field_from_json(Obj,"completed", completed);
|
field_from_json(Obj,"completed", completed);
|
||||||
|
field_from_json(Obj,"requesterUsername", requesterUsername);
|
||||||
return true;
|
return true;
|
||||||
} catch (...) {
|
} catch (...) {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DashBoardYearlyStats::to_json(Poco::JSON::Object &Obj) const {
|
||||||
|
field_to_json(Obj, "year", year);
|
||||||
|
field_to_json(Obj, "activeCerts", activeCerts);
|
||||||
|
field_to_json(Obj, "revokedCerts", revokedCerts);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Dashboard::to_json(Poco::JSON::Object &Obj) const {
|
||||||
|
field_to_json(Obj,"snapshot", snapshot);
|
||||||
|
field_to_json(Obj,"numberOfIssuedCerts", numberOfIssuedCerts);
|
||||||
|
field_to_json(Obj,"numberOfRevokedCerts", numberOfRevokedCerts);
|
||||||
|
field_to_json(Obj,"activeCertsPerOrganization", activeCertsPerOrganization);
|
||||||
|
field_to_json(Obj,"revokedCertsPerOrganization", revokedCertsPerOrganization);
|
||||||
|
field_to_json(Obj,"numberOfRedirectors", numberOfRedirectors);
|
||||||
|
field_to_json(Obj,"deviceTypes", deviceTypes);
|
||||||
|
field_to_json(Obj,"monthlyNumberOfCerts", monthlyNumberOfCerts);
|
||||||
|
field_to_json(Obj,"monthlyNumberOfCertsPerOrgPerYear", monthlyNumberOfCertsPerOrgPerYear);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Dashboard::reset() {
|
||||||
|
snapshot=0;
|
||||||
|
numberOfRevokedCerts = numberOfIssuedCerts = 0;
|
||||||
|
activeCertsPerOrganization.clear();
|
||||||
|
revokedCertsPerOrganization.clear();
|
||||||
|
numberOfRedirectors.clear();
|
||||||
|
deviceTypes.clear();
|
||||||
|
monthlyNumberOfCerts.clear();
|
||||||
|
monthlyNumberOfCertsPerOrgPerYear.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,13 +5,10 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "framework/MicroService.h"
|
|
||||||
#include "framework/OpenWifiTypes.h"
|
#include "framework/OpenWifiTypes.h"
|
||||||
#include "RESTObjects/RESTAPI_SecurityObjects.h"
|
#include "RESTObjects/RESTAPI_SecurityObjects.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi::CertObjects {
|
||||||
|
|
||||||
namespace CertObjects {
|
|
||||||
|
|
||||||
struct CertificateEntry {
|
struct CertificateEntry {
|
||||||
OpenWifi::Types::UUID_t id;
|
OpenWifi::Types::UUID_t id;
|
||||||
@@ -33,6 +30,7 @@ namespace OpenWifi {
|
|||||||
uint64_t modified = 0;
|
uint64_t modified = 0;
|
||||||
uint64_t revoked = 0;
|
uint64_t revoked = 0;
|
||||||
uint64_t revokeCount = 0;
|
uint64_t revokeCount = 0;
|
||||||
|
uint64_t synched = 0;
|
||||||
|
|
||||||
void to_json(Poco::JSON::Object &Obj) const;
|
void to_json(Poco::JSON::Object &Obj) const;
|
||||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||||
@@ -93,9 +91,33 @@ namespace OpenWifi {
|
|||||||
uint64_t submitted=0;
|
uint64_t submitted=0;
|
||||||
uint64_t started=0;
|
uint64_t started=0;
|
||||||
uint64_t completed=0;
|
uint64_t completed=0;
|
||||||
|
std::string requesterUsername;
|
||||||
|
|
||||||
void to_json(Poco::JSON::Object &Obj) const;
|
void to_json(Poco::JSON::Object &Obj) const;
|
||||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||||
};
|
};
|
||||||
}
|
|
||||||
|
struct DashBoardYearlyStats {
|
||||||
|
uint64_t year=0;
|
||||||
|
OpenWifi::Types::Counted3DMapSII activeCerts;
|
||||||
|
OpenWifi::Types::Counted3DMapSII revokedCerts;
|
||||||
|
|
||||||
|
void to_json(Poco::JSON::Object &Obj) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Dashboard {
|
||||||
|
uint64_t snapshot=0;
|
||||||
|
uint64_t numberOfIssuedCerts=0;
|
||||||
|
uint64_t numberOfRevokedCerts=0;
|
||||||
|
OpenWifi::Types::CountedMap activeCertsPerOrganization;
|
||||||
|
OpenWifi::Types::CountedMap revokedCertsPerOrganization;
|
||||||
|
OpenWifi::Types::CountedMap numberOfRedirectors;
|
||||||
|
OpenWifi::Types::CountedMap deviceTypes;
|
||||||
|
OpenWifi::Types::CountedMap monthlyNumberOfCerts;
|
||||||
|
std::vector<DashBoardYearlyStats> monthlyNumberOfCertsPerOrgPerYear;
|
||||||
|
|
||||||
|
void to_json(Poco::JSON::Object &Obj) const;
|
||||||
|
void reset();
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -3,7 +3,8 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include "RESTAPI_FMSObjects.h"
|
#include "RESTAPI_FMSObjects.h"
|
||||||
#include "framework/MicroService.h"
|
#include "framework/RESTAPI_utils.h"
|
||||||
|
#include "framework/utils.h"
|
||||||
|
|
||||||
using OpenWifi::RESTAPI_utils::field_to_json;
|
using OpenWifi::RESTAPI_utils::field_to_json;
|
||||||
using OpenWifi::RESTAPI_utils::field_from_json;
|
using OpenWifi::RESTAPI_utils::field_from_json;
|
||||||
@@ -233,7 +234,7 @@ namespace OpenWifi::FMSObjects {
|
|||||||
UnknownFirmwares_.clear();
|
UnknownFirmwares_.clear();
|
||||||
totalSecondsOld_.clear();
|
totalSecondsOld_.clear();
|
||||||
numberOfDevices = 0 ;
|
numberOfDevices = 0 ;
|
||||||
snapshot = std::time(nullptr);
|
snapshot = Utils::Now();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DeviceReport::from_json([[maybe_unused]] const Poco::JSON::Object::Ptr &Obj) {
|
bool DeviceReport::from_json([[maybe_unused]] const Poco::JSON::Object::Ptr &Obj) {
|
||||||
@@ -273,4 +274,37 @@ namespace OpenWifi::FMSObjects {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void DeviceCurrentInfo::to_json(Poco::JSON::Object &Obj) const {
|
||||||
|
field_to_json(Obj, "serialNumber",serialNumber);
|
||||||
|
field_to_json(Obj, "revision", revision);
|
||||||
|
field_to_json(Obj, "upgraded", upgraded);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DeviceCurrentInfo::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
|
try {
|
||||||
|
field_from_json(Obj, "serialNumber",serialNumber);
|
||||||
|
field_from_json(Obj, "revision", revision);
|
||||||
|
field_from_json(Obj, "upgraded", upgraded);
|
||||||
|
return true;
|
||||||
|
} catch(...) {
|
||||||
|
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void DeviceCurrentInfoList::to_json(Poco::JSON::Object &Obj) const {
|
||||||
|
field_to_json(Obj, "devices",devices);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool DeviceCurrentInfoList::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
|
try {
|
||||||
|
field_from_json(Obj, "devices",devices);
|
||||||
|
return true;
|
||||||
|
} catch(...) {
|
||||||
|
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,9 +4,7 @@
|
|||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#ifndef UCENTRALFMS_RESTAPI_FMSOBJECTS_H
|
#pragma once
|
||||||
#define UCENTRALFMS_RESTAPI_FMSOBJECTS_H
|
|
||||||
|
|
||||||
|
|
||||||
#include "RESTAPI_SecurityObjects.h"
|
#include "RESTAPI_SecurityObjects.h"
|
||||||
#include "framework/OpenWifiTypes.h"
|
#include "framework/OpenWifiTypes.h"
|
||||||
@@ -29,7 +27,7 @@ namespace OpenWifi::FMSObjects {
|
|||||||
std::string location;
|
std::string location;
|
||||||
std::string uploader;
|
std::string uploader;
|
||||||
std::string digest;
|
std::string digest;
|
||||||
bool latest=0;
|
bool latest=false;
|
||||||
SecurityObjects::NoteInfoVec notes;
|
SecurityObjects::NoteInfoVec notes;
|
||||||
uint64_t created=0;
|
uint64_t created=0;
|
||||||
|
|
||||||
@@ -141,7 +139,21 @@ namespace OpenWifi::FMSObjects {
|
|||||||
void to_json(Poco::JSON::Object &Obj) const;
|
void to_json(Poco::JSON::Object &Obj) const;
|
||||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct DeviceCurrentInfo {
|
||||||
|
std::string serialNumber;
|
||||||
|
std::string revision;
|
||||||
|
uint64_t upgraded=0;
|
||||||
|
|
||||||
|
void to_json(Poco::JSON::Object &Obj) const;
|
||||||
|
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct DeviceCurrentInfoList {
|
||||||
|
std::vector<DeviceCurrentInfo> devices;
|
||||||
|
|
||||||
|
void to_json(Poco::JSON::Object &Obj) const;
|
||||||
|
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif //UCENTRALFMS_RESTAPI_FMSOBJECTS_H
|
|
||||||
|
|||||||
@@ -11,12 +11,13 @@
|
|||||||
|
|
||||||
#include "Daemon.h"
|
#include "Daemon.h"
|
||||||
#ifdef TIP_GATEWAY_SERVICE
|
#ifdef TIP_GATEWAY_SERVICE
|
||||||
#include "DeviceRegistry.h"
|
#include "AP_WS_Server.h"
|
||||||
#include "CapabilitiesCache.h"
|
#include "CapabilitiesCache.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "RESTAPI_GWobjects.h"
|
#include "RESTAPI_GWobjects.h"
|
||||||
#include "framework/MicroService.h"
|
#include "framework/RESTAPI_utils.h"
|
||||||
|
#include "framework/utils.h"
|
||||||
|
|
||||||
using OpenWifi::RESTAPI_utils::field_to_json;
|
using OpenWifi::RESTAPI_utils::field_to_json;
|
||||||
using OpenWifi::RESTAPI_utils::field_from_json;
|
using OpenWifi::RESTAPI_utils::field_from_json;
|
||||||
@@ -49,6 +50,10 @@ namespace OpenWifi::GWObjects {
|
|||||||
field_to_json(Obj,"entity", entity);
|
field_to_json(Obj,"entity", entity);
|
||||||
field_to_json(Obj,"modified", modified);
|
field_to_json(Obj,"modified", modified);
|
||||||
field_to_json(Obj,"locale", locale);
|
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 {
|
void Device::to_json_with_status(Poco::JSON::Object &Obj) const {
|
||||||
@@ -57,7 +62,7 @@ namespace OpenWifi::GWObjects {
|
|||||||
#ifdef TIP_GATEWAY_SERVICE
|
#ifdef TIP_GATEWAY_SERVICE
|
||||||
ConnectionState ConState;
|
ConnectionState ConState;
|
||||||
|
|
||||||
if (DeviceRegistry()->GetState(SerialNumber, ConState)) {
|
if (AP_WS_Server()->GetState(SerialNumber, ConState)) {
|
||||||
ConState.to_json(Obj);
|
ConState.to_json(Obj);
|
||||||
} else {
|
} else {
|
||||||
field_to_json(Obj,"ipAddress", "");
|
field_to_json(Obj,"ipAddress", "");
|
||||||
@@ -69,6 +74,7 @@ namespace OpenWifi::GWObjects {
|
|||||||
field_to_json(Obj,"verifiedCertificate", "NO_CERTIFICATE");
|
field_to_json(Obj,"verifiedCertificate", "NO_CERTIFICATE");
|
||||||
field_to_json(Obj,"associations_2G", (uint64_t) 0);
|
field_to_json(Obj,"associations_2G", (uint64_t) 0);
|
||||||
field_to_json(Obj,"associations_5G", (uint64_t) 0);
|
field_to_json(Obj,"associations_5G", (uint64_t) 0);
|
||||||
|
field_to_json(Obj,"associations_6G", (uint64_t) 0);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
@@ -88,6 +94,10 @@ namespace OpenWifi::GWObjects {
|
|||||||
field_from_json(Obj,"subscriber", subscriber);
|
field_from_json(Obj,"subscriber", subscriber);
|
||||||
field_from_json(Obj,"entity", entity);
|
field_from_json(Obj,"entity", entity);
|
||||||
field_from_json(Obj,"locale", locale);
|
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;
|
return true;
|
||||||
} catch (const Poco::Exception &E) {
|
} catch (const Poco::Exception &E) {
|
||||||
}
|
}
|
||||||
@@ -198,11 +208,17 @@ namespace OpenWifi::GWObjects {
|
|||||||
field_to_json(Obj,"lastContact", LastContact);
|
field_to_json(Obj,"lastContact", LastContact);
|
||||||
field_to_json(Obj,"associations_2G", Associations_2G);
|
field_to_json(Obj,"associations_2G", Associations_2G);
|
||||||
field_to_json(Obj,"associations_5G", Associations_5G);
|
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,"webSocketClients", webSocketClients);
|
||||||
field_to_json(Obj,"websocketPackets", websocketPackets);
|
field_to_json(Obj,"websocketPackets", websocketPackets);
|
||||||
field_to_json(Obj,"kafkaClients", kafkaClients);
|
field_to_json(Obj,"kafkaClients", kafkaClients);
|
||||||
field_to_json(Obj,"kafkaPackets", kafkaPackets);
|
field_to_json(Obj,"kafkaPackets", kafkaPackets);
|
||||||
field_to_json(Obj,"locale", locale);
|
field_to_json(Obj,"locale", locale);
|
||||||
|
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);
|
||||||
|
|
||||||
switch(VerifiedCertificate) {
|
switch(VerifiedCertificate) {
|
||||||
case NO_CERTIFICATE:
|
case NO_CERTIFICATE:
|
||||||
@@ -218,6 +234,23 @@ 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) {
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void RttySessionDetails::to_json(Poco::JSON::Object &Obj) const {
|
void RttySessionDetails::to_json(Poco::JSON::Object &Obj) const {
|
||||||
field_to_json(Obj,"serialNumber", SerialNumber);
|
field_to_json(Obj,"serialNumber", SerialNumber);
|
||||||
field_to_json(Obj,"server", Server);
|
field_to_json(Obj,"server", Server);
|
||||||
@@ -264,7 +297,7 @@ namespace OpenWifi::GWObjects {
|
|||||||
lastContact.clear();
|
lastContact.clear();
|
||||||
associations.clear();
|
associations.clear();
|
||||||
numberOfDevices = 0 ;
|
numberOfDevices = 0 ;
|
||||||
snapshot = OpenWifi::Now();
|
snapshot = Utils::Now();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CapabilitiesModel::to_json(Poco::JSON::Object &Obj) const{
|
void CapabilitiesModel::to_json(Poco::JSON::Object &Obj) const{
|
||||||
@@ -276,9 +309,12 @@ namespace OpenWifi::GWObjects {
|
|||||||
field_to_json(Obj,"serialNumber",serialNumber);
|
field_to_json(Obj,"serialNumber",serialNumber);
|
||||||
field_to_json(Obj,"timeout",timeout);
|
field_to_json(Obj,"timeout",timeout);
|
||||||
field_to_json(Obj,"type",type);
|
field_to_json(Obj,"type",type);
|
||||||
field_to_json(Obj,"script",script);
|
|
||||||
field_to_json(Obj,"scriptId",scriptId);
|
field_to_json(Obj,"scriptId",scriptId);
|
||||||
|
field_to_json(Obj,"script",script);
|
||||||
field_to_json(Obj,"when",when);
|
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) {
|
bool ScriptRequest::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
@@ -289,11 +325,13 @@ namespace OpenWifi::GWObjects {
|
|||||||
field_from_json(Obj,"script",script);
|
field_from_json(Obj,"script",script);
|
||||||
field_from_json(Obj,"scriptId",scriptId);
|
field_from_json(Obj,"scriptId",scriptId);
|
||||||
field_from_json(Obj,"when",when);
|
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;
|
return true;
|
||||||
} catch (const Poco::Exception &E) {
|
} catch (const Poco::Exception &E) {
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void RadiusProxyPoolList::to_json(Poco::JSON::Object &Obj) const {
|
void RadiusProxyPoolList::to_json(Poco::JSON::Object &Obj) const {
|
||||||
@@ -314,6 +352,8 @@ namespace OpenWifi::GWObjects {
|
|||||||
field_to_json(Obj,"description",description);
|
field_to_json(Obj,"description",description);
|
||||||
field_to_json(Obj,"authConfig",authConfig);
|
field_to_json(Obj,"authConfig",authConfig);
|
||||||
field_to_json(Obj,"acctConfig",acctConfig);
|
field_to_json(Obj,"acctConfig",acctConfig);
|
||||||
|
field_to_json(Obj,"coaConfig",coaConfig);
|
||||||
|
field_to_json(Obj,"useByDefault",useByDefault);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RadiusProxyPool::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
bool RadiusProxyPool::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
@@ -322,6 +362,8 @@ namespace OpenWifi::GWObjects {
|
|||||||
field_from_json(Obj,"description",description);
|
field_from_json(Obj,"description",description);
|
||||||
field_from_json(Obj,"authConfig",authConfig);
|
field_from_json(Obj,"authConfig",authConfig);
|
||||||
field_from_json(Obj,"acctConfig",acctConfig);
|
field_from_json(Obj,"acctConfig",acctConfig);
|
||||||
|
field_from_json(Obj,"coaConfig",coaConfig);
|
||||||
|
field_from_json(Obj,"useByDefault",useByDefault);
|
||||||
return true;
|
return true;
|
||||||
} catch (const Poco::Exception &E) {
|
} catch (const Poco::Exception &E) {
|
||||||
}
|
}
|
||||||
@@ -329,7 +371,7 @@ namespace OpenWifi::GWObjects {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void RadiusProxyServerConfig::to_json(Poco::JSON::Object &Obj) const {
|
void RadiusProxyServerConfig::to_json(Poco::JSON::Object &Obj) const {
|
||||||
field_to_json(Obj,"policy",strategy);
|
field_to_json(Obj,"strategy",strategy);
|
||||||
field_to_json(Obj,"monitor",monitor);
|
field_to_json(Obj,"monitor",monitor);
|
||||||
field_to_json(Obj,"monitorMethod",monitorMethod);
|
field_to_json(Obj,"monitorMethod",monitorMethod);
|
||||||
field_to_json(Obj,"methodParameters",methodParameters);
|
field_to_json(Obj,"methodParameters",methodParameters);
|
||||||
@@ -338,7 +380,7 @@ namespace OpenWifi::GWObjects {
|
|||||||
|
|
||||||
bool RadiusProxyServerConfig::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
bool RadiusProxyServerConfig::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
try {
|
try {
|
||||||
field_from_json(Obj,"policy",strategy);
|
field_from_json(Obj,"strategy",strategy);
|
||||||
field_from_json(Obj,"monitor",monitor);
|
field_from_json(Obj,"monitor",monitor);
|
||||||
field_from_json(Obj,"monitorMethod",monitorMethod);
|
field_from_json(Obj,"monitorMethod",monitorMethod);
|
||||||
field_from_json(Obj,"methodParameters",methodParameters);
|
field_from_json(Obj,"methodParameters",methodParameters);
|
||||||
@@ -354,6 +396,17 @@ namespace OpenWifi::GWObjects {
|
|||||||
field_to_json(Obj,"ip",ip);
|
field_to_json(Obj,"ip",ip);
|
||||||
field_to_json(Obj,"port",port);
|
field_to_json(Obj,"port",port);
|
||||||
field_to_json(Obj,"weight",weight);
|
field_to_json(Obj,"weight",weight);
|
||||||
|
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);
|
||||||
|
field_to_json(Obj,"radsecCert",radsecCert);
|
||||||
|
field_to_json(Obj,"radsecKey",radsecKey);
|
||||||
|
field_to_json(Obj,"radsecRealms",radsecRealms);
|
||||||
|
field_to_json(Obj,"ignore",ignore);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool RadiusProxyServerEntry::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
bool RadiusProxyServerEntry::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
@@ -362,10 +415,133 @@ namespace OpenWifi::GWObjects {
|
|||||||
field_from_json(Obj,"ip",ip);
|
field_from_json(Obj,"ip",ip);
|
||||||
field_from_json(Obj,"port",port);
|
field_from_json(Obj,"port",port);
|
||||||
field_from_json(Obj,"weight",weight);
|
field_from_json(Obj,"weight",weight);
|
||||||
|
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);
|
||||||
|
field_from_json(Obj,"radsecCert",radsecCert);
|
||||||
|
field_from_json(Obj,"radsecKey",radsecKey);
|
||||||
|
field_from_json(Obj,"radsecRealms",radsecRealms);
|
||||||
|
field_from_json(Obj,"ignore",ignore);
|
||||||
return true;
|
return true;
|
||||||
} catch (const Poco::Exception &E) {
|
} catch (const Poco::Exception &E) {
|
||||||
}
|
}
|
||||||
return false;
|
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) );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ namespace OpenWifi::GWObjects {
|
|||||||
uint64_t TX = 0, RX = 0;
|
uint64_t TX = 0, RX = 0;
|
||||||
uint64_t Associations_2G=0;
|
uint64_t Associations_2G=0;
|
||||||
uint64_t Associations_5G=0;
|
uint64_t Associations_5G=0;
|
||||||
|
uint64_t Associations_6G=0;
|
||||||
bool Connected = false;
|
bool Connected = false;
|
||||||
uint64_t LastContact=0;
|
uint64_t LastContact=0;
|
||||||
std::string Firmware;
|
std::string Firmware;
|
||||||
@@ -38,9 +39,41 @@ namespace OpenWifi::GWObjects {
|
|||||||
uint64_t kafkaPackets=0;
|
uint64_t kafkaPackets=0;
|
||||||
uint64_t websocketPackets=0;
|
uint64_t websocketPackets=0;
|
||||||
std::string locale;
|
std::string locale;
|
||||||
|
uint64_t started=0;
|
||||||
|
uint64_t sessionId=0;
|
||||||
|
double connectionCompletionTime=0.0;
|
||||||
|
std::uint64_t certificateExpiryDate=0;
|
||||||
|
|
||||||
void to_json(Poco::JSON::Object &Obj) const;
|
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 {
|
struct Device {
|
||||||
std::string SerialNumber;
|
std::string SerialNumber;
|
||||||
std::string DeviceType;
|
std::string DeviceType;
|
||||||
@@ -64,6 +97,10 @@ namespace OpenWifi::GWObjects {
|
|||||||
std::string entity;
|
std::string entity;
|
||||||
uint64_t modified=0;
|
uint64_t modified=0;
|
||||||
std::string locale;
|
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(Poco::JSON::Object &Obj) const;
|
||||||
void to_json_with_status(Poco::JSON::Object &Obj) const;
|
void to_json_with_status(Poco::JSON::Object &Obj) const;
|
||||||
@@ -71,6 +108,15 @@ namespace OpenWifi::GWObjects {
|
|||||||
void Print() const;
|
void Print() const;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
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);
|
||||||
|
};
|
||||||
|
|
||||||
struct Statistics {
|
struct Statistics {
|
||||||
std::string SerialNumber;
|
std::string SerialNumber;
|
||||||
uint64_t UUID = 0 ;
|
uint64_t UUID = 0 ;
|
||||||
@@ -200,13 +246,44 @@ namespace OpenWifi::GWObjects {
|
|||||||
void to_json(Poco::JSON::Object &Obj) const;
|
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 {
|
struct ScriptRequest {
|
||||||
uint64_t timeout=30;
|
|
||||||
std::string serialNumber;
|
std::string serialNumber;
|
||||||
|
uint64_t timeout=30;
|
||||||
std::string type;
|
std::string type;
|
||||||
std::string script;
|
std::string script;
|
||||||
std::string scriptId;
|
std::string scriptId;
|
||||||
uint64_t when=0;
|
std::uint64_t when;
|
||||||
|
std::string signature;
|
||||||
|
bool deferred;
|
||||||
|
std::string uri;
|
||||||
|
|
||||||
void to_json(Poco::JSON::Object &Obj) const;
|
void to_json(Poco::JSON::Object &Obj) const;
|
||||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||||
};
|
};
|
||||||
@@ -216,6 +293,17 @@ namespace OpenWifi::GWObjects {
|
|||||||
std::string ip;
|
std::string ip;
|
||||||
uint16_t port=0;
|
uint16_t port=0;
|
||||||
uint64_t weight=0;
|
uint64_t weight=0;
|
||||||
|
std::string secret;
|
||||||
|
std::string certificate;
|
||||||
|
bool radsec=false;
|
||||||
|
bool allowSelfSigned=false;
|
||||||
|
uint16_t radsecPort=2083;
|
||||||
|
std::string radsecSecret;
|
||||||
|
std::string radsecKey;
|
||||||
|
std::string radsecCert;
|
||||||
|
std::vector<std::string> radsecCacerts;
|
||||||
|
std::vector<std::string> radsecRealms;
|
||||||
|
bool ignore=false;
|
||||||
|
|
||||||
void to_json(Poco::JSON::Object &Obj) const;
|
void to_json(Poco::JSON::Object &Obj) const;
|
||||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||||
@@ -237,6 +325,8 @@ namespace OpenWifi::GWObjects {
|
|||||||
std::string description;
|
std::string description;
|
||||||
RadiusProxyServerConfig authConfig;
|
RadiusProxyServerConfig authConfig;
|
||||||
RadiusProxyServerConfig acctConfig;
|
RadiusProxyServerConfig acctConfig;
|
||||||
|
RadiusProxyServerConfig coaConfig;
|
||||||
|
bool useByDefault=false;
|
||||||
|
|
||||||
void to_json(Poco::JSON::Object &Obj) const;
|
void to_json(Poco::JSON::Object &Obj) const;
|
||||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||||
@@ -248,4 +338,5 @@ namespace OpenWifi::GWObjects {
|
|||||||
void to_json(Poco::JSON::Object &Obj) const;
|
void to_json(Poco::JSON::Object &Obj) const;
|
||||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
110
src/RESTObjects/RESTAPI_OWLSobjects.cpp
Normal file
110
src/RESTObjects/RESTAPI_OWLSobjects.cpp
Normal file
@@ -0,0 +1,110 @@
|
|||||||
|
//
|
||||||
|
// Created by stephane bourque on 2021-08-31.
|
||||||
|
//
|
||||||
|
|
||||||
|
#include "framework/RESTAPI_utils.h"
|
||||||
|
|
||||||
|
using OpenWifi::RESTAPI_utils::field_to_json;
|
||||||
|
using OpenWifi::RESTAPI_utils::field_from_json;
|
||||||
|
using OpenWifi::RESTAPI_utils::EmbedDocument;
|
||||||
|
|
||||||
|
#include "RESTAPI_OWLSobjects.h"
|
||||||
|
|
||||||
|
// SIM -> 0x53/0x073, 0x49/0x69, 0x4d/0x6d
|
||||||
|
|
||||||
|
namespace OpenWifi::OWLSObjects {
|
||||||
|
|
||||||
|
void SimulationDetails::to_json(Poco::JSON::Object &Obj) const {
|
||||||
|
field_to_json(Obj,"id", id);
|
||||||
|
field_to_json(Obj,"name", name);
|
||||||
|
field_to_json(Obj,"gateway", gateway);
|
||||||
|
field_to_json(Obj,"certificate", certificate);
|
||||||
|
field_to_json(Obj,"key", key);
|
||||||
|
field_to_json(Obj,"macPrefix", macPrefix);
|
||||||
|
field_to_json(Obj,"deviceType", deviceType);
|
||||||
|
field_to_json(Obj,"devices", devices);
|
||||||
|
field_to_json(Obj,"healthCheckInterval", healthCheckInterval);
|
||||||
|
field_to_json(Obj,"stateInterval", stateInterval);
|
||||||
|
field_to_json(Obj,"minAssociations", minAssociations);
|
||||||
|
field_to_json(Obj,"maxAssociations", maxAssociations);
|
||||||
|
field_to_json(Obj,"minClients", minClients);
|
||||||
|
field_to_json(Obj,"maxClients", maxClients);
|
||||||
|
field_to_json(Obj,"simulationLength", simulationLength);
|
||||||
|
field_to_json(Obj,"threads", threads);
|
||||||
|
field_to_json(Obj,"clientInterval", clientInterval);
|
||||||
|
field_to_json(Obj,"keepAlive", keepAlive);
|
||||||
|
field_to_json(Obj,"reconnectInterval", reconnectInterval);
|
||||||
|
field_to_json(Obj,"concurrentDevices", concurrentDevices);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SimulationDetails::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,"gateway", gateway);
|
||||||
|
field_from_json(Obj,"certificate", certificate);
|
||||||
|
field_from_json(Obj,"key", key);
|
||||||
|
field_from_json(Obj,"macPrefix", macPrefix);
|
||||||
|
field_from_json(Obj,"deviceType", deviceType);
|
||||||
|
field_from_json(Obj,"devices", devices);
|
||||||
|
field_from_json(Obj,"healthCheckInterval", healthCheckInterval);
|
||||||
|
field_from_json(Obj,"stateInterval", stateInterval);
|
||||||
|
field_from_json(Obj,"minAssociations", minAssociations);
|
||||||
|
field_from_json(Obj,"maxAssociations", maxAssociations);
|
||||||
|
field_from_json(Obj,"minClients", minClients);
|
||||||
|
field_from_json(Obj,"maxClients", maxClients);
|
||||||
|
field_from_json(Obj,"simulationLength", simulationLength);
|
||||||
|
field_from_json(Obj,"threads", threads);
|
||||||
|
field_from_json(Obj,"clientInterval", clientInterval);
|
||||||
|
field_from_json(Obj,"keepAlive", keepAlive);
|
||||||
|
field_from_json(Obj,"reconnectInterval", reconnectInterval);
|
||||||
|
field_from_json(Obj,"concurrentDevices", concurrentDevices);
|
||||||
|
return true;
|
||||||
|
} catch(...) {
|
||||||
|
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SimulationDetailsList::to_json(Poco::JSON::Object &Obj) const {
|
||||||
|
field_to_json(Obj,"list", list);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool SimulationDetailsList::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
|
try {
|
||||||
|
field_from_json(Obj,"list", list);
|
||||||
|
return true;
|
||||||
|
} catch(...) {
|
||||||
|
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void SimulationStatus::to_json(Poco::JSON::Object &Obj) const {
|
||||||
|
field_to_json(Obj,"id", id);
|
||||||
|
field_to_json(Obj,"simulationId", simulationId);
|
||||||
|
field_to_json(Obj,"state", state);
|
||||||
|
field_to_json(Obj,"tx", tx);
|
||||||
|
field_to_json(Obj,"rx", rx);
|
||||||
|
field_to_json(Obj,"msgsTx", msgsTx);
|
||||||
|
field_to_json(Obj,"msgsRx", msgsRx);
|
||||||
|
field_to_json(Obj,"liveDevices", liveDevices);
|
||||||
|
field_to_json(Obj,"timeToFullDevices", timeToFullDevices);
|
||||||
|
field_to_json(Obj,"startTime", startTime);
|
||||||
|
field_to_json(Obj,"endTime", endTime);
|
||||||
|
field_to_json(Obj,"errorDevices", errorDevices);
|
||||||
|
field_to_json(Obj,"owner", owner);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Dashboard::to_json([[maybe_unused]] Poco::JSON::Object &Obj) const {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Dashboard::from_json([[maybe_unused]] const Poco::JSON::Object::Ptr &Obj) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Dashboard::reset() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
77
src/RESTObjects/RESTAPI_OWLSobjects.h
Normal file
77
src/RESTObjects/RESTAPI_OWLSobjects.h
Normal file
@@ -0,0 +1,77 @@
|
|||||||
|
//
|
||||||
|
// Created by stephane bourque on 2021-08-31.
|
||||||
|
//
|
||||||
|
|
||||||
|
#ifndef UCENTRALSIM_RESTAPI_OWLSOBJECTS_H
|
||||||
|
#define UCENTRALSIM_RESTAPI_OWLSOBJECTS_H
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
#include "Poco/JSON/Object.h"
|
||||||
|
|
||||||
|
namespace OpenWifi::OWLSObjects {
|
||||||
|
|
||||||
|
struct SimulationDetails {
|
||||||
|
std::string id;
|
||||||
|
std::string name;
|
||||||
|
std::string gateway;
|
||||||
|
std::string certificate;
|
||||||
|
std::string key;
|
||||||
|
std::string macPrefix;
|
||||||
|
std::string deviceType;
|
||||||
|
uint64_t devices = 5;
|
||||||
|
uint64_t healthCheckInterval = 60;
|
||||||
|
uint64_t stateInterval = 60 ;
|
||||||
|
uint64_t minAssociations = 1;
|
||||||
|
uint64_t maxAssociations = 3;
|
||||||
|
uint64_t minClients = 1 ;
|
||||||
|
uint64_t maxClients = 3;
|
||||||
|
uint64_t simulationLength = 60 * 60;
|
||||||
|
uint64_t threads = 16;
|
||||||
|
uint64_t clientInterval = 1;
|
||||||
|
uint64_t keepAlive = 300;
|
||||||
|
uint64_t reconnectInterval = 30 ;
|
||||||
|
uint64_t concurrentDevices = 5;
|
||||||
|
|
||||||
|
void to_json(Poco::JSON::Object &Obj) const;
|
||||||
|
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SimulationDetailsList {
|
||||||
|
std::vector<SimulationDetails> list;
|
||||||
|
|
||||||
|
void to_json(Poco::JSON::Object &Obj) const;
|
||||||
|
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct SimulationStatus {
|
||||||
|
std::string id;
|
||||||
|
std::string simulationId;
|
||||||
|
std::string state;
|
||||||
|
uint64_t tx;
|
||||||
|
uint64_t rx;
|
||||||
|
uint64_t msgsTx;
|
||||||
|
uint64_t msgsRx;
|
||||||
|
uint64_t liveDevices;
|
||||||
|
uint64_t timeToFullDevices;
|
||||||
|
uint64_t startTime;
|
||||||
|
uint64_t endTime;
|
||||||
|
uint64_t errorDevices;
|
||||||
|
std::string owner;
|
||||||
|
|
||||||
|
void to_json(Poco::JSON::Object &Obj) const;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
struct Dashboard {
|
||||||
|
int O;
|
||||||
|
|
||||||
|
void to_json(Poco::JSON::Object &Obj) const;
|
||||||
|
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||||
|
void reset();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#endif //UCENTRALSIM_RESTAPI_OWLSOBJECTS_H
|
||||||
@@ -8,7 +8,9 @@
|
|||||||
|
|
||||||
|
|
||||||
#include "RESTAPI_ProvObjects.h"
|
#include "RESTAPI_ProvObjects.h"
|
||||||
#include "framework/MicroService.h"
|
#include "framework/RESTAPI_utils.h"
|
||||||
|
#include "framework/MicroServiceFuncs.h"
|
||||||
|
#include "framework/utils.h"
|
||||||
|
|
||||||
using OpenWifi::RESTAPI_utils::field_to_json;
|
using OpenWifi::RESTAPI_utils::field_to_json;
|
||||||
using OpenWifi::RESTAPI_utils::field_from_json;
|
using OpenWifi::RESTAPI_utils::field_from_json;
|
||||||
@@ -600,6 +602,7 @@ namespace OpenWifi::ProvObjects {
|
|||||||
field_to_json( Obj, "devClass",devClass);
|
field_to_json( Obj, "devClass",devClass);
|
||||||
field_to_json( Obj, "locale",locale);
|
field_to_json( Obj, "locale",locale);
|
||||||
field_to_json( Obj, "realMacAddress",realMacAddress);
|
field_to_json( Obj, "realMacAddress",realMacAddress);
|
||||||
|
field_to_json( Obj, "doNotAllowOverrides",doNotAllowOverrides);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool InventoryTag::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
bool InventoryTag::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
@@ -621,6 +624,7 @@ namespace OpenWifi::ProvObjects {
|
|||||||
field_from_json( Obj,"devClass",devClass);
|
field_from_json( Obj,"devClass",devClass);
|
||||||
field_from_json( Obj,"locale",locale);
|
field_from_json( Obj,"locale",locale);
|
||||||
field_from_json( Obj,"realMacAddress",realMacAddress);
|
field_from_json( Obj,"realMacAddress",realMacAddress);
|
||||||
|
field_from_json( Obj, "doNotAllowOverrides",doNotAllowOverrides);
|
||||||
return true;
|
return true;
|
||||||
} catch(...) {
|
} catch(...) {
|
||||||
|
|
||||||
@@ -1091,7 +1095,7 @@ namespace OpenWifi::ProvObjects {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool UpdateObjectInfo(const Poco::JSON::Object::Ptr &O, const SecurityObjects::UserInfo &U, ObjectInfo &I) {
|
bool UpdateObjectInfo(const Poco::JSON::Object::Ptr &O, const SecurityObjects::UserInfo &U, ObjectInfo &I) {
|
||||||
uint64_t Now = OpenWifi::Now();
|
uint64_t Now = Utils::Now();
|
||||||
if(O->has("name"))
|
if(O->has("name"))
|
||||||
I.name = O->get("name").toString();
|
I.name = O->get("name").toString();
|
||||||
|
|
||||||
@@ -1112,7 +1116,7 @@ namespace OpenWifi::ProvObjects {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool CreateObjectInfo(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) {
|
||||||
uint64_t Now = OpenWifi::Now();
|
uint64_t Now = Utils::Now();
|
||||||
if(O->has("name"))
|
if(O->has("name"))
|
||||||
I.name = O->get("name").toString();
|
I.name = O->get("name").toString();
|
||||||
|
|
||||||
@@ -1130,14 +1134,14 @@ namespace OpenWifi::ProvObjects {
|
|||||||
}
|
}
|
||||||
I.notes = N;
|
I.notes = N;
|
||||||
I.modified = I.created = Now;
|
I.modified = I.created = Now;
|
||||||
I.id = MicroService::CreateUUID();
|
I.id = MicroServiceCreateUUID();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CreateObjectInfo([[maybe_unused]] const SecurityObjects::UserInfo &U, ObjectInfo &I) {
|
bool CreateObjectInfo([[maybe_unused]] const SecurityObjects::UserInfo &U, ObjectInfo &I) {
|
||||||
I.modified = I.created = OpenWifi::Now();
|
I.modified = I.created = Utils::Now();
|
||||||
I.id = MicroService::CreateUUID();
|
I.id = MicroServiceCreateUUID();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1159,5 +1163,82 @@ namespace OpenWifi::ProvObjects {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RRMAlgorithmDetails::to_json(Poco::JSON::Object &Obj) const {
|
||||||
|
field_to_json(Obj,"name",name);
|
||||||
|
field_to_json(Obj,"parameters",parameters);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RRMAlgorithmDetails::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
|
try {
|
||||||
|
field_from_json(Obj,"name",name);
|
||||||
|
field_from_json(Obj,"parameters",parameters);
|
||||||
|
return true;
|
||||||
|
} catch(...) {
|
||||||
|
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void RRMDetails::to_json(Poco::JSON::Object &Obj) const {
|
||||||
|
field_to_json(Obj,"vendor",vendor);
|
||||||
|
field_to_json(Obj,"schedule",schedule);
|
||||||
|
field_to_json(Obj,"algorithms",algorithms);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool RRMDetails::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||||
|
try {
|
||||||
|
field_from_json(Obj,"vendor",vendor);
|
||||||
|
field_from_json(Obj,"schedule",schedule);
|
||||||
|
field_from_json(Obj,"algorithms",algorithms);
|
||||||
|
return true;
|
||||||
|
} catch(...) {
|
||||||
|
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -8,8 +8,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
#include "RESTObjects/RESTAPI_SecurityObjects.h"
|
||||||
#include "RESTAPI_SecurityObjects.h"
|
|
||||||
|
|
||||||
namespace OpenWifi::ProvObjects {
|
namespace OpenWifi::ProvObjects {
|
||||||
|
|
||||||
@@ -62,6 +61,21 @@ namespace OpenWifi::ProvObjects {
|
|||||||
};
|
};
|
||||||
typedef std::vector<ManagementPolicy> ManagementPolicyVec;
|
typedef std::vector<ManagementPolicy> ManagementPolicyVec;
|
||||||
|
|
||||||
|
struct RRMAlgorithmDetails {
|
||||||
|
std::string name;
|
||||||
|
std::string parameters;
|
||||||
|
void to_json(Poco::JSON::Object &Obj) const;
|
||||||
|
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||||
|
};
|
||||||
|
|
||||||
|
struct RRMDetails {
|
||||||
|
std::string vendor;
|
||||||
|
std::string schedule;
|
||||||
|
std::vector<RRMAlgorithmDetails> algorithms;
|
||||||
|
void to_json(Poco::JSON::Object &Obj) const;
|
||||||
|
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||||
|
};
|
||||||
|
|
||||||
struct DeviceRules {
|
struct DeviceRules {
|
||||||
std::string rcOnly{"inherit"};
|
std::string rcOnly{"inherit"};
|
||||||
std::string rrm{"inherit"};
|
std::string rrm{"inherit"};
|
||||||
@@ -414,6 +428,7 @@ namespace OpenWifi::ProvObjects {
|
|||||||
std::string devClass;
|
std::string devClass;
|
||||||
std::string locale;
|
std::string locale;
|
||||||
std::string realMacAddress;
|
std::string realMacAddress;
|
||||||
|
bool doNotAllowOverrides=false;
|
||||||
|
|
||||||
void to_json(Poco::JSON::Object &Obj) const;
|
void to_json(Poco::JSON::Object &Obj) const;
|
||||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||||
@@ -679,6 +694,27 @@ namespace OpenWifi::ProvObjects {
|
|||||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
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 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 Poco::JSON::Object::Ptr &O, const SecurityObjects::UserInfo &U, ObjectInfo &I);
|
||||||
bool CreateObjectInfo(const SecurityObjects::UserInfo &U, ObjectInfo &I);
|
bool CreateObjectInfo(const SecurityObjects::UserInfo &U, ObjectInfo &I);
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
#include "Poco/JSON/Parser.h"
|
#include "Poco/JSON/Parser.h"
|
||||||
#include "Poco/JSON/Stringifier.h"
|
#include "Poco/JSON/Stringifier.h"
|
||||||
|
|
||||||
#include "framework/MicroService.h"
|
#include "framework/RESTAPI_utils.h"
|
||||||
#include "RESTAPI_SecurityObjects.h"
|
#include "RESTAPI_SecurityObjects.h"
|
||||||
|
|
||||||
using OpenWifi::RESTAPI_utils::field_to_json;
|
using OpenWifi::RESTAPI_utils::field_to_json;
|
||||||
@@ -433,7 +433,7 @@ namespace OpenWifi::SecurityObjects {
|
|||||||
SecurityObjects::NoteInfoVec NIV;
|
SecurityObjects::NoteInfoVec NIV;
|
||||||
NIV = RESTAPI_utils::to_object_array<SecurityObjects::NoteInfo>(Obj->get("notes").toString());
|
NIV = RESTAPI_utils::to_object_array<SecurityObjects::NoteInfo>(Obj->get("notes").toString());
|
||||||
for(auto const &i:NIV) {
|
for(auto const &i:NIV) {
|
||||||
SecurityObjects::NoteInfo ii{.created=(uint64_t)OpenWifi::Now(), .createdBy=UInfo.email, .note=i.note};
|
SecurityObjects::NoteInfo ii{.created=(uint64_t)Utils::Now(), .createdBy=UInfo.email, .note=i.note};
|
||||||
Notes.push_back(ii);
|
Notes.push_back(ii);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -446,7 +446,7 @@ namespace OpenWifi::SecurityObjects {
|
|||||||
|
|
||||||
bool MergeNotes(const NoteInfoVec & NewNotes, const UserInfo &UInfo, NoteInfoVec & ExistingNotes) {
|
bool MergeNotes(const NoteInfoVec & NewNotes, const UserInfo &UInfo, NoteInfoVec & ExistingNotes) {
|
||||||
for(auto const &i:NewNotes) {
|
for(auto const &i:NewNotes) {
|
||||||
SecurityObjects::NoteInfo ii{.created=(uint64_t)OpenWifi::Now(), .createdBy=UInfo.email, .note=i.note};
|
SecurityObjects::NoteInfo ii{.created=(uint64_t)Utils::Now(), .createdBy=UInfo.email, .note=i.note};
|
||||||
ExistingNotes.push_back(ii);
|
ExistingNotes.push_back(ii);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@@ -619,5 +619,80 @@ namespace OpenWifi::SecurityObjects {
|
|||||||
field_to_json(Obj,"login",login);
|
field_to_json(Obj,"login",login);
|
||||||
field_to_json(Obj,"logout",logout);
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -9,10 +9,12 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <type_traits>
|
||||||
#include "framework/OpenWifiTypes.h"
|
#include "framework/OpenWifiTypes.h"
|
||||||
#include "Poco/JSON/Object.h"
|
#include "Poco/JSON/Object.h"
|
||||||
#include "Poco/Data/LOB.h"
|
#include "Poco/Data/LOB.h"
|
||||||
#include "Poco/Data/LOBStream.h"
|
#include "Poco/Data/LOBStream.h"
|
||||||
|
#include "framework/utils.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
uint64_t Now();
|
uint64_t Now();
|
||||||
@@ -27,8 +29,13 @@ namespace OpenWifi {
|
|||||||
bool Delete_ = true;
|
bool Delete_ = true;
|
||||||
bool PortalLogin_ = true;
|
bool PortalLogin_ = true;
|
||||||
|
|
||||||
|
AclTemplate() noexcept = default;
|
||||||
|
|
||||||
void to_json(Poco::JSON::Object &Obj) const;
|
void to_json(Poco::JSON::Object &Obj) const;
|
||||||
bool from_json(const Poco::JSON::Object::Ptr &Obj); };
|
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||||
|
};
|
||||||
|
|
||||||
|
static_assert( std::is_nothrow_move_constructible_v<AclTemplate> );
|
||||||
|
|
||||||
struct WebToken {
|
struct WebToken {
|
||||||
std::string access_token_;
|
std::string access_token_;
|
||||||
@@ -56,7 +63,7 @@ namespace OpenWifi {
|
|||||||
std::string UserTypeToString(USER_ROLE U);
|
std::string UserTypeToString(USER_ROLE U);
|
||||||
|
|
||||||
struct NoteInfo {
|
struct NoteInfo {
|
||||||
uint64_t created=0; // = OpenWifi::Now();
|
uint64_t created=0; // = Utils::Now();
|
||||||
std::string createdBy;
|
std::string createdBy;
|
||||||
std::string note;
|
std::string note;
|
||||||
|
|
||||||
@@ -95,7 +102,7 @@ namespace OpenWifi {
|
|||||||
std::string uuid;
|
std::string uuid;
|
||||||
std::string question;
|
std::string question;
|
||||||
std::string method;
|
std::string method;
|
||||||
uint64_t created = OpenWifi::Now();
|
uint64_t created = Utils::Now();
|
||||||
|
|
||||||
void to_json(Poco::JSON::Object &Obj) const;
|
void to_json(Poco::JSON::Object &Obj) const;
|
||||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||||
@@ -245,7 +252,8 @@ namespace OpenWifi {
|
|||||||
VERIFY_EMAIL,
|
VERIFY_EMAIL,
|
||||||
SUB_FORGOT_PASSWORD,
|
SUB_FORGOT_PASSWORD,
|
||||||
SUB_VERIFY_EMAIL,
|
SUB_VERIFY_EMAIL,
|
||||||
SUB_SIGNUP
|
SUB_SIGNUP,
|
||||||
|
EMAIL_INVITATION
|
||||||
};
|
};
|
||||||
|
|
||||||
struct ActionLink {
|
struct ActionLink {
|
||||||
@@ -257,7 +265,7 @@ namespace OpenWifi {
|
|||||||
std::string locale;
|
std::string locale;
|
||||||
std::string message;
|
std::string message;
|
||||||
uint64_t sent=0;
|
uint64_t sent=0;
|
||||||
uint64_t created=OpenWifi::Now();
|
uint64_t created=Utils::Now();
|
||||||
uint64_t expires=0;
|
uint64_t expires=0;
|
||||||
uint64_t completed=0;
|
uint64_t completed=0;
|
||||||
uint64_t canceled=0;
|
uint64_t canceled=0;
|
||||||
@@ -317,5 +325,44 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
void to_json(Poco::JSON::Object &Obj) const;
|
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);
|
||||||
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,12 +3,11 @@
|
|||||||
//
|
//
|
||||||
|
|
||||||
#include "RESTAPI_SubObjects.h"
|
#include "RESTAPI_SubObjects.h"
|
||||||
#include "framework/MicroService.h"
|
#include "framework/RESTAPI_utils.h"
|
||||||
|
|
||||||
using OpenWifi::RESTAPI_utils::field_to_json;
|
using OpenWifi::RESTAPI_utils::field_to_json;
|
||||||
using OpenWifi::RESTAPI_utils::field_from_json;
|
using OpenWifi::RESTAPI_utils::field_from_json;
|
||||||
|
|
||||||
|
|
||||||
namespace OpenWifi::SubObjects {
|
namespace OpenWifi::SubObjects {
|
||||||
|
|
||||||
void HomeDeviceMode::to_json(Poco::JSON::Object &Obj) const {
|
void HomeDeviceMode::to_json(Poco::JSON::Object &Obj) const {
|
||||||
|
|||||||
@@ -2,11 +2,9 @@
|
|||||||
// Created by stephane bourque on 2021-08-11.
|
// Created by stephane bourque on 2021-08-11.
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "SerialNumberCache.h"
|
|
||||||
#include <mutex>
|
|
||||||
|
|
||||||
#include "StorageService.h"
|
#include "SerialNumberCache.h"
|
||||||
#include "framework/MicroService.h"
|
#include "framework/utils.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "framework/MicroService.h"
|
#include <mutex>
|
||||||
|
#include "framework/SubSystemServer.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
class SerialNumberCache : public SubSystemServer {
|
class SerialNumberCache : public SubSystemServer {
|
||||||
|
|||||||
@@ -5,12 +5,15 @@
|
|||||||
#include "Signup.h"
|
#include "Signup.h"
|
||||||
#include "StorageService.h"
|
#include "StorageService.h"
|
||||||
#include "sdks/SDK_gw.h"
|
#include "sdks/SDK_gw.h"
|
||||||
|
#include "framework/MicroServiceFuncs.h"
|
||||||
|
#include "framework/utils.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
|
|
||||||
int Signup::Start() {
|
int Signup::Start() {
|
||||||
GracePeriod_ = MicroService::instance().ConfigGetInt("signup.graceperiod", 60*60);
|
poco_information(Logger(),"Starting...");
|
||||||
LingerPeriod_ = MicroService::instance().ConfigGetInt("signup.lingerperiod", 24*60*60);
|
GracePeriod_ = MicroServiceConfigGetInt("signup.graceperiod", 60*60);
|
||||||
|
LingerPeriod_ = MicroServiceConfigGetInt("signup.lingerperiod", 24*60*60);
|
||||||
|
|
||||||
SignupDB::RecordVec Signups_;
|
SignupDB::RecordVec Signups_;
|
||||||
StorageService()->SignupDB().GetIncompleteSignups(Signups_);
|
StorageService()->SignupDB().GetIncompleteSignups(Signups_);
|
||||||
@@ -29,10 +32,12 @@ namespace OpenWifi {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void Signup::Stop() {
|
void Signup::Stop() {
|
||||||
|
poco_information(Logger(),"Stopping...");
|
||||||
Running_ = false;
|
Running_ = false;
|
||||||
Timer_.stop();
|
Timer_.stop();
|
||||||
Worker_.wakeUp();
|
Worker_.wakeUp();
|
||||||
Worker_.join();
|
Worker_.join();
|
||||||
|
poco_information(Logger(),"Stopped...");
|
||||||
}
|
}
|
||||||
|
|
||||||
void Signup::onTimer([[maybe_unused]] Poco::Timer &timer) {
|
void Signup::onTimer([[maybe_unused]] Poco::Timer &timer) {
|
||||||
@@ -42,6 +47,7 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
void Signup::run() {
|
void Signup::run() {
|
||||||
Running_ = true;
|
Running_ = true;
|
||||||
|
Utils::SetThreadName("signup-mgr");
|
||||||
while(Running_) {
|
while(Running_) {
|
||||||
Poco::Thread::trySleep(5000);
|
Poco::Thread::trySleep(5000);
|
||||||
|
|
||||||
@@ -67,7 +73,7 @@ namespace OpenWifi {
|
|||||||
// We must now complete the device transfer to this new subscriber and complete the
|
// We must now complete the device transfer to this new subscriber and complete the
|
||||||
// signup job.
|
// signup job.
|
||||||
IT.subscriber = SE.userId;
|
IT.subscriber = SE.userId;
|
||||||
IT.info.modified = OpenWifi::Now();
|
IT.info.modified = Utils::Now();
|
||||||
IT.realMacAddress = SE.macAddress;
|
IT.realMacAddress = SE.macAddress;
|
||||||
if(IT.entity.empty()) {
|
if(IT.entity.empty()) {
|
||||||
|
|
||||||
@@ -76,7 +82,7 @@ namespace OpenWifi {
|
|||||||
}
|
}
|
||||||
Poco::JSON::Object NewState;
|
Poco::JSON::Object NewState;
|
||||||
NewState.set("method", "signup");
|
NewState.set("method", "signup");
|
||||||
NewState.set("date", OpenWifi::Now());
|
NewState.set("date", Utils::Now());
|
||||||
NewState.set("status", "completed");
|
NewState.set("status", "completed");
|
||||||
std::ostringstream OS;
|
std::ostringstream OS;
|
||||||
NewState.stringify(OS);
|
NewState.stringify(OS);
|
||||||
@@ -85,8 +91,8 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
// we need to move this device to the SubscriberDevice DB
|
// we need to move this device to the SubscriberDevice DB
|
||||||
ProvObjects::SubscriberDevice SD;
|
ProvObjects::SubscriberDevice SD;
|
||||||
SD.info.id = MicroService::CreateUUID();
|
SD.info.id = MicroServiceCreateUUID();
|
||||||
SD.info.modified = SD.info.created = OpenWifi::Now();
|
SD.info.modified = SD.info.created = Utils::Now();
|
||||||
SD.info.name = IT.realMacAddress;
|
SD.info.name = IT.realMacAddress;
|
||||||
SD.operatorId = SE.operatorId;
|
SD.operatorId = SE.operatorId;
|
||||||
SD.serialNumber = SerialNumber;
|
SD.serialNumber = SerialNumber;
|
||||||
@@ -96,26 +102,26 @@ namespace OpenWifi {
|
|||||||
SD.state = OS.str();
|
SD.state = OS.str();
|
||||||
SD.subscriberId = SE.userId;
|
SD.subscriberId = SE.userId;
|
||||||
|
|
||||||
Logger().information(fmt::format("Setting service class for {}",SD.serialNumber));
|
poco_information(Logger(),fmt::format("Setting service class for {}",SD.serialNumber));
|
||||||
SD.serviceClass = StorageService()->ServiceClassDB().DefaultForOperator(SE.operatorId);
|
SD.serviceClass = StorageService()->ServiceClassDB().DefaultForOperator(SE.operatorId);
|
||||||
Logger().information(fmt::format("Removing old device information for {}",SD.serialNumber));
|
poco_information(Logger(),fmt::format("Removing old device information for {}",SD.serialNumber));
|
||||||
StorageService()->SubscriberDeviceDB().DeleteRecord("serialNumber", SD.serialNumber);
|
StorageService()->SubscriberDeviceDB().DeleteRecord("serialNumber", SD.serialNumber);
|
||||||
Logger().information(fmt::format("Creating subscriber device for {}",SD.serialNumber));
|
poco_information(Logger(),fmt::format("Creating subscriber device for {}",SD.serialNumber));
|
||||||
StorageService()->SubscriberDeviceDB().CreateRecord(SD);
|
StorageService()->SubscriberDeviceDB().CreateRecord(SD);
|
||||||
Logger().information(fmt::format("Removing old inventory for {}",SD.serialNumber));
|
poco_information(Logger(),fmt::format("Removing old inventory for {}",SD.serialNumber));
|
||||||
StorageService()->InventoryDB().DeleteRecord("serialNumber", SD.serialNumber);
|
StorageService()->InventoryDB().DeleteRecord("serialNumber", SD.serialNumber);
|
||||||
|
|
||||||
SE.status = "signup completed";
|
SE.status = "signup completed";
|
||||||
SE.serialNumber = SerialNumber;
|
SE.serialNumber = SerialNumber;
|
||||||
SE.statusCode = ProvObjects::SignupStatusCodes::SignupSuccess;
|
SE.statusCode = ProvObjects::SignupStatusCodes::SignupSuccess;
|
||||||
SE.completed = OpenWifi::Now();
|
SE.completed = Utils::Now();
|
||||||
SE.info.modified = OpenWifi::Now();
|
SE.info.modified = Utils::Now();
|
||||||
SE.error = 0;
|
SE.error = 0;
|
||||||
Logger().information(fmt::format("Completed signup for {}",SD.serialNumber));
|
poco_information(Logger(),fmt::format("Completed signup for {}",SD.serialNumber));
|
||||||
StorageService()->SignupDB().UpdateRecord("id", SE.info.id, SE);
|
StorageService()->SignupDB().UpdateRecord("id", SE.info.id, SE);
|
||||||
Logger().information(fmt::format("Setting GW subscriber for {}",SD.serialNumber));
|
poco_information(Logger(),fmt::format("Setting GW subscriber for {}",SD.serialNumber));
|
||||||
SDK::GW::Device::SetSubscriber(SerialNumber, IT.subscriber);
|
SDK::GW::Device::SetSubscriber(SerialNumber, IT.subscriber);
|
||||||
Logger().information(fmt::format("Success for {}",SD.serialNumber));
|
poco_information(Logger(),fmt::format("Success for {}",SD.serialNumber));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "framework/MicroService.h"
|
#include "framework/SubSystemServer.h"
|
||||||
#include "RESTObjects/RESTAPI_ProvObjects.h"
|
#include "RESTObjects/RESTAPI_ProvObjects.h"
|
||||||
#include "Poco/Timer.h"
|
#include "Poco/Timer.h"
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user