Skip to content

netops.parsers — Output Parsers

Vendor-specific parsers for CLI and structured API output.


netops.parsers.arista

Parsers for Arista EOS eAPI JSON responses and CLI text output.

Arista EOS supports two output modes:

  • eAPI JSON — structured JSON returned by the /command-api endpoint or via Netmiko with output_format="json". These are the primary parsers and accept already-decoded dict objects.
  • CLI text — plain-text show output, used as a fallback when eAPI is unavailable. These parsers operate on raw strings.

arista

Parsers for Arista EOS eAPI JSON responses and CLI text output.

Arista EOS supports two output modes:

  • eAPI JSON – structured JSON returned by the /command-api endpoint or via Netmiko send_command(..., use_genie=False) with output_format="json". These are the primary parsers and accept already-decoded dict objects.
  • CLI text – plain-text show output, used as a fallback when eAPI is unavailable. These parsers operate on raw strings.

All parser functions return lists or dicts that match the health-check schema used by the rest of the toolkit (same key names as Juniper/Cisco equivalents where possible).

Supported checks:

  • CPU / memoryshow version JSON (systemStats block)
  • Interface countersshow interfaces JSON / show interfaces counters errors JSON
  • Transceiver DOMshow interfaces transceiver JSON
  • BGP summaryshow bgp summary JSON (IPv4 + EVPN)
  • OSPF neighboursshow ip ospf neighbor JSON
  • MLAG healthshow mlag JSON + show mlag config-sanity JSON
  • Environmentshow environment all JSON (temperature, fans, PSUs)
Functions:
parse_cpu_memory_eos
parse_cpu_memory_eos(data: dict) -> dict

Parse show version eAPI JSON response for CPU and memory.

Arista's show version JSON includes a systemStats sub-dict with: cpuInfo (per-core usage) and memUsed / memTotal fields.

Returns:

Type Description
dict

Dict with:

  • cpu_utilization – overall CPU % (float) or None
  • memory_total_kb – total physical RAM in KB (int) or None
  • memory_used_kb – used RAM in KB (int) or None
  • memory_util – memory utilisation % (float) or None
  • uptime_seconds – system uptime in seconds (float) or None
  • eos_version – EOS software version string or None
  • serial_number – chassis serial number or None
  • model – hardware model string or None

Returns a dict with all values None when parsing fails.

parse_interfaces_eos
parse_interfaces_eos(data: dict) -> list[dict]

Parse show interfaces eAPI JSON response.

Returns:

Type Description
list

List of per-interface dicts:

  • name – interface name (str)
  • description – interface description (str)
  • line_protocol – line-protocol status ('up' / 'down')
  • oper_status – operational status string
  • link_status – link status ('connected' / 'notconnect' / …)
  • in_errors – input error count (int)
  • out_errors – output error count (int)
  • in_discards – input discard count (int)
  • out_discards – output discard count (int)
  • crc_errors – CRC align errors (int)
  • has_errorsTrue when any error counter > 0
  • is_upTrue when both oper and line-protocol are up
parse_interface_counters_eos
parse_interface_counters_eos(data: dict) -> list[dict]

Parse show interfaces counters errors eAPI JSON response.

Returns:

Type Description
list

List of per-interface error-counter dicts:

  • name – interface name (str)
  • fcs_errors – FCS / CRC errors (int)
  • align_errors – alignment errors (int)
  • symbol_errors – symbol errors (int)
  • rx_pause – received pause frames (int)
  • in_errors – total input errors (int)
  • out_errors – total output errors (int)
  • has_errorsTrue when any counter > 0
parse_transceivers_eos
parse_transceivers_eos(data: dict) -> list[dict]

Parse show interfaces transceiver eAPI JSON response.

Returns:

Type Description
list

List of per-interface transceiver dicts:

  • interface – interface name (str)
  • media_type – SFP/QSFP media type string
  • tx_power_dbm – transmit optical power in dBm (float) or None
  • rx_power_dbm – receive optical power in dBm (float) or None
  • tx_bias_ma – laser bias current in mA (float) or None
  • temperature_c – module temperature in °C (float) or None
  • supply_voltage – module supply voltage (float) or None
  • alertTrue when any DOM value is outside vendor limits
parse_bgp_summary_eos
parse_bgp_summary_eos(data: dict) -> list[dict]

Parse show bgp summary eAPI JSON response (IPv4 unicast).

Returns:

Type Description
list

List of BGP peer dicts:

  • neighbor – peer IP address (str)
  • peer_as – remote AS number (int) or None
  • state – session state ('Established' / 'Active' / …)
  • up_down – up/down time string
  • prefixes_rcvd – received prefix count (int)
  • is_establishedTrue when state is 'Established'
parse_bgp_evpn_eos
parse_bgp_evpn_eos(data: dict) -> list[dict]

Parse show bgp evpn summary eAPI JSON response.

Returns:

Type Description
list

Same per-peer structure as :func:parse_bgp_summary_eos.

parse_ospf_neighbors_eos
parse_ospf_neighbors_eos(data: dict) -> list[dict]

Parse show ip ospf neighbor eAPI JSON response.

Returns:

Type Description
list

List of OSPF neighbour dicts:

  • neighbor_id – neighbour router ID (str)
  • interface – local interface name (str)
  • address – neighbour IP address (str)
  • state – OSPF adjacency state (str)
  • priority – DR priority (int)
  • dead_time – dead-timer countdown string
  • is_fullTrue when state starts with 'Full'
parse_mlag_eos
parse_mlag_eos(data: dict) -> dict

Parse show mlag eAPI JSON response.

Returns:

Type Description
dict

Dict with:

  • state – MLAG state ('active' / 'inactive' / …)
  • peer_state – MLAG peer state string
  • peer_link – peer-link interface name
  • peer_link_status – peer-link line-protocol status
  • local_interface – MLAG local interface (VLAN SVI)
  • local_ip – MLAG local IP address
  • peer_ip – MLAG peer IP address
  • config_sanity – config-sanity status string ('consistent' / …)
  • is_activeTrue when state is 'active'
  • is_peer_activeTrue when peer_state is 'active'
  • peer_link_okTrue when peer-link is 'up'
parse_mlag_config_sanity_eos
parse_mlag_config_sanity_eos(data: dict) -> dict

Parse show mlag config-sanity eAPI JSON response.

Returns:

Type Description
dict

Dict with:

  • consistentTrue when no inconsistencies are found
  • global_inconsistencies – list of global inconsistency description strings
  • interface_inconsistencies – list of per-interface inconsistency dicts (each with interface, description, local_value, peer_value)
parse_environment_eos
parse_environment_eos(data: dict) -> dict

Parse show environment all eAPI JSON response.

Returns:

Type Description
dict

Dict with:

  • power_supplies – list of PSU dicts (name, status, ok)
  • fans – list of fan dicts (name, speed, status, ok)
  • temperatures – list of temperature sensor dicts (name, celsius, alert_raised, ok)
  • overall_okTrue when no component has a fault
parse_bgp_summary_eos_text
parse_bgp_summary_eos_text(output: str) -> list[dict]

Parse show bgp summary plain-text output from Arista EOS.

Handles output similar to::

BGP summary information for VRF default
Router identifier 10.0.0.1, local AS number 65001
Neighbor Status Codes: m - Under maintenance
  Description              Neighbor V AS           MsgRcvd   MsgSent  InQ OutQ  Up/Down State   PfxRcd PfxAcc
  10.0.0.2                 4 65002         1000      1001    0    0 5d03h Estab   50     50
  10.0.0.3                 4 65003           50        51    0    0 00:05:23 Active

Returns:

Type Description
list

Same structure as :func:parse_bgp_summary_eos.

parse_ospf_neighbors_eos_text
parse_ospf_neighbors_eos_text(output: str) -> list[dict]

Parse show ip ospf neighbor plain-text output from Arista EOS.

Handles output similar to::

Neighbor ID     Pri   State           Dead Time   Address         Interface
10.0.0.2          1   Full/DR         00:00:38    10.1.0.2        Ethernet1
10.0.0.3          1   Full/BDR        00:00:36    10.1.0.3        Ethernet2
10.0.0.4          0   ExStart/-       00:00:39    10.1.0.4        Ethernet3

Returns:

Type Description
list

Same structure as :func:parse_ospf_neighbors_eos.

parse_mlag_eos_text
parse_mlag_eos_text(output: str) -> dict

Parse show mlag plain-text output from Arista EOS.

Handles output similar to::

MLAG Configuration:
domain-id                          :        mlag-domain
local-interface                    :            Vlan4094
peer-address                       :          10.255.0.2
peer-link                          :     Port-Channel1
peer-config                        :        consistent

MLAG Status:
state                              :              Active
negotiation status                 :           Connected
peer-link status                   :                  Up
local-int status                   :                  Up
system-id                          :  02:1c:73:00:00:99
dual-primary detection             :            Disabled
dual-primary interface errdisabled :               False

MLAG Ports:
Disabled                           :                   0
Configured                         :                   0
Inactive                           :                   0
Active-partial                     :                   0
Active-full                        :                   2

Returns:

Type Description
dict

Same structure as :func:parse_mlag_eos.

parse_lldp_neighbors_eos
parse_lldp_neighbors_eos(data: dict) -> list[dict]

Parse show lldp neighbors eAPI JSON response.

Returns:

Type Description
list

List of LLDP neighbor dicts:

  • local_interface – local interface name (str)
  • chassis_id – remote chassis ID (str)
  • port_id – remote port identifier (str)
  • system_name – remote system name (str or None)
  • ttl – time-to-live in seconds (int) or None
parse_lldp_neighbors_eos_text
parse_lldp_neighbors_eos_text(output: str) -> list[dict]

Parse show lldp neighbors plain-text output from Arista EOS.

Handles output similar to::

Last table change time   : 0:05:23 ago
Number of table inserts  : 3
Number of table deletes  : 0
Number of table drops    : 0
Number of table age-outs : 0
Port          Neighbor Device ID       Neighbor Port ID    TTL
Ethernet1     switch-1                 Ethernet1           120
Ethernet2     switch-2.example.com     Ethernet3           120
Ethernet49    router-3                 ge-0/0/0            120

Returns:

Type Description
list

Same structure as :func:parse_lldp_neighbors_eos.

parse_vlan_eos
parse_vlan_eos(data: dict) -> list[dict]

Parse show vlan eAPI JSON response.

Returns:

Type Description
list

List of VLAN dicts:

  • vlan_id – VLAN identifier (int)
  • name – VLAN name (str)
  • status – VLAN status ('active' / 'suspended' / …)
  • interfaces – list of interface names in this VLAN
  • dynamicTrue when VLAN is dynamically created
parse_vlan_eos_text
parse_vlan_eos_text(output: str) -> list[dict]

Parse show vlan plain-text output from Arista EOS.

Handles output similar to::

VLAN  Name                             Status    Ports
1     default                          active    Et1, Et2, Et3
10    management                       active    Et49, Et50
100   servers                          suspended
200   guests                           active    Et10, Et11

Returns:

Type Description
list

Same structure as :func:parse_vlan_eos.


netops.parsers.bgp

Cisco IOS/IOS-XE/IOS-XR BGP summary parsers.

bgp

Parsers for BGP CLI output.

Supports Cisco IOS/IOS-XE (show ip bgp summary) and Cisco IOS-XR (show bgp summary).

Nokia SR-OS BGP output is handled by :func:netops.parsers.nokia_sros.parse_bgp_summary.

Functions:
parse_bgp_summary_cisco
parse_bgp_summary_cisco(output: str) -> list[dict]

Parse show ip bgp summary / show bgp summary output.

Handles Cisco IOS, IOS-XE, and IOS-XR formats.

Returns:

Type Description
list

List of per-peer dicts. Returns an empty list when the output cannot be parsed.

Each returned dict contains:
* ``neighbor`` – peer IPv4/IPv6 address
* ``peer_as`` – remote AS number (``int``)
* ``msg_rcvd`` – BGP messages received (``int``)
* ``msg_sent`` – BGP messages sent (``int``)
* ``up_down`` – session uptime or time-since-reset string
* ``state`` – ``'Established'`` or FSM state string

(e.g. 'Active', 'Idle', 'Connect')

* ``prefixes_received`` – prefixes received (``int``) when

state == 'Established', otherwise None

updown_to_seconds
updown_to_seconds(updown: str) -> int | None

Convert a BGP session up/down time string to total seconds.

Handles the most common Cisco and Nokia SR-OS formats:

  • HH:MM:SS — e.g. '00:15:30'
  • XdYh — e.g. '2d03h', '1d02h'
  • XwYd — e.g. '1w2d'
  • XhYm — Nokia SR-OS, e.g. '00h15m'
  • never — session was never established → None

Returns:

Type Description
int or None

Total seconds as an integer, or None when the string is 'never' or cannot be parsed.


netops.parsers.brocade

Brocade FastIron/ICX and Network OS/VDX CLI output parsers.

brocade

Parsers for Brocade FastIron / Network OS / Fabric OS CLI output.

Functions:
parse_interfaces
parse_interfaces(output: str) -> list[dict]

Parse show interfaces or show interface brief output.

Supports Brocade FastIron/ICX interface summary lines.

Returns:

Type Description
list

List of per-interface dicts.

Each returned dict contains:
* ``name`` – interface identifier (e.g. ``'GigabitEthernet1/1/1'``)
* ``status`` – administrative state: ``'up'`` or ``'down'``
* ``protocol`` – line-protocol state: ``'up'`` or ``'down'``
* ``up`` – ``True`` when both admin and line-protocol are ``'up'``
The field names match the Cisco / Nokia parser convention so callers can
treat output from all vendors uniformly.
Handles both the detailed form::

GigabitEthernet1/1/1 is up, line protocol is up

and the brief tabular form::

GigabitEthernet1/1/1 up up ...

parse_ip_routes
parse_ip_routes(output: str) -> list[dict]

Parse show ip route output from Brocade FastIron/ICX.

Returns:

Type Description
list

List of per-route dicts. Returns an empty list when the output cannot be parsed.

Each returned dict contains:
* ``type`` – route type code (e.g. ``'B'``, ``'C'``, ``'S'``, ``'R'``)
* ``network`` – destination prefix in CIDR notation (e.g. ``'10.0.0.0/8'``)
* ``next_hop`` – next-hop IP address, or ``'DIRECT'`` for connected routes
* ``interface`` – egress interface (e.g. ``'e1/1/1'``)
* ``metric`` – route metric / cost (``int``)
Example input lines::

B 10.0.0.0/8 192.168.1.254 e1/1 1 C 192.168.1.0/24 DIRECT e1/2 1 S 0.0.0.0/0 10.0.0.1 e1/1 1

parse_version
parse_version(output: str) -> dict

Parse show version output from a Brocade FastIron/ICX device.

Returns:

Type Description
dict

Dict with keys:

  • model – hardware model string (e.g. 'ICX7550-48')
  • version – software version string (e.g. '09.0.10T215')
  • vendor – always 'Brocade'

Returns a dict with None values when the output cannot be parsed.

Example input lines::

HW: ICX7550-48 SW: Version 09.0.10T215 Copyright (c) 1996-2023 Ruckus Networks, Inc.

parse_fabric
parse_fabric(output: str) -> dict

Parse show fabric output from a Brocade Fabric OS (FOS) SAN switch.

Returns:

Type Description
dict

Dict with keys:

  • fabric_name – fabric name string, or None
  • fabric_os – Fabric OS version string, or None
  • switches – list of switch dicts, each containing name and domain
  • ports – list of port dicts, each containing port, state ('Online' / 'Offline')

Returns a dict with empty defaults when the output cannot be parsed.

Example input::

Fabric Name: FabricA Fabric OS: v9.1.0 Switch: fc-sw-01 (domain 1) Port 0/1: Online Port 0/2: Offline


netops.parsers.cisco

Cisco IOS/IOS-XE CLI output parsers — OSPF neighbors, environment, version, inventory, and serial number.

cisco

Parsers for Cisco IOS/IOS-XE show command output.

Covers OSPF neighbor tables, device environment (temperature, fans, power supplies) and show version (uptime, reload reason, IOS version).

Functions:
parse_ospf_neighbors
parse_ospf_neighbors(output: str) -> list[dict]

Parse show ip ospf neighbor output from Cisco IOS/IOS-XE.

Returns:

Type Description
list

List of per-neighbor dicts. Returns an empty list when no neighbors are parsed.

Each returned dict contains:
* ``neighbor_id`` – OSPF router-ID of the neighbor (``str``)
* ``priority`` – interface priority (``int``)
* ``state`` – adjacency state string (e.g. ``'FULL/DR'``, ``'INIT/DROTHER'``)
* ``dead_time`` – dead-timer countdown in ``HH:MM:SS`` format (``str``)
* ``address`` – neighbor IP address (``str``)
* ``interface`` – local interface name (``str``)
* ``is_full`` – ``True`` when the state starts with ``'FULL'``
Example input::

Neighbor ID Pri State Dead Time Address Interface 192.168.1.2 1 FULL/DR 00:00:37 10.0.0.2 GigabitEthernet0/0 192.168.1.3 1 FULL/BDR 00:00:38 10.0.0.3 GigabitEthernet0/0 192.168.1.4 0 INIT/DROTHER 00:00:35 10.0.0.4 GigabitEthernet0/1

parse_environment_cisco
parse_environment_cisco(output: str) -> dict

Parse show environment all output from Cisco IOS/IOS-XE.

Handles both IOS (router) and IOS-XE (Catalyst switch) output formats.

Returns:

Type Description
dict

Dict with keys:

  • fans – list of fan dicts (name, status, ok)
  • temperatures – list of temperature dicts (name, celsius or None, status, ok)
  • power_supplies – list of power-supply dicts (name, status, ok)
  • overall_okTrue when every reported component is OK; True when no components were parsed (unknown state)

Returns a dict with empty lists when the output cannot be parsed.

Example IOS-XE input lines::

Switch 1 FAN 1 is OK Switch 1: TEMPERATURE is OK SYSTEM INLET : 28 Celsius, Critical threshold is 60 Celsius Switch 1: POWER-SUPPLY 1 is PRESENT Switch 1: POWER-SUPPLY 2 is NOT PRESENT

parse_version_cisco
parse_version_cisco(output: str) -> dict

Parse show version output from Cisco IOS/IOS-XE.

Returns:

Type Description
dict

Dict with keys:

  • version – IOS/IOS-XE version string (str or None)
  • platform – hardware platform identifier (str or None)
  • uptime – uptime string as reported by the device (str or None)
  • reload_reason – last reload/restart reason (str or None)
  • image – system image file path (str or None)

Returns a dict with all None values when the output cannot be parsed.

Example input lines::

Cisco IOS Software, Version 15.2(4)E8, RELEASE SOFTWARE (fc2) cisco WS-C3750X-48P (PowerPC405) processor ... Switch uptime is 2 weeks, 3 days, 4 hours, 5 minutes Last reload reason: Reload command System image file is "flash:c3750x-ipservicesk9-mz.152-4.E8.bin"

parse_inventory_cisco
parse_inventory_cisco(output: str) -> list[dict]

Parse show inventory output from Cisco IOS/NX-OS/IOS-XE.

Returns:

Type Description
list

List of dicts, each with:

  • name – component name (e.g. "Chassis", "Slot 1")
  • descr – description string
  • pid – product ID
  • vid – version ID
  • sn – serial number
Example input::

NAME: "Chassis", DESCR: "Nexus 9000 Series Chassis" PID: N9K-C93180YC-FX3, VID: V01, SN: FDO23456789

parse_serial_cisco
parse_serial_cisco(output: str) -> str | None

Extract the chassis serial number from show inventory output.

Returns:

Type Description
str or None

The serial number string for the first entry whose name contains "chassis" (case-insensitive), or the first entry if no chassis is found. Returns None if parsing fails.


netops.parsers.health

Multi-vendor CPU, memory, interface error, and log parsers.

health

Parsers for health-check CLI output (CPU, memory, interface errors, logs).

Supports Cisco IOS/XE/XR/NXOS, Nokia SR-OS, and Brocade FastIron/NOS output formats.

Functions:
parse_cpu_cisco
parse_cpu_cisco(output: str) -> dict

Parse show processes cpu output from Cisco IOS/XE/XR.

Returns:

Type Description
dict

Dict with keys:

  • five_seconds – CPU % over the last 5 seconds (float)
  • one_minute – CPU % over the last 1 minute (float)
  • five_minutes – CPU % over the last 5 minutes (float)

Returns an empty dict when the output cannot be parsed.

Example input line::

CPU utilization for five seconds: 12%/3%; one minute: 8%; five minutes: 6%

parse_cpu_nokia
parse_cpu_nokia(output: str) -> dict

Parse show system cpu output from Nokia SR-OS.

Returns:

Type Description
dict

Dict with keys:

  • avg – average CPU utilization % (float)
  • peak – peak CPU utilization % (float)

Returns an empty dict when the output cannot be parsed.

Example input lines::

CPU Usage : 5% 12%

parse_memory_cisco
parse_memory_cisco(output: str) -> dict

Parse show processes memory output from Cisco IOS/XE.

Returns:

Type Description
dict

Dict with keys:

  • total – total bytes (int)
  • used – used bytes (int)
  • free – free bytes (int)
  • utilization – percentage used (float, 0–100)

Returns an empty dict when the output cannot be parsed.

Example input line::

Processor 7F2B3C18 402702336 141058576 261643760 ...

parse_memory_nokia
parse_memory_nokia(output: str) -> dict

Parse show system memory-pools output from Nokia SR-OS.

Returns:

Type Description
dict

Dict with keys:

  • total – total bytes (int)
  • used – used bytes (int)
  • free – free bytes (int)
  • utilization – percentage used (float, 0–100)

Returns an empty dict when the output cannot be parsed.

Example input lines::

Total In Use : 141058576 Total Available : 261643760

parse_interface_errors_cisco
parse_interface_errors_cisco(output: str) -> list[dict]

Parse show interfaces output for error counters on Cisco IOS/XE/XR.

Returns:

Type Description
list

List of per-interface error-counter dicts. Returns an empty list when no interfaces are parsed.

Each returned dict contains:
* ``name`` – interface name (e.g. ``'GigabitEthernet0/0'``)
* ``input_errors`` – total input errors (``int``)
* ``output_errors`` – total output errors (``int``)
* ``crc`` – CRC errors (``int``)
* ``drops`` – total input/output drops (``int``)
* ``has_errors`` – ``True`` when any counter is non-zero
parse_interface_errors_nokia
parse_interface_errors_nokia(output: str) -> list[dict]

Parse show port detail output for error counters on Nokia SR-OS.

Returns:

Type Description
list

List of per-interface error-counter dicts. Returns an empty list when no ports are parsed.

Each returned dict contains:
* ``name`` – port identifier (e.g. ``'1/1/1'``)
* ``input_errors`` – total input errors (``int``)
* ``output_errors`` – total output errors (``int``)
* ``crc`` – CRC/alignment errors (``int``)
* ``drops`` – ingress/egress drops (``int``)
* ``has_errors`` – ``True`` when any counter is non-zero
parse_logs_cisco
parse_logs_cisco(output: str) -> list[dict]

Scan show logging output for severity 0–3 (critical/major) events.

Returns:

Type Description
list

List of per-log-entry dicts. Returns an empty list when no matching events are found.

Each returned dict contains:
* ``facility`` – syslog facility (e.g. ``'SYS'``)
* ``severity`` – numeric severity 0–3 (``int``)
* ``mnemonic`` – syslog mnemonic (e.g. ``'MALLOCFAIL'``)
* ``message`` – event description
parse_logs_nokia
parse_logs_nokia(output: str) -> list[dict]

Scan Nokia SR-OS log output for CRITICAL and MAJOR severity events.

Returns:

Type Description
list

List of per-log-entry dicts. Returns an empty list when no matching events are found.

Each returned dict contains:
* ``timestamp`` – event timestamp string
* ``severity`` – ``'CRITICAL'`` or ``'MAJOR'``
* ``subject`` – log subject/application
* ``message`` – event description
parse_cpu_brocade
parse_cpu_brocade(output: str) -> dict

Parse show cpu output from Brocade FastIron/ICX.

Returns:

Type Description
dict

Dict with keys:

  • one_second – CPU % over the last 1 second (float)
  • five_seconds – CPU % over the last 5 seconds (float)
  • one_minute – CPU % over the last 60 seconds (float)

Returns an empty dict when the output cannot be parsed.

Example input lines::

CPU Utilization: 1-second average: 12 percent 5-second average: 10 percent 60-second average: 8 percent

parse_memory_brocade
parse_memory_brocade(output: str) -> dict

Parse show memory output from Brocade FastIron/ICX.

Returns:

Type Description
dict

Dict with keys:

  • total – total bytes (int)
  • used – used bytes (int)
  • free – free bytes (int)
  • utilization – percentage used (float, 0–100)

Returns an empty dict when the output cannot be parsed.

Example input lines::

System memory information: Total DRAM: 1048576 KBytes Used DRAM: 512000 KBytes Free DRAM: 536576 KBytes

parse_interface_errors_brocade
parse_interface_errors_brocade(output: str) -> list[dict]

Parse show interfaces output for error counters on Brocade FastIron/ICX.

Returns:

Type Description
list

List of per-interface error-counter dicts. Returns an empty list when no interfaces are parsed.

Each returned dict contains:
* ``name`` – interface name (e.g. ``'GigabitEthernet1/1/1'``)
* ``input_errors`` – total input errors (``int``)
* ``output_errors`` – total output errors (``int``)
* ``crc`` – CRC/alignment errors (``int``)
* ``drops`` – input/output discards (``int``)
* ``has_errors`` – ``True`` when any counter is non-zero
Example input lines::

GigabitEthernet1/1/1 is up, line protocol is up 0 input errors, 0 CRC, 0 alignment errors, 0 runts, 0 giants 0 output errors, 0 output discards

parse_logs_brocade
parse_logs_brocade(output: str) -> list[dict]

Scan show logging output for critical/error severity events on Brocade.

Returns:

Type Description
list

List of per-log-entry dicts. Returns an empty list when no matching events are found.

Each returned dict contains:
* ``timestamp`` – event timestamp string (e.g. ``'Mar 15 12:34:56'``)
* ``severity`` – normalised severity: ``'CRITICAL'``, ``'ERROR'``, or

'WARNING'

* ``message`` – event description
parse_cpu_paloalto
parse_cpu_paloalto(output: str) -> dict

Parse show system resources follow duration 1 output from PAN-OS.

PAN-OS runs on a Linux kernel and exposes a top-style resource snapshot. This parser extracts the CPU idle percentage and derives utilization.

Returns:

Type Description
dict

Dict with keys:

  • user – user-space CPU % (float)
  • system – kernel CPU % (float)
  • idle – idle CPU % (float)
  • utilization – used CPU % = 100 - idle (float)

Returns an empty dict when the output cannot be parsed.

Example input line::

%Cpu(s): 5.0 us, 1.5 sy, 0.0 ni, 92.5 id, 0.5 wa, 0.0 hi, 0.5 si

parse_memory_paloalto
parse_memory_paloalto(output: str) -> dict

Parse show system resources follow duration 1 output from PAN-OS.

Extracts the memory summary line from the top-style output.

Returns:

Type Description
dict

Dict with keys:

  • total – total bytes (int)
  • used – used bytes (int)
  • free – free bytes (int)
  • utilization – percentage used (float, 0–100)

Returns an empty dict when the output cannot be parsed.

Example input line::

MiB Mem : 16384.0 total, 8192.0 free, 6144.0 used, 2048.0 buff/cache


netops.parsers.juniper

Juniper JunOS CLI output parsers — Routing Engine, FPC, BGP, OSPF, chassis alarms, environment, and route summary.

juniper

Parsers for Juniper JunOS CLI output.

Supports both plain-text (show …) and XML-like text output produced by JunOS show commands. All parsers operate on strings returned from the device connection and do not require the lxml or ncclient libraries.

Parsers are grouped into:

  • Routing Engine – CPU, memory, uptime (show chassis routing-engine)
  • FPC – slot status and temperatures (show chassis fpc)
  • Interfaces – error counters (show interfaces extensive)
  • BGP – neighbour summary (show bgp summary)
  • OSPF – neighbour table (show ospf neighbor)
  • Chassis alarms – active alarms (show chassis alarms)
  • Chassis environment – power/temperature/fans (show chassis environment)
  • Route summary – routing table statistics (show route summary)
Functions:
parse_re_status
parse_re_status(output: str) -> list[dict]

Parse show chassis routing-engine output.

Returns:

Type Description
list

List of routing-engine dicts. Returns an empty list when the output cannot be parsed.

Each returned dict represents one Routing Engine slot and contains:
* ``slot`` – RE slot index (``int``, 0 or 1)
* ``mastership`` – mastership state (e.g. ``'Master'``, ``'Backup'``, ``'Disabled'``)
* ``state`` – RE state (e.g. ``'Online'``, ``'Offline'``)
* ``cpu_util`` – CPU utilisation % (``int``) or ``None``
* ``memory_util`` – DRAM utilisation % (``int``) or ``None``
* ``memory_total`` – total DRAM in MB (``int``) or ``None``
* ``memory_used`` – used DRAM in MB (``int``) or ``None``
* ``uptime`` – uptime string (e.g. ``'10 days, 3 hours, 22 minutes'``)

or None

* ``temperature`` – temperature in Celsius (``int``) or ``None``
Example input::

Routing Engine status: Slot 0: Current state Master Election priority Master (default) Temperature 40 degrees C / 104 degrees F Total memory 2048 MB Memory utilization 65 percent CPU utilization: User 2 percent Background 0 percent Kernel 3 percent Interrupt 0 percent Idle 95 percent Model RE-S-1800x4 Start time: 2024-01-01 00:00:00 UTC Uptime: 10 days, 3 hours, 22 minutes, 15 seconds

parse_fpc_status
parse_fpc_status(output: str) -> list[dict]

Parse show chassis fpc output.

Returns:

Type Description
list

List of FPC slot dicts. Returns an empty list when the output cannot be parsed.

Each returned dict represents one FPC slot:
* ``slot`` – FPC slot index (``int``)
* ``state`` – operational state (e.g. ``'Online'``, ``'Offline'``,

'Empty', 'Present')

* ``cpu_util`` – CPU utilisation % (``int``) or ``None``
* ``memory_used`` – DRAM used in MB (``int``) or ``None``
* ``memory_total`` – total DRAM in MB (``int``) or ``None``
* ``temperature`` – temperature in Celsius (``int``) or ``None``
* ``ok`` – ``True`` when state is ``'Online'`` or ``'Empty'``
Example input::
             Temp  CPU Utilization (%)   Memory  Utilization (%)

Slot State (C) Total Interrupt DRAM (MB) Heap Buffer 0 Online 43 3 0 2048 34 47 1 Online 42 5 1 2048 36 49 2 Empty - - - - - -

parse_interface_errors_junos
parse_interface_errors_junos(output: str) -> list[dict]

Parse show interfaces extensive (or show interfaces detail) output.

Extracts per-interface error counters.

Returns:

Type Description
list

List of per-interface error-counter dicts. Returns an empty list when the output cannot be parsed.

Each returned dict contains:
* ``name`` – interface name (e.g. ``'ge-0/0/0'``, ``'xe-0/1/0'``)
* ``input_errors`` – total input errors (``int``)
* ``output_errors`` – total output errors (``int``)
* ``input_drops`` – input drops/discards (``int``)
* ``output_drops`` – output drops/discards (``int``)
* ``crc_errors`` – CRC/frame-check errors (``int``)
* ``has_errors`` – ``True`` when any counter is > 0
Example excerpt::

Physical interface: ge-0/0/0, Enabled, Physical link is Up Input errors: Errors: 0, Drops: 0, Framing errors: 0, Runts: 0, Giants: 0, Policed discards: 0, L3 incompletes: 0, L2 channel errors: 0, L2 mismatch timeouts: 0, FIFO errors: 0, Resource errors: 0 Output errors: Carrier transitions: 1, Errors: 0, Drops: 0, Collisions: 0, Aged packets: 0, FIFO errors: 0, HS link CRC errors: 0, MTU errors: 0, Resource errors: 0

parse_bgp_summary_junos
parse_bgp_summary_junos(output: str) -> list[dict]

Parse show bgp summary output from JunOS.

Returns:

Type Description
list

List of BGP peer dicts. Returns an empty list when the output cannot be parsed.

Each returned dict contains:
* ``neighbor`` – peer IPv4/IPv6 address (``str``)
* ``peer_as`` – remote AS number (``int``)
* ``state`` – session state (e.g. ``'Established'``, ``'Active'``,

'Idle', 'Connect')

* ``up_down`` – session uptime or time-since-reset string
* ``prefixes_received`` – prefixes received (``int``) when Established,

otherwise None

* ``active_prefixes`` – active prefixes (``int``) or ``None``
Example input::

Groups: 2 Peers: 3 Down peers: 0 Table Tot Paths Act Paths Suppressed History Damp State Pending inet.0 40 38 0 0 0 0 Peer AS InPkt OutPkt OutQ Flaps Last Up/Dwn State|#Active/Received/Accepted/Damped... 10.0.0.1 65001 14621 14609 0 0 5d 3:14 Establ inet.0: 38/40/40/0 10.0.0.2 65002 1823 1821 0 1 1:23:45 Active 10.0.0.3 65003 0 0 0 0 never Connect

parse_ospf_neighbors_junos
parse_ospf_neighbors_junos(output: str) -> list[dict]

Parse show ospf neighbor output from JunOS.

Returns:

Type Description
list

List of OSPF neighbor dicts. Returns an empty list when the output cannot be parsed.

Each returned dict contains:
* ``neighbor_id`` – OSPF Router-ID of the neighbour (``str``)
* ``address`` – neighbour interface IP address (``str``)
* ``interface`` – local interface name (``str``)
* ``state`` – adjacency state (e.g. ``'Full'``, ``'ExStart'``, ``'2Way'``)
* ``dead_time`` – dead-timer countdown in ``HH:MM:SS`` format (``str``)
* ``priority`` – interface priority (``int``)
* ``is_full`` – ``True`` when ``state == 'Full'``
Example input::

Address Interface State ID Pri Dead 10.0.0.2 ge-0/0/0.0 Full 192.168.1.2 1 33 10.0.0.3 ge-0/0/1.0 Full 192.168.1.3 1 35 10.0.0.4 ge-0/0/2.0 ExStart 192.168.1.4 0 38

parse_chassis_alarms
parse_chassis_alarms(output: str) -> list[dict]

Parse show chassis alarms output.

Returns:

Type Description
list

List of alarm dicts. Returns an empty list when no alarms are present or the output cannot be parsed.

Each returned dict represents one active alarm:
* ``time`` – timestamp string (e.g. ``'2024-01-15 10:23:01 UTC'``)
* ``class_`` – alarm class (``'Major'`` or ``'Minor'``)
* ``description`` – alarm description string
* ``is_major`` – ``True`` when class is ``'Major'``
Example input::

2 alarms currently active Alarm time Class Description 2024-01-15 10:23:01 UTC Major FPC 1 Major Errors 2024-01-15 10:30:12 UTC Minor PEM Input Failure

parse_chassis_environment
parse_chassis_environment(output: str) -> dict

Parse show chassis environment output.

Returns:

Type Description
dict

Dict with keys:

  • power_supplies – list of PSU dicts (name, status, ok)
  • fans – list of fan dicts (name, status, ok)
  • temperatures – list of temperature dicts (name, celsius, status, ok)
  • overall_okTrue when every parsed component is OK

Returns a dict with empty lists when the output cannot be parsed.

Example input::

Class Item Status Measurement Power Power Supply 0 OK Power Power Supply 1 Absent Cooling FPC 0 Fan 0 OK 2250 RPM Cooling FPC 0 Fan 1 OK 2250 RPM Temp CPU OK 38 degrees C / 100 degrees F Temp FPC 0 OK 43 degrees C / 109 degrees F

parse_route_summary
parse_route_summary(output: str) -> list[dict]

Parse show route summary output.

Returns:

Type Description
list

List of routing-table summary dicts. Returns an empty list when the output cannot be parsed.

Each returned dict represents one routing table:
* ``table`` – routing table name (e.g. ``'inet.0'``, ``'inet6.0'``)
* ``active_routes`` – number of active (best-path) routes (``int``)
* ``holddown_routes``– routes in holddown state (``int``)
* ``hidden_routes`` – hidden routes (``int``)
* ``total_routes`` – total routes in the table (``int``)
Example input::

Routing table: inet.0 Destinations: 1204 Routes: 1219 Holddown: 0 Hidden: 0 Limit/Threshold: 1048576/1048576 destinations Direct: 3 routes, 3 active Local: 3 routes, 3 active BGP: 1213 routes, 1198 active

parse_lldp_neighbors_junos
parse_lldp_neighbors_junos(output: str) -> list[dict]

Parse show lldp neighbors output from JunOS.

Returns:

Type Description
list

List of LLDP neighbor dicts. Returns an empty list when the output cannot be parsed.

Each returned dict contains:
* ``local_interface`` – local interface name (e.g. ``'ge-0/0/0'``)
* ``parent_interface`` – parent interface (e.g. ``'ae0'``, or ``'-'``)
* ``chassis_id`` – remote chassis ID (MAC address)
* ``port_id`` – remote port identifier or description
* ``system_name`` – remote system name
Example input::

Local Interface Parent Interface Chassis Id Port info System Name ge-0/0/0 - 00:11:22:33:44:55 Ethernet1 switch-1 ge-0/0/1 ae0 00:11:22:33:44:66 ge-0/0/0 router-2 xe-0/1/0 - aa:bb:cc:dd:ee:ff 1/1/1 nokia-3

parse_lacp_interfaces_junos
parse_lacp_interfaces_junos(output: str) -> list[dict]

Parse show lacp interfaces output from JunOS.

Returns:

Type Description
list

List of LACP interface dicts. Returns an empty list when the output cannot be parsed.

Each returned dict contains:
* ``name`` – aggregated interface name (e.g. ``'ae0'``)
* ``protocol`` – LACP protocol state (``'Up'`` / ``'Down'``)
* ``member_count`` – number of member links (``int``)
* ``members`` – list of member dicts, each with:
  • interface – member interface name
  • activity'Active' or 'Passive'
  • state – LACP state flags string (e.g. 'Collecting Distributing')
  • mux_state – MUX machine state (e.g. 'Collecting distributing')
Example input::

Aggregated interface: ae0 LACP state: Role Exp Def Dist Col Syn Aggr Timeout Activity ge-0/0/0 Actor No No Yes Yes Yes Yes Fast Active ge-0/0/0 Partner No No Yes Yes Yes Yes Fast Active ge-0/0/1 Actor No No Yes Yes Yes Yes Fast Active ge-0/0/1 Partner No No Yes Yes Yes Yes Fast Active LACP protocol: Receive State Transmit State Mux State ge-0/0/0 Current Fast periodic Collecting distributing ge-0/0/1 Current Fast periodic Collecting distributing


netops.parsers.nokia_sros

Nokia SR-OS CLI output parsers — interfaces, BGP, OSPF, system info, chassis, environment, routes, and LSPs.

nokia_sros

Parsers for Nokia SR OS CLI output.

Covers classic CLI (7750, 7450, 7210, 7705, 7250 IXR, 7730 SXR) and handles common formatting variations across TiMOS releases.

Functions:
parse_interfaces
parse_interfaces(output: str) -> list[dict]

Parse show port output into a list of interface dicts.

Returns:

Type Description
list

List of interface dicts.

Each dict contains:
* ``name`` – port identifier (e.g. ``'1/1/1'``, ``'1/1/c3/1'``)
* ``status`` – administrative state: ``'Up'`` or ``'Down'``
* ``protocol`` – operational state: ``'Up'`` or ``'Down'``
* ``up`` – ``True`` when both admin and oper state are ``'Up'``
Field names match the Cisco ``parse_cisco_interfaces`` convention so
callers can treat output from both vendors uniformly.
parse_bgp_summary
parse_bgp_summary(output: str) -> list[dict]

Parse show router bgp summary output into a BGP peer list.

Returns:

Type Description
list

List of BGP peer dicts.

Each dict contains:
* ``neighbor`` – peer IPv4 address
* ``description`` – peer description string, or ``None``
* ``peer_as`` – remote AS number (``int``)
* ``received`` – prefixes received / Adj-RIB-In count (``int``)
* ``sent`` – prefixes advertised (``int``)
* ``active`` – active (best-path) prefixes (``int``)
* ``up_down`` – session uptime or time-since-reset (e.g. ``'1d02h'``)
* ``state`` – session state (e.g. ``'Established'``, ``'Active'``)
parse_ospf_neighbors
parse_ospf_neighbors(output: str) -> list[dict]

Parse show router ospf neighbor output into an adjacency list.

Returns:

Type Description
list

List of OSPF neighbor dicts.

Each dict contains:
* ``interface`` – interface or link name (e.g. ``'to-core-1'``)
* ``router_id`` – neighbour router-ID as an IPv4 string
* ``state`` – OSPF adjacency state (e.g. ``'Full'``, ``'Init'``)
* ``priority`` – DR election priority (``int``)
* ``retx_queue`` – retransmit queue length (``int``)
parse_system_info
parse_system_info(output: str) -> dict

Parse show system information output.

Returns:

Type Description
dict

Dict with normalised keys:

  • system_name – configured system name
  • hostname – alias for system_name (for compatibility)
  • contact – admin contact string
  • location – system location
  • description – system description
  • object_id – SNMP sysObjectID
  • uptime – system uptime string
  • last_booted – last boot time
  • current_time – current time on the node
  • chassis_type – chassis model identifier
  • cpu_type – processor info
  • oper_version – running TiMOS version (if shown)
parse_chassis
parse_chassis(output: str) -> dict

Parse show chassis or show chassis detail output.

Returns:

Type Description
dict

Dict with:

  • chassis_type – e.g. '7750 SR-12', '7210 SAS-Sx 10/100GE'
  • part_number – Nokia part number (e.g. '3HE04820AAAB01')
  • serial_number – chassis serial
  • clei_code – CLEI code
  • mac_address – base MAC address
  • firmware – firmware / FPGA version
  • hardware_data – hardware coding
  • oper_state – operational state (Up/Down)
  • admin_state – administrative state
  • temperature – temperature reading (if present)
  • num_slots – number of card slots
  • num_ports – total number of ports
  • num_power – number of power supply modules
  • num_fan – number of fan trays
parse_cards
parse_cards(output: str) -> list[dict]

Parse show card output into a list of card dicts.

Each dict contains:

  • slot – card slot number (str)
  • card_type – provisioned or equipped card type string
  • admin_state'up' or 'down'
  • oper_state'up', 'down', 'provisioned', etc.
  • serial – serial number (from show card detail, may be None)
  • part_number – part number (from detail, may be None)
  • equipped_type – equipped type (may differ from provisioned)
parse_mda
parse_mda(output: str) -> list[dict]

Parse show mda output into a list of MDA dicts.

Each dict contains:

  • slot – slot/mda identifier (e.g. '1/1')
  • mda_type – provisioned MDA type
  • admin_state'up' or 'down'
  • oper_state – operational state
  • serial – serial number (None if not in output)
  • equipped_type – equipped type
parse_bof
parse_bof(output: str) -> dict

Parse show bof (Boot Options File) output.

Returns:

Type Description
dict

Dict with:

  • primary_image – primary boot image path
  • secondary_image – secondary boot image path
  • tertiary_image – tertiary boot image path
  • primary_config – primary config file path
  • secondary_config – secondary config file path
  • address – management IP address
  • prefix_length – management prefix length
  • static_route – static route entries (list of str)
  • dns_domain – DNS domain name
  • dns_server – DNS server IP
  • autonegotiate – auto-negotiate setting
  • duplex – duplex setting
  • speed – speed setting
  • wait_time – boot wait time
  • persist – persist on/off
  • console_speed – console baud rate
parse_version
parse_version(output: str) -> dict

Parse show version output.

Returns:

Type Description
dict

Dict with:

  • timos_version – full TiMOS version string
  • version – short version number (e.g. '23.10.R1')
  • build_date – build date/time if present
  • sros_version – SR OS version if shown separately
  • cpm_type – CPM module type
  • chassis_type – chassis/platform type
parse_service_summary
parse_service_summary(output: str) -> list[dict]

Parse show service service-using output.

Returns:

Type Description
list

List of dicts with:

  • service_id – service ID (int)
  • service_type – type string (e.g. 'VPLS', 'VPRN', 'Epipe')
  • admin_state'Up' or 'Down'
  • oper_state'Up' or 'Down'
  • customer_id – customer ID (int)
  • name – service name
parse_lag
parse_lag(output: str) -> list[dict]

Parse show lag output.

Returns:

Type Description
list

List of dicts with:

  • lag_id – LAG identifier (int)
  • admin_state'up' or 'down'
  • oper_state'up' or 'down'
  • port_count – number of member ports (int)
  • active_ports – number of active ports (int)
  • description – LAG description
  • lacp_mode – LACP mode ('active', 'passive', or None)
  • members – list of member port strings
parse_router_interface
parse_router_interface(output: str) -> list[dict]

Parse show router interface output.

Returns:

Type Description
list

List of dicts with:

  • name – interface name
  • ip_address – IPv4 address (or None)
  • admin_state'Up' or 'Down'
  • oper_state'Up' or 'Down' (may include protocol state)
  • protocol – protocol state ('Up' or 'Down')
  • port – bound SAP or port (None if system)
parse_lldp_neighbors
parse_lldp_neighbors(output: str) -> list[dict]

Parse show system lldp neighbor output.

Returns:

Type Description
list

List of dicts with:

  • local_interface – local port identifier
  • chassis_id – remote chassis ID (MAC or network address)
  • port_id – remote port identifier
  • system_name – remote system name (or None)
  • system_description – remote system description (or None)
Example input::

=============================================================================== Link Layer Discovery Protocol (LLDP) System Information =============================================================================== NB = nearest-bridge NTPMR = nearest-non-tpmr NC = nearest-customer

=============================================================================== LLDP Neighbor Information =============================================================================== Lcl Port Scope Remote Chassis ID Index Remote Port Remote Sys Name


1/1/1 NB 00:11:22:33:44:55 1 Ethernet1 switch-1 1/1/2 NB 00:11:22:33:44:66 2 Ethernet2 switch-2 1/1/c3/1 NB 00:AA:BB:CC:DD:EE 3 ge-0/0/0 router-3


No. of Neighbors: 3

netops.parsers.paloalto

Palo Alto PAN-OS CLI output parsers — system info, interfaces, routes, sessions, security policy, and HA state.

paloalto

Parsers for Palo Alto Networks PAN-OS CLI output.

Supports structured output for the core show commands used by health checks and security policy audits.

Functions:
parse_system_info
parse_system_info(output: str) -> dict

Parse show system info output from a PAN-OS device.

Returns:

Type Description
dict

Dict with keys:

  • hostname – device hostname (e.g. 'pa-fw-01')
  • ip_address – management IP address
  • model – hardware model (e.g. 'PA-3220')
  • serial – chassis serial number
  • panos_version – PAN-OS software version (e.g. '10.2.3')
  • app_version – application content version
  • threat_version – threat content version
  • url_version – URL filtering database version
  • ha_mode – HA operating mode (e.g. 'Active-Passive'), or None
  • ha_state – local HA state (e.g. 'active'), or None

Returns a dict with None values for any field that cannot be parsed.

Example input lines::

Hostname: pa-fw-01 IP address: 10.0.0.1 Model: PA-3220 Serial: 0123456789AB PAN-OS Version: 10.2.3 App version: 8700-7709 Threat version: 8700-7709 URL filtering version: 20231201.20079 HA mode: Active-Passive HA state: active

parse_interfaces
parse_interfaces(output: str) -> list[dict]

Parse show interface all output from a PAN-OS device.

Returns:

Type Description
list

List of per-interface dicts. Returns an empty list when the output cannot be parsed.

Each returned dict contains:
* ``name`` – interface name (e.g. ``'ethernet1/1'``)
* ``state`` – interface state: ``'up'`` or ``'down'``
* ``ip`` – IP address with prefix length (e.g. ``'10.0.1.1/24'``),

or None when unassigned

* ``vsys`` – virtual system the interface belongs to
* ``zone`` – security zone, or ``None`` when not displayed
* ``up`` – ``True`` when state is ``'up'``
Example input lines::

Name State IP (prefix) VSys Zone ethernet1/1 up 10.0.1.1/24 vsys1 trust ethernet1/2 up 203.0.113.1/30 vsys1 untrust ethernet1/3 down unassigned vsys1 loopback.1 up 1.1.1.1/32 vsys1

parse_routes
parse_routes(output: str) -> list[dict]

Parse show routing route output from a PAN-OS device.

Returns:

Type Description
list

List of per-route dicts. Returns an empty list when the output cannot be parsed.

Each returned dict contains:
* ``destination`` – destination prefix in CIDR notation
* ``nexthop`` – next-hop IP address, or ``'0.0.0.0'`` for connected routes
* ``metric`` – route metric (``int``)
* ``flags`` – raw flags string (e.g. ``'A S'``)
* ``active`` – ``True`` when the ``A`` (active) flag is set
* ``type`` – route type letter(s) extracted from flags

('C' connected, 'S' static, 'B' BGP, etc.)

* ``age`` – route age string (e.g. ``'1d'``), or ``None``
* ``interface`` – egress interface name
Example input lines::

destination nexthop metric flags age interface 0.0.0.0/0 10.0.0.1 10 A S 1d ethernet1/2 10.0.1.0/24 0.0.0.0 0 A C - ethernet1/1 10.0.0.0/8 192.168.1.1 10 A B 1d ethernet1/2

parse_session_info
parse_session_info(output: str) -> dict

Parse show session info output from a PAN-OS device.

Returns:

Type Description
dict

Dict with keys:

  • max_sessions – maximum supported sessions (int)
  • active_sessions – current active sessions (int)
  • active_tcp – active TCP sessions (int)
  • active_udp – active UDP sessions (int)
  • active_icmp – active ICMP sessions (int)
  • session_utilization – session table utilization percentage (float)

Any field that cannot be parsed will be None.

Example input lines::

Number of sessions supported: 131072 Number of active sessions: 1234 Number of active TCP sessions: 1000 Number of active UDP sessions: 200 Number of active ICMP sessions: 34 Session utilization: 1%

parse_security_policy
parse_security_policy(output: str) -> list[dict]

Parse show running security-policy output from a PAN-OS device.

Returns:

Type Description
list

List of per-policy dicts. Returns an empty list when the output cannot be parsed.

Each returned dict represents one security rule and contains:
* ``name`` – rule name
* ``from_zones`` – list of source security zones
* ``to_zones`` – list of destination security zones
* ``sources`` – list of source address objects / prefixes
* ``destinations`` – list of destination address objects / prefixes
* ``applications`` – list of application names
* ``services`` – list of service objects
* ``action`` – rule action: ``'allow'``, ``'deny'``, or ``'drop'``
Example input::

Rule: web-access from trust to untrust source [ any ] destination [ any ] application [ web-browsing ssl ] service [ application-default ] action allow Rule: block-all from any to any source [ any ] destination [ any ] application [ any ] service [ any ] action deny

parse_security_policy_stats
parse_security_policy_stats(output: str) -> list[dict]

Parse show security policy statistics output from a PAN-OS device.

Returns:

Type Description
list

List of per-policy stats dicts. Returns an empty list when the output cannot be parsed.

Each returned dict contains:
* ``name`` – rule name
* ``hit_count`` – number of times the rule has been matched (``int``)
* ``last_hit`` – last hit timestamp string, or ``None``
Example input::

Rule Name Hit Count Last Hit Date web-access 1523 2024-03-24 06:00:00 block-malware 45 2024-03-23 12:00:00 allow-dns 0 never unused-rule 0 never

parse_ha_state
parse_ha_state(output: str) -> dict

Parse show high-availability state output from a PAN-OS device.

Returns:

Type Description
dict

Dict with keys:

  • enabledTrue when HA is configured
  • mode – HA mode string (e.g. 'Active-Passive'), or None
  • local_state – local HA state (e.g. 'active'), or None
  • peer_state – peer HA state (e.g. 'passive'), or None
  • peer_ip – peer management IP address, or None
  • preemptiveTrue when preemptive failover is enabled

Returns defaults (enabled=False, all other fields None / False) when the output cannot be parsed or HA is not configured.

Example input lines::

Group 1: Mode: Active-Passive Local state: active Peer state: passive Peer IP: 192.168.1.2 Preemptive: no


netops.parsers.vlan

Cisco VLAN CLI parsers — VLAN brief table, trunk interfaces.

vlan

Parsers for VLAN CLI output.

Supports Cisco IOS/IOS-XE:

  • show vlan brief → :func:parse_vlan_brief
  • show interfaces trunk → :func:parse_interfaces_trunk

Utility:

  • :func:expand_vlan_range — expands VLAN range strings ("1,10-20,100")
Functions:
expand_vlan_range
expand_vlan_range(ranges: str) -> set[int]

Expand a VLAN range string into a set of integer VLAN IDs.

Handles comma-separated lists and dash-delimited ranges:

  • "10"{10}
  • "10,20,30"{10, 20, 30}
  • "10-14"{10, 11, 12, 13, 14}
  • "1,10-12,20"{1, 10, 11, 12, 20}
  • "none"set()
  • ""set()

Non-parseable tokens are silently ignored.

Returns:

Type Description
set

Set of integer VLAN IDs.

parse_vlan_brief
parse_vlan_brief(output: str) -> list[dict]

Parse show vlan brief output.

Handles Cisco IOS and IOS-XE formats.

Returns:

Type Description
list

List of per-VLAN dicts. Returns an empty list when the output cannot be parsed.

Each returned dict contains:
* ``vlan_id`` – VLAN ID (``int``)
* ``name`` – VLAN name (``str``)
* ``status`` – status string, e.g. ``'active'``, ``'act/unsup'``
* ``ports`` – list of access-port names assigned to this VLAN
parse_interfaces_trunk
parse_interfaces_trunk(output: str) -> list[dict]

Parse show interfaces trunk output.

Handles Cisco IOS and IOS-XE formats. The command output is divided into four stanzas; all four are parsed and merged per-port:

  1. Port / Mode / Encapsulation / Status / Native VLAN
  2. Port / VLANs allowed on trunk
  3. Port / VLANs allowed and active in management domain
  4. Port / VLANs in spanning tree forwarding state and not pruned

Returns:

Type Description
list

List of per-interface trunk dicts. Returns an empty list when the output cannot be parsed or contains no trunking ports.

Each returned dict contains:
* ``port`` – interface name
* ``mode`` – trunk mode (``'on'``, ``'auto'``, ``'desirable'``, …)
* ``encapsulation`` – ``'802.1q'``, ``'isl'``, or ``'n-802.1q'``
* ``status`` – ``'trunking'`` or ``'not-trunking'``
* ``native_vlan`` – native VLAN ID (``int``)
* ``allowed_vlans`` – raw allowed-VLAN string (e.g. ``'1-4094'``)
* ``active_vlans`` – set of active VLAN IDs (``set[int]``)
* ``forwarding_vlans`` – set of forwarding VLAN IDs (``set[int]``)