cancel
Showing results for 
Search instead for 
Did you mean: 
cancel

Who Me Too'd this topic

ncclient getting bad-element error when dispatching rpc

nikhchau
Cisco Employee
Cisco Employee

Hi,

 

When using dispatch method of ncclient(0.6.6) to execute an RPC with nso(5.3) getting unknown element error.

 

The same code used to work with previous nso version 4.7.2.1.

 

 

[Console output]

Sending: 2020-01-13T09:54:06: %NCCLIENT-INFO: 2020-01-13T09:54:06: %NCCLIENT-INFO: #673 2020-01-13T09:54:06: %NCCLIENT-INFO: <?xml version="1.0" encoding="UTF-8"?><nc:rpc xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:44e94a3b-f614-4660-9deb-2e30809d0b88"><edit-config> 2020-01-13T09:54:06: %NCCLIENT-INFO: <target> 2020-01-13T09:54:06: %NCCLIENT-INFO: <running/> 2020-01-13T09:54:06: %NCCLIENT-INFO: </target> 2020-01-13T09:54:06: %NCCLIENT-INFO: <config> 2020-01-13T09:54:06: %NCCLIENT-INFO: <org-openroadm-device xmlns="http://org/openroadm/device"> 2020-01-13T09:54:06: %NCCLIENT-INFO: <shelves nc:operation="create"> 2020-01-13T09:54:06: %NCCLIENT-INFO: <shelf-name>0</shelf-name> 2020-01-13T09:54:06: %NCCLIENT-INFO: <shelf-type>xyz Chassis</shelf-type> 2020-01-13T09:54:06: %NCCLIENT-INFO: </shelves> 2020-01-13T09:54:06: %NCCLIENT-INFO: </org-openroadm-device> 2020-01-13T09:54:06: %NCCLIENT-INFO: </config> 2020-01-13T09:54:06: %NCCLIENT-INFO: </edit-config></nc:rpc> 2020-01-13T09:54:06: %NCCLIENT-INFO: ## 2020-01-13T09:54:06: %NCCLIENT-INFO: [host 10.225.100.220 session-id 56] Received: 2020-01-13T09:54:06: %NCCLIENT-INFO: <?xml version="1.0" encoding="UTF-8"?> 2020-01-13T09:54:06: %NCCLIENT-INFO: <rpc-reply xmlns="urn:ietf:params:xml:ns:netconf:base:1.0" message-id="urn:uuid:44e94a3b-f614-4660-9deb-2e30809d0b88" xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0"><rpc-error> 2020-01-13T09:54:06: %NCCLIENT-INFO: <error-type>protocol</error-type> 2020-01-13T09:54:06: %NCCLIENT-INFO: <error-tag>unknown-element</error-tag> 2020-01-13T09:54:06: %NCCLIENT-INFO: <error-severity>error</error-severity> 2020-01-13T09:54:06: %NCCLIENT-INFO: <error-path> 2020-01-13T09:54:06: %NCCLIENT-INFO: /rpc 2020-01-13T09:54:06: %NCCLIENT-INFO: </error-path><error-info><bad-element>edit-config</bad-element> 2020-01-13T09:54:06: %NCCLIENT-INFO: </error-info> 2020-01-13T09:54:06: %NCCLIENT-INFO: </rpc-error> 2020-01-13T09:54:06: %NCCLIENT-INFO: </rpc-reply>

 

Code that executes with pyats test suite

 

with manager.connect(host=self.host,
                                 port=self.port,
                                 username=self.username,
                                 password=self.password,
                                 timeout=90,
                                 hostkey_verify=self.hostkey_verify,
                                 device_params={'name': 'csr'}) as m:
                try:
                    response = m.dispatch(et.fromstring(payload))
                    print(response)
                    data = response.data_ele
                    print(data)
                except Exception as e:
                    log.error(e)
                    return False
[Payload in code]
'''
<edit-config> <target> <running/> </target> <config> <org-openroadm-device xmlns="http://org/openroadm/device"> <shelves xmlns:nc="urn:ietf:params:xml:ns:netconf:base:1.0" nc:operation="{nc_operation}"> {shelf_name_leaf} {shelf_type_leaf} </shelves> </org-openroadm-device> </config> </edit-config>
'''

The dispatch method forms the final rpc out of the payload.

 

-----------------------------------------------------------------------------------------------------------

 

python version: 3.4.1

ncclient: 0.6.6

nso: 5.3

 

 

 

Who Me Too'd this topic