add --noobserver option to manage.py
diff --git a/planetstack/manage.py b/planetstack/manage.py
index ce14cdb..4a7e2df 100644
--- a/planetstack/manage.py
+++ b/planetstack/manage.py
@@ -12,4 +12,9 @@
model_policy.EnableModelPolicy(False)
sys.argv.remove("--nomodelpolicy")
+ if "--noobserver" in sys.argv:
+ import observer
+ observer.EnableObserver(False)
+ sys.argv.remove("--noobserver")
+
execute_from_command_line(sys.argv)
diff --git a/planetstack/openstack_observer/__init__.py b/planetstack/openstack_observer/__init__.py
index d9a63be..5d6ea79 100644
--- a/planetstack/openstack_observer/__init__.py
+++ b/planetstack/openstack_observer/__init__.py
@@ -5,28 +5,32 @@
except:
observer_disabled = False
+def EnableObserver(x):
+ """ used for manage.py --noobserver """
+ global observer_disabled
+ observer_disabled = not x
+
print_once = True
-if (not observer_disabled):
- from .event_manager import EventSender
-
- def notify_observer(model=None, delete=False, pk=None, model_dict={}):
- try:
- if (model and delete):
- if hasattr(model,"__name__"):
- modelName = model.__name__
- else:
- modelName = model.__class__.__name__
- EventSender().fire(delete_flag = delete, model = modelName, pk = pk, model_dict=model_dict)
- else:
- EventSender().fire()
- except Exception,e:
- print "Exception in Observer. This should not disrupt the front end. %s"%str(e)
-
-else:
- def notify_observer(model=None, delete=False, pk=None, model_dict={}):
+def notify_observer(model=None, delete=False, pk=None, model_dict={}):
+ if (observer_disabled):
global print_once
if (print_once):
print "The observer is disabled"
print_once = False
return
+
+ try:
+ from .event_manager import EventSender
+ if (model and delete):
+ if hasattr(model,"__name__"):
+ modelName = model.__name__
+ else:
+ modelName = model.__class__.__name__
+ EventSender().fire(delete_flag = delete, model = modelName, pk = pk, model_dict=model_dict)
+ else:
+ EventSender().fire()
+ except Exception,e:
+ print "Exception in Observer. This should not disrupt the front end. %s"%str(e)
+
+
diff --git a/planetstack/scripts/opencloud b/planetstack/scripts/opencloud
old mode 100755
new mode 100644
index 7811483..54852b9
--- a/planetstack/scripts/opencloud
+++ b/planetstack/scripts/opencloud
@@ -48,7 +48,7 @@
python /opt/planetstack/manage.py syncdb --noinput
if [[ $DJANGO_17 ]]; then
echo "Loading initial data from fixture..."
- python /opt/planetstack/manage.py --nomodelpolicy loaddata /opt/planetstack/core/fixtures/initial_data.json
+ python /opt/planetstack/manage.py --noobserver --nomodelpolicy loaddata /opt/planetstack/core/fixtures/initial_data.json
fi
}
function evolvedb {