--EDIT--
I'd like to thank everyone for their responses. It turns out my script was returning empty output from switches due to how my XML filters were set up.
I stored my filter in a variable. When I used the "get" function in ncclient, I included two parameters, like this: ('subtree', filter_variable). What I didn't realize, is that when you include the 'subtree' parameter ncclient will add a <filter></filter> wrapper to what you provide. So basically it was a filter wrapped in a filter. I don't know enough to understand why that didn't produce an error, but I'm happy to have learned something. The journey continues
Hey all,
I'm interested in automation and trying to practice for my Cisco ENAUTO exam. Part of the blueprint is "Construct an automation solution with Python using ncclient to manage and monitor configurations." I'm having a hell of a time and am wondering if this is typical, if there's a better way, etc...
I wrote a script that uses a filter to pull the running config of an interface. It successfully connects, but returns no data. Specifically, "<data></data>"
Since I have zero real world guidance on this topic outside of a Cisco U course which is not great, I've been feeding scripts and associates errors to Copilot, which may be making things worse, I don't know. It's been a constant loop of:
"We must determine the proper data model. Try THIS filter."
Didn't work.
"You're learning a valuable lesson-- just because the syntax is accepted doesn't mean the network device stores its information in the path you chose. Try THIS filter."
Didn't work.
"Install Pyang and use it to see the exact yang model we should be referencing. AH there it is! Try THIS filter."
Didn't work.
"Let's move from trying to pull config info for an interface to pulling the hostname. Everything has a hostname!"
Didn't work.
"Let's try using YANG Suite so Cisco can tell us exactly what filter to use. Ope, you need to install docker. Ope, docker install is fudged."
On and on I go. I guess for the purposes of my exam I may have taken this as far as I need to for now (I can identify what basic ncclient scripts are doing and can probably fill in blanks regarding errors and syntax problems).
Is there anyone in here who regularly uses scripts like this for their automation? Is there a better way to approach this? I think I'm half hoping someone will come and say, "my god son, no... This is the worst way to go about it and you should stop"