blob: ffc6eb80c11984d9fa3ac3cde534c59f120de224 [file] [log] [blame]
Sapan Bhatia24836f12013-08-27 10:16:05 -04001import os
2import base64
Tony Mackae7f30c2013-09-25 12:46:50 -04003from django.db.models import F, Q
Sapan Bhatia24836f12013-08-27 10:16:05 -04004from planetstack.config import Config
Sapan Bhatia04c94ad2013-09-02 18:00:28 -04005from observer.openstacksyncstep import OpenStackSyncStep
6from core.models.slice import *
Sapan Bhatia24836f12013-08-27 10:16:05 -04007
8class SyncSliceMemberships(OpenStackSyncStep):
Tony Mackce79de02013-09-24 10:12:33 -04009 requested_interval=0
Tony Mack66646d52013-09-24 21:47:12 -040010 provides=[SlicePrivilege]
11
12 def fetch_pending(self):
13 return SlicePrivilege.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None))
14
Tony Mack37146d22013-10-21 11:02:51 -040015 def sync_record(self, slice_memb):
Tony Mackce79de02013-09-24 10:12:33 -040016 if slice_memb.user.kuser_id and slice_memb.slice.tenant_id:
17 self.driver.add_user_role(slice_memb.user.kuser_id,
18 slice_memb.slice.tenant_id,
Tony Mack00367072013-10-08 18:09:30 -040019 slice_memb.role.role)