I want to shutdown core1
, core2
and bring up core3
, core4
while I am working on router1
. In the same way I have to bring up core1
, core2
and shutdown core3
, core4
while working on router2
.
router1, router2, = "10.11.12.13", "10.11.12.14"
tunnel1, tunnel2, tunnel3, tunnel4, tunnel5 =
"tunnel01","tunnel02","tunnel03","tunnel04", "tunnel05"
core1, core2, core3, core4 = "core01", "core02", "core03", "core04"
routers = [router1, router2]
tunnels = [tunnel1, tunnel2]
cores = [core1, core2, core3, core4]
loopback = "loopback"
def noshut(tunnel, router):
print('NO SHUTDOWN', tunnel, router)
def shut(tunnel, router):
print('SHUTDOWN', tunnel, router)
for r1 in routers:
for c in cores:
#Here I need to shut core1, core2, bring up core3 and core4 in
#router 1 and while working on router 2 core3 and core4 should be
#down and core1, core2 has to be up.
for t1 in tunnels:
for r2 in routers:
for t2 in tunnels:
if r1 == r2 and t1 == t2:
noshut(t1,r1)
else:
shut(t2,r2)
print("Ping")
print("")
This is the output of present code:
NO SHUTDOWN tunnel01 10.11.12.13
SHUTDOWN tunnel02 10.11.12.13
SHUTDOWN tunnel01 10.11.12.14
SHUTDOWN tunnel02 10.11.12.14
Ping
SHUTDOWN tunnel01 10.11.12.13
NO SHUTDOWN tunnel02 10.11.12.13
SHUTDOWN tunnel01 10.11.12.14
SHUTDOWN tunnel02 10.11.12.14
Ping
SHUTDOWN tunnel01 10.11.12.13
SHUTDOWN tunnel02 10.11.12.13
NO SHUTDOWN tunnel01 10.11.12.14
SHUTDOWN tunnel02 10.11.12.14
Ping
SHUTDOWN tunnel01 10.11.12.13
SHUTDOWN tunnel02 10.11.12.13
SHUTDOWN tunnel01 10.11.12.14
NO SHUTDOWN tunnel02 10.11.12.14
Ping
I want it to look like
SHUTDOWN loopback core01
SHUTDOWN loopback core02
NO SHUTDOWN loopback core03
NO SHUTDOWN loopback core04
NO SHUTDOWN tunnel01 10.11.12.13
SHUTDOWN tunnel02 10.11.12.13
SHUTDOWN tunnel01 10.11.12.14
SHUTDOWN tunnel02 10.11.12.14
Ping
SHUTDOWN tunnel01 10.11.12.13
NO SHUTDOWN tunnel02 10.11.12.13
SHUTDOWN tunnel01 10.11.12.14
SHUTDOWN tunnel02 10.11.12.14
Ping
NO SHUTDOWN loopback core01
NO SHUTDOWN loopback core02
SHUTDOWN loopback core03
SHUTDOWN loopback core04
SHUTDOWN tunnel01 10.11.12.13
SHUTDOWN tunnel02 10.11.12.13
NO SHUTDOWN tunnel01 10.11.12.14
SHUTDOWN tunnel02 10.11.12.14
Ping
SHUTDOWN tunnel01 10.11.12.13
SHUTDOWN tunnel02 10.11.12.13
SHUTDOWN tunnel01 10.11.12.14
NO SHUTDOWN tunnel02 10.11.12.14
Ping