-
-
Save h4ndzdatm0ld/c787191fc1fb48d509e1a69979bc73bc to your computer and use it in GitHub Desktop.
conditional depeding on ip
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
for x in SR7750: | |
ip = get_ip_only(x) | |
if '10' in ip: | |
print(f'skipping {ip} - We do not want to edit nodes in this subnet.') | |
elif '192' in ip: | |
sros_conn = net_connect = ConnectHandler(**router_dict(args,ip,SSH_PASS)) | |
# Establish a list of pre and post check commands. | |
print('Connecting to device and executing script...') | |
send_single(sros_conn, 'show system information | match Name') | |
enabled = sros_conn.send_command('show system netconf | match State') | |
if 'Enabled' in enabled: | |
print(f"{ip} already has NETCONF enabled. Moving on..") | |
disconnect(sros_conn) | |
time.sleep(2) | |
print('\n') | |
try: | |
netcbackup(ip, NETCONF_USER, NETCONF_PASS) | |
except Exception as e: | |
print(f"{e}") | |
continue |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment