pprint("Commiting") rsp = dev.cfg.commit() if rsp is True: pprint("Commit successful") dev.close() elif commit_config == 'NO': pprint("Rolling back") dev.cfg.rollback() dev.close() for xr_filename in glob.glob('./configs/*ios_xr.txt'): with open(os.path.join(xr_filename), 'r') as f: ipaddress = str(xr_filename[10:-11]) pprint('***Processing %s port %s ***' % (ipaddress, port)) xr_device = IOSXR(hostname='172.16.2.10', username='******', password='******') xr_device.open() try: xr_device.load_candidate_config(filename=xr_filename) except Exception as err: print('Error occured while loading candidate configs', err) continue if args.confirm is True: pprint("Confirmation bypassed") xr_device.commit_config() xr_device.close() continue else:
def __init__(self, hostname, username, password): self.hostname = hostname self.username = username self.password = password self.device = IOSXR(hostname, username, password) self.pending_changes = False