Added new model policies for images and controllerslices
diff --git a/planetstack/model_policies/__init__.py b/planetstack/model_policies/__init__.py
index f1c8071..cfcbe8f 100644
--- a/planetstack/model_policies/__init__.py
+++ b/planetstack/model_policies/__init__.py
@@ -4,3 +4,6 @@
from .model_policy_Site import *
from .model_policy_SitePrivilege import *
from .model_policy_SlicePrivilege import *
+from .model_policy_ControllerSlice import *
+from .model_policy_Controller import *
+from .model_policy_Image import *
diff --git a/planetstack/model_policies/model_policy_ControllerSlice.py b/planetstack/model_policies/model_policy_ControllerSlice.py
new file mode 100644
index 0000000..a7f6c9a
--- /dev/null
+++ b/planetstack/model_policies/model_policy_ControllerSlice.py
@@ -0,0 +1,16 @@
+def handle(controller_slice):
+ from core.models import ControllerSlice, Slice
+
+ try:
+ my_status_code = int(controller_slice.backend_status[0])
+ try:
+ his_status_code = int(controller_slice.slice.backend_status[0])
+ except:
+ his_status_code = 0
+
+ print "My: %d His: %d"%(my_status_code, his_status_code)
+ if (my_status_code not in [0,his_status_code]):
+ controller_slice.slice.backend_status = controller_slice.backend_status
+ except Exception,e:
+ print str(e)
+ pass
diff --git a/planetstack/model_policies/model_policy_Image.py b/planetstack/model_policies/model_policy_Image.py
new file mode 100644
index 0000000..72f76fa
--- /dev/null
+++ b/planetstack/model_policies/model_policy_Image.py
@@ -0,0 +1,13 @@
+def handle(image):
+ from core.models import Controller, ControllerImages, Image
+ from collections import defaultdict
+
+ controller_images = ControllerImages.objects.filter(image=image)
+ existing_controllers = [cs.controller for cs in controller_images]
+
+ all_controllers = Controller.objects.all()
+ for controller in all_controllers:
+ if controller not in existing_controllers:
+ sd = ControllerImages(image=image, controller=controller)
+ sd.save()
+