blob: 375c3a1e09bc93cdb268e1a3fa07c2ba6c408fbd [file] [log] [blame]
JianHaoce45e042017-01-16 11:06:29 +00001import os
2import sys
3from django.db.models import Q, F
4from services.vsgw.models import VSGWService, VSGWTenant
5from synchronizers.base.SyncInstanceUsingAnsible import SyncInstanceUsingAnsible
6
7parentdir = os.path.join(os.path.dirname(__file__), "..")
8sys.path.insert(0, parentdir)
9
10class SyncVSGWTenant(SyncInstanceUsingAnsible):
11
12 provides = [VSGWTenant]
13
14 observes = VSGWTenant
15
16 requested_interval = 0
17
18 template_name = "sync_vsgw.yaml"
19
20 service_key_name = "/opt/xos/synchronizers/vsgw/vsgw_private_key"
21
22 def __init__(self, *args, **kwargs):
23 super(SyncVSGWTenant, self).__init__(*args, **kwargs)
24
25 def fetch_pending(self, deleted):
26
27 if (not deleted):
28 objs = VSGWTenant.get_tenant_objects().filter(
29 Q(enacted__lt=F('updated')) | Q(enacted=None), Q(lazy_blocked=False))
30 else:
31 # If this is a deletion we get all of the deleted tenants..
32 objs = VSGWTenant.get_deleted_tenant_objects()
33
34 return objs
35
36 def get_extra_attributes(self, o):
37 fields = {}
38 fields['tenant_message'] = o.tenant_message
Saleil Bhat42e8c5e2017-02-01 15:59:54 -080039 fields['image_name'] = o.image_name
JianHaoce45e042017-01-16 11:06:29 +000040 return fields
41