mirror of
				https://github.com/Telecominfraproject/wlan-cloud-owprov.git
				synced 2025-11-03 20:17:54 +00:00 
			
		
		
		
	Compare commits
	
		
			4 Commits
		
	
	
		
			release/v3
			...
			v3.0.0
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 
						 | 
					ce04f1c9b3 | ||
| 
						 | 
					a9c4cdf0b7 | ||
| 
						 | 
					c34c10b637 | ||
| 
						 | 
					e930cc5b59 | 
							
								
								
									
										28
									
								
								BUILDING.md
									
									
									
									
									
								
							
							
						
						
									
										28
									
								
								BUILDING.md
									
									
									
									
									
								
							@@ -1,5 +1,5 @@
 | 
				
			|||||||
# Building from source
 | 
					# Building from source
 | 
				
			||||||
In order to build OWPROV, you will need to install its dependencies, which includes the following:
 | 
					In order to build the OWPROV, you will need to install its dependencies, which includes the following:
 | 
				
			||||||
- cmake
 | 
					- cmake
 | 
				
			||||||
- boost
 | 
					- boost
 | 
				
			||||||
- POCO 1.10.1 or later
 | 
					- POCO 1.10.1 or later
 | 
				
			||||||
@@ -12,7 +12,7 @@ In order to build OWPROV, you will need to install its dependencies, which inclu
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
The build is done in 2 parts. The first part is to build a local copy of the framework tailored to your environment. This
 | 
					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
 | 
					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/Telecominfraproject/wlan-cloud-lib-poco). Building
 | 
					from the master copy needed for cmake. Please use the version of this [Poco fix](https://github.com/AriliaWireless/poco). Building
 | 
				
			||||||
Poco may take several minutes depending on the platform you are building on.
 | 
					Poco may take several minutes depending on the platform you are building on.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Ubuntu
 | 
					## Ubuntu
 | 
				
			||||||
@@ -24,7 +24,7 @@ sudo apt install librdkafka-dev // default-libmysqlclient-dev
 | 
				
			|||||||
sudo apt install nlohmann-json-dev
 | 
					sudo apt install nlohmann-json-dev
 | 
				
			||||||
 | 
					
 | 
				
			||||||
cd ~
 | 
					cd ~
 | 
				
			||||||
git clone https://github.com/Telecominfraproject/wlan-cloud-lib-poco --branch poco-tip-v1 poco
 | 
					git clone https://github.com/AriliaWireless/poco --branch poco-tip-v1
 | 
				
			||||||
cd poco
 | 
					cd poco
 | 
				
			||||||
mkdir cmake-build
 | 
					mkdir cmake-build
 | 
				
			||||||
cd cmake-build
 | 
					cd cmake-build
 | 
				
			||||||
@@ -33,7 +33,7 @@ cmake --build . --config Release
 | 
				
			|||||||
sudo cmake --build . --target install
 | 
					sudo cmake --build . --target install
 | 
				
			||||||
 | 
					
 | 
				
			||||||
cd ~
 | 
					cd ~
 | 
				
			||||||
git clone https://github.com/Telecominfraproject/wlan-cloud-lib-cppkafka --branch tip-v1 cppkafka
 | 
					git clone https://github.com/AriliaWireless/cppkafka --branch tip-v1
 | 
				
			||||||
cd cppkafka
 | 
					cd cppkafka
 | 
				
			||||||
mkdir cmake-build
 | 
					mkdir cmake-build
 | 
				
			||||||
cd cmake-build
 | 
					cd cmake-build
 | 
				
			||||||
@@ -42,7 +42,7 @@ cmake --build . --config Release
 | 
				
			|||||||
sudo cmake --build . --target install
 | 
					sudo cmake --build . --target install
 | 
				
			||||||
 | 
					
 | 
				
			||||||
cd ~
 | 
					cd ~
 | 
				
			||||||
git clone https://github.com/Telecominfraproject/wlan-cloud-lib-valijson --branch tip-v1 valijson
 | 
					git clone https://github.com/AriliaWireless/valijson --branch tip-v1
 | 
				
			||||||
cd valijson
 | 
					cd valijson
 | 
				
			||||||
mkdir cmake-build
 | 
					mkdir cmake-build
 | 
				
			||||||
cd cmake-build
 | 
					cd cmake-build
 | 
				
			||||||
@@ -50,8 +50,7 @@ cmake ..
 | 
				
			|||||||
cmake --build . --config Release
 | 
					cmake --build . --config Release
 | 
				
			||||||
sudo cmake --build . --target install
 | 
					sudo cmake --build . --target install
 | 
				
			||||||
 | 
					
 | 
				
			||||||
cd ~
 | 
					git clone https://github.com/fmtlib/fmt --branch 9.0.0 /fmtlib
 | 
				
			||||||
git clone https://github.com/fmtlib/fmt --branch 9.0.0 fmtlib
 | 
					 | 
				
			||||||
cd fmtlib
 | 
					cd fmtlib
 | 
				
			||||||
mkdir cmake-build
 | 
					mkdir cmake-build
 | 
				
			||||||
cd cmake-build
 | 
					cd cmake-build
 | 
				
			||||||
@@ -76,7 +75,7 @@ sudo yum install yaml-cpp-devel lua-devel
 | 
				
			|||||||
sudo dnf install postgresql.x86_64 librdkafka-devel
 | 
					sudo dnf install postgresql.x86_64 librdkafka-devel
 | 
				
			||||||
sudo dnf install postgresql-devel json-devel
 | 
					sudo dnf install postgresql-devel json-devel
 | 
				
			||||||
 | 
					
 | 
				
			||||||
git clone https://github.com/Telecominfraproject/wlan-cloud-lib-poco --branch poco-tip-v1 poco
 | 
					git clone https://github.com/AriliaWireless/poco --branch poco-tip-v1
 | 
				
			||||||
cd poco
 | 
					cd poco
 | 
				
			||||||
mkdir cmake-build
 | 
					mkdir cmake-build
 | 
				
			||||||
cd cmake-build
 | 
					cd cmake-build
 | 
				
			||||||
@@ -84,8 +83,7 @@ cmake ..
 | 
				
			|||||||
cmake --build . --config Release
 | 
					cmake --build . --config Release
 | 
				
			||||||
sudo cmake --build . --target install
 | 
					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
 | 
					cd cppkafka
 | 
				
			||||||
mkdir cmake-build
 | 
					mkdir cmake-build
 | 
				
			||||||
cd cmake-build
 | 
					cd cmake-build
 | 
				
			||||||
@@ -94,7 +92,7 @@ cmake --build . --config Release
 | 
				
			|||||||
sudo cmake --build . --target install
 | 
					sudo cmake --build . --target install
 | 
				
			||||||
 | 
					
 | 
				
			||||||
cd ~
 | 
					cd ~
 | 
				
			||||||
git clone https://github.com/Telecominfraproject/wlan-cloud-lib-valijson --branch tip-v1 valijson
 | 
					git clone https://github.com/AriliaWireless/valijson --branch tip-v1
 | 
				
			||||||
cd valijson
 | 
					cd valijson
 | 
				
			||||||
mkdir cmake-build
 | 
					mkdir cmake-build
 | 
				
			||||||
cd cmake-build
 | 
					cd cmake-build
 | 
				
			||||||
@@ -127,7 +125,7 @@ brew install openssl \
 | 
				
			|||||||
	nlohmann-json \
 | 
						nlohmann-json \
 | 
				
			||||||
	fmt
 | 
						fmt
 | 
				
			||||||
 | 
					
 | 
				
			||||||
git clone https://github.com/Telecominfraproject/wlan-cloud-lib-poco --branch poco-tip-v1 poco
 | 
					git clone https://github.com/AriliaWireless/poco --branch poco-tip-v1
 | 
				
			||||||
pushd poco
 | 
					pushd poco
 | 
				
			||||||
mkdir cmake-build
 | 
					mkdir cmake-build
 | 
				
			||||||
push cmake-build
 | 
					push cmake-build
 | 
				
			||||||
@@ -137,7 +135,7 @@ sudo cmake --build . --target install
 | 
				
			|||||||
popd
 | 
					popd
 | 
				
			||||||
popd
 | 
					popd
 | 
				
			||||||
 | 
					
 | 
				
			||||||
git clone https://github.com/Telecominfraproject/wlan-cloud-lib-cppkafka --branch tip-v1 cppkafka
 | 
					git clone https://github.com/AriliaWireless/cppkafka --branch tip-v1
 | 
				
			||||||
pushd cppkafka
 | 
					pushd cppkafka
 | 
				
			||||||
mkdir cmake-build
 | 
					mkdir cmake-build
 | 
				
			||||||
pushd cmake-build
 | 
					pushd cmake-build
 | 
				
			||||||
@@ -147,7 +145,7 @@ sudo cmake --build . --target install
 | 
				
			|||||||
popd
 | 
					popd
 | 
				
			||||||
popd
 | 
					popd
 | 
				
			||||||
 | 
					
 | 
				
			||||||
git clone https://github.com/Telecominfraproject/wlan-cloud-lib-valijson --branch tip-v1 valijson
 | 
					git clone https://github.com/AriliaWireless/valijson --branch tip-v1
 | 
				
			||||||
cd valijson
 | 
					cd valijson
 | 
				
			||||||
mkdir cmake-build
 | 
					mkdir cmake-build
 | 
				
			||||||
cd cmake-build
 | 
					cd cmake-build
 | 
				
			||||||
@@ -174,8 +172,6 @@ adding -DSMALL_BUILD=1 on the cmake build line.
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
```bash
 | 
					```bash
 | 
				
			||||||
sudo apt install git cmake g++ libssl-dev libaprutil1-dev apache2-dev libboost-all-dev libyaml-cpp-dev
 | 
					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
 | 
					git clone https://github.com/stephb9959/poco
 | 
				
			||||||
cd poco
 | 
					cd poco
 | 
				
			||||||
mkdir cmake-build
 | 
					mkdir cmake-build
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,5 @@
 | 
				
			|||||||
cmake_minimum_required(VERSION 3.13)
 | 
					cmake_minimum_required(VERSION 3.13)
 | 
				
			||||||
project(owprov VERSION 3.2.1)
 | 
					project(owprov VERSION 3.0.0)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
set(CMAKE_CXX_STANDARD 17)
 | 
					set(CMAKE_CXX_STANDARD 17)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										13
									
								
								Dockerfile
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								Dockerfile
									
									
									
									
									
								
							@@ -15,9 +15,8 @@ FROM build-base AS poco-build
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
ARG POCO_VERSION
 | 
					ARG POCO_VERSION
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ADD https://api.github.com/repos/Telecominfraproject/wlan-cloud-lib-poco/git/refs/tags/${POCO_VERSION} version.json
 | 
					ADD https://api.github.com/repos/AriliaWireless/poco/git/refs/tags/${POCO_VERSION} version.json
 | 
				
			||||||
RUN git clone https://github.com/Telecominfraproject/wlan-cloud-lib-poco --branch ${POCO_VERSION} /poco
 | 
					RUN git clone https://github.com/AriliaWireless/poco --branch ${POCO_VERSION} /poco
 | 
				
			||||||
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
WORKDIR /poco
 | 
					WORKDIR /poco
 | 
				
			||||||
RUN mkdir cmake-build
 | 
					RUN mkdir cmake-build
 | 
				
			||||||
@@ -30,8 +29,8 @@ FROM build-base AS cppkafka-build
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
ARG CPPKAFKA_VERSION
 | 
					ARG CPPKAFKA_VERSION
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ADD https://api.github.com/repos/Telecominfraproject/wlan-cloud-lib-cppkafka/git/refs/tags/${CPPKAFKA_VERSION} version.json
 | 
					ADD https://api.github.com/repos/AriliaWireless/cppkafka/git/refs/tags/${CPPKAFKA_VERSION} version.json
 | 
				
			||||||
RUN git clone https://github.com/Telecominfraproject/wlan-cloud-lib-cppkafka --branch ${CPPKAFKA_VERSION} /cppkafka
 | 
					RUN git clone https://github.com/AriliaWireless/cppkafka --branch ${CPPKAFKA_VERSION} /cppkafka
 | 
				
			||||||
 | 
					
 | 
				
			||||||
WORKDIR /cppkafka
 | 
					WORKDIR /cppkafka
 | 
				
			||||||
RUN mkdir cmake-build
 | 
					RUN mkdir cmake-build
 | 
				
			||||||
@@ -44,8 +43,8 @@ FROM build-base AS valijson-build
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
ARG VALIJASON_VERSION
 | 
					ARG VALIJASON_VERSION
 | 
				
			||||||
 | 
					
 | 
				
			||||||
ADD https://api.github.com/repos/Telecominfraproject/wlan-cloud-lib-valijson/git/refs/tags/${VALIJASON_VERSION} version.json
 | 
					ADD https://api.github.com/repos/AriliaWireless/valijson/git/refs/tags/${VALIJASON_VERSION} version.json
 | 
				
			||||||
RUN git clone https://github.com/Telecominfraproject/wlan-cloud-lib-valijson --branch ${VALIJASON_VERSION} /valijson
 | 
					RUN git clone https://github.com/AriliaWireless/valijson --branch ${VALIJASON_VERSION} /valijson
 | 
				
			||||||
 | 
					
 | 
				
			||||||
WORKDIR /valijson
 | 
					WORKDIR /valijson
 | 
				
			||||||
RUN mkdir cmake-build
 | 
					RUN mkdir cmake-build
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -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: v3.2.1
 | 
					    tag: v3.0.0
 | 
				
			||||||
    pullPolicy: Always
 | 
					    pullPolicy: Always
 | 
				
			||||||
#    regcred:
 | 
					#    regcred:
 | 
				
			||||||
#      registry: tip-tip-wlan-cloud-ucentral.jfrog.io
 | 
					#      registry: tip-tip-wlan-cloud-ucentral.jfrog.io
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -815,17 +815,6 @@ components:
 | 
				
			|||||||
          type: string
 | 
					          type: string
 | 
				
			||||||
          minLength: 2
 | 
					          minLength: 2
 | 
				
			||||||
          maxLength: 2
 | 
					          maxLength: 2
 | 
				
			||||||
        imported:
 | 
					 | 
				
			||||||
          type: integer
 | 
					 | 
				
			||||||
          format: int64
 | 
					 | 
				
			||||||
        connected:
 | 
					 | 
				
			||||||
          type: integer
 | 
					 | 
				
			||||||
          format: int64
 | 
					 | 
				
			||||||
        platform:
 | 
					 | 
				
			||||||
          type: string
 | 
					 | 
				
			||||||
          enum:
 | 
					 | 
				
			||||||
            - AP
 | 
					 | 
				
			||||||
            - SWITCH
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    VenueDeviceList:
 | 
					    VenueDeviceList:
 | 
				
			||||||
      type: object
 | 
					      type: object
 | 
				
			||||||
@@ -3251,15 +3240,6 @@ paths:
 | 
				
			|||||||
          schema:
 | 
					          schema:
 | 
				
			||||||
            type: boolean
 | 
					            type: boolean
 | 
				
			||||||
          required: false
 | 
					          required: false
 | 
				
			||||||
        - in: query
 | 
					 | 
				
			||||||
          name: deviceType
 | 
					 | 
				
			||||||
          schema:
 | 
					 | 
				
			||||||
            type: string
 | 
					 | 
				
			||||||
            enum:
 | 
					 | 
				
			||||||
              - AP
 | 
					 | 
				
			||||||
              - SWITCH
 | 
					 | 
				
			||||||
          required: false
 | 
					 | 
				
			||||||
          default: AP
 | 
					 | 
				
			||||||
      requestBody:
 | 
					      requestBody:
 | 
				
			||||||
        description: Information used to create the new entity
 | 
					        description: Information used to create the new entity
 | 
				
			||||||
        content:
 | 
					        content:
 | 
				
			||||||
@@ -3288,15 +3268,6 @@ paths:
 | 
				
			|||||||
            format: uuid
 | 
					            format: uuid
 | 
				
			||||||
            example: When modifying the root entity, the uuid 0000-0000-0000 must be entered.
 | 
					            example: When modifying the root entity, the uuid 0000-0000-0000 must be entered.
 | 
				
			||||||
          required: true
 | 
					          required: true
 | 
				
			||||||
        - in: query
 | 
					 | 
				
			||||||
          name: deviceType
 | 
					 | 
				
			||||||
          schema:
 | 
					 | 
				
			||||||
            type: string
 | 
					 | 
				
			||||||
            enum:
 | 
					 | 
				
			||||||
              - AP
 | 
					 | 
				
			||||||
              - SWITCH
 | 
					 | 
				
			||||||
          required: false
 | 
					 | 
				
			||||||
          default: AP
 | 
					 | 
				
			||||||
      requestBody:
 | 
					      requestBody:
 | 
				
			||||||
        description: Information used to modify the new entity
 | 
					        description: Information used to modify the new entity
 | 
				
			||||||
        content:
 | 
					        content:
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -79,12 +79,15 @@ namespace OpenWifi {
 | 
				
			|||||||
        return false;
 | 
					        return false;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void APConfig::ReplaceNestedVariables(const std::string uuid, Poco::JSON::Object &Result) {
 | 
					    bool APConfig::ReplaceVariablesInObject(const Poco::JSON::Object &Original,
 | 
				
			||||||
		/*
 | 
																Poco::JSON::Object &Result) {
 | 
				
			||||||
		Helper method contains code previously in ReplaceVariablesinObject.
 | 
							// get all the names and expand
 | 
				
			||||||
		Once the top-level variable is resolved, this will be called to resolve any
 | 
							auto Names = Original.getNames();
 | 
				
			||||||
		variables nested within the top-level variable.
 | 
							for (const auto &i : Names) {
 | 
				
			||||||
		*/
 | 
					            if (i == "__variableBlock") {
 | 
				
			||||||
 | 
					                if (Original.isArray(i)) {
 | 
				
			||||||
 | 
					                    auto UUIDs = Original.getArray(i);
 | 
				
			||||||
 | 
					                    for (const auto &uuid: *UUIDs) {
 | 
				
			||||||
                        ProvObjects::VariableBlock VB;
 | 
					                        ProvObjects::VariableBlock VB;
 | 
				
			||||||
                        if (StorageService()->VariablesDB().GetRecord("id", uuid, VB)) {
 | 
					                        if (StorageService()->VariablesDB().GetRecord("id", uuid, VB)) {
 | 
				
			||||||
                            for (const auto &var: VB.variables) {
 | 
					                            for (const auto &var: VB.variables) {
 | 
				
			||||||
@@ -93,17 +96,20 @@ namespace OpenWifi {
 | 
				
			|||||||
                                        P.parse(var.value).extract<Poco::JSON::Object::Ptr>();
 | 
					                                        P.parse(var.value).extract<Poco::JSON::Object::Ptr>();
 | 
				
			||||||
                                auto VarNames = VariableBlockInfo->getNames();
 | 
					                                auto VarNames = VariableBlockInfo->getNames();
 | 
				
			||||||
                                for (const auto &j: VarNames) {
 | 
					                                for (const auto &j: VarNames) {
 | 
				
			||||||
 | 
					//                                    std::cout << "Name: " << j << std::endl;
 | 
				
			||||||
                                    if(VariableBlockInfo->isArray(j)) {
 | 
					                                    if(VariableBlockInfo->isArray(j)) {
 | 
				
			||||||
                                        auto Elements = VariableBlockInfo->getArray(j);
 | 
					                                        auto Elements = VariableBlockInfo->getArray(j);
 | 
				
			||||||
                                        if(Elements->size()>0) {
 | 
					                                        if(Elements->size()>0) {
 | 
				
			||||||
                                            Poco::JSON::Array InnerArray;
 | 
					                                            Poco::JSON::Array InnerArray;
 | 
				
			||||||
                                            ReplaceVariablesInArray(*Elements, InnerArray);
 | 
					                                            ReplaceVariablesInArray(*Elements, InnerArray);
 | 
				
			||||||
                                            Result.set(j, InnerArray);
 | 
					                                            Result.set(j, InnerArray);
 | 
				
			||||||
 | 
					//                                            std::cout << "Array!!!" << std::endl;
 | 
				
			||||||
                                        } else {
 | 
					                                        } else {
 | 
				
			||||||
//                                            std::cout << "Empty Array!!!" << std::endl;
 | 
					//                                            std::cout << "Empty Array!!!" << std::endl;
 | 
				
			||||||
                                        }
 | 
					                                        }
 | 
				
			||||||
                                    } else if(VariableBlockInfo->isObject(j)) {
 | 
					                                    } else if(VariableBlockInfo->isObject(j)) {
 | 
				
			||||||
                                        Poco::JSON::Object  InnerEval;
 | 
					                                        Poco::JSON::Object  InnerEval;
 | 
				
			||||||
 | 
					//                                        std::cout << "Visiting object " << j << std::endl;
 | 
				
			||||||
                                        auto O = VariableBlockInfo->getObject(j);
 | 
					                                        auto O = VariableBlockInfo->getObject(j);
 | 
				
			||||||
                                        ReplaceVariablesInObject(*O,InnerEval);
 | 
					                                        ReplaceVariablesInObject(*O,InnerEval);
 | 
				
			||||||
                                        Result.set(j, InnerEval);
 | 
					                                        Result.set(j, InnerEval);
 | 
				
			||||||
@@ -114,38 +120,6 @@ namespace OpenWifi {
 | 
				
			|||||||
                            }
 | 
					                            }
 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
 | 
					 | 
				
			||||||
    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 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") {
 | 
					            } else if (i == "__radiusEndpoint") {
 | 
				
			||||||
                auto EndPointId = Original.get(i).toString();
 | 
					                auto EndPointId = Original.get(i).toString();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -47,7 +47,6 @@ namespace OpenWifi {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
		bool ReplaceVariablesInArray(const Poco::JSON::Array &O,
 | 
							bool ReplaceVariablesInArray(const Poco::JSON::Array &O,
 | 
				
			||||||
									 Poco::JSON::Array &Result);
 | 
														 Poco::JSON::Array &Result);
 | 
				
			||||||
		void ReplaceNestedVariables(const std::string uuid, Poco::JSON::Object &Result);
 | 
					 | 
				
			||||||
		bool ReplaceVariablesInObject(const Poco::JSON::Object &Original,
 | 
							bool ReplaceVariablesInObject(const Poco::JSON::Object &Original,
 | 
				
			||||||
									  Poco::JSON::Object &Result);
 | 
														  Poco::JSON::Object &Result);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -5,7 +5,6 @@
 | 
				
			|||||||
#include "AutoDiscovery.h"
 | 
					#include "AutoDiscovery.h"
 | 
				
			||||||
#include "Poco/JSON/Parser.h"
 | 
					#include "Poco/JSON/Parser.h"
 | 
				
			||||||
#include "StorageService.h"
 | 
					#include "StorageService.h"
 | 
				
			||||||
#include "Tasks/VenueConfigUpdater.h"
 | 
					 | 
				
			||||||
#include "framework/KafkaManager.h"
 | 
					#include "framework/KafkaManager.h"
 | 
				
			||||||
#include "framework/KafkaTopics.h"
 | 
					#include "framework/KafkaTopics.h"
 | 
				
			||||||
#include "framework/ow_constants.h"
 | 
					#include "framework/ow_constants.h"
 | 
				
			||||||
@@ -55,8 +54,6 @@ namespace OpenWifi {
 | 
				
			|||||||
            FW = P->get(uCentralProtocol::FIRMWARE).toString();
 | 
					            FW = P->get(uCentralProtocol::FIRMWARE).toString();
 | 
				
			||||||
        if (P->has(uCentralProtocol::SERIALNUMBER))
 | 
					        if (P->has(uCentralProtocol::SERIALNUMBER))
 | 
				
			||||||
            SN = P->get(uCentralProtocol::SERIALNUMBER).toString();
 | 
					            SN = P->get(uCentralProtocol::SERIALNUMBER).toString();
 | 
				
			||||||
        else if (P->has(uCentralProtocol::SERIAL))
 | 
					 | 
				
			||||||
            SN = P->get(uCentralProtocol::SERIAL).toString();
 | 
					 | 
				
			||||||
        if (P->has("locale")) {
 | 
					        if (P->has("locale")) {
 | 
				
			||||||
            locale = P->get("locale").toString();
 | 
					            locale = P->get("locale").toString();
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
@@ -86,7 +83,6 @@ namespace OpenWifi {
 | 
				
			|||||||
					Poco::JSON::Parser Parser;
 | 
										Poco::JSON::Parser Parser;
 | 
				
			||||||
					auto Object = Parser.parse(Msg->Payload()).extract<Poco::JSON::Object::Ptr>();
 | 
										auto Object = Parser.parse(Msg->Payload()).extract<Poco::JSON::Object::Ptr>();
 | 
				
			||||||
                    bool    Connected=true;
 | 
					                    bool    Connected=true;
 | 
				
			||||||
                    bool isConnection=false;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
					if (Object->has(uCentralProtocol::PAYLOAD)) {
 | 
										if (Object->has(uCentralProtocol::PAYLOAD)) {
 | 
				
			||||||
                        auto PayloadObj = Object->getObject(uCentralProtocol::PAYLOAD);
 | 
					                        auto PayloadObj = Object->getObject(uCentralProtocol::PAYLOAD);
 | 
				
			||||||
@@ -95,7 +91,6 @@ namespace OpenWifi {
 | 
				
			|||||||
                            auto PingObj = PayloadObj->getObject("ping");
 | 
					                            auto PingObj = PayloadObj->getObject("ping");
 | 
				
			||||||
                            ProcessPing(PingObj, Firmware, SerialNumber, Compatible, ConnectedIP, Locale);
 | 
					                            ProcessPing(PingObj, Firmware, SerialNumber, Compatible, ConnectedIP, Locale);
 | 
				
			||||||
                        } else if(PayloadObj->has("capabilities")) {
 | 
					                        } else if(PayloadObj->has("capabilities")) {
 | 
				
			||||||
                            isConnection=true;
 | 
					 | 
				
			||||||
                            ProcessConnect(PayloadObj, Firmware, SerialNumber, Compatible, ConnectedIP, Locale);
 | 
					                            ProcessConnect(PayloadObj, Firmware, SerialNumber, Compatible, ConnectedIP, Locale);
 | 
				
			||||||
                        } else if(PayloadObj->has("disconnection")) {
 | 
					                        } else if(PayloadObj->has("disconnection")) {
 | 
				
			||||||
                            //  we ignore disconnection in provisioning
 | 
					                            //  we ignore disconnection in provisioning
 | 
				
			||||||
@@ -107,12 +102,7 @@ namespace OpenWifi {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
                        if (!SerialNumber.empty() && Connected) {
 | 
					                        if (!SerialNumber.empty() && Connected) {
 | 
				
			||||||
                            StorageService()->InventoryDB().CreateFromConnection(
 | 
					                            StorageService()->InventoryDB().CreateFromConnection(
 | 
				
			||||||
                                    SerialNumber, ConnectedIP, Compatible, Locale, isConnection);
 | 
					                                    SerialNumber, ConnectedIP, Compatible, Locale);
 | 
				
			||||||
                            // Now that the entry has been created, we can try to push a config if
 | 
					 | 
				
			||||||
                            // the connection was a capabilities message.
 | 
					 | 
				
			||||||
                            if (isConnection){
 | 
					 | 
				
			||||||
                                ComputeAndPushConfig(SerialNumber, Compatible, Logger());
 | 
					 | 
				
			||||||
                            }
 | 
					 | 
				
			||||||
                        }
 | 
					                        }
 | 
				
			||||||
                    }
 | 
					                    }
 | 
				
			||||||
				} catch (const Poco::Exception &E) {
 | 
									} catch (const Poco::Exception &E) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -91,10 +91,9 @@ namespace OpenWifi {
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
			auto Config = RawObject->get("configuration").toString();
 | 
								auto Config = RawObject->get("configuration").toString();
 | 
				
			||||||
			Poco::JSON::Object Answer;
 | 
								Poco::JSON::Object Answer;
 | 
				
			||||||
            auto deviceType = GetParameter("deviceType", "AP");
 | 
								std::vector<std::string> Error;
 | 
				
			||||||
            std::string Error;
 | 
					 | 
				
			||||||
			auto Res =
 | 
								auto Res =
 | 
				
			||||||
				ValidateUCentralConfiguration(ConfigurationValidator::GetType(deviceType),Config, Error, GetBoolParameter("strict", true));
 | 
									ValidateUCentralConfiguration(Config, Error, GetBoolParameter("strict", true));
 | 
				
			||||||
			Answer.set("valid", Res);
 | 
								Answer.set("valid", Res);
 | 
				
			||||||
			Answer.set("error", Error);
 | 
								Answer.set("error", Error);
 | 
				
			||||||
			return ReturnObject(Answer);
 | 
								return ReturnObject(Answer);
 | 
				
			||||||
@@ -135,27 +134,11 @@ namespace OpenWifi {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		std::vector<std::string> Errors;
 | 
							std::vector<std::string> Errors;
 | 
				
			||||||
        auto deviceType = GetParameter("deviceType", "AP");
 | 
							if (!ValidateConfigBlock(NewObject, Errors)) {
 | 
				
			||||||
        if (!ValidateConfigBlock(ConfigurationValidator::GetType(deviceType), NewObject, Errors)) {
 | 
					 | 
				
			||||||
			return BadRequest(RESTAPI::Errors::ConfigBlockInvalid);
 | 
								return BadRequest(RESTAPI::Errors::ConfigBlockInvalid);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		Types::UUIDvec_t ToVariables;
 | 
					 | 
				
			||||||
		if (RawObject->has("variables")) {
 | 
					 | 
				
			||||||
			for (const auto &i : NewObject.variables) {
 | 
					 | 
				
			||||||
				if (!i.empty() && !StorageService()->VariablesDB().Exists("id", i)) {
 | 
					 | 
				
			||||||
					return BadRequest(RESTAPI::Errors::VariableMustExist);
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			for (const auto &i : NewObject.variables)
 | 
					 | 
				
			||||||
				ToVariables.emplace_back(i);
 | 
					 | 
				
			||||||
			
 | 
					 | 
				
			||||||
			ToVariables = NewObject.variables;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		if (DB_.CreateRecord(NewObject)) {
 | 
							if (DB_.CreateRecord(NewObject)) {
 | 
				
			||||||
			AddMembership(StorageService()->VariablesDB(),
 | 
					 | 
				
			||||||
							 &ProvObjects::VariableBlock::configurations, ToVariables, NewObject.info.id);
 | 
					 | 
				
			||||||
			MoveUsage(StorageService()->PolicyDB(), DB_, "", NewObject.managementPolicy,
 | 
								MoveUsage(StorageService()->PolicyDB(), DB_, "", NewObject.managementPolicy,
 | 
				
			||||||
					  NewObject.info.id);
 | 
										  NewObject.info.id);
 | 
				
			||||||
			AddMembership(StorageService()->VenueDB(), &ProvObjects::Venue::configurations,
 | 
								AddMembership(StorageService()->VenueDB(), &ProvObjects::Venue::configurations,
 | 
				
			||||||
@@ -202,8 +185,7 @@ namespace OpenWifi {
 | 
				
			|||||||
			Existing.deviceTypes = NewObject.deviceTypes;
 | 
								Existing.deviceTypes = NewObject.deviceTypes;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		std::vector<std::string> Errors;
 | 
							std::vector<std::string> Errors;
 | 
				
			||||||
        auto deviceType = GetParameter("deviceType", "AP");
 | 
							if (!ValidateConfigBlock(NewObject, Errors)) {
 | 
				
			||||||
        if (!ValidateConfigBlock(ConfigurationValidator::GetType(deviceType), NewObject, Errors)) {
 | 
					 | 
				
			||||||
			return BadRequest(RESTAPI::Errors::ConfigBlockInvalid);
 | 
								return BadRequest(RESTAPI::Errors::ConfigBlockInvalid);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -389,13 +389,6 @@ namespace OpenWifi {
 | 
				
			|||||||
			DB.ManipulateVectorMember(T, "id", Obj, Id, true);
 | 
								DB.ManipulateVectorMember(T, "id", Obj, Id, true);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	template <typename db_type, typename Member>
 | 
					 | 
				
			||||||
	void AddMembership(db_type &DB, Member T, const Types::UUIDvec_t &Obj, const std::string &Id) {
 | 
					 | 
				
			||||||
		for (const auto &i : Obj) {
 | 
					 | 
				
			||||||
			AddMembership(DB, T, i, Id);
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	template <typename db_type, typename Member>
 | 
						template <typename db_type, typename Member>
 | 
				
			||||||
	void ManageMembership(db_type &DB, Member T, const std::string &From, const std::string &To,
 | 
						void ManageMembership(db_type &DB, Member T, const std::string &From, const std::string &To,
 | 
				
			||||||
						  const std::string &Id) {
 | 
											  const std::string &Id) {
 | 
				
			||||||
@@ -438,7 +431,7 @@ namespace OpenWifi {
 | 
				
			|||||||
		return EntityDB::RootUUID();
 | 
							return EntityDB::RootUUID();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    inline bool ValidateConfigBlock(ConfigurationValidator::ConfigurationType Type, const ProvObjects::DeviceConfiguration &Config,
 | 
						inline bool ValidateConfigBlock(const ProvObjects::DeviceConfiguration &Config,
 | 
				
			||||||
									std::vector<std::string> &Errors) {
 | 
														std::vector<std::string> &Errors) {
 | 
				
			||||||
		static const std::vector<std::string> SectionNames{
 | 
							static const std::vector<std::string> SectionNames{
 | 
				
			||||||
			"globals",	   "interfaces", "metrics", "radios",	  "services",	"unit",
 | 
								"globals",	   "interfaces", "metrics", "radios",	  "services",	"unit",
 | 
				
			||||||
@@ -467,11 +460,9 @@ namespace OpenWifi {
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			try {
 | 
								try {
 | 
				
			||||||
                std::string Error;
 | 
									if (ValidateUCentralConfiguration(i.configuration, Errors, true)) {
 | 
				
			||||||
                if (ValidateUCentralConfiguration(Type,i.configuration, Error, true)) {
 | 
					 | 
				
			||||||
					// std::cout << "Block: " << i.name << " is valid" << std::endl;
 | 
										// std::cout << "Block: " << i.name << " is valid" << std::endl;
 | 
				
			||||||
				} else {
 | 
									} else {
 | 
				
			||||||
                    Errors.push_back(Error);
 | 
					 | 
				
			||||||
					return false;
 | 
										return false;
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
			} catch (...) {
 | 
								} catch (...) {
 | 
				
			||||||
@@ -544,7 +535,7 @@ namespace OpenWifi {
 | 
				
			|||||||
						ProvObjects::DeviceConfiguration DC;
 | 
											ProvObjects::DeviceConfiguration DC;
 | 
				
			||||||
						if (DC.from_json(ConfigurationDetails)) {
 | 
											if (DC.from_json(ConfigurationDetails)) {
 | 
				
			||||||
							if constexpr (std::is_same_v<Type, ProvObjects::InventoryTag>) {
 | 
												if constexpr (std::is_same_v<Type, ProvObjects::InventoryTag>) {
 | 
				
			||||||
								if (!ValidateConfigBlock(ConfigurationValidator::ConfigurationType::AP,DC, Errors)) {
 | 
													if (!ValidateConfigBlock(DC, Errors)) {
 | 
				
			||||||
									break;
 | 
														break;
 | 
				
			||||||
								}
 | 
													}
 | 
				
			||||||
								ProvObjects::CreateObjectInfo(R.UserInfo_.userinfo, DC.info);
 | 
													ProvObjects::CreateObjectInfo(R.UserInfo_.userinfo, DC.info);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -14,13 +14,28 @@
 | 
				
			|||||||
#include "RESTAPI/RESTAPI_db_helpers.h"
 | 
					#include "RESTAPI/RESTAPI_db_helpers.h"
 | 
				
			||||||
#include "SerialNumberCache.h"
 | 
					#include "SerialNumberCache.h"
 | 
				
			||||||
#include "StorageService.h"
 | 
					#include "StorageService.h"
 | 
				
			||||||
#include "Tasks/VenueConfigUpdater.h"
 | 
					 | 
				
			||||||
#include "framework/utils.h"
 | 
					#include "framework/utils.h"
 | 
				
			||||||
#include "sdks/SDK_gw.h"
 | 
					#include "sdks/SDK_gw.h"
 | 
				
			||||||
#include "sdks/SDK_sec.h"
 | 
					#include "sdks/SDK_sec.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace OpenWifi {
 | 
					namespace OpenWifi {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						void GetRejectedLines(const Poco::JSON::Object::Ptr &Response, Types::StringVec &Warnings) {
 | 
				
			||||||
 | 
							try {
 | 
				
			||||||
 | 
								if (Response->has("results")) {
 | 
				
			||||||
 | 
									auto Results = Response->get("results").extract<Poco::JSON::Object::Ptr>();
 | 
				
			||||||
 | 
									auto Status = Results->get("status").extract<Poco::JSON::Object::Ptr>();
 | 
				
			||||||
 | 
									auto Rejected = Status->getArray("rejected");
 | 
				
			||||||
 | 
									std::transform(
 | 
				
			||||||
 | 
										Rejected->begin(), Rejected->end(), std::back_inserter(Warnings),
 | 
				
			||||||
 | 
										[](auto i) -> auto { return i.toString(); });
 | 
				
			||||||
 | 
									//                for(const auto &i:*Rejected)
 | 
				
			||||||
 | 
									//                  Warnings.push_back(i.toString());
 | 
				
			||||||
 | 
								}
 | 
				
			||||||
 | 
							} catch (...) {
 | 
				
			||||||
 | 
							}
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void RESTAPI_inventory_handler::DoGet() {
 | 
						void RESTAPI_inventory_handler::DoGet() {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		ProvObjects::InventoryTag Existing;
 | 
							ProvObjects::InventoryTag Existing;
 | 
				
			||||||
@@ -299,8 +314,6 @@ namespace OpenWifi {
 | 
				
			|||||||
			return NotFound();
 | 
								return NotFound();
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		std::string previous_venue = Existing.venue;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		auto RemoveSubscriber = GetParameter("removeSubscriber");
 | 
							auto RemoveSubscriber = GetParameter("removeSubscriber");
 | 
				
			||||||
		if (!RemoveSubscriber.empty()) {
 | 
							if (!RemoveSubscriber.empty()) {
 | 
				
			||||||
			if (Existing.subscriber == RemoveSubscriber) {
 | 
								if (Existing.subscriber == RemoveSubscriber) {
 | 
				
			||||||
@@ -458,13 +471,6 @@ namespace OpenWifi {
 | 
				
			|||||||
			SDK::GW::Device::SetOwnerShip(this, SerialNumber, Existing.entity, Existing.venue,
 | 
								SDK::GW::Device::SetOwnerShip(this, SerialNumber, Existing.entity, Existing.venue,
 | 
				
			||||||
										  Existing.subscriber);
 | 
															  Existing.subscriber);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			// Attempt an automatic config push when the venue is set and different than what is
 | 
					 | 
				
			||||||
			// in DB.
 | 
					 | 
				
			||||||
			poco_information(Logger(), fmt::format("New Venue {} Old Venue {}", NewObject.venue, previous_venue));
 | 
					 | 
				
			||||||
			if (!NewObject.venue.empty() && NewObject.venue != previous_venue) {
 | 
					 | 
				
			||||||
				ComputeAndPushConfig(SerialNumber, NewObject.deviceType, Logger());
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			ProvObjects::InventoryTag NewObjectCreated;
 | 
								ProvObjects::InventoryTag NewObjectCreated;
 | 
				
			||||||
			DB_.GetRecord("id", Existing.info.id, NewObjectCreated);
 | 
								DB_.GetRecord("id", Existing.info.id, NewObjectCreated);
 | 
				
			||||||
			Poco::JSON::Object Answer;
 | 
								Poco::JSON::Object Answer;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -131,9 +131,7 @@ namespace OpenWifi {
 | 
				
			|||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			ProvObjects::InventoryTagVec Tags;
 | 
								ProvObjects::InventoryTagVec Tags;
 | 
				
			||||||
			DB_.GetRecords(QB_.Offset, QB_.Limit, Tags, "", OrderBy);
 | 
								DB_.GetRecords(QB_.Offset, QB_.Limit, Tags, "", OrderBy);
 | 
				
			||||||
            return SendList(Tags, SerialOnly);
 | 
								return MakeJSONObjectArray("taglist", Tags, *this);
 | 
				
			||||||
 | 
					 | 
				
			||||||
//			return MakeJSONObjectArray("taglist", Tags, *this);
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
} // namespace OpenWifi
 | 
					} // namespace OpenWifi
 | 
				
			||||||
@@ -187,7 +187,7 @@ namespace OpenWifi {
 | 
				
			|||||||
			}
 | 
								}
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		if (!NewObject.sourceIP.empty() && !CIDR::ValidateIpRanges(NewObject.sourceIP)) {
 | 
							if (!NewObject.sourceIP.empty() && CIDR::ValidateIpRanges(NewObject.sourceIP)) {
 | 
				
			||||||
			return BadRequest(RESTAPI::Errors::InvalidIPRanges);
 | 
								return BadRequest(RESTAPI::Errors::InvalidIPRanges);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -587,9 +587,6 @@ namespace OpenWifi::ProvObjects {
 | 
				
			|||||||
		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);
 | 
							field_to_json(Obj, "doNotAllowOverrides", doNotAllowOverrides);
 | 
				
			||||||
        field_to_json(Obj, "imported", imported);
 | 
					 | 
				
			||||||
        field_to_json(Obj, "connected", connected);
 | 
					 | 
				
			||||||
        field_to_json(Obj, "platform", platform);
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	bool InventoryTag::from_json(const Poco::JSON::Object::Ptr &Obj) {
 | 
						bool InventoryTag::from_json(const Poco::JSON::Object::Ptr &Obj) {
 | 
				
			||||||
@@ -612,9 +609,6 @@ namespace OpenWifi::ProvObjects {
 | 
				
			|||||||
			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);
 | 
								field_from_json(Obj, "doNotAllowOverrides", doNotAllowOverrides);
 | 
				
			||||||
            field_from_json(Obj, "imported", imported);
 | 
					 | 
				
			||||||
            field_from_json(Obj, "connected", connected);
 | 
					 | 
				
			||||||
            field_from_json(Obj, "platform", platform);
 | 
					 | 
				
			||||||
			return true;
 | 
								return true;
 | 
				
			||||||
		} catch (...) {
 | 
							} catch (...) {
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -490,11 +490,9 @@ namespace OpenWifi::ProvObjects {
 | 
				
			|||||||
        std::string locale;
 | 
					        std::string locale;
 | 
				
			||||||
        std::string realMacAddress;
 | 
					        std::string realMacAddress;
 | 
				
			||||||
        bool doNotAllowOverrides = false;
 | 
					        bool doNotAllowOverrides = false;
 | 
				
			||||||
        std::uint64_t imported=0;
 | 
					 | 
				
			||||||
        std::uint64_t connected=0;
 | 
					 | 
				
			||||||
        std::string platform{"AP"};
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
        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);
 | 
				
			||||||
    };
 | 
					    };
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -28,42 +28,6 @@ namespace OpenWifi {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	[[maybe_unused]] static void ComputeAndPushConfig(const std::string &SerialNumber, const std::string &DeviceType, Poco::Logger &Logger) {
 | 
					 | 
				
			||||||
		/*
 | 
					 | 
				
			||||||
		Generic Helper to compute a device's config and push it down to the device.
 | 
					 | 
				
			||||||
		*/
 | 
					 | 
				
			||||||
		poco_information(Logger, fmt::format("Attempting to push venue config for device {}", SerialNumber));
 | 
					 | 
				
			||||||
		auto DeviceConfig = std::make_shared<APConfig>(SerialNumber,
 | 
					 | 
				
			||||||
														DeviceType, Logger, false);
 | 
					 | 
				
			||||||
		auto Configuration = Poco::makeShared<Poco::JSON::Object>();
 | 
					 | 
				
			||||||
		try {
 | 
					 | 
				
			||||||
			if (DeviceConfig->Get(Configuration)) {
 | 
					 | 
				
			||||||
				std::ostringstream OS;
 | 
					 | 
				
			||||||
				Configuration->stringify(OS);
 | 
					 | 
				
			||||||
				auto Response = Poco::makeShared<Poco::JSON::Object>();
 | 
					 | 
				
			||||||
				poco_debug(Logger,
 | 
					 | 
				
			||||||
							fmt::format("{}: Pushing configuration.", SerialNumber));
 | 
					 | 
				
			||||||
				if (SDK::GW::Device::Configure(nullptr, SerialNumber, Configuration,
 | 
					 | 
				
			||||||
												Response)) {
 | 
					 | 
				
			||||||
					Logger.debug(
 | 
					 | 
				
			||||||
						fmt::format("{}: Configuration pushed.", SerialNumber));
 | 
					 | 
				
			||||||
					poco_information(Logger,
 | 
					 | 
				
			||||||
										fmt::format("{}: Updated.", SerialNumber));
 | 
					 | 
				
			||||||
				} else {
 | 
					 | 
				
			||||||
					poco_information(Logger,
 | 
					 | 
				
			||||||
										fmt::format("{}: Not updated.", SerialNumber));
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			} else {
 | 
					 | 
				
			||||||
				poco_debug(Logger,
 | 
					 | 
				
			||||||
							fmt::format("{}: Configuration is bad.", SerialNumber));
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
		} catch (...) {
 | 
					 | 
				
			||||||
			poco_debug(Logger,
 | 
					 | 
				
			||||||
						fmt::format("{}: Configuration is bad (caused an exception).",
 | 
					 | 
				
			||||||
									SerialNumber));
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	class VenueDeviceConfigUpdater : public Poco::Runnable {
 | 
						class VenueDeviceConfigUpdater : public Poco::Runnable {
 | 
				
			||||||
	  public:
 | 
						  public:
 | 
				
			||||||
		VenueDeviceConfigUpdater(const std::string &UUID, const std::string &venue, Poco::Logger &L)
 | 
							VenueDeviceConfigUpdater(const std::string &UUID, const std::string &venue, Poco::Logger &L)
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -67,9 +67,9 @@ namespace OpenWifi {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        bool Get(const char *key, std::vector<std::string> &Value) {
 | 
					        bool Get(const char *key, std::vector<std::string> &Value) {
 | 
				
			||||||
            if(Registry_->has(key) && !Registry_->isNull(key) && Registry_->isArray(key)) {
 | 
					            if(Registry_->has(key) && !Registry_->isNull(key) && Registry_->isArray(key)) {
 | 
				
			||||||
                auto pArr = Registry_->getArray(key);
 | 
					                auto Arr = Registry_->get(key);
 | 
				
			||||||
                for(const auto &v : *pArr) {
 | 
					                for(const auto &v:Arr) {
 | 
				
			||||||
                    Value.emplace_back(v.toString());
 | 
					                    Value.emplace_back(v);
 | 
				
			||||||
                }
 | 
					                }
 | 
				
			||||||
                return true;
 | 
					                return true;
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
 
 | 
				
			|||||||
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -17,42 +17,33 @@
 | 
				
			|||||||
namespace OpenWifi {
 | 
					namespace OpenWifi {
 | 
				
			||||||
	class ConfigurationValidator : public SubSystemServer {
 | 
						class ConfigurationValidator : public SubSystemServer {
 | 
				
			||||||
	  public:
 | 
						  public:
 | 
				
			||||||
 | 
					 | 
				
			||||||
		enum class ConfigurationType { AP = 0 , SWITCH = 1};
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		static auto instance() {
 | 
							static auto instance() {
 | 
				
			||||||
			static auto instance_ = new ConfigurationValidator;
 | 
								static auto instance_ = new ConfigurationValidator;
 | 
				
			||||||
			return instance_;
 | 
								return instance_;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		bool Validate(ConfigurationType Type, const std::string &C, std::string &Errors, bool Strict);
 | 
							bool Validate(const std::string &C, std::vector<std::string> &Errors, bool Strict);
 | 
				
			||||||
		int Start() override;
 | 
							int Start() override;
 | 
				
			||||||
		void Stop() override;
 | 
							void Stop() override;
 | 
				
			||||||
		void reinitialize(Poco::Util::Application &self) override;
 | 
							void reinitialize(Poco::Util::Application &self) override;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		inline static ConfigurationType GetType(const std::string &type) {
 | 
					 | 
				
			||||||
			std::string Type = Poco::toUpper(type);
 | 
					 | 
				
			||||||
			if (Type == "AP")
 | 
					 | 
				
			||||||
				return ConfigurationType::AP;
 | 
					 | 
				
			||||||
			if (Type == "SWITCH")
 | 
					 | 
				
			||||||
				return ConfigurationType::SWITCH;
 | 
					 | 
				
			||||||
			return ConfigurationType::AP;
 | 
					 | 
				
			||||||
		}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	  private:
 | 
						  private:
 | 
				
			||||||
		bool Initialized_ = false;
 | 
							bool Initialized_ = false;
 | 
				
			||||||
		bool Working_ = false;
 | 
							bool Working_ = false;
 | 
				
			||||||
		void Init();
 | 
							void Init();
 | 
				
			||||||
		std::array<valijson::Schema,2> 			RootSchema_;
 | 
							std::unique_ptr<valijson::Schema> RootSchema_;
 | 
				
			||||||
		bool SetSchema(ConfigurationType Type, const std::string &SchemaStr);
 | 
							std::unique_ptr<valijson::SchemaParser> SchemaParser_;
 | 
				
			||||||
 | 
							std::unique_ptr<valijson::adapters::PocoJsonAdapter> PocoJsonAdapter_;
 | 
				
			||||||
 | 
							Poco::JSON::Object::Ptr SchemaDocPtr_;
 | 
				
			||||||
 | 
							bool SetSchema(const std::string &SchemaStr);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		ConfigurationValidator()
 | 
							ConfigurationValidator()
 | 
				
			||||||
			: SubSystemServer("ConfigValidator", "CFG-VALIDATOR", "config.validator") {}
 | 
								: SubSystemServer("ConfigValidator", "CFG-VALIDATOR", "config.validator") {}
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	inline auto ConfigurationValidator() { return ConfigurationValidator::instance(); }
 | 
						inline auto ConfigurationValidator() { return ConfigurationValidator::instance(); }
 | 
				
			||||||
	inline bool ValidateUCentralConfiguration(ConfigurationValidator::ConfigurationType Type, const std::string &C, std::string &Errors,
 | 
						inline bool ValidateUCentralConfiguration(const std::string &C, std::vector<std::string> &Error,
 | 
				
			||||||
											  bool strict) {
 | 
																  bool strict) {
 | 
				
			||||||
		return ConfigurationValidator::instance()->Validate(Type, C, Errors, strict);
 | 
							return ConfigurationValidator::instance()->Validate(C, Error, strict);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
} // namespace OpenWifi
 | 
					} // namespace OpenWifi
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -16,9 +16,9 @@ namespace OpenWifi {
 | 
				
			|||||||
		KafkaManager()->PostMessage(KafkaTopics::SERVICE_EVENTS, MicroServicePrivateEndPoint(), Msg,
 | 
							KafkaManager()->PostMessage(KafkaTopics::SERVICE_EVENTS, MicroServicePrivateEndPoint(), Msg,
 | 
				
			||||||
									false);
 | 
														false);
 | 
				
			||||||
		while (Running_) {
 | 
							while (Running_) {
 | 
				
			||||||
			if(!Poco::Thread::trySleep((unsigned long)MicroServiceDaemonBusTimer())) {
 | 
								Poco::Thread::trySleep((unsigned long)MicroServiceDaemonBusTimer());
 | 
				
			||||||
 | 
								if (!Running_)
 | 
				
			||||||
				break;
 | 
									break;
 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
			Msg = (MicroServiceMakeSystemEventMessage(KafkaTopics::ServiceEvents::EVENT_KEEP_ALIVE));
 | 
								Msg = (MicroServiceMakeSystemEventMessage(KafkaTopics::ServiceEvents::EVENT_KEEP_ALIVE));
 | 
				
			||||||
			KafkaManager()->PostMessage(KafkaTopics::SERVICE_EVENTS, MicroServicePrivateEndPoint(),
 | 
								KafkaManager()->PostMessage(KafkaTopics::SERVICE_EVENTS, MicroServicePrivateEndPoint(),
 | 
				
			||||||
										Msg, false);
 | 
															Msg, false);
 | 
				
			||||||
@@ -29,7 +29,7 @@ namespace OpenWifi {
 | 
				
			|||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void EventBusManager::Start() {
 | 
						void EventBusManager::Start() {
 | 
				
			||||||
		poco_information(Logger_, "Starting...");
 | 
							poco_information(Logger(), "Starting...");
 | 
				
			||||||
		if (KafkaManager()->Enabled()) {
 | 
							if (KafkaManager()->Enabled()) {
 | 
				
			||||||
			Thread_.start(*this);
 | 
								Thread_.start(*this);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
@@ -37,11 +37,11 @@ namespace OpenWifi {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	void EventBusManager::Stop() {
 | 
						void EventBusManager::Stop() {
 | 
				
			||||||
		if (KafkaManager()->Enabled()) {
 | 
							if (KafkaManager()->Enabled()) {
 | 
				
			||||||
			poco_information(Logger_, "Stopping...");
 | 
								poco_information(Logger(), "Stopping...");
 | 
				
			||||||
			Running_ = false;
 | 
								Running_ = false;
 | 
				
			||||||
			Thread_.wakeUp();
 | 
								Thread_.wakeUp();
 | 
				
			||||||
			Thread_.join();
 | 
								Thread_.join();
 | 
				
			||||||
			poco_information(Logger_, "Stopped...");
 | 
								poco_information(Logger(), "Stopped...");
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -22,6 +22,7 @@ namespace OpenWifi {
 | 
				
			|||||||
			return instance_;
 | 
								return instance_;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							explicit EventBusManager(Poco::Logger &L);
 | 
				
			||||||
		void run() final;
 | 
							void run() final;
 | 
				
			||||||
		void Start();
 | 
							void Start();
 | 
				
			||||||
		void Stop();
 | 
							void Stop();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -79,10 +79,8 @@ namespace OpenWifi {
 | 
				
			|||||||
		Utils::SetThreadName("Kafka:Prod");
 | 
							Utils::SetThreadName("Kafka:Prod");
 | 
				
			||||||
		cppkafka::Configuration Config(
 | 
							cppkafka::Configuration Config(
 | 
				
			||||||
			{{"client.id", MicroServiceConfigGetString("openwifi.kafka.client.id", "")},
 | 
								{{"client.id", MicroServiceConfigGetString("openwifi.kafka.client.id", "")},
 | 
				
			||||||
			 {"metadata.broker.list",MicroServiceConfigGetString("openwifi.kafka.brokerlist", "")} // ,
 | 
								 {"metadata.broker.list",
 | 
				
			||||||
			 // {"send.buffer.bytes", KafkaManager()->KafkaManagerMaximumPayloadSize() }
 | 
								  MicroServiceConfigGetString("openwifi.kafka.brokerlist", "")}});
 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
 		);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		AddKafkaSecurity(Config);
 | 
							AddKafkaSecurity(Config);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -107,17 +105,8 @@ namespace OpenWifi {
 | 
				
			|||||||
					NewMessage.partition(0);
 | 
										NewMessage.partition(0);
 | 
				
			||||||
					NewMessage.payload(Msg->Payload());
 | 
										NewMessage.payload(Msg->Payload());
 | 
				
			||||||
					Producer.produce(NewMessage);
 | 
										Producer.produce(NewMessage);
 | 
				
			||||||
					if (Queue_.size() < 100) {
 | 
					 | 
				
			||||||
						// use flush when internal queue is lightly loaded, i.e. flush after each
 | 
					 | 
				
			||||||
						// message
 | 
					 | 
				
			||||||
					Producer.flush();
 | 
										Producer.flush();
 | 
				
			||||||
				}
 | 
									}
 | 
				
			||||||
					else {
 | 
					 | 
				
			||||||
						// use poll when internal queue is loaded to allow messages to be sent in
 | 
					 | 
				
			||||||
						// batches
 | 
					 | 
				
			||||||
						Producer.poll((std::chrono::milliseconds) 0);
 | 
					 | 
				
			||||||
					}
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			} catch (const cppkafka::HandleException &E) {
 | 
								} catch (const cppkafka::HandleException &E) {
 | 
				
			||||||
				poco_warning(Logger_,
 | 
									poco_warning(Logger_,
 | 
				
			||||||
							 fmt::format("Caught a Kafka exception (producer): {}", E.what()));
 | 
												 fmt::format("Caught a Kafka exception (producer): {}", E.what()));
 | 
				
			||||||
@@ -126,13 +115,8 @@ namespace OpenWifi {
 | 
				
			|||||||
			} catch (...) {
 | 
								} catch (...) {
 | 
				
			||||||
				poco_error(Logger_, "std::exception");
 | 
									poco_error(Logger_, "std::exception");
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
			if (Queue_.size() == 0) {
 | 
					 | 
				
			||||||
				// message queue is empty, flush all previously sent messages
 | 
					 | 
				
			||||||
				Producer.flush();
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
			Note = Queue_.waitDequeueNotification();
 | 
								Note = Queue_.waitDequeueNotification();
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		Producer.flush();
 | 
					 | 
				
			||||||
		poco_information(Logger_, "Stopped...");
 | 
							poco_information(Logger_, "Stopped...");
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -291,7 +275,6 @@ namespace OpenWifi {
 | 
				
			|||||||
	int KafkaManager::Start() {
 | 
						int KafkaManager::Start() {
 | 
				
			||||||
		if (!KafkaEnabled_)
 | 
							if (!KafkaEnabled_)
 | 
				
			||||||
			return 0;
 | 
								return 0;
 | 
				
			||||||
		MaxPayloadSize_ = MicroServiceConfigGetInt("openwifi.kafka.max.payload", 250000);
 | 
					 | 
				
			||||||
		ConsumerThr_.Start();
 | 
							ConsumerThr_.Start();
 | 
				
			||||||
		ProducerThr_.Start();
 | 
							ProducerThr_.Start();
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -94,14 +94,11 @@ namespace OpenWifi {
 | 
				
			|||||||
			return ConsumerThr_.UnregisterTopicWatcher(Topic,Id);
 | 
								return ConsumerThr_.UnregisterTopicWatcher(Topic,Id);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		std::uint64_t KafkaManagerMaximumPayloadSize() const { return MaxPayloadSize_; }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	  private:
 | 
						  private:
 | 
				
			||||||
		bool KafkaEnabled_ = false;
 | 
							bool KafkaEnabled_ = false;
 | 
				
			||||||
		std::string SystemInfoWrapper_;
 | 
							std::string SystemInfoWrapper_;
 | 
				
			||||||
		KafkaProducer ProducerThr_;
 | 
							KafkaProducer ProducerThr_;
 | 
				
			||||||
		KafkaConsumer ConsumerThr_;
 | 
							KafkaConsumer ConsumerThr_;
 | 
				
			||||||
		std::uint64_t MaxPayloadSize_ = 250000;
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		void PartitionAssignment(const cppkafka::TopicPartitionList &partitions);
 | 
							void PartitionAssignment(const cppkafka::TopicPartitionList &partitions);
 | 
				
			||||||
		void PartitionRevocation(const cppkafka::TopicPartitionList &partitions);
 | 
							void PartitionRevocation(const cppkafka::TopicPartitionList &partitions);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -1,5 +1,4 @@
 | 
				
			|||||||
//
 | 
					//
 | 
				
			||||||
//
 | 
					 | 
				
			||||||
// Created by stephane bourque on 2022-10-26.
 | 
					// Created by stephane bourque on 2022-10-26.
 | 
				
			||||||
//
 | 
					//
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -30,12 +29,10 @@
 | 
				
			|||||||
#include "framework/WebSocketLogger.h"
 | 
					#include "framework/WebSocketLogger.h"
 | 
				
			||||||
#include "framework/utils.h"
 | 
					#include "framework/utils.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef  USE_MEDUSA_CLIENT
 | 
					 | 
				
			||||||
#include <medusa/MedusaClient.h>
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
namespace OpenWifi {
 | 
					namespace OpenWifi {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						void MicroService::Exit(int Reason) { std::exit(Reason); }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    static std::string MakeServiceListString(const Types::MicroServiceMetaMap &Services) {
 | 
					    static std::string MakeServiceListString(const Types::MicroServiceMetaMap &Services) {
 | 
				
			||||||
        std::string SvcList;
 | 
					        std::string SvcList;
 | 
				
			||||||
        for (const auto &Svc : Services) {
 | 
					        for (const auto &Svc : Services) {
 | 
				
			||||||
@@ -207,11 +204,9 @@ namespace OpenWifi {
 | 
				
			|||||||
			Res.push_back(ServiceRec);
 | 
								Res.push_back(ServiceRec);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		return Res;
 | 
							return Res;
 | 
				
			||||||
 | 
					 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	void MicroService::LoadConfigurationFile() {
 | 
						void MicroService::LoadConfigurationFile() {
 | 
				
			||||||
        if(ConfigContent_.empty()) {
 | 
					 | 
				
			||||||
		std::string Location = Poco::Environment::get(DAEMON_CONFIG_ENV_VAR, ".");
 | 
							std::string Location = Poco::Environment::get(DAEMON_CONFIG_ENV_VAR, ".");
 | 
				
			||||||
		ConfigFileName_ =
 | 
							ConfigFileName_ =
 | 
				
			||||||
			ConfigFileName_.empty() ? Location + "/" + DAEMON_PROPERTIES_FILENAME : ConfigFileName_;
 | 
								ConfigFileName_.empty() ? Location + "/" + DAEMON_PROPERTIES_FILENAME : ConfigFileName_;
 | 
				
			||||||
@@ -225,11 +220,9 @@ namespace OpenWifi {
 | 
				
			|||||||
					  << std::endl;
 | 
										  << std::endl;
 | 
				
			||||||
			std::exit(Poco::Util::Application::EXIT_CONFIG);
 | 
								std::exit(Poco::Util::Application::EXIT_CONFIG);
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
							// 	    loadConfiguration(ConfigFile.toString());
 | 
				
			||||||
		PropConfigurationFile_ = new Poco::Util::PropertyFileConfiguration(ConfigFile.toString());
 | 
							PropConfigurationFile_ = new Poco::Util::PropertyFileConfiguration(ConfigFile.toString());
 | 
				
			||||||
        } else {
 | 
					 | 
				
			||||||
            std::istringstream is(ConfigContent_);
 | 
					 | 
				
			||||||
            PropConfigurationFile_ = new Poco::Util::PropertyFileConfiguration(is);
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
		configPtr()->addWriteable(PropConfigurationFile_, PRIO_DEFAULT);
 | 
							configPtr()->addWriteable(PropConfigurationFile_, PRIO_DEFAULT);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -432,13 +425,11 @@ namespace OpenWifi {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	void DaemonPostInitialization(Poco::Util::Application &self);
 | 
						void DaemonPostInitialization(Poco::Util::Application &self);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void MicroService::StartEverything(Poco::Util::Application &self) {
 | 
						void MicroService::initialize(Poco::Util::Application &self) {
 | 
				
			||||||
 | 
							// add the default services
 | 
				
			||||||
		LoadConfigurationFile();
 | 
							LoadConfigurationFile();
 | 
				
			||||||
		InitializeLoggingSystem();
 | 
							InitializeLoggingSystem();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        static bool InitializedBaseService=false;
 | 
					 | 
				
			||||||
        if(!InitializedBaseService) {
 | 
					 | 
				
			||||||
            InitializedBaseService = true;
 | 
					 | 
				
			||||||
		SubSystems_.push_back(KafkaManager());
 | 
							SubSystems_.push_back(KafkaManager());
 | 
				
			||||||
		SubSystems_.push_back(ALBHealthCheckServer());
 | 
							SubSystems_.push_back(ALBHealthCheckServer());
 | 
				
			||||||
		SubSystems_.push_back(RESTAPI_ExtServer());
 | 
							SubSystems_.push_back(RESTAPI_ExtServer());
 | 
				
			||||||
@@ -446,13 +437,11 @@ namespace OpenWifi {
 | 
				
			|||||||
#ifndef TIP_SECURITY_SERVICE
 | 
					#ifndef TIP_SECURITY_SERVICE
 | 
				
			||||||
		SubSystems_.push_back(AuthClient());
 | 
							SubSystems_.push_back(AuthClient());
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					 | 
				
			||||||
		Poco::Net::initializeSSL();
 | 
							Poco::Net::initializeSSL();
 | 
				
			||||||
		Poco::Net::HTTPStreamFactory::registerFactory();
 | 
							Poco::Net::HTTPStreamFactory::registerFactory();
 | 
				
			||||||
		Poco::Net::HTTPSStreamFactory::registerFactory();
 | 
							Poco::Net::HTTPSStreamFactory::registerFactory();
 | 
				
			||||||
		Poco::Net::FTPStreamFactory::registerFactory();
 | 
							Poco::Net::FTPStreamFactory::registerFactory();
 | 
				
			||||||
		Poco::Net::FTPSStreamFactory::registerFactory();
 | 
							Poco::Net::FTPSStreamFactory::registerFactory();
 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		Poco::File DataDir(ConfigPath("openwifi.system.data"));
 | 
							Poco::File DataDir(ConfigPath("openwifi.system.data"));
 | 
				
			||||||
		DataDir_ = DataDir.path();
 | 
							DataDir_ = DataDir.path();
 | 
				
			||||||
@@ -481,22 +470,6 @@ namespace OpenWifi {
 | 
				
			|||||||
		KafkaManager()->RegisterTopicWatcher(KafkaTopics::SERVICE_EVENTS, F);
 | 
							KafkaManager()->RegisterTopicWatcher(KafkaTopics::SERVICE_EVENTS, F);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    void MicroService::StopEverything([[maybe_unused]] Poco::Util::Application &self) {
 | 
					 | 
				
			||||||
        LoadConfigurationFile();
 | 
					 | 
				
			||||||
        InitializeLoggingSystem();
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        Types::TopicNotifyFunction F = [this](const std::string &Key, const std::string &Payload) {
 | 
					 | 
				
			||||||
            this->BusMessageReceived(Key, Payload);
 | 
					 | 
				
			||||||
        };
 | 
					 | 
				
			||||||
        KafkaManager()->RegisterTopicWatcher(KafkaTopics::SERVICE_EVENTS, F);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    void MicroService::initialize([[maybe_unused]] Poco::Util::Application &self) {
 | 
					 | 
				
			||||||
#ifndef USE_MEDUSA_CLIENT
 | 
					 | 
				
			||||||
        StartEverything(self);
 | 
					 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
	}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	void MicroService::uninitialize() {
 | 
						void MicroService::uninitialize() {
 | 
				
			||||||
		// add your own uninitialization code here
 | 
							// add your own uninitialization code here
 | 
				
			||||||
		ServerApplication::uninitialize();
 | 
							ServerApplication::uninitialize();
 | 
				
			||||||
@@ -780,8 +753,6 @@ namespace OpenWifi {
 | 
				
			|||||||
		MicroServiceErrorHandler ErrorHandler(*this);
 | 
							MicroServiceErrorHandler ErrorHandler(*this);
 | 
				
			||||||
		Poco::ErrorHandler::set(&ErrorHandler);
 | 
							Poco::ErrorHandler::set(&ErrorHandler);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        Args_ = args;
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		if (!HelpRequested_) {
 | 
							if (!HelpRequested_) {
 | 
				
			||||||
			SavePID();
 | 
								SavePID();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -797,18 +768,11 @@ namespace OpenWifi {
 | 
				
			|||||||
				poco_information(logger, "Starting as a daemon.");
 | 
									poco_information(logger, "Starting as a daemon.");
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef USE_MEDUSA_CLIENT
 | 
					 | 
				
			||||||
            MedusaClient::instance()->SetSubSystems(SubSystems_);
 | 
					 | 
				
			||||||
            MedusaClient::instance()->Start();
 | 
					 | 
				
			||||||
			waitForTerminationRequest();
 | 
					 | 
				
			||||||
            MedusaClient::instance()->Stop();
 | 
					 | 
				
			||||||
#else
 | 
					 | 
				
			||||||
			poco_information(logger, fmt::format("System ID set to {}", ID_));
 | 
								poco_information(logger, fmt::format("System ID set to {}", ID_));
 | 
				
			||||||
			StartSubSystemServers();
 | 
								StartSubSystemServers();
 | 
				
			||||||
			waitForTerminationRequest();
 | 
								waitForTerminationRequest();
 | 
				
			||||||
			StopSubSystemServers();
 | 
								StopSubSystemServers();
 | 
				
			||||||
			logger.notice(fmt::format("Stopped {}...", DAEMON_APP_NAME));
 | 
								logger.notice(fmt::format("Stopped {}...", DAEMON_APP_NAME));
 | 
				
			||||||
#endif
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		return Application::EXIT_OK;
 | 
							return Application::EXIT_OK;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -55,6 +55,9 @@ namespace OpenWifi {
 | 
				
			|||||||
#include "nlohmann/json.hpp"
 | 
					#include "nlohmann/json.hpp"
 | 
				
			||||||
#include "ow_version.h"
 | 
					#include "ow_version.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#define _OWDEBUG_ std::cout << __FILE__ << ":" << __LINE__ << std::endl;
 | 
				
			||||||
 | 
					// #define _OWDEBUG_ Logger().debug(Poco::format("%s: %lu",__FILE__,__LINE__));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
namespace OpenWifi {
 | 
					namespace OpenWifi {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	class MicroService : public Poco::Util::ServerApplication {
 | 
						class MicroService : public Poco::Util::ServerApplication {
 | 
				
			||||||
@@ -67,6 +70,7 @@ namespace OpenWifi {
 | 
				
			|||||||
			  SubSystems_(std::move(Subsystems)), Logger_(Poco::Logger::get("FRAMEWORK")) {
 | 
								  SubSystems_(std::move(Subsystems)), Logger_(Poco::Logger::get("FRAMEWORK")) {
 | 
				
			||||||
			instance_ = this;
 | 
								instance_ = this;
 | 
				
			||||||
			RandomEngine_.seed(std::chrono::steady_clock::now().time_since_epoch().count());
 | 
								RandomEngine_.seed(std::chrono::steady_clock::now().time_since_epoch().count());
 | 
				
			||||||
 | 
								// Logger_ = Poco::Logger::root().get("BASE-SVC");
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		inline static const char *ExtraConfigurationFilename = "/configuration_override.json";
 | 
							inline static const char *ExtraConfigurationFilename = "/configuration_override.json";
 | 
				
			||||||
@@ -88,7 +92,7 @@ namespace OpenWifi {
 | 
				
			|||||||
		inline uint64_t DaemonBusTimer() const { return DAEMON_BUS_TIMER; };
 | 
							inline uint64_t DaemonBusTimer() const { return DAEMON_BUS_TIMER; };
 | 
				
			||||||
		[[nodiscard]] const std::string &AppName() { return DAEMON_APP_NAME; }
 | 
							[[nodiscard]] const std::string &AppName() { return DAEMON_APP_NAME; }
 | 
				
			||||||
		static inline uint64_t GetPID() { return Poco::Process::id(); };
 | 
							static inline uint64_t GetPID() { return Poco::Process::id(); };
 | 
				
			||||||
		[[nodiscard]] inline std::string GetPublicAPIEndPoint() const {
 | 
							[[nodiscard]] inline const std::string GetPublicAPIEndPoint() {
 | 
				
			||||||
			return MyPublicEndPoint_ + "/api/v1";
 | 
								return MyPublicEndPoint_ + "/api/v1";
 | 
				
			||||||
		};
 | 
							};
 | 
				
			||||||
		[[nodiscard]] inline const std::string &GetUIURI() const { return UIURI_; };
 | 
							[[nodiscard]] inline const std::string &GetUIURI() const { return UIURI_; };
 | 
				
			||||||
@@ -103,8 +107,7 @@ namespace OpenWifi {
 | 
				
			|||||||
		}
 | 
							}
 | 
				
			||||||
		static MicroService &instance() { return *instance_; }
 | 
							static MicroService &instance() { return *instance_; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		inline void Exit(int Reason) { std::exit(Reason); }
 | 
							inline void Exit(int Reason);
 | 
				
			||||||
 | 
					 | 
				
			||||||
		void BusMessageReceived(const std::string &Key, const std::string &Payload);
 | 
							void BusMessageReceived(const std::string &Key, const std::string &Payload);
 | 
				
			||||||
		Types::MicroServiceMetaVec GetServices(const std::string &Type);
 | 
							Types::MicroServiceMetaVec GetServices(const std::string &Type);
 | 
				
			||||||
		Types::MicroServiceMetaVec GetServices();
 | 
							Types::MicroServiceMetaVec GetServices();
 | 
				
			||||||
@@ -112,8 +115,6 @@ namespace OpenWifi {
 | 
				
			|||||||
		void Reload();
 | 
							void Reload();
 | 
				
			||||||
		void LoadMyConfig();
 | 
							void LoadMyConfig();
 | 
				
			||||||
		void initialize(Poco::Util::Application &self) override;
 | 
							void initialize(Poco::Util::Application &self) override;
 | 
				
			||||||
        void StartEverything(Poco::Util::Application &self);
 | 
					 | 
				
			||||||
        void StopEverything(Poco::Util::Application &self);
 | 
					 | 
				
			||||||
		void uninitialize() override;
 | 
							void uninitialize() override;
 | 
				
			||||||
		void reinitialize(Poco::Util::Application &self) override;
 | 
							void reinitialize(Poco::Util::Application &self) override;
 | 
				
			||||||
		void defineOptions(Poco::Util::OptionSet &options) override;
 | 
							void defineOptions(Poco::Util::OptionSet &options) override;
 | 
				
			||||||
@@ -131,7 +132,7 @@ namespace OpenWifi {
 | 
				
			|||||||
		void Reload(const std::string &Sub);
 | 
							void Reload(const std::string &Sub);
 | 
				
			||||||
		Types::StringVec GetSubSystems() const;
 | 
							Types::StringVec GetSubSystems() const;
 | 
				
			||||||
		Types::StringPairVec GetLogLevels();
 | 
							Types::StringPairVec GetLogLevels();
 | 
				
			||||||
		static const Types::StringVec &GetLogLevelNames();
 | 
							const Types::StringVec &GetLogLevelNames();
 | 
				
			||||||
		uint64_t ConfigGetInt(const std::string &Key, uint64_t Default);
 | 
							uint64_t ConfigGetInt(const std::string &Key, uint64_t Default);
 | 
				
			||||||
		uint64_t ConfigGetInt(const std::string &Key);
 | 
							uint64_t ConfigGetInt(const std::string &Key);
 | 
				
			||||||
		uint64_t ConfigGetBool(const std::string &Key, bool Default);
 | 
							uint64_t ConfigGetBool(const std::string &Key, bool Default);
 | 
				
			||||||
@@ -165,25 +166,12 @@ namespace OpenWifi {
 | 
				
			|||||||
								const std::string &FormatterPattern,
 | 
													const std::string &FormatterPattern,
 | 
				
			||||||
								const std::string &root_env_var);
 | 
													const std::string &root_env_var);
 | 
				
			||||||
		inline bool AllowExternalMicroServices() const { return AllowExternalMicroServices_; }
 | 
							inline bool AllowExternalMicroServices() const { return AllowExternalMicroServices_; }
 | 
				
			||||||
        const ArgVec &Args() const { return Args_; }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        inline void SetConfigContent(const std::string &Content) { ConfigContent_ = Content; }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
        inline std::optional<OpenWifi::Types::MicroServiceMeta> GetPrivateEndPointServiceKey( const std::string & ServicePrivateEndPoint ) {
 | 
					 | 
				
			||||||
            std::lock_guard   G(InfraMutex_);
 | 
					 | 
				
			||||||
            auto K = Services_.find(ServicePrivateEndPoint);
 | 
					 | 
				
			||||||
            if(K==end(Services_)) {
 | 
					 | 
				
			||||||
                return std::nullopt;
 | 
					 | 
				
			||||||
            }
 | 
					 | 
				
			||||||
            return K->second;
 | 
					 | 
				
			||||||
        }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	  private:
 | 
						  private:
 | 
				
			||||||
		static MicroService *instance_;
 | 
							static MicroService *instance_;
 | 
				
			||||||
		bool HelpRequested_ = false;
 | 
							bool HelpRequested_ = false;
 | 
				
			||||||
		std::string LogDir_;
 | 
							std::string LogDir_;
 | 
				
			||||||
		std::string ConfigFileName_;
 | 
							std::string ConfigFileName_;
 | 
				
			||||||
        std::string ConfigContent_;
 | 
					 | 
				
			||||||
		uint64_t ID_ = 1;
 | 
							uint64_t ID_ = 1;
 | 
				
			||||||
		Poco::SharedPtr<Poco::Crypto::RSAKey> AppKey_;
 | 
							Poco::SharedPtr<Poco::Crypto::RSAKey> AppKey_;
 | 
				
			||||||
		bool DebugMode_ = false;
 | 
							bool DebugMode_ = false;
 | 
				
			||||||
@@ -213,7 +201,6 @@ namespace OpenWifi {
 | 
				
			|||||||
		Poco::JWT::Signer Signer_;
 | 
							Poco::JWT::Signer Signer_;
 | 
				
			||||||
		Poco::Logger &Logger_;
 | 
							Poco::Logger &Logger_;
 | 
				
			||||||
		Poco::ThreadPool TimerPool_{"timer:pool", 2, 32};
 | 
							Poco::ThreadPool TimerPool_{"timer:pool", 2, 32};
 | 
				
			||||||
        ArgVec Args_;
 | 
					 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	inline MicroService *MicroService::instance_ = nullptr;
 | 
						inline MicroService *MicroService::instance_ = nullptr;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -133,8 +133,4 @@ namespace OpenWifi {
 | 
				
			|||||||
		return MicroService::instance().Hash();
 | 
							return MicroService::instance().Hash();
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    std::optional<OpenWifi::Types::MicroServiceMeta> MicroServicePrivateAccessKey(const std::string &servicePrivateEndPoint) {
 | 
					 | 
				
			||||||
        return MicroService::instance().GetPrivateEndPointServiceKey(servicePrivateEndPoint);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
} // namespace OpenWifi
 | 
					} // namespace OpenWifi
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -23,8 +23,6 @@ namespace OpenWifi {
 | 
				
			|||||||
	std::string MicroServiceConfigGetString(const std::string &Key,
 | 
						std::string MicroServiceConfigGetString(const std::string &Key,
 | 
				
			||||||
											const std::string &DefaultValue);
 | 
																const std::string &DefaultValue);
 | 
				
			||||||
	std::string MicroServiceAccessKey();
 | 
						std::string MicroServiceAccessKey();
 | 
				
			||||||
    std::optional<OpenWifi::Types::MicroServiceMeta> MicroServicePrivateAccessKey(const std::string &servicePrivateEndPoint);
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
	bool MicroServiceConfigGetBool(const std::string &Key, bool DefaultValue);
 | 
						bool MicroServiceConfigGetBool(const std::string &Key, bool DefaultValue);
 | 
				
			||||||
	std::uint64_t MicroServiceConfigGetInt(const std::string &Key, std::uint64_t DefaultValue);
 | 
						std::uint64_t MicroServiceConfigGetInt(const std::string &Key, std::uint64_t DefaultValue);
 | 
				
			||||||
	std::string MicroServicePrivateEndPoint();
 | 
						std::string MicroServicePrivateEndPoint();
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -58,9 +58,11 @@ namespace OpenWifi {
 | 
				
			|||||||
	void UI_WebSocketClientServer::run() {
 | 
						void UI_WebSocketClientServer::run() {
 | 
				
			||||||
		Running_ = true;
 | 
							Running_ = true;
 | 
				
			||||||
		while (Running_) {
 | 
							while (Running_) {
 | 
				
			||||||
			if(!Poco::Thread::trySleep(2000)) {
 | 
								Poco::Thread::trySleep(2000);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
								if (!Running_)
 | 
				
			||||||
				break;
 | 
									break;
 | 
				
			||||||
            }
 | 
					
 | 
				
			||||||
			std::lock_guard G(LocalMutex_);
 | 
								std::lock_guard G(LocalMutex_);
 | 
				
			||||||
			for (const auto i : ToBeRemoved_) {
 | 
								for (const auto i : ToBeRemoved_) {
 | 
				
			||||||
				// std::cout << "Erasing old WS UI connection..." << std::endl;
 | 
									// std::cout << "Erasing old WS UI connection..." << std::endl;
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -565,7 +565,6 @@ namespace OpenWifi::RESTAPI::Protocol {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	static const char *TRANSFER = "transfer";
 | 
						static const char *TRANSFER = "transfer";
 | 
				
			||||||
	static const char *CERTUPDATE = "certupdate";
 | 
						static const char *CERTUPDATE = "certupdate";
 | 
				
			||||||
	static const char *POWERCYCLE = "powercycle";
 | 
					 | 
				
			||||||
	static const char *RRM = "rrm";
 | 
						static const char *RRM = "rrm";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	static const char *REQUIREMENTS = "requirements";
 | 
						static const char *REQUIREMENTS = "requirements";
 | 
				
			||||||
@@ -688,7 +687,6 @@ namespace OpenWifi::uCentralProtocol {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
	static const char *TRANSFER = "transfer";
 | 
						static const char *TRANSFER = "transfer";
 | 
				
			||||||
	static const char *CERTUPDATE = "certupdate";
 | 
						static const char *CERTUPDATE = "certupdate";
 | 
				
			||||||
	static const char *POWERCYCLE = "powercycle";
 | 
					 | 
				
			||||||
	static const char *RRM = "rrm";
 | 
						static const char *RRM = "rrm";
 | 
				
			||||||
	static const char *ACTIONS = "actions";
 | 
						static const char *ACTIONS = "actions";
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -787,7 +785,6 @@ namespace OpenWifi::APCommands {
 | 
				
			|||||||
		rrm,
 | 
							rrm,
 | 
				
			||||||
		certupdate,
 | 
							certupdate,
 | 
				
			||||||
		transfer,
 | 
							transfer,
 | 
				
			||||||
		powercycle,
 | 
					 | 
				
			||||||
		unknown
 | 
							unknown
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -802,7 +799,7 @@ namespace OpenWifi::APCommands {
 | 
				
			|||||||
		RESTAPI::Protocol::EVENTQUEUE,	 RESTAPI::Protocol::TELEMETRY,
 | 
							RESTAPI::Protocol::EVENTQUEUE,	 RESTAPI::Protocol::TELEMETRY,
 | 
				
			||||||
		RESTAPI::Protocol::PING,		 RESTAPI::Protocol::SCRIPT,
 | 
							RESTAPI::Protocol::PING,		 RESTAPI::Protocol::SCRIPT,
 | 
				
			||||||
		RESTAPI::Protocol::RRM,		 	 RESTAPI::Protocol::CERTUPDATE,
 | 
							RESTAPI::Protocol::RRM,		 	 RESTAPI::Protocol::CERTUPDATE,
 | 
				
			||||||
		RESTAPI::Protocol::TRANSFER,	 RESTAPI::Protocol::POWERCYCLE
 | 
							RESTAPI::Protocol::TRANSFER
 | 
				
			||||||
	};
 | 
						};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	inline const char *to_string(Commands Cmd) { return uCentralAPCommands[(uint8_t)Cmd]; }
 | 
						inline const char *to_string(Commands Cmd) { return uCentralAPCommands[(uint8_t)Cmd]; }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -44,10 +44,7 @@ namespace OpenWifi {
 | 
				
			|||||||
		ORM::Field{"devClass", ORM::FieldType::FT_TEXT},
 | 
							ORM::Field{"devClass", ORM::FieldType::FT_TEXT},
 | 
				
			||||||
		ORM::Field{"locale", ORM::FieldType::FT_TEXT},
 | 
							ORM::Field{"locale", ORM::FieldType::FT_TEXT},
 | 
				
			||||||
		ORM::Field{"realMacAddress", ORM::FieldType::FT_TEXT},
 | 
							ORM::Field{"realMacAddress", ORM::FieldType::FT_TEXT},
 | 
				
			||||||
		ORM::Field{"doNotAllowOverrides", ORM::FieldType::FT_BOOLEAN},
 | 
							ORM::Field{"doNotAllowOverrides", ORM::FieldType::FT_BOOLEAN}};
 | 
				
			||||||
        ORM::Field{"imported", ORM::FieldType::FT_BIGINT},
 | 
					 | 
				
			||||||
        ORM::Field{"connected", ORM::FieldType::FT_BIGINT},
 | 
					 | 
				
			||||||
        ORM::Field{"platform", ORM::FieldType::FT_TEXT}};
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	static ORM::IndexVec InventoryDB_Indexes{
 | 
						static ORM::IndexVec InventoryDB_Indexes{
 | 
				
			||||||
		{std::string("inventory_name_index"),
 | 
							{std::string("inventory_name_index"),
 | 
				
			||||||
@@ -63,9 +60,6 @@ namespace OpenWifi {
 | 
				
			|||||||
			"alter table " + TableName_ + " add column realMacAddress text",
 | 
								"alter table " + TableName_ + " add column realMacAddress text",
 | 
				
			||||||
			"alter table " + TableName_ + " add column devClass text",
 | 
								"alter table " + TableName_ + " add column devClass text",
 | 
				
			||||||
			"alter table " + TableName_ + " add column deviceRules text",
 | 
								"alter table " + TableName_ + " add column deviceRules text",
 | 
				
			||||||
            "alter table " + TableName_ + " add column platform text default 'AP'",
 | 
					 | 
				
			||||||
            "alter table " + TableName_ + " add column imported bigint",
 | 
					 | 
				
			||||||
            "alter table " + TableName_ + " add column connected bigint",
 | 
					 | 
				
			||||||
			"alter table " + TableName_ + " add column doNotAllowOverrides boolean"};
 | 
								"alter table " + TableName_ + " add column doNotAllowOverrides boolean"};
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		for (const auto &i : Script) {
 | 
							for (const auto &i : Script) {
 | 
				
			||||||
@@ -86,8 +80,7 @@ namespace OpenWifi {
 | 
				
			|||||||
	bool InventoryDB::CreateFromConnection(const std::string &SerialNumberRaw,
 | 
						bool InventoryDB::CreateFromConnection(const std::string &SerialNumberRaw,
 | 
				
			||||||
										   const std::string &ConnectionInfo,
 | 
															   const std::string &ConnectionInfo,
 | 
				
			||||||
										   const std::string &DeviceType,
 | 
															   const std::string &DeviceType,
 | 
				
			||||||
										   const std::string &Locale,
 | 
															   const std::string &Locale) {
 | 
				
			||||||
										   const bool isConnection) {
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		ProvObjects::InventoryTag ExistingDevice;
 | 
							ProvObjects::InventoryTag ExistingDevice;
 | 
				
			||||||
		auto SerialNumber = Poco::toLower(SerialNumberRaw);
 | 
							auto SerialNumber = Poco::toLower(SerialNumberRaw);
 | 
				
			||||||
@@ -113,8 +106,6 @@ namespace OpenWifi {
 | 
				
			|||||||
			StateDoc["date"] = Utils::Now();
 | 
								StateDoc["date"] = Utils::Now();
 | 
				
			||||||
			NewDevice.state = to_string(StateDoc);
 | 
								NewDevice.state = to_string(StateDoc);
 | 
				
			||||||
			NewDevice.devClass = "any";
 | 
								NewDevice.devClass = "any";
 | 
				
			||||||
            NewDevice.connected = Now;
 | 
					 | 
				
			||||||
            NewDevice.imported = 0;
 | 
					 | 
				
			||||||
			if (!IP.empty()) {
 | 
								if (!IP.empty()) {
 | 
				
			||||||
				StorageService()->VenueDB().GetByIP(IP, NewDevice.venue);
 | 
									StorageService()->VenueDB().GetByIP(IP, NewDevice.venue);
 | 
				
			||||||
				if (NewDevice.venue.empty()) {
 | 
									if (NewDevice.venue.empty()) {
 | 
				
			||||||
@@ -185,32 +176,9 @@ namespace OpenWifi {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
			if (modified) {
 | 
								if (modified) {
 | 
				
			||||||
				ExistingDevice.info.modified = Utils::Now();
 | 
									ExistingDevice.info.modified = Utils::Now();
 | 
				
			||||||
                ExistingDevice.connected = Utils::Now();
 | 
					 | 
				
			||||||
				StorageService()->InventoryDB().UpdateRecord("id", ExistingDevice.info.id,
 | 
									StorageService()->InventoryDB().UpdateRecord("id", ExistingDevice.info.id,
 | 
				
			||||||
															 ExistingDevice);
 | 
																				 ExistingDevice);
 | 
				
			||||||
			}
 | 
								}
 | 
				
			||||||
 | 
					 | 
				
			||||||
			// Push entity and venue down to GW but only on connect (not ping)
 | 
					 | 
				
			||||||
			if (isConnection && !ExistingDevice.venue.empty()) {
 | 
					 | 
				
			||||||
				if (SDK::GW::Device::SetVenue(nullptr, ExistingDevice.serialNumber, ExistingDevice.venue)) {
 | 
					 | 
				
			||||||
						Logger().information(Poco::format("%s: GW set venue property.",
 | 
					 | 
				
			||||||
														  ExistingDevice.serialNumber));
 | 
					 | 
				
			||||||
				} else {
 | 
					 | 
				
			||||||
					Logger().information(Poco::format(
 | 
					 | 
				
			||||||
						"%s: could not set GW venue property.", ExistingDevice.serialNumber));
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
			if (isConnection && !ExistingDevice.entity.empty()) {
 | 
					 | 
				
			||||||
				if (SDK::GW::Device::SetEntity(nullptr, ExistingDevice.serialNumber, ExistingDevice.entity)) {
 | 
					 | 
				
			||||||
						Logger().information(Poco::format("%s: GW set entity property.",
 | 
					 | 
				
			||||||
														  ExistingDevice.serialNumber));
 | 
					 | 
				
			||||||
				} else {
 | 
					 | 
				
			||||||
					Logger().information(Poco::format(
 | 
					 | 
				
			||||||
						"%s: could not set GW entity property.", ExistingDevice.serialNumber));
 | 
					 | 
				
			||||||
				}
 | 
					 | 
				
			||||||
			}
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
		return false;
 | 
							return false;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
@@ -358,9 +326,6 @@ void ORM::DB<OpenWifi::InventoryDBRecordType, OpenWifi::ProvObjects::InventoryTa
 | 
				
			|||||||
	Out.locale = In.get<21>();
 | 
						Out.locale = In.get<21>();
 | 
				
			||||||
	Out.realMacAddress = In.get<22>();
 | 
						Out.realMacAddress = In.get<22>();
 | 
				
			||||||
	Out.doNotAllowOverrides = In.get<23>();
 | 
						Out.doNotAllowOverrides = In.get<23>();
 | 
				
			||||||
    Out.imported = In.get<24>();
 | 
					 | 
				
			||||||
    Out.connected = In.get<25>();
 | 
					 | 
				
			||||||
    Out.platform = In.get<26>();
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
template <>
 | 
					template <>
 | 
				
			||||||
@@ -390,7 +355,4 @@ void ORM::DB<OpenWifi::InventoryDBRecordType, OpenWifi::ProvObjects::InventoryTa
 | 
				
			|||||||
	Out.set<21>(In.locale);
 | 
						Out.set<21>(In.locale);
 | 
				
			||||||
	Out.set<22>(In.realMacAddress);
 | 
						Out.set<22>(In.realMacAddress);
 | 
				
			||||||
	Out.set<23>(In.doNotAllowOverrides);
 | 
						Out.set<23>(In.doNotAllowOverrides);
 | 
				
			||||||
    Out.set<24>(In.imported);
 | 
					 | 
				
			||||||
    Out.set<25>(In.connected);
 | 
					 | 
				
			||||||
    Out.set<26>(In.platform);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -16,7 +16,7 @@ namespace OpenWifi {
 | 
				
			|||||||
						std::string, std::string, std::string, std::string, std::string,
 | 
											std::string, std::string, std::string, std::string, std::string,
 | 
				
			||||||
						std::string, std::string, std::string, std::string, std::string,
 | 
											std::string, std::string, std::string, std::string, std::string,
 | 
				
			||||||
						std::string, std::string, std::string, std::string, std::string,
 | 
											std::string, std::string, std::string, std::string, std::string,
 | 
				
			||||||
						std::string, std::string, bool, uint64_t, uint64_t, std::string>
 | 
											std::string, std::string, bool>
 | 
				
			||||||
		InventoryDBRecordType;
 | 
							InventoryDBRecordType;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	class InventoryDB : public ORM::DB<InventoryDBRecordType, ProvObjects::InventoryTag> {
 | 
						class InventoryDB : public ORM::DB<InventoryDBRecordType, ProvObjects::InventoryTag> {
 | 
				
			||||||
@@ -25,8 +25,7 @@ namespace OpenWifi {
 | 
				
			|||||||
		virtual ~InventoryDB(){};
 | 
							virtual ~InventoryDB(){};
 | 
				
			||||||
		bool CreateFromConnection(const std::string &SerialNumber,
 | 
							bool CreateFromConnection(const std::string &SerialNumber,
 | 
				
			||||||
								  const std::string &ConnectionInfo, const std::string &DeviceType,
 | 
													  const std::string &ConnectionInfo, const std::string &DeviceType,
 | 
				
			||||||
								  const std::string &Locale,
 | 
													  const std::string &Locale);
 | 
				
			||||||
								  const bool isConnection);
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
		void InitializeSerialCache();
 | 
							void InitializeSerialCache();
 | 
				
			||||||
		bool GetRRMDeviceList(Types::UUIDvec_t &DeviceList);
 | 
							bool GetRRMDeviceList(Types::UUIDvec_t &DeviceList);
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user