A R Karthick | 65d950d | 2016-12-19 19:41:55 -0800 | [diff] [blame] | 1 | # |
A R Karthick | 07608ef | 2016-08-23 16:51:19 -0700 | [diff] [blame] | 2 | # Copyright 2016-present Ciena Corporation |
| 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 |
A R Karthick | 65d950d | 2016-12-19 19:41:55 -0800 | [diff] [blame] | 7 | # |
A R Karthick | 07608ef | 2016-08-23 16:51:19 -0700 | [diff] [blame] | 8 | # http://www.apache.org/licenses/LICENSE-2.0 |
A R Karthick | 65d950d | 2016-12-19 19:41:55 -0800 | [diff] [blame] | 9 | # |
A R Karthick | 07608ef | 2016-08-23 16:51:19 -0700 | [diff] [blame] | 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 | import json |
| 17 | import os |
| 18 | import shutil |
A R Karthick | 65d950d | 2016-12-19 19:41:55 -0800 | [diff] [blame] | 19 | import platform |
A R Karthick | 757eb4d | 2017-01-09 14:51:16 -0800 | [diff] [blame] | 20 | from CordTestServer import CORD_TEST_HOST, CORD_TEST_PORT |
A R Karthick | 07608ef | 2016-08-23 16:51:19 -0700 | [diff] [blame] | 21 | |
| 22 | class TestManifest(object): |
| 23 | |
A R Karthick | 65d950d | 2016-12-19 19:41:55 -0800 | [diff] [blame] | 24 | def __init__(self, manifest = None, args = None): |
A R Karthick | 07608ef | 2016-08-23 16:51:19 -0700 | [diff] [blame] | 25 | self.manifest = manifest |
A R Karthick | 65d950d | 2016-12-19 19:41:55 -0800 | [diff] [blame] | 26 | if args is not None and manifest is None: |
| 27 | self.onos_ip = None |
| 28 | self.radius_ip = None |
| 29 | self.head_node = platform.node() |
| 30 | self.log_level = args.log_level.upper() |
| 31 | self.onos_instances = args.onos_instances |
| 32 | self.async_mode = args.async_mode |
| 33 | self.shared_volume = args.shared_volume |
| 34 | self.olt = args.olt |
| 35 | self.start_switch = args.start_switch |
| 36 | self.image_prefix = args.prefix |
| 37 | self.onos_image = args.onos |
A R Karthick | 757eb4d | 2017-01-09 14:51:16 -0800 | [diff] [blame] | 38 | self.server = '{}:{}'.format(CORD_TEST_HOST, CORD_TEST_PORT) |
A R Karthick | 65d950d | 2016-12-19 19:41:55 -0800 | [diff] [blame] | 39 | else: |
| 40 | with open(self.manifest, 'r') as fd: |
| 41 | data = json.load(fd) |
| 42 | self.onos_ip = data.get('onos', None) |
| 43 | self.radius_ip = data.get('radius', None) |
| 44 | self.head_node = data.get('head_node', platform.node()) |
| 45 | self.log_level = data.get('log_level', 'INFO').upper() |
| 46 | self.onos_instances = data.get('onos_instances', 1) |
| 47 | self.shared_volume = data.get('shared_volume', True) |
| 48 | self.async_mode = True if self.onos_instances > 1 else False |
| 49 | self.olt = data.get('olt', True) |
| 50 | self.start_switch = data.get('start_switch', self.olt) |
| 51 | self.image_prefix = data.get('image_prefix', '') |
| 52 | self.onos_image = data.get('onos_image', 'onosproject/onos:latest') |
A R Karthick | 757eb4d | 2017-01-09 14:51:16 -0800 | [diff] [blame] | 53 | self.server = data.get('test_server', '{}:{}'.format(CORD_TEST_HOST, CORD_TEST_PORT)) |