Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pyIOSXR #40

Open
annejg opened this issue Apr 10, 2017 · 5 comments
Open

pyIOSXR #40

annejg opened this issue Apr 10, 2017 · 5 comments

Comments

@annejg
Copy link

annejg commented Apr 10, 2017

Hi!

I'm been working on a program where I want to push configuration to Cisco IOS XR devices and I run into problems when trying to use the code below.

This is my current code snippets:

device = IOSXR(hostname=router["ip"], username=router["username"], password=["password", port=router["port"], timeout=120)

device.open()
device.load_candidate_config(filename=router["path"])`
device.compare_replace_config()
device.commit_replace_config(label='test')
device.close()

I've made sure that the device xml agent is configured with 'iteration off' and I've tried different combinations of locking and unlocking the configuration, and wrapping it in 'try' statements to figure out where the problem lies.

The device just wont accept the load_candidate, compare_replace and commit_replace command.

Have I missed something obvious with the pyIOSXR library?

Best regards,
Anne Golinski

@fooelisa
Copy link
Owner

Hi Anne, this is the right approach. Does the code or device return any errors? What's the error you are seeing?

@annejg
Copy link
Author

annejg commented Apr 12, 2017

Hi Elisa,

Sorry, rookie mistake! The error was in my json file where I had replaced a " with a ' by mistake.. The code above now replaces the running configuration without errors!

However, it does not always commit the configuration into the commit database. I'm then left with an error that target buffer is empty, as a response to the commit request, i.e.:

DEBUG:netmiko:read_channel: <?xml version="1.0" encoding="UTF-8"?> 
<Response MajorVersion="1" MinorVersion="0"><Commit ErrorCode="0x41864e00" 
ErrorMsg="&apos;CfgMgr&apos; detected the &apos;warning&apos; condition &apos;The target 
configuration buffer is empty.&apos;"/> ResultSummary ErrorCount="1"/></Response> 

This problem seam to appear sporadically regardless of content of the configuration text file I try to push to the device.

@annejg
Copy link
Author

annejg commented Apr 25, 2017

Hi @fooelisa!

I really can't figure this out and would like to ask for your help.

The code runs without errors, but it still wont commit the changes into the devices database. I've hardcoded the device information into the script to avoid errors caused by the json file

I'm using

netmiko 1.3.0
lxml 3.7.3
IOS-XR 5.3.3

and this is the code:

def configure_router(router):
	try:
		print('\nConfiguring: ' + router["name"])
		device = IOSXR(hostname='', username='', password='', port=22, timeout=120)
		device.open()
		try: 
			device.load_candidate_config(filename='/home/...')
			device.compare_replace_config()		
			device.commit_replace_config(label='test')
		except: 
			print('Configuration: Did not commit into database\n')

		device.close()
 		print('Configuration: OK\n')
	except: 
		print('Configuration: Unable to communicate with device\n')

Do you have any idea of what could be wrong?

Is there way to integrate some form of delay in the commands to exclude that the error is not due to slow connections?

Thank you in advance!

Best Regards,
Anne Golinski

Update:
I've tried to look at the return values from each function.
While load_candidate_config() and commit_replace_config() returns 'None', the compare_replace_config() doesn't return anything at all. Is that as it should?

@thorko
Copy link
Contributor

thorko commented May 17, 2017

Hi Anne,
I'm not sure if it the same problem. But I also run into this problem and I could figure out the issue. When my configuration file contains a "commit" at the end I also get this error message which is quite obvious. Because the router already committed the changes the second commit will tell you that there are no changes, so the buffer is empty.
Hope this helps
Cheers
thorko

@annejg
Copy link
Author

annejg commented Jun 24, 2017

Hi @thorko!
Yes, You are absolutely right, that was the problem all along
Thank you!

Best Regards,
Anne

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants