Compare commits
17 Commits
328d48f861
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 2d2362815b | |||
| bd4bc7cb24 | |||
| 0b7d66777e | |||
| 558a4c30f7 | |||
| 39f8b87743 | |||
| ff878558f9 | |||
| f3f157318a | |||
| 1948a6c927 | |||
| 6aadc1e8e1 | |||
| bd0942782a | |||
| adc251afe6 | |||
| 72a79ee83f | |||
| ee6b19082a | |||
| dcb967dc2f | |||
| 2389e11ed5 | |||
| ef4dffe5ef | |||
| 5c7fa4d11a |
109
Pipfile.lock.old
Normal file
109
Pipfile.lock.old
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
{
|
||||||
|
"_meta": {
|
||||||
|
"hash": {
|
||||||
|
"sha256": "918d1549cca9dcec46bd830771c96b3ef413742ea1b7c178caca4e709bf894ae"
|
||||||
|
},
|
||||||
|
"pipfile-spec": 6,
|
||||||
|
"requires": {
|
||||||
|
"python_version": "3.12"
|
||||||
|
},
|
||||||
|
"sources": [
|
||||||
|
{
|
||||||
|
"name": "pypi",
|
||||||
|
"url": "https://pypi.org/simple",
|
||||||
|
"verify_ssl": true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"default": {
|
||||||
|
"nornir": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:7e273d7b2aa519fa84b4fbbeb74ac5df3595d80105009049f0157c72a345b0b2",
|
||||||
|
"sha256:f0d212999a37bc5962534738c47099b3e11a45d8f7dc8bc855530f7fb73d2f64"
|
||||||
|
],
|
||||||
|
"index": "pypi",
|
||||||
|
"markers": "python_version >= '3.9' and python_version < '4.0'",
|
||||||
|
"version": "==3.5.0"
|
||||||
|
},
|
||||||
|
"ruamel.yaml": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:048f26d64245bae57a4f9ef6feb5b552a386830ef7a826f235ffb804c59efbba",
|
||||||
|
"sha256:a6e587512f3c998b2225d68aa1f35111c29fad14aed561a26e73fab729ec5e5a"
|
||||||
|
],
|
||||||
|
"markers": "python_version >= '3.8'",
|
||||||
|
"version": "==0.18.16"
|
||||||
|
},
|
||||||
|
"ruamel.yaml.clib": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:090782b5fb9d98df96509eecdbcaffd037d47389a89492320280d52f91330d78",
|
||||||
|
"sha256:0a54e5e40a7a691a426c2703b09b0d61a14294d25cfacc00631aa6f9c964df0d",
|
||||||
|
"sha256:10d9595b6a19778f3269399eff6bab642608e5966183abc2adbe558a42d4efc9",
|
||||||
|
"sha256:13997d7d354a9890ea1ec5937a219817464e5cc344805b37671562a401ca3008",
|
||||||
|
"sha256:16a60d69f4057ad9a92f3444e2367c08490daed6428291aa16cefb445c29b0e9",
|
||||||
|
"sha256:18c041b28f3456ddef1f1951d4492dbebe0f8114157c1b3c981a4611c2020792",
|
||||||
|
"sha256:1c1acc3a0209ea9042cc3cfc0790edd2eddd431a2ec3f8283d081e4d5018571e",
|
||||||
|
"sha256:1f118b707eece8cf84ecbc3e3ec94d9db879d85ed608f95870d39b2d2efa5dca",
|
||||||
|
"sha256:2070bf0ad1540d5c77a664de07ebcc45eebd1ddcab71a7a06f26936920692beb",
|
||||||
|
"sha256:26a8de280ab0d22b6e3ec745b4a5a07151a0f74aad92dd76ab9c8d8d7087720d",
|
||||||
|
"sha256:275f938692013a3883edbd848edde6d9f26825d65c9a2eb1db8baa1adc96a05d",
|
||||||
|
"sha256:27c070cf3888e90d992be75dd47292ff9aa17dafd36492812a6a304a1aedc182",
|
||||||
|
"sha256:29757bdb7c142f9595cc1b62ec49a3d1c83fab9cef92db52b0ccebaad4eafb98",
|
||||||
|
"sha256:4ccba93c1e5a40af45b2f08e4591969fa4697eae951c708f3f83dcbf9f6c6bb1",
|
||||||
|
"sha256:4f4a150a737fccae13fb51234d41304ff2222e3b7d4c8e9428ed1a6ab48389b8",
|
||||||
|
"sha256:557df28dbccf79b152fe2d1b935f6063d9cc431199ea2b0e84892f35c03bb0ee",
|
||||||
|
"sha256:5ac5ff9425d8acb8f59ac5b96bcb7fd3d272dc92d96a7c730025928ffcc88a7a",
|
||||||
|
"sha256:5bae1a073ca4244620425cd3d3aa9746bde590992b98ee8c7c8be8c597ca0d4e",
|
||||||
|
"sha256:5e56ac47260c0eed992789fa0b8efe43404a9adb608608631a948cee4fc2b052",
|
||||||
|
"sha256:6aeadc170090ff1889f0d2c3057557f9cd71f975f17535c26a5d37af98f19c27",
|
||||||
|
"sha256:6d5472f63a31b042aadf5ed28dd3ef0523da49ac17f0463e10fda9c4a2773352",
|
||||||
|
"sha256:70eda7703b8126f5e52fcf276e6c0f40b0d314674f896fc58c47b0aef2b9ae83",
|
||||||
|
"sha256:7df6f6e9d0e33c7b1d435defb185095386c469109de723d514142632a7b9d07f",
|
||||||
|
"sha256:7e4f9da7e7549946e02a6122dcad00b7c1168513acb1f8a726b1aaf504a99d32",
|
||||||
|
"sha256:803f5044b13602d58ea378576dd75aa759f52116a0232608e8fdada4da33752e",
|
||||||
|
"sha256:808c7190a0fe7ae7014c42f73897cf8e9ef14ff3aa533450e51b1e72ec5239ad",
|
||||||
|
"sha256:81f6d3b19bc703679a5705c6a16dabdc79823c71d791d73c65949be7f3012c02",
|
||||||
|
"sha256:83bbd8354f6abb3fdfb922d1ed47ad8d1db3ea72b0523dac8d07cdacfe1c0fcf",
|
||||||
|
"sha256:8dd3c2cc49caa7a8d64b67146462aed6723a0495e44bf0aa0a2e94beaa8432f6",
|
||||||
|
"sha256:915748cfc25b8cfd81b14d00f4bfdb2ab227a30d6d43459034533f4d1c207a2a",
|
||||||
|
"sha256:94f3efb718f8f49b031f2071ec7a27dd20cbfe511b4dfd54ecee54c956da2b31",
|
||||||
|
"sha256:9b4104bf43ca0cd4e6f738cb86326a3b2f6eef00f417bd1e7efb7bdffe74c539",
|
||||||
|
"sha256:9bd8fe07f49c170e09d76773fb86ad9135e0beee44f36e1576a201b0676d3d1d",
|
||||||
|
"sha256:9bf6b699223afe6c7fe9f2ef76e0bfa6dd892c21e94ce8c957478987ade76cd8",
|
||||||
|
"sha256:a05ba88adf3d7189a974b2de7a9d56731548d35dc0a822ec3dc669caa7019b29",
|
||||||
|
"sha256:a0ac90efbc7a77b0d796c03c8cc4e62fd710b3f1e4c32947713ef2ef52e09543",
|
||||||
|
"sha256:a0cb71ccc6ef9ce36eecb6272c81afdc2f565950cdcec33ae8e6cd8f7fc86f27",
|
||||||
|
"sha256:a37f40a859b503304dd740686359fcf541d6fb3ff7fc10f539af7f7150917c68",
|
||||||
|
"sha256:a911aa73588d9a8b08d662b9484bc0567949529824a55d3885b77e8dd62a127a",
|
||||||
|
"sha256:aef953f3b8bd0b50bd52a2e52fb54a6a2171a1889d8dea4a5959d46c6624c451",
|
||||||
|
"sha256:b28caeaf3e670c08cb7e8de221266df8494c169bd6ed8875493fab45be9607a4",
|
||||||
|
"sha256:b30110b29484adc597df6bd92a37b90e63a8c152ca8136aad100a02f8ba6d1b6",
|
||||||
|
"sha256:b5b0f7e294700b615a3bcf6d28b26e6da94e8eba63b079f4ec92e9ba6c0d6b54",
|
||||||
|
"sha256:c099cafc1834d3c5dac305865d04235f7c21c167c8dd31ebc3d6bbc357e2f023",
|
||||||
|
"sha256:d73a0187718f6eec5b2f729b0f98e4603f7bd9c48aa65d01227d1a5dcdfbe9e8",
|
||||||
|
"sha256:d8354515ab62f95a07deaf7f845886cc50e2f345ceab240a3d2d09a9f7d77853",
|
||||||
|
"sha256:dba72975485f2b87b786075e18a6e5d07dc2b4d8973beb2732b9b2816f1bad70",
|
||||||
|
"sha256:dd7546c851e59c06197a7c651335755e74aa383a835878ca86d2c650c07a2f85",
|
||||||
|
"sha256:df3ec9959241d07bc261f4983d25a1205ff37703faf42b474f15d54d88b4f8c9",
|
||||||
|
"sha256:e1d1735d97fd8a48473af048739379975651fab186f8a25a9f683534e6904179",
|
||||||
|
"sha256:e501c096aa3889133d674605ebd018471bc404a59cbc17da3c5924421c54d97c",
|
||||||
|
"sha256:e7cb9ad1d525d40f7d87b6df7c0ff916a66bc52cb61b66ac1b2a16d0c1b07640",
|
||||||
|
"sha256:f4e97a1cf0b7a30af9e1d9dad10a5671157b9acee790d9e26996391f49b965a2",
|
||||||
|
"sha256:f8b2acb0ffdd2ce8208accbec2dca4a06937d556fdcaefd6473ba1b5daa7e3c4",
|
||||||
|
"sha256:fb04c5650de6668b853623eceadcdb1a9f2fee381f5d7b6bc842ee7c239eeec4",
|
||||||
|
"sha256:fbc08c02e9b147a11dfcaa1ac8a83168b699863493e183f7c0c8b12850b7d259",
|
||||||
|
"sha256:ff86876889ea478b1381089e55cf9e345707b312beda4986f823e1d95e8c0f59"
|
||||||
|
],
|
||||||
|
"markers": "platform_python_implementation == 'CPython' and python_version < '3.14'",
|
||||||
|
"version": "==0.2.14"
|
||||||
|
},
|
||||||
|
"setuptools": {
|
||||||
|
"hashes": [
|
||||||
|
"sha256:062d34222ad13e0cc312a4c02d73f059e86a4acbfbdea8f8f76b28c99f306922",
|
||||||
|
"sha256:f36b47402ecde768dbfafc46e8e4207b4360c654f1f3bb84475f0a28628fb19c"
|
||||||
|
],
|
||||||
|
"markers": "python_version >= '3.9'",
|
||||||
|
"version": "==80.9.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"develop": {}
|
||||||
|
}
|
||||||
12
Pipfile.old
Normal file
12
Pipfile.old
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
[[source]]
|
||||||
|
url = "https://pypi.org/simple"
|
||||||
|
verify_ssl = true
|
||||||
|
name = "pypi"
|
||||||
|
|
||||||
|
[packages]
|
||||||
|
nornir = "*"
|
||||||
|
|
||||||
|
[dev-packages]
|
||||||
|
|
||||||
|
[requires]
|
||||||
|
python_version = "3.12"
|
||||||
BIN
TP-01/DEVNET-TP-01.pdf
Normal file
BIN
TP-01/DEVNET-TP-01.pdf
Normal file
Binary file not shown.
BIN
TP-02/DEVNET-TP-02.pdf
Normal file
BIN
TP-02/DEVNET-TP-02.pdf
Normal file
Binary file not shown.
14
TP-02/Pipfile
Normal file
14
TP-02/Pipfile
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
[[source]]
|
||||||
|
url = "https://pypi.org/simple"
|
||||||
|
verify_ssl = true
|
||||||
|
name = "pypi"
|
||||||
|
|
||||||
|
[packages]
|
||||||
|
jinja2 = "*"
|
||||||
|
netmiko = "*"
|
||||||
|
napalm = "*"
|
||||||
|
|
||||||
|
[dev-packages]
|
||||||
|
|
||||||
|
[requires]
|
||||||
|
python_version = "3.12"
|
||||||
1023
TP-02/Pipfile.lock
generated
Normal file
1023
TP-02/Pipfile.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
1
TP-02/backup/ESW2.bak
Normal file
1
TP-02/backup/ESW2.bak
Normal file
File diff suppressed because one or more lines are too long
1
TP-02/backup/ESW3.bak
Normal file
1
TP-02/backup/ESW3.bak
Normal file
File diff suppressed because one or more lines are too long
1
TP-02/backup/R01.bak
Normal file
1
TP-02/backup/R01.bak
Normal file
File diff suppressed because one or more lines are too long
1
TP-02/backup/R02.bak
Normal file
1
TP-02/backup/R02.bak
Normal file
File diff suppressed because one or more lines are too long
1
TP-02/backup/R03.bak
Normal file
1
TP-02/backup/R03.bak
Normal file
File diff suppressed because one or more lines are too long
8
TP-02/config/loopback_R01.conf
Normal file
8
TP-02/config/loopback_R01.conf
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
interface loopback 1
|
||||||
|
ip address 192.168.1.1 255.255.255.255
|
||||||
|
description "interface loopback 1"
|
||||||
|
no shut
|
||||||
|
interface loopback 2
|
||||||
|
ip address 192.168.2.1 255.255.255.255
|
||||||
|
description "interface loopback 2"
|
||||||
|
no shut
|
||||||
16
TP-02/config/loopback_R01.conf.bak
Normal file
16
TP-02/config/loopback_R01.conf.bak
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
interface loopback 1
|
||||||
|
ip address 192.168.1.1 255.255.255.255
|
||||||
|
description "interface loopback 1"
|
||||||
|
no shut
|
||||||
|
interface loopback 2
|
||||||
|
ip address 192.168.2.1 255.255.255.255
|
||||||
|
description "interface loopback 2"
|
||||||
|
no shut
|
||||||
|
interface loopback 3
|
||||||
|
ip address 192.168.3.1 255.255.255.255
|
||||||
|
description "interface loopback 3"
|
||||||
|
no shut
|
||||||
|
interface loopback 4
|
||||||
|
ip address 192.168.4.1 255.255.255.255
|
||||||
|
description "interface loopback 4"
|
||||||
|
no shut
|
||||||
14
TP-02/config/ospf_R1.conf
Normal file
14
TP-02/config/ospf_R1.conf
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
router ospf 1
|
||||||
|
router-id 1.1.1.1
|
||||||
|
|
||||||
|
network 172.16.10.0 0.0.0.255 area 0
|
||||||
|
|
||||||
|
network 172.16.20.0 0.0.0.255 area 0
|
||||||
|
|
||||||
|
network 172.16.100.0 0.0.0.63 area 0
|
||||||
|
|
||||||
|
network 10.1.3.0 0.0.0.3 area 0
|
||||||
|
|
||||||
|
network 10.1.1.0 0.0.0.3 area 0
|
||||||
|
|
||||||
|
end
|
||||||
14
TP-02/config/ospf_R2.conf
Normal file
14
TP-02/config/ospf_R2.conf
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
router ospf 1
|
||||||
|
router-id 2.2.2.2
|
||||||
|
|
||||||
|
network 172.16.30.0 0.0.0.255 area 0
|
||||||
|
|
||||||
|
network 172.16.40.0 0.0.0.255 area 0
|
||||||
|
|
||||||
|
network 172.16.100.64 0.0.0.63 area 0
|
||||||
|
|
||||||
|
network 10.1.2.0 0.0.0.3 area 0
|
||||||
|
|
||||||
|
network 10.1.1.0 0.0.0.3 area 0
|
||||||
|
|
||||||
|
end
|
||||||
14
TP-02/config/ospf_R3.conf
Normal file
14
TP-02/config/ospf_R3.conf
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
router ospf 1
|
||||||
|
router-id 3.3.3.3
|
||||||
|
|
||||||
|
network 172.16.50.0 0.0.0.255 area 0
|
||||||
|
|
||||||
|
network 172.16.60.0 0.0.0.255 area 0
|
||||||
|
|
||||||
|
network 172.16.100.192 0.0.0.63 area 0
|
||||||
|
|
||||||
|
network 10.1.3.0 0.0.0.3 area 0
|
||||||
|
|
||||||
|
network 10.1.2.0 0.0.0.3 area 0
|
||||||
|
|
||||||
|
end
|
||||||
30
TP-02/config/vlan_ESW2.conf
Normal file
30
TP-02/config/vlan_ESW2.conf
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
hostname ESW2
|
||||||
|
|
||||||
|
! Configuration des interfaces
|
||||||
|
|
||||||
|
interface f1/1
|
||||||
|
description Connexion vers le VLAN 10
|
||||||
|
|
||||||
|
switchport mode access
|
||||||
|
switchport access vlan 10
|
||||||
|
|
||||||
|
no shutdown
|
||||||
|
|
||||||
|
interface f1/2
|
||||||
|
description Connexion vers le VLAN 20
|
||||||
|
|
||||||
|
switchport mode access
|
||||||
|
switchport access vlan 20
|
||||||
|
|
||||||
|
no shutdown
|
||||||
|
|
||||||
|
interface f1/0
|
||||||
|
description Connexion vers le routeur R2
|
||||||
|
|
||||||
|
switchport mode trunk
|
||||||
|
switchport trunk allowed vlan add 10,20
|
||||||
|
|
||||||
|
no shutdown
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
30
TP-02/config/vlan_ESW3.conf
Normal file
30
TP-02/config/vlan_ESW3.conf
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
hostname ESW3
|
||||||
|
|
||||||
|
! Configuration des interfaces
|
||||||
|
|
||||||
|
interface f1/1
|
||||||
|
description Connexion vers le VLAN 10
|
||||||
|
|
||||||
|
switchport mode access
|
||||||
|
switchport access vlan 10
|
||||||
|
|
||||||
|
no shutdown
|
||||||
|
|
||||||
|
interface f1/2
|
||||||
|
description Connexion vers le VLAN 20
|
||||||
|
|
||||||
|
switchport mode access
|
||||||
|
switchport access vlan 20
|
||||||
|
|
||||||
|
no shutdown
|
||||||
|
|
||||||
|
interface f1/0
|
||||||
|
description Connexion vers le routeur R2
|
||||||
|
|
||||||
|
switchport mode trunk
|
||||||
|
switchport trunk allowed vlan add 10,20
|
||||||
|
|
||||||
|
no shutdown
|
||||||
|
|
||||||
|
|
||||||
|
end
|
||||||
15
TP-02/config/vlan_R02.conf
Normal file
15
TP-02/config/vlan_R02.conf
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
hostname R2
|
||||||
|
|
||||||
|
interface g0/0.10
|
||||||
|
description Gateway pour le reseau 172.16.30.0/24
|
||||||
|
ip address 172.16.30.254 255.255.255.0
|
||||||
|
encapsulation dot1Q 10
|
||||||
|
no shutdown
|
||||||
|
|
||||||
|
interface g0/0.20
|
||||||
|
description Gateway pour le reseau 172.16.40.0/24
|
||||||
|
ip address 172.16.40.254 255.255.255.0
|
||||||
|
encapsulation dot1Q 20
|
||||||
|
no shutdown
|
||||||
|
|
||||||
|
end
|
||||||
15
TP-02/config/vlan_R03.conf
Normal file
15
TP-02/config/vlan_R03.conf
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
hostname R3
|
||||||
|
|
||||||
|
interface g0/0.10
|
||||||
|
description Gateway pour le reseau 172.16.50.0/24
|
||||||
|
ip address 172.16.50.254 255.255.255.0
|
||||||
|
encapsulation dot1Q 10
|
||||||
|
no shutdown
|
||||||
|
|
||||||
|
interface g0/0.20
|
||||||
|
description Gateway pour le reseau 172.16.60.0/24
|
||||||
|
ip address 172.16.60.254 255.255.255.0
|
||||||
|
encapsulation dot1Q 20
|
||||||
|
no shutdown
|
||||||
|
|
||||||
|
end
|
||||||
11
TP-02/data/ospf_R01.json
Normal file
11
TP-02/data/ospf_R01.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"hostname": "R1",
|
||||||
|
"id_router": "1.1.1.1",
|
||||||
|
"networks": [
|
||||||
|
"172.16.10.0 0.0.0.255",
|
||||||
|
"172.16.20.0 0.0.0.255",
|
||||||
|
"172.16.100.0 0.0.0.63",
|
||||||
|
"10.1.3.0 0.0.0.3",
|
||||||
|
"10.1.1.0 0.0.0.3"
|
||||||
|
]
|
||||||
|
}
|
||||||
11
TP-02/data/ospf_R02.json
Normal file
11
TP-02/data/ospf_R02.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"hostname": "R2",
|
||||||
|
"id_router": "2.2.2.2",
|
||||||
|
"networks": [
|
||||||
|
"172.16.30.0 0.0.0.255",
|
||||||
|
"172.16.40.0 0.0.0.255",
|
||||||
|
"172.16.100.64 0.0.0.63",
|
||||||
|
"10.1.2.0 0.0.0.3",
|
||||||
|
"10.1.1.0 0.0.0.3"
|
||||||
|
]
|
||||||
|
}
|
||||||
11
TP-02/data/ospf_R03.json
Normal file
11
TP-02/data/ospf_R03.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"hostname": "R3",
|
||||||
|
"id_router": "3.3.3.3",
|
||||||
|
"networks": [
|
||||||
|
"172.16.50.0 0.0.0.255",
|
||||||
|
"172.16.60.0 0.0.0.255",
|
||||||
|
"172.16.100.192 0.0.0.63",
|
||||||
|
"10.1.3.0 0.0.0.3",
|
||||||
|
"10.1.2.0 0.0.0.3"
|
||||||
|
]
|
||||||
|
}
|
||||||
23
TP-02/data/vlan_ESW2.json
Normal file
23
TP-02/data/vlan_ESW2.json
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"hostname": "ESW2",
|
||||||
|
"interfaces": [
|
||||||
|
{
|
||||||
|
"name": "f1/1",
|
||||||
|
"mode": "access",
|
||||||
|
"vlan_id": "10",
|
||||||
|
"description": "Connexion vers le VLAN 10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "f1/2",
|
||||||
|
"mode": "access",
|
||||||
|
"vlan_id": "20",
|
||||||
|
"description": "Connexion vers le VLAN 20"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "f1/0",
|
||||||
|
"mode": "trunk",
|
||||||
|
"vlan_id": "10,20",
|
||||||
|
"description": "Connexion vers le routeur R2"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
23
TP-02/data/vlan_ESW3.json
Normal file
23
TP-02/data/vlan_ESW3.json
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
{
|
||||||
|
"hostname": "ESW3",
|
||||||
|
"interfaces": [
|
||||||
|
{
|
||||||
|
"name": "f1/1",
|
||||||
|
"mode": "access",
|
||||||
|
"vlan_id": "10",
|
||||||
|
"description": "Connexion vers le VLAN 10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "f1/2",
|
||||||
|
"mode": "access",
|
||||||
|
"vlan_id": "20",
|
||||||
|
"description": "Connexion vers le VLAN 20"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "f1/0",
|
||||||
|
"mode": "trunk",
|
||||||
|
"vlan_id": "10,20",
|
||||||
|
"description": "Connexion vers le routeur R2"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
19
TP-02/data/vlan_R02.json
Normal file
19
TP-02/data/vlan_R02.json
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"hostname": "R2",
|
||||||
|
"interfaces": [
|
||||||
|
{
|
||||||
|
"name": "g0/0.10",
|
||||||
|
"description": "Gateway pour le reseau 172.16.30.0/24",
|
||||||
|
"ip": "172.16.30.254",
|
||||||
|
"mask": "255.255.255.0",
|
||||||
|
"vlan_id": "10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "g0/0.20",
|
||||||
|
"description": "Gateway pour le reseau 172.16.40.0/24",
|
||||||
|
"ip": "172.16.40.254",
|
||||||
|
"mask": "255.255.255.0",
|
||||||
|
"vlan_id": "20"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
19
TP-02/data/vlan_R03.json
Normal file
19
TP-02/data/vlan_R03.json
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
{
|
||||||
|
"hostname": "R3",
|
||||||
|
"interfaces": [
|
||||||
|
{
|
||||||
|
"name": "g0/0.10",
|
||||||
|
"description": "Gateway pour le reseau 172.16.50.0/24",
|
||||||
|
"ip": "172.16.50.254",
|
||||||
|
"mask": "255.255.255.0",
|
||||||
|
"vlan_id": "10"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "g0/0.20",
|
||||||
|
"description": "Gateway pour le reseau 172.16.60.0/24",
|
||||||
|
"ip": "172.16.60.254",
|
||||||
|
"mask": "255.255.255.0",
|
||||||
|
"vlan_id": "20"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
44
TP-02/inventory/hosts.json
Normal file
44
TP-02/inventory/hosts.json
Normal file
@@ -0,0 +1,44 @@
|
|||||||
|
[
|
||||||
|
{
|
||||||
|
"hostname":"R01",
|
||||||
|
"ip":"172.16.100.126",
|
||||||
|
"device_type": "cisco_ios",
|
||||||
|
"username": "cisco",
|
||||||
|
"password": "cisco"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"hostname":"R02",
|
||||||
|
"ip":"172.16.100.190",
|
||||||
|
"device_type": "cisco_ios",
|
||||||
|
"username": "cisco",
|
||||||
|
"password": "cisco"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"hostname":"R03",
|
||||||
|
"ip":"172.16.100.254",
|
||||||
|
"device_type": "cisco_ios",
|
||||||
|
"username": "cisco",
|
||||||
|
"password": "cisco"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"hostname":"ESW1",
|
||||||
|
"ip":"172.16.100.125",
|
||||||
|
"device_type": "cisco_ios",
|
||||||
|
"username": "cisco",
|
||||||
|
"password": "cisco"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"hostname":"ESW2",
|
||||||
|
"ip":"172.16.100.189",
|
||||||
|
"device_type": "cisco_ios",
|
||||||
|
"username": "cisco",
|
||||||
|
"password": "cisco"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"hostname":"ESW3",
|
||||||
|
"ip":"172.16.100.253",
|
||||||
|
"device_type": "cisco_ios",
|
||||||
|
"username": "cisco",
|
||||||
|
"password": "cisco"
|
||||||
|
}
|
||||||
|
]
|
||||||
BIN
TP-02/scripts/__pycache__/create_config.cpython-312.pyc
Normal file
BIN
TP-02/scripts/__pycache__/create_config.cpython-312.pyc
Normal file
Binary file not shown.
BIN
TP-02/scripts/__pycache__/run_netmiko.cpython-312.pyc
Normal file
BIN
TP-02/scripts/__pycache__/run_netmiko.cpython-312.pyc
Normal file
Binary file not shown.
@@ -4,38 +4,85 @@ from jinja2 import Template, Environment, FileSystemLoader
|
|||||||
env = Environment(loader=FileSystemLoader("templates"))
|
env = Environment(loader=FileSystemLoader("templates"))
|
||||||
|
|
||||||
def load_json_data_from_file(file_path):
|
def load_json_data_from_file(file_path):
|
||||||
pass
|
with open(file_path) as json_file:
|
||||||
|
data = json.load(json_file)
|
||||||
|
return data
|
||||||
|
|
||||||
|
|
||||||
|
def load_yaml_data_from_file(file_path):
|
||||||
|
with open(file_path) as yaml_file:
|
||||||
|
data = yaml.safe_load(yaml_file)
|
||||||
|
return data
|
||||||
|
|
||||||
|
|
||||||
def render_network_config(template_name, data):
|
def render_network_config(template_name, data):
|
||||||
pass
|
template = env.get_template(template_name)
|
||||||
|
return template.render(data)
|
||||||
|
|
||||||
|
|
||||||
def save_built_config(file_name, data):
|
def save_built_config(file_name, data):
|
||||||
pass
|
with open(file_name, "w") as f:
|
||||||
|
f.write(data)
|
||||||
|
return file_name
|
||||||
|
|
||||||
def create_vlan_config_cpe_marseille():
|
def create_vlan_config_cpe_marseille():
|
||||||
"""
|
"""
|
||||||
Must return two values : router config and the switch config
|
Must return two values : router config and the switch config
|
||||||
"""
|
"""
|
||||||
pass
|
esw2_data = load_json_data_from_file(file_path='data/vlan_ESW2.json')
|
||||||
|
esw2_config = render_network_config(template_name='vlan_switch.j2', data=esw2_data)
|
||||||
|
|
||||||
|
R2_data = load_json_data_from_file(file_path='data/vlan_R02.json')
|
||||||
|
R2_config = render_network_config(template_name='vlan_router.j2', data=R2_data)
|
||||||
|
return R2_config,esw2_config
|
||||||
|
|
||||||
|
|
||||||
def create_vlan_config_cpe_paris():
|
def create_vlan_config_cpe_paris():
|
||||||
"""
|
"""
|
||||||
Must return two values : router config and the switch config
|
Must return two values : router config and the switch config
|
||||||
"""
|
"""
|
||||||
pass
|
esw3_data = load_json_data_from_file(file_path='data/vlan_ESW3.json')
|
||||||
|
esw3_config = render_network_config(template_name='vlan_switch.j2', data=esw3_data)
|
||||||
|
|
||||||
|
R3_data = load_json_data_from_file(file_path='data/vlan_R03.json')
|
||||||
|
R3_config = render_network_config(template_name='vlan_router.j2', data=R3_data)
|
||||||
|
return R3_config,esw3_config
|
||||||
|
|
||||||
|
def create_ospf_config_cpe_marseille():
|
||||||
|
R1_data = load_json_data_from_file(file_path='data/ospf_R01.json')
|
||||||
|
R1_config = render_network_config(template_name='config_ospf.j2', data=R1_data)
|
||||||
|
|
||||||
|
return R1_config
|
||||||
|
|
||||||
|
def create_ospf_config_cpe_paris():
|
||||||
|
R2_data = load_json_data_from_file(file_path='data/ospf_R02.json')
|
||||||
|
R2_config = render_network_config(template_name='config_ospf.j2', data=R2_data)
|
||||||
|
|
||||||
|
return R2_config
|
||||||
|
|
||||||
|
def create_ospf_config_cpe_lyon():
|
||||||
|
R3_data = load_json_data_from_file(file_path='data/ospf_R03.json')
|
||||||
|
R3_config = render_network_config(template_name='config_ospf.j2', data=R3_data)
|
||||||
|
|
||||||
|
return R3_config
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
"""
|
"""
|
||||||
process question 1 to 5:
|
process question 1 to 5:
|
||||||
"""
|
"""
|
||||||
# r02_config, esw2_config = create_vlan_config_cpe_marseille()
|
r02_config, esw2_config = create_vlan_config_cpe_marseille()
|
||||||
# save_built_config('config/vlan_R02.conf', r02_config)
|
save_built_config('config/vlan_R02.conf', r02_config)
|
||||||
# save_built_config('config/vlan_ESW2.conf', esw2_config)
|
save_built_config('config/vlan_ESW2.conf', esw2_config)
|
||||||
|
|
||||||
|
r03_config, esw3_config = create_vlan_config_cpe_paris()
|
||||||
|
save_built_config('config/vlan_R03.conf', r03_config)
|
||||||
|
save_built_config('config/vlan_ESW3.conf', esw3_config)
|
||||||
|
|
||||||
|
R1_ospf_config = create_ospf_config_cpe_marseille()
|
||||||
|
save_built_config('config/ospf_R1.conf', R1_ospf_config)
|
||||||
|
R2_ospf_config = create_ospf_config_cpe_paris()
|
||||||
|
save_built_config('config/ospf_R2.conf', R2_ospf_config)
|
||||||
|
R3_ospf_config = create_ospf_config_cpe_lyon()
|
||||||
|
save_built_config('config/ospf_R3.conf', R3_ospf_config)
|
||||||
|
|
||||||
|
|
||||||
# r03_config, esw3_config = create_vlan_config_cpe_paris()
|
|
||||||
# save_built_config('config/vlan_R03.conf', r03_config)
|
|
||||||
# save_built_config('config/vlan_ESW3.conf', esw3_config)
|
|
||||||
|
|||||||
@@ -1,56 +1,123 @@
|
|||||||
import json
|
import json
|
||||||
from napalm import get_network_driver
|
from napalm import get_network_driver
|
||||||
|
def save_built_config(file_name, data):
|
||||||
|
with open(file_name, "w") as f:
|
||||||
|
f.write(data)
|
||||||
|
return file_name
|
||||||
|
|
||||||
def get_inventory():
|
def get_inventory():
|
||||||
pass
|
"""
|
||||||
|
Lit le fichier inventory/hosts.json et retourne son contenu.
|
||||||
|
"""
|
||||||
|
inventory_file = "inventory/hosts.json"
|
||||||
|
try:
|
||||||
|
with open(inventory_file, "r") as f:
|
||||||
|
data = json.load(f)
|
||||||
|
return data
|
||||||
|
except FileNotFoundError:
|
||||||
|
print(f"Erreur : le fichier {inventory_file} n'existe pas.")
|
||||||
|
return []
|
||||||
|
|
||||||
def get_json_data_from_file(file):
|
def get_json_data_from_file(file):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def question_26(device):
|
def question_26(device):
|
||||||
pass
|
command = ['show ip interface brief']
|
||||||
|
output = device.cli(command)
|
||||||
|
|
||||||
def question_27(device):
|
def question_27(device):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
|
||||||
def question_28(device):
|
def question_28(device):
|
||||||
pass
|
command = ['show ip interface brief']
|
||||||
|
output = device.cli(command)
|
||||||
|
print(type(output))
|
||||||
|
|
||||||
def question_29(device):
|
def question_29(device):
|
||||||
pass
|
#output = device.get_config()
|
||||||
|
output = device.get_arp_table()
|
||||||
|
print(output)
|
||||||
|
|
||||||
|
|
||||||
def question_30(device):
|
def question_30(device):
|
||||||
pass
|
output = device.get_arp_table()
|
||||||
|
print(type(output))
|
||||||
|
|
||||||
|
|
||||||
def question_31():
|
def question_31():
|
||||||
pass
|
device.load_merge_candidate(filename='config/loopback_R01.conf')
|
||||||
|
print(device.compare_config())
|
||||||
|
device.commit_config()
|
||||||
|
|
||||||
|
|
||||||
def question_32():
|
def question_33():
|
||||||
pass
|
r01 = {
|
||||||
|
'hostname': '172.16.100.62',
|
||||||
|
'username': 'cisco',
|
||||||
|
'password': 'cisco'
|
||||||
|
}
|
||||||
|
r02 = {
|
||||||
|
'hostname': '172.16.100.190',
|
||||||
|
'username': 'cisco',
|
||||||
|
'password': 'cisco'
|
||||||
|
}
|
||||||
|
r03 = {
|
||||||
|
'hostname': '172.16.100.254',
|
||||||
|
'username': 'cisco',
|
||||||
|
'password': 'cisco'
|
||||||
|
}
|
||||||
|
|
||||||
|
routers = {'1': r01, '2': r02, '3': r03}
|
||||||
|
|
||||||
def question_34():
|
for i in range(1, 4):
|
||||||
pass
|
driver = get_network_driver('ios')
|
||||||
|
device = driver(**routers[str(i)])
|
||||||
|
device.open()
|
||||||
|
device.load_merge_candidate(filename=f'config/ospf_R{i}.conf')
|
||||||
|
print(device.compare_config())
|
||||||
|
device.commit_config()
|
||||||
|
device.close()
|
||||||
|
|
||||||
|
def question_35():
|
||||||
|
liste_hosts = get_inventory()
|
||||||
|
|
||||||
|
for host in liste_hosts:
|
||||||
|
nom_host = host['hostname']
|
||||||
|
|
||||||
|
connexion_info = {
|
||||||
|
'hostname': host['ip'],
|
||||||
|
'username': host['username'],
|
||||||
|
'password': host['password']
|
||||||
|
}
|
||||||
|
|
||||||
|
try:
|
||||||
|
driver_ios = get_network_driver('ios')
|
||||||
|
device = driver_ios(**connexion_info)
|
||||||
|
device.open()
|
||||||
|
config_sauvegarde = device.get_config()
|
||||||
|
|
||||||
|
with open(f'backup/{nom_host}.bak', 'w') as fichier_sauvegarde:
|
||||||
|
fichier_sauvegarde.write(str(config_sauvegarde))
|
||||||
|
|
||||||
|
device.close()
|
||||||
|
|
||||||
|
except Exception as erreur:
|
||||||
|
print(f"Erreur lors de la connexion à {nom_host} : {erreur}")
|
||||||
|
continue
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
r01 = {
|
r01 = {
|
||||||
'hostname':'xx.xx.xx.xx',
|
'hostname':'172.16.100.62',
|
||||||
'username': "xx",
|
'username': "cisco",
|
||||||
'password': "xx"
|
'password': "cisco"
|
||||||
}
|
}
|
||||||
|
|
||||||
# driver = get_network_driver('ios')
|
driver = get_network_driver('ios')
|
||||||
# device = driver(**r01)
|
device = driver(**r01)
|
||||||
# device.open()
|
device.open()
|
||||||
|
|
||||||
#question_26(device)
|
#question_26(device)
|
||||||
#question_27(device)
|
#question_27(device)
|
||||||
@@ -58,5 +125,5 @@ if __name__ == "__main__":
|
|||||||
#question_29(device)
|
#question_29(device)
|
||||||
#question_30(device)
|
#question_30(device)
|
||||||
#question_31()
|
#question_31()
|
||||||
#question_32()
|
#question_33()
|
||||||
#question_34()
|
question_35()
|
||||||
@@ -2,39 +2,111 @@ import json
|
|||||||
from netmiko import ConnectHandler
|
from netmiko import ConnectHandler
|
||||||
|
|
||||||
def question_9(net_connect):
|
def question_9(net_connect):
|
||||||
pass
|
print(net_connect.__dict__)
|
||||||
|
print("Adresse IP :", net_connect.host)
|
||||||
|
print("Device type :", net_connect.device_type)
|
||||||
|
|
||||||
|
|
||||||
def question_10(net_connect):
|
def question_10(net_connect):
|
||||||
pass
|
output = net_connect.send_command("show ip interface brief")
|
||||||
|
print(output)
|
||||||
|
|
||||||
def question_11(net_connect):
|
def question_11(net_connect):
|
||||||
pass
|
output = net_connect.send_command("show ip interface brief", use_textfsm=True)
|
||||||
|
print(type(output))
|
||||||
|
|
||||||
def question_12(net_connect):
|
def question_12(net_connect):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def question_13(net_connect):
|
def question_13(net_connect):
|
||||||
pass
|
output = net_connect.send_command("show ip route", use_textfsm=True)
|
||||||
|
print(output)
|
||||||
|
print(type(output))
|
||||||
|
|
||||||
|
|
||||||
def question_14(net_connect):
|
def question_14(net_connect):
|
||||||
pass
|
interfaces_status = net_connect.send_command("show ip interface brief", use_textfsm=True)
|
||||||
|
print("État des interfaces du routeur R1 :")
|
||||||
|
#print(interfaces_status)
|
||||||
|
|
||||||
|
for iface in interfaces_status:
|
||||||
|
intf_name = iface['interface']
|
||||||
|
print(f"\nConfiguration de l'interface {intf_name} :")
|
||||||
|
config = net_connect.send_command(f"show run interface {intf_name}")
|
||||||
|
print(config)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def question_15(net_connect):
|
def question_15(net_connect):
|
||||||
pass
|
# Liste de commandes pour créer l'interface Loopback
|
||||||
|
loopback_cmds = [
|
||||||
|
"interface loopback1",
|
||||||
|
"ip address 192.168.1.1 255.255.255.255",
|
||||||
|
"description loopback interface from netmiko",
|
||||||
|
"no shutdown"
|
||||||
|
]
|
||||||
|
|
||||||
|
# Exécution des commandes en mode configuration
|
||||||
|
output = net_connect.send_config_set(loopback_cmds)
|
||||||
|
print("Résultat de la configuration :")
|
||||||
|
print(output)
|
||||||
|
|
||||||
|
# Sauvegarder la configuration
|
||||||
|
save_output = net_connect.save_config()
|
||||||
|
print("\nConfiguration sauvegardée :")
|
||||||
|
print(save_output)
|
||||||
|
|
||||||
def question_16(net_connect):
|
def question_16(net_connect):
|
||||||
pass
|
# Exécution en mode configuration
|
||||||
|
output = net_connect.send_config_set("no interface loopback1")
|
||||||
|
print("Résultat de la suppression de loopback1 :")
|
||||||
|
print(output)
|
||||||
|
|
||||||
|
# Sauvegarder la configuration
|
||||||
|
save_output = net_connect.save_config()
|
||||||
|
print("\nConfiguration sauvegardée après suppression :")
|
||||||
|
print(save_output)
|
||||||
|
|
||||||
|
|
||||||
def question_17(net_connect):
|
def question_17(net_connect):
|
||||||
pass
|
# Lire les commandes depuis le fichier
|
||||||
|
with open("config/loopback_R01.conf", "r") as f:
|
||||||
|
commands = [line.strip() for line in f if line.strip()] # ignore les lignes vides
|
||||||
|
|
||||||
|
# Exécuter les commandes en mode configuration
|
||||||
|
output = net_connect.send_config_set(commands)
|
||||||
|
print("Résultat de l'exécution des commandes :")
|
||||||
|
print(output)
|
||||||
|
|
||||||
|
# Sauvegarder la configuration
|
||||||
|
save_output = net_connect.save_config()
|
||||||
|
print("\nConfiguration sauvegardée :")
|
||||||
|
print(save_output)
|
||||||
|
|
||||||
|
def question_18(net_connect):
|
||||||
|
for i in range(1, 5):
|
||||||
|
loopback_name = f"loopback{i}"
|
||||||
|
commands = [f"no interface {loopback_name}"]
|
||||||
|
print(f"\nSuppression de l'interface {loopback_name} :")
|
||||||
|
output = net_connect.send_config_set(commands)
|
||||||
|
print(output)
|
||||||
|
# Sauvegarder la configuration
|
||||||
|
save_output = net_connect.save_config()
|
||||||
|
print("\nConfiguration sauvegardée :")
|
||||||
|
print(save_output)
|
||||||
|
|
||||||
def get_inventory():
|
def get_inventory():
|
||||||
pass
|
"""
|
||||||
|
Lit le fichier inventory/hosts.json et retourne son contenu.
|
||||||
|
"""
|
||||||
|
inventory_file = "inventory/hosts.json"
|
||||||
|
try:
|
||||||
|
with open(inventory_file, "r") as f:
|
||||||
|
data = json.load(f)
|
||||||
|
return data
|
||||||
|
except FileNotFoundError:
|
||||||
|
print(f"Erreur : le fichier {inventory_file} n'existe pas.")
|
||||||
|
return []
|
||||||
|
|
||||||
|
|
||||||
def question_20():
|
def question_20():
|
||||||
@@ -42,16 +114,70 @@ def question_20():
|
|||||||
|
|
||||||
|
|
||||||
def question_21():
|
def question_21():
|
||||||
pass
|
inventory = get_inventory()
|
||||||
|
|
||||||
|
for device in inventory:
|
||||||
|
print(f"\n=== Connexion au routeur {device['hostname']} ({device['ip']}) ===")
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Connexion au routeur
|
||||||
|
net_connect = ConnectHandler(
|
||||||
|
device_type=device["device_type"],
|
||||||
|
host=device["ip"],
|
||||||
|
username=device["username"],
|
||||||
|
password=device["password"]
|
||||||
|
)
|
||||||
|
|
||||||
|
# Commande à exécuter
|
||||||
|
command = "show run interface GigabitEthernet0/0.99"
|
||||||
|
output = net_connect.send_command(command)
|
||||||
|
|
||||||
|
print(f"\nConfiguration de GigabitEthernet0/0.99 sur {device['hostname']} :\n")
|
||||||
|
print(output)
|
||||||
|
|
||||||
|
net_connect.disconnect()
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print(f"❌ Erreur sur {device['hostname']} : {e}")
|
||||||
|
def question_22():
|
||||||
|
inventory = get_inventory()
|
||||||
|
|
||||||
|
for device in inventory:
|
||||||
|
# On ne traite pas les routeurs dont le hostname != 'R1' de ESW1
|
||||||
|
if 'R1' == device["hostname"] or 'ESW1' == device["hostname"]:
|
||||||
|
continue
|
||||||
|
|
||||||
|
print(f"\n=== Connexion au routeur {device['hostname']} ({device['ip']}) ===")
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Paramètres de connexion
|
||||||
|
device_params = {
|
||||||
|
'device_type': device['device_type'],
|
||||||
|
'host': device['ip'],
|
||||||
|
'username': device['username'],
|
||||||
|
'password': device['password']
|
||||||
|
}
|
||||||
|
net_connect = ConnectHandler(**device_params)
|
||||||
|
net_connect.enable()
|
||||||
|
|
||||||
|
# affiche le hostname
|
||||||
|
print(f"Connexion réussie sur {device['hostname']}")
|
||||||
|
|
||||||
|
config_file = f'config/vlan_{device["hostname"]}.conf'
|
||||||
|
output = net_connect.send_config_from_file(config_file)
|
||||||
|
print(f"\nRésultat de l'application de la configuration sur {device['hostname']} :\n{output}")
|
||||||
|
|
||||||
|
# Sauvegarde la configuration
|
||||||
|
save_output = net_connect.save_config()
|
||||||
|
print(f"\nSauvegarde de la configuration sur {device['hostname']} :\n{save_output}")
|
||||||
|
|
||||||
|
net_connect.disconnect()
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
print(f"❌ Erreur sur {device['hostname']} : {e}")
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
r01 = {
|
|
||||||
'device_type': 'cisco_ios',
|
|
||||||
'host': 'xx.xx.xx.xx',
|
|
||||||
'username': 'xx',
|
|
||||||
'password': 'xx'
|
|
||||||
}
|
|
||||||
#net_connect = ConnectHandler(**r01)
|
|
||||||
|
|
||||||
#question_9(net_connect)
|
#question_9(net_connect)
|
||||||
#question_10(net_connect)
|
#question_10(net_connect)
|
||||||
@@ -62,7 +188,9 @@ if __name__ == "__main__":
|
|||||||
#question_15(net_connect)
|
#question_15(net_connect)
|
||||||
#question_16(net_connect)
|
#question_16(net_connect)
|
||||||
#question_17(net_connect)
|
#question_17(net_connect)
|
||||||
# hosts = get_inventory()
|
#question_18(net_connect)
|
||||||
# print(hosts)
|
hosts = get_inventory()
|
||||||
|
#print(hosts)
|
||||||
#question_20()
|
#question_20()
|
||||||
#question_21()
|
#question_21()
|
||||||
|
question_22()
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
# TEMPLATES
|
|
||||||
|
|
||||||
**This directory is required.**
|
|
||||||
|
|
||||||
The templates directory contains your jinja.j2 files.
|
|
||||||
6
TP-02/templates/config_ospf.j2
Normal file
6
TP-02/templates/config_ospf.j2
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
router ospf 1
|
||||||
|
router-id {{ id_router }}
|
||||||
|
{% for network in networks %}
|
||||||
|
network {{ network }} area 0
|
||||||
|
{% endfor %}
|
||||||
|
end
|
||||||
9
TP-02/templates/vlan_router.j2
Normal file
9
TP-02/templates/vlan_router.j2
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
hostname {{ hostname }}
|
||||||
|
{% for interface in interfaces %}
|
||||||
|
interface {{ interface.name }}
|
||||||
|
description {{ interface.description }}
|
||||||
|
ip address {{ interface.ip }} {{ interface.mask }}
|
||||||
|
encapsulation dot1Q {{ interface.vlan_id }}
|
||||||
|
no shutdown
|
||||||
|
{% endfor %}
|
||||||
|
end
|
||||||
22
TP-02/templates/vlan_switch.j2
Normal file
22
TP-02/templates/vlan_switch.j2
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
hostname {{ hostname }}
|
||||||
|
|
||||||
|
! Configuration des interfaces
|
||||||
|
{% for interface in interfaces %}
|
||||||
|
interface {{ interface.name }}
|
||||||
|
description {{ interface.description }}
|
||||||
|
{% if interface.mode == "access" %}
|
||||||
|
switchport mode access
|
||||||
|
switchport access vlan {{ interface.vlan_id }}
|
||||||
|
{% elif interface.mode == "trunk" %}
|
||||||
|
switchport mode trunk
|
||||||
|
switchport trunk allowed vlan add {{ interface.vlan_id }}
|
||||||
|
{% endif %}
|
||||||
|
no shutdown
|
||||||
|
{% endfor %}
|
||||||
|
{% if management is defined %}
|
||||||
|
! Configuration de l'IP de management
|
||||||
|
interface vlan {{ management.vlan }}
|
||||||
|
ip address {{ management.ip_address }} {{ management.subnet }}
|
||||||
|
no shutdown
|
||||||
|
{% endif %}
|
||||||
|
end
|
||||||
16
TP_03/Pipfile
Normal file
16
TP_03/Pipfile
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
[[source]]
|
||||||
|
url = "https://pypi.org/simple"
|
||||||
|
verify_ssl = true
|
||||||
|
name = "pypi"
|
||||||
|
|
||||||
|
[packages]
|
||||||
|
jinja2 = "*"
|
||||||
|
nornir = "*"
|
||||||
|
nornir-utils = "*"
|
||||||
|
nornir-napalm = "*"
|
||||||
|
nornir-netmiko = "*"
|
||||||
|
|
||||||
|
[dev-packages]
|
||||||
|
|
||||||
|
[requires]
|
||||||
|
python_version = "3.12"
|
||||||
1071
TP_03/Pipfile.lock
generated
Normal file
1071
TP_03/Pipfile.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
30
TP_03/config/ESW1_CPE_LYON_BAT_A.conf
Normal file
30
TP_03/config/ESW1_CPE_LYON_BAT_A.conf
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
|
||||||
|
vlan 10
|
||||||
|
name teacher
|
||||||
|
exit
|
||||||
|
vlan 20
|
||||||
|
name student
|
||||||
|
exit
|
||||||
|
|
||||||
|
|
||||||
|
interface fa1/14
|
||||||
|
switchport mode trunk
|
||||||
|
switchport trunk allowed vlan all
|
||||||
|
exit
|
||||||
|
|
||||||
|
interface fa1/15
|
||||||
|
switchport mode trunk
|
||||||
|
switchport trunk allowed vlan all
|
||||||
|
exit
|
||||||
|
|
||||||
|
interface fa1/1
|
||||||
|
switchport mode access
|
||||||
|
switchport access vlan 10
|
||||||
|
description "port vlan teacher"
|
||||||
|
exit
|
||||||
|
|
||||||
|
interface fa1/2
|
||||||
|
switchport mode access
|
||||||
|
switchport access vlan 20
|
||||||
|
description "port vlan student"
|
||||||
|
exit
|
||||||
30
TP_03/config/ESW1_CPE_LYON_BAT_B.conf
Normal file
30
TP_03/config/ESW1_CPE_LYON_BAT_B.conf
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
|
||||||
|
vlan 10
|
||||||
|
name teacher
|
||||||
|
exit
|
||||||
|
vlan 20
|
||||||
|
name student
|
||||||
|
exit
|
||||||
|
|
||||||
|
|
||||||
|
interface fa1/14
|
||||||
|
switchport mode trunk
|
||||||
|
switchport trunk allowed vlan all
|
||||||
|
exit
|
||||||
|
|
||||||
|
interface fa1/15
|
||||||
|
switchport mode trunk
|
||||||
|
switchport trunk allowed vlan all
|
||||||
|
exit
|
||||||
|
|
||||||
|
interface fa1/1
|
||||||
|
switchport mode access
|
||||||
|
switchport access vlan 10
|
||||||
|
description "port vlan teacher"
|
||||||
|
exit
|
||||||
|
|
||||||
|
interface fa1/2
|
||||||
|
switchport mode access
|
||||||
|
switchport access vlan 20
|
||||||
|
description "port vlan student"
|
||||||
|
exit
|
||||||
15
TP_03/config/R1_CPE_LYON_BAT_A.conf
Normal file
15
TP_03/config/R1_CPE_LYON_BAT_A.conf
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
|
||||||
|
interface g2/0
|
||||||
|
no shutdown
|
||||||
|
exit
|
||||||
|
interface g2/0.10
|
||||||
|
encapsulation dot1Q 10
|
||||||
|
description "Gateway for teacher vlan"
|
||||||
|
ip address 172.16.10.253 255.255.255.0
|
||||||
|
exit
|
||||||
|
|
||||||
|
interface g2/0.20
|
||||||
|
encapsulation dot1Q 20
|
||||||
|
description "Gateway for student vlan"
|
||||||
|
ip address 172.16.20.253 255.255.255.0
|
||||||
|
exit
|
||||||
10
TP_03/config/R1_CPE_LYON_BAT_A_OSPF.conf
Normal file
10
TP_03/config/R1_CPE_LYON_BAT_A_OSPF.conf
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
router ospf 1
|
||||||
|
router-id 1.1.1.1
|
||||||
|
|
||||||
|
network 172.16.10.0 0.0.0.255 area 0
|
||||||
|
|
||||||
|
network 172.16.20.0 0.0.0.255 area 0
|
||||||
|
|
||||||
|
network 172.16.100.0 0.0.0.63 area 0
|
||||||
|
|
||||||
|
end
|
||||||
10
TP_03/config/R1_CPE_LYON_BAT_A_VRRP.conf
Normal file
10
TP_03/config/R1_CPE_LYON_BAT_A_VRRP.conf
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
interface g2/0.10
|
||||||
|
vrrp 10 ip 172.16.10.252
|
||||||
|
vrrp 10 priority 100
|
||||||
|
|
||||||
|
interface g2/0.20
|
||||||
|
vrrp 20 ip 172.16.20.252
|
||||||
|
vrrp 20 priority 100
|
||||||
15
TP_03/config/R1_CPE_LYON_BAT_B.conf
Normal file
15
TP_03/config/R1_CPE_LYON_BAT_B.conf
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
|
||||||
|
interface g3/0
|
||||||
|
no shutdown
|
||||||
|
exit
|
||||||
|
interface g3/0.10
|
||||||
|
encapsulation dot1Q 10
|
||||||
|
description "Gateway for teacher vlan"
|
||||||
|
ip address 172.16.30.253 255.255.255.0
|
||||||
|
exit
|
||||||
|
|
||||||
|
interface g3/0.20
|
||||||
|
encapsulation dot1Q 20
|
||||||
|
description "Gateway for student vlan"
|
||||||
|
ip address 172.16.40.253 255.255.255.0
|
||||||
|
exit
|
||||||
10
TP_03/config/R1_CPE_LYON_BAT_B_OSPF.conf
Normal file
10
TP_03/config/R1_CPE_LYON_BAT_B_OSPF.conf
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
router ospf 1
|
||||||
|
router-id 4.4.4.4
|
||||||
|
|
||||||
|
network 172.16.30.0 0.0.0.255 area 0
|
||||||
|
|
||||||
|
network 172.16.40.0 0.0.0.255 area 0
|
||||||
|
|
||||||
|
network 172.16.100.64 0.0.0.63 area 0
|
||||||
|
|
||||||
|
end
|
||||||
10
TP_03/config/R1_CPE_LYON_BAT_B_VRRP.conf
Normal file
10
TP_03/config/R1_CPE_LYON_BAT_B_VRRP.conf
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
interface g3/0.10
|
||||||
|
vrrp 10 ip 172.16.30.252
|
||||||
|
vrrp 10 priority 100
|
||||||
|
|
||||||
|
interface g3/0.20
|
||||||
|
vrrp 20 ip 172.16.40.252
|
||||||
|
vrrp 20 priority 100
|
||||||
10
TP_03/config/R1_VRRP_CPE_LYON_BAT_A.conf
Normal file
10
TP_03/config/R1_VRRP_CPE_LYON_BAT_A.conf
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
interface g2/0.10
|
||||||
|
vrrp 10 ip 172.16.10.252
|
||||||
|
vrrp 10 priority 100
|
||||||
|
|
||||||
|
interface g2/0.20
|
||||||
|
vrrp 20 ip 172.16.20.252
|
||||||
|
vrrp 20 priority 100
|
||||||
10
TP_03/config/R1_VRRP_CPE_LYON_BAT_B.conf
Normal file
10
TP_03/config/R1_VRRP_CPE_LYON_BAT_B.conf
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
interface g3/0.10
|
||||||
|
vrrp 10 ip 172.16.30.252
|
||||||
|
vrrp 10 priority 100
|
||||||
|
|
||||||
|
interface g3/0.20
|
||||||
|
vrrp 20 ip 172.16.40.252
|
||||||
|
vrrp 20 priority 100
|
||||||
15
TP_03/config/R2_CPE_LYON_BAT_A.conf
Normal file
15
TP_03/config/R2_CPE_LYON_BAT_A.conf
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
|
||||||
|
interface g2/0
|
||||||
|
no shutdown
|
||||||
|
exit
|
||||||
|
interface g2/0.10
|
||||||
|
encapsulation dot1Q 10
|
||||||
|
description "Gateway for teacher vlan"
|
||||||
|
ip address 172.16.10.254 255.255.255.0
|
||||||
|
exit
|
||||||
|
|
||||||
|
interface g2/0.20
|
||||||
|
encapsulation dot1Q 20
|
||||||
|
description "Gateway for student vlan"
|
||||||
|
ip address 172.16.20.254 255.255.255.0
|
||||||
|
exit
|
||||||
10
TP_03/config/R2_CPE_LYON_BAT_A_OSPF.conf
Normal file
10
TP_03/config/R2_CPE_LYON_BAT_A_OSPF.conf
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
router ospf 1
|
||||||
|
router-id 2.2.2.2
|
||||||
|
|
||||||
|
network 172.16.10.0 0.0.0.255 area 0
|
||||||
|
|
||||||
|
network 172.16.20.0 0.0.0.255 area 0
|
||||||
|
|
||||||
|
network 172.16.100.0 0.0.0.63 area 0
|
||||||
|
|
||||||
|
end
|
||||||
14
TP_03/config/R2_CPE_LYON_BAT_A_VRRP.conf
Normal file
14
TP_03/config/R2_CPE_LYON_BAT_A_VRRP.conf
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
interface g2/0.10
|
||||||
|
vrrp 10 ip 172.16.10.252
|
||||||
|
vrrp 10 priority 110
|
||||||
|
vrrp 10 preempt
|
||||||
|
exit
|
||||||
|
|
||||||
|
interface g2/0.20
|
||||||
|
vrrp 20 ip 172.16.20.252
|
||||||
|
vrrp 20 priority 110
|
||||||
|
vrrp 20 preempt
|
||||||
|
exit
|
||||||
15
TP_03/config/R2_CPE_LYON_BAT_B.conf
Normal file
15
TP_03/config/R2_CPE_LYON_BAT_B.conf
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
|
||||||
|
interface g3/0
|
||||||
|
no shutdown
|
||||||
|
exit
|
||||||
|
interface g3/0.10
|
||||||
|
encapsulation dot1Q 10
|
||||||
|
description "Gateway for teacher vlan"
|
||||||
|
ip address 172.16.30.254 255.255.255.0
|
||||||
|
exit
|
||||||
|
|
||||||
|
interface g3/0.20
|
||||||
|
encapsulation dot1Q 20
|
||||||
|
description "Gateway for student vlan"
|
||||||
|
ip address 172.16.40.254 255.255.255.0
|
||||||
|
exit
|
||||||
10
TP_03/config/R2_CPE_LYON_BAT_B_OSPF.conf
Normal file
10
TP_03/config/R2_CPE_LYON_BAT_B_OSPF.conf
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
router ospf 1
|
||||||
|
router-id 3.3.3.3
|
||||||
|
|
||||||
|
network 172.16.30.0 0.0.0.255 area 0
|
||||||
|
|
||||||
|
network 172.16.40.0 0.0.0.255 area 0
|
||||||
|
|
||||||
|
network 172.16.100.64 0.0.0.63 area 0
|
||||||
|
|
||||||
|
end
|
||||||
14
TP_03/config/R2_CPE_LYON_BAT_B_VRRP.conf
Normal file
14
TP_03/config/R2_CPE_LYON_BAT_B_VRRP.conf
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
interface g3/0.10
|
||||||
|
vrrp 10 ip 172.16.30.252
|
||||||
|
vrrp 10 priority 110
|
||||||
|
vrrp 10 preempt
|
||||||
|
exit
|
||||||
|
|
||||||
|
interface g3/0.20
|
||||||
|
vrrp 20 ip 172.16.40.252
|
||||||
|
vrrp 20 priority 110
|
||||||
|
vrrp 20 preempt
|
||||||
|
exit
|
||||||
8
TP_03/data/R1_CPE_LYON_BAT_A_OSPF.json
Normal file
8
TP_03/data/R1_CPE_LYON_BAT_A_OSPF.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"id_router": "1.1.1.1",
|
||||||
|
"networks": [
|
||||||
|
"172.16.10.0 0.0.0.255",
|
||||||
|
"172.16.20.0 0.0.0.255",
|
||||||
|
"172.16.100.0 0.0.0.63"
|
||||||
|
]
|
||||||
|
}
|
||||||
8
TP_03/data/R1_CPE_LYON_BAT_B_OSPF.json
Normal file
8
TP_03/data/R1_CPE_LYON_BAT_B_OSPF.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"id_router": "4.4.4.4",
|
||||||
|
"networks": [
|
||||||
|
"172.16.30.0 0.0.0.255",
|
||||||
|
"172.16.40.0 0.0.0.255",
|
||||||
|
"172.16.100.64 0.0.0.63"
|
||||||
|
]
|
||||||
|
}
|
||||||
8
TP_03/data/R2_CPE_LYON_BAT_A_OSPF.json
Normal file
8
TP_03/data/R2_CPE_LYON_BAT_A_OSPF.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"id_router": "2.2.2.2",
|
||||||
|
"networks": [
|
||||||
|
"172.16.10.0 0.0.0.255",
|
||||||
|
"172.16.20.0 0.0.0.255",
|
||||||
|
"172.16.100.0 0.0.0.63"
|
||||||
|
]
|
||||||
|
}
|
||||||
8
TP_03/data/R2_CPE_LYON_BAT_B_OSPF.json
Normal file
8
TP_03/data/R2_CPE_LYON_BAT_B_OSPF.json
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
{
|
||||||
|
"id_router": "3.3.3.3",
|
||||||
|
"networks": [
|
||||||
|
"172.16.30.0 0.0.0.255",
|
||||||
|
"172.16.40.0 0.0.0.255",
|
||||||
|
"172.16.100.64 0.0.0.63"
|
||||||
|
]
|
||||||
|
}
|
||||||
10
TP_03/inventory/config.yaml
Normal file
10
TP_03/inventory/config.yaml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
inventory:
|
||||||
|
plugin: SimpleInventory
|
||||||
|
options:
|
||||||
|
host_file: "inventory/hosts.yaml"
|
||||||
|
group_file: "inventory/groups.yaml"
|
||||||
|
defaults_file: "inventory/defaults.yaml"
|
||||||
|
runner:
|
||||||
|
plugin: threaded
|
||||||
|
options:
|
||||||
|
num_workers: 20
|
||||||
2
TP_03/inventory/defaults.yaml
Normal file
2
TP_03/inventory/defaults.yaml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
username: cisco
|
||||||
|
password: cisco
|
||||||
4
TP_03/inventory/groups.yaml
Normal file
4
TP_03/inventory/groups.yaml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
ios:
|
||||||
|
platform: ios
|
||||||
|
data:
|
||||||
|
vendor: Cisco
|
||||||
72
TP_03/inventory/hosts.yaml
Normal file
72
TP_03/inventory/hosts.yaml
Normal file
@@ -0,0 +1,72 @@
|
|||||||
|
R1-CPE-BAT-A:
|
||||||
|
hostname: 172.16.100.125
|
||||||
|
port: 22
|
||||||
|
groups:
|
||||||
|
- ios
|
||||||
|
data: # Anything under this key is custom data
|
||||||
|
device_name: R1-CPE-BAT-A
|
||||||
|
device_type: router
|
||||||
|
device_model: C7200
|
||||||
|
locality: lyon
|
||||||
|
building: A
|
||||||
|
room: 001
|
||||||
|
|
||||||
|
R2-CPE-BAT-A:
|
||||||
|
hostname: 172.16.100.126
|
||||||
|
port: 22
|
||||||
|
groups:
|
||||||
|
- ios
|
||||||
|
data: # Anything under this key is custom data
|
||||||
|
device_name: R2-CPE-BAT-A
|
||||||
|
device_type: router
|
||||||
|
device_model: C7200
|
||||||
|
locality: lyon
|
||||||
|
building: A
|
||||||
|
|
||||||
|
ESW1-CPE-BAT-A:
|
||||||
|
hostname: 172.16.100.123
|
||||||
|
port: 22
|
||||||
|
groups:
|
||||||
|
- ios
|
||||||
|
data: # Anything under this key is custom data
|
||||||
|
device_name: ESW1-CPE-BAT-A
|
||||||
|
device_type: router_switch
|
||||||
|
device_model: C3725
|
||||||
|
locality: lyon
|
||||||
|
building: A
|
||||||
|
|
||||||
|
R1-CPE-BAT-B:
|
||||||
|
hostname: 172.16.100.189
|
||||||
|
port: 22
|
||||||
|
groups:
|
||||||
|
- ios
|
||||||
|
data: # Anything under this key is custom data
|
||||||
|
device_name: R1-CPE-BAT-B
|
||||||
|
device_type: router
|
||||||
|
device_model: C7200
|
||||||
|
locality: lyon
|
||||||
|
building: B
|
||||||
|
|
||||||
|
R2-CPE-BAT-B:
|
||||||
|
hostname: 172.16.100.190
|
||||||
|
port: 22
|
||||||
|
groups:
|
||||||
|
- ios
|
||||||
|
data: # Anything under this key is custom data
|
||||||
|
device_name: R2-CPE-BAT-B
|
||||||
|
device_type: router
|
||||||
|
device_model: C7200
|
||||||
|
locality: lyon
|
||||||
|
building: B
|
||||||
|
|
||||||
|
ESW1-CPE-BAT-B:
|
||||||
|
hostname: 172.16.100.187
|
||||||
|
port: 22
|
||||||
|
groups:
|
||||||
|
- ios
|
||||||
|
data: # Anything under this key is custom data
|
||||||
|
device_name: ESW1-CPE-BAT-B
|
||||||
|
device_type: router_switch
|
||||||
|
device_model: C3725
|
||||||
|
locality: lyon
|
||||||
|
building: B
|
||||||
1019
TP_03/nornir.log
Normal file
1019
TP_03/nornir.log
Normal file
File diff suppressed because it is too large
Load Diff
@@ -5,37 +5,98 @@ env = Environment(loader=FileSystemLoader("templates"))
|
|||||||
|
|
||||||
|
|
||||||
def load_json_data_from_file(file_path):
|
def load_json_data_from_file(file_path):
|
||||||
pass
|
with open(file_path) as json_file:
|
||||||
|
data = json.load(json_file)
|
||||||
|
return data
|
||||||
def render_network_config(template_name, data):
|
def render_network_config(template_name, data):
|
||||||
pass
|
template = env.get_template(template_name)
|
||||||
|
return template.render(data)
|
||||||
|
|
||||||
def save_built_config(file_name, data):
|
def save_built_config(file_name, data):
|
||||||
pass
|
with open(file_name, "w") as f:
|
||||||
|
f.write(data)
|
||||||
|
return file_name
|
||||||
|
|
||||||
|
|
||||||
def create_config_cpe_lyon_batA():
|
def create_config_cpe_lyon_batA():
|
||||||
pass
|
ESW1_CPE_LYON_BAT_A_data= load_json_data_from_file(file_path='data/ESW1_CPE_LYON_BAT_A.json')
|
||||||
|
ESW1_CPE_LYON_BAT_A_config = render_network_config(template_name='vlan_switch.j2', data=ESW1_CPE_LYON_BAT_A_data)
|
||||||
|
|
||||||
|
R2_LYON_BAT_A_data = load_json_data_from_file(file_path='data/R2_CPE_LYON_BAT_A.json')
|
||||||
|
R2_LYON_BAT_A_config = render_network_config(template_name='vlan_router.j2', data=R2_LYON_BAT_A_data)
|
||||||
|
|
||||||
|
R1_LYON_BAT_A_data = load_json_data_from_file(file_path='data/R1_CPE_LYON_BAT_A.json')
|
||||||
|
R1_LYON_BAT_A_config = render_network_config(template_name='vlan_router.j2', data=R1_LYON_BAT_A_data)
|
||||||
|
|
||||||
|
R2_LYON_BAT_A_config_vrrp = render_network_config(template_name='vrrp_router.j2', data=R2_LYON_BAT_A_data)
|
||||||
|
R1_LYON_BAT_A_config_vrrp = render_network_config(template_name='vrrp_router.j2', data=R1_LYON_BAT_A_data)
|
||||||
|
|
||||||
|
R2_LYON_BAT_A_config_ospf_data = load_json_data_from_file(file_path='data/R2_CPE_LYON_BAT_A_OSPF.json')
|
||||||
|
R2_LYON_BAT_A_config_ospf = render_network_config(template_name='config_ospf.j2', data=R2_LYON_BAT_A_config_ospf_data)
|
||||||
|
R1_LYON_BAT_A_config_ospf_data = load_json_data_from_file(file_path='data/R1_CPE_LYON_BAT_A_OSPF.json')
|
||||||
|
R1_LYON_BAT_A_config_ospf = render_network_config(template_name='config_ospf.j2', data=R1_LYON_BAT_A_config_ospf_data)
|
||||||
|
|
||||||
|
return {
|
||||||
|
'esw1': ESW1_CPE_LYON_BAT_A_config,
|
||||||
|
'r1': R1_LYON_BAT_A_config,
|
||||||
|
'r2': R2_LYON_BAT_A_config,
|
||||||
|
'r1_vrrp' : R1_LYON_BAT_A_config_vrrp,
|
||||||
|
'r2_vrrp' : R2_LYON_BAT_A_config_vrrp,
|
||||||
|
'r1_ospf' : R1_LYON_BAT_A_config_ospf,
|
||||||
|
'r2_ospf' : R2_LYON_BAT_A_config_ospf
|
||||||
|
}
|
||||||
|
|
||||||
def create_config_cpe_lyon_batB():
|
def create_config_cpe_lyon_batB():
|
||||||
pass
|
ESW1_CPE_LYON_BAT_B_data= load_json_data_from_file(file_path='data/ESW1_CPE_LYON_BAT_B.json')
|
||||||
|
ESW1_CPE_LYON_BAT_B_config = render_network_config(template_name='vlan_switch.j2', data=ESW1_CPE_LYON_BAT_B_data)
|
||||||
|
|
||||||
|
R2_LYON_BAT_B_data = load_json_data_from_file(file_path='data/R2_CPE_LYON_BAT_B.json')
|
||||||
|
R2_LYON_BAT_B_config = render_network_config(template_name='vlan_router.j2', data=R2_LYON_BAT_B_data)
|
||||||
|
|
||||||
|
R1_LYON_BAT_B_data = load_json_data_from_file(file_path='data/R1_CPE_LYON_BAT_B.json')
|
||||||
|
R1_LYON_BAT_B_config = render_network_config(template_name='vlan_router.j2', data=R1_LYON_BAT_B_data)
|
||||||
|
|
||||||
|
R2_LYON_BAT_B_config_vrrp = render_network_config(template_name='vrrp_router.j2', data=R2_LYON_BAT_B_data)
|
||||||
|
R1_LYON_BAT_B_config_vrrp = render_network_config(template_name='vrrp_router.j2', data=R1_LYON_BAT_B_data)
|
||||||
|
|
||||||
|
R2_LYON_BAT_B_config_ospf_data = load_json_data_from_file(file_path='data/R2_CPE_LYON_BAT_B_OSPF.json')
|
||||||
|
R2_LYON_BAT_B_config_ospf = render_network_config(template_name='config_ospf.j2', data=R2_LYON_BAT_B_config_ospf_data)
|
||||||
|
R1_LYON_BAT_B_config_ospf_data = load_json_data_from_file(file_path='data/R1_CPE_LYON_BAT_B_OSPF.json')
|
||||||
|
R1_LYON_BAT_B_config_ospf = render_network_config(template_name='config_ospf.j2', data=R1_LYON_BAT_B_config_ospf_data)
|
||||||
|
|
||||||
|
return {
|
||||||
|
'esw1': ESW1_CPE_LYON_BAT_B_config,
|
||||||
|
'r1': R1_LYON_BAT_B_config,
|
||||||
|
'r2': R2_LYON_BAT_B_config,
|
||||||
|
'r1_vrrp' : R1_LYON_BAT_B_config_vrrp,
|
||||||
|
'r2_vrrp' : R2_LYON_BAT_B_config_vrrp,
|
||||||
|
'r1_ospf' : R1_LYON_BAT_B_config_ospf,
|
||||||
|
'r2_ospf' : R2_LYON_BAT_B_config_ospf
|
||||||
|
}
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
"""
|
"""
|
||||||
process question 3 to 5:
|
process question 3 to 5:
|
||||||
"""
|
"""
|
||||||
#question 3:
|
#question 3:
|
||||||
#config = create_config_cpe_lyon_batA()
|
config = create_config_cpe_lyon_batA()
|
||||||
|
|
||||||
#question 4:
|
#question 4:
|
||||||
# save_built_config('config/R1_CPE_LYON_BAT_A.conf', config.get('r1'))
|
save_built_config('config/R1_CPE_LYON_BAT_A.conf', config.get('r1'))
|
||||||
# save_built_config('config/R2_CPE_LYON_BAT_A.conf', config.get('r2'))
|
save_built_config('config/R2_CPE_LYON_BAT_A.conf', config.get('r2'))
|
||||||
# save_built_config('config/ESW1_CPE_LYON_BAT_A.conf', config.get('esw1'))
|
save_built_config('config/ESW1_CPE_LYON_BAT_A.conf', config.get('esw1'))
|
||||||
|
save_built_config('config/R1_CPE_LYON_BAT_A_VRRP.conf', config.get('r1_vrrp'))
|
||||||
|
save_built_config('config/R2_CPE_LYON_BAT_A_VRRP.conf', config.get('r2_vrrp'))
|
||||||
|
save_built_config('config/R1_CPE_LYON_BAT_A_OSPF.conf', config.get('r1_ospf'))
|
||||||
|
save_built_config('config/R2_CPE_LYON_BAT_A_OSPF.conf', config.get('r2_ospf'))
|
||||||
|
|
||||||
#question 5:
|
#question 5:
|
||||||
# config = create_config_cpe_lyon_batB()
|
config = create_config_cpe_lyon_batB()
|
||||||
# save_built_config('config/R1_CPE_LYON_BAT_B.conf', config.get('r1'))
|
save_built_config('config/R1_CPE_LYON_BAT_B.conf', config.get('r1'))
|
||||||
# save_built_config('config/R2_CPE_LYON_BAT_B.conf', config.get('r2'))
|
save_built_config('config/R2_CPE_LYON_BAT_B.conf', config.get('r2'))
|
||||||
# save_built_config('config/ESW1_CPE_LYON_BAT_B.conf', config.get('esw1'))
|
save_built_config('config/ESW1_CPE_LYON_BAT_B.conf', config.get('esw1'))
|
||||||
|
save_built_config('config/R1_CPE_LYON_BAT_B_VRRP.conf', config.get('r1_vrrp'))
|
||||||
|
save_built_config('config/R2_CPE_LYON_BAT_B_VRRP.conf', config.get('r2_vrrp'))
|
||||||
|
save_built_config('config/R1_CPE_LYON_BAT_B_OSPF.conf', config.get('r1_ospf'))
|
||||||
|
save_built_config('config/R2_CPE_LYON_BAT_B_OSPF.conf', config.get('r2_ospf'))
|
||||||
|
|
||||||
@@ -1,79 +1,240 @@
|
|||||||
|
from nornir import InitNornir
|
||||||
|
from nornir.core.task import Task, Result
|
||||||
|
from nornir_utils.plugins.functions import print_result
|
||||||
|
from nornir_napalm.plugins.tasks import napalm_get,napalm_configure, napalm_cli
|
||||||
|
from nornir_netmiko.tasks import netmiko_send_config,netmiko_send_command, netmiko_save_config, netmiko_commit
|
||||||
|
|
||||||
def question_13(nr):
|
def question_13(nr):
|
||||||
pass
|
for key in nr.__dict__.keys():
|
||||||
|
print(f" - {key}")
|
||||||
|
|
||||||
def question_14(nr):
|
def question_14(nr):
|
||||||
pass
|
print(nr.inventory.hosts)
|
||||||
|
print(type(nr.inventory.hosts))
|
||||||
|
|
||||||
def question_15(nr):
|
def question_15(nr):
|
||||||
pass
|
print(nr.inventory.hosts["R1-CPE-BAT-A"])
|
||||||
|
print(type(nr.inventory.hosts["R1-CPE-BAT-A"]))
|
||||||
|
|
||||||
def question_16(nr):
|
def question_16(nr):
|
||||||
pass
|
print(dir(nr.inventory.hosts["R1-CPE-BAT-A"]))
|
||||||
|
first_host = list(nr.inventory.hosts.values())[0]
|
||||||
|
print(f"Adresse IP (hostname): {first_host.hostname}")
|
||||||
|
print(f"Username: {first_host.username}")
|
||||||
|
print(f"Password: {first_host.password}")
|
||||||
|
|
||||||
def question_17(nr):
|
def question_17(nr):
|
||||||
pass
|
print(dir(nr.inventory.hosts["R1-CPE-BAT-A"]))
|
||||||
|
|
||||||
def question_18(nr):
|
def question_18(nr):
|
||||||
pass
|
print(nr.inventory.hosts["R1-CPE-BAT-A"].data["room"])
|
||||||
|
|
||||||
def question_19(nr):
|
def question_19(nr):
|
||||||
pass
|
print(nr.inventory.groups)
|
||||||
|
|
||||||
|
|
||||||
def question_20(nr):
|
def question_20(nr):
|
||||||
pass
|
print(nr.inventory.hosts.get('R1-CPE-BAT-A').groups)
|
||||||
|
|
||||||
def question_21(nr):
|
def question_21(nr):
|
||||||
pass
|
print(nr.inventory.hosts.get('R1-CPE-BAT-A').groups[0].keys())
|
||||||
|
|
||||||
def question_22(nr):
|
def question_22(nr):
|
||||||
pass
|
print(nr.inventory.hosts.get('R1-CPE-BAT-A').groups[0].get('vendor'))
|
||||||
|
|
||||||
def question_23(nr):
|
def question_23(nr):
|
||||||
pass
|
for host_name in nr.inventory.hosts:
|
||||||
|
print(nr.inventory.hosts.get(host_name).hostname)
|
||||||
|
|
||||||
def question_24(nr):
|
def question_24(nr):
|
||||||
pass
|
print(nr.filter(device_type='router').inventory.hosts.keys())
|
||||||
|
|
||||||
def question_25(nr):
|
def question_25(nr):
|
||||||
pass
|
print(nr.filter(device_type='router_switch').inventory.hosts.keys())
|
||||||
|
|
||||||
|
def hello_world(task: Task) -> Result:
|
||||||
|
return Result(
|
||||||
|
host=task.host,
|
||||||
|
result=f"{task.host.name} says hello world!"
|
||||||
|
)
|
||||||
|
|
||||||
def question_26(nr):
|
def question_26(nr):
|
||||||
pass
|
result = nr.run(task=hello_world)
|
||||||
|
print(result)
|
||||||
|
|
||||||
def question_27(nr):
|
def question_27(nr):
|
||||||
pass
|
result = nr.run(task=hello_world)
|
||||||
|
print(type(result))
|
||||||
|
|
||||||
def question_29(nr):
|
def question_29(nr):
|
||||||
pass
|
result = nr.run(task=hello_world)
|
||||||
|
print_result(result)
|
||||||
|
|
||||||
def question_30(nr):
|
def question_30(nr):
|
||||||
pass
|
host = nr.filter(device_type='router_switch')
|
||||||
|
print_result(host.run(task=hello_world))
|
||||||
|
|
||||||
|
|
||||||
|
def display_interfaces(task):
|
||||||
|
task.run(
|
||||||
|
task=napalm_cli,
|
||||||
|
commands=["show ip interface brief"]
|
||||||
|
)
|
||||||
def question_32(nr):
|
def question_32(nr):
|
||||||
pass
|
filtre = nr.filter(device_type='router')
|
||||||
|
result = filtre.run(task=display_interfaces)
|
||||||
|
print_result(result)
|
||||||
|
|
||||||
|
def get_arp_table(task):
|
||||||
|
task.run(
|
||||||
|
task=napalm_get,
|
||||||
|
getters=["arp_table"]
|
||||||
|
)
|
||||||
|
|
||||||
|
def configure_loopback_r1(task):
|
||||||
|
task.run(
|
||||||
|
task=napalm_configure,
|
||||||
|
configuration="""
|
||||||
|
interface Lo1
|
||||||
|
ip address 1.1.1.1 255.255.255.255
|
||||||
|
description Loopback pour R1-CPE-BAT-A
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
|
||||||
|
def configure_loopback_r2(task):
|
||||||
|
task.run(
|
||||||
|
task=napalm_configure,
|
||||||
|
configuration="""
|
||||||
|
interface Lo1
|
||||||
|
ip address 2.2.2.2 255.255.255.255
|
||||||
|
description Loopback pour R2-CPE-BAT-A
|
||||||
|
"""
|
||||||
|
)
|
||||||
|
|
||||||
def question_33(nr):
|
|
||||||
pass
|
|
||||||
|
|
||||||
def question_34(nr):
|
def question_34(nr):
|
||||||
pass
|
R1 = nr.filter(name='R1-CPE-BAT-A')
|
||||||
|
result_R1 = R1.run(task=configure_loopback_r1)
|
||||||
|
R2 = nr.filter(name='R2-CPE-BAT-A')
|
||||||
|
result_R2 = R2.run(task=configure_loopback_r2)
|
||||||
|
print_result(result_R1)
|
||||||
|
print_result(result_R2)
|
||||||
|
|
||||||
|
def save_running_config(task):
|
||||||
|
# Exécute la commande de sauvegarde de la configuration
|
||||||
|
task.run(
|
||||||
|
task=napalm_cli,
|
||||||
|
commands=["wr"]
|
||||||
|
)
|
||||||
|
|
||||||
def question_35(nr):
|
def question_35(nr):
|
||||||
pass
|
result = nr.run(task=save_running_config)
|
||||||
|
print_result(result)
|
||||||
|
|
||||||
def question_36(nr):
|
def question_36(nr):
|
||||||
pass
|
filtre = nr.filter(device_type='router')
|
||||||
|
result = filtre.run(task=netmiko_send_command,command_string="show ip interface brief")
|
||||||
|
print_result(result)
|
||||||
|
|
||||||
|
def configure_loopback2_r1(task):
|
||||||
|
config_commands = [
|
||||||
|
"interface loopback 2",
|
||||||
|
"ip address 1.1.1.2 255.255.255.255",
|
||||||
|
"description Loopback2 pour R1-CPE-BAT-A"
|
||||||
|
]
|
||||||
|
task.run(task=netmiko_send_config, config_commands=config_commands)
|
||||||
|
|
||||||
|
def configure_loopback2_r2(task):
|
||||||
|
config_commands = [
|
||||||
|
"interface loopback 2",
|
||||||
|
"ip address 2.2.2.3 255.255.255.255",
|
||||||
|
"description Loopback2 pour R2-CPE-BAT-A"
|
||||||
|
]
|
||||||
|
task.run(task=netmiko_send_config, config_commands=config_commands)
|
||||||
|
|
||||||
def question_37(nr):
|
def question_37(nr):
|
||||||
pass
|
result_r1 = nr.filter(name='R1-CPE-BAT-A').run(task=configure_loopback2_r1)
|
||||||
|
result_r2 = nr.filter(name='R2-CPE-BAT-A').run(task=configure_loopback2_r2)
|
||||||
|
print_result(result_r1)
|
||||||
|
print_result(result_r2)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def question_38(nr):
|
def question_38(nr):
|
||||||
pass
|
filtreR1 = nr.filter(name='R1-CPE-BAT-A')
|
||||||
|
resultR1 = filtreR1.run(task=netmiko_save_config)
|
||||||
|
filtreR2 = nr.filter(name='R2-CPE-BAT-A')
|
||||||
|
resultR2 = filtreR2.run(task=netmiko_save_config)
|
||||||
|
print_result(resultR1)
|
||||||
|
print_result(resultR2)
|
||||||
|
|
||||||
|
def deploy_config_from_file(task: Task, config_file: str) -> Result:
|
||||||
|
"""Déploie la configuration depuis un fichier sur un équipement via Nornir/Netmiko."""
|
||||||
|
with open(config_file, "r") as f:
|
||||||
|
commands = f.read().splitlines()
|
||||||
|
result = task.run(task=netmiko_send_config, config_commands=commands)
|
||||||
|
print_result(result)
|
||||||
|
result = task.run(task=netmiko_save_config)
|
||||||
|
print_result(result)
|
||||||
|
return result
|
||||||
|
|
||||||
|
def deploy_vrrp(task):
|
||||||
|
vrrp_filename = task.host.name.replace("-", "_").replace("CPE", "CPE_LYON") + "_VRRP.conf"
|
||||||
|
task.run(
|
||||||
|
task=deploy_config_from_file,
|
||||||
|
config_file=f"config/{vrrp_filename}",
|
||||||
|
name=f"Déploiement VRRP {task.host.name}"
|
||||||
|
)
|
||||||
|
|
||||||
|
def deploy_ospf(task):
|
||||||
|
vrrp_filename = task.host.name.replace("-", "_").replace("CPE", "CPE_LYON") + "_OSPF.conf"
|
||||||
|
task.run(
|
||||||
|
task=deploy_config_from_file,
|
||||||
|
config_file=f"config/{vrrp_filename}",
|
||||||
|
name=f"Déploiement VRRP {task.host.name}"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def deploy_to_hosts(nr, host_patterns):
|
||||||
|
"""Déploie les configurations pour tous les hôtes et ajoute le fichier VRRP pour les routers."""
|
||||||
|
|
||||||
|
for pattern in host_patterns:
|
||||||
|
# Filtrer uniquement par nom pour tous
|
||||||
|
filtered_hosts = nr.filter(name=pattern)
|
||||||
|
if not filtered_hosts.inventory.hosts:
|
||||||
|
print(f"Aucun hôte correspondant à '{pattern}'")
|
||||||
|
continue
|
||||||
|
|
||||||
|
# Déploiement des configs principales
|
||||||
|
def deploy_main(task):
|
||||||
|
filename = task.host.name.replace("-", "_").replace("CPE", "CPE_LYON") + ".conf"
|
||||||
|
task.run(
|
||||||
|
task=deploy_config_from_file,
|
||||||
|
config_file=f"config/{filename}",
|
||||||
|
name=f"Déploiement config {task.host.name}"
|
||||||
|
)
|
||||||
|
|
||||||
|
filtered_hosts.run(task=deploy_main)
|
||||||
|
|
||||||
|
# Déploiement VRRP uniquement pour les routers
|
||||||
|
routers = nr.filter(device_type="router")
|
||||||
|
routers.run(task=deploy_vrrp)
|
||||||
|
routers.run(task=deploy_ospf)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def question_39(nr):
|
def question_39(nr):
|
||||||
pass
|
host_patterns = [
|
||||||
|
'R1-CPE-BAT-A',
|
||||||
|
'R2-CPE-BAT-A',
|
||||||
|
'R1-CPE-BAT-B',
|
||||||
|
'R2-CPE-BAT-B',
|
||||||
|
'ESW1-CPE-BAT-A',
|
||||||
|
'ESW1-CPE-BAT-BS'
|
||||||
|
|
||||||
|
]
|
||||||
|
deploy_to_hosts(nr, host_patterns)
|
||||||
|
|
||||||
def question_39_d(nr):
|
def question_39_d(nr):
|
||||||
pass
|
pass
|
||||||
@@ -83,7 +244,7 @@ def question_40(nr):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
#nr = InitNornir(config_file="inventory/config.yaml")
|
nr = InitNornir(config_file="inventory/config.yaml")
|
||||||
|
|
||||||
#question_13(nr)
|
#question_13(nr)
|
||||||
#question_14(nr)
|
#question_14(nr)
|
||||||
@@ -110,7 +271,7 @@ if __name__ == "__main__":
|
|||||||
#question_36(nr)
|
#question_36(nr)
|
||||||
#question_37(nr)
|
#question_37(nr)
|
||||||
#question_38(nr)
|
#question_38(nr)
|
||||||
#question_39(nr)
|
question_39(nr)
|
||||||
#question_39_d(nr)
|
#question_39_d(nr)
|
||||||
|
|
||||||
#question_40(nr)
|
#question_40(nr)
|
||||||
|
|||||||
6
TP_03/templates/config_ospf.j2
Normal file
6
TP_03/templates/config_ospf.j2
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
router ospf 1
|
||||||
|
router-id {{ id_router }}
|
||||||
|
{% for network in networks %}
|
||||||
|
network {{ network }} area 0
|
||||||
|
{% endfor %}
|
||||||
|
end
|
||||||
@@ -4,7 +4,7 @@ interface {{ interface.name }}
|
|||||||
no shutdown
|
no shutdown
|
||||||
exit
|
exit
|
||||||
|
|
||||||
{%- elif "3/0" == interface.name %}
|
{%- elif "g3/0" == interface.name %}
|
||||||
interface {{ interface.name }}
|
interface {{ interface.name }}
|
||||||
no shutdown
|
no shutdown
|
||||||
exit
|
exit
|
||||||
|
|||||||
18
fastprod_backend/Pipfile
Normal file
18
fastprod_backend/Pipfile
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
[[source]]
|
||||||
|
url = "https://pypi.org/simple"
|
||||||
|
verify_ssl = true
|
||||||
|
name = "pypi"
|
||||||
|
|
||||||
|
[packages]
|
||||||
|
flask = "*"
|
||||||
|
nornir = "*"
|
||||||
|
pyyaml = "*"
|
||||||
|
nornir-napalm = "*"
|
||||||
|
nornir-netmiko = "*"
|
||||||
|
nornir-utils = "*"
|
||||||
|
flask-cors = "*"
|
||||||
|
|
||||||
|
[dev-packages]
|
||||||
|
|
||||||
|
[requires]
|
||||||
|
python_version = "3.12"
|
||||||
1121
fastprod_backend/Pipfile.lock
generated
Normal file
1121
fastprod_backend/Pipfile.lock
generated
Normal file
File diff suppressed because it is too large
Load Diff
168
fastprod_backend/R1-CPE-BAT-A_2025-11-27 13:41:22.690142.conf
Normal file
168
fastprod_backend/R1-CPE-BAT-A_2025-11-27 13:41:22.690142.conf
Normal file
@@ -0,0 +1,168 @@
|
|||||||
|
!
|
||||||
|
upgrade fpd auto
|
||||||
|
version 12.4
|
||||||
|
service timestamps debug datetime msec
|
||||||
|
service timestamps log datetime msec
|
||||||
|
no service password-encryption
|
||||||
|
!
|
||||||
|
hostname R1-CPE-BAT-A
|
||||||
|
!
|
||||||
|
boot-start-marker
|
||||||
|
boot-end-marker
|
||||||
|
!
|
||||||
|
logging message-counter syslog
|
||||||
|
!
|
||||||
|
no aaa new-model
|
||||||
|
ip source-route
|
||||||
|
no ip icmp rate-limit unreachable
|
||||||
|
ip cef
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
no ip domain lookup
|
||||||
|
ip domain name r1.cpe.local
|
||||||
|
no ipv6 cef
|
||||||
|
!
|
||||||
|
multilink bundle-name authenticated
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
file prompt quiet
|
||||||
|
username cisco privilege 15 password 0 cisco
|
||||||
|
archive
|
||||||
|
log config
|
||||||
|
hidekeys
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
ip tcp synwait-time 5
|
||||||
|
ip ssh version 2
|
||||||
|
ip scp server enable
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
interface Loopback1
|
||||||
|
description Loopback pour R1-CPE-BAT-A
|
||||||
|
ip address 1.1.1.1 255.255.255.255
|
||||||
|
!
|
||||||
|
interface Loopback2
|
||||||
|
description Loopback2 pour R1-CPE-BAT-A
|
||||||
|
ip address 1.1.1.2 255.255.255.255
|
||||||
|
!
|
||||||
|
interface Loopback10
|
||||||
|
description created from config file uploaded from postman
|
||||||
|
ip address 10.10.10.10 255.255.255.255
|
||||||
|
!
|
||||||
|
interface FastEthernet0/0
|
||||||
|
ip address 172.16.100.62 255.255.255.192
|
||||||
|
duplex half
|
||||||
|
!
|
||||||
|
interface Serial1/0
|
||||||
|
no ip address
|
||||||
|
shutdown
|
||||||
|
serial restart-delay 0
|
||||||
|
!
|
||||||
|
interface Serial1/1
|
||||||
|
ip address 10.1.1.1 255.255.255.252
|
||||||
|
shutdown
|
||||||
|
serial restart-delay 0
|
||||||
|
!
|
||||||
|
interface Serial1/2
|
||||||
|
no ip address
|
||||||
|
shutdown
|
||||||
|
serial restart-delay 0
|
||||||
|
!
|
||||||
|
interface Serial1/3
|
||||||
|
no ip address
|
||||||
|
shutdown
|
||||||
|
serial restart-delay 0
|
||||||
|
!
|
||||||
|
interface GigabitEthernet2/0
|
||||||
|
no ip address
|
||||||
|
negotiation auto
|
||||||
|
!
|
||||||
|
interface GigabitEthernet2/0.10
|
||||||
|
description "Gateway for teacher vlan"
|
||||||
|
encapsulation dot1Q 10
|
||||||
|
ip address 172.16.10.253 255.255.255.0
|
||||||
|
vrrp 10 ip 172.16.10.252
|
||||||
|
!
|
||||||
|
interface GigabitEthernet2/0.20
|
||||||
|
description "Gateway for student vlan"
|
||||||
|
encapsulation dot1Q 20
|
||||||
|
ip address 172.16.20.253 255.255.255.0
|
||||||
|
vrrp 20 ip 172.16.20.252
|
||||||
|
!
|
||||||
|
interface GigabitEthernet2/0.99
|
||||||
|
encapsulation dot1Q 99
|
||||||
|
ip address 172.16.100.125 255.255.255.192
|
||||||
|
vrrp 99 ip 172.16.100.124
|
||||||
|
!
|
||||||
|
router ospf 1
|
||||||
|
router-id 1.1.1.1
|
||||||
|
log-adjacency-changes
|
||||||
|
passive-interface FastEthernet0/0
|
||||||
|
passive-interface GigabitEthernet2/0.99
|
||||||
|
network 10.1.1.0 0.0.0.3 area 0
|
||||||
|
network 172.16.10.0 0.0.0.255 area 0
|
||||||
|
network 172.16.20.0 0.0.0.255 area 0
|
||||||
|
network 172.16.100.0 0.0.0.63 area 0
|
||||||
|
network 172.16.100.64 0.0.0.63 area 0
|
||||||
|
!
|
||||||
|
ip forward-protocol nd
|
||||||
|
no ip http server
|
||||||
|
no ip http secure-server
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
no cdp log mismatch duplex
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
control-plane
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
gatekeeper
|
||||||
|
shutdown
|
||||||
|
!
|
||||||
|
!
|
||||||
|
line con 0
|
||||||
|
exec-timeout 0 0
|
||||||
|
privilege level 15
|
||||||
|
logging synchronous
|
||||||
|
stopbits 1
|
||||||
|
line aux 0
|
||||||
|
exec-timeout 0 0
|
||||||
|
privilege level 15
|
||||||
|
logging synchronous
|
||||||
|
stopbits 1
|
||||||
|
line vty 0 4
|
||||||
|
login local
|
||||||
|
transport input ssh
|
||||||
|
!
|
||||||
|
end
|
||||||
146
fastprod_backend/fastprod/api.py
Normal file
146
fastprod_backend/fastprod/api.py
Normal file
@@ -0,0 +1,146 @@
|
|||||||
|
from flask import Flask,jsonify,request,abort, make_response,send_file
|
||||||
|
from werkzeug.exceptions import HTTPException
|
||||||
|
from nornir import InitNornir
|
||||||
|
from flask_cors import CORS
|
||||||
|
|
||||||
|
import os
|
||||||
|
from werkzeug.utils import secure_filename
|
||||||
|
import json
|
||||||
|
|
||||||
|
|
||||||
|
ALLOWED_EXTENSIONS = {'conf'}
|
||||||
|
UPLOAD_FOLDER = 'fastprod/upload_files/'
|
||||||
|
|
||||||
|
|
||||||
|
def init_nornir():
|
||||||
|
app.config['nr'] = InitNornir(config_file="fastprod/inventory/config.yaml")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def allowed_file(filename):
|
||||||
|
return '.' in filename and \
|
||||||
|
filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
|
||||||
|
|
||||||
|
app = Flask(__name__)
|
||||||
|
app.config['UPLOAD_FOLDER'] = UPLOAD_FOLDER
|
||||||
|
CORS(app)
|
||||||
|
|
||||||
|
|
||||||
|
from services.devices import ( get_inventory, add_device,get_device_by_name,delete_device,get_device_interfaces,get_device_interfaces_ip,get_device_technical_info)
|
||||||
|
from services.config import (get_config_by_device,run_config_from_file_by_device)
|
||||||
|
from services.tasks import (run_show_commands_by_device,run_config_commands_by_device)
|
||||||
|
from services.snapshots import (get_snapshot_by_name,create_snapshot_by_device,get_snapshots_by_device)
|
||||||
|
init_nornir()
|
||||||
|
|
||||||
|
@app.route("/")
|
||||||
|
def hello_world():
|
||||||
|
return jsonify({
|
||||||
|
"env": "DEV",
|
||||||
|
"name": "fastprod_backend",
|
||||||
|
"version": 1.0
|
||||||
|
})
|
||||||
|
|
||||||
|
@app.route("/devices", methods=['GET', 'POST'])
|
||||||
|
def devices():
|
||||||
|
if request.method == 'GET':
|
||||||
|
init_nornir()
|
||||||
|
devices = get_inventory()
|
||||||
|
return jsonify(devices=devices, total_count=len(devices))
|
||||||
|
if request.method == 'POST':
|
||||||
|
data = request.get_json()
|
||||||
|
new_device = add_device(data)
|
||||||
|
return jsonify(device=new_device)
|
||||||
|
|
||||||
|
@app.route("/devices/<device_name>", methods=['GET', 'DELETE'])
|
||||||
|
def device_by_name(device_name):
|
||||||
|
if request.method == 'GET':
|
||||||
|
device = get_device_by_name(device_name)
|
||||||
|
return jsonify(device=device)
|
||||||
|
if request.method == 'DELETE':
|
||||||
|
device = get_device_by_name(device_name)
|
||||||
|
delete_device(device)
|
||||||
|
return jsonify(message="Device deleted")
|
||||||
|
|
||||||
|
|
||||||
|
@app.route("/devices/<device_name>/interfaces", methods=['GET'])
|
||||||
|
def get_interfaces(device_name):
|
||||||
|
device = get_device_by_name(device_name)
|
||||||
|
interfaces = get_device_interfaces(device)
|
||||||
|
return jsonify(interfaces=interfaces)
|
||||||
|
|
||||||
|
@app.route("/devices/<device_name>/interfaces/ip", methods=['GET'])
|
||||||
|
def get_interfaces_ip(device_name):
|
||||||
|
if request.method == 'GET':
|
||||||
|
device = get_device_by_name(device_name)
|
||||||
|
interfaces_ip = get_device_interfaces_ip(device)
|
||||||
|
return jsonify(interfaces_ip=interfaces_ip)
|
||||||
|
|
||||||
|
@app.route("/devices/<device_name>/facts", methods=['GET'])
|
||||||
|
def get_technical_info(device_name):
|
||||||
|
if request.method == 'GET':
|
||||||
|
device = get_device_by_name(device_name)
|
||||||
|
technical_info = get_device_technical_info(device)
|
||||||
|
return jsonify(facts=technical_info)
|
||||||
|
|
||||||
|
@app.route("/devices/<device_name>/config", methods=['GET','POST'])
|
||||||
|
def get_config(device_name):
|
||||||
|
device = get_device_by_name(device_name)
|
||||||
|
if request.method == 'GET':
|
||||||
|
config = get_config_by_device(device)
|
||||||
|
return jsonify(interfaces_ip=config)
|
||||||
|
if request.method == 'POST':
|
||||||
|
if request.files.to_dict(flat=False).get('config_file'):
|
||||||
|
file = request.files['config_file']
|
||||||
|
if not allowed_file(file.filename):
|
||||||
|
abort(make_response(jsonify(message="file extension not allowed"), 403))
|
||||||
|
filename = secure_filename(file.filename)
|
||||||
|
file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename))
|
||||||
|
result = run_config_from_file_by_device(device,file_path=os.path.join(app.config['UPLOAD_FOLDER'], filename))
|
||||||
|
return jsonify(result=result)
|
||||||
|
if request.get_json().get('mode') == 'enable':
|
||||||
|
commands = request.get_json().get('commands')
|
||||||
|
result = run_show_commands_by_device(device, commands=commands)
|
||||||
|
return jsonify(result=result)
|
||||||
|
if request.get_json().get('mode') == 'config':
|
||||||
|
commands = request.get_json().get('commands')
|
||||||
|
result = run_config_commands_by_device(device, commands=commands)
|
||||||
|
return jsonify(result=result, commands=commands)
|
||||||
|
|
||||||
|
@app.route("/devices/<device_name>/snapshots", methods=['GET','POST'])
|
||||||
|
def snapshot(device_name):
|
||||||
|
device = get_device_by_name(device_name)
|
||||||
|
print(device)
|
||||||
|
if request.method == 'GET':
|
||||||
|
data = get_snapshots_by_device(device)
|
||||||
|
return jsonify({
|
||||||
|
"result": True,
|
||||||
|
"snapshots": data
|
||||||
|
})
|
||||||
|
if request.method == 'POST':
|
||||||
|
snapshot_path = create_snapshot_by_device(device)
|
||||||
|
return jsonify({
|
||||||
|
"result": True,
|
||||||
|
"snapshots": snapshot_path
|
||||||
|
})
|
||||||
|
|
||||||
|
@app.route("/snapshots/<path:filename>", methods=['GET'])
|
||||||
|
def snapshot_by_name(filename):
|
||||||
|
if request.method == 'GET':
|
||||||
|
try:
|
||||||
|
return send_file('snapshots/'+filename)
|
||||||
|
except FileNotFoundError:
|
||||||
|
abort(make_response(jsonify(message="snapshot not found"), 404))
|
||||||
|
|
||||||
|
@app.errorhandler(HTTPException)
|
||||||
|
def handle_exception(e):
|
||||||
|
"""Return JSON instead of HTML for HTTP errors."""
|
||||||
|
# start with the correct headers and status code from the error
|
||||||
|
response = e.get_response()
|
||||||
|
# replace the body with JSON
|
||||||
|
response.data = json.dumps({
|
||||||
|
"code": e.code,
|
||||||
|
"name": e.name,
|
||||||
|
"description": e.description,
|
||||||
|
})
|
||||||
|
response.content_type = "application/json"
|
||||||
|
return response
|
||||||
10
fastprod_backend/fastprod/inventory/config.yaml
Normal file
10
fastprod_backend/fastprod/inventory/config.yaml
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
inventory:
|
||||||
|
plugin: SimpleInventory
|
||||||
|
options:
|
||||||
|
host_file: "fastprod/inventory/hosts.yaml"
|
||||||
|
group_file: "fastprod/inventory/groups.yaml"
|
||||||
|
defaults_file: "fastprod/inventory/defaults.yaml"
|
||||||
|
runner:
|
||||||
|
plugin: threaded
|
||||||
|
options:
|
||||||
|
num_workers: 20
|
||||||
2
fastprod_backend/fastprod/inventory/defaults.yaml
Normal file
2
fastprod_backend/fastprod/inventory/defaults.yaml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
username: cisco
|
||||||
|
password: cisco
|
||||||
4
fastprod_backend/fastprod/inventory/groups.yaml
Normal file
4
fastprod_backend/fastprod/inventory/groups.yaml
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
ios:
|
||||||
|
platform: ios
|
||||||
|
data:
|
||||||
|
vendor: Cisco
|
||||||
67
fastprod_backend/fastprod/inventory/hosts.yaml
Normal file
67
fastprod_backend/fastprod/inventory/hosts.yaml
Normal file
@@ -0,0 +1,67 @@
|
|||||||
|
ESW1-CPE-BAT-A:
|
||||||
|
data:
|
||||||
|
building: A
|
||||||
|
device_model: C3725
|
||||||
|
device_name: ESW1-CPE-BAT-A
|
||||||
|
device_type: router_switch
|
||||||
|
locality: lyon
|
||||||
|
groups:
|
||||||
|
- ios
|
||||||
|
hostname: 172.16.100.123
|
||||||
|
port: 22
|
||||||
|
ESW1-CPE-BAT-B:
|
||||||
|
data:
|
||||||
|
building: B
|
||||||
|
device_model: C3725
|
||||||
|
device_name: ESW1-CPE-BAT-B
|
||||||
|
device_type: router_switch
|
||||||
|
locality: lyon
|
||||||
|
groups:
|
||||||
|
- ios
|
||||||
|
hostname: 172.16.100.187
|
||||||
|
port: 22
|
||||||
|
R1-CPE-BAT-A:
|
||||||
|
data:
|
||||||
|
building: A
|
||||||
|
device_model: C7200
|
||||||
|
device_name: R1-CPE-BAT-A
|
||||||
|
device_type: router
|
||||||
|
locality: lyon
|
||||||
|
room: 1
|
||||||
|
groups:
|
||||||
|
- ios
|
||||||
|
hostname: 172.16.100.125
|
||||||
|
port: 22
|
||||||
|
R1-CPE-BAT-B:
|
||||||
|
data:
|
||||||
|
building: B
|
||||||
|
device_model: C7200
|
||||||
|
device_name: R1-CPE-BAT-B
|
||||||
|
device_type: router
|
||||||
|
locality: lyon
|
||||||
|
groups:
|
||||||
|
- ios
|
||||||
|
hostname: 172.16.100.189
|
||||||
|
port: 22
|
||||||
|
R2-CPE-BAT-A:
|
||||||
|
data:
|
||||||
|
building: A
|
||||||
|
device_model: C7200
|
||||||
|
device_name: R2-CPE-BAT-A
|
||||||
|
device_type: router
|
||||||
|
locality: lyon
|
||||||
|
groups:
|
||||||
|
- ios
|
||||||
|
hostname: 172.16.100.126
|
||||||
|
port: 22
|
||||||
|
R2-CPE-BAT-B:
|
||||||
|
data:
|
||||||
|
building: B
|
||||||
|
device_model: C7200
|
||||||
|
device_name: R2-CPE-BAT-B
|
||||||
|
device_type: router
|
||||||
|
locality: lyon
|
||||||
|
groups:
|
||||||
|
- ios
|
||||||
|
hostname: 172.16.100.190
|
||||||
|
port: 22
|
||||||
19
fastprod_backend/fastprod/services/config.py
Normal file
19
fastprod_backend/fastprod/services/config.py
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
from api import app
|
||||||
|
from nornir_napalm.plugins.tasks import napalm_get, napalm_configure, napalm_cli
|
||||||
|
from nornir.core.task import Task, Result
|
||||||
|
from nornir_utils.plugins.functions import print_result
|
||||||
|
from nornir_netmiko.tasks import netmiko_send_config, netmiko_send_command, netmiko_save_config,netmiko_commit
|
||||||
|
|
||||||
|
|
||||||
|
def get_config_by_device(device):
|
||||||
|
nr = app.config.get('nr')
|
||||||
|
result = nr.filter(device_name=device.get('name')).run(task=napalm_get, getters=["get_config"])
|
||||||
|
return result[device.get('name')][0].result.get("get_config")
|
||||||
|
|
||||||
|
|
||||||
|
def run_config_from_file_by_device(device=None, file_path=None):
|
||||||
|
nr = app.config.get('nr')
|
||||||
|
if device and file_path:
|
||||||
|
result = nr.filter(device_name=device.get('name')).run(task=netmiko_send_config,config_file=file_path)
|
||||||
|
print_result(result)
|
||||||
|
return result[device.get('name')].changed
|
||||||
70
fastprod_backend/fastprod/services/devices.py
Normal file
70
fastprod_backend/fastprod/services/devices.py
Normal file
@@ -0,0 +1,70 @@
|
|||||||
|
from api import app
|
||||||
|
from flask import Flask,jsonify,request,abort, make_response
|
||||||
|
from utils.inventory import *
|
||||||
|
from nornir import InitNornir
|
||||||
|
from nornir_utils.plugins.functions import print_result
|
||||||
|
from nornir_napalm.plugins.tasks import napalm_get,napalm_configure, napalm_cli
|
||||||
|
from nornir_netmiko.tasks import netmiko_send_config,netmiko_send_command, netmiko_save_config, netmiko_commit
|
||||||
|
|
||||||
|
def get_inventory():
|
||||||
|
hosts = app.config.get('nr').inventory.dict().get('hosts').keys()
|
||||||
|
return list(map(lambda item: app.config.get('nr').inventory.dict().get('hosts').get(item), hosts))
|
||||||
|
|
||||||
|
def add_device(device):
|
||||||
|
device = add_item_to_hosts_yaml(item=device)
|
||||||
|
return device
|
||||||
|
|
||||||
|
def get_device_by_name(name):
|
||||||
|
host = app.config.get('nr').inventory.hosts.get(name)
|
||||||
|
if not host:
|
||||||
|
abort(make_response(jsonify(message="device not found"), 404))
|
||||||
|
return host.dict()
|
||||||
|
|
||||||
|
def delete_device(device):
|
||||||
|
try:
|
||||||
|
delete_item_from_hosts_yaml(item=device)
|
||||||
|
except Exception as e:
|
||||||
|
abort(make_response(jsonify(message="Unable to delete this device", error=str(e)), 500))
|
||||||
|
|
||||||
|
def get_device_interfaces(device):
|
||||||
|
nr = app.config.get('nr')
|
||||||
|
result = nr.filter(device_name=device.get('name')).run(task=napalm_get,
|
||||||
|
getters=["get_interfaces"])
|
||||||
|
print_result(result)
|
||||||
|
print(result)
|
||||||
|
interfaces = result[device.get('name')][0].result.get('get_interfaces')
|
||||||
|
return list(map(lambda item: dict(name=item, **interfaces.get(item)), interfaces))
|
||||||
|
|
||||||
|
def get_device_technical_info(device):
|
||||||
|
nr = app.config.get('nr')
|
||||||
|
result = nr.filter(device_name=device.get('name')).run(
|
||||||
|
task=napalm_get,
|
||||||
|
getters=["get_facts"]
|
||||||
|
)
|
||||||
|
|
||||||
|
print_result(result)
|
||||||
|
|
||||||
|
facts = result[device.get('name')][0].result.get('get_facts')
|
||||||
|
|
||||||
|
return {
|
||||||
|
"hostname": facts.get("hostname"),
|
||||||
|
"vendor": facts.get("vendor"),
|
||||||
|
"model": facts.get("model"),
|
||||||
|
"serial_number": facts.get("serial_number"),
|
||||||
|
"os_version": facts.get("os_version"),
|
||||||
|
"uptime": facts.get("uptime"),
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def get_device_interfaces_ip(device):
|
||||||
|
nr = app.config.get('nr')
|
||||||
|
result = nr.filter(device_name=device.get('name')).run(task=napalm_get,
|
||||||
|
getters=["get_interfaces_ip"])
|
||||||
|
print_result(result)
|
||||||
|
interfaces = result[device.get('name')][0].result.get('get_interfaces_ip')
|
||||||
|
def transformer(item):
|
||||||
|
ip_address = list(interfaces.get(item).get('ipv4').keys())[0]
|
||||||
|
prefix_length = interfaces.get(item).get('ipv4').get(list(interfaces.get(item).get('ipv4').keys())[0]).get('prefix_length')
|
||||||
|
return dict(name=item, ip=ip_address, prefix_length=prefix_length)
|
||||||
|
return list(map(lambda item: transformer(item), interfaces))
|
||||||
|
#return interfaces
|
||||||
35
fastprod_backend/fastprod/services/snapshots.py
Normal file
35
fastprod_backend/fastprod/services/snapshots.py
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
import os
|
||||||
|
from datetime import datetime
|
||||||
|
from api import app
|
||||||
|
from services.config import get_config_by_device
|
||||||
|
from flask import Flask,jsonify,request,abort, make_response
|
||||||
|
snapshot_directory = 'fastprod/snapshots'
|
||||||
|
|
||||||
|
|
||||||
|
def get_snapshot_by_name(name):
|
||||||
|
files = os.listdir()
|
||||||
|
snapshots = []
|
||||||
|
for file in files:
|
||||||
|
file_device_name = file.split('_')[0]
|
||||||
|
if name == file:
|
||||||
|
snapshots.append(dict(file=file, path=snapshot_directory, at=file.split('_')[1].split('.')[0]))
|
||||||
|
return snapshots
|
||||||
|
def create_snapshot_by_device(device=None):
|
||||||
|
nr = app.config.get('nr')
|
||||||
|
config = get_config_by_device(device)
|
||||||
|
|
||||||
|
timestamp = datetime.now().strftime('%Y%m%d%H%M%S')
|
||||||
|
|
||||||
|
file_path = os.path.join(snapshot_directory, f"{device.get('name')}_{timestamp}.conf")
|
||||||
|
with open(file_path, 'w') as file:
|
||||||
|
file.write(config.get('running'))
|
||||||
|
return file_path
|
||||||
|
|
||||||
|
def get_snapshots_by_device(device):
|
||||||
|
files = os.listdir(snapshot_directory)
|
||||||
|
snapshots = []
|
||||||
|
for file in files:
|
||||||
|
file_device_name = file.split('_')[0]
|
||||||
|
if file_device_name == device.get('name'):
|
||||||
|
snapshots.append(dict(file=file, path=snapshot_directory, at=file.split('_')[1].split('.')[0]))
|
||||||
|
return snapshots
|
||||||
35
fastprod_backend/fastprod/services/tasks.py
Normal file
35
fastprod_backend/fastprod/services/tasks.py
Normal file
@@ -0,0 +1,35 @@
|
|||||||
|
from api import app
|
||||||
|
from nornir_napalm.plugins.tasks import napalm_get, napalm_configure, napalm_cli
|
||||||
|
from nornir.core.task import Task, Result
|
||||||
|
from nornir_utils.plugins.functions import print_result
|
||||||
|
from nornir_netmiko.tasks import netmiko_send_config, netmiko_send_command, netmiko_save_config,netmiko_commit
|
||||||
|
|
||||||
|
def run_show_commands_by_device(device=None, commands=[]):
|
||||||
|
nr = app.config.get('nr')
|
||||||
|
commands_sent = []
|
||||||
|
if device:
|
||||||
|
if len(commands) > 1:
|
||||||
|
for command in commands:
|
||||||
|
result = nr.filter(device_name=device.get('name')).run(task=napalm_cli,
|
||||||
|
commands=[command])
|
||||||
|
print_result(result)
|
||||||
|
output = result[device.get('name')][0].result.get(command)
|
||||||
|
commands_sent.append(dict(command=command, result=output))
|
||||||
|
output = commands_sent
|
||||||
|
else:
|
||||||
|
result = nr.filter(device_name=device.get('name')).run(task=napalm_cli,
|
||||||
|
commands=commands)
|
||||||
|
|
||||||
|
output = result[device.get('name')][0].result.get(commands[0])
|
||||||
|
commands_sent.append(dict(command=commands[0], result= output))
|
||||||
|
output = commands_sent
|
||||||
|
return output
|
||||||
|
|
||||||
|
def run_config_commands_by_device(device=None, commands=[]):
|
||||||
|
nr = app.config.get('nr')
|
||||||
|
commands_sent = []
|
||||||
|
if device:
|
||||||
|
result = nr.filter(device_name=device.get('name')).run(task=netmiko_send_config,
|
||||||
|
config_commands=[commands])
|
||||||
|
print_result(result)
|
||||||
|
return result[device.get('name')].changed
|
||||||
@@ -0,0 +1,236 @@
|
|||||||
|
!
|
||||||
|
version 12.4
|
||||||
|
service timestamps debug datetime msec
|
||||||
|
service timestamps log datetime msec
|
||||||
|
no service password-encryption
|
||||||
|
no service dhcp
|
||||||
|
!
|
||||||
|
hostname ESW1-CPE-BAT-A
|
||||||
|
!
|
||||||
|
boot-start-marker
|
||||||
|
boot-end-marker
|
||||||
|
!
|
||||||
|
!
|
||||||
|
no aaa new-model
|
||||||
|
memory-size iomem 5
|
||||||
|
no ip routing
|
||||||
|
no ip icmp rate-limit unreachable
|
||||||
|
no ip cef
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
no ip domain lookup
|
||||||
|
ip domain name esw1.local
|
||||||
|
!
|
||||||
|
multilink bundle-name authenticated
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
macro name add_vlan
|
||||||
|
end
|
||||||
|
vlan database
|
||||||
|
vlan $v
|
||||||
|
exit
|
||||||
|
@
|
||||||
|
macro name del_vlan
|
||||||
|
end
|
||||||
|
vlan database
|
||||||
|
no vlan $v
|
||||||
|
exit
|
||||||
|
@
|
||||||
|
!
|
||||||
|
vtp file nvram:vlan.dat
|
||||||
|
username cisco privilege 15 password 0 cisco
|
||||||
|
archive
|
||||||
|
log config
|
||||||
|
hidekeys
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
ip tcp synwait-time 5
|
||||||
|
ip ssh version 2
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
interface Loopback1
|
||||||
|
no ip address
|
||||||
|
!
|
||||||
|
interface FastEthernet0/0
|
||||||
|
description *** Unused for Layer2 EtherSwitch ***
|
||||||
|
no ip address
|
||||||
|
no ip route-cache
|
||||||
|
duplex auto
|
||||||
|
speed auto
|
||||||
|
!
|
||||||
|
interface FastEthernet0/1
|
||||||
|
description *** Unused for Layer2 EtherSwitch ***
|
||||||
|
no ip address
|
||||||
|
no ip route-cache
|
||||||
|
shutdown
|
||||||
|
duplex auto
|
||||||
|
speed auto
|
||||||
|
!
|
||||||
|
interface FastEthernet1/0
|
||||||
|
switchport mode trunk
|
||||||
|
duplex full
|
||||||
|
speed 100
|
||||||
|
!
|
||||||
|
interface FastEthernet1/1
|
||||||
|
description "port vlan teacher"
|
||||||
|
switchport access vlan 10
|
||||||
|
duplex full
|
||||||
|
speed 100
|
||||||
|
!
|
||||||
|
interface FastEthernet1/2
|
||||||
|
description "port vlan student"
|
||||||
|
switchport access vlan 20
|
||||||
|
duplex full
|
||||||
|
speed 100
|
||||||
|
!
|
||||||
|
interface FastEthernet1/3
|
||||||
|
duplex full
|
||||||
|
speed 100
|
||||||
|
!
|
||||||
|
interface FastEthernet1/4
|
||||||
|
switchport mode trunk
|
||||||
|
duplex full
|
||||||
|
speed 100
|
||||||
|
!
|
||||||
|
interface FastEthernet1/5
|
||||||
|
duplex full
|
||||||
|
speed 100
|
||||||
|
!
|
||||||
|
interface FastEthernet1/6
|
||||||
|
duplex full
|
||||||
|
speed 100
|
||||||
|
!
|
||||||
|
interface FastEthernet1/7
|
||||||
|
duplex full
|
||||||
|
speed 100
|
||||||
|
!
|
||||||
|
interface FastEthernet1/8
|
||||||
|
duplex full
|
||||||
|
speed 100
|
||||||
|
!
|
||||||
|
interface FastEthernet1/9
|
||||||
|
duplex full
|
||||||
|
speed 100
|
||||||
|
!
|
||||||
|
interface FastEthernet1/10
|
||||||
|
duplex full
|
||||||
|
speed 100
|
||||||
|
!
|
||||||
|
interface FastEthernet1/11
|
||||||
|
duplex full
|
||||||
|
speed 100
|
||||||
|
!
|
||||||
|
interface FastEthernet1/12
|
||||||
|
duplex full
|
||||||
|
speed 100
|
||||||
|
!
|
||||||
|
interface FastEthernet1/13
|
||||||
|
duplex full
|
||||||
|
speed 100
|
||||||
|
!
|
||||||
|
interface FastEthernet1/14
|
||||||
|
switchport mode trunk
|
||||||
|
duplex full
|
||||||
|
speed 100
|
||||||
|
!
|
||||||
|
interface FastEthernet1/15
|
||||||
|
switchport mode trunk
|
||||||
|
duplex full
|
||||||
|
speed 100
|
||||||
|
!
|
||||||
|
interface FastEthernet2/0
|
||||||
|
no ip address
|
||||||
|
no ip route-cache
|
||||||
|
shutdown
|
||||||
|
duplex auto
|
||||||
|
speed auto
|
||||||
|
!
|
||||||
|
interface Vlan1
|
||||||
|
no ip address
|
||||||
|
no ip route-cache
|
||||||
|
!
|
||||||
|
interface Vlan99
|
||||||
|
ip address 172.16.100.123 255.255.255.192
|
||||||
|
!
|
||||||
|
ip forward-protocol nd
|
||||||
|
!
|
||||||
|
!
|
||||||
|
no ip http server
|
||||||
|
no ip http secure-server
|
||||||
|
!
|
||||||
|
no cdp log mismatch duplex
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
control-plane
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
banner exec ^C
|
||||||
|
|
||||||
|
***************************************************************
|
||||||
|
This is a normal Router with a Switch module inside (NM-16ESW)
|
||||||
|
It has been pre-configured with hard-coded speed and duplex
|
||||||
|
|
||||||
|
To create vlans use the command "vlan database" in exec mode
|
||||||
|
After creating all desired vlans use "exit" to apply the config
|
||||||
|
|
||||||
|
To view existing vlans use the command "show vlan-switch brief"
|
||||||
|
|
||||||
|
Alias(exec) : vl - "show vlan-switch brief" command
|
||||||
|
Alias(configure): va X - macro to add vlan X
|
||||||
|
Alias(configure): vd X - macro to delete vlan X
|
||||||
|
***************************************************************
|
||||||
|
|
||||||
|
^C
|
||||||
|
alias configure va macro global trace add_vlan $v
|
||||||
|
alias configure vd macro global trace del_vlan $v
|
||||||
|
alias exec vl show vlan-switch brief
|
||||||
|
!
|
||||||
|
line con 0
|
||||||
|
exec-timeout 0 0
|
||||||
|
privilege level 15
|
||||||
|
logging synchronous
|
||||||
|
line aux 0
|
||||||
|
exec-timeout 0 0
|
||||||
|
privilege level 15
|
||||||
|
logging synchronous
|
||||||
|
line vty 0 4
|
||||||
|
login local
|
||||||
|
transport input ssh
|
||||||
|
!
|
||||||
|
!
|
||||||
|
end
|
||||||
@@ -0,0 +1,236 @@
|
|||||||
|
!
|
||||||
|
version 12.4
|
||||||
|
service timestamps debug datetime msec
|
||||||
|
service timestamps log datetime msec
|
||||||
|
no service password-encryption
|
||||||
|
no service dhcp
|
||||||
|
!
|
||||||
|
hostname ESW1-CPE-BAT-A
|
||||||
|
!
|
||||||
|
boot-start-marker
|
||||||
|
boot-end-marker
|
||||||
|
!
|
||||||
|
!
|
||||||
|
no aaa new-model
|
||||||
|
memory-size iomem 5
|
||||||
|
no ip routing
|
||||||
|
no ip icmp rate-limit unreachable
|
||||||
|
no ip cef
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
no ip domain lookup
|
||||||
|
ip domain name esw1.local
|
||||||
|
!
|
||||||
|
multilink bundle-name authenticated
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
macro name add_vlan
|
||||||
|
end
|
||||||
|
vlan database
|
||||||
|
vlan $v
|
||||||
|
exit
|
||||||
|
@
|
||||||
|
macro name del_vlan
|
||||||
|
end
|
||||||
|
vlan database
|
||||||
|
no vlan $v
|
||||||
|
exit
|
||||||
|
@
|
||||||
|
!
|
||||||
|
vtp file nvram:vlan.dat
|
||||||
|
username cisco privilege 15 password 0 cisco
|
||||||
|
archive
|
||||||
|
log config
|
||||||
|
hidekeys
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
ip tcp synwait-time 5
|
||||||
|
ip ssh version 2
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
interface Loopback1
|
||||||
|
no ip address
|
||||||
|
!
|
||||||
|
interface FastEthernet0/0
|
||||||
|
description *** Unused for Layer2 EtherSwitch ***
|
||||||
|
no ip address
|
||||||
|
no ip route-cache
|
||||||
|
duplex auto
|
||||||
|
speed auto
|
||||||
|
!
|
||||||
|
interface FastEthernet0/1
|
||||||
|
description *** Unused for Layer2 EtherSwitch ***
|
||||||
|
no ip address
|
||||||
|
no ip route-cache
|
||||||
|
shutdown
|
||||||
|
duplex auto
|
||||||
|
speed auto
|
||||||
|
!
|
||||||
|
interface FastEthernet1/0
|
||||||
|
switchport mode trunk
|
||||||
|
duplex full
|
||||||
|
speed 100
|
||||||
|
!
|
||||||
|
interface FastEthernet1/1
|
||||||
|
description "port vlan teacher"
|
||||||
|
switchport access vlan 10
|
||||||
|
duplex full
|
||||||
|
speed 100
|
||||||
|
!
|
||||||
|
interface FastEthernet1/2
|
||||||
|
description "port vlan student"
|
||||||
|
switchport access vlan 20
|
||||||
|
duplex full
|
||||||
|
speed 100
|
||||||
|
!
|
||||||
|
interface FastEthernet1/3
|
||||||
|
duplex full
|
||||||
|
speed 100
|
||||||
|
!
|
||||||
|
interface FastEthernet1/4
|
||||||
|
switchport mode trunk
|
||||||
|
duplex full
|
||||||
|
speed 100
|
||||||
|
!
|
||||||
|
interface FastEthernet1/5
|
||||||
|
duplex full
|
||||||
|
speed 100
|
||||||
|
!
|
||||||
|
interface FastEthernet1/6
|
||||||
|
duplex full
|
||||||
|
speed 100
|
||||||
|
!
|
||||||
|
interface FastEthernet1/7
|
||||||
|
duplex full
|
||||||
|
speed 100
|
||||||
|
!
|
||||||
|
interface FastEthernet1/8
|
||||||
|
duplex full
|
||||||
|
speed 100
|
||||||
|
!
|
||||||
|
interface FastEthernet1/9
|
||||||
|
duplex full
|
||||||
|
speed 100
|
||||||
|
!
|
||||||
|
interface FastEthernet1/10
|
||||||
|
duplex full
|
||||||
|
speed 100
|
||||||
|
!
|
||||||
|
interface FastEthernet1/11
|
||||||
|
duplex full
|
||||||
|
speed 100
|
||||||
|
!
|
||||||
|
interface FastEthernet1/12
|
||||||
|
duplex full
|
||||||
|
speed 100
|
||||||
|
!
|
||||||
|
interface FastEthernet1/13
|
||||||
|
duplex full
|
||||||
|
speed 100
|
||||||
|
!
|
||||||
|
interface FastEthernet1/14
|
||||||
|
switchport mode trunk
|
||||||
|
duplex full
|
||||||
|
speed 100
|
||||||
|
!
|
||||||
|
interface FastEthernet1/15
|
||||||
|
switchport mode trunk
|
||||||
|
duplex full
|
||||||
|
speed 100
|
||||||
|
!
|
||||||
|
interface FastEthernet2/0
|
||||||
|
no ip address
|
||||||
|
no ip route-cache
|
||||||
|
shutdown
|
||||||
|
duplex auto
|
||||||
|
speed auto
|
||||||
|
!
|
||||||
|
interface Vlan1
|
||||||
|
no ip address
|
||||||
|
no ip route-cache
|
||||||
|
!
|
||||||
|
interface Vlan99
|
||||||
|
ip address 172.16.100.123 255.255.255.192
|
||||||
|
!
|
||||||
|
ip forward-protocol nd
|
||||||
|
!
|
||||||
|
!
|
||||||
|
no ip http server
|
||||||
|
no ip http secure-server
|
||||||
|
!
|
||||||
|
no cdp log mismatch duplex
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
control-plane
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
banner exec ^C
|
||||||
|
|
||||||
|
***************************************************************
|
||||||
|
This is a normal Router with a Switch module inside (NM-16ESW)
|
||||||
|
It has been pre-configured with hard-coded speed and duplex
|
||||||
|
|
||||||
|
To create vlans use the command "vlan database" in exec mode
|
||||||
|
After creating all desired vlans use "exit" to apply the config
|
||||||
|
|
||||||
|
To view existing vlans use the command "show vlan-switch brief"
|
||||||
|
|
||||||
|
Alias(exec) : vl - "show vlan-switch brief" command
|
||||||
|
Alias(configure): va X - macro to add vlan X
|
||||||
|
Alias(configure): vd X - macro to delete vlan X
|
||||||
|
***************************************************************
|
||||||
|
|
||||||
|
^C
|
||||||
|
alias configure va macro global trace add_vlan $v
|
||||||
|
alias configure vd macro global trace del_vlan $v
|
||||||
|
alias exec vl show vlan-switch brief
|
||||||
|
!
|
||||||
|
line con 0
|
||||||
|
exec-timeout 0 0
|
||||||
|
privilege level 15
|
||||||
|
logging synchronous
|
||||||
|
line aux 0
|
||||||
|
exec-timeout 0 0
|
||||||
|
privilege level 15
|
||||||
|
logging synchronous
|
||||||
|
line vty 0 4
|
||||||
|
login local
|
||||||
|
transport input ssh
|
||||||
|
!
|
||||||
|
!
|
||||||
|
end
|
||||||
@@ -0,0 +1,168 @@
|
|||||||
|
!
|
||||||
|
upgrade fpd auto
|
||||||
|
version 12.4
|
||||||
|
service timestamps debug datetime msec
|
||||||
|
service timestamps log datetime msec
|
||||||
|
no service password-encryption
|
||||||
|
!
|
||||||
|
hostname R1-CPE-BAT-A
|
||||||
|
!
|
||||||
|
boot-start-marker
|
||||||
|
boot-end-marker
|
||||||
|
!
|
||||||
|
logging message-counter syslog
|
||||||
|
!
|
||||||
|
no aaa new-model
|
||||||
|
ip source-route
|
||||||
|
no ip icmp rate-limit unreachable
|
||||||
|
ip cef
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
no ip domain lookup
|
||||||
|
ip domain name r1.cpe.local
|
||||||
|
no ipv6 cef
|
||||||
|
!
|
||||||
|
multilink bundle-name authenticated
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
file prompt quiet
|
||||||
|
username cisco privilege 15 password 0 cisco
|
||||||
|
archive
|
||||||
|
log config
|
||||||
|
hidekeys
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
ip tcp synwait-time 5
|
||||||
|
ip ssh version 2
|
||||||
|
ip scp server enable
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
interface Loopback1
|
||||||
|
description Loopback pour R1-CPE-BAT-A
|
||||||
|
ip address 1.1.1.1 255.255.255.255
|
||||||
|
!
|
||||||
|
interface Loopback2
|
||||||
|
description Loopback2 pour R1-CPE-BAT-A
|
||||||
|
ip address 1.1.1.2 255.255.255.255
|
||||||
|
!
|
||||||
|
interface Loopback10
|
||||||
|
description created from config file uploaded from postman
|
||||||
|
ip address 10.10.10.10 255.255.255.255
|
||||||
|
!
|
||||||
|
interface FastEthernet0/0
|
||||||
|
ip address 172.16.100.62 255.255.255.192
|
||||||
|
duplex half
|
||||||
|
!
|
||||||
|
interface Serial1/0
|
||||||
|
no ip address
|
||||||
|
shutdown
|
||||||
|
serial restart-delay 0
|
||||||
|
!
|
||||||
|
interface Serial1/1
|
||||||
|
ip address 10.1.1.1 255.255.255.252
|
||||||
|
shutdown
|
||||||
|
serial restart-delay 0
|
||||||
|
!
|
||||||
|
interface Serial1/2
|
||||||
|
no ip address
|
||||||
|
shutdown
|
||||||
|
serial restart-delay 0
|
||||||
|
!
|
||||||
|
interface Serial1/3
|
||||||
|
no ip address
|
||||||
|
shutdown
|
||||||
|
serial restart-delay 0
|
||||||
|
!
|
||||||
|
interface GigabitEthernet2/0
|
||||||
|
no ip address
|
||||||
|
negotiation auto
|
||||||
|
!
|
||||||
|
interface GigabitEthernet2/0.10
|
||||||
|
description "Gateway for teacher vlan"
|
||||||
|
encapsulation dot1Q 10
|
||||||
|
ip address 172.16.10.253 255.255.255.0
|
||||||
|
vrrp 10 ip 172.16.10.252
|
||||||
|
!
|
||||||
|
interface GigabitEthernet2/0.20
|
||||||
|
description "Gateway for student vlan"
|
||||||
|
encapsulation dot1Q 20
|
||||||
|
ip address 172.16.20.253 255.255.255.0
|
||||||
|
vrrp 20 ip 172.16.20.252
|
||||||
|
!
|
||||||
|
interface GigabitEthernet2/0.99
|
||||||
|
encapsulation dot1Q 99
|
||||||
|
ip address 172.16.100.125 255.255.255.192
|
||||||
|
vrrp 99 ip 172.16.100.124
|
||||||
|
!
|
||||||
|
router ospf 1
|
||||||
|
router-id 1.1.1.1
|
||||||
|
log-adjacency-changes
|
||||||
|
passive-interface FastEthernet0/0
|
||||||
|
passive-interface GigabitEthernet2/0.99
|
||||||
|
network 10.1.1.0 0.0.0.3 area 0
|
||||||
|
network 172.16.10.0 0.0.0.255 area 0
|
||||||
|
network 172.16.20.0 0.0.0.255 area 0
|
||||||
|
network 172.16.100.0 0.0.0.63 area 0
|
||||||
|
network 172.16.100.64 0.0.0.63 area 0
|
||||||
|
!
|
||||||
|
ip forward-protocol nd
|
||||||
|
no ip http server
|
||||||
|
no ip http secure-server
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
no cdp log mismatch duplex
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
control-plane
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
gatekeeper
|
||||||
|
shutdown
|
||||||
|
!
|
||||||
|
!
|
||||||
|
line con 0
|
||||||
|
exec-timeout 0 0
|
||||||
|
privilege level 15
|
||||||
|
logging synchronous
|
||||||
|
stopbits 1
|
||||||
|
line aux 0
|
||||||
|
exec-timeout 0 0
|
||||||
|
privilege level 15
|
||||||
|
logging synchronous
|
||||||
|
stopbits 1
|
||||||
|
line vty 0 4
|
||||||
|
login local
|
||||||
|
transport input ssh
|
||||||
|
!
|
||||||
|
end
|
||||||
@@ -0,0 +1,168 @@
|
|||||||
|
!
|
||||||
|
upgrade fpd auto
|
||||||
|
version 12.4
|
||||||
|
service timestamps debug datetime msec
|
||||||
|
service timestamps log datetime msec
|
||||||
|
no service password-encryption
|
||||||
|
!
|
||||||
|
hostname R1-CPE-BAT-A
|
||||||
|
!
|
||||||
|
boot-start-marker
|
||||||
|
boot-end-marker
|
||||||
|
!
|
||||||
|
logging message-counter syslog
|
||||||
|
!
|
||||||
|
no aaa new-model
|
||||||
|
ip source-route
|
||||||
|
no ip icmp rate-limit unreachable
|
||||||
|
ip cef
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
no ip domain lookup
|
||||||
|
ip domain name r1.cpe.local
|
||||||
|
no ipv6 cef
|
||||||
|
!
|
||||||
|
multilink bundle-name authenticated
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
file prompt quiet
|
||||||
|
username cisco privilege 15 password 0 cisco
|
||||||
|
archive
|
||||||
|
log config
|
||||||
|
hidekeys
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
ip tcp synwait-time 5
|
||||||
|
ip ssh version 2
|
||||||
|
ip scp server enable
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
interface Loopback1
|
||||||
|
description Loopback pour R1-CPE-BAT-A
|
||||||
|
ip address 1.1.1.1 255.255.255.255
|
||||||
|
!
|
||||||
|
interface Loopback2
|
||||||
|
description Loopback2 pour R1-CPE-BAT-A
|
||||||
|
ip address 1.1.1.2 255.255.255.255
|
||||||
|
!
|
||||||
|
interface Loopback10
|
||||||
|
description created from config file uploaded from postman
|
||||||
|
ip address 10.10.10.10 255.255.255.255
|
||||||
|
!
|
||||||
|
interface FastEthernet0/0
|
||||||
|
ip address 172.16.100.62 255.255.255.192
|
||||||
|
duplex half
|
||||||
|
!
|
||||||
|
interface Serial1/0
|
||||||
|
no ip address
|
||||||
|
shutdown
|
||||||
|
serial restart-delay 0
|
||||||
|
!
|
||||||
|
interface Serial1/1
|
||||||
|
ip address 10.1.1.1 255.255.255.252
|
||||||
|
shutdown
|
||||||
|
serial restart-delay 0
|
||||||
|
!
|
||||||
|
interface Serial1/2
|
||||||
|
no ip address
|
||||||
|
shutdown
|
||||||
|
serial restart-delay 0
|
||||||
|
!
|
||||||
|
interface Serial1/3
|
||||||
|
no ip address
|
||||||
|
shutdown
|
||||||
|
serial restart-delay 0
|
||||||
|
!
|
||||||
|
interface GigabitEthernet2/0
|
||||||
|
no ip address
|
||||||
|
negotiation auto
|
||||||
|
!
|
||||||
|
interface GigabitEthernet2/0.10
|
||||||
|
description "Gateway for teacher vlan"
|
||||||
|
encapsulation dot1Q 10
|
||||||
|
ip address 172.16.10.253 255.255.255.0
|
||||||
|
vrrp 10 ip 172.16.10.252
|
||||||
|
!
|
||||||
|
interface GigabitEthernet2/0.20
|
||||||
|
description "Gateway for student vlan"
|
||||||
|
encapsulation dot1Q 20
|
||||||
|
ip address 172.16.20.253 255.255.255.0
|
||||||
|
vrrp 20 ip 172.16.20.252
|
||||||
|
!
|
||||||
|
interface GigabitEthernet2/0.99
|
||||||
|
encapsulation dot1Q 99
|
||||||
|
ip address 172.16.100.125 255.255.255.192
|
||||||
|
vrrp 99 ip 172.16.100.124
|
||||||
|
!
|
||||||
|
router ospf 1
|
||||||
|
router-id 1.1.1.1
|
||||||
|
log-adjacency-changes
|
||||||
|
passive-interface FastEthernet0/0
|
||||||
|
passive-interface GigabitEthernet2/0.99
|
||||||
|
network 10.1.1.0 0.0.0.3 area 0
|
||||||
|
network 172.16.10.0 0.0.0.255 area 0
|
||||||
|
network 172.16.20.0 0.0.0.255 area 0
|
||||||
|
network 172.16.100.0 0.0.0.63 area 0
|
||||||
|
network 172.16.100.64 0.0.0.63 area 0
|
||||||
|
!
|
||||||
|
ip forward-protocol nd
|
||||||
|
no ip http server
|
||||||
|
no ip http secure-server
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
no cdp log mismatch duplex
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
control-plane
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
gatekeeper
|
||||||
|
shutdown
|
||||||
|
!
|
||||||
|
!
|
||||||
|
line con 0
|
||||||
|
exec-timeout 0 0
|
||||||
|
privilege level 15
|
||||||
|
logging synchronous
|
||||||
|
stopbits 1
|
||||||
|
line aux 0
|
||||||
|
exec-timeout 0 0
|
||||||
|
privilege level 15
|
||||||
|
logging synchronous
|
||||||
|
stopbits 1
|
||||||
|
line vty 0 4
|
||||||
|
login local
|
||||||
|
transport input ssh
|
||||||
|
!
|
||||||
|
end
|
||||||
@@ -0,0 +1,168 @@
|
|||||||
|
!
|
||||||
|
upgrade fpd auto
|
||||||
|
version 12.4
|
||||||
|
service timestamps debug datetime msec
|
||||||
|
service timestamps log datetime msec
|
||||||
|
no service password-encryption
|
||||||
|
!
|
||||||
|
hostname R1-CPE-BAT-A
|
||||||
|
!
|
||||||
|
boot-start-marker
|
||||||
|
boot-end-marker
|
||||||
|
!
|
||||||
|
logging message-counter syslog
|
||||||
|
!
|
||||||
|
no aaa new-model
|
||||||
|
ip source-route
|
||||||
|
no ip icmp rate-limit unreachable
|
||||||
|
ip cef
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
no ip domain lookup
|
||||||
|
ip domain name r1.cpe.local
|
||||||
|
no ipv6 cef
|
||||||
|
!
|
||||||
|
multilink bundle-name authenticated
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
file prompt quiet
|
||||||
|
username cisco privilege 15 password 0 cisco
|
||||||
|
archive
|
||||||
|
log config
|
||||||
|
hidekeys
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
ip tcp synwait-time 5
|
||||||
|
ip ssh version 2
|
||||||
|
ip scp server enable
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
interface Loopback1
|
||||||
|
description Loopback pour R1-CPE-BAT-A
|
||||||
|
ip address 1.1.1.1 255.255.255.255
|
||||||
|
!
|
||||||
|
interface Loopback2
|
||||||
|
description Loopback2 pour R1-CPE-BAT-A
|
||||||
|
ip address 1.1.1.2 255.255.255.255
|
||||||
|
!
|
||||||
|
interface Loopback10
|
||||||
|
description created from config file uploaded from postman
|
||||||
|
ip address 10.10.10.10 255.255.255.255
|
||||||
|
!
|
||||||
|
interface FastEthernet0/0
|
||||||
|
ip address 172.16.100.62 255.255.255.192
|
||||||
|
duplex half
|
||||||
|
!
|
||||||
|
interface Serial1/0
|
||||||
|
no ip address
|
||||||
|
shutdown
|
||||||
|
serial restart-delay 0
|
||||||
|
!
|
||||||
|
interface Serial1/1
|
||||||
|
ip address 10.1.1.1 255.255.255.252
|
||||||
|
shutdown
|
||||||
|
serial restart-delay 0
|
||||||
|
!
|
||||||
|
interface Serial1/2
|
||||||
|
no ip address
|
||||||
|
shutdown
|
||||||
|
serial restart-delay 0
|
||||||
|
!
|
||||||
|
interface Serial1/3
|
||||||
|
no ip address
|
||||||
|
shutdown
|
||||||
|
serial restart-delay 0
|
||||||
|
!
|
||||||
|
interface GigabitEthernet2/0
|
||||||
|
no ip address
|
||||||
|
negotiation auto
|
||||||
|
!
|
||||||
|
interface GigabitEthernet2/0.10
|
||||||
|
description "Gateway for teacher vlan"
|
||||||
|
encapsulation dot1Q 10
|
||||||
|
ip address 172.16.10.253 255.255.255.0
|
||||||
|
vrrp 10 ip 172.16.10.252
|
||||||
|
!
|
||||||
|
interface GigabitEthernet2/0.20
|
||||||
|
description "Gateway for student vlan"
|
||||||
|
encapsulation dot1Q 20
|
||||||
|
ip address 172.16.20.253 255.255.255.0
|
||||||
|
vrrp 20 ip 172.16.20.252
|
||||||
|
!
|
||||||
|
interface GigabitEthernet2/0.99
|
||||||
|
encapsulation dot1Q 99
|
||||||
|
ip address 172.16.100.125 255.255.255.192
|
||||||
|
vrrp 99 ip 172.16.100.124
|
||||||
|
!
|
||||||
|
router ospf 1
|
||||||
|
router-id 1.1.1.1
|
||||||
|
log-adjacency-changes
|
||||||
|
passive-interface FastEthernet0/0
|
||||||
|
passive-interface GigabitEthernet2/0.99
|
||||||
|
network 10.1.1.0 0.0.0.3 area 0
|
||||||
|
network 172.16.10.0 0.0.0.255 area 0
|
||||||
|
network 172.16.20.0 0.0.0.255 area 0
|
||||||
|
network 172.16.100.0 0.0.0.63 area 0
|
||||||
|
network 172.16.100.64 0.0.0.63 area 0
|
||||||
|
!
|
||||||
|
ip forward-protocol nd
|
||||||
|
no ip http server
|
||||||
|
no ip http secure-server
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
no cdp log mismatch duplex
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
control-plane
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
gatekeeper
|
||||||
|
shutdown
|
||||||
|
!
|
||||||
|
!
|
||||||
|
line con 0
|
||||||
|
exec-timeout 0 0
|
||||||
|
privilege level 15
|
||||||
|
logging synchronous
|
||||||
|
stopbits 1
|
||||||
|
line aux 0
|
||||||
|
exec-timeout 0 0
|
||||||
|
privilege level 15
|
||||||
|
logging synchronous
|
||||||
|
stopbits 1
|
||||||
|
line vty 0 4
|
||||||
|
login local
|
||||||
|
transport input ssh
|
||||||
|
!
|
||||||
|
end
|
||||||
@@ -0,0 +1,168 @@
|
|||||||
|
!
|
||||||
|
upgrade fpd auto
|
||||||
|
version 12.4
|
||||||
|
service timestamps debug datetime msec
|
||||||
|
service timestamps log datetime msec
|
||||||
|
no service password-encryption
|
||||||
|
!
|
||||||
|
hostname R1-CPE-BAT-A
|
||||||
|
!
|
||||||
|
boot-start-marker
|
||||||
|
boot-end-marker
|
||||||
|
!
|
||||||
|
logging message-counter syslog
|
||||||
|
!
|
||||||
|
no aaa new-model
|
||||||
|
ip source-route
|
||||||
|
no ip icmp rate-limit unreachable
|
||||||
|
ip cef
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
no ip domain lookup
|
||||||
|
ip domain name r1.cpe.local
|
||||||
|
no ipv6 cef
|
||||||
|
!
|
||||||
|
multilink bundle-name authenticated
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
file prompt quiet
|
||||||
|
username cisco privilege 15 password 0 cisco
|
||||||
|
archive
|
||||||
|
log config
|
||||||
|
hidekeys
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
ip tcp synwait-time 5
|
||||||
|
ip ssh version 2
|
||||||
|
ip scp server enable
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
interface Loopback1
|
||||||
|
description Loopback pour R1-CPE-BAT-A
|
||||||
|
ip address 1.1.1.1 255.255.255.255
|
||||||
|
!
|
||||||
|
interface Loopback2
|
||||||
|
description Loopback2 pour R1-CPE-BAT-A
|
||||||
|
ip address 1.1.1.2 255.255.255.255
|
||||||
|
!
|
||||||
|
interface Loopback10
|
||||||
|
description created from config file uploaded from postman
|
||||||
|
ip address 10.10.10.10 255.255.255.255
|
||||||
|
!
|
||||||
|
interface FastEthernet0/0
|
||||||
|
ip address 172.16.100.62 255.255.255.192
|
||||||
|
duplex half
|
||||||
|
!
|
||||||
|
interface Serial1/0
|
||||||
|
no ip address
|
||||||
|
shutdown
|
||||||
|
serial restart-delay 0
|
||||||
|
!
|
||||||
|
interface Serial1/1
|
||||||
|
ip address 10.1.1.1 255.255.255.252
|
||||||
|
shutdown
|
||||||
|
serial restart-delay 0
|
||||||
|
!
|
||||||
|
interface Serial1/2
|
||||||
|
no ip address
|
||||||
|
shutdown
|
||||||
|
serial restart-delay 0
|
||||||
|
!
|
||||||
|
interface Serial1/3
|
||||||
|
no ip address
|
||||||
|
shutdown
|
||||||
|
serial restart-delay 0
|
||||||
|
!
|
||||||
|
interface GigabitEthernet2/0
|
||||||
|
no ip address
|
||||||
|
negotiation auto
|
||||||
|
!
|
||||||
|
interface GigabitEthernet2/0.10
|
||||||
|
description "Gateway for teacher vlan"
|
||||||
|
encapsulation dot1Q 10
|
||||||
|
ip address 172.16.10.253 255.255.255.0
|
||||||
|
vrrp 10 ip 172.16.10.252
|
||||||
|
!
|
||||||
|
interface GigabitEthernet2/0.20
|
||||||
|
description "Gateway for student vlan"
|
||||||
|
encapsulation dot1Q 20
|
||||||
|
ip address 172.16.20.253 255.255.255.0
|
||||||
|
vrrp 20 ip 172.16.20.252
|
||||||
|
!
|
||||||
|
interface GigabitEthernet2/0.99
|
||||||
|
encapsulation dot1Q 99
|
||||||
|
ip address 172.16.100.125 255.255.255.192
|
||||||
|
vrrp 99 ip 172.16.100.124
|
||||||
|
!
|
||||||
|
router ospf 1
|
||||||
|
router-id 1.1.1.1
|
||||||
|
log-adjacency-changes
|
||||||
|
passive-interface FastEthernet0/0
|
||||||
|
passive-interface GigabitEthernet2/0.99
|
||||||
|
network 10.1.1.0 0.0.0.3 area 0
|
||||||
|
network 172.16.10.0 0.0.0.255 area 0
|
||||||
|
network 172.16.20.0 0.0.0.255 area 0
|
||||||
|
network 172.16.100.0 0.0.0.63 area 0
|
||||||
|
network 172.16.100.64 0.0.0.63 area 0
|
||||||
|
!
|
||||||
|
ip forward-protocol nd
|
||||||
|
no ip http server
|
||||||
|
no ip http secure-server
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
no cdp log mismatch duplex
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
control-plane
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
gatekeeper
|
||||||
|
shutdown
|
||||||
|
!
|
||||||
|
!
|
||||||
|
line con 0
|
||||||
|
exec-timeout 0 0
|
||||||
|
privilege level 15
|
||||||
|
logging synchronous
|
||||||
|
stopbits 1
|
||||||
|
line aux 0
|
||||||
|
exec-timeout 0 0
|
||||||
|
privilege level 15
|
||||||
|
logging synchronous
|
||||||
|
stopbits 1
|
||||||
|
line vty 0 4
|
||||||
|
login local
|
||||||
|
transport input ssh
|
||||||
|
!
|
||||||
|
end
|
||||||
@@ -0,0 +1,168 @@
|
|||||||
|
!
|
||||||
|
upgrade fpd auto
|
||||||
|
version 12.4
|
||||||
|
service timestamps debug datetime msec
|
||||||
|
service timestamps log datetime msec
|
||||||
|
no service password-encryption
|
||||||
|
!
|
||||||
|
hostname R1-CPE-BAT-A
|
||||||
|
!
|
||||||
|
boot-start-marker
|
||||||
|
boot-end-marker
|
||||||
|
!
|
||||||
|
logging message-counter syslog
|
||||||
|
!
|
||||||
|
no aaa new-model
|
||||||
|
ip source-route
|
||||||
|
no ip icmp rate-limit unreachable
|
||||||
|
ip cef
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
no ip domain lookup
|
||||||
|
ip domain name r1.cpe.local
|
||||||
|
no ipv6 cef
|
||||||
|
!
|
||||||
|
multilink bundle-name authenticated
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
file prompt quiet
|
||||||
|
username cisco privilege 15 password 0 cisco
|
||||||
|
archive
|
||||||
|
log config
|
||||||
|
hidekeys
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
ip tcp synwait-time 5
|
||||||
|
ip ssh version 2
|
||||||
|
ip scp server enable
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
interface Loopback1
|
||||||
|
description Loopback pour R1-CPE-BAT-A
|
||||||
|
ip address 1.1.1.1 255.255.255.255
|
||||||
|
!
|
||||||
|
interface Loopback2
|
||||||
|
description Loopback2 pour R1-CPE-BAT-A
|
||||||
|
ip address 1.1.1.2 255.255.255.255
|
||||||
|
!
|
||||||
|
interface Loopback10
|
||||||
|
description created from config file uploaded from postman
|
||||||
|
ip address 10.10.10.10 255.255.255.255
|
||||||
|
!
|
||||||
|
interface FastEthernet0/0
|
||||||
|
ip address 172.16.100.62 255.255.255.192
|
||||||
|
duplex half
|
||||||
|
!
|
||||||
|
interface Serial1/0
|
||||||
|
no ip address
|
||||||
|
shutdown
|
||||||
|
serial restart-delay 0
|
||||||
|
!
|
||||||
|
interface Serial1/1
|
||||||
|
ip address 10.1.1.1 255.255.255.252
|
||||||
|
shutdown
|
||||||
|
serial restart-delay 0
|
||||||
|
!
|
||||||
|
interface Serial1/2
|
||||||
|
no ip address
|
||||||
|
shutdown
|
||||||
|
serial restart-delay 0
|
||||||
|
!
|
||||||
|
interface Serial1/3
|
||||||
|
no ip address
|
||||||
|
shutdown
|
||||||
|
serial restart-delay 0
|
||||||
|
!
|
||||||
|
interface GigabitEthernet2/0
|
||||||
|
no ip address
|
||||||
|
negotiation auto
|
||||||
|
!
|
||||||
|
interface GigabitEthernet2/0.10
|
||||||
|
description "Gateway for teacher vlan"
|
||||||
|
encapsulation dot1Q 10
|
||||||
|
ip address 172.16.10.253 255.255.255.0
|
||||||
|
vrrp 10 ip 172.16.10.252
|
||||||
|
!
|
||||||
|
interface GigabitEthernet2/0.20
|
||||||
|
description "Gateway for student vlan"
|
||||||
|
encapsulation dot1Q 20
|
||||||
|
ip address 172.16.20.253 255.255.255.0
|
||||||
|
vrrp 20 ip 172.16.20.252
|
||||||
|
!
|
||||||
|
interface GigabitEthernet2/0.99
|
||||||
|
encapsulation dot1Q 99
|
||||||
|
ip address 172.16.100.125 255.255.255.192
|
||||||
|
vrrp 99 ip 172.16.100.124
|
||||||
|
!
|
||||||
|
router ospf 1
|
||||||
|
router-id 1.1.1.1
|
||||||
|
log-adjacency-changes
|
||||||
|
passive-interface FastEthernet0/0
|
||||||
|
passive-interface GigabitEthernet2/0.99
|
||||||
|
network 10.1.1.0 0.0.0.3 area 0
|
||||||
|
network 172.16.10.0 0.0.0.255 area 0
|
||||||
|
network 172.16.20.0 0.0.0.255 area 0
|
||||||
|
network 172.16.100.0 0.0.0.63 area 0
|
||||||
|
network 172.16.100.64 0.0.0.63 area 0
|
||||||
|
!
|
||||||
|
ip forward-protocol nd
|
||||||
|
no ip http server
|
||||||
|
no ip http secure-server
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
no cdp log mismatch duplex
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
control-plane
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
gatekeeper
|
||||||
|
shutdown
|
||||||
|
!
|
||||||
|
!
|
||||||
|
line con 0
|
||||||
|
exec-timeout 0 0
|
||||||
|
privilege level 15
|
||||||
|
logging synchronous
|
||||||
|
stopbits 1
|
||||||
|
line aux 0
|
||||||
|
exec-timeout 0 0
|
||||||
|
privilege level 15
|
||||||
|
logging synchronous
|
||||||
|
stopbits 1
|
||||||
|
line vty 0 4
|
||||||
|
login local
|
||||||
|
transport input ssh
|
||||||
|
!
|
||||||
|
end
|
||||||
@@ -0,0 +1,168 @@
|
|||||||
|
!
|
||||||
|
upgrade fpd auto
|
||||||
|
version 12.4
|
||||||
|
service timestamps debug datetime msec
|
||||||
|
service timestamps log datetime msec
|
||||||
|
no service password-encryption
|
||||||
|
!
|
||||||
|
hostname R1-CPE-BAT-A
|
||||||
|
!
|
||||||
|
boot-start-marker
|
||||||
|
boot-end-marker
|
||||||
|
!
|
||||||
|
logging message-counter syslog
|
||||||
|
!
|
||||||
|
no aaa new-model
|
||||||
|
ip source-route
|
||||||
|
no ip icmp rate-limit unreachable
|
||||||
|
ip cef
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
no ip domain lookup
|
||||||
|
ip domain name r1.cpe.local
|
||||||
|
no ipv6 cef
|
||||||
|
!
|
||||||
|
multilink bundle-name authenticated
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
file prompt quiet
|
||||||
|
username cisco privilege 15 password 0 cisco
|
||||||
|
archive
|
||||||
|
log config
|
||||||
|
hidekeys
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
ip tcp synwait-time 5
|
||||||
|
ip ssh version 2
|
||||||
|
ip scp server enable
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
interface Loopback1
|
||||||
|
description Loopback pour R1-CPE-BAT-A
|
||||||
|
ip address 1.1.1.1 255.255.255.255
|
||||||
|
!
|
||||||
|
interface Loopback2
|
||||||
|
description Loopback2 pour R1-CPE-BAT-A
|
||||||
|
ip address 1.1.1.2 255.255.255.255
|
||||||
|
!
|
||||||
|
interface Loopback10
|
||||||
|
description created from config file uploaded from postman
|
||||||
|
ip address 10.10.10.10 255.255.255.255
|
||||||
|
!
|
||||||
|
interface FastEthernet0/0
|
||||||
|
ip address 172.16.100.62 255.255.255.192
|
||||||
|
duplex half
|
||||||
|
!
|
||||||
|
interface Serial1/0
|
||||||
|
no ip address
|
||||||
|
shutdown
|
||||||
|
serial restart-delay 0
|
||||||
|
!
|
||||||
|
interface Serial1/1
|
||||||
|
ip address 10.1.1.1 255.255.255.252
|
||||||
|
shutdown
|
||||||
|
serial restart-delay 0
|
||||||
|
!
|
||||||
|
interface Serial1/2
|
||||||
|
no ip address
|
||||||
|
shutdown
|
||||||
|
serial restart-delay 0
|
||||||
|
!
|
||||||
|
interface Serial1/3
|
||||||
|
no ip address
|
||||||
|
shutdown
|
||||||
|
serial restart-delay 0
|
||||||
|
!
|
||||||
|
interface GigabitEthernet2/0
|
||||||
|
no ip address
|
||||||
|
negotiation auto
|
||||||
|
!
|
||||||
|
interface GigabitEthernet2/0.10
|
||||||
|
description "Gateway for teacher vlan"
|
||||||
|
encapsulation dot1Q 10
|
||||||
|
ip address 172.16.10.253 255.255.255.0
|
||||||
|
vrrp 10 ip 172.16.10.252
|
||||||
|
!
|
||||||
|
interface GigabitEthernet2/0.20
|
||||||
|
description "Gateway for student vlan"
|
||||||
|
encapsulation dot1Q 20
|
||||||
|
ip address 172.16.20.253 255.255.255.0
|
||||||
|
vrrp 20 ip 172.16.20.252
|
||||||
|
!
|
||||||
|
interface GigabitEthernet2/0.99
|
||||||
|
encapsulation dot1Q 99
|
||||||
|
ip address 172.16.100.125 255.255.255.192
|
||||||
|
vrrp 99 ip 172.16.100.124
|
||||||
|
!
|
||||||
|
router ospf 1
|
||||||
|
router-id 1.1.1.1
|
||||||
|
log-adjacency-changes
|
||||||
|
passive-interface FastEthernet0/0
|
||||||
|
passive-interface GigabitEthernet2/0.99
|
||||||
|
network 10.1.1.0 0.0.0.3 area 0
|
||||||
|
network 172.16.10.0 0.0.0.255 area 0
|
||||||
|
network 172.16.20.0 0.0.0.255 area 0
|
||||||
|
network 172.16.100.0 0.0.0.63 area 0
|
||||||
|
network 172.16.100.64 0.0.0.63 area 0
|
||||||
|
!
|
||||||
|
ip forward-protocol nd
|
||||||
|
no ip http server
|
||||||
|
no ip http secure-server
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
no cdp log mismatch duplex
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
control-plane
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
gatekeeper
|
||||||
|
shutdown
|
||||||
|
!
|
||||||
|
!
|
||||||
|
line con 0
|
||||||
|
exec-timeout 0 0
|
||||||
|
privilege level 15
|
||||||
|
logging synchronous
|
||||||
|
stopbits 1
|
||||||
|
line aux 0
|
||||||
|
exec-timeout 0 0
|
||||||
|
privilege level 15
|
||||||
|
logging synchronous
|
||||||
|
stopbits 1
|
||||||
|
line vty 0 4
|
||||||
|
login local
|
||||||
|
transport input ssh
|
||||||
|
!
|
||||||
|
end
|
||||||
@@ -0,0 +1,168 @@
|
|||||||
|
!
|
||||||
|
upgrade fpd auto
|
||||||
|
version 12.4
|
||||||
|
service timestamps debug datetime msec
|
||||||
|
service timestamps log datetime msec
|
||||||
|
no service password-encryption
|
||||||
|
!
|
||||||
|
hostname R1-CPE-BAT-A
|
||||||
|
!
|
||||||
|
boot-start-marker
|
||||||
|
boot-end-marker
|
||||||
|
!
|
||||||
|
logging message-counter syslog
|
||||||
|
!
|
||||||
|
no aaa new-model
|
||||||
|
ip source-route
|
||||||
|
no ip icmp rate-limit unreachable
|
||||||
|
ip cef
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
no ip domain lookup
|
||||||
|
ip domain name r1.cpe.local
|
||||||
|
no ipv6 cef
|
||||||
|
!
|
||||||
|
multilink bundle-name authenticated
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
file prompt quiet
|
||||||
|
username cisco privilege 15 password 0 cisco
|
||||||
|
archive
|
||||||
|
log config
|
||||||
|
hidekeys
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
ip tcp synwait-time 5
|
||||||
|
ip ssh version 2
|
||||||
|
ip scp server enable
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
interface Loopback1
|
||||||
|
description Loopback pour R1-CPE-BAT-A
|
||||||
|
ip address 1.1.1.1 255.255.255.255
|
||||||
|
!
|
||||||
|
interface Loopback2
|
||||||
|
description Loopback2 pour R1-CPE-BAT-A
|
||||||
|
ip address 1.1.1.2 255.255.255.255
|
||||||
|
!
|
||||||
|
interface Loopback10
|
||||||
|
description created from config file uploaded from postman
|
||||||
|
ip address 10.10.10.10 255.255.255.255
|
||||||
|
!
|
||||||
|
interface FastEthernet0/0
|
||||||
|
ip address 172.16.100.62 255.255.255.192
|
||||||
|
duplex half
|
||||||
|
!
|
||||||
|
interface Serial1/0
|
||||||
|
no ip address
|
||||||
|
shutdown
|
||||||
|
serial restart-delay 0
|
||||||
|
!
|
||||||
|
interface Serial1/1
|
||||||
|
ip address 10.1.1.1 255.255.255.252
|
||||||
|
shutdown
|
||||||
|
serial restart-delay 0
|
||||||
|
!
|
||||||
|
interface Serial1/2
|
||||||
|
no ip address
|
||||||
|
shutdown
|
||||||
|
serial restart-delay 0
|
||||||
|
!
|
||||||
|
interface Serial1/3
|
||||||
|
no ip address
|
||||||
|
shutdown
|
||||||
|
serial restart-delay 0
|
||||||
|
!
|
||||||
|
interface GigabitEthernet2/0
|
||||||
|
no ip address
|
||||||
|
negotiation auto
|
||||||
|
!
|
||||||
|
interface GigabitEthernet2/0.10
|
||||||
|
description "Gateway for teacher vlan"
|
||||||
|
encapsulation dot1Q 10
|
||||||
|
ip address 172.16.10.253 255.255.255.0
|
||||||
|
vrrp 10 ip 172.16.10.252
|
||||||
|
!
|
||||||
|
interface GigabitEthernet2/0.20
|
||||||
|
description "Gateway for student vlan"
|
||||||
|
encapsulation dot1Q 20
|
||||||
|
ip address 172.16.20.253 255.255.255.0
|
||||||
|
vrrp 20 ip 172.16.20.252
|
||||||
|
!
|
||||||
|
interface GigabitEthernet2/0.99
|
||||||
|
encapsulation dot1Q 99
|
||||||
|
ip address 172.16.100.125 255.255.255.192
|
||||||
|
vrrp 99 ip 172.16.100.124
|
||||||
|
!
|
||||||
|
router ospf 1
|
||||||
|
router-id 1.1.1.1
|
||||||
|
log-adjacency-changes
|
||||||
|
passive-interface FastEthernet0/0
|
||||||
|
passive-interface GigabitEthernet2/0.99
|
||||||
|
network 10.1.1.0 0.0.0.3 area 0
|
||||||
|
network 172.16.10.0 0.0.0.255 area 0
|
||||||
|
network 172.16.20.0 0.0.0.255 area 0
|
||||||
|
network 172.16.100.0 0.0.0.63 area 0
|
||||||
|
network 172.16.100.64 0.0.0.63 area 0
|
||||||
|
!
|
||||||
|
ip forward-protocol nd
|
||||||
|
no ip http server
|
||||||
|
no ip http secure-server
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
no cdp log mismatch duplex
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
control-plane
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
gatekeeper
|
||||||
|
shutdown
|
||||||
|
!
|
||||||
|
!
|
||||||
|
line con 0
|
||||||
|
exec-timeout 0 0
|
||||||
|
privilege level 15
|
||||||
|
logging synchronous
|
||||||
|
stopbits 1
|
||||||
|
line aux 0
|
||||||
|
exec-timeout 0 0
|
||||||
|
privilege level 15
|
||||||
|
logging synchronous
|
||||||
|
stopbits 1
|
||||||
|
line vty 0 4
|
||||||
|
login local
|
||||||
|
transport input ssh
|
||||||
|
!
|
||||||
|
end
|
||||||
@@ -0,0 +1,168 @@
|
|||||||
|
!
|
||||||
|
upgrade fpd auto
|
||||||
|
version 12.4
|
||||||
|
service timestamps debug datetime msec
|
||||||
|
service timestamps log datetime msec
|
||||||
|
no service password-encryption
|
||||||
|
!
|
||||||
|
hostname R1-CPE-BAT-A
|
||||||
|
!
|
||||||
|
boot-start-marker
|
||||||
|
boot-end-marker
|
||||||
|
!
|
||||||
|
logging message-counter syslog
|
||||||
|
!
|
||||||
|
no aaa new-model
|
||||||
|
ip source-route
|
||||||
|
no ip icmp rate-limit unreachable
|
||||||
|
ip cef
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
no ip domain lookup
|
||||||
|
ip domain name r1.cpe.local
|
||||||
|
no ipv6 cef
|
||||||
|
!
|
||||||
|
multilink bundle-name authenticated
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
file prompt quiet
|
||||||
|
username cisco privilege 15 password 0 cisco
|
||||||
|
archive
|
||||||
|
log config
|
||||||
|
hidekeys
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
ip tcp synwait-time 5
|
||||||
|
ip ssh version 2
|
||||||
|
ip scp server enable
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
interface Loopback1
|
||||||
|
description Loopback pour R1-CPE-BAT-A
|
||||||
|
ip address 1.1.1.1 255.255.255.255
|
||||||
|
!
|
||||||
|
interface Loopback2
|
||||||
|
description Loopback2 pour R1-CPE-BAT-A
|
||||||
|
ip address 1.1.1.2 255.255.255.255
|
||||||
|
!
|
||||||
|
interface Loopback10
|
||||||
|
description created from config file uploaded from postman
|
||||||
|
ip address 10.10.10.10 255.255.255.255
|
||||||
|
!
|
||||||
|
interface FastEthernet0/0
|
||||||
|
ip address 172.16.100.62 255.255.255.192
|
||||||
|
duplex half
|
||||||
|
!
|
||||||
|
interface Serial1/0
|
||||||
|
no ip address
|
||||||
|
shutdown
|
||||||
|
serial restart-delay 0
|
||||||
|
!
|
||||||
|
interface Serial1/1
|
||||||
|
ip address 10.1.1.1 255.255.255.252
|
||||||
|
shutdown
|
||||||
|
serial restart-delay 0
|
||||||
|
!
|
||||||
|
interface Serial1/2
|
||||||
|
no ip address
|
||||||
|
shutdown
|
||||||
|
serial restart-delay 0
|
||||||
|
!
|
||||||
|
interface Serial1/3
|
||||||
|
no ip address
|
||||||
|
shutdown
|
||||||
|
serial restart-delay 0
|
||||||
|
!
|
||||||
|
interface GigabitEthernet2/0
|
||||||
|
no ip address
|
||||||
|
negotiation auto
|
||||||
|
!
|
||||||
|
interface GigabitEthernet2/0.10
|
||||||
|
description "Gateway for teacher vlan"
|
||||||
|
encapsulation dot1Q 10
|
||||||
|
ip address 172.16.10.253 255.255.255.0
|
||||||
|
vrrp 10 ip 172.16.10.252
|
||||||
|
!
|
||||||
|
interface GigabitEthernet2/0.20
|
||||||
|
description "Gateway for student vlan"
|
||||||
|
encapsulation dot1Q 20
|
||||||
|
ip address 172.16.20.253 255.255.255.0
|
||||||
|
vrrp 20 ip 172.16.20.252
|
||||||
|
!
|
||||||
|
interface GigabitEthernet2/0.99
|
||||||
|
encapsulation dot1Q 99
|
||||||
|
ip address 172.16.100.125 255.255.255.192
|
||||||
|
vrrp 99 ip 172.16.100.124
|
||||||
|
!
|
||||||
|
router ospf 1
|
||||||
|
router-id 1.1.1.1
|
||||||
|
log-adjacency-changes
|
||||||
|
passive-interface FastEthernet0/0
|
||||||
|
passive-interface GigabitEthernet2/0.99
|
||||||
|
network 10.1.1.0 0.0.0.3 area 0
|
||||||
|
network 172.16.10.0 0.0.0.255 area 0
|
||||||
|
network 172.16.20.0 0.0.0.255 area 0
|
||||||
|
network 172.16.100.0 0.0.0.63 area 0
|
||||||
|
network 172.16.100.64 0.0.0.63 area 0
|
||||||
|
!
|
||||||
|
ip forward-protocol nd
|
||||||
|
no ip http server
|
||||||
|
no ip http secure-server
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
no cdp log mismatch duplex
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
control-plane
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
!
|
||||||
|
gatekeeper
|
||||||
|
shutdown
|
||||||
|
!
|
||||||
|
!
|
||||||
|
line con 0
|
||||||
|
exec-timeout 0 0
|
||||||
|
privilege level 15
|
||||||
|
logging synchronous
|
||||||
|
stopbits 1
|
||||||
|
line aux 0
|
||||||
|
exec-timeout 0 0
|
||||||
|
privilege level 15
|
||||||
|
logging synchronous
|
||||||
|
stopbits 1
|
||||||
|
line vty 0 4
|
||||||
|
login local
|
||||||
|
transport input ssh
|
||||||
|
!
|
||||||
|
end
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
interface loopback 10
|
||||||
|
ip add 10.10.10.10 255.255.255.255
|
||||||
|
description created from config file uploaded from postman
|
||||||
28
fastprod_backend/fastprod/utils/inventory.py
Normal file
28
fastprod_backend/fastprod/utils/inventory.py
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
import yaml
|
||||||
|
|
||||||
|
def update_hosts_yaml(file_path="fastprod/inventory/hosts.yaml", items=None):
|
||||||
|
if items:
|
||||||
|
with open(file_path, 'w') as yaml_file:
|
||||||
|
yaml.safe_dump(items, yaml_file)
|
||||||
|
return True
|
||||||
|
|
||||||
|
def add_item_to_hosts_yaml(file_path="fastprod/inventory/hosts.yaml", save=True, item=None):
|
||||||
|
with open(file_path, 'r') as yaml_file:
|
||||||
|
hosts = yaml.safe_load(yaml_file)
|
||||||
|
|
||||||
|
new_hosts = hosts.copy()
|
||||||
|
new_hosts[item.get('data').get('device_name')] = item
|
||||||
|
|
||||||
|
if save:
|
||||||
|
update_hosts_yaml(items=new_hosts)
|
||||||
|
|
||||||
|
return new_hosts[item.get('data').get('device_name')]
|
||||||
|
|
||||||
|
def delete_item_from_hosts_yaml(yaml_file_path="fastprod/inventory/hosts.yaml", save=True,item=None, ):
|
||||||
|
with open(yaml_file_path,'r') as yaml_file:
|
||||||
|
hosts = yaml.safe_load(yaml_file)
|
||||||
|
new_hosts = hosts.copy()
|
||||||
|
del new_hosts[item.get('data').get('device_name')]
|
||||||
|
if save:
|
||||||
|
update_hosts_yaml(items=new_hosts)
|
||||||
|
return True
|
||||||
267
fastprod_backend/nornir.log
Normal file
267
fastprod_backend/nornir.log
Normal file
@@ -0,0 +1,267 @@
|
|||||||
|
2025-11-27 10:29:07,377 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_interfaces']} on 1 hosts
|
||||||
|
2025-11-27 10:30:31,532 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_interfaces']} on 1 hosts
|
||||||
|
2025-11-27 10:32:16,142 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_interfaces']} on 1 hosts
|
||||||
|
2025-11-27 10:33:00,527 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_interfaces']} on 1 hosts
|
||||||
|
2025-11-27 10:42:31,649 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_interfaces_ip']} on 1 hosts
|
||||||
|
2025-11-27 10:43:18,016 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_interfaces_ip']} on 1 hosts
|
||||||
|
2025-11-27 10:44:05,459 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_interfaces_ip']} on 1 hosts
|
||||||
|
2025-11-27 10:44:18,600 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_interfaces_ip']} on 1 hosts
|
||||||
|
2025-11-27 10:47:29,054 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_interfaces_ip']} on 1 hosts
|
||||||
|
2025-11-27 10:47:38,118 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_interfaces_ip']} on 1 hosts
|
||||||
|
2025-11-27 10:49:17,515 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_interfaces_ip']} on 1 hosts
|
||||||
|
2025-11-27 10:50:27,409 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_interfaces_ip']} on 1 hosts
|
||||||
|
2025-11-27 10:55:14,616 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_facts']} on 1 hosts
|
||||||
|
2025-11-27 10:55:35,609 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_facts']} on 1 hosts
|
||||||
|
2025-11-27 11:03:38,869 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_config']} on 1 hosts
|
||||||
|
2025-11-27 11:11:30,181 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_interfaces']} on 1 hosts
|
||||||
|
2025-11-27 11:12:43,941 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_interfaces']} on 1 hosts
|
||||||
|
2025-11-27 11:12:47,660 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_config']} on 1 hosts
|
||||||
|
2025-11-27 11:12:58,676 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_config']} on 1 hosts
|
||||||
|
2025-11-27 11:13:05,327 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_config']} on 1 hosts
|
||||||
|
2025-11-27 11:13:07,216 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_config']} on 1 hosts
|
||||||
|
2025-11-27 11:13:17,120 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_config']} on 1 hosts
|
||||||
|
2025-11-27 11:17:14,064 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_interfaces']} on 1 hosts
|
||||||
|
2025-11-27 11:17:51,306 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_interfaces']} on 1 hosts
|
||||||
|
2025-11-27 11:18:37,859 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_interfaces']} on 1 hosts
|
||||||
|
2025-11-27 11:18:53,937 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_interfaces']} on 1 hosts
|
||||||
|
2025-11-27 11:23:38,281 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_interfaces']} on 1 hosts
|
||||||
|
2025-11-27 11:29:27,867 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_config']} on 1 hosts
|
||||||
|
2025-11-27 11:29:31,935 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_config']} on 1 hosts
|
||||||
|
2025-11-27 11:34:46,926 - nornir.core - INFO - run() - Running task 'napalm_cli' with args {'commands': ['show ip route']} on 1 hosts
|
||||||
|
2025-11-27 11:35:32,732 - nornir.core - INFO - run() - Running task 'napalm_cli' with args {'commands': ['show ip route']} on 1 hosts
|
||||||
|
2025-11-27 11:40:04,424 - nornir.core - INFO - run() - Running task 'napalm_cli' with args {'commands': ['show ip route']} on 1 hosts
|
||||||
|
2025-11-27 11:40:04,522 - nornir.core - INFO - run() - Running task 'napalm_cli' with args {'commands': ['show ip interfaces brief']} on 1 hosts
|
||||||
|
2025-11-27 11:52:28,952 - nornir.core - INFO - run() - Running task 'netmiko_send_config' with args {'config_commands': [['interface loopback 8', 'ip add 8.8.8.8 255.255.255.255', 'description created_from_postman']]} on 1 hosts
|
||||||
|
2025-11-27 11:52:29,772 - nornir.core.task - ERROR - start() - Host 'R1-CPE-BAT-A': task 'netmiko_send_config' failed with traceback:
|
||||||
|
Traceback (most recent call last):
|
||||||
|
File "/home/cpe/.local/share/virtualenvs/fastprod_backend-xSm6n0LL/lib/python3.12/site-packages/nornir/core/task.py", line 98, in start
|
||||||
|
r = self.task(self, **self.params)
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
File "/home/cpe/.local/share/virtualenvs/fastprod_backend-xSm6n0LL/lib/python3.12/site-packages/nornir_netmiko/tasks/netmiko_send_config.py", line 38, in netmiko_send_config
|
||||||
|
result = net_connect.send_config_set(config_commands=config_commands, **kwargs)
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
File "/home/cpe/.local/share/virtualenvs/fastprod_backend-xSm6n0LL/lib/python3.12/site-packages/netmiko/base_connection.py", line 111, in wrapper_decorator
|
||||||
|
return_val = func(self, *args, **kwargs)
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
File "/home/cpe/.local/share/virtualenvs/fastprod_backend-xSm6n0LL/lib/python3.12/site-packages/netmiko/base_connection.py", line 2294, in send_config_set
|
||||||
|
[True for cmd in config_commands_tmp if re.search(bypass_commands, cmd)]
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
File "/usr/lib/python3.12/re/__init__.py", line 177, in search
|
||||||
|
return _compile(pattern, flags).search(string)
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
TypeError: expected string or bytes-like object, got 'list'
|
||||||
|
|
||||||
|
2025-11-27 13:16:50,900 - nornir.core - INFO - run() - Running task 'netmiko_send_config' with args {'config_file': 'fastprod/upload_files/R1-CPE-BAT-A_loopback.conf'} on 1 hosts
|
||||||
|
2025-11-27 13:18:50,146 - nornir.core - INFO - run() - Running task 'netmiko_send_config' with args {'config_file': 'fastprod/upload_files/R1-CPE-BAT-A_loopback.conf'} on 1 hosts
|
||||||
|
2025-11-27 13:37:51,507 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_config']} on 1 hosts
|
||||||
|
2025-11-27 13:38:36,507 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_config']} on 1 hosts
|
||||||
|
2025-11-27 13:39:25,827 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_config']} on 1 hosts
|
||||||
|
2025-11-27 13:41:20,882 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_config']} on 1 hosts
|
||||||
|
2025-11-27 13:47:08,252 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_config']} on 1 hosts
|
||||||
|
2025-11-27 13:47:38,160 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_config']} on 1 hosts
|
||||||
|
2025-11-27 13:47:55,759 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_config']} on 1 hosts
|
||||||
|
2025-11-27 13:48:27,889 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_config']} on 1 hosts
|
||||||
|
2025-11-27 13:48:56,963 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_config']} on 1 hosts
|
||||||
|
2025-11-27 13:51:12,137 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_config']} on 1 hosts
|
||||||
|
2025-11-27 13:52:20,289 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_config']} on 1 hosts
|
||||||
|
2025-11-27 13:52:47,032 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_config']} on 1 hosts
|
||||||
|
2025-11-27 13:53:07,676 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_config']} on 1 hosts
|
||||||
|
2025-11-27 13:53:27,844 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_config']} on 1 hosts
|
||||||
|
2025-11-27 13:55:22,325 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_config']} on 1 hosts
|
||||||
|
2025-11-27 14:27:45,418 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_interfaces']} on 1 hosts
|
||||||
|
2025-11-27 14:27:45,421 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_facts']} on 1 hosts
|
||||||
|
2025-11-27 14:27:45,425 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_interfaces_ip']} on 1 hosts
|
||||||
|
2025-11-27 14:27:58,534 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_facts']} on 1 hosts
|
||||||
|
2025-11-27 14:28:03,171 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_config']} on 1 hosts
|
||||||
|
2025-11-27 14:28:26,673 - nornir.core - INFO - run() - Running task 'napalm_cli' with args {'commands': ['show ip int br']} on 1 hosts
|
||||||
|
2025-11-27 14:29:34,616 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_facts']} on 1 hosts
|
||||||
|
2025-11-27 14:31:40,826 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_facts']} on 1 hosts
|
||||||
|
2025-11-27 14:31:47,954 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_facts']} on 1 hosts
|
||||||
|
2025-11-27 14:34:06,500 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_facts']} on 1 hosts
|
||||||
|
2025-11-27 14:34:06,510 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_interfaces']} on 1 hosts
|
||||||
|
2025-11-27 14:34:06,526 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_interfaces_ip']} on 1 hosts
|
||||||
|
2025-11-27 14:34:09,203 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_config']} on 1 hosts
|
||||||
|
2025-11-27 14:34:19,454 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_interfaces_ip']} on 1 hosts
|
||||||
|
2025-11-27 14:34:20,018 - nornir.core.task - ERROR - start() - Host 'ESW1-CPE-BAT-A': task 'napalm_get' failed with traceback:
|
||||||
|
Traceback (most recent call last):
|
||||||
|
File "/home/cpe/.local/share/virtualenvs/fastprod_backend-xSm6n0LL/lib/python3.12/site-packages/nornir/core/task.py", line 98, in start
|
||||||
|
r = self.task(self, **self.params)
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
File "/home/cpe/.local/share/virtualenvs/fastprod_backend-xSm6n0LL/lib/python3.12/site-packages/nornir_napalm/plugins/tasks/napalm_get.py", line 44, in napalm_get
|
||||||
|
result[g] = method(**options)
|
||||||
|
^^^^^^^^^^^^^^^^^
|
||||||
|
File "/home/cpe/.local/share/virtualenvs/fastprod_backend-xSm6n0LL/lib/python3.12/site-packages/napalm/ios/ios.py", line 1215, in get_interfaces
|
||||||
|
output = self._send_command(command)
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
File "/home/cpe/.local/share/virtualenvs/fastprod_backend-xSm6n0LL/lib/python3.12/site-packages/napalm/ios/ios.py", line 208, in _send_command
|
||||||
|
output = self.device.send_command(command)
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
File "/home/cpe/.local/share/virtualenvs/fastprod_backend-xSm6n0LL/lib/python3.12/site-packages/netmiko/base_connection.py", line 111, in wrapper_decorator
|
||||||
|
return_val = func(self, *args, **kwargs)
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
File "/home/cpe/.local/share/virtualenvs/fastprod_backend-xSm6n0LL/lib/python3.12/site-packages/netmiko/utilities.py", line 667, in wrapper_decorator
|
||||||
|
return func(self, *args, **kwargs)
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
File "/home/cpe/.local/share/virtualenvs/fastprod_backend-xSm6n0LL/lib/python3.12/site-packages/netmiko/base_connection.py", line 1791, in send_command
|
||||||
|
new_data = self.command_echo_read(cmd=cmd, read_timeout=10)
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
File "/home/cpe/.local/share/virtualenvs/fastprod_backend-xSm6n0LL/lib/python3.12/site-packages/netmiko/base_connection.py", line 1494, in command_echo_read
|
||||||
|
new_data = self.read_until_pattern(
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
File "/home/cpe/.local/share/virtualenvs/fastprod_backend-xSm6n0LL/lib/python3.12/site-packages/netmiko/base_connection.py", line 755, in read_until_pattern
|
||||||
|
raise ReadTimeout(msg)
|
||||||
|
netmiko.exceptions.ReadTimeout:
|
||||||
|
|
||||||
|
Pattern not detected: 'show\\ interfaces' in output.
|
||||||
|
|
||||||
|
Things you might try to fix this:
|
||||||
|
1. Adjust the regex pattern to better identify the terminating string. Note, in
|
||||||
|
many situations the pattern is automatically based on the network device's prompt.
|
||||||
|
2. Increase the read_timeout to a larger value.
|
||||||
|
|
||||||
|
You can also look at the Netmiko session_log or debug log for more information.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
2025-11-27 14:34:20,648 - nornir.core.task - ERROR - start() - Host 'ESW1-CPE-BAT-A': task 'napalm_get' failed with traceback:
|
||||||
|
Traceback (most recent call last):
|
||||||
|
File "/home/cpe/.local/share/virtualenvs/fastprod_backend-xSm6n0LL/lib/python3.12/site-packages/nornir/core/task.py", line 98, in start
|
||||||
|
r = self.task(self, **self.params)
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
File "/home/cpe/.local/share/virtualenvs/fastprod_backend-xSm6n0LL/lib/python3.12/site-packages/nornir_napalm/plugins/tasks/napalm_get.py", line 44, in napalm_get
|
||||||
|
result[g] = method(**options)
|
||||||
|
^^^^^^^^^^^^^^^^^
|
||||||
|
File "/home/cpe/.local/share/virtualenvs/fastprod_backend-xSm6n0LL/lib/python3.12/site-packages/napalm/ios/ios.py", line 3676, in get_config
|
||||||
|
output = self._send_command(command)
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
File "/home/cpe/.local/share/virtualenvs/fastprod_backend-xSm6n0LL/lib/python3.12/site-packages/napalm/ios/ios.py", line 208, in _send_command
|
||||||
|
output = self.device.send_command(command)
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
File "/home/cpe/.local/share/virtualenvs/fastprod_backend-xSm6n0LL/lib/python3.12/site-packages/netmiko/base_connection.py", line 111, in wrapper_decorator
|
||||||
|
return_val = func(self, *args, **kwargs)
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
File "/home/cpe/.local/share/virtualenvs/fastprod_backend-xSm6n0LL/lib/python3.12/site-packages/netmiko/utilities.py", line 667, in wrapper_decorator
|
||||||
|
return func(self, *args, **kwargs)
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
File "/home/cpe/.local/share/virtualenvs/fastprod_backend-xSm6n0LL/lib/python3.12/site-packages/netmiko/base_connection.py", line 1791, in send_command
|
||||||
|
new_data = self.command_echo_read(cmd=cmd, read_timeout=10)
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
File "/home/cpe/.local/share/virtualenvs/fastprod_backend-xSm6n0LL/lib/python3.12/site-packages/netmiko/base_connection.py", line 1494, in command_echo_read
|
||||||
|
new_data = self.read_until_pattern(
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
File "/home/cpe/.local/share/virtualenvs/fastprod_backend-xSm6n0LL/lib/python3.12/site-packages/netmiko/base_connection.py", line 755, in read_until_pattern
|
||||||
|
raise ReadTimeout(msg)
|
||||||
|
netmiko.exceptions.ReadTimeout:
|
||||||
|
|
||||||
|
Pattern not detected: 'show\\ running\\-config' in output.
|
||||||
|
|
||||||
|
Things you might try to fix this:
|
||||||
|
1. Adjust the regex pattern to better identify the terminating string. Note, in
|
||||||
|
many situations the pattern is automatically based on the network device's prompt.
|
||||||
|
2. Increase the read_timeout to a larger value.
|
||||||
|
|
||||||
|
You can also look at the Netmiko session_log or debug log for more information.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
2025-11-27 14:34:26,321 - nornir.core - WARNING - run() - Task 'napalm_get' has not been run – 0 hosts selected
|
||||||
|
2025-11-27 14:34:29,743 - nornir.core - WARNING - run() - Task 'napalm_get' has not been run – 0 hosts selected
|
||||||
|
2025-11-27 14:35:36,177 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_facts']} on 1 hosts
|
||||||
|
2025-11-27 14:35:36,181 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_interfaces_ip']} on 1 hosts
|
||||||
|
2025-11-27 14:35:36,182 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_interfaces']} on 1 hosts
|
||||||
|
2025-11-27 14:35:58,683 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_config']} on 1 hosts
|
||||||
|
2025-11-27 14:40:22,059 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_facts']} on 1 hosts
|
||||||
|
2025-11-27 14:40:22,065 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_interfaces_ip']} on 1 hosts
|
||||||
|
2025-11-27 14:40:22,069 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_interfaces']} on 1 hosts
|
||||||
|
2025-11-27 14:40:30,793 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_interfaces']} on 1 hosts
|
||||||
|
2025-11-27 14:40:30,804 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_facts']} on 1 hosts
|
||||||
|
2025-11-27 14:40:30,817 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_interfaces_ip']} on 1 hosts
|
||||||
|
2025-11-27 14:40:36,971 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_config']} on 1 hosts
|
||||||
|
2025-11-27 14:40:43,753 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_interfaces_ip']} on 1 hosts
|
||||||
|
2025-11-27 14:40:43,762 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_facts']} on 1 hosts
|
||||||
|
2025-11-27 14:40:43,767 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_interfaces']} on 1 hosts
|
||||||
|
2025-11-27 14:43:35,049 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_interfaces']} on 1 hosts
|
||||||
|
2025-11-27 14:43:35,051 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_interfaces_ip']} on 1 hosts
|
||||||
|
2025-11-27 14:43:35,053 - nornir.core - INFO - run() - Running task 'napalm_get' with args {'getters': ['get_facts']} on 1 hosts
|
||||||
|
2025-11-27 14:43:45,140 - nornir.core.task - ERROR - start() - Host 'R1-CPE-BAT-A': task 'napalm_get' failed with traceback:
|
||||||
|
Traceback (most recent call last):
|
||||||
|
File "/home/cpe/.local/share/virtualenvs/fastprod_backend-xSm6n0LL/lib/python3.12/site-packages/nornir/core/task.py", line 98, in start
|
||||||
|
r = self.task(self, **self.params)
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
File "/home/cpe/.local/share/virtualenvs/fastprod_backend-xSm6n0LL/lib/python3.12/site-packages/nornir_napalm/plugins/tasks/napalm_get.py", line 44, in napalm_get
|
||||||
|
result[g] = method(**options)
|
||||||
|
^^^^^^^^^^^^^^^^^
|
||||||
|
File "/home/cpe/.local/share/virtualenvs/fastprod_backend-xSm6n0LL/lib/python3.12/site-packages/napalm/ios/ios.py", line 1215, in get_interfaces
|
||||||
|
output = self._send_command(command)
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
File "/home/cpe/.local/share/virtualenvs/fastprod_backend-xSm6n0LL/lib/python3.12/site-packages/napalm/ios/ios.py", line 208, in _send_command
|
||||||
|
output = self.device.send_command(command)
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
File "/home/cpe/.local/share/virtualenvs/fastprod_backend-xSm6n0LL/lib/python3.12/site-packages/netmiko/base_connection.py", line 111, in wrapper_decorator
|
||||||
|
return_val = func(self, *args, **kwargs)
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
File "/home/cpe/.local/share/virtualenvs/fastprod_backend-xSm6n0LL/lib/python3.12/site-packages/netmiko/utilities.py", line 667, in wrapper_decorator
|
||||||
|
return func(self, *args, **kwargs)
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
File "/home/cpe/.local/share/virtualenvs/fastprod_backend-xSm6n0LL/lib/python3.12/site-packages/netmiko/base_connection.py", line 1791, in send_command
|
||||||
|
new_data = self.command_echo_read(cmd=cmd, read_timeout=10)
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
File "/home/cpe/.local/share/virtualenvs/fastprod_backend-xSm6n0LL/lib/python3.12/site-packages/netmiko/base_connection.py", line 1494, in command_echo_read
|
||||||
|
new_data = self.read_until_pattern(
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
File "/home/cpe/.local/share/virtualenvs/fastprod_backend-xSm6n0LL/lib/python3.12/site-packages/netmiko/base_connection.py", line 755, in read_until_pattern
|
||||||
|
raise ReadTimeout(msg)
|
||||||
|
netmiko.exceptions.ReadTimeout:
|
||||||
|
|
||||||
|
Pattern not detected: 'show\\ interfaces' in output.
|
||||||
|
|
||||||
|
Things you might try to fix this:
|
||||||
|
1. Adjust the regex pattern to better identify the terminating string. Note, in
|
||||||
|
many situations the pattern is automatically based on the network device's prompt.
|
||||||
|
2. Increase the read_timeout to a larger value.
|
||||||
|
|
||||||
|
You can also look at the Netmiko session_log or debug log for more information.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
2025-11-27 14:43:45,145 - nornir.core.task - ERROR - start() - Host 'R1-CPE-BAT-A': task 'napalm_get' failed with traceback:
|
||||||
|
Traceback (most recent call last):
|
||||||
|
File "/home/cpe/.local/share/virtualenvs/fastprod_backend-xSm6n0LL/lib/python3.12/site-packages/nornir/core/task.py", line 98, in start
|
||||||
|
r = self.task(self, **self.params)
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
File "/home/cpe/.local/share/virtualenvs/fastprod_backend-xSm6n0LL/lib/python3.12/site-packages/nornir_napalm/plugins/tasks/napalm_get.py", line 44, in napalm_get
|
||||||
|
result[g] = method(**options)
|
||||||
|
^^^^^^^^^^^^^^^^^
|
||||||
|
File "/home/cpe/.local/share/virtualenvs/fastprod_backend-xSm6n0LL/lib/python3.12/site-packages/napalm/ios/ios.py", line 1316, in get_interfaces_ip
|
||||||
|
show_ip_interface = self._send_command(command)
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
File "/home/cpe/.local/share/virtualenvs/fastprod_backend-xSm6n0LL/lib/python3.12/site-packages/napalm/ios/ios.py", line 208, in _send_command
|
||||||
|
output = self.device.send_command(command)
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
File "/home/cpe/.local/share/virtualenvs/fastprod_backend-xSm6n0LL/lib/python3.12/site-packages/netmiko/base_connection.py", line 111, in wrapper_decorator
|
||||||
|
return_val = func(self, *args, **kwargs)
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
File "/home/cpe/.local/share/virtualenvs/fastprod_backend-xSm6n0LL/lib/python3.12/site-packages/netmiko/utilities.py", line 667, in wrapper_decorator
|
||||||
|
return func(self, *args, **kwargs)
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
File "/home/cpe/.local/share/virtualenvs/fastprod_backend-xSm6n0LL/lib/python3.12/site-packages/netmiko/base_connection.py", line 1791, in send_command
|
||||||
|
new_data = self.command_echo_read(cmd=cmd, read_timeout=10)
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
File "/home/cpe/.local/share/virtualenvs/fastprod_backend-xSm6n0LL/lib/python3.12/site-packages/netmiko/base_connection.py", line 1494, in command_echo_read
|
||||||
|
new_data = self.read_until_pattern(
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
File "/home/cpe/.local/share/virtualenvs/fastprod_backend-xSm6n0LL/lib/python3.12/site-packages/netmiko/base_connection.py", line 755, in read_until_pattern
|
||||||
|
raise ReadTimeout(msg)
|
||||||
|
netmiko.exceptions.ReadTimeout:
|
||||||
|
|
||||||
|
Pattern not detected: 'show\\ ip\\ interface' in output.
|
||||||
|
|
||||||
|
Things you might try to fix this:
|
||||||
|
1. Adjust the regex pattern to better identify the terminating string. Note, in
|
||||||
|
many situations the pattern is automatically based on the network device's prompt.
|
||||||
|
2. Increase the read_timeout to a larger value.
|
||||||
|
|
||||||
|
You can also look at the Netmiko session_log or debug log for more information.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
3
fastprod_backend/start.sh
Executable file
3
fastprod_backend/start.sh
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
export FLASK_APP=fastprod/api.py
|
||||||
|
pipenv run flask run --host=0.0.0.0 --port=5000
|
||||||
Reference in New Issue
Block a user