diff --git a/dest.txt b/dest.txt index ecf4fe4e64ef3f88b3ebbd64b952f06ff10608a6..cf06aab8d439b71a33fd9b39cef5ba7e60885326 100644 --- a/dest.txt +++ b/dest.txt @@ -1 +1 @@ -192.168.6.2 \ No newline at end of file +192.168.2.2 \ No newline at end of file diff --git a/host.txt b/host.txt index 5f6b3977c183d4c3c219e7faeb6bb656da265a87..4e19eec16deed110a2dc3bd521e44e939cecd032 100644 --- a/host.txt +++ b/host.txt @@ -1 +1 @@ -router5 \ No newline at end of file +router3 \ No newline at end of file diff --git a/networkxtest.py b/networkxtest.py index 0793be0b888ef95a99cd91b674f59937aca4d8dc..c97125899f659982bc9b83af734d0424e1ccd80b 100644 --- a/networkxtest.py +++ b/networkxtest.py @@ -38,7 +38,7 @@ def read(): newitem = Host() - os.system('ansible-playbook playbooks/get_informations.yaml -i inventory/hosts.yaml --ask-pass') + #os.system('ansible-playbook playbooks/get_informations.yaml -i inventory/hosts.yaml --ask-pass') routersNumber = int(input("Adja meg hany router van a halozatban (szammal): ")) @@ -129,22 +129,6 @@ def checkroutings(): for j in i: for x in hosts: if j == x.name: - for pindex, p in enumerate(x.networks): - if searchedNetwork == p: - if searchedMask != x.masks[pindex]: - 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]) for pindex, p in enumerate(x.sroutes): if searchedNetwork == p: if searchedMask != x.smasks[pindex]: @@ -160,8 +144,14 @@ def checkroutings(): if h == k: h = open("dest.txt", "w") h.write(elozo.ips[index]) - #print(elozo.ips[index]) - print(elozo.name) + repairtables() + if searchedMask < x.smasks[pindex]: + print(searchedMask + " " + x.smasks[pindex]) + l = open("oldmask.txt", "w") + ipmask = ipaddress.IPv4Network((0, x.smasks[pindex])) + l.write(str(ipmask.netmask)) + delete() + print(elozo.name + " " + j) elozo = getelement(j) def getelement(element): @@ -169,8 +159,12 @@ def getelement(element): if i.name == element: return i +def delete(): + #os.system('ansible-playbook playbooks/delete_routing.yaml -i inventory/hosts.yaml --ask-pass') + print("deleted") + def repairtables(): - os.system('ansible-playbook playbooks/repair_routing.yaml -i inventory/hosts.yaml --ask-pass') + #os.system('ansible-playbook playbooks/repair_routing.yaml -i inventory/hosts.yaml --ask-pass') print("routing javitva") def draw(): @@ -186,7 +180,6 @@ def main(): graphConstruct() findpath() checkroutings() - repairtables() draw() clear() diff --git a/oldmask.txt b/oldmask.txt new file mode 100644 index 0000000000000000000000000000000000000000..0c142776fd4f17005b37fa34a2135c9a654054ea --- /dev/null +++ b/oldmask.txt @@ -0,0 +1 @@ +255.255.255.192 \ No newline at end of file diff --git a/playbooks/delete_routing.yaml b/playbooks/delete_routing.yaml new file mode 100644 index 0000000000000000000000000000000000000000..624696ed893b79cd7e53339133df7ffc8bb10674 --- /dev/null +++ b/playbooks/delete_routing.yaml @@ -0,0 +1,11 @@ +--- +- name: Repair routing mask + hosts: "{{ lookup('file', '~/onlab/host.txt') }}" + gather_facts: false + connection: network_cli + tasks: + - name: Mask repair + cisco.ios.ios_command: + commands: + - configure terminal + - ip route {{ lookup('file', '~/onlab/repairip.txt') }} {{ lookup('file', '~/onlab/oldmask.txt' ) }} {{ lookup('file', '~/onlab/dest.txt') }} \ No newline at end of file diff --git a/router5/router5_routes.txt b/router5/router5_routes.txt index 8f03e5d5ec78eafb974c2090a9a9e75e57c73c52..70658d0b6b297c0ab99741887f1c5a80501b708a 100644 --- a/router5/router5_routes.txt +++ b/router5/router5_routes.txt @@ -13,7 +13,7 @@ Gateway of last resort is not set 10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks C 10.10.1.0/24 is directly connected, GigabitEthernet1/0/43 L 10.10.1.6/32 is directly connected, GigabitEthernet1/0/43 -S 192.168.2.0/23 [1/0] via 192.168.6.2 +S 192.168.2.0/26 [1/0] via 192.168.6.2 192.168.6.0/24 is variably subnetted, 2 subnets, 2 masks C 192.168.6.0/24 is directly connected, GigabitEthernet1/0/1 L 192.168.6.1/32 is directly connected, GigabitEthernet1/0/1 \ No newline at end of file