Skip to content

Tests and juniper #110

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 36 commits into from
Aug 21, 2024
Merged
Changes from all commits
Commits
Show all changes
36 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
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: 25 additions & 0 deletions EXAMPLES.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ A set of common Netpicker compliance use-cases.
2. [Simple Examples](#simple-examples)
3. [Multiple Lines](#multiple-lines)
4. [Using Configuration and Commands](#configuration-commands)
5. [Using TextFSM](#using-textfsm)


## Format of the Rules

Expand Down Expand Up @@ -114,3 +116,26 @@ def rule_bgp_neighbors_status(configuration, device):
assert len(neighbors_down) == 0, f"BGP neighbors down: {', '.join([line.split()[0] for line in neighbors_down])}"
```
*This example looks for 'router bgp' in configuration and if found then executes the `show ip bgp summary` command and checks the status of all BGP neighbors. If any neighbor is in an "Idle," "Active," or "Connect" state, the rule will fail, listing the IP addresses of the down neighbors.*

## Using TextFSM

### Example: Interface Status Check Using TextFSM

This rule checks the status of a specific interface on a Cisco IOS device using TextFSM for command output parsing. It ensures that the interface is up and running.

```python
@medium(
name='rule_interface_status_check',
platform=['cisco_ios'],
)
def rule_interface_status_check(device):
# Execute the command to get interface details using TextFSM parsing
inf_output = device.cli("show interface eth0/0").fsm[0]

# Print the parsed output for debugging or verification purposes
print(inf_output)

# Assert that the interface is up; fail the test if it is down
assert inf_output.link_status == "up", "Interface is down"
```
*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.*
Loading