Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIFI-13542 Release merge #100

Merged
merged 23 commits into from
Mar 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
bc116c1
https://telecominfraproject.atlassian.net/browse/WIFI-13267
stephb9959 Jan 4, 2024
4ab9a1d
https://telecominfraproject.atlassian.net/browse/WIFI-13256
stephb9959 Jan 4, 2024
4ded899
https://telecominfraproject.atlassian.net/browse/WIFI-13256
stephb9959 Feb 7, 2024
eed9525
Fix IP range check.
Feb 16, 2024
ec11708
Fix IP range check.
Feb 16, 2024
fd85c70
https://telecominfraproject.atlassian.net/browse/WIFI-13434
stephb9959 Feb 20, 2024
102e240
https://telecominfraproject.atlassian.net/browse/WIFI-13434
stephb9959 Feb 21, 2024
2e8a2fe
https://telecominfraproject.atlassian.net/browse/WIFI-13434
stephb9959 Feb 21, 2024
c653550
https://telecominfraproject.atlassian.net/browse/WIFI-13450
stephb9959 Feb 29, 2024
74557c1
https://telecominfraproject.atlassian.net/browse/WIFI-13450
stephb9959 Mar 1, 2024
5ac7b92
Merge pull request #93 from kinarasystems/ip_range_fix
stephb9959 Mar 19, 2024
d6e3701
Add more comments.
Feb 15, 2024
9412c00
Refactor code into helper method, some cleanup.
Feb 15, 2024
01b1107
testing
Feb 14, 2024
0a846e4
fix: reverting change
Mar 19, 2024
3529f86
fix: typo
Mar 19, 2024
2575fa6
Support linking of resources and configs through POST request. (#5)
Feb 26, 2024
a619c0d
Fix bug where process capabilities does not update serial number, bug…
Mar 11, 2024
cd9fdc7
WIFI-12939: change to TIP repos for libraries
Mar 19, 2024
da015b2
Merge pull request #98 from Telecominfraproject/WIFI-12939
stephb9959 Mar 20, 2024
8fc7ce7
Merge pull request #97 from kinarasystems/wifi_13519_fix_venue_propag…
stephb9959 Mar 20, 2024
10a39f2
Merge pull request #96 from kinarasystems/wifi_13523_fix_resource_req…
stephb9959 Mar 20, 2024
4b07db9
Merge pull request #95 from kinarasystems/wifi_13517_fix_expand_neste…
stephb9959 Mar 20, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 18 additions & 14 deletions BUILDING.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Building from source
In order to build the OWPROV, you will need to install its dependencies, which includes the following:
In order to build OWPROV, you will need to install its dependencies, which includes the following:
- cmake
- boost
- POCO 1.10.1 or later
Expand All @@ -12,19 +12,19 @@ In order to build the OWPROV, you will need to install its dependencies, which i

The build is done in 2 parts. The first part is to build a local copy of the framework tailored to your environment. This
framework is called [Poco](https://github.com/pocoproject/poco). The version used in this project has a couple of fixes
from the master copy needed for cmake. Please use the version of this [Poco fix](https://github.com/AriliaWireless/poco). Building
from the master copy needed for cmake. Please use the version of this [Poco fix](https://github.com/Telecominfraproject/wlan-cloud-lib-poco). Building
Poco may take several minutes depending on the platform you are building on.

## Ubuntu
These instructions have proven to work on Ubuntu 20.4.
```bash
sudo apt install git cmake g++ libssl-dev libmariadb-dev
sudo apt install git cmake g++ libssl-dev libmariadb-dev
sudo apt install libpq-dev libaprutil1-dev apache2-dev libboost-all-dev
sudo apt install librdkafka-dev // default-libmysqlclient-dev
sudo apt install nlohmann-json-dev

cd ~
git clone https://github.com/AriliaWireless/poco --branch poco-tip-v1
git clone https://github.com/Telecominfraproject/wlan-cloud-lib-poco --branch poco-tip-v1 poco
cd poco
mkdir cmake-build
cd cmake-build
Expand All @@ -33,7 +33,7 @@ cmake --build . --config Release
sudo cmake --build . --target install

cd ~
git clone https://github.com/AriliaWireless/cppkafka --branch tip-v1
git clone https://github.com/Telecominfraproject/wlan-cloud-lib-cppkafka --branch tip-v1 cppkafka
cd cppkafka
mkdir cmake-build
cd cmake-build
Expand All @@ -42,15 +42,16 @@ cmake --build . --config Release
sudo cmake --build . --target install

cd ~
git clone https://github.com/AriliaWireless/valijson --branch tip-v1
git clone https://github.com/Telecominfraproject/wlan-cloud-lib-valijson --branch tip-v1 valijson
cd valijson
mkdir cmake-build
cd cmake-build
cmake ..
cmake --build . --config Release
sudo cmake --build . --target install

git clone https://github.com/fmtlib/fmt --branch 9.0.0 /fmtlib
cd ~
git clone https://github.com/fmtlib/fmt --branch 9.0.0 fmtlib
cd fmtlib
mkdir cmake-build
cd cmake-build
Expand All @@ -71,19 +72,20 @@ make -j 8
The following instructions have proven to work on Fedora 33
```bash
sudo yum install cmake g++ openssl-devel mysql-devel mysql apr-util-devel boost boost-devel
sudo yum install yaml-cpp-devel lua-devel
sudo yum install yaml-cpp-devel lua-devel
sudo dnf install postgresql.x86_64 librdkafka-devel
sudo dnf install postgresql-devel json-devel

git clone https://github.com/AriliaWireless/poco --branch poco-tip-v1
git clone https://github.com/Telecominfraproject/wlan-cloud-lib-poco --branch poco-tip-v1 poco
cd poco
mkdir cmake-build
cd cmake-build
cmake ..
cmake --build . --config Release
sudo cmake --build . --target install

git clone https://github.com/AriliaWireless/cppkafka --branch tip-v1
cd ~
git clone https://github.com/Telecominfraproject/wlan-cloud-lib-cppkafka --branch tip-v1 cppkafka
cd cppkafka
mkdir cmake-build
cd cmake-build
Expand All @@ -92,7 +94,7 @@ cmake --build . --config Release
sudo cmake --build . --target install

cd ~
git clone https://github.com/AriliaWireless/valijson --branch tip-v1
git clone https://github.com/Telecominfraproject/wlan-cloud-lib-valijson --branch tip-v1 valijson
cd valijson
mkdir cmake-build
cd cmake-build
Expand Down Expand Up @@ -125,7 +127,7 @@ brew install openssl \
nlohmann-json \
fmt

git clone https://github.com/AriliaWireless/poco --branch poco-tip-v1
git clone https://github.com/Telecominfraproject/wlan-cloud-lib-poco --branch poco-tip-v1 poco
pushd poco
mkdir cmake-build
push cmake-build
Expand All @@ -135,7 +137,7 @@ sudo cmake --build . --target install
popd
popd

git clone https://github.com/AriliaWireless/cppkafka --branch tip-v1
git clone https://github.com/Telecominfraproject/wlan-cloud-lib-cppkafka --branch tip-v1 cppkafka
pushd cppkafka
mkdir cmake-build
pushd cmake-build
Expand All @@ -145,7 +147,7 @@ sudo cmake --build . --target install
popd
popd

git clone https://github.com/AriliaWireless/valijson --branch tip-v1
git clone https://github.com/Telecominfraproject/wlan-cloud-lib-valijson --branch tip-v1 valijson
cd valijson
mkdir cmake-build
cd cmake-build
Expand All @@ -172,6 +174,8 @@ adding -DSMALL_BUILD=1 on the cmake build line.

```bash
sudo apt install git cmake g++ libssl-dev libaprutil1-dev apache2-dev libboost-all-dev libyaml-cpp-dev

cd ~
git clone https://github.com/stephb9959/poco
cd poco
mkdir cmake-build
Expand Down
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.13)
project(owprov VERSION 3.0.0)
project(owprov VERSION 3.0.2)

set(CMAKE_CXX_STANDARD 17)

Expand Down
13 changes: 7 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,9 @@ FROM build-base AS poco-build

ARG POCO_VERSION

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
ADD https://api.github.com/repos/Telecominfraproject/wlan-cloud-lib-poco/git/refs/tags/${POCO_VERSION} version.json
RUN git clone https://github.com/Telecominfraproject/wlan-cloud-lib-poco --branch ${POCO_VERSION} /poco


WORKDIR /poco
RUN mkdir cmake-build
Expand All @@ -29,8 +30,8 @@ FROM build-base AS cppkafka-build

ARG CPPKAFKA_VERSION

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
ADD https://api.github.com/repos/Telecominfraproject/wlan-cloud-lib-cppkafka/git/refs/tags/${CPPKAFKA_VERSION} version.json
RUN git clone https://github.com/Telecominfraproject/wlan-cloud-lib-cppkafka --branch ${CPPKAFKA_VERSION} /cppkafka

WORKDIR /cppkafka
RUN mkdir cmake-build
Expand All @@ -43,8 +44,8 @@ FROM build-base AS valijson-build

ARG VALIJASON_VERSION

ADD https://api.github.com/repos/AriliaWireless/valijson/git/refs/tags/${VALIJASON_VERSION} version.json
RUN git clone https://github.com/AriliaWireless/valijson --branch ${VALIJASON_VERSION} /valijson
ADD https://api.github.com/repos/Telecominfraproject/wlan-cloud-lib-valijson/git/refs/tags/${VALIJASON_VERSION} version.json
RUN git clone https://github.com/Telecominfraproject/wlan-cloud-lib-valijson --branch ${VALIJASON_VERSION} /valijson

WORKDIR /valijson
RUN mkdir cmake-build
Expand Down
2 changes: 1 addition & 1 deletion build
Original file line number Diff line number Diff line change
@@ -1 +1 @@
10
23
29 changes: 29 additions & 0 deletions openapi/owprov.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,17 @@ components:
type: string
minLength: 2
maxLength: 2
imported:
type: integer
format: int64
connected:
type: integer
format: int64
platform:
type: string
enum:
- AP
- SWITCH

VenueDeviceList:
type: object
Expand Down Expand Up @@ -3240,6 +3251,15 @@ paths:
schema:
type: boolean
required: false
- in: query
name: deviceType
schema:
type: string
enum:
- AP
- SWITCH
required: false
default: AP
requestBody:
description: Information used to create the new entity
content:
Expand Down Expand Up @@ -3268,6 +3288,15 @@ paths:
format: uuid
example: When modifying the root entity, the uuid 0000-0000-0000 must be entered.
required: true
- in: query
name: deviceType
schema:
type: string
enum:
- AP
- SWITCH
required: false
default: AP
requestBody:
description: Information used to modify the new entity
content:
Expand Down
94 changes: 60 additions & 34 deletions src/APConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,48 +79,74 @@ namespace OpenWifi {
return false;
}

void APConfig::ReplaceNestedVariables(const std::string uuid, Poco::JSON::Object &Result) {
/*
Helper method contains code previously in ReplaceVariablesinObject.
Once the top-level variable is resolved, this will be called to resolve any
variables nested within the top-level variable.
*/
ProvObjects::VariableBlock VB;
if (StorageService()->VariablesDB().GetRecord("id", uuid, VB)) {
for (const auto &var: VB.variables) {
Poco::JSON::Parser P;
auto VariableBlockInfo =
P.parse(var.value).extract<Poco::JSON::Object::Ptr>();
auto VarNames = VariableBlockInfo->getNames();
for (const auto &j: VarNames) {
if(VariableBlockInfo->isArray(j)) {
auto Elements = VariableBlockInfo->getArray(j);
if(Elements->size()>0) {
Poco::JSON::Array InnerArray;
ReplaceVariablesInArray(*Elements, InnerArray);
Result.set(j, InnerArray);
} else {
// std::cout << "Empty Array!!!" << std::endl;
}
} else if(VariableBlockInfo->isObject(j)) {
Poco::JSON::Object InnerEval;
auto O = VariableBlockInfo->getObject(j);
ReplaceVariablesInObject(*O,InnerEval);
Result.set(j, InnerEval);
} else {
Result.set(j, VariableBlockInfo->get(j));
}
}
}
}
}

bool APConfig::ReplaceVariablesInObject(const Poco::JSON::Object &Original,
Poco::JSON::Object &Result) {
// get all the names and expand
auto Names = Original.getNames();
for (const auto &i : Names) {
if (i == "__variableBlock") {
if (Original.isArray(i)) {
/*
E.g. of what the variable block would look like in an array:
"ssids": [
{
"__variableBlock": [
"79c083d2-d496-4de0-8600-76a63556851b"
]
}
]
*/
auto UUIDs = Original.getArray(i);
for (const auto &uuid: *UUIDs) {
ProvObjects::VariableBlock VB;
if (StorageService()->VariablesDB().GetRecord("id", uuid, VB)) {
for (const auto &var: VB.variables) {
Poco::JSON::Parser P;
auto VariableBlockInfo =
P.parse(var.value).extract<Poco::JSON::Object::Ptr>();
auto VarNames = VariableBlockInfo->getNames();
for (const auto &j: VarNames) {
// std::cout << "Name: " << j << std::endl;
if(VariableBlockInfo->isArray(j)) {
auto Elements = VariableBlockInfo->getArray(j);
if(Elements->size()>0) {
Poco::JSON::Array InnerArray;
ReplaceVariablesInArray(*Elements, InnerArray);
Result.set(j, InnerArray);
// std::cout << "Array!!!" << std::endl;
} else {
// std::cout << "Empty Array!!!" << std::endl;
}
} else if(VariableBlockInfo->isObject(j)) {
Poco::JSON::Object InnerEval;
// std::cout << "Visiting object " << j << std::endl;
auto O = VariableBlockInfo->getObject(j);
ReplaceVariablesInObject(*O,InnerEval);
Result.set(j, InnerEval);
} else {
Result.set(j, VariableBlockInfo->get(j));
}
}
}
}
}
for (const std::string &uuid: *UUIDs) {
ReplaceNestedVariables(uuid, Result);
}
}
else {
/*
E.g. of what the variable block would look like replacing an entire json blob:
"services" : {
"__variableBlock": "ef8db4c0-f0ef-40d2-b676-c9c02ef39430"
}
*/
const std::string uuid = Original.get(i);
ReplaceNestedVariables(uuid, Result);
}
} else if (i == "__radiusEndpoint") {
auto EndPointId = Original.get(i).toString();
ProvObjects::RADIUSEndPoint RE;
Expand Down Expand Up @@ -434,4 +460,4 @@ namespace OpenWifi {
} else {
}
}
} // namespace OpenWifi
} // namespace OpenWifi
1 change: 1 addition & 0 deletions src/APConfig.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ namespace OpenWifi {

bool ReplaceVariablesInArray(const Poco::JSON::Array &O,
Poco::JSON::Array &Result);
void ReplaceNestedVariables(const std::string uuid, Poco::JSON::Object &Result);
bool ReplaceVariablesInObject(const Poco::JSON::Object &Original,
Poco::JSON::Object &Result);

Expand Down
6 changes: 5 additions & 1 deletion src/AutoDiscovery.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ namespace OpenWifi {
FW = P->get(uCentralProtocol::FIRMWARE).toString();
if (P->has(uCentralProtocol::SERIALNUMBER))
SN = P->get(uCentralProtocol::SERIALNUMBER).toString();
else if (P->has(uCentralProtocol::SERIAL))
SN = P->get(uCentralProtocol::SERIAL).toString();
if (P->has("locale")) {
locale = P->get("locale").toString();
}
Expand Down Expand Up @@ -83,6 +85,7 @@ namespace OpenWifi {
Poco::JSON::Parser Parser;
auto Object = Parser.parse(Msg->Payload()).extract<Poco::JSON::Object::Ptr>();
bool Connected=true;
bool isConnection=false;

if (Object->has(uCentralProtocol::PAYLOAD)) {
auto PayloadObj = Object->getObject(uCentralProtocol::PAYLOAD);
Expand All @@ -91,6 +94,7 @@ namespace OpenWifi {
auto PingObj = PayloadObj->getObject("ping");
ProcessPing(PingObj, Firmware, SerialNumber, Compatible, ConnectedIP, Locale);
} else if(PayloadObj->has("capabilities")) {
isConnection=true;
ProcessConnect(PayloadObj, Firmware, SerialNumber, Compatible, ConnectedIP, Locale);
} else if(PayloadObj->has("disconnection")) {
// we ignore disconnection in provisioning
Expand All @@ -102,7 +106,7 @@ namespace OpenWifi {

if (!SerialNumber.empty() && Connected) {
StorageService()->InventoryDB().CreateFromConnection(
SerialNumber, ConnectedIP, Compatible, Locale);
SerialNumber, ConnectedIP, Compatible, Locale, isConnection);
}
}
} catch (const Poco::Exception &E) {
Expand Down
Loading
Loading