Andy Bavier | 89a9542 | 2016-11-02 14:38:39 -0400 | [diff] [blame] | 1 | import os |
| 2 | import base64 |
| 3 | from django.db.models import F, Q |
| 4 | from xos.config import Config |
| 5 | from core.models.role import Role |
| 6 | from core.models.site import SiteRole, Controller, ControllerRole |
| 7 | from core.models.slice import SliceRole |
| 8 | from xos.logger import observer_logger as logger |
Sapan Bhatia | b8e981d | 2017-01-24 19:32:59 +0100 | [diff] [blame] | 9 | from synchronizers.base.ansible_helper import * |
Andy Bavier | 89a9542 | 2016-11-02 14:38:39 -0400 | [diff] [blame] | 10 | from synchronizers.base.syncstep import * |
| 11 | |
| 12 | class SyncRoles(SyncStep): |
| 13 | provides=[Role] |
| 14 | requested_interval=0 |
| 15 | observes=[SiteRole,SliceRole,ControllerRole] |
| 16 | |
| 17 | def sync_record(self, role): |
| 18 | if not role.enacted: |
| 19 | controllers = Controller.objects.all() |
| 20 | """ |
| 21 | for controller in controllers: |
| 22 | driver = self.driver.admin_driver(controller=controller) |
| 23 | driver.create_role(role.role) |
| 24 | """ |
| 25 | role.save() |
| 26 | |