blob: 09b3c544458dad0ee75c57f9e8b91320f894222a [file] [log] [blame]
Andy Bavier0c564b32017-10-12 13:04:11 -07001
2# Copyright 2017-present Open Networking Foundation
3#
4# Licensed under the Apache License, Version 2.0 (the "License");
5# you may not use this file except in compliance with the License.
6# You may obtain a copy of the License at
7#
8# http://www.apache.org/licenses/LICENSE-2.0
9#
10# Unless required by applicable law or agreed to in writing, software
11# distributed under the License is distributed on an "AS IS" BASIS,
12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
16
17import os
18import sys
19from synchronizers.new_base.SyncInstanceUsingAnsible import SyncInstanceUsingAnsible
20from synchronizers.new_base.modelaccessor import *
21from xos.logger import Logger, logging
22
23parentdir = os.path.join(os.path.dirname(__file__), "..")
24sys.path.insert(0, parentdir)
25
26logger = Logger(level=logging.INFO)
27
28class SyncInternetEmulatorServiceInstance(SyncInstanceUsingAnsible):
29
30 provides = [InternetEmulatorServiceInstance]
31
32 observes = InternetEmulatorServiceInstance
33
34 requested_interval = 0
35
Andy Bavier0c7904f2017-10-19 10:36:26 -070036 template_name = "internetemulatorserviceinstance_playbook.yaml"
Andy Bavier0c564b32017-10-12 13:04:11 -070037
38 service_key_name = "/opt/xos/synchronizers/internetemulator/internetemulator_private_key"
39
40 watches = [ModelLink(ServiceDependency,via='servicedependency')]
41
42 def __init__(self, *args, **kwargs):
Andy Bavier1f25be52017-10-12 15:23:04 -070043 super(SyncInternetEmulatorServiceInstance, self).__init__(*args, **kwargs)
Andy Bavier0c564b32017-10-12 13:04:11 -070044
45 def get_internetemulator(self, o):
46 if not o.owner:
47 return None
48
49 internetemulator = InternetEmulatorService.objects.filter(id=o.owner.id)
50
51 if not internetemulator:
52 return None
53
54 return internetemulator[0]
55
56 # Gets the attributes that are used by the Ansible template but are not
57 # part of the set of default attributes.
58 def get_extra_attributes(self, o):
59 fields = {}
Andy Bavier1f25be52017-10-12 15:23:04 -070060 return fields