Pingping Lin | d28ab98 | 2016-08-29 18:42:52 +0000 | [diff] [blame] | 1 | import os |
| 2 | import sys |
| 3 | from django.db.models import Q, F |
Pingping Lin | 99ed559 | 2016-09-01 01:41:34 +0000 | [diff] [blame] | 4 | from services.vbbu.models import MCORDService, VBBUComponent |
Pingping Lin | d28ab98 | 2016-08-29 18:42:52 +0000 | [diff] [blame] | 5 | from synchronizers.base.SyncInstanceUsingAnsible import SyncInstanceUsingAnsible |
| 6 | |
| 7 | parentdir = os.path.join(os.path.dirname(__file__), "..") |
| 8 | sys.path.insert(0, parentdir) |
| 9 | |
| 10 | class SyncVBBUComponent(SyncInstanceUsingAnsible): |
| 11 | |
| 12 | provides = [VBBUComponent] |
| 13 | |
| 14 | observes = VBBUComponent |
| 15 | |
| 16 | requested_interval = 0 |
| 17 | |
| 18 | template_name = "sync_vbbu.yaml" |
| 19 | |
| 20 | service_key_name = "/opt/xos/configurations/mcord/mcord_private_key" |
| 21 | |
| 22 | def __init__(self, *args, **kwargs): |
| 23 | super(SyncVBBUComponent, self).__init__(*args, **kwargs) |
| 24 | |
| 25 | def fetch_pending(self, deleted): |
| 26 | |
| 27 | if (not deleted): |
| 28 | objs = VBBUComponent.get_tenant_objects().filter( |
| 29 | Q(enacted__lt=F('updated')) | Q(enacted=None), Q(lazy_blocked=False)) |
| 30 | else: |
| 31 | |
| 32 | objs = VBBUComponent.get_deleted_tenant_objects() |
| 33 | |
| 34 | return objs |
| 35 | |
| 36 | def get_extra_attributes(self, o): |
| 37 | return {"display_message": o.display_message, "s1u_tag": o.s1u_tag, "s1mme_tag": o.s1mme_tag, "rru_tag": o.rru_tag} |