2 # Author: George Paraskevopoulos (geopar@intracom-telecom.com)
3 # Manuel Buil (manuel.buil@ericsson.com)
4 # Prepares the controller and the compute nodes for the odl-sfc testcase
7 # All rights reserved. This program and the accompanying materials
8 # are made available under the terms of the Apache License, Version 2.0
9 # which accompanies this distribution, and is available at
10 # http://www.apache.org/licenses/LICENSE-2.0
17 import functest.utils.functest_logger as ft_logger
19 logger = ft_logger.Logger("ODL_SFC").getLogger()
22 FUNCTEST_REPO_DIR = os.environ['FUNCTEST_REPO_DIR']
24 logger.debug("FUNCTEST_REPO_DIR does not exist!!!!!")
26 FUNCTEST_REPO_DIR = "/home/opnfv/repos/functest"
29 INSTALLER_IP = os.environ['INSTALLER_IP']
32 logger.debug("INSTALLER_IP does not exist. We create 10.20.0.2")
33 INSTALLER_IP = "10.20.0.2"
35 os.environ['ODL_SFC_LOG'] = "/home/opnfv/functest/results/odl-sfc.log"
36 os.environ['ODL_SFC_DIR'] = FUNCTEST_REPO_DIR + "/testcases/features/sfc"
38 command = os.environ['ODL_SFC_DIR'] + ("/server_presetup_CI.bash | "
39 "tee -a ${ODL_SFC_LOG} "
42 output = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
44 # This code is for debugging purposes
45 # for line in iter(output.stdout.readline, ''):
49 # Make sure the process is finished before checking the returncode
55 print("The presetup of the server did not work")
56 sys.exit(output.returncode)
58 logger.info("The presetup of the server worked ")
60 ssh_options = "-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
61 ssh = paramiko.SSHClient()
62 ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
65 ssh.connect(INSTALLER_IP, username="root",
66 password="r00tme", timeout=2)
67 command = "fuel node | grep compute | awk '{print $10}'"
68 logger.info("Executing ssh to collect the compute IPs")
69 (stdin, stdout, stderr) = ssh.exec_command(command)
71 logger.debug("Something went wrong in the ssh to collect the computes IP")
73 output = stdout.readlines()
75 command = os.environ['ODL_SFC_DIR'] + ("/compute_presetup_CI.bash "
76 "" + ip.rstrip() + "| tee -a "
77 "${ODL_SFC_LOG} 1>/dev/null 2>&1")
79 output = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE)
81 # This code is for debugging purposes
82 # for line in iter(output.stdout.readline, ''):
88 if not (output.poll()):
93 print("The compute config did not work on compute %s" % ip)
94 sys.exit(output.returncode)