Fixed import errors in model policies
diff --git a/planetstack/model_policies/model_policy_Controller.py b/planetstack/model_policies/model_policy_Controller.py
index 9415bb5..98eeaff 100644
--- a/planetstack/model_policies/model_policy_Controller.py
+++ b/planetstack/model_policies/model_policy_Controller.py
@@ -2,6 +2,10 @@
def handle(controller):
from core.models import Controller, Site, ControllerSite, Slice, ControllerSlice, User, ControllerUser
from collections import defaultdict
+
+ #controller = Controller.get(controller_id)
+
+
# relations for all sites
ctrls_by_site = defaultdict(list)
ctrl_sites = ControllerSite.objects.all()
@@ -12,7 +16,7 @@
if site not in ctrls_by_site or \
controller not in ctrls_by_site[site]:
controller_site = ControllerSite(controller=controller, site=site)
- controller_site.save()
+ controller_site.save()
# relations for all slices
ctrls_by_slice = defaultdict(list)
ctrl_slices = ControllerSlice.objects.all()
@@ -23,7 +27,7 @@
if slice not in ctrls_by_slice or \
controller not in ctrls_by_slice:
controller_slice = ControllerSlice(controller=controller, slice=slice)
- controller_slice.save()
+ controller_slice.save()
# relations for all users
ctrls_by_user = defaultdict(list)
ctrl_users = ControllerUser.objects.all()
@@ -34,8 +38,4 @@
if user not in ctrls_by_user or \
controller not in ctrls_by_user[user]:
controller_user = ControllerUser(controller=controller, user=user)
- controller_user.save()
-
-
-
-
+ controller_user.save()
diff --git a/planetstack/model_policies/model_policy_Network.py b/planetstack/model_policies/model_policy_Network.py
index f822bf2..8702d21 100644
--- a/planetstack/model_policies/model_policy_Network.py
+++ b/planetstack/model_policies/model_policy_Network.py
@@ -1,8 +1,10 @@
from core.models import *
def handle(network):
- from core.models import ControllerSlice,ControllerNetwork
+ from core.models import ControllerSlice,ControllerNetwork, Network
from collections import defaultdict
+
+ # network = Network.get(network_id)
# network controllers are not visible to users. We must ensure
# networks are deployed at all deploymets available to their slices.
slice_controllers = ControllerSlice.objects.all()
diff --git a/planetstack/model_policies/model_policy_Site.py b/planetstack/model_policies/model_policy_Site.py
index 7d96264..23010a2 100644
--- a/planetstack/model_policies/model_policy_Site.py
+++ b/planetstack/model_policies/model_policy_Site.py
@@ -1,6 +1,8 @@
def handle(site):
- from core.models import Controller, ControllerSite
+ from core.models import Controller, ControllerSite, Site
+
+ # site = Site.get(site_id)
# make sure site has a ControllerSite record for each controller
ctrl_sites = ControllerSite.objects.filter(site=site)
existing_controllers = [cs.controller for cs in ctrl_sites]
diff --git a/planetstack/model_policies/model_policy_SitePrivilege.py b/planetstack/model_policies/model_policy_SitePrivilege.py
index 90280a3..6e9a65c 100644
--- a/planetstack/model_policies/model_policy_SitePrivilege.py
+++ b/planetstack/model_policies/model_policy_SitePrivilege.py
@@ -1,6 +1,7 @@
def handle(site_privilege):
from core.models import Controller, SitePrivilege, ControllerSitePrivilege
+ # site_privilege = SitePrivilege.get(site_privilege_id)
# apply site privilage at all controllers
controller_site_privileges = ControllerSitePrivilege.objects.filter(
site_privilege = site_privilege,
diff --git a/planetstack/model_policies/model_policy_Slice.py b/planetstack/model_policies/model_policy_Slice.py
index cc9f2b0..1f58570 100644
--- a/planetstack/model_policies/model_policy_Slice.py
+++ b/planetstack/model_policies/model_policy_Slice.py
@@ -1,7 +1,10 @@
def handle(slice):
- from core.models import Controller, ControllerSlice, SiteDeployment, Network, NetworkSlice,NetworkTemplate
+ from core.models import Controller, ControllerSlice, SiteDeployment, Network, NetworkSlice,NetworkTemplate, Slice
from collections import defaultdict
+
+ # slice = Slice.get(slice_id)
+
controller_slices = ControllerSlice.objects.filter(slice=slice)
existing_controllers = [cs.controller for cs in controller_slices]
diff --git a/planetstack/model_policies/model_policy_SlicePrivilege.py b/planetstack/model_policies/model_policy_SlicePrivilege.py
index 0f772cb..e58a973 100644
--- a/planetstack/model_policies/model_policy_SlicePrivilege.py
+++ b/planetstack/model_policies/model_policy_SlicePrivilege.py
@@ -1,6 +1,7 @@
def handle(slice_privilege):
from core.models import Controller, SlicePrivilege, ControllerSlicePrivilege
-
+
+ # slice_privilege = SlicePrivilege.get(slice_privilege_id)
# apply slice privilage at all controllers
controller_slice_privileges = ControllerSlicePrivilege.objects.filter(
slice_privilege = slice_privilege,
diff --git a/planetstack/model_policies/model_policy_User.py b/planetstack/model_policies/model_policy_User.py
index b7b16ad..8d14244 100644
--- a/planetstack/model_policies/model_policy_User.py
+++ b/planetstack/model_policies/model_policy_User.py
@@ -1,6 +1,8 @@
def handle(user):
- from core.models import Controller, ControllerSite, ControllerUser
+ from core.models import Controller, ControllerSite, ControllerUser, User
from collections import defaultdict
+
+ # user = User.get(user_id)
controller_users = ControllerUser.objects.filter(user=user)
existing_controllers = [cu.controller for cu in controller_users]