Python3 NCClient: enabling nacm throws unknown object error

28 views Asked by At

I am trying to enable nacm via ncclient but getting the error - ncclient.operations.rpc.RPCError: unknown object

>>> nacm_config = """<config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
...     <ietf-netconf-acm xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-acm">
...         <enable-nacm>true</enable-nacm>
...     </ietf-netconf-acm>
... </config>"""
>>>

>>> from ncclient import manager
>>> m = manager.connect(host='192.168.40.100', port=830, username='root', password='password', hostkey_verify=False)
>>> m.edit_config(target='running', config=nacm_config)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.10/dist-packages/ncclient/manager.py", line 257, in execute
    return cls(self._session,
  File "/usr/local/lib/python3.10/dist-packages/ncclient/operations/edit.py", line 76, in request
    return self._request(node)
  File "/usr/local/lib/python3.10/dist-packages/ncclient/operations/rpc.py", line 375, in _request
    raise self._reply.error
ncclient.operations.rpc.RPCError: unknown object

But when i try to get the nacm running config - it replies correctky and the xml name space shows

>>> nacm_reply = m.get_config(source='running', filter=('subtree', '<nacm xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-acm"/>'))
>>>
>>> print(nacm_reply)
<?xml version="1.0" encoding="UTF-8"?>
<rpc-reply xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"
 message-id="urn:uuid:0f5b1ca8-7163-445f-a6d5-4b468775d147"
 xmlns:ncx="http://netconfcentral.org/ns/yuma-ncx"
 ncx:last-modified="2022-05-04T17:44:42Z" ncx:etag="34"
 xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
 <data>
  <nacm xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-acm">
   <enable-nacm>false</enable-nacm>
  </nacm>
 </data>
</rpc-reply>
>>>

I have tried with different combinations of xml to no avail - any help to fix this would be appreciated.

Thanks!

1

There are 1 answers

0
Ulysses On BEST ANSWER

This works - needed to head it with - namespace is same as ietf-netconf-acm but config tag is without xmlns attribute and nacm tag instead of ietf-netconf-acm tag to contain nacm attribute arguments.

<config>
    <nacm xmlns="urn:ietf:params:xml:ns:yang:ietf-netconf-acm">
        <enable-nacm>true</enable-nacm>
    </nacm>
</config>