Lab 4 of 5
Β·
Semi-Guided
Write report.py and Print the Inventory Report
Objective: Write report.py with write_report(), call it from main.py, and read the output file back to screen.
Instructions
Inside capstone/, write report.py. The write_report(devices, filename) function must write a report with this exact structure:
Network Inventory Report
Generated: 2025-04-15 09:30:00
============================================================
<one get_summary() line per device>
============================================================
Total: X devices
Use this fixed string for the datestamp β do not use datetime.now() so your output matches exactly:
generated = "2025-04-15 09:30:00"
Then update main.py to call write_report(devices, "inventory_report.txt") after the loop, then open inventory_report.txt and print every line.
Your output (the report printed to screen β not the logging lines) must match exactly:
Network Inventory Report
Generated: 2025-04-15 09:30:00
============================================================
sw-core-01 switch 10.1.1.1 Site: HQ VLAN: 10
sw-access-01 switch 10.1.1.2 Site: HQ VLAN: 20
rtr-edge-01 router 10.1.1.254 Site: HQ VLAN: 1
fw-dmz-01 firewall 10.1.2.1 Site: DMZ VLAN: 100
============================================================
Total: 4 devices
Paste only the report output (not the logging lines) below and submit.
π‘ Show Hint
get_summary() needs column alignment β use f-string padding like {self.name:<20} {self.device_type:<10} {self.ip:<16} Site: {self.site:<10} VLAN: {self.vlan}. In report.py open the file with "w" and write each line with f.write(...). In main.py, after calling write_report(), open the file again and print each line with strip().
Paste Your Output