mirror of
https://github.com/Telecominfraproject/wlan-cloud-owprov.git
synced 2025-10-29 17:52:28 +00:00
Fixing inventory-applyConfiguration
This commit is contained in:
@@ -1623,6 +1623,8 @@ paths:
|
||||
- $ref: '#/components/schemas/SerialNumberList'
|
||||
- $ref: '#/components/schemas/InventoryTagList'
|
||||
- $ref: '#/components/schemas/CountAnswer'
|
||||
400:
|
||||
$ref: '#/components/responses/BadRequest'
|
||||
403:
|
||||
$ref: '#/components/responses/Unauthorized'
|
||||
404:
|
||||
@@ -1671,6 +1673,8 @@ paths:
|
||||
- $ref: '#/components/schemas/InventoryTag'
|
||||
- $ref: '#/components/schemas/FirmwareOptions'
|
||||
- $ref: '#/components/schemas/InventoryConfigApplyResult'
|
||||
400:
|
||||
$ref: '#/components/responses/BadRequest'
|
||||
403:
|
||||
$ref: '#/components/responses/Unauthorized'
|
||||
404:
|
||||
|
||||
@@ -71,33 +71,23 @@ namespace OpenWifi{
|
||||
} else if(HasParameter("applyConfiguration",Arg) && Arg=="true") {
|
||||
APConfig Device(SerialNumber, Existing.deviceType, Logger(), false);
|
||||
Poco::JSON::Object::Ptr Configuration;
|
||||
|
||||
Types::StringVec Errors, Warnings;
|
||||
Poco::JSON::Object ErrorsObj, WarningsObj;
|
||||
int ErrorCode;
|
||||
ProvObjects::InventoryConfigApplyResult Results;
|
||||
if (Device.Get(Configuration)) {
|
||||
std::ostringstream OS;
|
||||
Configuration->stringify(OS);
|
||||
Results.appliedConfiguration = OS.str();
|
||||
Poco::JSON::Object::Ptr Response;
|
||||
if (SDK::GW::Device::Configure(this, SerialNumber, Configuration, Response)) {
|
||||
std::ostringstream os;
|
||||
Response->stringify(os);
|
||||
// std::cout << "Success: " << os.str() << std::endl;
|
||||
GetRejectedLines(Response, Warnings);
|
||||
ErrorCode = 0;
|
||||
GetRejectedLines(Response, Results.warnings);
|
||||
Results.errorCode = 0;
|
||||
} else {
|
||||
std::ostringstream os;
|
||||
Response->stringify(os);
|
||||
ErrorCode = 1;
|
||||
// std::cout << "Failure: " << os.str() << std::endl;
|
||||
Results.errorCode = 1;
|
||||
}
|
||||
Answer.set("appliedConfiguration", Configuration);
|
||||
Answer.set("response", Response);
|
||||
} else {
|
||||
Answer.set("appliedConfiguration", "");
|
||||
ErrorCode = 1;
|
||||
Results.errorCode = 1;
|
||||
}
|
||||
Answer.set("errorCode", ErrorCode);
|
||||
RESTAPI_utils::field_to_json(Answer, "errors", Errors);
|
||||
RESTAPI_utils::field_to_json(Answer, "warnings", Warnings);
|
||||
Results.to_json(Answer);
|
||||
return ReturnObject(Answer);
|
||||
} else if(QB_.AdditionalInfo) {
|
||||
AddExtendedInfo(Existing,Answer);
|
||||
|
||||
@@ -340,6 +340,26 @@ namespace OpenWifi::ProvObjects {
|
||||
return false;
|
||||
}
|
||||
|
||||
void InventoryConfigApplyResult::to_json(Poco::JSON::Object &Obj) const {
|
||||
field_to_json( Obj, "appliedConfiguration", appliedConfiguration);
|
||||
field_to_json( Obj, "warnings", warnings);
|
||||
field_to_json( Obj, "errors", errors);
|
||||
field_to_json( Obj, "errorCode", errorCode);
|
||||
}
|
||||
|
||||
bool InventoryConfigApplyResult::from_json(const Poco::JSON::Object::Ptr &Obj) {
|
||||
try {
|
||||
field_from_json( Obj, "appliedConfiguration", appliedConfiguration);
|
||||
field_from_json( Obj, "warnings", warnings);
|
||||
field_from_json( Obj, "errors", errors);
|
||||
field_from_json( Obj, "errorCode", errorCode);
|
||||
return true;
|
||||
} catch (...) {
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void InventoryTagList::to_json(Poco::JSON::Object &Obj) const {
|
||||
field_to_json( Obj,"taglist",taglist);
|
||||
}
|
||||
|
||||
@@ -301,6 +301,15 @@ namespace OpenWifi::ProvObjects {
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
struct InventoryConfigApplyResult {
|
||||
std::string appliedConfiguration;
|
||||
Types::StringVec errors;
|
||||
Types::StringVec warnings;
|
||||
uint64_t errorCode;
|
||||
|
||||
void to_json(Poco::JSON::Object &Obj) const;
|
||||
bool from_json(const Poco::JSON::Object::Ptr &Obj);
|
||||
};
|
||||
|
||||
struct Report {
|
||||
uint64_t snapShot=0;
|
||||
|
||||
@@ -448,6 +448,13 @@ reloadsubsystem() {
|
||||
-d "$payload"
|
||||
}
|
||||
|
||||
getsubdevs() {
|
||||
curl ${FLAGS} -X GET "https://${OWPROV}/api/v1/inventory?subscriber=$1" \
|
||||
-H "accept: application/json" \
|
||||
-H "Authorization: Bearer ${token}" > ${result_file}
|
||||
jq < ${result_file}
|
||||
}
|
||||
|
||||
addresscheck() {
|
||||
echo "Token:${token}"
|
||||
wscat -c wss://${OWPROV}/api/v1/ws
|
||||
@@ -522,6 +529,7 @@ case "$1" in
|
||||
"affecteddevices") login; affecteddevices "$2"; logout;;
|
||||
"signup") login; signup ; logout;;
|
||||
"getsignup") login; getsignup $2; logout;;
|
||||
"getsubdevs") login; getsubdevs $2; logout;;
|
||||
*) help ;;
|
||||
esac
|
||||
|
||||
|
||||
Reference in New Issue
Block a user