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 |
A.R Karthick | 5968e0d | 2017-05-16 14:50:46 -0700 | [diff] [blame] | 35 | self.olt_config = args.olt_config |
A R Karthick | 65d950d | 2016-12-19 19:41:55 -0800 | [diff] [blame] | 36 | self.start_switch = args.start_switch |
| 37 | self.image_prefix = args.prefix |
| 38 | self.onos_image = args.onos |
A.R Karthick | b17e202 | 2017-01-27 11:29:26 -0800 | [diff] [blame] | 39 | self.test_controller = args.test_controller |
| 40 | if self.test_controller: |
| 41 | ips = self.test_controller.split('/') |
| 42 | self.onos_ip = ips[0] |
| 43 | if len(ips) > 1: |
| 44 | self.radius_ip = ips[1] |
| 45 | self.onos_cord = args.onos_cord if args.onos_cord else None |
A.R Karthick | f184b34 | 2017-01-27 19:30:50 -0800 | [diff] [blame] | 46 | self.service_profile = args.service_profile if args.service_profile else None |
| 47 | self.synchronizer = args.synchronizer if args.synchronizer else None |
A R Karthick | 44a9560 | 2017-01-23 16:17:16 -0800 | [diff] [blame] | 48 | self.docker_network = args.network if args.network else None |
A R Karthick | 5af2371 | 2017-01-20 09:49:24 -0800 | [diff] [blame] | 49 | self.iterations = None |
A.R Karthick | b17e202 | 2017-01-27 11:29:26 -0800 | [diff] [blame] | 50 | self.server = args.server |
A R Karthick | c69d73e | 2017-01-20 11:44:34 -0800 | [diff] [blame] | 51 | self.jvm_heap_size = args.jvm_heap_size if args.jvm_heap_size else None |
A R Karthick | 973010f | 2017-02-06 16:41:51 -0800 | [diff] [blame] | 52 | self.karaf_version = args.karaf |
A R Karthick | 65d950d | 2016-12-19 19:41:55 -0800 | [diff] [blame] | 53 | else: |
| 54 | with open(self.manifest, 'r') as fd: |
| 55 | data = json.load(fd) |
| 56 | self.onos_ip = data.get('onos', None) |
| 57 | self.radius_ip = data.get('radius', None) |
A.R Karthick | b17e202 | 2017-01-27 11:29:26 -0800 | [diff] [blame] | 58 | self.test_controller = '' if self.onos_ip is None else self.onos_ip |
| 59 | if self.onos_ip and self.radius_ip: |
| 60 | self.test_controller = '{}/{}'.format(self.onos_ip, self.radius_ip) |
| 61 | self.onos_cord = data.get('onos_cord', None) |
A.R Karthick | f184b34 | 2017-01-27 19:30:50 -0800 | [diff] [blame] | 62 | self.service_profile = data.get('service_profile', None) |
| 63 | self.synchronizer = data.get('synchronizer', None) |
A R Karthick | 65d950d | 2016-12-19 19:41:55 -0800 | [diff] [blame] | 64 | self.head_node = data.get('head_node', platform.node()) |
| 65 | self.log_level = data.get('log_level', 'INFO').upper() |
| 66 | self.onos_instances = data.get('onos_instances', 1) |
| 67 | self.shared_volume = data.get('shared_volume', True) |
| 68 | self.async_mode = True if self.onos_instances > 1 else False |
| 69 | self.olt = data.get('olt', True) |
A.R Karthick | 5968e0d | 2017-05-16 14:50:46 -0700 | [diff] [blame] | 70 | self.olt_config = data.get('olt_config', 'olt_config.json') |
A R Karthick | 65d950d | 2016-12-19 19:41:55 -0800 | [diff] [blame] | 71 | self.start_switch = data.get('start_switch', self.olt) |
| 72 | self.image_prefix = data.get('image_prefix', '') |
| 73 | self.onos_image = data.get('onos_image', 'onosproject/onos:latest') |
A R Karthick | 85eb186 | 2017-01-23 16:10:57 -0800 | [diff] [blame] | 74 | self.docker_network = data.get('docker_network', None) |
A R Karthick | 757eb4d | 2017-01-09 14:51:16 -0800 | [diff] [blame] | 75 | self.server = data.get('test_server', '{}:{}'.format(CORD_TEST_HOST, CORD_TEST_PORT)) |
A R Karthick | 5af2371 | 2017-01-20 09:49:24 -0800 | [diff] [blame] | 76 | self.iterations = data.get('iterations', None) |
A R Karthick | c69d73e | 2017-01-20 11:44:34 -0800 | [diff] [blame] | 77 | self.jvm_heap_size = data.get('jvm_heap_size', None) |
A.R Karthick | dda2206 | 2017-02-09 14:39:20 -0800 | [diff] [blame] | 78 | self.karaf_version = data.get('karaf_version', '3.0.8') |