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 | 81acbff | 2016-06-17 14:45:16 -0700 | [diff] [blame] | 17 | # |
Chetan Gaonker | cfcce78 | 2016-05-10 10:10:42 -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 | 81acbff | 2016-06-17 14:45:16 -0700 | [diff] [blame] | 23 | # |
Chetan Gaonker | cfcce78 | 2016-05-10 10:10:42 -0700 | [diff] [blame] | 24 | # http://www.apache.org/licenses/LICENSE-2.0 |
A R Karthick | 81acbff | 2016-06-17 14:45:16 -0700 | [diff] [blame] | 25 | # |
Chetan Gaonker | cfcce78 | 2016-05-10 10:10:42 -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 | # |
A.R Karthick | 1700e0e | 2016-10-06 18:16:57 -0700 | [diff] [blame] | 32 | from CordContainer import Container, Onos, OnosStopWrapper, OnosCord, OnosCordStopWrapper, Quagga, QuaggaStopWrapper, Radius, reinitContainerClients |
A R Karthick | 1555c7c | 2017-09-07 14:59:41 -0700 | [diff] [blame] | 33 | from OltConfig import OltConfig |
| 34 | from EapolAAA import get_radius_macs |
Chetan Gaonker | 3533faa | 2016-04-25 17:50:14 -0700 | [diff] [blame] | 35 | from nose.tools import nottest |
A R Karthick | 81acbff | 2016-06-17 14:45:16 -0700 | [diff] [blame] | 36 | from SimpleXMLRPCServer import SimpleXMLRPCServer |
A R Karthick | 1878c4f | 2016-11-29 09:19:50 -0800 | [diff] [blame] | 37 | from resource import getrlimit, RLIMIT_NOFILE |
A R Karthick | 81acbff | 2016-06-17 14:45:16 -0700 | [diff] [blame] | 38 | import daemon |
| 39 | import xmlrpclib |
| 40 | import os |
A R Karthick | e99ab5c | 2016-09-30 13:59:57 -0700 | [diff] [blame] | 41 | import signal |
A R Karthick | 81acbff | 2016-06-17 14:45:16 -0700 | [diff] [blame] | 42 | import json |
| 43 | import time |
| 44 | import threading |
Chetan Gaonker | 3533faa | 2016-04-25 17:50:14 -0700 | [diff] [blame] | 45 | |
A R Karthick | 81acbff | 2016-06-17 14:45:16 -0700 | [diff] [blame] | 46 | ##Server to handle container restart/stop requests from test container. |
Chetan Gaonker | 3533faa | 2016-04-25 17:50:14 -0700 | [diff] [blame] | 47 | ##Used now to restart ONOS from vrouter test container |
| 48 | |
| 49 | CORD_TEST_HOST = '172.17.0.1' |
| 50 | CORD_TEST_PORT = 25000 |
| 51 | |
A R Karthick | 81acbff | 2016-06-17 14:45:16 -0700 | [diff] [blame] | 52 | class CordTestServer(object): |
| 53 | |
A R Karthick | bd9b8a3 | 2016-07-21 09:56:45 -0700 | [diff] [blame] | 54 | onos_cord = None |
| 55 | |
A R Karthick | de6b9dc | 2016-11-29 17:46:16 -0800 | [diff] [blame] | 56 | def __restart_onos(self, node = None, config = None, timeout = 10): |
A R Karthick | bd9b8a3 | 2016-07-21 09:56:45 -0700 | [diff] [blame] | 57 | if self.onos_cord: |
A R Karthick | 928ad62 | 2017-01-30 12:18:32 -0800 | [diff] [blame] | 58 | onos_config = '{}/network-cfg.json'.format(self.onos_cord.onos_config_dir) |
A R Karthick | d44cea1 | 2016-07-20 12:16:41 -0700 | [diff] [blame] | 59 | else: |
| 60 | onos_config = '{}/network-cfg.json'.format(Onos.host_config_dir) |
A R Karthick | 81acbff | 2016-06-17 14:45:16 -0700 | [diff] [blame] | 61 | if config is None: |
| 62 | try: |
| 63 | os.unlink(onos_config) |
| 64 | except: |
| 65 | pass |
Chetan Gaonker | 6cf6e47 | 2016-04-26 14:41:51 -0700 | [diff] [blame] | 66 | print('Restarting ONOS') |
A R Karthick | bd9b8a3 | 2016-07-21 09:56:45 -0700 | [diff] [blame] | 67 | if self.onos_cord: |
| 68 | self.onos_cord.start(restart = True, network_cfg = config) |
A R Karthick | d44cea1 | 2016-07-20 12:16:41 -0700 | [diff] [blame] | 69 | else: |
A R Karthick | de6b9dc | 2016-11-29 17:46:16 -0800 | [diff] [blame] | 70 | Onos.restart_node(node = node, network_cfg = config, timeout = timeout) |
A R Karthick | 81acbff | 2016-06-17 14:45:16 -0700 | [diff] [blame] | 71 | return 'DONE' |
Chetan Gaonker | 6cf6e47 | 2016-04-26 14:41:51 -0700 | [diff] [blame] | 72 | |
A R Karthick | 81acbff | 2016-06-17 14:45:16 -0700 | [diff] [blame] | 73 | def restart_onos(self, kwargs): |
| 74 | return self.__restart_onos(**kwargs) |
| 75 | |
A.R Karthick | 1700e0e | 2016-10-06 18:16:57 -0700 | [diff] [blame] | 76 | def __shutdown_onos(self, node = None): |
| 77 | if node is None: |
| 78 | node = Onos.NAME |
| 79 | OnosStopWrapper(node) |
| 80 | return 'DONE' |
| 81 | |
| 82 | def shutdown_onos(self, kwargs): |
| 83 | return self.__shutdown_onos(**kwargs) |
| 84 | |
A.R Karthick | 2560f04 | 2016-11-30 14:38:52 -0800 | [diff] [blame] | 85 | def __restart_cluster(self, config = None, timeout = 10, setup = False): |
| 86 | Onos.restart_cluster(network_cfg = config, timeout = timeout, setup = setup) |
| 87 | return 'DONE' |
| 88 | |
| 89 | def restart_cluster(self, kwargs): |
| 90 | return self.__restart_cluster(**kwargs) |
| 91 | |
A R Karthick | e2c24bd | 2016-10-07 14:51:38 -0700 | [diff] [blame] | 92 | def __add_cluster_onos(self, count = 1, config = None): |
| 93 | Onos.add_cluster(count = count, network_cfg = config) |
| 94 | return 'DONE' |
| 95 | |
| 96 | def add_cluster_onos(self, kwargs): |
A R Karthick | db59cf7 | 2016-10-10 10:43:22 -0700 | [diff] [blame] | 97 | return self.__add_cluster_onos(**kwargs) |
A R Karthick | e2c24bd | 2016-10-07 14:51:38 -0700 | [diff] [blame] | 98 | |
A R Karthick | 81acbff | 2016-06-17 14:45:16 -0700 | [diff] [blame] | 99 | def __restart_quagga(self, config = None, boot_delay = 30 ): |
Chetan Gaonker | fd3d650 | 2016-05-03 13:23:07 -0700 | [diff] [blame] | 100 | config_file = Quagga.quagga_config_file |
A R Karthick | 81acbff | 2016-06-17 14:45:16 -0700 | [diff] [blame] | 101 | if config is not None: |
| 102 | quagga_config = '{}/testrib_gen.conf'.format(Quagga.host_quagga_config) |
| 103 | config_file = '{}/testrib_gen.conf'.format(Quagga.guest_quagga_config) |
| 104 | with open(quagga_config, 'w+') as fd: |
| 105 | fd.write(str(config)) |
| 106 | print('Restarting QUAGGA with config file %s, delay %d' %(config_file, boot_delay)) |
A R Karthick | 07608ef | 2016-08-23 16:51:19 -0700 | [diff] [blame] | 107 | Quagga(prefix = Container.IMAGE_PREFIX, restart = True, config_file = config_file, boot_delay = boot_delay) |
A R Karthick | 81acbff | 2016-06-17 14:45:16 -0700 | [diff] [blame] | 108 | return 'DONE' |
Chetan Gaonker | 6cf6e47 | 2016-04-26 14:41:51 -0700 | [diff] [blame] | 109 | |
A R Karthick | 81acbff | 2016-06-17 14:45:16 -0700 | [diff] [blame] | 110 | def restart_quagga(self, kwargs): |
| 111 | return self.__restart_quagga(**kwargs) |
Chetan Gaonker | 7f4bf74 | 2016-05-04 15:56:08 -0700 | [diff] [blame] | 112 | |
A R Karthick | 81acbff | 2016-06-17 14:45:16 -0700 | [diff] [blame] | 113 | def stop_quagga(self): |
| 114 | quaggaStop = QuaggaStopWrapper() |
A R Karthick | 4a2362c | 2016-06-22 17:32:44 -0700 | [diff] [blame] | 115 | time.sleep(5) |
Chetan Gaonker | 6cf6e47 | 2016-04-26 14:41:51 -0700 | [diff] [blame] | 116 | try: |
A R Karthick | 81acbff | 2016-06-17 14:45:16 -0700 | [diff] [blame] | 117 | quagga_config_gen = '{}/testrib_gen.conf'.format(Quagga.host_quagga_config) |
| 118 | os.unlink(quagga_config_gen) |
| 119 | except: pass |
| 120 | return 'DONE' |
Chetan Gaonker | 6cf6e47 | 2016-04-26 14:41:51 -0700 | [diff] [blame] | 121 | |
A R Karthick | c3d80e2 | 2016-06-22 17:51:24 -0700 | [diff] [blame] | 122 | def __run_shell_quagga(self, cmd = None): |
| 123 | ret = 0 |
| 124 | if cmd is not None: |
| 125 | exec_cmd = 'docker exec {} {}'.format(Quagga.NAME, cmd) |
| 126 | ret = os.system(exec_cmd) |
| 127 | return ret |
| 128 | |
A R Karthick | a013a27 | 2016-08-16 16:40:19 -0700 | [diff] [blame] | 129 | def __run_shell(self, cmd = None): |
| 130 | ret = 0 |
| 131 | if cmd is not None: |
| 132 | ret = os.system(cmd) |
| 133 | return ret |
| 134 | |
A R Karthick | c3d80e2 | 2016-06-22 17:51:24 -0700 | [diff] [blame] | 135 | def run_shell_quagga(self, kwargs): |
| 136 | return self.__run_shell_quagga(**kwargs) |
| 137 | |
A R Karthick | a013a27 | 2016-08-16 16:40:19 -0700 | [diff] [blame] | 138 | def run_shell(self, kwargs): |
| 139 | return self.__run_shell(**kwargs) |
| 140 | |
A R Karthick | 1555c7c | 2017-09-07 14:59:41 -0700 | [diff] [blame] | 141 | def __restart_radius(self, olt_conf_file = ''): |
| 142 | olt_conf = os.path.join(Onos.setup_dir, os.path.basename(olt_conf_file)) |
| 143 | olt = OltConfig(olt_conf_file = olt_conf) |
| 144 | port_map, _ = olt.olt_port_map() |
A R Karthick | 07608ef | 2016-08-23 16:51:19 -0700 | [diff] [blame] | 145 | Radius(prefix = Container.IMAGE_PREFIX, restart = True) |
A R Karthick | 1555c7c | 2017-09-07 14:59:41 -0700 | [diff] [blame] | 146 | radius_macs = get_radius_macs(len(port_map['radius_ports'])) |
| 147 | radius_intf_index = 0 |
| 148 | radius_intf_subnet = Radius.SUBNET_PREFIX |
| 149 | for host_intf, ports in port_map['switch_radius_port_list']: |
| 150 | for port in ports: |
| 151 | guest_if = 'eth{}'.format(radius_intf_index + 2) |
| 152 | port_index = port_map[port] |
| 153 | local_if = 'r{}'.format(port_index) |
| 154 | guest_ip = '{}.{}/24'.format(radius_intf_subnet, port_index) |
| 155 | mac = radius_macs[radius_intf_index] |
| 156 | radius_intf_index += 1 |
| 157 | pipework_cmd = 'pipework {0} -i {1} -l {2} {3} {4} {5}'.format(host_intf, guest_if, |
| 158 | local_if, Radius.NAME, |
| 159 | guest_ip, mac) |
| 160 | print('Configuring Radius port %s on OVS bridge %s' %(guest_if, host_intf)) |
| 161 | print('Running pipework command: %s' %(pipework_cmd)) |
| 162 | res = os.system(pipework_cmd) |
| 163 | |
| 164 | def restart_radius(self, kwargs): |
| 165 | print('Restarting RADIUS Server') |
| 166 | self.__restart_radius(**kwargs) |
A R Karthick | 81acbff | 2016-06-17 14:45:16 -0700 | [diff] [blame] | 167 | return 'DONE' |
Chetan Gaonker | 3533faa | 2016-04-25 17:50:14 -0700 | [diff] [blame] | 168 | |
A R Karthick | e99ab5c | 2016-09-30 13:59:57 -0700 | [diff] [blame] | 169 | def shutdown(self): |
| 170 | print('Shutting down cord test server') |
| 171 | os.kill(0, signal.SIGKILL) |
| 172 | return 'DONE' |
| 173 | |
A R Karthick | 1878c4f | 2016-11-29 09:19:50 -0800 | [diff] [blame] | 174 | def find_files_by_path(*paths): |
| 175 | wanted = [] |
| 176 | for p in paths: |
| 177 | try: |
| 178 | fd = os.open(p, os.O_RDONLY) |
| 179 | wanted.append(os.fstat(fd)[1:3]) |
| 180 | finally: |
| 181 | os.close(fd) |
| 182 | |
| 183 | def fd_wanted(fd): |
| 184 | try: |
| 185 | return os.fstat(fd)[1:3] in wanted |
| 186 | except OSError: |
| 187 | return False |
| 188 | |
| 189 | max_fd = getrlimit(RLIMIT_NOFILE)[1] |
| 190 | return [ fd for fd in xrange(max_fd) if fd_wanted(fd) ] |
| 191 | |
Chetan Gaonker | 3533faa | 2016-04-25 17:50:14 -0700 | [diff] [blame] | 192 | @nottest |
A R Karthick | bd82f36 | 2016-11-10 15:08:52 -0800 | [diff] [blame] | 193 | def cord_test_server_start(daemonize = True, |
| 194 | cord_test_host = CORD_TEST_HOST, |
| 195 | cord_test_port = CORD_TEST_PORT, |
| 196 | onos_cord = None, |
| 197 | foreground=False): |
A R Karthick | 81acbff | 2016-06-17 14:45:16 -0700 | [diff] [blame] | 198 | server = SimpleXMLRPCServer( (cord_test_host, cord_test_port) ) |
| 199 | server.register_instance(CordTestServer()) |
A R Karthick | bd9b8a3 | 2016-07-21 09:56:45 -0700 | [diff] [blame] | 200 | CordTestServer.onos_cord = onos_cord |
A R Karthick | 81acbff | 2016-06-17 14:45:16 -0700 | [diff] [blame] | 201 | if daemonize is True: |
A R Karthick | 1878c4f | 2016-11-29 09:19:50 -0800 | [diff] [blame] | 202 | ##before daemonizing, preserve urandom needed by paramiko |
| 203 | preserve_list = find_files_by_path('/dev/urandom') |
| 204 | preserve_list.append(server) |
| 205 | d = daemon.DaemonContext(files_preserve = preserve_list, |
A R Karthick | 81acbff | 2016-06-17 14:45:16 -0700 | [diff] [blame] | 206 | detach_process = True) |
| 207 | with d: |
| 208 | reinitContainerClients() |
| 209 | server.serve_forever() |
| 210 | else: |
A R Karthick | bd82f36 | 2016-11-10 15:08:52 -0800 | [diff] [blame] | 211 | if foreground: |
| 212 | try: |
| 213 | server.serve_forever() |
| 214 | except KeyboardInterrupt: |
| 215 | return server |
| 216 | else: |
| 217 | task = threading.Thread(target = server.serve_forever) |
| 218 | ##terminate when main thread exits |
| 219 | task.daemon = True |
| 220 | task.start() |
Chetan Gaonker | 3533faa | 2016-04-25 17:50:14 -0700 | [diff] [blame] | 221 | return server |
| 222 | |
| 223 | @nottest |
| 224 | def cord_test_server_stop(server): |
| 225 | server.shutdown() |
| 226 | server.server_close() |
| 227 | |
| 228 | @nottest |
A R Karthick | 81acbff | 2016-06-17 14:45:16 -0700 | [diff] [blame] | 229 | def get_cord_test_loc(): |
| 230 | host = os.getenv('CORD_TEST_HOST', CORD_TEST_HOST) |
| 231 | port = int(os.getenv('CORD_TEST_PORT', CORD_TEST_PORT)) |
| 232 | return host, port |
| 233 | |
| 234 | def rpc_server_instance(): |
| 235 | '''Stateless''' |
| 236 | host, port = get_cord_test_loc() |
| 237 | rpc_server = 'http://{}:{}'.format(host, port) |
| 238 | return xmlrpclib.Server(rpc_server, allow_none = True) |
| 239 | |
| 240 | @nottest |
| 241 | def __cord_test_onos_restart(**kwargs): |
| 242 | return rpc_server_instance().restart_onos(kwargs) |
| 243 | |
| 244 | @nottest |
A R Karthick | de6b9dc | 2016-11-29 17:46:16 -0800 | [diff] [blame] | 245 | def cord_test_onos_restart(node = None, config = None, timeout = 10): |
Chetan Gaonker | 3533faa | 2016-04-25 17:50:14 -0700 | [diff] [blame] | 246 | '''Send ONOS restart to server''' |
A R Karthick | 6cc8b81 | 2016-12-09 10:24:40 -0800 | [diff] [blame] | 247 | for i in range(3): |
| 248 | try: |
| 249 | data = __cord_test_onos_restart(node = node, config = config, timeout = timeout) |
| 250 | if data == 'DONE': |
| 251 | return True |
| 252 | except: |
| 253 | time.sleep(2) |
| 254 | |
Chetan Gaonker | 6cf6e47 | 2016-04-26 14:41:51 -0700 | [diff] [blame] | 255 | return False |
| 256 | |
| 257 | @nottest |
A.R Karthick | 1700e0e | 2016-10-06 18:16:57 -0700 | [diff] [blame] | 258 | def __cord_test_onos_shutdown(**kwargs): |
| 259 | return rpc_server_instance().shutdown_onos(kwargs) |
| 260 | |
| 261 | @nottest |
| 262 | def cord_test_onos_shutdown(node = None): |
| 263 | data = __cord_test_onos_shutdown(node = node) |
| 264 | if data == 'DONE': |
| 265 | return True |
| 266 | return False |
| 267 | |
| 268 | @nottest |
A.R Karthick | 2560f04 | 2016-11-30 14:38:52 -0800 | [diff] [blame] | 269 | def __cord_test_restart_cluster(**kwargs): |
| 270 | return rpc_server_instance().restart_cluster(kwargs) |
| 271 | |
| 272 | @nottest |
| 273 | def cord_test_restart_cluster(config = None, timeout = 10, setup = False): |
A R Karthick | 6cc8b81 | 2016-12-09 10:24:40 -0800 | [diff] [blame] | 274 | for i in range(3): |
| 275 | try: |
| 276 | data = __cord_test_restart_cluster(config = config, timeout = timeout, setup = setup) |
| 277 | if data == 'DONE': |
| 278 | return True |
| 279 | except: |
| 280 | time.sleep(2) |
| 281 | |
A.R Karthick | 2560f04 | 2016-11-30 14:38:52 -0800 | [diff] [blame] | 282 | return False |
| 283 | |
| 284 | @nottest |
A R Karthick | e2c24bd | 2016-10-07 14:51:38 -0700 | [diff] [blame] | 285 | def __cord_test_onos_add_cluster(**kwargs): |
| 286 | return rpc_server_instance().add_cluster_onos(kwargs) |
| 287 | |
| 288 | @nottest |
| 289 | def cord_test_onos_add_cluster(count = 1, config = None): |
| 290 | data = __cord_test_onos_add_cluster(count = count, config = config) |
| 291 | if data == 'DONE': |
| 292 | return True |
| 293 | return False |
| 294 | |
| 295 | @nottest |
A R Karthick | 81acbff | 2016-06-17 14:45:16 -0700 | [diff] [blame] | 296 | def __cord_test_quagga_restart(**kwargs): |
| 297 | return rpc_server_instance().restart_quagga(kwargs) |
| 298 | |
| 299 | @nottest |
A R Karthick | 1555c7c | 2017-09-07 14:59:41 -0700 | [diff] [blame] | 300 | def __cord_test_radius_restart(**kwargs): |
| 301 | return rpc_server_instance().restart_radius(kwargs) |
| 302 | |
| 303 | @nottest |
A R Karthick | 81acbff | 2016-06-17 14:45:16 -0700 | [diff] [blame] | 304 | def cord_test_quagga_restart(config = None, boot_delay = 30): |
Chetan Gaonker | 6cf6e47 | 2016-04-26 14:41:51 -0700 | [diff] [blame] | 305 | '''Send QUAGGA restart to server''' |
A R Karthick | 81acbff | 2016-06-17 14:45:16 -0700 | [diff] [blame] | 306 | data = __cord_test_quagga_restart(config = config, boot_delay = boot_delay) |
| 307 | if data == 'DONE': |
| 308 | return True |
| 309 | return False |
| 310 | |
| 311 | @nottest |
A R Karthick | c3d80e2 | 2016-06-22 17:51:24 -0700 | [diff] [blame] | 312 | def __cord_test_quagga_shell(**kwargs): |
| 313 | return rpc_server_instance().run_shell_quagga(kwargs) |
| 314 | |
| 315 | @nottest |
| 316 | def cord_test_quagga_shell(cmd = None): |
| 317 | '''Send QUAGGA shell cmd to server''' |
| 318 | return __cord_test_quagga_shell(cmd = cmd) |
| 319 | |
| 320 | @nottest |
A R Karthick | a013a27 | 2016-08-16 16:40:19 -0700 | [diff] [blame] | 321 | def __cord_test_shell(**kwargs): |
| 322 | return rpc_server_instance().run_shell(kwargs) |
| 323 | |
| 324 | @nottest |
| 325 | def cord_test_shell(cmd = None): |
| 326 | '''Send shell cmd to run remotely''' |
| 327 | return __cord_test_shell(cmd = cmd) |
| 328 | |
| 329 | @nottest |
A R Karthick | 81acbff | 2016-06-17 14:45:16 -0700 | [diff] [blame] | 330 | def cord_test_quagga_stop(): |
| 331 | data = rpc_server_instance().stop_quagga() |
Chetan Gaonker | 3533faa | 2016-04-25 17:50:14 -0700 | [diff] [blame] | 332 | if data == 'DONE': |
| 333 | return True |
| 334 | return False |
Chetan Gaonker | 7f4bf74 | 2016-05-04 15:56:08 -0700 | [diff] [blame] | 335 | |
| 336 | @nottest |
A R Karthick | 1555c7c | 2017-09-07 14:59:41 -0700 | [diff] [blame] | 337 | def cord_test_radius_restart(olt_conf_file = ''): |
Chetan Gaonker | 7f4bf74 | 2016-05-04 15:56:08 -0700 | [diff] [blame] | 338 | '''Send Radius server restart to server''' |
A R Karthick | 1555c7c | 2017-09-07 14:59:41 -0700 | [diff] [blame] | 339 | if not olt_conf_file: |
| 340 | olt_conf_file = os.getenv('OLT_CONFIG') |
| 341 | olt_conf_file = os.path.basename(olt_conf_file) |
| 342 | data = __cord_test_radius_restart(olt_conf_file = olt_conf_file) |
Chetan Gaonker | 7f4bf74 | 2016-05-04 15:56:08 -0700 | [diff] [blame] | 343 | if data == 'DONE': |
| 344 | return True |
| 345 | return False |
A R Karthick | e99ab5c | 2016-09-30 13:59:57 -0700 | [diff] [blame] | 346 | |
| 347 | @nottest |
| 348 | def cord_test_server_shutdown(host, port): |
| 349 | '''Shutdown the cord test server''' |
| 350 | rpc_server = 'http://{}:{}'.format(host, port) |
| 351 | try: |
| 352 | xmlrpclib.Server(rpc_server, allow_none = True).shutdown() |
| 353 | except: pass |
| 354 | |
| 355 | return True |