JianHao | 4a9550f | 2017-10-19 11:05:14 +0800 | [diff] [blame] | 1 | # Copyright 2017-present Open Networking Foundation |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
| 14 | |
| 15 | import os |
| 16 | import sys |
| 17 | from django.db.models import Q, F |
| 18 | from synchronizers.new_base.modelaccessor import * |
| 19 | from synchronizers.new_base.SyncInstanceUsingAnsible import SyncInstanceUsingAnsible |
| 20 | |
| 21 | parentdir = os.path.join(os.path.dirname(__file__), "..") |
| 22 | sys.path.insert(0, parentdir) |
| 23 | |
| 24 | class SyncVSPGWCTenant(SyncInstanceUsingAnsible): |
| 25 | provides = [VSPGWCTenant] |
| 26 | |
| 27 | observes = VSPGWCTenant |
| 28 | |
| 29 | requested_interval = 0 |
| 30 | |
| 31 | template_name = "vspgwctenant_playbook.yaml" |
| 32 | |
| 33 | service_key_name = "/opt/xos/configurations/mcord/mcord_private_key" |
| 34 | |
| 35 | def __init__(self, *args, **kwargs): |
| 36 | super(SyncVSPGWCTenant, self).__init__(*args, **kwargs) |
| 37 | |
| 38 | # Gets the attributes that are used by the Ansible template but are not |
| 39 | # part of the set of default attribtues. |
| 40 | #def get_extra_attributes(self, o): |
| 41 | # fields = {} |
| 42 | # shared_net_id = Network.objects.get(name='shared_network').id |
| 43 | |
| 44 | #try: |
| 45 | # fields['sgwc_shared_ip'] = Port.objects.get(network_id=shared_net_id, instance_id=o.instance_id).ip |
| 46 | # except Exception: |
| 47 | # print '{} does not have an instance'.format(o.name) |
| 48 | |
| 49 | # try: |
| 50 | # mme = TenantWithContainer.objects.get(provider_service_id=Service.objects.get(name='vmme').id, subscriber_tenant_id=o.subscriber_tenant_id) |
| 51 | # fields['mme_shared_ip'] = Port.objects.get(network_id=shared_net_id, instance_id=mme.instance_id).ip |
| 52 | #except Exception: |
| 53 | # print '{} does not have a VMME instance'.format(o.subscriber_tenant.name) |
| 54 | |
| 55 | # try: |
| 56 | # sgwu = TenantWithContainer.objects.get(provider_service_id=Service.objects.get(name='vspgwu').id, subscriber_tenant_id=o.subscriber_tenant_id) |
| 57 | # fields['sgwu_shared_ip'] = Port.objects.get(network_id=shared_net_id, instance_id=sgwu.instance_id).ip |
| 58 | # except Exception: |
| 59 | # print '{} does not have a VSPGWU instance'.format(o.subscriber_tenant.name) |
| 60 | |
| 61 | # return fields |