mirror of
https://github.com/Telecominfraproject/wlan-cloud-owprov.git
synced 2025-11-01 19:17:47 +00:00
Signed-off-by: stephb9959 <stephane.bourque@gmail.com>
This commit is contained in:
9
.github/workflows/cleanup.yml
vendored
9
.github/workflows/cleanup.yml
vendored
@@ -4,6 +4,7 @@ on:
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
- 'release/*'
|
||||
types: [ closed ]
|
||||
|
||||
defaults:
|
||||
@@ -16,4 +17,10 @@ jobs:
|
||||
steps:
|
||||
- run: |
|
||||
export PR_BRANCH_TAG=$(echo ${GITHUB_HEAD_REF#refs/heads/} | tr '/' '-')
|
||||
curl -uucentral:${{ secrets.DOCKER_REGISTRY_PASSWORD }} -X DELETE "https://tip.jfrog.io/artifactory/tip-wlan-cloud-ucentral/owprov/$PR_BRANCH_TAG"
|
||||
|
||||
if [[ ! $PR_BRANCH_TAG =~ (main|master|release-*) ]]; then
|
||||
echo "PR branch is $PR_BRANCH_TAG, deleting Docker image"
|
||||
curl -s -uucentral:${{ secrets.DOCKER_REGISTRY_PASSWORD }} -X DELETE "https://tip.jfrog.io/artifactory/tip-wlan-cloud-ucentral/owprov/$PR_BRANCH_TAG"
|
||||
else
|
||||
echo "PR branch is $PR_BRANCH_TAG, not deleting Docker image"
|
||||
fi
|
||||
|
||||
@@ -213,21 +213,45 @@ namespace OpenWifi {
|
||||
return true;
|
||||
};
|
||||
|
||||
auto FixEntityDevices = [&](const ProvObjects::Entity &E) -> bool {
|
||||
auto FixEntity = [&](const ProvObjects::Entity &E) -> bool {
|
||||
Types::UUIDvec_t NewDevices;
|
||||
bool Modified=false;
|
||||
for(const auto &device:E.devices) {
|
||||
ProvObjects::InventoryTag T;
|
||||
if(InventoryDB().GetRecord("id", device, T)) {
|
||||
NewDevices.emplace_back(device);
|
||||
} else {
|
||||
|
||||
Modified=true;
|
||||
}
|
||||
}
|
||||
|
||||
if(NewDevices!=E.devices) {
|
||||
Types::UUIDvec_t NewContacts;
|
||||
for(const auto &contact:E.contacts) {
|
||||
ProvObjects::Contact C;
|
||||
if(ContactDB().GetRecord("id", contact, C)) {
|
||||
NewContacts.emplace_back(contact);
|
||||
} else {
|
||||
Modified=true;
|
||||
}
|
||||
}
|
||||
|
||||
Types::UUIDvec_t NewLocations;
|
||||
for(const auto &location:E.locations) {
|
||||
ProvObjects::Location L;
|
||||
if(LocationDB().GetRecord("id", location, L)) {
|
||||
NewLocations.emplace_back(location);
|
||||
} else {
|
||||
Modified=true;
|
||||
}
|
||||
}
|
||||
|
||||
if(Modified)
|
||||
{
|
||||
Logger().warning(fmt::format(" fixing entity: {}",E.info.name));
|
||||
ProvObjects::Entity NewEntity = E;
|
||||
NewEntity.devices = NewDevices;
|
||||
NewEntity.contacts = NewContacts;
|
||||
NewEntity.locations = NewLocations;
|
||||
EntityDB().UpdateRecord("id", E.info.id, NewEntity);
|
||||
}
|
||||
return true;
|
||||
@@ -236,7 +260,7 @@ namespace OpenWifi {
|
||||
Logger().information("Checking DB consistency: venues");
|
||||
VenueDB().Iterate(FixVenueDevices);
|
||||
Logger().information("Checking DB consistency: entities");
|
||||
EntityDB().Iterate(FixEntityDevices);
|
||||
EntityDB().Iterate(FixEntity);
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user