From db9fce16527573a7b81978fa15d03ebf0e937e94 Mon Sep 17 00:00:00 2001 From: wuwenbin2 Date: Fri, 8 Jul 2016 15:49:06 +0800 Subject: Fix onos sfc's block. Add ping check before login. Change-Id: If93809ddf727246db453208c79a8e4ecaa288c51 Signed-off-by: wuwenbin2 --- testcases/Controllers/ONOS/Sfc/Sfc.py | 12 ++++++------ testcases/Controllers/ONOS/Sfc/Sfc_fun.py | 27 ++++++++++++++++++++++----- 2 files changed, 28 insertions(+), 11 deletions(-) (limited to 'testcases') diff --git a/testcases/Controllers/ONOS/Sfc/Sfc.py b/testcases/Controllers/ONOS/Sfc/Sfc.py index 94b24e680..dd012edbf 100644 --- a/testcases/Controllers/ONOS/Sfc/Sfc.py +++ b/testcases/Controllers/ONOS/Sfc/Sfc.py @@ -94,8 +94,8 @@ class Sfc: logger.error("\t\t : Floating Ip NOT attached to VM ") print ("\n###########################################################\n") ######################################################################## - logger.info("TestCase 3 : Configure SFC [Portair,PortGroup,\ - Flow classifer") + logger.info( + "TestCase 3 : Configure SFC [Portair,PortGroup,Flow classifer]") ######################################################################### logger.info("\t3.1 Creation of Port Pair") if (Sfc_obj.createPortPair() == 201): @@ -133,8 +133,8 @@ class Sfc: logger.error("\t\t : Flow Classifier NOT successfully Created") print ("\n###########################################################\n") ######################################################################## - logger.info("TestCase 4 : Configure Port Chain and verify the flows are\ - added.") + logger.info( + "TestCase 4 : Configure Port Chain and verify flows are added") ######################################################################### logger.info("\t4.1 Creation of PortChain") if (Sfc_obj.createPortChain() == 201): @@ -185,8 +185,8 @@ class Sfc: if (Sfc_obj.deleteFlowClassifier() == 204): if (Sfc_obj.deletePortGroup() == 204): if (Sfc_obj.deletePortPair() == 204): - logger.info("\t\tSFC configuration is deleted \ - successfully") + logger.info( + "\t\tSFC configuration is deleted successfully") else: logger.error("\t\t : Port pair configuration is NOT\ deleted successfully") diff --git a/testcases/Controllers/ONOS/Sfc/Sfc_fun.py b/testcases/Controllers/ONOS/Sfc/Sfc_fun.py index 6090e8866..68929bf0a 100644 --- a/testcases/Controllers/ONOS/Sfc/Sfc_fun.py +++ b/testcases/Controllers/ONOS/Sfc/Sfc_fun.py @@ -7,6 +7,7 @@ from pexpect import pxssh import re import requests import time +import os class Sfc_fun: @@ -14,7 +15,7 @@ class Sfc_fun: def __init__(self): """Initialization of variables.""" - self.logger = ft_logger.Logger("sfc_fun_log").getLogger() + self.logger = ft_logger.Logger("sfc_fun").getLogger() self.osver = "v2.0" self.token_id = 0 self.net_id = 0 @@ -303,7 +304,7 @@ class Sfc_fun: response = requests.post(url, headers=headers, data=data) if (response.status_code == 201): print ("\t\t\t\tCreation of Port Pair PP"+str(p) + - "is successful") + " is successful") else: return(response.status_code) @@ -617,8 +618,24 @@ class Sfc_fun: self.logger.info("\tPacket not received in Instance") queue1.put("0") - if (self.value == 0): - time.sleep(10) + def ping(ip, timeout=300): + while True: + time.sleep(1) + self.logger.debug("Pinging %s. Waiting for response..." % ip) + response = os.system("ping -c 1 " + ip + " >/dev/null 2>&1") + if response == 0: + self.logger.info("Ping " + ip + " detected!") + return 0 + + elif timeout == 0: + self.logger.info("Ping " + ip + " timeout reached.") + return 1 + timeout -= 1 + + result0 = ping(self.vm_public_ip[0]) + result1 = ping(self.vm_public_ip[1]) + if result0 == 0 and result1 == 0: + time.sleep(300) queue1 = Queue() p1 = Process(target=vm1, args=(queue1, )) p1.start() @@ -797,7 +814,7 @@ class Sfc_fun: else: return(response.status_code) - print ("\n\t\t Deletion of Floating ip") + print ("\n\t\tDeletion of Floating ip") for ip_num in range(0, 2): url = 'http://'+self.os_hostname+':9696/'+self.osver + \ '/floatingips/'+self.vm_public_id[ip_num] -- cgit 1.2.3-korg