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