Merge branch 'master' of ssh://git.planet-lab.org/git/plstackapi
diff --git a/planetstack/core/models/plcorebase.py b/planetstack/core/models/plcorebase.py
index d461c9d..4263f94 100644
--- a/planetstack/core/models/plcorebase.py
+++ b/planetstack/core/models/plcorebase.py
@@ -98,25 +98,31 @@
def delete(self, *args, **kwds):
# so we have something to give the observer
purge = kwds.get('purge',False)
+ silent = kwds.get('silent',False)
try:
purge = purge or observer_disabled
except NameError:
pass
-
+
if (purge):
del kwds['purge']
super(PlCoreBase, self).delete(*args, **kwds)
else:
self.deleted = True
self.enacted=None
- self.save(update_fields=['enacted','deleted'])
-
+ self.save(update_fields=['enacted','deleted'], silent=silent)
def save(self, *args, **kwargs):
+ if "silent" in kwargs:
+ silent=kwargs.pop("silent")
+ else:
+ silent=False
+
super(PlCoreBase, self).save(*args, **kwargs)
# This is a no-op if observer_disabled is set
- notify_observer()
+ if not silent:
+ notify_observer()
self.__initial = self._dict
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 @@
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))
diff --git a/planetstack/hpc_observer/steps/sync_contentprovider.py b/planetstack/hpc_observer/steps/sync_contentprovider.py
index e10dca9..c7335d6 100644
--- a/planetstack/hpc_observer/steps/sync_contentprovider.py
+++ b/planetstack/hpc_observer/steps/sync_contentprovider.py
@@ -24,6 +24,20 @@
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_cp_ids = [x["content_provider_id"] for x in self.client.onev.ListAll("ContentProvider")]
+ for cp in ContentProvider.objects.all():
+ if (cp.content_provider_id is not None) and (cp.content_provider_id not in all_cp_ids):
+ logger.info("Content provider %s was not found on CMI" % cp.content_provider_id)
+ cp.content_provider_id=None
+ cp.save()
+
def sync_record(self, cp):
logger.info("sync'ing content provider %s" % str(cp))
account_name = self.make_account_name(cp.name)
diff --git a/planetstack/hpc_observer/steps/sync_originserver.py b/planetstack/hpc_observer/steps/sync_originserver.py
index 4f0ba4c..6fb6234 100644
--- a/planetstack/hpc_observer/steps/sync_originserver.py
+++ b/planetstack/hpc_observer/steps/sync_originserver.py
@@ -24,6 +24,23 @@
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_ors_ids = [x["origin_server_id"] for x in self.client.onev.ListAll("OriginServer")]
+ for ors in OriginServer.objects.all():
+ if (ors.origin_server_id is not None) and (ors.origin_server_id not in all_ors_ids):
+ # we have an origin server ID, but it doesn't exist in the CMI
+ # something went wrong
+ # start over
+ logger.info("origin server %s was not found on CMI" % ors.origin_server_id)
+ ors.origin_server_id=None
+ ors.save()
+
def sync_record(self, ors):
logger.info("sync'ing origin server %s" % str(ors))
diff --git a/planetstack/hpc_observer/steps/sync_serviceprovider.py b/planetstack/hpc_observer/steps/sync_serviceprovider.py
index 36f2689..19c6db3 100644
--- a/planetstack/hpc_observer/steps/sync_serviceprovider.py
+++ b/planetstack/hpc_observer/steps/sync_serviceprovider.py
@@ -24,6 +24,20 @@
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_sp_ids = [x["service_provider_id"] for x in self.client.onev.ListAll("ServiceProvider")]
+ for sp in ServiceProvider.objects.all():
+ if (sp.service_provider_id is not None) and (sp.service_provider_id not in all_sp_ids):
+ logger.info("Service provider %s was not found on CMI" % sp.service_provider_id)
+ sp.service_provider_id=None
+ sp.save()
+
def sync_record(self, sp):
logger.info("sync'ing service provider %s" % str(sp))
account_name = self.make_account_name(sp.name)