Skip to content

Update NC-get-config.py #22

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

Closed
wants to merge 1 commit into from
Closed

Update NC-get-config.py #22

wants to merge 1 commit into from

Conversation

cromulon-actual
Copy link

Fixed get-config arguments. Previous version resulted in error.

Fixed get-config arguments. Previous version resulted in error.
@cromulon-actual
Copy link
Author

Previous version error:
raise self._reply.error ncclient.operations.rpc.RPCError: {'type': 'protocol', 'tag': 'unknown-element', 'app_tag': None, 'severity': 'error', 'info': '<?xml version="1.0" encoding="UTF-8"?><error-info xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"><bad-element>filter</bad-element>\n</error-info>\n', 'path': '\n /rpc/get-config\n ', 'message': None}

@xorrkaz
Copy link
Collaborator

xorrkaz commented Dec 1, 2020

Hmmm, the original works for me on recent IOS-XE. What device and version are you using? Admittedly, the variable name lends itself to just return the hostname, but I'm not inclined to change the code as doing a subtree filter (or seeing it done) is useful.

@cromulon-actual
Copy link
Author

cromulon-actual commented Dec 2, 2020

I used the always on iosxe sandbox on DevNet.

Edit: on mobile.

@einarnn
Copy link

einarnn commented Dec 2, 2020

Hmmm, the original works for me on recent IOS-XE. What device and version are you using? Admittedly, the variable name lends itself to just return the hostname, but I'm not inclined to change the code as doing a subtree filter (or seeing it done) is useful.

Recent versions of IOS XE have stopped making netconf base the default namespace for netconf messages. This means you need to set the namespace for filter, rather than assume that XE will do that, as it has done in the past. An alternative to that is to use the form of get similar to the xpath example, passing subtree instead. In that form, the filter you pass in should leave out the filter tag, making your code insensitive to this issue.

Cheers,

Einar

xorrkaz pushed a commit that referenced this pull request Dec 2, 2020
Be explicit about where <filter> is defined.

Reported by:	cromulon-actual (#22)
Clue bat by:	einarnn
@xorrkaz
Copy link
Collaborator

xorrkaz commented Dec 2, 2020

Thanks, Einar! I hadn't realized DevNet updated their Sandbox image to 17.3. I'm still back on 16.12 at home. I added the NS to filter, since I think it's best to be explicit and show people that namespaces matter. Thanks, @cromulon-actual for the report!

@xorrkaz xorrkaz closed this Dec 2, 2020
@cromulon-actual
Copy link
Author

No problem! Though I stumbled upon this, there may be revisions needed in other script examples in the repo.

@xorrkaz
Copy link
Collaborator

xorrkaz commented Dec 2, 2020

Yeah, I found cases in a couple of other scripts which I fixed.

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

Successfully merging this pull request may close these issues.

3 participants