Skip to content

Tests and juniper #118

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 45 commits into from
Aug 26, 2024
Merged
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
71691c6
adding wireless tests
mailsanjayhere Aug 2, 2024
ced476c
renamed vendor names
mailsanjayhere Aug 2, 2024
a32f586
testing juniper file
mailsanjayhere Aug 2, 2024
b45c401
testing with rule_11.py
mailsanjayhere Aug 2, 2024
592c5de
updated the first rule
mailsanjayhere Aug 2, 2024
addcd0a
adding EXAMPLES.md
mailsanjayhere Aug 19, 2024
01883e8
updated the URL for EXAMPLES.md
mailsanjayhere Aug 19, 2024
e4473f7
Merge branch 'main' into tests_and_juniper
netpicker Aug 19, 2024
b4d1115
TOC for EXAMPLES.md
mailsanjayhere Aug 19, 2024
1bb817e
Tests and juniper (#96) (#97)
netpicker Aug 19, 2024
634ffa1
Merge branch 'tests_and_juniper' of https://github.com/netpicker/pyte…
mailsanjayhere Aug 19, 2024
cb25c11
updating TOC
mailsanjayhere Aug 19, 2024
8f545d5
Merge branch 'main' into tests_and_juniper
netpicker Aug 19, 2024
1575a16
updated for EXAMPLES.md
mailsanjayhere Aug 19, 2024
d8e6bfb
one more update
mailsanjayhere Aug 19, 2024
e0225d7
Merge branch 'main' into tests_and_juniper
netpicker Aug 19, 2024
d046490
removed example inside EXAMPLE.md
mailsanjayhere Aug 20, 2024
cc1fe9d
Squashed commit of the following:
netpicker Aug 20, 2024
eaa20b5
Merge branch 'main' into tests_and_juniper
netpicker Aug 20, 2024
33a850c
changed entire file contents
mailsanjayhere Aug 20, 2024
6a2e73a
Merge branch 'tests_and_juniper' of https://github.com/netpicker/pyte…
mailsanjayhere Aug 20, 2024
5830aeb
Merge branch 'main' into tests_and_juniper
netpicker Aug 20, 2024
e14a500
fixed typo for devices
mailsanjayhere Aug 20, 2024
a6aeaab
Merge branch 'tests_and_juniper' of https://github.com/netpicker/pyte…
mailsanjayhere Aug 20, 2024
a6b5929
Merge branch 'main' into tests_and_juniper
netpicker Aug 20, 2024
6aef930
update EXAMPLES.md README.md
mailsanjayhere Aug 20, 2024
5ff7b35
Merge branch 'tests_and_juniper' of https://github.com/netpicker/pyte…
mailsanjayhere Aug 20, 2024
949ccf0
removed few items from TOC
mailsanjayhere Aug 20, 2024
eb15933
replaced : with = in commands check
mailsanjayhere Aug 20, 2024
9bed9ed
added 2nd example for multiple lines check
mailsanjayhere Aug 21, 2024
973b666
Merge branch 'main' into tests_and_juniper
netpicker Aug 21, 2024
0b45225
updated example 2
mailsanjayhere Aug 21, 2024
691eac5
Merge branch 'main' into tests_and_juniper
netpicker Aug 21, 2024
25e3767
add 4th example
mailsanjayhere Aug 21, 2024
c4303c9
added textfsm example
mailsanjayhere Aug 21, 2024
233d350
Merge branch 'main' into tests_and_juniper
netpicker Aug 21, 2024
8b91b4b
updated hyperlink for toc 4
mailsanjayhere Aug 26, 2024
a8ab282
Merge branch 'main' into tests_and_juniper
netpicker Aug 26, 2024
57d1974
added one more example.. using tags
mailsanjayhere Aug 26, 2024
f143fc4
typo
mailsanjayhere Aug 26, 2024
2927c3f
Merge branch 'main' into tests_and_juniper
netpicker Aug 26, 2024
1613da6
Update EXAMPLES.md
netpicker Aug 26, 2024
df44542
Merge branch 'main' into tests_and_juniper
netpicker Aug 26, 2024
c30007e
Update EXAMPLES.md
netpicker Aug 26, 2024
ae0335e
Merge branch 'main' into tests_and_juniper
netpicker Aug 26, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion EXAMPLES.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ A set of common Netpicker compliance use-cases.
4. [Using Configuration and Commands](#using-configuration-and-commands)
5. [Using TextFSM](#using-textfsm)
6. [Using Tags for Device Grouping](#using-tags-for-device-grouping)
7. [Accessing Netbox Data in Netpicker Rules](#accessing-netbox-data-in-netpicker-rules)

## Format of the Rules

Expand Down Expand Up @@ -141,11 +142,11 @@ def rule_interface_status_check(device):
*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.*

## Using Tags for Device Grouping
You can create tags such as `datacenter`, `campus`, or `branch`, and then apply specific rules to all devices in these groups.

### Example: Printing All Devices with a Specific Tag

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.
You can create tags such as `datacenter`, `campus`, or `branch`, and then apply specific rules to all devices in these groups.

```python
@medium(
Expand All @@ -160,3 +161,25 @@ def rule_one(devices, device):
print(f"Device: {dev.name} and IP address: {dev.ipaddress}")
```
*This example demonstrates how to print the name and IP address of all devices tagged with `campus`.*

## Accessing NetBox Data in Netpicker Rules

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.

### Example: Accessing and Printing Device Names from NetBox
```python
@medium(
name='rule_netbox',
)
def rule_netbox(netbox):
# Fetch all devices from NetBox
devices = netbox.dcim.devices.all()

# Extract the names of the devices
device_names = [device.name for device in devices]

# Print the names of all devices fetched from NetBox
for name in device_names:
print(name)
```
*The above example demonstrates how to access NetBox data within a Netpicker rule. This rule fetches all devices from NetBox and prints their names.*
Loading