Skip to main content

Alcatel-Lucent Enterprise AOS CLI parsing (TextFSM)

Project description

Build Status

TEXTFSM-AOS

Alcatel-Lucent Enterprise AOS CLI parsing

Python package for Alcatel-Lucent Enterprise aos6 and aos8 parsing based on TextFSM templates.

Why TextFSM-AOS?

Parse semi-structured cli data to structured data ready to be ingested by your network automation pipeline. Automatically transform gathered output from screen-scraping tools like Netmiko, Scrapli and Paramiko. Receive uniform data across Alcatel-Lucent Enterprise devices running aos6 or aos8.

Installation

Textfsm-aos can be installed using Git + Poetry or PyPI.

Git

git clone https://github.com/jefvantongerloo/textfsm-aos
poetry install

PyPI

pip install textfsm-aos

Getting started

Provide screen-scraped data to parser

from textfsm_aos.parser import parse

sample_data = """
   Package           Release       Size     Description
-----------------+---------------+--------+-----------------------------------
KFbase.img        6.7.2.89.R06    18059551 Alcatel-Lucent Enterprise Base Softw
KFos.img          6.7.2.89.R06     3566798 Alcatel-Lucent Enterprise OS
KFeni.img         6.7.2.89.R06     6123991 Alcatel-Lucent Enterprise NI softwar
KFsecu.img        6.7.2.89.R06      649383 Alcatel-Lucent Enterprise Security M
"""

parse("ale_aos6", "show microcode", sample_data)

parsed result

[
   {
      "package":"KFbase.img",
      "release":"6.7.2.89.R06",
      "size":"18059551",
      "description":"Alcatel-Lucent Enterprise Base Softw"
   },
   {
      "package":"KFos.img",
      "release":"6.7.2.89.R06",
      "size":"3566798",
      "description":"Alcatel-Lucent Enterprise OS"
   },
   {
      "package":"KFeni.img",
      "release":"6.7.2.89.R06",
      "size":"6123991",
      "description":"Alcatel-Lucent Enterprise NI softwar"
   },
   {
      "package":"KFsecu.img",
      "release":"6.7.2.89.R06",
      "size":"649383",
      "description":"Alcatel-Lucent Enterprise Security M"
   }
]

Integration tests

Due to sensitive information the gathered live data for integration testing is stored in a private repository. Releases are tested against following aos versions:

aos version tests
6.7.2.122.R08 :heavy_check_mark:
8.9.73.R01 :heavy_check_mark:
8.8.56.R02 :heavy_check_mark:
8.8.152.R01 :heavy_check_mark:
8.9.73.R01 :heavy_check_mark:
8.9.94.R04 :heavy_check_mark:
8.9.107.R02 :heavy_check_mark:
8.9.221.R03 :heavy_check_mark:

Supported commands

command aos6 aos8
history alias: show history :heavy_check_mark:
show 802.1x users :heavy_check_mark: alias: show unp user
show 802.1x users unp :heavy_check_mark: :x:
show 802.1x non-supplicant :heavy_check_mark: :x:
show 802.1x non-supplicant unp :heavy_check_mark: :x:
show arp :x: :heavy_check_mark:
show chassis :heavy_check_mark: :heavy_check_mark:
show cmm :x: :heavy_check_mark:
show command-log :heavy_check_mark: :heavy_check_mark:
show hardware-info :x: :heavy_check_mark:
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 router database :x: :heavy_check_mark:
show ip routes alias: show ip route :heavy_check_mark:
show linkagg :x: :heavy_check_mark:
show linkagg port :x: :heavy_check_mark:
show lld remote system :heavy_check_mark: :x:
show log events :x: :heavy_check_mark:
show mac-address-table :heavy_check_mark: alias: show mac-learning
show mac-learning alias: show mac-address-table :heavy_check_mark:
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 unp user details :x: :heavy_check_mark:
show user :heavy_check_mark: :heavy_check_mark:
show running-directory :x: :heavy_check_mark:
show qos log :x: :heavy_check_mark:
show services :x: :heavy_check_mark:
show services spb :x: :heavy_check_mark:
show snmp station :heavy_check_mark: :heavy_check_mark:
show snmp community map :heavy_check_mark: alias: show snmp community-map
show snmp community-map alias: show snmp community map :heavy_check_mark:
show spantree ports :x: :heavy_check_mark:
show system :heavy_check_mark: :heavy_check_mark:
show transceivers :x: :heavy_check_mark:
show vlan :heavy_check_mark: :heavy_check_mark:
show vlan members :x: :heavy_check_mark:
show vlan port mobile :heavy_check_mark: :x:

Direct TextFSM example usage

Bypass the build-in parser functionality and use the TextFSM templates directly in network cli scraping and orchestration tools like Netmiko, Scrapli and Ansible.

Scrapli

Python script:

from scrapli import Scrapli
from scrapli.helper import textfsm_parse

device = {
    "host": "<host ip>",
    "auth_username": "<username>",
    "auth_password": "<password>",
    "auth_strict_key": False,
    "transport": "ssh2",
    "platform": "alcatel_aos",
}

with Scrapli(**device) as conn:
    response = conn.send_command("show health").result
    structured_response = textfsm_parse(
        "templates/ale_aos6_show_health.textfsm", response
    )

Example output:

[
   {
      "resource":"Receive",
      "limit":"80",
      "current":"01",
      "min_avg":"01",
      "hr_avg":"01",
      "hr_max":"01"
   },
   {
      "resource":"Transmit/Receive",
      "limit":"80",
      "current":"01",
      "min_avg":"01",
      "hr_avg":"01",
      "hr_max":"01"
   },
   {
      "resource":"Memory",
      "limit":"80",
      "current":"76",
      "min_avg":"76",
      "hr_avg":"76",
      "hr_max":"76"
   },
   {
      "resource":"Cpu",
      "limit":"80",
      "current":"32",
      "min_avg":"33",
      "hr_avg":"29",
      "hr_max":"97"
   }
]

Netmiko

Python script:

from netmiko import ConnectHandler

device = {
    'device_type': 'alcatel_aos',
    'host': '<host ip>',
    'username': '<username>',
    'password': '<password>'
}

with ConnectHandler(**device) as conn:
    output = conn.send_command("show health", use_textfsm=True, textfsm_template="textfsm-aos/templates/ale_aos6_show_health.textfsm")

Example Output:

[
   {
      "resource":"Receive",
      "limit":"80",
      "current":"01",
      "min_avg":"01",
      "hr_avg":"01",
      "hr_max":"01"
   },
   {
      "resource":"Transmit/Receive",
      "limit":"80",
      "current":"01",
      "min_avg":"01",
      "hr_avg":"01",
      "hr_max":"01"
   },
   {
      "resource":"Memory",
      "limit":"80",
      "current":"76",
      "min_avg":"76",
      "hr_avg":"76",
      "hr_max":"76"
   },
   {
      "resource":"Cpu",
      "limit":"80",
      "current":"32",
      "min_avg":"33",
      "hr_avg":"29",
      "hr_max":"97"
   }
]

Ansible

Ansible task:

- name: AOS6 >> parsed with textfsm
  set_fact:
    health: "{{ health-aos6 | ansible.netcommon.parse_cli_textfsm('textfsm/templates/ale_aos6_show_health.textfsm') }}"

Example Output:

    health:
    - healthModuleCpu1HrAvg: '29'
      healthModuleCpu1HrMax: '98'
      healthModuleCpu1MinAvg: '26'
      healthModuleCpuLatest: '31'
      healthModuleCpuLimit: '80'
      healthModuleMemory1HrAvg: '76'
      healthModuleMemory1HrMax: '76'
      healthModuleMemory1MinAvg: '76'
      healthModuleMemoryLatest: '76'
      healthModuleMemoryLimit: '80'
      healthModuleRx1HrAvg: '01'
      healthModuleRx1HrMax: '01'
      healthModuleRx1MinAvg: '01'
      healthModuleRxLatest: '01'
      healthModuleRxLimit: '80'
      healthModuleRxTxRx1HrAvg: '01'
      healthModuleRxTxRx1HrMax: '01'
      healthModuleRxTxRx1MinAvg: '01'
      healthModuleRxTxRxLatest: '01'
      healthModuleRxTxRxLimit: '80'
      healthModuleSlot: '1'

How to contribute

  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.

  3. Add entry in templates_index with attribute command and platform.

  4. Add test folder in 'templates' with naming <platform>_<command>.

  5. Add sample cli output file in newly created folder <platform>_<command>.txt.

  6. Add expected parsed data from sample cli output in <platform>_<command>.yml.

  7. Run linting tox and tests pytest.

How to setup development environment

  1. Install Poetry package manager via pip install poetry

  2. Install dev dependencies and textfsm-aos package in development mode with poetry install

  3. Open virtual environment poetry shell

Related projects

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

textfsm_aos-1.1.4.tar.gz (26.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

textfsm_aos-1.1.4-py3-none-any.whl (42.2 kB view details)

Uploaded Python 3

File details

Details for the file textfsm_aos-1.1.4.tar.gz.

File metadata

  • Download URL: textfsm_aos-1.1.4.tar.gz
  • Upload date:
  • Size: 26.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.3 Linux/6.17.0-14-generic

File hashes

Hashes for textfsm_aos-1.1.4.tar.gz
Algorithm Hash digest
SHA256 31fc7d05156827f7a5519e60869b08b1b6554198bcb0d26b2846b914451b8078
MD5 b0060fc90ef0474ed0d3f683338851cf
BLAKE2b-256 3815a991706e4182fb025ddddf144e0bf4290ee9596298df1c1d38ed976b392b

See more details on using hashes here.

File details

Details for the file textfsm_aos-1.1.4-py3-none-any.whl.

File metadata

  • Download URL: textfsm_aos-1.1.4-py3-none-any.whl
  • Upload date:
  • Size: 42.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.3 Linux/6.17.0-14-generic

File hashes

Hashes for textfsm_aos-1.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 ef9e577e276ee15931cb4de568a0a206a2e215a2837aa89dc4920795ce5cbd19
MD5 78e892349789ff24eb773f98c8bf61c2
BLAKE2b-256 b1acbe8ae8d55d15f766db43b5c3e3802f2b246c4df5667d78fe849785c7ee4a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page