mirror of
https://github.com/Telecominfraproject/wlan-cloud-owprov.git
synced 2025-10-29 09:42:38 +00:00
Adding tree import.
This commit is contained in:
@@ -225,13 +225,13 @@ namespace OpenWifi{
|
||||
bool UnAssign=false;
|
||||
if(HasParameter("unassign", Arg) && Arg=="true") {
|
||||
UnAssign=true;
|
||||
if(!NewVenue.empty() && ExistingObject.venue!=NewVenue) {
|
||||
if(!ExistingObject.venue.empty()) {
|
||||
Storage()->VenueDB().DeleteDevice("id",ExistingObject.venue,ExistingObject.info.id);
|
||||
}
|
||||
|
||||
if(!NewEntity.empty() && ExistingObject.entity!=NewEntity) {
|
||||
} else if(!ExistingObject.entity.empty()) {
|
||||
Storage()->EntityDB().DeleteDevice("id",ExistingObject.venue,ExistingObject.info.id);
|
||||
}
|
||||
ExistingObject.venue.clear();
|
||||
ExistingObject.entity.clear();
|
||||
}
|
||||
|
||||
AssignIfPresent(RawObject, "name", ExistingObject.info.name);
|
||||
@@ -239,25 +239,22 @@ namespace OpenWifi{
|
||||
ExistingObject.info.modified = std::time(nullptr);
|
||||
|
||||
if(Storage()->InventoryDB().UpdateRecord("id", ExistingObject.info.id, ExistingObject)) {
|
||||
if(UnAssign) {
|
||||
if(!NewEntity.empty() && NewEntity!=ExistingObject.entity) {
|
||||
if(!UnAssign && !NewEntity.empty() && NewEntity!=ExistingObject.entity) {
|
||||
Storage()->EntityDB().DeleteDevice("id",ExistingObject.entity,ExistingObject.info.id);
|
||||
Storage()->EntityDB().AddDevice("id",NewEntity,ExistingObject.info.id);
|
||||
ExistingObject.entity = NewEntity;
|
||||
ExistingObject.venue.clear();
|
||||
}
|
||||
|
||||
if(!NewVenue.empty() && NewVenue!=ExistingObject.venue) {
|
||||
} else if(!UnAssign && !NewVenue.empty() && NewVenue!=ExistingObject.venue) {
|
||||
Storage()->VenueDB().DeleteDevice("id",ExistingObject.venue,ExistingObject.info.id);
|
||||
Storage()->VenueDB().AddDevice("id",NewVenue,ExistingObject.info.id);
|
||||
ExistingObject.venue = NewVenue;
|
||||
ExistingObject.entity.clear();
|
||||
ExistingObject.venue = NewVenue;
|
||||
}
|
||||
Storage()->InventoryDB().UpdateRecord("id", ExistingObject.info.id, ExistingObject);
|
||||
}
|
||||
|
||||
Storage()->InventoryDB().GetRecord("id", ExistingObject.info.id, ExistingObject);
|
||||
|
||||
ProvObjects::InventoryTag NewObject;
|
||||
Storage()->InventoryDB().GetRecord("id", ExistingObject.info.id, NewObject);
|
||||
Poco::JSON::Object Answer;
|
||||
ExistingObject.to_json(Answer);
|
||||
NewObject.to_json(Answer);
|
||||
ReturnObject(Request, Answer, Response);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -321,6 +321,16 @@ listconfigs() {
|
||||
jq < ${result_file}
|
||||
}
|
||||
|
||||
deviceconfig() {
|
||||
gettag() {
|
||||
curl ${FLAGS} "https://${OWPROV}/api/v1/inventory/$1?config=true" \
|
||||
-H "Content-Type: application/json" \
|
||||
-H "Authorization: Bearer ${token}" \
|
||||
-H "accept: application/json" > ${result_file}
|
||||
jq < ${result_file}
|
||||
}
|
||||
}
|
||||
|
||||
shopt -s nocasematch
|
||||
case "$1" in
|
||||
"login") login; help ; logout ;;
|
||||
@@ -332,6 +342,7 @@ case "$1" in
|
||||
"entitycount") login; entitycount ; logout;;
|
||||
"tree") login; tree ; logout;;
|
||||
"importtree") login; importtree $2; logout;;
|
||||
"deviceconfig") login; deviceconfig $2; logout;;
|
||||
"addtag") login; addtag $2 $3; logout;;
|
||||
"unassigntag") login; unassigntag $2; logout;;
|
||||
"addunassignedtag") login; addunassignedtag $2 ; logout;;
|
||||
|
||||
Reference in New Issue
Block a user