mirror of
https://github.com/Telecominfraproject/wlan-cloud-owprov.git
synced 2025-11-01 19:17:47 +00:00
Adding firmware upgrade automation.
This commit is contained in:
@@ -485,7 +485,7 @@ components:
|
|||||||
- inherit
|
- inherit
|
||||||
firmwareUpgrade:
|
firmwareUpgrade:
|
||||||
type: string
|
type: string
|
||||||
example: "auto" or a time string of the format "DOW-HH:MM"
|
example: auto or a time string of the format DOW-HH:MM
|
||||||
firmwareRCOnly:
|
firmwareRCOnly:
|
||||||
type: boolean
|
type: boolean
|
||||||
|
|
||||||
@@ -587,6 +587,18 @@ components:
|
|||||||
items:
|
items:
|
||||||
$ref: '#/components/schemas/ExpandedUseEntryMap'
|
$ref: '#/components/schemas/ExpandedUseEntryMap'
|
||||||
|
|
||||||
|
FirmwareOptions:
|
||||||
|
type: object
|
||||||
|
properties:
|
||||||
|
firmwareUpgrade:
|
||||||
|
type: string
|
||||||
|
example: auto or a time string of the format DOW-HH:MM
|
||||||
|
firmwareRCOnly:
|
||||||
|
type: boolean
|
||||||
|
from:
|
||||||
|
type: string
|
||||||
|
|
||||||
|
|
||||||
#########################################################################################
|
#########################################################################################
|
||||||
##
|
##
|
||||||
## These are endpoints that all services in the OPenWiFI stack must provide
|
## These are endpoints that all services in the OPenWiFI stack must provide
|
||||||
@@ -774,7 +786,7 @@ components:
|
|||||||
items:
|
items:
|
||||||
type: string
|
type: string
|
||||||
|
|
||||||
SystemGetSubSystemNemesResult:
|
SystemGetSubSystemNamesResult:
|
||||||
type: object
|
type: object
|
||||||
properties:
|
properties:
|
||||||
taglist:
|
taglist:
|
||||||
@@ -1389,9 +1401,30 @@ paths:
|
|||||||
type: string
|
type: string
|
||||||
format: uuid
|
format: uuid
|
||||||
required: true
|
required: true
|
||||||
|
- in: query
|
||||||
|
name: config
|
||||||
|
schema:
|
||||||
|
type: boolean
|
||||||
|
required: false
|
||||||
|
- in: query
|
||||||
|
name: explain
|
||||||
|
schema:
|
||||||
|
type: boolean
|
||||||
|
required: false
|
||||||
|
- in: query
|
||||||
|
name: firmwareOptions
|
||||||
|
schema:
|
||||||
|
type: boolean
|
||||||
|
required: false
|
||||||
responses:
|
responses:
|
||||||
200:
|
200:
|
||||||
$ref: '#/components/schemas/InventoryTag'
|
description: Succesful retrieve configuratiopn or part of the configuration
|
||||||
|
content:
|
||||||
|
application/json:
|
||||||
|
schema:
|
||||||
|
oneOf:
|
||||||
|
- $ref: '#/components/schemas/InventoryTag'
|
||||||
|
- $ref: '#/components/schemas/FirmwareOptions'
|
||||||
403:
|
403:
|
||||||
$ref: '#/components/responses/Unauthorized'
|
$ref: '#/components/responses/Unauthorized'
|
||||||
404:
|
404:
|
||||||
@@ -1414,7 +1447,6 @@ paths:
|
|||||||
application/json:
|
application/json:
|
||||||
schema:
|
schema:
|
||||||
$ref: '#/components/schemas/InventoryTag'
|
$ref: '#/components/schemas/InventoryTag'
|
||||||
|
|
||||||
responses:
|
responses:
|
||||||
200:
|
200:
|
||||||
$ref: '#/components/schemas/InventoryTag'
|
$ref: '#/components/schemas/InventoryTag'
|
||||||
@@ -2213,7 +2245,7 @@ paths:
|
|||||||
oneOf:
|
oneOf:
|
||||||
- $ref: '#/components/schemas/SystemGetLogLevelsResult'
|
- $ref: '#/components/schemas/SystemGetLogLevelsResult'
|
||||||
- $ref: '#/components/schemas/SystemCommandGetLogLevelNamesResult'
|
- $ref: '#/components/schemas/SystemCommandGetLogLevelNamesResult'
|
||||||
- $ref: '#/components/schemas/SystemGetSubSystemNemesResult'
|
- $ref: '#/components/schemas/SystemGetSubSystemNamesResult'
|
||||||
403:
|
403:
|
||||||
$ref: '#/components/responses/Unauthorized'
|
$ref: '#/components/responses/Unauthorized'
|
||||||
404:
|
404:
|
||||||
|
|||||||
@@ -41,6 +41,18 @@ namespace OpenWifi{
|
|||||||
}
|
}
|
||||||
ReturnObject(Answer);
|
ReturnObject(Answer);
|
||||||
return;
|
return;
|
||||||
|
} else if(HasParameter("firmwareOptions", Arg) && Arg=="true") {
|
||||||
|
Poco::JSON::Object Answer;
|
||||||
|
|
||||||
|
std::string firmwareUpgrade;
|
||||||
|
bool firmwareRCOnly=false;
|
||||||
|
|
||||||
|
Storage()->InventoryDB().FindFirmwareOptions(SerialNumber,firmwareUpgrade, firmwareRCOnly);
|
||||||
|
|
||||||
|
Answer.set("firmwareUpgrade",firmwareUpgrade);
|
||||||
|
Answer.set("firmwareRCOnly", firmwareRCOnly);
|
||||||
|
ReturnObject(Answer);
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Poco::JSON::Object Answer;
|
Poco::JSON::Object Answer;
|
||||||
|
|||||||
@@ -111,6 +111,110 @@ namespace OpenWifi {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool InventoryDB::FindFirmwareOptionsForEntity(std::string &EntityUUID, std::string &firmwareUpgrade,
|
||||||
|
bool &firmwareRCOnly) {
|
||||||
|
std::string UUID = EntityUUID;
|
||||||
|
while(!UUID.empty() && UUID!=EntityDB::RootUUID()) {
|
||||||
|
ProvObjects::Entity E;
|
||||||
|
if(Storage()->EntityDB().GetRecord("id",UUID,E)) {
|
||||||
|
if(!E.deviceConfiguration.empty()) {
|
||||||
|
ProvObjects::DeviceConfiguration C;
|
||||||
|
if(Storage()->ConfigurationDB().GetRecord("id",E.deviceConfiguration,C)) {
|
||||||
|
if(C.firmwareUpgrade=="no") {
|
||||||
|
firmwareUpgrade="no";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(C.firmwareUpgrade=="yes") {
|
||||||
|
firmwareUpgrade="yes";
|
||||||
|
firmwareRCOnly=C.firmwareRCOnly;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
UUID = E.parent;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
firmwareUpgrade="no";
|
||||||
|
firmwareRCOnly= false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool InventoryDB::FindFirmwareOptionsForVenue(std::string &VenueUUID, std::string &firmwareUpgrade,
|
||||||
|
bool &firmwareRCOnly) {
|
||||||
|
std::string UUID = VenueUUID;
|
||||||
|
while(!UUID.empty()) {
|
||||||
|
ProvObjects::Venue V;
|
||||||
|
if(Storage()->VenueDB().GetRecord("id",UUID,V)) {
|
||||||
|
if(!V.deviceConfiguration.empty()) {
|
||||||
|
ProvObjects::DeviceConfiguration C;
|
||||||
|
if(Storage()->ConfigurationDB().GetRecord("id",V.deviceConfiguration,C)) {
|
||||||
|
if(C.firmwareUpgrade=="no") {
|
||||||
|
firmwareUpgrade="no";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(C.firmwareUpgrade=="yes") {
|
||||||
|
firmwareUpgrade="yes";
|
||||||
|
firmwareRCOnly=C.firmwareRCOnly;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// must be inherit...
|
||||||
|
if(!V.entity.empty()) {
|
||||||
|
return FindFirmwareOptionsForEntity(V.entity,firmwareUpgrade,firmwareRCOnly);
|
||||||
|
} else {
|
||||||
|
UUID=V.parent;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
firmwareUpgrade="no";
|
||||||
|
firmwareRCOnly= false;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool InventoryDB::FindFirmwareOptions(std::string &SerialNumber, std::string &firmwareUpgrade,
|
||||||
|
bool &firmwareRCOnly) {
|
||||||
|
|
||||||
|
ProvObjects::InventoryTag T;
|
||||||
|
firmwareRCOnly = false;
|
||||||
|
firmwareUpgrade.clear();
|
||||||
|
if(GetRecord("serialNumber",SerialNumber,T)) {
|
||||||
|
// if there is a local configuration, use this
|
||||||
|
firmwareRCOnly = false;
|
||||||
|
firmwareUpgrade.clear();
|
||||||
|
if(!T.deviceConfiguration.empty()) {
|
||||||
|
ProvObjects::DeviceConfiguration C;
|
||||||
|
if(Storage()->ConfigurationDB().GetRecord("id",T.deviceConfiguration,C)) {
|
||||||
|
if(C.firmwareUpgrade=="no") {
|
||||||
|
firmwareUpgrade="no";
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if(C.firmwareUpgrade=="yes") {
|
||||||
|
firmwareUpgrade="yes";
|
||||||
|
firmwareRCOnly = C.firmwareRCOnly;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// look at entity...
|
||||||
|
if(!T.entity.empty()) {
|
||||||
|
return FindFirmwareOptionsForEntity(T.entity,firmwareUpgrade,firmwareRCOnly);
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!T.venue.empty()) {
|
||||||
|
return FindFirmwareOptionsForVenue(T.entity,firmwareUpgrade,firmwareRCOnly);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> void ORM::DB< OpenWifi::InventoryDBRecordType, OpenWifi::ProvObjects::InventoryTag>::Convert(OpenWifi::InventoryDBRecordType &In, OpenWifi::ProvObjects::InventoryTag &Out) {
|
template<> void ORM::DB< OpenWifi::InventoryDBRecordType, OpenWifi::ProvObjects::InventoryTag>::Convert(OpenWifi::InventoryDBRecordType &In, OpenWifi::ProvObjects::InventoryTag &Out) {
|
||||||
|
|||||||
@@ -40,6 +40,9 @@ namespace OpenWifi {
|
|||||||
public:
|
public:
|
||||||
InventoryDB( ORM::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L);
|
InventoryDB( ORM::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L);
|
||||||
bool CreateFromConnection(const std::string & SerialNumber, const std::string & ConnectionInfo, const std::string & DeviceType);
|
bool CreateFromConnection(const std::string & SerialNumber, const std::string & ConnectionInfo, const std::string & DeviceType);
|
||||||
|
bool FindFirmwareOptions(std::string & SerialNumber, std::string &firmwareUpgrade, bool &firmwareRCOnly);
|
||||||
|
bool FindFirmwareOptionsForEntity(std::string & EntityUUID, std::string &firmwareUpgrade, bool &firmwareRCOnly);
|
||||||
|
bool FindFirmwareOptionsForVenue(std::string & VenueUUID, std::string &firmwareUpgrade, bool &firmwareRCOnly);
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -370,6 +370,14 @@ deviceconfig() {
|
|||||||
jq < ${result_file}
|
jq < ${result_file}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
devicefwoptions() {
|
||||||
|
curl ${FLAGS} "https://${OWPROV}/api/v1/inventory/$1?firmwareOptions=true" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-H "Authorization: Bearer ${token}" \
|
||||||
|
-H "accept: application/json" > ${result_file}
|
||||||
|
jq < ${result_file}
|
||||||
|
}
|
||||||
|
|
||||||
adddeviceconfig() {
|
adddeviceconfig() {
|
||||||
payload="{\"deviceConfiguration\" : \"$2\"}";
|
payload="{\"deviceConfiguration\" : \"$2\"}";
|
||||||
curl ${FLAGS} -X PUT "https://${OWPROV}/api/v1/inventory/$1" \
|
curl ${FLAGS} -X PUT "https://${OWPROV}/api/v1/inventory/$1" \
|
||||||
@@ -448,6 +456,7 @@ case "$1" in
|
|||||||
"tree") login; tree ; logout;;
|
"tree") login; tree ; logout;;
|
||||||
"importtree") login; importtree $2; logout;;
|
"importtree") login; importtree $2; logout;;
|
||||||
"deviceconfig") login; deviceconfig "$2"; logout;;
|
"deviceconfig") login; deviceconfig "$2"; logout;;
|
||||||
|
"devicefwoptions") login; devicefwoptions "$2"; logout;;
|
||||||
"addtag") login; addtag "$2"; logout;;
|
"addtag") login; addtag "$2"; logout;;
|
||||||
"unassigntag") login; unassigntag $2; logout;;
|
"unassigntag") login; unassigntag $2; logout;;
|
||||||
"addunassignedtag") login; addunassignedtag $2 ; logout;;
|
"addunassignedtag") login; addunassignedtag $2 ; logout;;
|
||||||
|
|||||||
Reference in New Issue
Block a user