blob: d52422bf33f21d5675465466aea731248e37ab8d [file] [log] [blame]
Matteo Scandolo0a207b52018-01-29 13:39:43 -08001# 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
15from xosconfig import Config
16from multistructlog import create_logger
17from synchronizers.new_base.modelaccessor import ProgranService
18
19log = create_logger(Config().get('logging'))
20
21class ProgranHelpers():
22
23 @staticmethod
24 def get_onos_info_from_si(service_instance):
25 progran_service = service_instance.owner.leaf_model
26 return ProgranHelpers.get_onos_info_from_service(progran_service)
27
28 @staticmethod
29 def get_progran_onos_info():
Matteo Scandolo6b607c82018-01-30 09:12:26 -080030 try:
31 progran_service = ProgranService.objects.all()[0]
32 except IndexError:
33 log.error("Cannot find Progran Service, does it exists?")
Matteo Scandolo0a207b52018-01-29 13:39:43 -080034 return ProgranHelpers.get_onos_info_from_service(progran_service)
35
36 @staticmethod
37 def get_onos_info_from_service(progran_service):
38 return {
39 'url': progran_service.onos_address,
40 'port': progran_service.onos_port,
41 'username': progran_service.onos_username,
42 'password': progran_service.onos_password,
43 }