mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-24 17:38:37 -06:00
Extend example custom script to generate output
This commit is contained in:
parent
950a09895b
commit
463c636301
@ -165,4 +165,18 @@ class NewBranchScript(Script):
|
|||||||
)
|
)
|
||||||
switch.save()
|
switch.save()
|
||||||
self.log_success("Created new switch: {}".format(switch))
|
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)
|
||||||
```
|
```
|
||||||
|
Loading…
Reference in New Issue
Block a user