Skip to content

Tests and juniper #100

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 16 commits into from
Aug 19, 2024
Merged
Changes from all commits
Commits
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
38 changes: 33 additions & 5 deletions EXAMPLES.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,37 @@ A set of common Netpicker compliance use-cases.
#### Using Textfsm

## Format of the rules
Understand the Netpicker Rule Structure

Severity Levels: Decide whether your rule should be low, medium, or high severity, depending on its importance.
Rule Naming: Name your rule starting with rule_, followed by a descriptive name that reflects the test's purpose.
Platform Specification: Identify the platforms (e.g., cisco_ios, juniper_junos) the rule applies to.

### 2. **Understand the Netpicker Rule Structure**
- **Severity Levels**: Decide whether your rule should be low, medium, or high severity, depending on its importance.
- **Rule Naming**: Name your rule starting with `rule_`, followed by a descriptive name that reflects the test's purpose.
- **Platform Specification**: Identify the platforms (e.g., `cisco_ios`, `juniper`) the rule applies to.

### 3. **Write the Netpicker Rule**
- **Basic Structure**: Use the Netpicker rule template:
```python
@low(
name='rule_name',
platform=['platform_name'],
commands={'command_name': 'command_to_execute'},
)
def rule_name(configuration, commands, device, devices):
assert 'keyword' in configuration
```
- **Customize the Rule**:
- Replace `'rule_name'` with your actual rule name.
- Specify the correct platform(s).
- Define the commands needed for the test.
- Implement the logic inside the function, using assertions to determine if the device complies with the rule.

**Example**:
```python
@medium(
name='rule_no_default_route',
platform=['cisco_ios'],
commands={'show_route': 'show ip route'},
)
def rule_no_default_route(configuration, commands, device, devices):
assert '0.0.0.0/0' not in commands.show_route
```
- **Testing Logic**: The example above checks if a default route (0.0.0.0/0) exists in the device's route table.
Loading