Compare commits

...

14 Commits

Author SHA1 Message Date
Automation User - kinaraauto
8392b4bbc1 chore: updated package.json, updated helm/Chart.yaml, updated helm/values.yaml, updated CMakeLists.txt, updated version, updated CHANGELOG.md, bumped 3.0.11 -> 3.0.12 2024-09-27 14:59:01 +00:00
i-chvets
5727432d1b Merge pull request #15 from kinarasystems/WIFI-14134-fix_file_upload_status
WIFI-14134: fix: file upload status - code style change
2024-09-27 10:58:48 -04:00
Ivan Chvets
addd6ed346 fix: file upload status - code style change
https://telecominfraproject.atlassian.net/browse/WIFI-14134

Summary of changes:
- Code style change.

Signed-off-by: Ivan Chvets <ivan.chvets@kinarasystems.com>
2024-09-27 10:37:43 -04:00
Automation User - kinaraauto
3ee2adf03c chore: updated package.json, updated helm/Chart.yaml, updated helm/values.yaml, updated CMakeLists.txt, updated version, updated CHANGELOG.md, bumped 3.0.10 -> 3.0.11 2024-09-27 01:34:01 +00:00
i-chvets
1b915e988f Merge pull request #14 from kinarasystems/WIFI-14134-fix_file_upload_status
WIFI-14134: fix: file upload status
2024-09-26 21:33:46 -04:00
Ivan Chvets
084cfb78dd fix: file upload status
https://telecominfraproject.atlassian.net/browse/WIFI-14134

Summary of changes:
- Return 202 in case of file pening upload.

Signed-off-by: Ivan Chvets <ivan.chvets@kinarasystems.com>
2024-09-26 16:19:19 -04:00
Adam Capparelli
996cdba49d Merge pull request #13 from kinarasystems/openapi-fix
Fix wrong port in openapi.yaml
2024-09-25 10:52:51 -04:00
Adam Capparelli
d211222052 Fix wrong port in openapi.yaml
Signed-off-by: Adam Capparelli <adam.capparelli@alumni.utoronto.ca>
2024-09-25 10:40:06 -04:00
Automation User - kinaraauto
b92d0ff308 chore: updated package.json, updated helm/Chart.yaml, updated helm/values.yaml, updated CMakeLists.txt, updated version, updated CHANGELOG.md, bumped 3.0.9 -> 3.0.10 2024-09-18 15:02:55 +00:00
i-chvets
843e7039b3 Merge pull request #12 from kinarasystems/cable_diag
OLS-246: feat: add cable diagnostics command
2024-09-18 11:02:36 -04:00
Ivan Chvets
e9e0a6845d feat: add cable diagnostics command
https://telecominfraproject.atlassian.net/browse/OLS-246

Summary of changes:
- Added `cablediagnostics` command.

Signed-off-by: Ivan Chvets <ivan.chvets@kinarasystems.com>
2024-09-18 10:52:35 -04:00
Automation User - kinaraauto
3e255f3257 chore: updated package.json, updated helm/Chart.yaml, updated helm/values.yaml, updated CMakeLists.txt, updated version, updated CHANGELOG.md, bumped 3.0.8 -> 3.0.9 2024-08-30 14:24:47 +00:00
i-chvets
b75a1aa923 Merge pull request #11 from kinarasystems/fixedconfig
feat: add fixedconfig command
2024-08-30 10:24:32 -04:00
Ivan Chvets
2333cc7a40 feat: add fixedconfig command
https://telecominfraproject.atlassian.net/browse/WIFI-13126

Summary of changes:
- Added `fixedconfig` command.

Signed-off-by: Ivan Chvets <ivan.chvets@kinarasystems.com>
2024-08-30 10:10:59 -04:00
16 changed files with 173 additions and 25 deletions

View File

@@ -1,3 +1,19 @@
## 3.0.12 (September 27, 2024)
- chore: updated package.json, updated helm/Chart.yaml, updated helm/values.yaml, updated CMakeLists.txt, updated version, updated CHANGELOG.md, bumped 3.0.11 -> 3.0.12
- Merge pull request #15 from kinarasystems/WIFI-14134-fix_file_upload_status
## 3.0.11 (September 27, 2024)
- chore: updated package.json, updated helm/Chart.yaml, updated helm/values.yaml, updated CMakeLists.txt, updated version, updated CHANGELOG.md, bumped 3.0.10 -> 3.0.11
- Merge pull request #14 from kinarasystems/WIFI-14134-fix_file_upload_status
## 3.0.10 (September 18, 2024)
- chore: updated package.json, updated helm/Chart.yaml, updated helm/values.yaml, updated CMakeLists.txt, updated version, updated CHANGELOG.md, bumped 3.0.9 -> 3.0.10
- Merge pull request #12 from kinarasystems/cable_diag
## 3.0.9 (August 30, 2024)
- chore: updated package.json, updated helm/Chart.yaml, updated helm/values.yaml, updated CMakeLists.txt, updated version, updated CHANGELOG.md, bumped 3.0.8 -> 3.0.9
- Merge pull request #11 from kinarasystems/fixedconfig
## 3.0.8 (August 08, 2024) ## 3.0.8 (August 08, 2024)
- chore: updated package.json, updated helm/Chart.yaml, updated helm/values.yaml, updated CMakeLists.txt, updated version, updated CHANGELOG.md, bumped 3.0.7 -> 3.0.8 - chore: updated package.json, updated helm/Chart.yaml, updated helm/values.yaml, updated CMakeLists.txt, updated version, updated CHANGELOG.md, bumped 3.0.7 -> 3.0.8
- Merge pull request #10 from kinarasystems/WIFI-13875-fix-use-dns - Merge pull request #10 from kinarasystems/WIFI-13875-fix-use-dns

View File

@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.13) cmake_minimum_required(VERSION 3.13)
project(owgw VERSION 3.0.8) project(owgw VERSION 3.0.12)
set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED True) set(CMAKE_CXX_STANDARD_REQUIRED True)

View File

@@ -1,5 +1,5 @@
apiVersion: v2 apiVersion: v2
appVersion: "3.0.8" appVersion: "3.0.12"
description: A Helm chart for Kubernetes description: A Helm chart for Kubernetes
name: owgw name: owgw
version: 0.1.0 version: 0.1.0

View File

@@ -7,7 +7,7 @@ fullnameOverride: ""
images: images:
owgw: owgw:
repository: 471112855615.dkr.ecr.us-east-1.amazonaws.com/owgw repository: 471112855615.dkr.ecr.us-east-1.amazonaws.com/owgw
tag: kv3.0.8 tag: kv3.0.12
pullPolicy: Always pullPolicy: Always
# regcred: # regcred:
# registry: tip-tip-wlan-cloud-ucentral.jfrog.io # registry: tip-tip-wlan-cloud-ucentral.jfrog.io

View File

@@ -12,7 +12,7 @@ info:
url: https://www.ucentral.info/support url: https://www.ucentral.info/support
servers: servers:
- url: 'https://localhost:16001/api/v1' - url: 'https://localhost:16002/api/v1'
security: security:
- bearerAuth: [] - bearerAuth: []

View File

@@ -1,6 +1,6 @@
{ {
"name": "owgw", "name": "owgw",
"version": "3.0.8", "version": "3.0.12",
"description": "This is the Kinara version of OpenWifi OWGW", "description": "This is the Kinara version of OpenWifi OWGW",
"author": "Kinara Systems", "author": "Kinara Systems",
"homepage": "https://kinarasystems.com", "homepage": "https://kinarasystems.com",

View File

@@ -167,7 +167,10 @@ namespace OpenWifi {
{APCommands::Commands::certupdate, false, true, &RESTAPI_device_commandHandler::CertUpdate, 60000ms}, {APCommands::Commands::certupdate, false, true, &RESTAPI_device_commandHandler::CertUpdate, 60000ms},
{APCommands::Commands::transfer, false, true, &RESTAPI_device_commandHandler::Transfer, 60000ms}, {APCommands::Commands::transfer, false, true, &RESTAPI_device_commandHandler::Transfer, 60000ms},
{APCommands::Commands::script, false, true, &RESTAPI_device_commandHandler::Script, 60000ms}, {APCommands::Commands::script, false, true, &RESTAPI_device_commandHandler::Script, 60000ms},
{APCommands::Commands::powercycle, false, true, &RESTAPI_device_commandHandler::PowerCycle, 60000ms} {APCommands::Commands::powercycle, false, true, &RESTAPI_device_commandHandler::PowerCycle, 60000ms},
{APCommands::Commands::fixedconfig, false, true, &RESTAPI_device_commandHandler::FixedConfig, 120000ms},
{APCommands::Commands::cablediagnostics, false, true, &RESTAPI_device_commandHandler::CableDiagnostics, 120000ms},
}; };
void RESTAPI_device_commandHandler::DoPost() { void RESTAPI_device_commandHandler::DoPost() {
@@ -1548,4 +1551,76 @@ namespace OpenWifi {
Logger_); Logger_);
} }
void RESTAPI_device_commandHandler::FixedConfig(
const std::string &CMD_UUID, uint64_t CMD_RPC, std::chrono::milliseconds timeout,
[[maybe_unused]] const GWObjects::DeviceRestrictions &Restrictions) {
poco_debug(Logger_, fmt::format("FIXEDCONFIG({},{}): TID={} user={} serial={}", CMD_UUID, CMD_RPC,
TransactionId_, Requester(), SerialNumber_));
if(IsDeviceSimulated(SerialNumber_)) {
CallCanceled("FIXEDCONFIG", CMD_UUID, CMD_RPC, RESTAPI::Errors::SimulatedDeviceNotSupported);
return BadRequest(RESTAPI::Errors::SimulatedDeviceNotSupported);
}
GWObjects::FixedConfig fixed_config;
if(!fixed_config.from_json(ParsedBody_)) {
return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
}
GWObjects::CommandDetails Cmd;
Cmd.SerialNumber = SerialNumber_;
Cmd.SubmittedBy = Requester();
Cmd.UUID = CMD_UUID;
Cmd.Command = uCentralProtocol::FIXEDCONFIG;
std::ostringstream os;
ParsedBody_->stringify(os);
Cmd.Details = os.str();
Cmd.RunAt = 0;
Cmd.ErrorCode = 0;
Cmd.WaitingForFile = 0;
return RESTAPI_RPC::WaitForCommand(CMD_RPC, APCommands::Commands::fixedconfig, false, Cmd,
*ParsedBody_, *Request, *Response, timeout, nullptr, this,
Logger_);
}
void RESTAPI_device_commandHandler::CableDiagnostics(
const std::string &CMD_UUID, uint64_t CMD_RPC,
[[maybe_unused]] std::chrono::milliseconds timeout,
[[maybe_unused]] const GWObjects::DeviceRestrictions &Restrictions) {
if(UserInfo_.userinfo.userRole != SecurityObjects::ROOT &&
UserInfo_.userinfo.userRole != SecurityObjects::ADMIN) {
CallCanceled("CABLEDIAGNOSTICS", CMD_UUID, CMD_RPC, RESTAPI::Errors::ACCESS_DENIED);
return UnAuthorized(RESTAPI::Errors::ACCESS_DENIED);
}
poco_debug(Logger_, fmt::format("CABLEDIAGNOSTICS({},{}): TID={} user={} serial={}", CMD_UUID,
CMD_RPC, TransactionId_, Requester(), SerialNumber_));
if(IsDeviceSimulated(SerialNumber_)) {
CallCanceled("CABLEDIAGNOSTICS", CMD_UUID, CMD_RPC, RESTAPI::Errors::SimulatedDeviceNotSupported);
return BadRequest(RESTAPI::Errors::SimulatedDeviceNotSupported);
}
GWObjects::CableDiagnostics PR;
if(!PR.from_json(ParsedBody_)) {
return BadRequest(RESTAPI::Errors::MissingOrInvalidParameters);
}
GWObjects::CommandDetails Cmd;
Cmd.SerialNumber = SerialNumber_;
Cmd.SubmittedBy = Requester();
Cmd.UUID = CMD_UUID;
Cmd.Command = uCentralProtocol::CABLEDIAGNOSTICS;
std::ostringstream os;
ParsedBody_->stringify(os);
Cmd.Details = os.str();
Cmd.RunAt = PR.when;
Cmd.ErrorCode = 0;
Cmd.WaitingForFile = 0;
return RESTAPI_RPC::WaitForCommand(CMD_RPC, APCommands::Commands::cablediagnostics, false, Cmd,
*ParsedBody_, *Request, *Response, timeout, nullptr, this,
Logger_);
}
} // namespace OpenWifi } // namespace OpenWifi

View File

@@ -70,6 +70,10 @@ namespace OpenWifi {
const GWObjects::DeviceRestrictions &R); const GWObjects::DeviceRestrictions &R);
void PowerCycle(const std::string &UUID, uint64_t RPC, std::chrono::milliseconds timeout, void PowerCycle(const std::string &UUID, uint64_t RPC, std::chrono::milliseconds timeout,
const GWObjects::DeviceRestrictions &R); const GWObjects::DeviceRestrictions &R);
void FixedConfig(const std::string &UUID, uint64_t RPC, std::chrono::milliseconds timeout,
const GWObjects::DeviceRestrictions &R);
void CableDiagnostics(const std::string &UUID, uint64_t RPC, std::chrono::milliseconds timeout,
const GWObjects::DeviceRestrictions &R);
static auto PathName() { static auto PathName() {
return std::list<std::string>{"/api/v1/device/{serialNumber}/{command}"}; return std::list<std::string>{"/api/v1/device/{serialNumber}/{command}"};

View File

@@ -22,9 +22,15 @@ namespace OpenWifi {
std::string FileType; std::string FileType;
std::string FileContent; std::string FileContent;
if (!StorageService()->GetAttachedFileContent(UUID, SerialNumber, FileContent, FileType) || FileContent.empty()) { int WaitingForFile = 0;
if (!StorageService()->GetAttachedFileContent(UUID, SerialNumber, FileContent, FileType, WaitingForFile) && !WaitingForFile) {
return NotFound(); return NotFound();
} }
else if (WaitingForFile) {
// waiting for file to be uploaded, return Accepted
return Accepted();
}
if (FileType == "pcap") { if (FileType == "pcap") {
SendFileContent(FileContent, "application/vnd.tcpdump.pcap", UUID + ".pcap"); SendFileContent(FileContent, "application/vnd.tcpdump.pcap", UUID + ".pcap");
} }

View File

@@ -799,4 +799,24 @@ namespace OpenWifi::GWObjects {
return false; return false;
} }
bool FixedConfig::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
field_from_json(Obj, "serial", serialNumber);
field_from_json(Obj, "country", country);
return true;
} catch (const Poco::Exception &E) {
}
return false;
}
bool CableDiagnostics::from_json(const Poco::JSON::Object::Ptr &Obj) {
try {
field_from_json(Obj, "serial", serialNumber);
field_from_json(Obj, "when", when);
field_from_json(Obj, "ports", ports);
return true;
} catch (const Poco::Exception &E) {
}
return false;
}
} // namespace OpenWifi::GWObjects } // namespace OpenWifi::GWObjects

View File

@@ -532,6 +532,19 @@ namespace OpenWifi::GWObjects {
std::uint64_t when; std::uint64_t when;
std::vector<PowerCyclePort> ports; std::vector<PowerCyclePort> ports;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
struct FixedConfig {
std::string serialNumber;
std::string country;
bool from_json(const Poco::JSON::Object::Ptr &Obj);
};
struct CableDiagnostics {
std::string serialNumber;
std::uint64_t when;
std::vector<std::string> ports;
bool from_json(const Poco::JSON::Object::Ptr &Obj); bool from_json(const Poco::JSON::Object::Ptr &Obj);
}; };
} // namespace OpenWifi::GWObjects } // namespace OpenWifi::GWObjects

View File

@@ -243,7 +243,7 @@ namespace OpenWifi {
const std::string &Type); const std::string &Type);
bool CancelWaitFile(std::string &UUID, std::string &ErrorText); bool CancelWaitFile(std::string &UUID, std::string &ErrorText);
bool GetAttachedFileContent(std::string &UUID, const std::string &SerialNumber, bool GetAttachedFileContent(std::string &UUID, const std::string &SerialNumber,
std::string &FileContent, std::string &Type); std::string &FileContent, std::string &Type, int& WaitingForFile);
bool RemoveAttachedFile(std::string &UUID); bool RemoveAttachedFile(std::string &UUID);
bool SetCommandResult(std::string &UUID, std::string &Result); bool SetCommandResult(std::string &UUID, std::string &Result);
bool GetNewestCommands(std::string &SerialNumber, uint64_t HowMany, bool GetNewestCommands(std::string &SerialNumber, uint64_t HowMany,

View File

@@ -474,6 +474,11 @@ namespace OpenWifi {
} }
} }
inline void Accepted() {
PrepareResponse(Poco::Net::HTTPResponse::HTTP_ACCEPTED);
Response->send();
}
inline void SendCompressedTarFile(const std::string &FileName, const std::string &Content) { inline void SendCompressedTarFile(const std::string &FileName, const std::string &Content) {
Response->setStatus(Poco::Net::HTTPResponse::HTTPStatus::HTTP_OK); Response->setStatus(Poco::Net::HTTPResponse::HTTPStatus::HTTP_OK);
SetCommonHeaders(); SetCommonHeaders();

View File

@@ -580,6 +580,9 @@ namespace OpenWifi::RESTAPI::Protocol {
static const char *INTERVAL = "interval"; static const char *INTERVAL = "interval";
static const char *UI = "UI"; static const char *UI = "UI";
static const char *BANDWIDTH = "bandwidth"; static const char *BANDWIDTH = "bandwidth";
static const char *FIXEDCONFIG = "fixedconfig";
static const char *CABLEDIAGNOSTICS = "cablediagnostics";
} // namespace OpenWifi::RESTAPI::Protocol } // namespace OpenWifi::RESTAPI::Protocol
namespace OpenWifi::uCentralProtocol { namespace OpenWifi::uCentralProtocol {
@@ -692,6 +695,9 @@ namespace OpenWifi::uCentralProtocol {
static const char *RRM = "rrm"; static const char *RRM = "rrm";
static const char *ACTIONS = "actions"; static const char *ACTIONS = "actions";
static const char *FIXEDCONFIG = "fixedconfig";
static const char *CABLEDIAGNOSTICS = "cablediagnostics";
} // namespace OpenWifi::uCentralProtocol } // namespace OpenWifi::uCentralProtocol
namespace OpenWifi::uCentralProtocol::Events { namespace OpenWifi::uCentralProtocol::Events {
@@ -788,6 +794,8 @@ namespace OpenWifi::APCommands {
certupdate, certupdate,
transfer, transfer,
powercycle, powercycle,
fixedconfig,
cablediagnostics,
unknown unknown
}; };
@@ -802,7 +810,8 @@ 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, RESTAPI::Protocol::POWERCYCLE,
RESTAPI::Protocol::FIXEDCONFIG, RESTAPI::Protocol::CABLEDIAGNOSTICS
}; };
inline const char *to_string(Commands Cmd) { return uCentralAPCommands[(uint8_t)Cmd]; } inline const char *to_string(Commands Cmd) { return uCentralAPCommands[(uint8_t)Cmd]; }

View File

@@ -647,18 +647,6 @@ namespace OpenWifi {
Sess.begin(); Sess.begin();
Poco::Data::Statement Statement(Sess); Poco::Data::Statement Statement(Sess);
std::string StatementStr;
// Get the existing command
StatementStr =
"UPDATE CommandList SET WaitingForFile=?, AttachDate=?, AttachSize=? WHERE UUID=?";
Statement << ConvertParams(StatementStr), Poco::Data::Keywords::use(WaitForFile),
Poco::Data::Keywords::use(Now), Poco::Data::Keywords::use(Size),
Poco::Data::Keywords::use(UUID);
Statement.execute();
Sess.commit();
if (Size < FileUploader()->MaxSize()) { if (Size < FileUploader()->MaxSize()) {
Poco::Data::BLOB TheBlob; Poco::Data::BLOB TheBlob;
@@ -681,6 +669,18 @@ namespace OpenWifi {
poco_warning(Logger(), fmt::format("File {} is too large.", UUID)); poco_warning(Logger(), fmt::format("File {} is too large.", UUID));
} }
Sess.commit(); Sess.commit();
// update CommandList here to ensure that file us uploaded
std::string StatementStr;
StatementStr =
"UPDATE CommandList SET WaitingForFile=?, AttachDate=?, AttachSize=? WHERE UUID=?";
Statement << ConvertParams(StatementStr), Poco::Data::Keywords::use(WaitForFile),
Poco::Data::Keywords::use(Now), Poco::Data::Keywords::use(Size),
Poco::Data::Keywords::use(UUID);
Statement.execute();
Sess.commit();
return true; return true;
} catch (const Poco::Exception &E) { } catch (const Poco::Exception &E) {
Logger().log(E); Logger().log(E);
@@ -689,7 +689,7 @@ namespace OpenWifi {
} }
bool Storage::GetAttachedFileContent(std::string &UUID, const std::string &SerialNumber, bool Storage::GetAttachedFileContent(std::string &UUID, const std::string &SerialNumber,
std::string &FileContent, std::string &Type) { std::string &FileContent, std::string &Type, int &WaitingForFile) {
try { try {
Poco::Data::BLOB L; Poco::Data::BLOB L;
/* /*
@@ -702,10 +702,10 @@ namespace OpenWifi {
Poco::Data::Statement Select1(Sess); Poco::Data::Statement Select1(Sess);
std::string TmpSerialNumber; std::string TmpSerialNumber;
std::string st1{"SELECT SerialNumber, Command FROM CommandList WHERE UUID=?"}; std::string st1{"SELECT SerialNumber, Command , WaitingForFile FROM CommandList WHERE UUID=?"};
std::string Command; std::string Command;
Select1 << ConvertParams(st1), Poco::Data::Keywords::into(TmpSerialNumber), Select1 << ConvertParams(st1), Poco::Data::Keywords::into(TmpSerialNumber),
Poco::Data::Keywords::into(Command), Poco::Data::Keywords::use(UUID); Poco::Data::Keywords::into(Command), Poco::Data::Keywords::into(WaitingForFile), Poco::Data::Keywords::use(UUID);
Select1.execute(); Select1.execute();
if (TmpSerialNumber != SerialNumber) { if (TmpSerialNumber != SerialNumber) {

View File

@@ -1 +1 @@
3.0.8 3.0.12