Yunpeng Zhang | 0048cf4 | 2017-08-15 23:01:28 -0400 | [diff] [blame] | 1 | import os |
| 2 | import sys |
| 3 | from django.db.models import Q, F |
| 4 | from synchronizers.new_base.SyncInstanceUsingAnsible import SyncInstanceUsingAnsible |
| 5 | from synchronizers.new_base.modelaccessor import * |
| 6 | |
| 7 | parentdir = os.path.join(os.path.dirname(__file__), "..") |
| 8 | sys.path.insert(0, parentdir) |
| 9 | |
| 10 | class SyncVPGWUTenant(SyncInstanceUsingAnsible): |
| 11 | |
| 12 | provides = [VPGWUTenant] |
| 13 | |
| 14 | observes = VPGWUTenant |
| 15 | |
| 16 | requested_interval = 0 |
| 17 | |
| 18 | template_name = "vpgwutenant_playbook.yaml" |
| 19 | |
| 20 | service_key_name = "/opt/xos/configurations/mcord/mcord_private_key" |
| 21 | |
| 22 | def __init__(self, *args, **kwargs): |
| 23 | super(SyncVPGWUTenant, self).__init__(*args, **kwargs) |
| 24 | |
| 25 | def fetch_pending(self, deleted): |
| 26 | |
| 27 | if (not deleted): |
| 28 | objs = VPGWUTenant.get_tenant_objects().filter( |
| 29 | Q(enacted__lt=F('updated')) | Q(enacted=None), Q(lazy_blocked=False)) |
| 30 | else: |
| 31 | |
| 32 | objs = VPGWUTenant.get_deleted_tenant_objects() |
| 33 | |
| 34 | return objs |
| 35 | |
| 36 | def get_extra_attributes(self, o): |
| 37 | fields = {} |
| 38 | fields['display_message'] = o.display_message |
| 39 | fields['s5s8_pgw_tag'] = o.s5s8_pgw_tag |
| 40 | fields['image_name'] = o.image_name |
| 41 | return fields |
| 42 | |
| 43 | def delete_record(self, port): |
| 44 | pass |