CiscoTestAutomation / genieparser

sub-component of Genie that parse the device output into structured datastructure
Apache License 2.0
251 stars 388 forks source link

IOS XR Parser for ISIS (ShowIsis) #163

Closed filippohronsky closed 4 years ago

filippohronsky commented 4 years ago

Genie generate error due a missing keys.

`Issue while parsing: <class 'genie.libs.parser.iosxr.show_isis.ShowIsis'>

Traceback (most recent call last):
  File "src/genie/cli/commands/learn.py", line 343, in genie.cli.commands.learn.LearnCommand._retrieve_ops
  File "/home/mpls/fipo/lib64/python3.6/site-packages/genie/libs/ops/isis/iosxr/isis.py", line 313, in learn
    self.make()
  File "/home/mpls/fipo/lib64/python3.6/site-packages/genie/ops/base/base.py", line 101, in make
    self.maker.make(*args, **kwargs)
  File "src/genie/ops/base/maker.py", line 312, in genie.ops.base.maker.Maker.make
  File "src/genie/ops/base/maker.py", line 418, in genie.ops.base.maker.Maker._call_parser
  File "src/genie/metaparser/_metaparser.py", line 302, in genie.metaparser._metaparser.MetaParser.parse
  File "src/genie/metaparser/_metaparser.py", line 284, in genie.metaparser._metaparser.MetaParser.parse
  File "src/genie/metaparser/util/schemaengine.py", line 405, in genie.metaparser.util.schemaengine.Schema.validate
genie.metaparser.util.exceptions.SchemaMissingKeyError: Missing keys: [['instance', 'core', 'vrf', 'default', 'topology', 'IPv4 Unicast', 'vrf', 'default', 'protocols_redistributed']]`
filippohronsky commented 4 years ago

There is nothing abour vrf in show isis command on ios xr. But in the class ShowIsis there is mention about vrf

from IOX-XR device: in RP/0/RSP0/CPU0:A910#show isis | i VRF Thu Jun 4 13:10:37.981 CEST RP/0/RSP0/CPU0:A910#show isis | i vrf Thu Jun 4 13:10:40.931 CEST RP/0/RSP0/CPU0:A910#

ahersi2-cisco commented 4 years ago

Hi @filippohronsky,

Thanks for reporting this issue. There is a new version of genie.libs.parser that is available. Can you try updating your version if you haven't already and give it a shot again if you don't mind?

Thank you, Abdurahman

filippohronsky commented 4 years ago

Hi Abdurahman, thank you for your effort.

I had already used the latest version of genie.libs.parser.

(fi) [user@localhost fi]$ pip install --upgrade genie.libs.parser Requirement already up-to-date: genie.libs.parser in ./lib/python3.6/site-packages (20.5) Requirement already satisfied, skipping upgrade: xmltodict in ./lib/python3.6/site-packages (from genie.libs.parser) (0.12.0)

Still result is the same:

(fi) [user@localhost lab]$ cat isis_iosxr_A9K_exception.txt Issue while parsing: <class 'genie.libs.parser.iosxr.show_isis.ShowIsis'>

Traceback (most recent call last): File "src/genie/cli/commands/learn.py", line 343, in genie.cli.commands.learn.LearnCommand._retrieve_ops File "/home/user/fi/lib64/python3.6/site-packages/genie/libs/ops/isis/iosxr/isis.py", line 313, in learn self.make() File "/home/user/fi/lib64/python3.6/site-packages/genie/ops/base/base.py", line 101, in make self.maker.make(*args, **kwargs) File "src/genie/ops/base/maker.py", line 312, in genie.ops.base.maker.Maker.make File "src/genie/ops/base/maker.py", line 418, in genie.ops.base.maker.Maker._call_parser File "src/genie/metaparser/_metaparser.py", line 302, in genie.metaparser._metaparser.MetaParser.parse File "src/genie/metaparser/_metaparser.py", line 284, in genie.metaparser._metaparser.MetaParser.parse File "src/genie/metaparser/util/schemaengine.py", line 392, in genie.metaparser.util.schemaengine.Schema.validate genie.metaparser.util.exceptions.SchemaMissingKeyError: Missing keys: [['instance', 'core', 'vrf', 'default', 'topology', 'IPv4 Unicast', 'vrf', 'default', 'protocols_redistributed']]

Kind regards, Filip Pohronský

Od: ahersi2-cisco notifications@github.com Príjemca odpovede: CiscoTestAutomation/genieparser reply@reply.github.com Dátum: piatok, 5. júna 2020, 22:16 Komu: CiscoTestAutomation/genieparser genieparser@noreply.github.com Kópia: Pohronsky Filip Pohronsky@ditec.sk, Mention mention@noreply.github.com Predmet: Re: [CiscoTestAutomation/genieparser] IOS XR Parser for ISIS (ShowIsis) (#163)

Hi @filippohronskyhttps://github.com/filippohronsky,

Thanks for reporting this issue. There is a new version of genie.libs.parser that is available. Can you try updating your version if you haven't already and give it a shot again if you don't mind?

Thank you, Abdurahman

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://github.com/CiscoTestAutomation/genieparser/issues/163#issuecomment-639776641, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AF4V5NFK2ZCPVRIHNCANZCDRVFHBBANCNFSM4NSKERYQ.

ahersi2-cisco commented 4 years ago

Hi @filippohronsky,

Thanks for the response. Can you please provide the CLI output?

Thank you, Abdurahman

filippohronsky commented 4 years ago
(fi) [user@localhost lab]$ genie learn isis  --device 'A9K10' --via 'A9K10:cli' --testbed-file testbed/reduced_testbed.yaml 

Learning '['isis']' on devices '['A9K10']'
100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 1/1 [00:01<00:00,  1.01s/it]
+==============================================================================+
| Genie Learn Summary for device A9K10                                      |
+==============================================================================+
|  Connected to A9K10                                                       |
|  -   Log: ./connection_A9K10.txt                                          |
|------------------------------------------------------------------------------|
|  Could not learn feature 'isis'                                              |
|  -  Exception:      ./isis_iosxr_A9K10_exception.txt                      |
|  -  Ops structure:  ./isis_iosxr_A9K10_ops.txt                            |
|  -  Device Console: ./isis_iosxr_A9K10_console.txt                        |
|==============================================================================|

(fi) [user@localhost lab]$ cat 
^C
(fi) [user@localhost lab]$ cat isis_iosxr_A9K10_exception.txt
Issue while parsing: <class 'genie.libs.parser.iosxr.show_isis.ShowIsis'>

Traceback (most recent call last):
  File "src/genie/cli/commands/learn.py", line 343, in genie.cli.commands.learn.LearnCommand._retrieve_ops
  File "/home/mpls/fipo/lib64/python3.6/site-packages/genie/libs/ops/isis/iosxr/isis.py", line 313, in learn
    self.make()
  File "/home/mpls/fipo/lib64/python3.6/site-packages/genie/ops/base/base.py", line 101, in make
    self.maker.make(*args, **kwargs)
  File "src/genie/ops/base/maker.py", line 312, in genie.ops.base.maker.Maker.make
  File "src/genie/ops/base/maker.py", line 418, in genie.ops.base.maker.Maker._call_parser
  File "src/genie/metaparser/_metaparser.py", line 302, in genie.metaparser._metaparser.MetaParser.parse
  File "src/genie/metaparser/_metaparser.py", line 284, in genie.metaparser._metaparser.MetaParser.parse
  File "src/genie/metaparser/util/schemaengine.py", line 392, in genie.metaparser.util.schemaengine.Schema.validate
genie.metaparser.util.exceptions.SchemaMissingKeyError: Missing keys: [['instance', 'core', 'vrf', 'default', 'topology', 'IPv4 Unicast', 'vrf', 'default', 'protocols_redistributed']]
(fipo) [mpls@localhost lab]$ 
filippohronsky commented 4 years ago

Hi @ahersi2-cisco, here is also output of show isis command. In genieparser there is mention about vrf, but show isis command isn't include that information.

RP/0/RSP0/CPU0:A9K10#show isis
Tue Jun  9 07:59:23.124 CEST

IS-IS Router: core
  System Id: 0000.0000.0064 
  Instance Id: 0
  IS Levels: level-1
  Manual area address(es):
    01
  Routing for area address(es):
    01
  Non-stop forwarding: Cisco Proprietary NSF Restart enabled
  Most recent startup mode: Cold Restart
  TE connection status: Down
  Topologies supported by IS-IS:
    IPv4 Unicast
      Level-1
        Metric style (generate/accept): Wide/Wide
        Metric: 10
        ISPF status: Disabled
        TE Enabled
      Redistributing:
        BGP AS 65535
      Distance: 115
      Advertise Passive Interface Prefixes Only: Yes
  SRLB not allocated
  SRGB not allocated
  Interfaces supported by IS-IS:
    Bundle-Ether2 is running suppressed (active in configuration)
    Loopback0 is running passively (passive in configuration)
    GigabitEthernet0/2/0/0 is running suppressed (active in configuration)
    TenGigE0/2/1/2 is running suppressed (active in configuration)
    TenGigE0/2/1/3 is disabled (active in configuration)

Parser: genieparser/src/genie/libs/parser/iosxr/show_isis.py

class ShowIsisSchema(MetaParser):
    ''' Schema for commands:
        * show isis
        * show isis protocol
    '''
    schema = {
        'instance': {
            Any(): {
                'process_id': str,
                'instance': str,
                **'vrf': {
                    Any(): {**
                        'system_id': str,
                        'is_levels': str,
                        Optional('manual_area_address'): list,
                        Optional('routing_area_address'): list,

Hopefully, it was helpful.

ahersi2-cisco commented 4 years ago

Hi @filippohronsky,

Sorry for the late reply, and thanks for providing the supporting information. A small tweak in the schema of this parser will fix your issue. The key called ;

protocols_redistributed

Can be changed to be an optional key. You should see other keys with similar behavior in the code. It should be around line 496 of show_isis.py file in the iosxr directory. Feel free to submit a PR if this change works for you, and if it doesn't please let me know.

Thank you, Abdurahman