blob: 428c7e325b27da8d7ea0317186f0ce73b523b087 [file] [log] [blame]
Scott Bakeraf599eb2017-03-21 12:43:26 -07001from synchronizers.new_base.modelaccessor import *
Scott Baker46a3ee92017-05-30 16:44:56 -07002from synchronizers.new_base.policy import Policy
Scott Bakeraf599eb2017-03-21 12:43:26 -07003
Scott Baker46a3ee92017-05-30 16:44:56 -07004class SlicePrivilegePolicy(Policy):
5 model_name = "SlicePrivilege"
6
7 def handle_create(self, slice_privilege):
8 return self.handle_update(slice_privilege)
9
10 def handle_update(self, slice_privilege):
11 # slice_privilege = SlicePrivilege.get(slice_privilege_id)
12 # apply slice privilage at all controllers
13 controller_slice_privileges = ControllerSlicePrivilege.objects.filter(
14 slice_privilege = slice_privilege,
15 )
16 existing_controllers = [sp.controller for sp in controller_slice_privileges]
17 all_controllers = Controller.objects.all()
18 for controller in all_controllers:
19 if controller not in existing_controllers:
20 ctrl_slice_priv = ControllerSlicePrivilege(controller=controller, slice_privilege=slice_privilege)
21 ctrl_slice_priv.save()
Scott Bakerb63ea792016-08-11 10:24:48 -070022