blob: 683cbd8782288eb2c43ecc1c0eb88db0afd44d4d [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
Andy Bavier0c564b32017-10-12 13:04:11 -070030 observes = InternetEmulatorServiceInstance
Andy Bavier0c7904f2017-10-19 10:36:26 -070031 template_name = "internetemulatorserviceinstance_playbook.yaml"
Andy Bavier0c564b32017-10-12 13:04:11 -070032 service_key_name = "/opt/xos/synchronizers/internetemulator/internetemulator_private_key"
33
Andy Bavier0c564b32017-10-12 13:04:11 -070034 def __init__(self, *args, **kwargs):
Andy Bavier1f25be52017-10-12 15:23:04 -070035 super(SyncInternetEmulatorServiceInstance, self).__init__(*args, **kwargs)
Andy Bavier0c564b32017-10-12 13:04:11 -070036
37 def get_internetemulator(self, o):
38 if not o.owner:
39 return None
40
41 internetemulator = InternetEmulatorService.objects.filter(id=o.owner.id)
42
43 if not internetemulator:
44 return None
45
46 return internetemulator[0]
47
48 # Gets the attributes that are used by the Ansible template but are not
49 # part of the set of default attributes.
50 def get_extra_attributes(self, o):
51 fields = {}
Andy Bavier1f25be52017-10-12 15:23:04 -070052 return fields