Matteo Scandolo | f5e1033 | 2017-08-08 13:05:25 -0700 | [diff] [blame] | 1 | |
| 2 | # Copyright 2017-present Open Networking Foundation |
| 3 | # |
| 4 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | # you may not use this file except in compliance with the License. |
| 6 | # You may obtain a copy of the License at |
| 7 | # |
| 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | # |
| 10 | # Unless required by applicable law or agreed to in writing, software |
| 11 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | # See the License for the specific language governing permissions and |
| 14 | # limitations under the License. |
| 15 | |
| 16 | |
Andy Bavier | 89a9542 | 2016-11-02 14:38:39 -0400 | [diff] [blame] | 17 | import os |
| 18 | import base64 |
| 19 | from django.db.models import F, Q |
| 20 | from xos.config import Config |
| 21 | from core.models.role import Role |
| 22 | from core.models.site import SiteRole, Controller, ControllerRole |
| 23 | from core.models.slice import SliceRole |
| 24 | from xos.logger import observer_logger as logger |
Sapan Bhatia | b8e981d | 2017-01-24 19:32:59 +0100 | [diff] [blame] | 25 | from synchronizers.base.ansible_helper import * |
Andy Bavier | 89a9542 | 2016-11-02 14:38:39 -0400 | [diff] [blame] | 26 | from synchronizers.base.syncstep import * |
| 27 | |
| 28 | class SyncRoles(SyncStep): |
| 29 | provides=[Role] |
| 30 | requested_interval=0 |
| 31 | observes=[SiteRole,SliceRole,ControllerRole] |
| 32 | |
| 33 | def sync_record(self, role): |
| 34 | if not role.enacted: |
| 35 | controllers = Controller.objects.all() |
| 36 | """ |
| 37 | for controller in controllers: |
| 38 | driver = self.driver.admin_driver(controller=controller) |
| 39 | driver.create_role(role.role) |
| 40 | """ |
| 41 | role.save() |
| 42 | |