| from django.db.models import F, Q |
| from planetstack.config import Config |
| from observer.openstacksyncstep import OpenStackSyncStep |
| from core.models.role import Role |
| from core.models.site import SiteRole, Deployment, DeploymentRole |
| from core.models.slice import SliceRole |
| class SyncRoles(OpenStackSyncStep): |
| def fetch_pending(self, deleted): |
| # Deleting roles is not supported yet |
| site_roles = SiteRole.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None)) |
| slice_roles = SliceRole.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None)) |
| deployment_roles = DeploymentRole.objects.filter(Q(enacted__lt=F('updated')) | Q(enacted=None)) |
| for site_role in site_roles: |
| for slice_role in slice_roles: |
| for deployment_role in deployment_roles: |
| roles.append(deployment_role) |
| def sync_record(self, role): |
| deployments = Deployment.objects.all() |
| for deployment in deployments: |
| driver = self.driver.admin_driver(deployment=deployment.name) |
| driver.create_role(role.role) |