Skip to content

Does the xml() method in Genie parsers provide any value beyond what cli() already gives us? #990

@MilosQL

Description

@MilosQL

The only operating system that appears to implement an xml() method is NX-OS, and it looks roughly like this:

cli_command = 'show bgp all dampening flap-statistics'
xml_command = 'show bgp all dampening flap-statistics | xml'

#...

def cli(self, output=None):
    if output is None:
        out = self.device.execute(self.cli_command)
    else:
        out = output

    # Init vars
    ret_dict = {}
    # ...

def xml(self):
    out = self.device.execute(self.xml_command)
    # ...

The | xml suffix is simply an additional CLI modifier that changes the output format returned by the device. From an API and caller perspective, it is not clear that this justifies introducing a separate xml() method, since cli() could already accommodate this variation. For example, the same behavior could be modeled as:

  • an argument on the existing method (e.g., cli(..., xml_pipe=True)), where output format is treated as a retrieval option rather than a separate API surface, or
  • a separate parser class (e.g., ShowBgpAllDampeningFlapStatisticsXml vs ShowBgpAllDampeningFlapStatistics) with its own cli() method and potentially a different schema if XML output differs meaningfully from CLI output.

A few additional downsides and concerns when comparing xml() to cli() are:

Given that xml() primarily represents an alternative output format of the same command, is there a clear design rationale or practical benefit for keeping it as a separate public method in Genie parsers?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions