blob: f93e7f7ff77021e0c347905908818285c4b99ed5 [file] [log] [blame]
Yunpeng Zhangd01f3ce2017-07-06 20:06:35 -04001import os
2import sys
3from django.db.models import Q, F
4# from services.vbbu.models import MCORDService, VBBUTenant
5from synchronizers.new_base.modelaccessor import *
6from synchronizers.new_base.SyncInstanceUsingAnsible import SyncInstanceUsingAnsible
7
8parentdir = os.path.join(os.path.dirname(__file__), "..")
9sys.path.insert(0, parentdir)
10
11class SyncVBBUTenant(SyncInstanceUsingAnsible):
Yunpeng Zhangd01f3ce2017-07-06 20:06:35 -040012 provides = [VBBUTenant]
13
14 observes = VBBUTenant
15
16 requested_interval = 0
17
18 template_name = "vbbutenant_playbook.yaml"
19
20 service_key_name = "/opt/xos/configurations/mcord/mcord_private_key"
21
22 def __init__(self, *args, **kwargs):
23 super(SyncVBBUTenant, self).__init__(*args, **kwargs)
24
25 def fetch_pending(self, deleted):
Yunpeng Zhangd01f3ce2017-07-06 20:06:35 -040026 if (not deleted):
27 objs = VBBUTenant.get_tenant_objects().filter(
28 Q(enacted__lt=F('updated')) | Q(enacted=None), Q(lazy_blocked=False))
29 else:
Yunpeng Zhangd01f3ce2017-07-06 20:06:35 -040030 objs = VBBUTenant.get_deleted_tenant_objects()
31
32 return objs
33