Skip to content

Commit

Permalink
Merge pull request #100 from Telecominfraproject/main
Browse files Browse the repository at this point in the history
WIFI-13542 Release merge
  • Loading branch information
jaspreetsachdev authored Mar 22, 2024
2 parents ce04f1c + 4b07db9 commit 0224d22
Show file tree
Hide file tree
Showing 28 changed files with 5,182 additions and 418 deletions.
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

0 comments on commit 0224d22

Please sign in to comment.