-
Notifications
You must be signed in to change notification settings - Fork 0
/
deneme.py
48 lines (44 loc) · 1.47 KB
/
deneme.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/python
import time
from threading import Thread
import os
import commands
import time
bridge_list = ['s1','s2','s3','s4','s5','s6','s7','s8','s9','s10']
while True:
time.sleep(3)
reponse = ""
for i in range(0,10):
getcontr = commands.getstatusoutput("sudo ovs-vsctl get-controller "+ bridge_list[i])
if(getcontr[1] == "tcp:127.0.0.1:6633"):
response = commands.getstatusoutput("sudo ovs-vsctl get controller "+ bridge_list[i] + " is_connected")
if response[1] == "false":
start = time.time()
print("start = ")
print(start)
print("---------------")
os.system("sudo ovs-vsctl set-controller " +bridge_list[i]+ " tcp:127.0.0.1:6639")
print("switch :: "+bridge_list[i]+" is connected to controller:c2")
end = time.time()
print("duration = ")
print(end - start)
print("---------------")
print("end =")
print(end)
print("---------------")
elif(getcontr[1] == "tcp:127.0.0.1:6639"):
response = commands.getstatusoutput("sudo ovs-vsctl get controller "+ bridge_list[i] + " is_connected")
if response[1] == "false":
start = time.time()
print("start = ")
print(start)
print("---------------")
os.system("sudo ovs-vsctl set-controller " +bridge_list[i]+ " tcp:127.0.0.1:6645")
print("switch :: "+bridge_list[i]+" is connected to controller:c3")
end = time.time()
print("duration = ")
print(end - start)
print("---------------")
print("end =")
print(end)
print("---------------")