-
Notifications
You must be signed in to change notification settings - Fork 13
/
test_temp.py
100 lines (84 loc) · 4.94 KB
/
test_temp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
from drawio_network_plot.drawio_network_plot import NetPlot
device_list = [
# Routers
{'nodeName' : 'Router_1','nodeType' : 'router','nodeDescription' : 'External Peering Provider 1'},
{'nodeName' : 'Router_2','nodeType' : 'router','nodeDescription' : 'External Peering Provider 2'},
# Core
{'nodeName' : 'Core_switch_1','nodeType' : 'l3_switch','nodeDescription' : 'Spine Switch 01'},
{'nodeName' : 'Core_switch_2','nodeType' : 'l3_switch','nodeDescription' : 'Spine Switch 02'},
# Firewalls
{'nodeName' : 'FW_1','nodeType' : 'firewall','nodeDescription' : 'Firewall 01'},
{'nodeName' : 'FW_2','nodeType' : 'firewall','nodeDescription' : 'Firewall 02'},
# Leafs
{'nodeName' : 'TOR_1','nodeType' : 'l2_switch','nodeDescription' : 'Leaf Switch 01'},
{'nodeName' : 'TOR_2','nodeType' : 'l2_switch','nodeDescription' : 'Leaf Switch 02'},
{'nodeName' : 'TOR_3','nodeType' : 'l2_switch','nodeDescription' : 'Leaf Switch 03'},
{'nodeName' : 'TOR_4','nodeType' : 'l2_switch','nodeDescription' : 'Leaf Switch 04'},
# Servers
{'nodeName' : 'Server_1','nodeType' : 'server','nodeDescription' : 'Server 1'},
{'nodeName' : 'Server_2','nodeType' : 'server','nodeDescription' : 'Server 2'},
{'nodeName' : 'Server_3','nodeType' : 'server','nodeDescription' : 'Server 3'},
{'nodeName' : 'Server_4','nodeType' : 'server','nodeDescription' : 'Server 4'},
{'nodeName' : 'Server_5','nodeType' : 'server','nodeDescription' : 'Server 5'},
{'nodeName' : 'Server_6','nodeType' : 'server','nodeDescription' : 'Server 6'},
{'nodeName' : 'Server_7','nodeType' : 'server','nodeDescription' : 'Server 7'},
{'nodeName' : 'Server_8','nodeType' : 'server','nodeDescription' : 'Server 8'},
{'nodeName' : 'Server_9','nodeType' : 'server','nodeDescription' : 'Server 9'},
{'nodeName' : 'Server_10','nodeType' : 'server','nodeDescription' : 'Server 10'},
{'nodeName' : 'Server_11','nodeType' : 'server','nodeDescription' : 'Server 11'},
{'nodeName' : 'Server_12','nodeType' : 'server','nodeDescription' : 'Server 12'},
{'nodeName' : 'Server_13','nodeType' : 'server','nodeDescription' : 'Server 13'},
{'nodeName' : 'Server_14','nodeType' : 'server','nodeDescription' : 'Server 14'},
{'nodeName' : 'Server_15','nodeType' : 'server','nodeDescription' : 'Server 15'},
{'nodeName' : 'Server_16','nodeType' : 'server','nodeDescription' : 'Server 16'},
]
connection_list = [
# Router to Core
{'sourceNodeID' : 'Router_1','destinationNodeID' : 'Core_switch_1'},
{'sourceNodeID' : 'Router_1','destinationNodeID' : 'Core_switch_2'},
{'sourceNodeID' : 'Router_2','destinationNodeID' : 'Core_switch_1'},
{'sourceNodeID' : 'Router_2','destinationNodeID' : 'Core_switch_2'},
# Core to FW
{'sourceNodeID' : 'Core_switch_1','destinationNodeID' : 'FW_1'},
{'sourceNodeID' : 'Core_switch_2','destinationNodeID' : 'FW_2'},
# Core to TOR
{'sourceNodeID' : 'Core_switch_1','destinationNodeID' : 'TOR_1'},
{'sourceNodeID' : 'Core_switch_1','destinationNodeID' : 'TOR_2'},
{'sourceNodeID' : 'Core_switch_1','destinationNodeID' : 'TOR_3'},
{'sourceNodeID' : 'Core_switch_1','destinationNodeID' : 'TOR_4'},
{'sourceNodeID' : 'Core_switch_2','destinationNodeID' : 'TOR_1'},
{'sourceNodeID' : 'Core_switch_2','destinationNodeID' : 'TOR_2'},
{'sourceNodeID' : 'Core_switch_2','destinationNodeID' : 'TOR_3'},
{'sourceNodeID' : 'Core_switch_2','destinationNodeID' : 'TOR_4'},
# TOR to Server
{'sourceNodeID' : 'TOR_1','destinationNodeID' : 'Server_1'},
{'sourceNodeID' : 'TOR_2','destinationNodeID' : 'Server_2'},
{'sourceNodeID' : 'TOR_3','destinationNodeID' : 'Server_3'},
{'sourceNodeID' : 'TOR_4','destinationNodeID' : 'Server_4'},
{'sourceNodeID' : 'TOR_1','destinationNodeID' : 'Server_5'},
{'sourceNodeID' : 'TOR_2','destinationNodeID' : 'Server_6'},
{'sourceNodeID' : 'TOR_3','destinationNodeID' : 'Server_7'},
{'sourceNodeID' : 'TOR_4','destinationNodeID' : 'Server_8'},
{'sourceNodeID' : 'TOR_1','destinationNodeID' : 'Server_9'},
{'sourceNodeID' : 'TOR_2','destinationNodeID' : 'Server_10'},
{'sourceNodeID' : 'TOR_3','destinationNodeID' : 'Server_11'},
{'sourceNodeID' : 'TOR_4','destinationNodeID' : 'Server_12'},
{'sourceNodeID' : 'TOR_1','destinationNodeID' : 'Server_13'},
{'sourceNodeID' : 'TOR_2','destinationNodeID' : 'Server_14'},
{'sourceNodeID' : 'TOR_3','destinationNodeID' : 'Server_15'},
{'sourceNodeID' : 'TOR_4','destinationNodeID' : 'Server_16'},
]
x = NetPlot()
x.addNode(nodeName='Router_17',nodeType='router')
x.addNode(nodeName='Router_18',nodeType='router')
x.addLink('Router_17','Router_18')
x.addLink('Router_17','Router_1')
x.addNodeList(device_list)
x.addLinkList(connection_list)
# print(x.display_xml())
# print(x)
x.exportXML('examples/output.xml')
# for mxCell in x.root:
# print(item.get('value'))
# print(item.get('id'))
# print(mxCell.attrib)