Skip to content

Instantly share code, notes, and snippets.

@clay584
Last active April 18, 2019 03:47
Show Gist options
  • Save clay584/84cac8bf1af717574a79b3a5b898f75e to your computer and use it in GitHub Desktop.
Save clay584/84cac8bf1af717574a79b3a5b898f75e to your computer and use it in GitHub Desktop.
from __future__ import (absolute_import, division, print_function)
__metaclass__ = type
from ansible.errors import AnsibleError
from ansible.module_utils._text import to_bytes, to_native, to_text
from ansible.utils.display import Display
display = Display()
def genie_parse(cli_output, command, platform="iosxe"):
"""
Uses the Cisco pyATS/Genie library to parse cli output into structured data.
:param cli_output: (String) CLI output from Cisco device
:param command: (String) CLI command that was used to generate the cli_output
:param platform: (String) Platform of the device for which cli_output was obtained. Defaults to iosxe.
:return: Dict object conforming to the defined genie parser model.
https://pubhub.devnetcloud.com/media/pyats-packages/docs/genie/genie_libs/#/parsers/show%20version
"""
return to_text("the command sent was {}".format(command))
class FilterModule(object):
''' Cisco pyATS/Genie Parser Filter '''
def filters(self):
return {
# jinja2 overrides
'genie_parse': genie_parse
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment