@@ -62,12 +62,13 @@ def getTopology(ticket):
62
62
# convert data to json format.
63
63
r_json= response.json()
64
64
65
+ # Iterate through network device data and list the nodes, their interfaces, status and to what they connect
65
66
# Iterate through network device data and list the nodes, their interfaces, status and to what they connect
66
67
for n in r_json[" response" ][" nodes" ]:
67
68
if " platformId" in n:
68
69
print ()
69
70
print ()
70
- print (' {:30 } ' .format(" Node" ) + ' {:25 } ' .format(" Family" ) + ' {:20 } ' .format(" label " )+ " Management IP" )
71
+ print (' {:30 } ' .format(" Node" ) + ' {:25 } ' .format(" Family" ) + ' {:20 } ' .format(" Label " )+ " Management IP" )
71
72
print (' {:30 } ' .format(n[" platformId" ]) + ' {:25 } ' .format(n[" family" ]) + ' {:20 } ' .format(n[" label" ]) + n[" ip" ])
72
73
found= 0 # print header flag
73
74
printed= 0 # formatting flag
@@ -76,13 +77,13 @@ def getTopology(ticket):
76
77
# check that the source device id for the interface matches the node id. Means interface originated from this device.
77
78
if i[" source" ] == n[" id" ]:
78
79
if found== 0 :
79
- print (' {:>20 } ' .format(" Source Interface" ) + ' {:>15 } ' .format(" Status " ) + ' {:>22 } ' .format(" Target Interface" ) + ' {:>18 } ' .format(" Target " ) )
80
+ print (' {:>20 } ' .format(" Source Interface" ) + ' {:>15 } ' .format(" Target " ) + ' {:>28 } ' .format(" Target Interface" ) + ' {:>15 } ' .format(" Status " ) )
80
81
found= 1
81
82
printed= 1
82
83
for n1 in r_json[" response" ][" nodes" ]:
83
84
# find name of node to which this one connects
84
85
if i[" target" ] == n1[" id" ]:
85
- print (" " + ' {:<25 } ' .format(i[" startPortName" ]) + ' {:<12 } ' .format(i[ " linkStatus " ]) + ' {:<28 } ' .format(i[" endPortName" ]) + ' {:<15 } ' .format(n1[ " platformId " ]))
86
+ print (" " + ' {:<25 } ' .format(i[" startPortName" ]) + ' {:<18 } ' .format(n1[ " platformId " ]) + ' {:<25 } ' .format(i[" endPortName" ]) + ' {:<9 } ' .format(i[ " linkStatus " ]) )
86
87
break ;
87
88
found= 0
88
89
for i in r_json[" response" ][" links" ]:
@@ -92,13 +93,12 @@ def getTopology(ticket):
92
93
if found== 0 :
93
94
if printed== 1 :
94
95
print ()
95
- print (' {:>20 } ' .format(" Source Interface " ) + ' {:>15 } ' .format(" Status " ) + ' {:>22 } ' .format(" Target Interface" ) + ' {:>18 } ' .format(" Source " ))
96
+ print (' {:>10 } ' .format(" Source" ) + ' {:>30 } ' .format(" Source Interface " ) + ' {:>25 } ' .format(" Target Interface" ) + ' {:>13 } ' .format(" Status " ))
96
97
found= 1
97
98
for n1 in r_json[" response" ][" nodes" ]:
98
99
# find name of node to that connects to this one
99
- if i[" source" ] == n1[" id" ]:
100
- # print('{:<30}'.format(i["endPortName"]) + '{:>10}'.format(i["linkStatus"]) + '{:>26}'.format(n1["platformId"]))
101
- print (" " + ' {:<25 } ' .format(i[" startPortName" ]) + ' {:<12 } ' .format(i[" linkStatus" ]) + ' {:<28 } ' .format(i[" endPortName" ]) + ' {:<15 } ' .format(n1[" platformId" ]))
100
+ if i[" source" ] == n1[" id" ]:
101
+ print (" " + ' {:<20 } ' .format(n1[" platformId" ]) + ' {:<25 } ' .format(i[" startPortName" ]) + ' {:<23 } ' .format(i[" endPortName" ]) + ' {:<8 } ' .format(i[" linkStatus" ]))
102
102
break ;
103
103
104
104
theTicket= getTicket()
0 commit comments