diff options
author | Jose Lausuch <jose.lausuch@ericsson.com> | 2016-09-21 15:02:46 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@172.30.200.206> | 2016-09-21 15:02:46 +0000 |
commit | 3791aecf9d19da188e480754ae156d7919a51b81 (patch) | |
tree | 9452d00ce7dabbca92c5144d6e249edc1532c0a7 /testcases/features/sfc/sfc.py | |
parent | 4de89d461ca0df0bd88c56a0f0eeedaf358ba345 (diff) | |
parent | b9e50a3e0869cef0ff6ac11355abc2387c86839c (diff) |
Merge "Add SSH connectivity check"
Diffstat (limited to 'testcases/features/sfc/sfc.py')
-rwxr-xr-x | testcases/features/sfc/sfc.py | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/testcases/features/sfc/sfc.py b/testcases/features/sfc/sfc.py index e0bf4e8d7..3f46026ad 100755 --- a/testcases/features/sfc/sfc.py +++ b/testcases/features/sfc/sfc.py @@ -52,6 +52,16 @@ TACKER_SCRIPT = 'sfc_tacker.bash' TEARDOWN_SCRIPT = "sfc_teardown.bash" TACKER_CHANGECLASSI = "sfc_change_classi.bash" +ssh_options = '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' + + +def check_ssh(ip): + cmd = "sshpass -p opnfv ssh " + ssh_options + " -q " + ip + " exit" + success = subprocess.call(cmd, shell=True) == 0 + if not success: + logger.debug("Wating for SSH connectivity in SF with IP: %s" % ip) + return success + def main(): @@ -63,7 +73,6 @@ def main(): start_time = time.time() json_results = {} - ssh_options = '-o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no' contr_cmd = ("sshpass -p r00tme ssh " + ssh_options + " root@10.20.0.2" " 'fuel node'|grep controller|awk '{print $10}'") logger.info("Executing script to get ip_server: '%s'" % contr_cmd) @@ -98,7 +107,7 @@ def main(): subprocess.call(iptable_cmd2, shell=True, stderr=subprocess.PIPE) logger.info("Changing firewall policy in controller: '%s'" % iptable_cmd3) - subprocess.call(iptable_cmd2, shell=True, stderr=subprocess.PIPE) + subprocess.call(iptable_cmd3, shell=True, stderr=subprocess.PIPE) # Getting the different clients @@ -263,13 +272,29 @@ def main(): logger.error('Failed to obtain IPs, cant continue, exiting') return - logger.info("Waiting 60 seconds for floating IP assignment") - for j in range(0, 6): - logger.debug("Test starting in {0} seconds".format(str((6 - j) * 10))) - time.sleep(10) - logger.debug("Floating IPs for SFs: %s..." % ips) + # Check SSH connectivity to VNFs + r = 0 + retries = 100 + check = [False, False] + + logger.info("Checking SSH connectivity to the SFs with ips %s" % str(ips)) + while r < retries and not all(check): + try: + check = [check_ssh(ips[0]), check_ssh(ips[1])] + except Exception: + logger.exception("SSH check failed") + check = [False, False] + time.sleep(3) + r += 1 + + logger.info("SSH connectivity to the SFs established") + + if not all(check): + logger.error("Cannot establish SSH connection to the SFs") + sys.exit(1) + # SSH TO START THE VXLAN_TOOL ON SF1 logger.info("Configuring the SFs") try: |