You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A filter get_certificate that takes as input a running configuration and extracts its certificates, similar to the following:
defget_certificate(
configuration: str,
platform: str,
) ->Optional[str]:
"""Extracts certificate from downloaded configuration with all the included special characters and intricacies of a cisco certificate. Args: configuration (str): Running configuration copied from device. platform (str): Device platform. Ex: ios, nxos etc. {{ config | get_certificate("ios")}} {{ "ios" | get_certificate }} Returns: str: Certificates. """# this function is Cisco specific, it can take a list of config commands or the name of a file# with cisco config, parse it and return a specific part based on a regexparse=CiscoConfParse(config=configuration, syntax=platform)
crypto_trustpoint=parse.find_all_children("^crypto pki trustpoint")
crypto_cert_chain=parse.find_all_children("^crypto pki certificate chain")
ifcrypto_trustpointorcrypto_cert_chain:
return"\n".join(["!"] +crypto_trustpoint+ ["!"] +crypto_cert_chain+ ["!"])
returnNone
Use Case
This feature will be useful for config replacement and a simple diff of running and candidate configs that does not include special chars.
The text was updated successfully, but these errors were encountered:
Environment
A
get_certificates
filter needs to be added for configurations that add special characters in their certificates, for example Cisco ios has a hidden tab character: https://napalm.readthedocs.io/en/latest/support/ios.htmlProposed Functionality
A filter
get_certificate
that takes as input a running configuration and extracts its certificates, similar to the following:Use Case
This feature will be useful for config replacement and a simple diff of running and candidate configs that does not include special chars.
The text was updated successfully, but these errors were encountered: