blob: 44ab34b80966f60f2bab6b07d6420ddf02a860de [file] [log] [blame]
Andy Baviereddb6b62017-10-26 08:39:27 -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 SyncTemplateServiceInstance(SyncInstanceUsingAnsible):
29
30 provides = [TemplateServiceInstance]
31
32 observes = TemplateServiceInstance
33
34 requested_interval = 0
35
36 template_name = "serviceinstance_playbook.yaml"
37
38 service_key_name = "/opt/xos/synchronizers/templateservice/service_private_key"
39
40 def __init__(self, *args, **kwargs):
41 super(SyncTemplateServiceInstance, self).__init__(*args, **kwargs)
42
43 def get_service(self, o):
44 if not o.owner:
45 return None
46
47 service = TemplateService.objects.filter(id=o.owner.id)
48
49 if not service:
50 return None
51
52 return service[0]
53
54 # Gets the attributes that are used by the Ansible template but are not
55 # part of the set of default attributes.
56 def get_extra_attributes(self, o):
57 fields = {}
Andy Baviereddb6b62017-10-26 08:39:27 -070058 return fields