diff --git a/maskrecover.py b/maskrecover.py index d75c0aa9bc2b6061ef17b71b7bf2a3e751f33aba..b4d7b006cbdad8857c9de7096f8e3eacec369025 100755 --- a/maskrecover.py +++ b/maskrecover.py @@ -1,11 +1,19 @@ def read_file(): - ip_path = "router1_ip.txt" - mask_path = "router1_mask.txt" + router1_ip_path = "router1/router1_ip.txt" + router1_mask_path = "router1/router1_mask.txt" + router2_ip_path = "router2/router2_ip.txt" + router2_mask_path = "router2/router2_mask.txt" - with open(ip_path, "r") as file: - lines = file.readlines() - for line in lines: - print(line.strip()) + with open(router1_ip_path, "r") as file: + router1_ips = file.readlines() + with open(router1_mask_path, "r") as file: + router1_masks = file.readlines() + with open(router2_ip_path, "r") as file: + router2_ips = file.readlines() + with open(router2_mask_path, "r") as file: + router2_masks = file.readlines() + if router1_masks < router2_masks: + router1_masks[0] = router2_masks[0] if __name__ == "__main__": diff --git a/plays/test.yaml b/plays/test.yaml index 2fe522a48015dbad81ba148b94f9fe8812db6625..1f23be6af4294039407b17a63130fc891689a237 100644 --- a/plays/test.yaml +++ b/plays/test.yaml @@ -4,12 +4,22 @@ gather_facts: no connection: network_cli tasks: - - name: Show int info + - name: Show static ruting table cisco.ios.ios_command: commands: show ip static route - register: interfaces_info + register: routing_table - - name: Print output + - name: Print routing table copy: - content: "{{interfaces_info.stdout[0]}}" + content: "{{routing_table.stdout[0]}}" dest: ~/onlab/{{inventory_hostname}}/{{inventory_hostname}}.txt + + - name: Show config of interfaces gi0/1 + cisco.ios.ios_command: + commands: show running-config interface gigabitEthernet 0/1 + register: interface_config + + - name: Print interface config + copy: + content: "{{interface_config.stdout[0]}}" + dest: ~/onlab/{{inventory_hostname}}/{{inventory_hostname}}_interface.txt diff --git a/router1/router1_interface.txt b/router1/router1_interface.txt new file mode 100644 index 0000000000000000000000000000000000000000..6065c88a6b220444f6f9ed65380484fbd2b5ec05 --- /dev/null +++ b/router1/router1_interface.txt @@ -0,0 +1,10 @@ +Building configuration... + +Current configuration : 119 bytes +! +interface GigabitEthernet0/1 + ip address 10.10.20.169 255.255.255.248 + duplex auto + speed auto + media-type rj45 +end \ No newline at end of file diff --git a/router1/router1_ip.txt b/router1/router1_ip.txt index 382cf6af2f6eaa843b9ee613f4052b48f42a61c9..8c0e09b966050a6c677353fc561be2a890f774b6 100644 --- a/router1/router1_ip.txt +++ b/router1/router1_ip.txt @@ -1,2 +1,8 @@ 10.10.20.160 10.10.20.176 +10.10.20.160 +10.10.20.176 +10.10.20.160 +10.10.20.176 +10.10.20.160 +10.10.20.176 diff --git a/router1/router1_mask.txt b/router1/router1_mask.txt index bae7f4f14cf38bd26b5a1a76feb5cd73cc80d3da..7fd56bc38d88307511f3a068bcfcd6695225e3b7 100644 --- a/router1/router1_mask.txt +++ b/router1/router1_mask.txt @@ -1,2 +1,8 @@ 29 29 +29 +29 +29 +29 +29 +29 diff --git a/sort.sh b/sort.sh index 8cc53c7c4d6725b9f243f71342fbb19c45600175..9a6d5bd989a3136b3bb8a91e2ccb1d04cb0fda81 100755 --- a/sort.sh +++ b/sort.sh @@ -1,2 +1,4 @@ cat ./router1/router1.txt | grep "^M" | cut -d' ' -f3 | cut -d'/' -f1 >> ./router1/router1_ip.txt cat ./router1/router1.txt | grep "^M" | cut -d' ' -f3 | cut -d'/' -f2 >> ./router1/router1_mask.txt +cat ./router2/router2.txt | grep "^M" | cut -d' ' -f3 | cut -d'/' -f1 >> ./router2/router2_ip.txt +cat ./router2/router2.txt | grep "^M" | cut -d' ' -f3 | cut -d'/' -f2 >> ./router2/router2_mask.txt