1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00

Extend example custom script to generate output

This commit is contained in:
Jeremy Stretch
2019-08-09 16:52:00 -04:00
parent 950a09895b
commit 463c636301

View File

@ -165,4 +165,18 @@ class NewBranchScript(Script):
)
switch.save()
self.log_success("Created new switch: {}".format(switch))
# Generate a CSV table of new devices
output = [
'name,make,model'
]
for switch in Device.objects.filter(site=site):
attrs = [
switch.name,
switch.device_type.manufacturer.name,
switch.device_type.model
]
output.append(','.join(attrs))
return '\n'.join(output)
```