我想找些诊断方法
用于opendaylight bgp配置的restful get命令
示例;显示bgp会话/组/邻居的所有bgp属性。
我在哪能找到?
In [9]: cmd = """ <neighbor xmlns="urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions">
...: <neighbor-address>10.20.14.1</neighbor-address>
...: <afi-safis>
...: <afi-safi>
...: <afi-safi-name>LINKSTATE</afi-safi-name>
...: </afi-safi>
...: </afi-safis>
...: </neighbor>
...: """
In [10]: url = "/restconf/config/openconfig-network-instance:network-instances/network-instance/global-bgp/openconfig-network-instance:protocols/protocol/openconfig-policy-types:BGP/bgp-example/bgp/ne
...: ighbors"
In [11]:
In [11]: requests.post('http://{}:{}{}'.format(odl['api']['ipaddr'],odl['api']['port'],url), auth=auth, headers=headers, data=cmd).json()
---------------------------------------------------------------------------
JSONDecodeError Traceback (most recent call last)
<ipython-input-11-6c5beab7d9fb> in <module>()
----> 1 requests.post('http://{}:{}{}'.format(odl['api']['ipaddr'],odl['api']['port'],url), auth=auth, headers=headers, data=cmd).json()
/usr/lib/python3.6/site-packages/requests/models.py in json(self, **kwargs)
894 # used.
895 pass
--> 896 return complexjson.loads(self.text, **kwargs)
897
898 @property
/usr/lib64/python3.6/json/__init__.py in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
352 parse_int is None and parse_float is None and
353 parse_constant is None and object_pairs_hook is None and not kw):
--> 354 return _default_decoder.decode(s)
355 if cls is None:
356 cls = JSONDecoder
/usr/lib64/python3.6/json/decoder.py in decode(self, s, _w)
337
338 """
--> 339 obj, end = self.raw_decode(s, idx=_w(s, 0).end())
340 end = _w(s, end).end()
341 if end != len(s):
/usr/lib64/python3.6/json/decoder.py in raw_decode(self, s, idx)
355 obj, end = self.scan_once(s, idx)
356 except StopIteration as err:
--> 357 raise JSONDecodeError("Expecting value", s, err.value) from None
358 return obj, end
JSONDecodeError: Expecting value: line 1 column 1 (char 0)
In [12]: requests.post('http://{}:{}{}'.format(odl['api']['ipaddr'],odl['api']['port'],url), auth=auth, headers=headers, data=cmd).json()
Out[12]:
{'errors': {'error': [{'error-type': 'protocol',
'error-tag': 'data-exists',
'error-message': 'Data already exists for path: /(http://openconfig.net/yang/network-instance?revision=2015-10-18)network-instances/network-instance/network-instance[{(http://openconfig.net/yang/network-instance?revision=2015-10-18)name=global-bgp}]/protocols/protocol/protocol[{(http://openconfig.net/yang/network-instance?revision=2015-10-18)identifier=(http://openconfig.net/yang/policy-types?revision=2015-10-09)BGP, (http://openconfig.net/yang/network-instance?revision=2015-10-18)name=bgp-example}]/AugmentationIdentifier{childNames=[(urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions?revision=2017-12-07)bgp]}/(urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions?revision=2017-12-07)bgp/neighbors/neighbor/neighbor[{(urn:opendaylight:params:xml:ns:yang:bgp:openconfig-extensions?revision=2017-12-07)neighbor-address=10.20.14.1}]'}]}}