You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
*This example uses TextFSM to parse the output of the `show interface eth0/0` command. The rule then checks the parsed output to verify that the interface is up. If the interface is down, the rule will fail, reporting the issue.*
142
143
143
144
## Using Tags for Device Grouping
145
+
You can create tags such as `datacenter`, `campus`, or `branch`, and then apply specific rules to all devices in these groups.
144
146
145
147
### Example: Printing All Devices with a Specific Tag
146
148
147
149
In this example, the `device_tags` parameter is set to `campus`, meaning the rule is intended to apply only to devices tagged as part of the `campus` group.
148
-
You can create tags such as `datacenter`, `campus`, or `branch`, and then apply specific rules to all devices in these groups.
print(f"Device: {dev.name} and IP address: {dev.ipaddress}")
161
162
```
162
163
*This example demonstrates how to print the name and IP address of all devices tagged with `campus`.*
164
+
165
+
## Accessing NetBox Data in Netpicker Rules
166
+
167
+
Netpicker allows you to integrate with NetBox, a popular open-source IP address management (IPAM) and data center infrastructure management (DCIM) tool. By accessing NetBox data within your Netpicker rules, you can enhance your network automation tasks by incorporating detailed device information directly from your source of truth.
168
+
169
+
### Example: Accessing and Printing Device Names from NetBox
170
+
```python
171
+
@medium(
172
+
name='rule_netbox',
173
+
)
174
+
defrule_netbox(netbox):
175
+
# Fetch all devices from NetBox
176
+
devices = netbox.dcim.devices.all()
177
+
178
+
# Extract the names of the devices
179
+
device_names = [device.name for device in devices]
180
+
181
+
# Print the names of all devices fetched from NetBox
182
+
for name in device_names:
183
+
print(name)
184
+
```
185
+
*The above example demonstrates how to access NetBox data within a Netpicker rule. This rule fetches all devices from NetBox and prints their names.*
0 commit comments