Scott Baker | b63ea79 | 2016-08-11 10:24:48 -0700 | [diff] [blame] | 1 | import os |
| 2 | import base64 |
| 3 | from django.db.models import F, Q |
| 4 | from xos.config import Config |
Scott Baker | 8b75e85 | 2016-08-16 15:04:59 -0700 | [diff] [blame^] | 5 | from synchronizers.openstack.openstacksyncstep import OpenStackSyncStep |
Scott Baker | b63ea79 | 2016-08-11 10:24:48 -0700 | [diff] [blame] | 6 | from core.models.role import Role |
| 7 | from core.models.site import SiteRole, Controller, ControllerRole |
| 8 | from core.models.slice import SliceRole |
| 9 | from xos.logger import observer_logger as logger |
| 10 | |
| 11 | class SyncRoles(OpenStackSyncStep): |
| 12 | provides=[Role] |
| 13 | requested_interval=0 |
| 14 | observes=[SiteRole,SliceRole,ControllerRole] |
| 15 | |
| 16 | def sync_record(self, role): |
| 17 | if not role.enacted: |
| 18 | controllers = Controller.objects.all() |
| 19 | for controller in controllers: |
| 20 | driver = self.driver.admin_driver(controller=controller) |
| 21 | driver.create_role(role.role) |
| 22 | role.save() |
| 23 | |