Skip to content

Commit

Permalink
Merge pull request #53 from jefvantongerloo/ale_aos8_show_interfaces
Browse files Browse the repository at this point in the history
Ale aos8 show interfaces
  • Loading branch information
jefvantongerloo committed Jun 23, 2022
2 parents 34cedb5 + ac2ad2f commit 350d81d
Show file tree
Hide file tree
Showing 10 changed files with 238 additions and 19 deletions.
8 changes: 8 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"python.testing.pytestArgs": [
"--ignore=dev"
],
"python.testing.unittestEnabled": false,
"python.testing.pytestEnabled": true,
"python.testing.pytestPath": "/home/p064033/projects/forks/textfsm-aos/.venv/bin/pytest"
}
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

### Added CLI commands

- aos8 - `show interfaces` [#53](https://github.com/jefvantongerloo/textfsm-aos/pull/53)
- aos8 - `show port-security brief` [#51](https://github.com/jefvantongerloo/textfsm-aos/pull/51)
- aos8 - `show qos port` [#52](https://github.com/jefvantongerloo/textfsm-aos/pull/52)

Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ parsed result
| show health | :heavy_check_mark: | :heavy_check_mark: |
| show history | :heavy_check_mark: | `alias: history` |
| show interface status | :heavy_check_mark: | :heavy_check_mark: |
| show interfaces | :x: | :heavy_check_mark: |
| show ip interface | :heavy_check_mark: | :heavy_check_mark: |
| show ip route | :heavy_check_mark: | `alias: show ip routes` |
| show ip routes | `alias: show ip route` | :heavy_check_mark: |
Expand All @@ -101,6 +102,7 @@ parsed result
| show microcode | :heavy_check_mark: | :heavy_check_mark: |
| show ntp server status | :heavy_check_mark: | :heavy_check_mark: |
| show port-security brief | :x: | :heavy_check_mark: |
| show qos port | :x: | :heavy_check_mark: |
| show unp user | `alias: show 802.1x users` | :heavy_check_mark: |
| show user | :heavy_check_mark: | :heavy_check_mark: |
| show running-directory | :x: | :heavy_check_mark: |
Expand Down Expand Up @@ -276,7 +278,7 @@ Example Output:
## How to contribute
1. Create branch with naming `<platform>_<command>` (for example: ale_aos8_show_system).
1. Fork and create a branch with naming `<platform>_<command>` (for example: ale_aos8_show_system).

2. Add TextFSM template file in templates folder with naming `<platform>_<command>.textfsm`.

Expand All @@ -292,13 +294,11 @@ Example Output:

## How to setup development environment

1. Create virtual Python environment `python -m venv .venv`
1. Install `Poetry` package manager via `pip install poetry`

2. Activate environment `source .venv/bin/activate`
2. Install dev dependencies and textfsm-aos package in development mode with `poetry install`

3. Install Python dependencies `pip install -r requirements.txt`

4. Install textfsm_aos package in development mode `pip install -e .`
3. Open virtual environment `poetry shell`

## Related projects

Expand Down
16 changes: 8 additions & 8 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,9 @@ homepage = "https://github.com/jefvantongerloo/textfsm-aos"
keywords = ["network automation", "textfsm", "scraping", "Alcatel-Lucent Enterprise", "infrastructure"]

[tool.poetry.dependencies]
python = "^3.8"
python = ">=3.8"
textfsm = "^1.1.2"
PyYAML = "^6.0"
rich = "^12.4.1"

[tool.poetry.dev-dependencies]
textfsm = "^1.1.2"
Expand Down
3 changes: 0 additions & 3 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
pytest
pyyaml
scrapli
scrapli[community]
scrapli[ssh2]
textfsm
tox-travis
58 changes: 58 additions & 0 deletions tests/ale_aos8_show_interfaces/ale_aos8_show_interfaces.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
Chassis/Slot/Port : 1/1/1
Operational Status : up,
Port-Down/Violation Reason: None,
Last Time Link Changed : Sat Mar 19 16:23:13 2022,
Number of Status Change : 31,
Type : Ethernet,
SFP/XFP : N/A,
Interface Type : Copper,
EPP : Disabled,
Link-Quality : N/A,
MAC address : 94:24:e1:56:cd:ba,
BandWidth (Megabits) : 1000, Duplex : Full,
Autonegotiation : 1 [ 1000-F 100-F 100-H 10-F 10-H ],
Long Frame Size(Bytes) : 9216,
Inter Frame Gap(Bytes) : 12,
loopback mode : N/A,
Rx :
Bytes Received : 59594072906, Unicast Frames : 185795516,
Broadcast Frames: 681, M-cast Frames : 550006,
UnderSize Frames: 0, OverSize Frames: 0,
Lost Frames : 0, Error Frames : 0,
CRC Error Frames: 0, Alignments Err : 0,
Tx :
Bytes Xmitted : 306228410627, Unicast Frames : 262707153,
Broadcast Frames: 11045175, M-cast Frames : 6102302,
UnderSize Frames: 0, OverSize Frames: 0,
Lost Frames : 0, Collided Frames: 0,
Error Frames : 0, Collisions : 0,
Late collisions : 0, Exc-Collisions : 0
Chassis/Slot/Port : 1/1/2
Operational Status : up,
Port-Down/Violation Reason: None,
Last Time Link Changed : Fri May 13 18:22:39 2022,
Number of Status Change : 146,
Type : Ethernet,
SFP/XFP : N/A,
Interface Type : Copper,
EPP : Disabled,
Link-Quality : N/A,
MAC address : 94:24:e1:56:cd:bb,
BandWidth (Megabits) : 100, Duplex : Full,
Autonegotiation : 1 [ 1000-F 100-F 100-H 10-F 10-H ],
Long Frame Size(Bytes) : 1552,
Inter Frame Gap(Bytes) : 12,
loopback mode : N/A,
Rx :
Bytes Received : 204986659, Unicast Frames : 1943330,
Broadcast Frames: 151600, M-cast Frames : 0,
UnderSize Frames: 0, OverSize Frames: 0,
Lost Frames : 0, Error Frames : 5,
CRC Error Frames: 0, Alignments Err : 0,
Tx :
Bytes Xmitted : 4738744836, Unicast Frames : 7071910,
Broadcast Frames: 11042646, M-cast Frames : 6102320,
UnderSize Frames: 0, OverSize Frames: 0,
Lost Frames : 0, Collided Frames: 0,
Error Frames : 0, Collisions : 0,
Late collisions : 0, Exc-Collisions : 0
79 changes: 79 additions & 0 deletions tests/ale_aos8_show_interfaces/ale_aos8_show_interfaces.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
---
- chassis_slot_port: '1/1/1'
operation_status: 'up'
port_down_violation_reason: 'None'
last_time_link_changed: 'Sat Mar 19 16:23:13 2022'
number_of_status_change: '31'
type: 'Ethernet'
sfp_xfp: 'N/A'
interface_type: 'Copper'
epp: 'Disabled'
link_quality: 'N/A'
mac_address: '94:24:e1:56:cd:ba'
bandwidth: '1000'
duplex: 'Full'
autonegotiation: '1 [ 1000-F 100-F 100-H 10-F 10-H ]'
long_frame_size: '9216'
inter_frame_gap: '12'
loopback_mode: 'N/A'
bytes_received: '59594072906'
rx_unicast_frames: '185795516'
rx_broadcast_frames: '681'
rx_mcast_frames: '550006'
rx_undersize_frames: '0'
rx_oversize_frames: '0'
rx_lost_frames: '0'
rx_error_frames: '0'
rx_crc_error_frames: '0'
rx_alignments_err: '0'
bytes_xmitted: '306228410627'
tx_unicast_frames: '262707153'
tx_broadcast_frames: '11045175'
tx_mcast_frames: '6102302'
tx_undersize_frames: '0'
tx_oversize_frames: '0'
tx_lost_frames: '0'
tx_collided_frames: '0'
tx_error_frames: '0'
collisions: '0'
late_collisions: '0'
exc_collisions: '0'
- chassis_slot_port: '1/1/2'
operation_status: 'up'
port_down_violation_reason: 'None'
last_time_link_changed: 'Fri May 13 18:22:39 2022'
number_of_status_change: '146'
type: 'Ethernet'
sfp_xfp: 'N/A'
interface_type: 'Copper'
epp: 'Disabled'
link_quality: 'N/A'
mac_address: '94:24:e1:56:cd:bb'
bandwidth: '100'
duplex: 'Full'
autonegotiation: '1 [ 1000-F 100-F 100-H 10-F 10-H ]'
long_frame_size: '1552'
inter_frame_gap: '12'
loopback_mode: 'N/A'
bytes_received: '204986659'
rx_unicast_frames: '1943330'
rx_broadcast_frames: '151600'
rx_mcast_frames: '0'
rx_undersize_frames: '0'
rx_oversize_frames: '0'
rx_lost_frames: '0'
rx_error_frames: '5'
rx_crc_error_frames: '0'
rx_alignments_err: '0'
bytes_xmitted: '4738744836'
tx_unicast_frames: '7071910'
tx_broadcast_frames: '11042646'
tx_mcast_frames: '6102320'
tx_undersize_frames: '0'
tx_oversize_frames: '0'
tx_lost_frames: '0'
tx_collided_frames: '0'
tx_error_frames: '0'
collisions: '0'
late_collisions: '0'
exc_collisions: '0'
75 changes: 75 additions & 0 deletions textfsm_aos/templates/ale_aos8_show_interfaces.textfsm
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
Value Key,Required chassis_slot_port (\d\/\d+\/\d+[\w]*)
Value operation_status (up|down|dormant)
Value port_down_violation_reason (.+\s*)
Value last_time_link_changed (.+\s*)
Value number_of_status_change (\d+)
Value type (Ethernet|Fast Ethernet|Gigabit Ethernet)
Value sfp_xfp (.+\s*)
Value interface_type (Copper|Fiber|Combo-copper|Combo-Fiber)
Value epp (Enabled|Disabled)
Value link_quality (GOOD|FAIR|POOR|N/A)
Value mac_address (([0-9A-Fa-f]{2}[:-]){5}([0-9A-Fa-f]){2})
Value bandwidth (\d+|-)
Value duplex (Half|Full|Auto|-)
Value autonegotiation (.+\s*)
Value long_frame_size (\d+)
Value inter_frame_gap (\d+)
Value loopback_mode (N/A|SPB-VPN)
Value bytes_received (\d+)
Value rx_unicast_frames (\d+)
Value rx_broadcast_frames (\d+)
Value rx_mcast_frames (\d+)
Value rx_undersize_frames (\d+)
Value rx_oversize_frames (\d+)
Value rx_lost_frames (\d+)
Value rx_error_frames (\d+)
Value rx_crc_error_frames (\d+)
Value rx_alignments_err (\d+)
Value bytes_xmitted (\d+)
Value tx_unicast_frames (\d+)
Value tx_broadcast_frames (\d+)
Value tx_mcast_frames (\d+)
Value tx_undersize_frames (\d+)
Value tx_oversize_frames (\d+)
Value tx_lost_frames (\d+)
Value tx_collided_frames (\d+)
Value tx_error_frames (\d+)
Value collisions (\d+)
Value late_collisions (\d+)
Value exc_collisions (\d+)

Start
^Chassis\/Slot\/Port\s+:\s${chassis_slot_port}\s+$$
^\sOperational Status\s+:\s${operation_status},$$
^\sPort-Down\/Violation Reason:\s${port_down_violation_reason},$$
^\sLast Time Link Changed\s+:\s${last_time_link_changed},$$
^\sNumber of Status Change\s+:\s${number_of_status_change},$$
^\sType\s+:\s${type},$$
^\sSFP/XFP\s+:\s${sfp_xfp},$$
^\sInterface Type\s+:\s${interface_type},$$
^\sEPP\s+:\s${epp},$$
^\sLink-Quality\s+:\s${link_quality},$$
^\sMAC address\s+:\s${mac_address},$$
^\sBandWidth \(Megabits\)\s+:\s+${bandwidth}\s*,\s+Duplex\s+:\s${duplex}\s*,$$
^\sAutonegotiation\s+:\s+${autonegotiation},$$
^\sLong Frame Size\(Bytes\)\s+:\s${long_frame_size},$$
^\sInter Frame Gap\(Bytes\)\s+:\s${inter_frame_gap},$$
^\sloopback mode\s+:\s${loopback_mode},$$ -> Rx

Rx
^\sRx\s+:$$
^\sBytes Received\s*:\s+${bytes_received}, Unicast Frames\s*:\s+${rx_unicast_frames},$$
^\sBroadcast Frames\s*:\s+${rx_broadcast_frames}, M-cast Frames\s*:\s+${rx_mcast_frames},$$
^\sUnderSize Frames\s*:\s+${rx_undersize_frames}, OverSize Frames\s*:\s+${rx_oversize_frames},$$
^\sLost Frames\s*:\s+${rx_lost_frames}, Error Frames\s*:\s+${rx_error_frames},$$
^\sCRC Error Frames\s*:\s+${rx_crc_error_frames}, Alignments Err\s*:\s+${rx_alignments_err},$$ -> Tx

Tx
^\sTx\s+:$$
^\sBytes Xmitted\s*:\s+${bytes_xmitted},\s*Unicast Frames\s*:\s+${tx_unicast_frames},$$
^\sBroadcast Frames\s*:\s+${tx_broadcast_frames}, M-cast Frames\s*:\s+${tx_mcast_frames},$$
^\sUnderSize Frames\s*:\s+${tx_undersize_frames}, OverSize Frames\s*:\s+${tx_oversize_frames},$$
^\sLost Frames\s*:\s+${tx_lost_frames},\s*Collided Frames\s*:\s+${tx_collided_frames},$$
^\sError Frames\s*:\s+${tx_error_frames},\s*Collisions\s*:\s+${collisions},$$
^\sLate collisions\s*:\s+${late_collisions},\s*Exc-Collisions\s*:\s+${exc_collisions}$$ -> Record Start
^. -> Error
2 changes: 2 additions & 0 deletions textfsm_aos/templates/templates_index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@
platform: ale_aos8
- command: show history
platform: ale_aos6
- command: show interfaces
platform: ale_aos8
- command: show interfaces status
platform: ale_aos6
- command: show interfaces status
Expand Down

0 comments on commit 350d81d

Please sign in to comment.