blob: 4bfa228b5b91e0c89871b9643f4722e411a1da15 [file] [log] [blame]
Matteo Scandolof5e10332017-08-08 13:05:25 -07001
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 Bavier89a95422016-11-02 14:38:39 -040017import os
18import base64
19from django.db.models import F, Q
20from xos.config import Config
21from core.models.role import Role
22from core.models.site import SiteRole, Controller, ControllerRole
23from core.models.slice import SliceRole
24from xos.logger import observer_logger as logger
Sapan Bhatiab8e981d2017-01-24 19:32:59 +010025from synchronizers.base.ansible_helper import *
Andy Bavier89a95422016-11-02 14:38:39 -040026from synchronizers.base.syncstep import *
27
28class 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