Ошибка типа: тип 'NoneType' не может быть сериализован - PullRequest
0 голосов
/ 07 апреля 2019

Я пытаюсь получить текущую конфигурацию моего маршрутизатора, используя netconf-ncclient.Мой код -

    #!/usr/bin/env python3.5

        try:
            from ncclient import manager

        host = '198.51.100.3'
        with manager.connect(host=host, port=22, username='lab9',password='lab9',hostkey_verify=False, device_params={'name':'iosxr'}) as m:
            c = m.get_config(source='running').data_xml
            #print (c.server_capabilities)
            with open(r1.xml, 'w') as f:
                f.write(c)

    except ImportError as e:
        print ("\n!!! ImportError !!!")
        print ("{0}. Install it.\n".format(e)) 

Получение TypeError-

Traceback (most recent call last):
  File "ojb2.py", line 16, in <module>
    c = m.get_config(source='running').data_xml
  File "/usr/local/lib/python3.5/dist-packages/ncclient/operations/retrieve.py", line 64, in data_xml
    return to_xml(self._data)
  File "/usr/local/lib/python3.5/dist-packages/ncclient/xml_.py", line 100, in to_xml
    xml = etree.tostring(ele, encoding=encoding, pretty_print=pretty_print)
  File "src/lxml/lxml.etree.pyx", line 3350, in lxml.etree.tostring (src/lxml/lxml.etree.c:84534)
TypeError: Type 'NoneType' cannot be serialized.
...