[AIM] Repair missing extension data when validating

If extension data records for networks or subnets are missing, the
gbp-validate tool will now fail, or attempt to repair them if repair
is enabled. For external Neutron networks, the DN of the ACI
ExternalNetwork must be supplied via the migrate_ext_net_dns configuration
option in the ml2_apic_aim group, which is a dictionary keyed by the
network_id.

Change-Id: I427596b9ea01140af44e9eaf415c82935c668ebe
This commit is contained in:
Robert Kukura
2018-08-19 09:50:54 -04:00
parent ac49921cff
commit 51796eab0c
5 changed files with 170 additions and 36 deletions

View File

@@ -132,10 +132,13 @@ class ValidationManager(object):
for resource in self.aim_mgr.find(
self.actual_aim_ctx, resource_class)}
def expect_aim_resource(self, resource, replace=False):
def expect_aim_resource(self, resource, replace=False, remove=False):
expected_resources = self._expected_aim_resources[resource.__class__]
key = tuple(resource.identity)
if not replace and key in expected_resources:
if remove:
del expected_resources[key]
return
elif not replace and key in expected_resources:
print("resource %s already expected" % resource)
raise InternalValidationError()
for attr_name, attr_type in resource.other_attributes.items():
@@ -339,7 +342,7 @@ class ValidationAimStore(aim_store.AimStore):
self._mgr.expect_aim_resource(db_obj, True)
def delete(self, db_obj):
assert(False)
self._mgr.expect_aim_resource(db_obj, remove=True)
def query(self, db_obj_type, resource_class, in_=None, notin_=None,
order_by=None, lock_update=False, **filters):