diff --git a/dest.txt b/dest.txt new file mode 100644 index 0000000000000000000000000000000000000000..e085b0b6b2bf79df8771ff7ef0c26d3469b3832e --- /dev/null +++ b/dest.txt @@ -0,0 +1 @@ +192.168.6.1 \ No newline at end of file diff --git a/host.txt b/host.txt new file mode 100644 index 0000000000000000000000000000000000000000..a8a2de608946ec30ce71607c492a57d7a100d49c --- /dev/null +++ b/host.txt @@ -0,0 +1 @@ +R5 \ No newline at end of file diff --git a/networkxtest.py b/networkxtest.py index 2133af47378a9398ed3e3f69c47d64dc122f16ad..d28c864a674b13fa79857d9df6889cbc47c8a52f 100644 --- a/networkxtest.py +++ b/networkxtest.py @@ -122,11 +122,42 @@ def checkroutings(): for i in pathlist: for j in i: + elozo = getelement(j) for x in hosts: if j == x.name: - if searchedNetwork in x.networks or searchedNetwork in x.sroutes: - print(x.name) - print("route megnezve") + if searchedNetwork in x.networks: + if searchedMask != x.masks: + p = open("host.txt", "w") + p.write(x.name) + f = open("repairmask.txt", "w") + f.write(searchedMask) + g = open("repairip.txt", "w") + g.write(searchedNetwork) + for k in x.networks: + for index, h in enumerate(elozo.networks): + if h == k: + h = open("dest.txt", "w") + h.write(elozo.ips[index]) + elif searchedNetwork in x.sroutes: + if searchedMask != x.smasks: + p = open("host.txt", "w") + p.write(x.name) + f = open("repairmask.txt", "w") + f.write(searchedMask) + g = open("repairip.txt", "w") + g.write(searchedNetwork) + for k in x.networks: + for index, h in enumerate(elozo.networks): + if h == k: + h = open("dest.txt", "w") + h.write(elozo.ips[index]) + print(elozo.ips[index]) + elozo = getelement(j) + +def getelement(element): + for i in hosts: + if i.name == element: + return i def repairtables(): #itt majd javitja a routingot diff --git a/playbooks/repair_routing.yaml b/playbooks/repair_routing.yaml index 722fa6e488373e5ed4696065b4f13c5b700717f9..8c4c8dbeaf84b149a297f37dabe128ae434710e4 100644 --- a/playbooks/repair_routing.yaml +++ b/playbooks/repair_routing.yaml @@ -1,13 +1,11 @@ --- - name: Repair routing mask - hosts: router1 + hosts: {{ lookup('file', 'host.txt') }} gather_facts: false connection: network_cli tasks: - - name: Mask repair cisco.ios.ios_command: - commands: + commands: - configure terminal - - no ip route * - - "ip route 10.10.20.176 {{int_mask}} 10.10.20.170" + - ip route 10.10.20.176 {{ lookup('file', 'hely' ) }} 10.10.20.170 diff --git a/repairip.txt b/repairip.txt new file mode 100644 index 0000000000000000000000000000000000000000..b3e5df0ad93dbb25f69f6dce0699aadae0a3cf4b --- /dev/null +++ b/repairip.txt @@ -0,0 +1 @@ +192.168.2.0 \ No newline at end of file diff --git a/repairmask.txt b/repairmask.txt new file mode 100644 index 0000000000000000000000000000000000000000..cabf43b5ddf813cbe89697372a21373f14921884 --- /dev/null +++ b/repairmask.txt @@ -0,0 +1 @@ +24 \ No newline at end of file