Skip to content

Commit 114eca9

Browse files
committed
updates
1 parent f895a43 commit 114eca9

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

labs/coding-102-rest-python-ga/5.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,12 +62,13 @@ def getTopology(ticket):
6262
#convert data to json format.
6363
r_json=response.json()
6464

65+
#Iterate through network device data and list the nodes, their interfaces, status and to what they connect
6566
#Iterate through network device data and list the nodes, their interfaces, status and to what they connect
6667
for n in r_json["response"]["nodes"]:
6768
if "platformId" in n:
6869
print()
6970
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")
7172
print('{:30}'.format(n["platformId"]) + '{:25}'.format(n["family"]) + '{:20}'.format(n["label"]) + n["ip"])
7273
found=0 #print header flag
7374
printed=0 #formatting flag
@@ -76,13 +77,13 @@ def getTopology(ticket):
7677
#check that the source device id for the interface matches the node id. Means interface originated from this device.
7778
if i["source"] == n["id"]:
7879
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") )
8081
found=1
8182
printed=1
8283
for n1 in r_json["response"]["nodes"]:
8384
#find name of node to which this one connects
8485
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"]) )
8687
break;
8788
found=0
8889
for i in r_json["response"]["links"]:
@@ -92,13 +93,12 @@ def getTopology(ticket):
9293
if found==0:
9394
if printed==1:
9495
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"))
9697
found=1
9798
for n1 in r_json["response"]["nodes"]:
9899
#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"]))
102102
break;
103103

104104
theTicket=getTicket()
Loading

0 commit comments

Comments
 (0)