X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=planetstack%2Fhpc_observer%2Fsteps%2Fsync_cdnprefix.py;h=b773df96d1855b1070aea6eea19c6e5a5388cd90;hb=0d718ab944fcf3a7a943e3652fa9746529510d78;hp=adb95db75632b8ba959ed5f66741bf7a90f50282;hpb=6f97fe90552b95f8f1398147a804e8da83f327a3;p=plstackapi.git diff --git a/planetstack/hpc_observer/steps/sync_cdnprefix.py b/planetstack/hpc_observer/steps/sync_cdnprefix.py index adb95db..b773df9 100644 --- a/planetstack/hpc_observer/steps/sync_cdnprefix.py +++ b/planetstack/hpc_observer/steps/sync_cdnprefix.py @@ -24,6 +24,20 @@ class SyncCDNPrefix(SyncStep, HpcLibrary): SyncStep.__init__(self, **args) HpcLibrary.__init__(self) + def fetch_pending(self, deleted): + self.sanity_check() + + return SyncStep.fetch_pending(self, deleted) + + def sanity_check(self): + # sanity check to make sure our PS objects have CMI objects behind them + all_p_ids = [x["cdn_prefix_id"] for x in self.client.onev.ListAll("CDNPrefix")] + for p in CDNPrefix.objects.all(): + if (p.cdn_prefix_id is not None) and (p.cdn_prefix_id not in all_p_ids): + logger.info("CDN Prefix %s was not found on CMI" % p.cdn_prefix_id) + p.cdn_prefix_id=None + p.save() + def sync_record(self, cp): logger.info("sync'ing cdn prefix %s" % str(cp))