Question 5
This commit is contained in:
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
|
||||||
18
TP_03/config/R1_CPE_LYON_BAT_B.conf
Normal file
18
TP_03/config/R1_CPE_LYON_BAT_B.conf
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
interface g3/0
|
||||||
|
encapsulation dot1Q
|
||||||
|
description "**NO DESCRIPTION**"
|
||||||
|
ip address
|
||||||
|
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
|
||||||
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
|
||||||
18
TP_03/config/R2_CPE_LYON_BAT_B.conf
Normal file
18
TP_03/config/R2_CPE_LYON_BAT_B.conf
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
|
||||||
|
interface g3/0
|
||||||
|
encapsulation dot1Q
|
||||||
|
description "**NO DESCRIPTION**"
|
||||||
|
ip address
|
||||||
|
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
|
||||||
@@ -5,41 +5,66 @@ 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():
|
||||||
esw3_data = load_json_data_from_file(file_path='data/vlan_ESW3.json')
|
ESW1_CPE_LYON_BAT_A_data= load_json_data_from_file(file_path='data/ESW1_CPE_LYON_BAT_A.json')
|
||||||
esw3_config = render_network_config(template_name='vlan_switch.j2', data=esw3_data)
|
ESW1_CPE_LYON_BAT_A_config = render_network_config(template_name='vlan_switch.j2', data=ESW1_CPE_LYON_BAT_A_data)
|
||||||
|
|
||||||
R3_data = load_json_data_from_file(file_path='data/vlan_R03.json')
|
R2_LYON_BAT_A_data = load_json_data_from_file(file_path='data/R2_CPE_LYON_BAT_A.json')
|
||||||
R3_config = render_network_config(template_name='vlan_router.j2', data=R3_data)
|
R2_LYON_BAT_A_config = render_network_config(template_name='vlan_router.j2', data=R2_LYON_BAT_A_data)
|
||||||
return R3_config,esw3_config
|
|
||||||
|
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)
|
||||||
|
|
||||||
|
return {
|
||||||
|
'esw1': ESW1_CPE_LYON_BAT_A_config,
|
||||||
|
'r1': R1_LYON_BAT_A_config,
|
||||||
|
'r2': R2_LYON_BAT_A_config
|
||||||
|
}
|
||||||
|
|
||||||
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)
|
||||||
|
|
||||||
|
return {
|
||||||
|
'esw1': ESW1_CPE_LYON_BAT_B_config,
|
||||||
|
'r1': R1_LYON_BAT_B_config,
|
||||||
|
'r2': R2_LYON_BAT_B_config
|
||||||
|
}
|
||||||
|
|
||||||
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'))
|
||||||
|
|
||||||
#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'))
|
||||||
|
|
||||||
Reference in New Issue
Block a user