Matteo Scandolo | 48d3d2d | 2017-08-08 13:05:27 -0700 | [diff] [blame] | 1 | |
| 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 | |
A R Karthick | 65d950d | 2016-12-19 19:41:55 -0800 | [diff] [blame] | 17 | # |
A R Karthick | 07608ef | 2016-08-23 16:51:19 -0700 | [diff] [blame] | 18 | # Copyright 2016-present Ciena Corporation |
| 19 | # |
| 20 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 21 | # you may not use this file except in compliance with the License. |
| 22 | # You may obtain a copy of the License at |
A R Karthick | 65d950d | 2016-12-19 19:41:55 -0800 | [diff] [blame] | 23 | # |
A R Karthick | 07608ef | 2016-08-23 16:51:19 -0700 | [diff] [blame] | 24 | # http://www.apache.org/licenses/LICENSE-2.0 |
A R Karthick | 65d950d | 2016-12-19 19:41:55 -0800 | [diff] [blame] | 25 | # |
A R Karthick | 07608ef | 2016-08-23 16:51:19 -0700 | [diff] [blame] | 26 | # Unless required by applicable law or agreed to in writing, software |
| 27 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 28 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 29 | # See the License for the specific language governing permissions and |
| 30 | # limitations under the License. |
| 31 | # |
| 32 | import json |
| 33 | import os |
| 34 | import shutil |
A R Karthick | 65d950d | 2016-12-19 19:41:55 -0800 | [diff] [blame] | 35 | import platform |
A R Karthick | 757eb4d | 2017-01-09 14:51:16 -0800 | [diff] [blame] | 36 | from CordTestServer import CORD_TEST_HOST, CORD_TEST_PORT |
A R Karthick | 07608ef | 2016-08-23 16:51:19 -0700 | [diff] [blame] | 37 | |
| 38 | class TestManifest(object): |
| 39 | |
A R Karthick | 65d950d | 2016-12-19 19:41:55 -0800 | [diff] [blame] | 40 | def __init__(self, manifest = None, args = None): |
A R Karthick | 07608ef | 2016-08-23 16:51:19 -0700 | [diff] [blame] | 41 | self.manifest = manifest |
A R Karthick | 65d950d | 2016-12-19 19:41:55 -0800 | [diff] [blame] | 42 | if args is not None and manifest is None: |
| 43 | self.onos_ip = None |
| 44 | self.radius_ip = None |
| 45 | self.head_node = platform.node() |
| 46 | self.log_level = args.log_level.upper() |
| 47 | self.onos_instances = args.onos_instances |
| 48 | self.async_mode = args.async_mode |
| 49 | self.shared_volume = args.shared_volume |
| 50 | self.olt = args.olt |
A.R Karthick | 5968e0d | 2017-05-16 14:50:46 -0700 | [diff] [blame] | 51 | self.olt_config = args.olt_config |
A R Karthick | 65d950d | 2016-12-19 19:41:55 -0800 | [diff] [blame] | 52 | self.start_switch = args.start_switch |
Thangavelu K S | a61d1da | 2017-09-05 05:32:21 -0700 | [diff] [blame] | 53 | self.setup_dhcpd = args.setup_dhcpd |
A R Karthick | 65d950d | 2016-12-19 19:41:55 -0800 | [diff] [blame] | 54 | self.image_prefix = args.prefix |
| 55 | self.onos_image = args.onos |
A.R Karthick | b17e202 | 2017-01-27 11:29:26 -0800 | [diff] [blame] | 56 | self.test_controller = args.test_controller |
| 57 | if self.test_controller: |
| 58 | ips = self.test_controller.split('/') |
| 59 | self.onos_ip = ips[0] |
| 60 | if len(ips) > 1: |
| 61 | self.radius_ip = ips[1] |
| 62 | 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] | 63 | self.service_profile = args.service_profile if args.service_profile else None |
| 64 | self.synchronizer = args.synchronizer if args.synchronizer else None |
A R Karthick | 44a9560 | 2017-01-23 16:17:16 -0800 | [diff] [blame] | 65 | self.docker_network = args.network if args.network else None |
A R Karthick | 5af2371 | 2017-01-20 09:49:24 -0800 | [diff] [blame] | 66 | self.iterations = None |
A.R Karthick | b17e202 | 2017-01-27 11:29:26 -0800 | [diff] [blame] | 67 | self.server = args.server |
A R Karthick | c69d73e | 2017-01-20 11:44:34 -0800 | [diff] [blame] | 68 | 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] | 69 | self.karaf_version = args.karaf |
A.R Karthick | 57fa937 | 2017-05-24 12:47:03 -0700 | [diff] [blame] | 70 | self.voltha_loc = args.voltha_loc |
| 71 | self.voltha_intf = args.voltha_intf |
A R Karthick | fa2caab | 2017-07-24 18:04:46 -0700 | [diff] [blame] | 72 | self.voltha_enable = args.voltha_enable |
A R Karthick | 168e234 | 2017-08-15 16:13:10 -0700 | [diff] [blame] | 73 | self.voltha_container_mode = args.voltha_container_mode |
A R Karthick | 184945a | 2017-07-25 17:23:57 -0700 | [diff] [blame] | 74 | self.expose_port = args.expose_port |
Kailash Khalasi | 1511ef0 | 2018-01-23 11:19:16 -0800 | [diff] [blame] | 75 | self.skip_onos_restart = args.skip_onos_restart |
A R Karthick | 65d950d | 2016-12-19 19:41:55 -0800 | [diff] [blame] | 76 | else: |
| 77 | with open(self.manifest, 'r') as fd: |
| 78 | data = json.load(fd) |
| 79 | self.onos_ip = data.get('onos', None) |
| 80 | self.radius_ip = data.get('radius', None) |
A.R Karthick | b17e202 | 2017-01-27 11:29:26 -0800 | [diff] [blame] | 81 | self.test_controller = '' if self.onos_ip is None else self.onos_ip |
| 82 | if self.onos_ip and self.radius_ip: |
| 83 | self.test_controller = '{}/{}'.format(self.onos_ip, self.radius_ip) |
| 84 | self.onos_cord = data.get('onos_cord', None) |
A.R Karthick | f184b34 | 2017-01-27 19:30:50 -0800 | [diff] [blame] | 85 | self.service_profile = data.get('service_profile', None) |
| 86 | self.synchronizer = data.get('synchronizer', None) |
A R Karthick | 65d950d | 2016-12-19 19:41:55 -0800 | [diff] [blame] | 87 | self.head_node = data.get('head_node', platform.node()) |
| 88 | self.log_level = data.get('log_level', 'INFO').upper() |
| 89 | self.onos_instances = data.get('onos_instances', 1) |
| 90 | self.shared_volume = data.get('shared_volume', True) |
| 91 | self.async_mode = True if self.onos_instances > 1 else False |
| 92 | self.olt = data.get('olt', True) |
A.R Karthick | 5968e0d | 2017-05-16 14:50:46 -0700 | [diff] [blame] | 93 | self.olt_config = data.get('olt_config', 'olt_config.json') |
A R Karthick | 65d950d | 2016-12-19 19:41:55 -0800 | [diff] [blame] | 94 | self.start_switch = data.get('start_switch', self.olt) |
Thangavelu K S | a61d1da | 2017-09-05 05:32:21 -0700 | [diff] [blame] | 95 | self.setup_dhcpd = data.get('setup_dhcpd', self.start_switch) |
A R Karthick | 65d950d | 2016-12-19 19:41:55 -0800 | [diff] [blame] | 96 | self.image_prefix = data.get('image_prefix', '') |
| 97 | self.onos_image = data.get('onos_image', 'onosproject/onos:latest') |
A R Karthick | 85eb186 | 2017-01-23 16:10:57 -0800 | [diff] [blame] | 98 | self.docker_network = data.get('docker_network', None) |
A R Karthick | 757eb4d | 2017-01-09 14:51:16 -0800 | [diff] [blame] | 99 | 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] | 100 | self.iterations = data.get('iterations', None) |
A R Karthick | c69d73e | 2017-01-20 11:44:34 -0800 | [diff] [blame] | 101 | self.jvm_heap_size = data.get('jvm_heap_size', None) |
A.R Karthick | dda2206 | 2017-02-09 14:39:20 -0800 | [diff] [blame] | 102 | self.karaf_version = data.get('karaf_version', '3.0.8') |
A.R Karthick | 57fa937 | 2017-05-24 12:47:03 -0700 | [diff] [blame] | 103 | self.voltha_loc = data.get('voltha_loc', '') |
| 104 | self.voltha_intf = data.get('voltha_intf', 'eth0') |
A R Karthick | fa2caab | 2017-07-24 18:04:46 -0700 | [diff] [blame] | 105 | voltha_enable = False |
| 106 | if self.voltha_loc: |
| 107 | voltha_enable = True |
| 108 | self.voltha_enable = data.get('voltha_enable', voltha_enable) |
A R Karthick | 8e9ed07 | 2017-08-21 11:22:32 -0700 | [diff] [blame] | 109 | self.voltha_container_mode = data.get('voltha_container_mode', True) |
A R Karthick | 184945a | 2017-07-25 17:23:57 -0700 | [diff] [blame] | 110 | self.expose_port = data.get('expose_port', False) |
A R Karthick | 168e234 | 2017-08-15 16:13:10 -0700 | [diff] [blame] | 111 | if self.voltha_enable and self.voltha_container_mode: |
| 112 | self.expose_port = True |
Kailash Khalasi | 1511ef0 | 2018-01-23 11:19:16 -0800 | [diff] [blame] | 113 | self.skip_onos_restart = data.get('skip_onos_restart', False) |