blob: 17bc3707db9cc32d67ac1ec62b97fdfcdbee2506 [file] [log] [blame]
Matteo Scandolo48d3d2d2017-08-08 13:05: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
A R Karthick65d950d2016-12-19 19:41:55 -080017#
A R Karthick07608ef2016-08-23 16:51:19 -070018# 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 Karthick65d950d2016-12-19 19:41:55 -080023#
A R Karthick07608ef2016-08-23 16:51:19 -070024# http://www.apache.org/licenses/LICENSE-2.0
A R Karthick65d950d2016-12-19 19:41:55 -080025#
A R Karthick07608ef2016-08-23 16:51:19 -070026# 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#
32import json
33import os
34import shutil
A R Karthick65d950d2016-12-19 19:41:55 -080035import platform
A R Karthick757eb4d2017-01-09 14:51:16 -080036from CordTestServer import CORD_TEST_HOST, CORD_TEST_PORT
A R Karthick07608ef2016-08-23 16:51:19 -070037
38class TestManifest(object):
39
A R Karthick65d950d2016-12-19 19:41:55 -080040 def __init__(self, manifest = None, args = None):
A R Karthick07608ef2016-08-23 16:51:19 -070041 self.manifest = manifest
A R Karthick65d950d2016-12-19 19:41:55 -080042 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 Karthick5968e0d2017-05-16 14:50:46 -070051 self.olt_config = args.olt_config
A R Karthick65d950d2016-12-19 19:41:55 -080052 self.start_switch = args.start_switch
53 self.image_prefix = args.prefix
54 self.onos_image = args.onos
A.R Karthickb17e2022017-01-27 11:29:26 -080055 self.test_controller = args.test_controller
56 if self.test_controller:
57 ips = self.test_controller.split('/')
58 self.onos_ip = ips[0]
59 if len(ips) > 1:
60 self.radius_ip = ips[1]
61 self.onos_cord = args.onos_cord if args.onos_cord else None
A.R Karthickf184b342017-01-27 19:30:50 -080062 self.service_profile = args.service_profile if args.service_profile else None
63 self.synchronizer = args.synchronizer if args.synchronizer else None
A R Karthick44a95602017-01-23 16:17:16 -080064 self.docker_network = args.network if args.network else None
A R Karthick5af23712017-01-20 09:49:24 -080065 self.iterations = None
A.R Karthickb17e2022017-01-27 11:29:26 -080066 self.server = args.server
A R Karthickc69d73e2017-01-20 11:44:34 -080067 self.jvm_heap_size = args.jvm_heap_size if args.jvm_heap_size else None
A R Karthick973010f2017-02-06 16:41:51 -080068 self.karaf_version = args.karaf
A.R Karthick57fa9372017-05-24 12:47:03 -070069 self.voltha_loc = args.voltha_loc
70 self.voltha_intf = args.voltha_intf
A R Karthickfa2caab2017-07-24 18:04:46 -070071 self.voltha_enable = args.voltha_enable
A R Karthick168e2342017-08-15 16:13:10 -070072 self.voltha_container_mode = args.voltha_container_mode
A R Karthick184945a2017-07-25 17:23:57 -070073 self.expose_port = args.expose_port
A R Karthick65d950d2016-12-19 19:41:55 -080074 else:
75 with open(self.manifest, 'r') as fd:
76 data = json.load(fd)
77 self.onos_ip = data.get('onos', None)
78 self.radius_ip = data.get('radius', None)
A.R Karthickb17e2022017-01-27 11:29:26 -080079 self.test_controller = '' if self.onos_ip is None else self.onos_ip
80 if self.onos_ip and self.radius_ip:
81 self.test_controller = '{}/{}'.format(self.onos_ip, self.radius_ip)
82 self.onos_cord = data.get('onos_cord', None)
A.R Karthickf184b342017-01-27 19:30:50 -080083 self.service_profile = data.get('service_profile', None)
84 self.synchronizer = data.get('synchronizer', None)
A R Karthick65d950d2016-12-19 19:41:55 -080085 self.head_node = data.get('head_node', platform.node())
86 self.log_level = data.get('log_level', 'INFO').upper()
87 self.onos_instances = data.get('onos_instances', 1)
88 self.shared_volume = data.get('shared_volume', True)
89 self.async_mode = True if self.onos_instances > 1 else False
90 self.olt = data.get('olt', True)
A.R Karthick5968e0d2017-05-16 14:50:46 -070091 self.olt_config = data.get('olt_config', 'olt_config.json')
A R Karthick65d950d2016-12-19 19:41:55 -080092 self.start_switch = data.get('start_switch', self.olt)
93 self.image_prefix = data.get('image_prefix', '')
94 self.onos_image = data.get('onos_image', 'onosproject/onos:latest')
A R Karthick85eb1862017-01-23 16:10:57 -080095 self.docker_network = data.get('docker_network', None)
A R Karthick757eb4d2017-01-09 14:51:16 -080096 self.server = data.get('test_server', '{}:{}'.format(CORD_TEST_HOST, CORD_TEST_PORT))
A R Karthick5af23712017-01-20 09:49:24 -080097 self.iterations = data.get('iterations', None)
A R Karthickc69d73e2017-01-20 11:44:34 -080098 self.jvm_heap_size = data.get('jvm_heap_size', None)
A.R Karthickdda22062017-02-09 14:39:20 -080099 self.karaf_version = data.get('karaf_version', '3.0.8')
A.R Karthick57fa9372017-05-24 12:47:03 -0700100 self.voltha_loc = data.get('voltha_loc', '')
101 self.voltha_intf = data.get('voltha_intf', 'eth0')
A R Karthickfa2caab2017-07-24 18:04:46 -0700102 voltha_enable = False
103 if self.voltha_loc:
104 voltha_enable = True
105 self.voltha_enable = data.get('voltha_enable', voltha_enable)
A R Karthick8e9ed072017-08-21 11:22:32 -0700106 self.voltha_container_mode = data.get('voltha_container_mode', True)
A R Karthick184945a2017-07-25 17:23:57 -0700107 self.expose_port = data.get('expose_port', False)
A R Karthick168e2342017-08-15 16:13:10 -0700108 if self.voltha_enable and self.voltha_container_mode:
109 self.expose_port = True