mirror of
https://github.com/Telecominfraproject/wlan-cloud-owprov.git
synced 2025-10-29 17:52:28 +00:00
Fixing firmware inheritance rules.
This commit is contained in:
@@ -43,6 +43,10 @@ namespace OpenWifi{
|
|||||||
}
|
}
|
||||||
Answer.set("entries", Inner);
|
Answer.set("entries", Inner);
|
||||||
return ReturnObject(Answer);
|
return ReturnObject(Answer);
|
||||||
|
} else if(HasParameter("computedAffected",Arg) && Arg=="true") {
|
||||||
|
Types::UUIDvec_t DeviceSerialNumbers;
|
||||||
|
DB_.GetListOfAffectedDevices(UUID,DeviceSerialNumbers);
|
||||||
|
return ReturnObject("affectedDevices", DeviceSerialNumbers);
|
||||||
} else if(QB_.AdditionalInfo) {
|
} else if(QB_.AdditionalInfo) {
|
||||||
AddExtendedInfo(Existing,Answer);
|
AddExtendedInfo(Existing,Answer);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@
|
|||||||
#include "framework/OpenWifiTypes.h"
|
#include "framework/OpenWifiTypes.h"
|
||||||
#include "framework/MicroService.h"
|
#include "framework/MicroService.h"
|
||||||
#include "RESTObjects/RESTAPI_SecurityObjects.h"
|
#include "RESTObjects/RESTAPI_SecurityObjects.h"
|
||||||
|
#include "StorageService.h"
|
||||||
|
|
||||||
namespace OpenWifi {
|
namespace OpenWifi {
|
||||||
|
|
||||||
@@ -42,6 +43,48 @@ namespace OpenWifi {
|
|||||||
|
|
||||||
ConfigurationDB::ConfigurationDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L) :
|
ConfigurationDB::ConfigurationDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L) :
|
||||||
DB(T, "configurations", ConfigurationDB_Fields, ConfigurationDB_Indexes, P, L, "cfg") {}
|
DB(T, "configurations", ConfigurationDB_Fields, ConfigurationDB_Indexes, P, L, "cfg") {}
|
||||||
|
|
||||||
|
bool ConfigurationDB::GetListOfAffectedDevices(const Types::UUID_t & ConfigUUID, Types::UUIDvec_t & DeviceSerialNumbers ) {
|
||||||
|
// find all the places where this configuration is used
|
||||||
|
// for each of them get the devices they oversee
|
||||||
|
ProvObjects::DeviceConfiguration Config;
|
||||||
|
if(!GetRecord("id",ConfigUUID,Config))
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if(Config.inUse.empty())
|
||||||
|
return true;
|
||||||
|
|
||||||
|
std::set<std::string> SerialNumbers;
|
||||||
|
for(const auto &i:Config.inUse) {
|
||||||
|
auto Tokens = Poco::StringTokenizer(i,":");
|
||||||
|
if(Tokens.count()!=2)
|
||||||
|
continue;
|
||||||
|
if(Tokens[0] == "ent") {
|
||||||
|
ProvObjects::Entity E;
|
||||||
|
if(!StorageService()->EntityDB().GetRecord("id",Tokens[1],E))
|
||||||
|
continue;
|
||||||
|
for(const auto &j:E.devices)
|
||||||
|
SerialNumbers.insert(j);
|
||||||
|
} else if (Tokens[0] == "ven") {
|
||||||
|
ProvObjects::Venue V;
|
||||||
|
if(!StorageService()->VenueDB().GetRecord("id",Tokens[1],V))
|
||||||
|
continue;
|
||||||
|
for(const auto &j:V.devices)
|
||||||
|
SerialNumbers.insert(j);
|
||||||
|
} else if (Tokens[0] == "inv") {
|
||||||
|
ProvObjects::InventoryTag T;
|
||||||
|
if(!StorageService()->InventoryDB().GetRecord("id",Tokens[1],T))
|
||||||
|
continue;
|
||||||
|
SerialNumbers.insert(T.serialNumber);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::for_each(cbegin(SerialNumbers),cend(SerialNumbers),
|
||||||
|
[&DeviceSerialNumbers](const std::string &S){ DeviceSerialNumbers.push_back(S); });
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
template<> void ORM::DB< OpenWifi::ConfigurationDBRecordType, OpenWifi::ProvObjects::DeviceConfiguration>::Convert(OpenWifi::ConfigurationDBRecordType &In, OpenWifi::ProvObjects::DeviceConfiguration &Out) {
|
template<> void ORM::DB< OpenWifi::ConfigurationDBRecordType, OpenWifi::ProvObjects::DeviceConfiguration>::Convert(OpenWifi::ConfigurationDBRecordType &In, OpenWifi::ProvObjects::DeviceConfiguration &Out) {
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ namespace OpenWifi {
|
|||||||
class ConfigurationDB : public ORM::DB<ConfigurationDBRecordType, ProvObjects::DeviceConfiguration> {
|
class ConfigurationDB : public ORM::DB<ConfigurationDBRecordType, ProvObjects::DeviceConfiguration> {
|
||||||
public:
|
public:
|
||||||
ConfigurationDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L);
|
ConfigurationDB( OpenWifi::DBType T, Poco::Data::SessionPool & P, Poco::Logger &L);
|
||||||
|
bool GetListOfAffectedDevices(const Types::UUID_t & ConfigUUID, Types::UUIDvec_t & DeviceSerialNumbers );
|
||||||
private:
|
private:
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -449,6 +449,15 @@ addresscheck() {
|
|||||||
wscat -c wss://${OWPROV}/api/v1/ws
|
wscat -c wss://${OWPROV}/api/v1/ws
|
||||||
}
|
}
|
||||||
|
|
||||||
|
affecteddevices() {
|
||||||
|
computedAffected
|
||||||
|
curl ${FLAGS} -X GET "https://${OWPROV}/api/v1/configurations/${1}?computedAffected=true" \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-H "Authorization: Bearer ${token}" \
|
||||||
|
-H "accept: application/json" > ${result_file}
|
||||||
|
jq < ${result_file}
|
||||||
|
}
|
||||||
|
|
||||||
shopt -s nocasematch
|
shopt -s nocasematch
|
||||||
case "$1" in
|
case "$1" in
|
||||||
"login") login; help ; logout ;;
|
"login") login; help ; logout ;;
|
||||||
|
|||||||
Reference in New Issue
Block a user