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

ncclient_call (transactions) on Junos hardware. #6

Closed
gcasella opened this issue Jul 22, 2022 · 3 comments
Closed

ncclient_call (transactions) on Junos hardware. #6

gcasella opened this issue Jul 22, 2022 · 3 comments
Labels
bug Something isn't working enhancement New feature or request

Comments

@gcasella
Copy link

gcasella commented Jul 22, 2022

This is for a ticket regarding the the conversation we've had on Slack.

Attached you will see the ncclient_call.py that I had modified with your assistance to make this work for us.
ncclient_call.py.zip

I've made modifications to the following lines:

  • 169
  • 178
  • 184
  • 190
  • 195
  • 199
  • 202
  • 210
  • 220

When using r.tostring.decode() instead of etree.tostring(r._root, pretty_print=True) I was able to perform all transactions and was thrown an error regarding persist=pid as seen in the below exception:

error:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/nornir_salt/plugins/tasks/ncclient_call.py", line 189, in _call_transaction
r = manager.commit(
File "/usr/local/lib/python3.9/site-packages/ncclient/manager.py", line 246, in execute
return cls(self.session,
TypeError: request() got an unexpected keyword argument 'persist'
|

After removing the persist=pid part of the code i was able to successfully do a full transaction.
However the following flow did not work as expected;

  1. Lock target configuration datastore
  2. If client and server supports it - Discard previous changes if any
  3. Edit configuration
  4. If client and server supports it - validate configuration if validate argument is True
  5. If client and server supports it - do commit confirmed if confirmed argument is True
  6. If client and server supports it - do commit operation
  7. Unlock target configuration datastore
  8. If client and server supports it - discard all changes if any of steps 3, 4, 5 or 6 fail
  9. Return results list of dictionaries keyed by step name

steps 5 & 6 did not work.
The command I executed is as follows;

salt 'nrp02' nr.nc transaction config="salt://templates/my_rpc_config.xml" target="candidate" confirmed=True confirmed_delay=120 commit_final_delay=10 comment="Commit via NCCLIENT with rollback" FO='[{"hostname": "192.168.2.2"}]'

On the juniper device i saw this mesage;

0 2022-07-22 00:59:21 EDT by admin via netconf commit confirmed, rollback in 1mins

The final commit never happens.

When I use this command;
salt 'nrp02' nr.nc transaction config="salt://templates/my_rpc_config.xml" target="candidate" comment="Commit via NCCLIENT with rollback" FO='[{"hostname": "192.168.2.2"}]'

The juniper see's this

0 2022-07-22 01:07:42 EDT by admin via netconf commit confirmed, rollback in 10mins
1 2022-07-22 01:07:34 EDT by admin via netconf commit confirmed, rollback in 1mins

It looks like it's doing a double commit confirmed on the box.

Lastly a few points;
Using the ncclient, the transactions function doesn't seem to call the ncclient third-party/junos/rpc.py for it's work (i could be wrong)
I should be able to pass in the following attributes based on their documentation;
format="text" action="set" comment="Test Comment"
Looks like it doesn't work as expected, comments don't pass through either.

I am more than happy to continue testing in a collaborative effort as well and will report any additional findings.

@dmulyalin dmulyalin added bug Something isn't working enhancement New feature or request labels Jul 22, 2022
@dmulyalin
Copy link
Owner

Hi, updated ncclient_call to support specifying edit configuration operation name and passing custom arguments to edit configuration call. Also, updated transaction function to better handle return results and properly handle proprietary commit confirmed RPC for juniper. Commit changes - d05e667

@dmulyalin
Copy link
Owner

@gcasella Let me know if you had a chance to test it.

@gcasella
Copy link
Author

gcasella commented Aug 6, 2022

I tested it before and was working. I'll test once more and report back.

@gcasella gcasella closed this as completed Aug 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants