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?
The only operating system that appears to implement an
xml()method is NX-OS, and it looks roughly like this:The
| xmlsuffix 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 separatexml()method, sincecli()could already accommodate this variation. For example, the same behavior could be modeled as:cli(..., xml_pipe=True)), where output format is treated as a retrieval option rather than a separate API surface, orShowBgpAllDampeningFlapStatisticsXmlvsShowBgpAllDampeningFlapStatistics) with its owncli()method and potentially a different schema if XML output differs meaningfully from CLI output.A few additional downsides and concerns when comparing
xml()tocli()are:xml()methods (see: Does folder_parsing_job.py support yang() and xml() tests? #989)pyats parsecommand does not appear to supportxml()methods, despite them being very similar tocli()in terms of transport and execution mechanismGiven 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?