Last active
September 23, 2020 22:50
-
-
Save h4ndzdatm0ld/9f7975fa6a49d7815adb70975498d41b to your computer and use it in GitHub Desktop.
Nornir Walkthrough 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_vrfcli(task, servicename): | |
''' Retrieve VRF from IOSXR | |
''' | |
vrf = task.run(netmiko_send_command, command_string=f"sh vrf {servicename} detail") | |
print_result(vrf) | |
def get_vprncli(task, servicename): | |
''' Retrieve VPRN from Nokia | |
''' | |
vprn = task.run(netmiko_send_command, command_string=f"show service id {servicename} base") | |
print_result(vprn) | |
def cli_stats(task, **kwargs): | |
''' Revert to CLI scraping automation to retrieve simple show commands and verify status of Services / L3 connectivity. | |
''' | |
# Load Yaml file to extract specific vars | |
vars_yaml = f"vars/{task.host}.yml" | |
vars_data = task.run(task=load_yaml, file=vars_yaml) | |
# Capture the Service Name: | |
servicename = vars_data.result['VRF'][0]['SERVICE_NAME'] | |
if task.host.platform == 'alcatel_sros': | |
get_vprncli(task, servicename) | |
elif task.host.platform == 'iosxr': | |
get_vrfcli(task, servicename) | |
else: | |
print(f"{task.host.platform} Not supported in this runbook") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment