Skip to content

cisco_ios_show_power_inline.textfsm issue with the word "faulty" #2099

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

Open
Mikeg2881 opened this issue Apr 9, 2025 · 3 comments · May be fixed by #2101
Open

cisco_ios_show_power_inline.textfsm issue with the word "faulty" #2099

Mikeg2881 opened this issue Apr 9, 2025 · 3 comments · May be fixed by #2101

Comments

@Mikeg2881
Copy link

Model WS-C3850-48P
Version Version 03.06.03E
It doesn't like the word fault

from ntc_templates.parse import parse_output

platform="cisco_ios"
poe_output_4 = """
Module   Available     Used     Remaining
          (Watts)     (Watts)    (Watts) 
------   ---------   --------   ---------
1          1440.0      107.0      1333.0
Interface Admin  Oper       Power   Device              Class Max
                            (Watts)                            
--------- ------ ---------- ------- ------------------- ----- ----
Gi1/0/1   auto   off        0.0     n/a                 n/a   30.0 
Gi1/0/2   auto   off        0.0     n/a                 n/a   30.0 
Gi1/0/3   auto   off        0.0     n/a                 n/a   30.0 
Gi1/0/4   auto   off        0.0     n/a                 n/a   30.0 
Gi1/0/5   auto   off        0.0     n/a                 n/a   30.0 
Gi1/0/6   auto   off        0.0     n/a                 n/a   30.0 
Gi1/0/7   auto   off        0.0     n/a                 n/a   30.0 
Gi1/0/8   auto   off        0.0     n/a                 n/a   30.0 
Gi1/0/9   auto   on         6.0     Ieee PD             2     30.0 
Gi1/0/10  auto   off        0.0     n/a                 n/a   30.0 
Gi1/0/11  auto   on         6.0     Ieee PD             2     30.0 
Gi1/0/12  auto   off        0.0     n/a                 n/a   30.0 
Gi1/0/13  auto   off        0.0     n/a                 n/a   30.0 
Gi1/0/14  auto   on         6.0     Ieee PD             2     30.0 
Gi1/0/15  auto   off        0.0     n/a                 n/a   30.0 
Gi1/0/16  auto   off        0.0     n/a                 n/a   30.0 
Gi1/0/17  auto   off        0.0     n/a                 n/a   30.0 
Gi1/0/18  auto   off        0.0     n/a                 n/a   30.0 
Gi1/0/19  auto   off        0.0     n/a                 n/a   30.0 
Gi1/0/20  auto   off        0.0     n/a                 n/a   30.0 
Gi1/0/21  auto   off        0.0     n/a                 n/a   30.0 
Gi1/0/22  auto   on         6.0     Ieee PD             2     30.0 
Gi1/0/23  auto   off        0.0     n/a                 n/a   30.0 
Gi1/0/24  auto   off        0.0     n/a                 n/a   30.0 
Gi1/0/25  auto   off        0.0     n/a                 n/a   30.0 
Gi1/0/26  auto   off        0.0     n/a                 n/a   30.0 
Gi1/0/27  auto   on         6.0     Ieee PD             2     30.0 
Gi1/0/28  auto   off        0.0     n/a                 n/a   30.0 
Gi1/0/29  auto   off        0.0     n/a                 n/a   30.0 
Gi1/0/30  auto   off        0.0     n/a                 n/a   30.0 
Gi1/0/31  auto   off        0.0     n/a                 n/a   30.0 
Gi1/0/32  auto   off        0.0     n/a                 n/a   30.0 
Gi1/0/33  auto   on         6.0     Ieee PD             2     30.0 
Gi1/0/34  auto   off        0.0     n/a                 n/a   30.0 
Gi1/0/35  auto   on         6.0     Ieee PD             2     30.0 
Gi1/0/36  auto   off        0.0     n/a                 n/a   30.0 
Gi1/0/37  auto   off        0.0     n/a                 n/a   30.0 
Gi1/0/38  auto   off        0.0     n/a                 n/a   30.0 
Gi1/0/39  auto   on         6.0     Ieee PD             2     30.0 
Gi1/0/40  auto   on         3.8     Ieee PD             1     30.0 
Gi1/0/41  auto   on         6.0     Ieee PD             2     30.0 
Gi1/0/42  auto   on         3.8     Ieee PD             1     30.0 
Gi1/0/43  auto   off        0.0     n/a                 n/a   30.0 
Gi1/0/44  auto   off        0.0     n/a                 n/a   30.0 
Gi1/0/45  auto   on         15.4    Ieee PD             0     30.0 
Gi1/0/46  auto   off        0.0     n/a                 n/a   30.0 
Gi1/0/47  static on         30.0    Ieee PD             4     30.0 
Gi1/0/48  auto   off        0.0     n/a                 n/a   30.0 

Module   Available     Used     Remaining
          (Watts)     (Watts)    (Watts) 
------   ---------   --------   ---------
2          1440.0       75.8      1364.2
Interface Admin  Oper       Power   Device              Class Max
                            (Watts)                            
--------- ------ ---------- ------- ------------------- ----- ----
Gi2/0/1   auto   off        0.0     n/a                 n/a   30.0 
Gi2/0/2   auto   off        0.0     n/a                 n/a   30.0 
Gi2/0/3   auto   off        0.0     n/a                 n/a   30.0 
Gi2/0/4   auto   off        0.0     n/a                 n/a   30.0 
Gi2/0/5   auto   on         6.0     Ieee PD             2     30.0 
Gi2/0/6   auto   off        0.0     n/a                 n/a   30.0 
Gi2/0/7   auto   off        0.0     n/a                 n/a   30.0 
Gi2/0/8   auto   off        0.0     n/a                 n/a   30.0 
Gi2/0/9   auto   off        0.0     n/a                 n/a   30.0 
Gi2/0/10  auto   off        0.0     n/a                 n/a   30.0 
Gi2/0/11  auto   off        0.0     n/a                 n/a   30.0 
Gi2/0/12  auto   off        0.0     n/a                 n/a   30.0 
Gi2/0/13  auto   on         6.0     Ieee PD             2     30.0 
Gi2/0/14  auto   off        0.0     n/a                 n/a   30.0 
Gi2/0/15  auto   off        0.0     n/a                 n/a   30.0 
Gi2/0/16  auto   on         6.0     Ieee PD             2     30.0 
Gi2/0/17  auto   on         6.0     Ieee PD             2     30.0 
Gi2/0/18  auto   on         6.0     Ieee PD             2     30.0 
Gi2/0/19  auto   on         6.0     Ieee PD             2     30.0 
Gi2/0/20  auto   on         6.0     Ieee PD             2     30.0 
Gi2/0/21  auto   on         3.8     Ieee PD             1     30.0 
Gi2/0/22  auto   off        0.0     n/a                 n/a   30.0 
Gi2/0/23  auto   off        0.0     n/a                 n/a   30.0 
Gi2/0/24  auto   off        0.0     n/a                 n/a   30.0 
Gi2/0/25  auto   off        0.0     n/a                 n/a   30.0 
Gi2/0/26  auto   off        0.0     n/a                 n/a   30.0 
Gi2/0/27  auto   off        0.0     n/a                 n/a   30.0 
Gi2/0/28  auto   off        0.0     n/a                 n/a   30.0 
Gi2/0/29  auto   off        0.0     n/a                 n/a   30.0 
Gi2/0/30  auto   off        0.0     n/a                 n/a   30.0 
Gi2/0/31  auto   on         6.0     Ieee PD             2     30.0 
Gi2/0/32  auto   off        0.0     n/a                 n/a   30.0 
Gi2/0/33  auto   off        0.0     n/a                 n/a   30.0 
Gi2/0/34  auto   off        0.0     n/a                 n/a   30.0 
Gi2/0/35  auto   on         6.0     Ieee PD             2     30.0 
Gi2/0/36  auto   off        0.0     n/a                 n/a   30.0 
Gi2/0/37  auto   off        0.0     n/a                 n/a   30.0 
Gi2/0/38  auto   faulty     0.0     n/a                 n/a   30.0 
Gi2/0/39  auto   off        0.0     n/a                 n/a   30.0 
Gi2/0/40  auto   off        0.0     n/a                 n/a   30.0 
Gi2/0/41  auto   off        0.0     n/a                 n/a   30.0 
Gi2/0/42  auto   on         6.0     Ieee PD             2     30.0 
Gi2/0/43  auto   on         6.0     Ieee PD             2     30.0 
Gi2/0/44  auto   on         6.0     Ieee PD             2     30.0 
Gi2/0/45  auto   off        0.0     n/a                 n/a   30.0 
Gi2/0/46  auto   off        0.0     n/a                 n/a   30.0 
Gi2/0/47  auto   off        0.0     n/a                 n/a   30.0 
Gi2/0/48  auto   off        0.0     n/a                 n/a   30.0 
"""

data_entries=[poe_output_4]

for entry in data_entries:

    try:
        print("")
        show_power_inline_parsed = parse_output(platform=platform, command="show power inline", data=entry)
        print("===========================") 
        print(show_power_inline_parsed)
        print("===========================")

    except Exception as e:
        print(f"Error occurred: {e}")

CLI Output
Error occurred: State Error raised. Rule Line: 26. Input Line: Gi2/0/38 auto faulty 0.0 n/a n/a 30.0

I am using the most recent textfsm file

Value INTERFACE (\S+)
Value ADMIN_STATUS (\S+)
Value OPERATIONAL_STATUS (on|off)
Value POWER (\d+\.\d+)
Value DEVICE (\S+(\s\S+)*)
Value CLASS (\d|n/a)
Value MAX (\d+\.\d+)

Start
  ^Interface\s+Admin\s+Oper\s+Power\s+Device\s+Class\s+Max\s*$$ -> Interfaces
  ^Interface\s+Admin\s+Oper\s+Power\(Watts\)\s+Device\s+Class\s*$$ -> Interfaces45xx
  ^Available:
  ^Module
  ^\d+
  ^-+
  ^\s+\(Watts\)
  ^\s*$$
  ^. -> Error

Interfaces
  ^\s*${INTERFACE}\s+${ADMIN_STATUS}\s+${OPERATIONAL_STATUS}\s+${POWER}\s+${DEVICE}\s+${CLASS}\s+${MAX}\s*$$ -> Record
  ^Totals.*
  ^\s+\(Watts\)
  ^-+
  ^\s*$$ -> Start
  ^. -> Error

Interfaces45xx
  ^\s*${INTERFACE}\s+${ADMIN_STATUS}\s+${OPERATIONAL_STATUS}\s+\d+\.\d+\s+${POWER}\s+${DEVICE}\s+${CLASS}\s*$$ -> Record
  ^\s+From\s+PS\s+To\s+Device\s*$$
  ^-+
  ^Totals:.*
  ^. -> Error

It looks like i can just modify and add the word faulty to fix this?
Value OPERATIONAL_STATUS (on|off|faulty)

@mjbear
Copy link
Collaborator

mjbear commented Apr 10, 2025

Model WS-C3850-48P Version Version 03.06.03E It doesn't like the word fault

Module   Available     Used     Remaining
          (Watts)     (Watts)    (Watts) 
------   ---------   --------   ---------
2          1440.0       75.8      1364.2
Interface Admin  Oper       Power   Device              Class Max
                            (Watts)                            
--------- ------ ---------- ------- ------------------- ----- ----
Gi2/0/21  auto   on         3.8     Ieee PD             1     30.0
Gi2/0/35  auto   on         6.0     Ieee PD             2     30.0 
Gi2/0/36  auto   off        0.0     n/a                 n/a   30.0 
Gi2/0/37  auto   off        0.0     n/a                 n/a   30.0 
Gi2/0/38  auto   faulty     0.0     n/a                 n/a   30.0 

It looks like i can just modify and add the word faulty to fix this? Value OPERATIONAL_STATUS (on|off|faulty)

Yes, that is one option.

Another option would be to replace that OPERATIONAL_STATUS capture group regex with another more flexible regex (so if there was a fourth word, it would work by default 😀).

I've tested the flexible regex alternative and it does work, though I've not submitted a pull request yet while we discuss it.

@Mikeg2881
Thoughts?

@Mikeg2881
Copy link
Author

That works better!

@mjbear
Copy link
Collaborator

mjbear commented Apr 11, 2025

That works better!

I created PR #2101 to add flexible support so in case there's another keyword we're not aware of that we should be able to match it once and for all. 😀

Give it a test if you'd like @Mikeg2881 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants