blob: bbfc0a8c20d4def357b97433d15f2fd1d5676d4f [file] [log] [blame]
Pingping Lind07e26c2016-09-06 23:06:01 +00001import os
2import sys
3from django.db.models import Q, F
Pingping Linc537fd92017-01-17 20:52:09 -08004from services.vpgwc.models import VPGWCService, VPGWCTenant
Pingping Lind07e26c2016-09-06 23:06:01 +00005from synchronizers.base.SyncInstanceUsingAnsible import SyncInstanceUsingAnsible
6
7parentdir = os.path.join(os.path.dirname(__file__), "..")
8sys.path.insert(0, parentdir)
9
Pingping Linc537fd92017-01-17 20:52:09 -080010class SyncVPGWCTenant(SyncInstanceUsingAnsible):
Pingping Lind07e26c2016-09-06 23:06:01 +000011
Pingping Linc537fd92017-01-17 20:52:09 -080012 provides = [VPGWCTenant]
Pingping Lind07e26c2016-09-06 23:06:01 +000013
Pingping Linc537fd92017-01-17 20:52:09 -080014 observes = VPGWCTenant
Pingping Lind07e26c2016-09-06 23:06:01 +000015
16 requested_interval = 0
17
18 template_name = "sync_vpgwc.yaml"
19
20 service_key_name = "/opt/xos/configurations/mcord/mcord_private_key"
21
22 def __init__(self, *args, **kwargs):
Pingping Linc537fd92017-01-17 20:52:09 -080023 super(SyncVPGWCTenant, self).__init__(*args, **kwargs)
Pingping Lind07e26c2016-09-06 23:06:01 +000024
25 def fetch_pending(self, deleted):
26
27 if (not deleted):
Pingping Linc537fd92017-01-17 20:52:09 -080028 objs = VPGWCTenant.get_tenant_objects().filter(
Pingping Lind07e26c2016-09-06 23:06:01 +000029 Q(enacted__lt=F('updated')) | Q(enacted=None), Q(lazy_blocked=False))
30 else:
31
Pingping Linc537fd92017-01-17 20:52:09 -080032 objs = VPGWCTenant.get_deleted_tenant_objects()
Pingping Lind07e26c2016-09-06 23:06:01 +000033
34 return objs
35
Pingping Linc537fd92017-01-17 20:52:09 -080036 # Gets the attributes that are used by the Ansible template but are not
37 # part of the set of default attributes.
Pingping Lind07e26c2016-09-06 23:06:01 +000038 def get_extra_attributes(self, o):
39 return {"display_message": o.display_message, "s5s8_pgw_tag": o.s5s8_pgw_tag}