From 8447ab8cc00e7516de62fe844cf9803fd0c1bf5a Mon Sep 17 00:00:00 2001
From: bmzsombi <bmzsombi@sch.bme.hu>
Date: Mon, 27 Nov 2023 19:19:06 +0100
Subject: [PATCH] asdwedw

---
 dest.txt                      |  1 +
 host.txt                      |  1 +
 networkxtest.py               | 37 ++++++++++++++++++++++++++++++++---
 playbooks/repair_routing.yaml |  8 +++-----
 repairip.txt                  |  1 +
 repairmask.txt                |  1 +
 6 files changed, 41 insertions(+), 8 deletions(-)
 create mode 100644 dest.txt
 create mode 100644 host.txt
 create mode 100644 repairip.txt
 create mode 100644 repairmask.txt

diff --git a/dest.txt b/dest.txt
new file mode 100644
index 0000000..e085b0b
--- /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 0000000..a8a2de6
--- /dev/null
+++ b/host.txt
@@ -0,0 +1 @@
+R5
\ No newline at end of file
diff --git a/networkxtest.py b/networkxtest.py
index 2133af4..d28c864 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 722fa6e..8c4c8db 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 0000000..b3e5df0
--- /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 0000000..cabf43b
--- /dev/null
+++ b/repairmask.txt
@@ -0,0 +1 @@
+24
\ No newline at end of file
-- 
GitLab