0

以下の Python スクリプトを実行しようとすると、次のエラーが発生します**" AttributeError: 'RPCReply' object has no attribute 'data_ele'"**

この問題を解決するのを手伝ってください

import lxml.etree as et
from argparse import ArgumentParser
from ncclient import manager
from ncclient.operations import RPCError

payload = [
'''
<get-config xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
  <source>
    <running/>
  </source>
  <filter>
    <interfaces xmlns="urn:ietf:params:xml:ns:yang:ietf-interfaces">
      <interface>
        <name>GigabitEthernet1</name>
        <description/>
      </interface>
    </interfaces>
  </filter>
</get-config>
''',
]

# connect to netconf agent
with manager.connect(host="sandbox-iosxe-recomm-1.cisco.com",
                         port="830",
                         username="developer",
                         password="C1sco12345",
                         timeout=90,
                         hostkey_verify=False,
                         device_params={'name': 'csr'}) as m:

        # execute netconf operation
        for rpc in payload:
            try:
                response = m.dispatch(et.fromstring(rpc))
                data = response.data_ele
            except RPCError as e:
                data = e._raw

            # beautify output
            print(et.tostring(data, encoding='unicode', pretty_print=True))    
4

0 に答える 0