Repository: networktocode/ntc-templates

Issue:
cisco_ios_show_power_inline.textfsm issue with the word "faulty"
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)



Discussion:

Patch:
diff --git a/ntc_templates/templates/cisco_ios_show_power_inline.textfsm b/ntc_templates/templates/cisco_ios_show_power_inline.textfsm
index 466534fe9c..a260a445a5 100644
--- a/ntc_templates/templates/cisco_ios_show_power_inline.textfsm
+++ b/ntc_templates/templates/cisco_ios_show_power_inline.textfsm
@@ -1,6 +1,6 @@
 Value INTERFACE (\S+)
 Value ADMIN_STATUS (\S+)
-Value OPERATIONAL_STATUS (on|off)
+Value OPERATIONAL_STATUS (\S+)
 Value POWER (\d+\.\d+)
 Value DEVICE (\S+(\s\S+)*)
 Value CLASS (\d|n/a)


Test patch:
diff --git a/tests/cisco_ios/show_power_inline/cisco_ios_show_power_inline_faulty.raw b/tests/cisco_ios/show_power_inline/cisco_ios_show_power_inline_faulty.raw
new file mode 100644
index 0000000000..09f923ea64
--- /dev/null
+++ b/tests/cisco_ios/show_power_inline/cisco_ios_show_power_inline_faulty.raw
@@ -0,0 +1,12 @@
+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 
diff --git a/tests/cisco_ios/show_power_inline/cisco_ios_show_power_inline_faulty.yml b/tests/cisco_ios/show_power_inline/cisco_ios_show_power_inline_faulty.yml
new file mode 100644
index 0000000000..8f5d094915
--- /dev/null
+++ b/tests/cisco_ios/show_power_inline/cisco_ios_show_power_inline_faulty.yml
@@ -0,0 +1,37 @@
+---
+parsed_sample:
+  - admin_status: "auto"
+    class: "1"
+    device: "Ieee PD"
+    interface: "Gi2/0/21"
+    max: "30.0"
+    operational_status: "on"
+    power: "3.8"
+  - admin_status: "auto"
+    class: "2"
+    device: "Ieee PD"
+    interface: "Gi2/0/35"
+    max: "30.0"
+    operational_status: "on"
+    power: "6.0"
+  - admin_status: "auto"
+    class: "n/a"
+    device: "n/a"
+    interface: "Gi2/0/36"
+    max: "30.0"
+    operational_status: "off"
+    power: "0.0"
+  - admin_status: "auto"
+    class: "n/a"
+    device: "n/a"
+    interface: "Gi2/0/37"
+    max: "30.0"
+    operational_status: "off"
+    power: "0.0"
+  - admin_status: "auto"
+    class: "n/a"
+    device: "n/a"
+    interface: "Gi2/0/38"
+    max: "30.0"
+    operational_status: "faulty"
+    power: "0.0"