aboutsummaryrefslogtreecommitdiffstats
path: root/testcases/Controllers/ONOS/Sfc/Sfc_fun.py
diff options
context:
space:
mode:
authorwuwenbin2 <wuwenbin2@huawei.com>2016-07-08 15:49:06 +0800
committerJose Lausuch <jose.lausuch@ericsson.com>2016-07-08 10:27:23 +0000
commitdb9fce16527573a7b81978fa15d03ebf0e937e94 (patch)
tree2500e71cb751f2308f3ec9aed1bd621d99a5f3e0 /testcases/Controllers/ONOS/Sfc/Sfc_fun.py
parent037679cb6390c69c309d441e574715a26577b674 (diff)
Fix onos sfc's block.
Add ping check before login. Change-Id: If93809ddf727246db453208c79a8e4ecaa288c51 Signed-off-by: wuwenbin2 <wuwenbin2@huawei.com>
Diffstat (limited to 'testcases/Controllers/ONOS/Sfc/Sfc_fun.py')
-rw-r--r--testcases/Controllers/ONOS/Sfc/Sfc_fun.py27
1 files changed, 22 insertions, 5 deletions
diff --git a/testcases/Controllers/ONOS/Sfc/Sfc_fun.py b/testcases/Controllers/ONOS/Sfc/Sfc_fun.py
index 6090e886..68929bf0 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]