You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
from pyroute2 import NDB
ndb = NDB(log='debug', auto_netns=True)
ndb.sources.add(netns='testns') # connect to a namespace
print(ndb.sources.summary())
with ( ndb.interfaces.create(ifname='veth0', kind='veth',
peer={'ifname':'eth0', 'net_ns_fd':'testns', }, state='up',)) as veth0:
veth0.set(state='up')
veth0.add_ip(address='10.0.0.1', prefixlen=24)
with ndb.interfaces.wait(target='testns', ifname='lo') as peer: # wait for the peer
peer.set(state='up') # bring it up
with ndb.interfaces.wait(target='testns', ifname='eth0') as peer: # wait for the peer
peer.set(state='up') # bring it up
peer.add_ip('10.0.0.2', prefixlen=24) # add address
ndb.routes.create(target='testns', dst='10.0.0.0/24', src='10.0.0.2/24', oif=2 ).commit()
When create namespace : "lo" is down and in the namespace no routers from eth0 and need to create route like
10.0.0.0/24 dev veth0 proto kernel scope link src 10.0.0.1
We have next errors : src and src_len lost in line 2024-06-07 22:25:19,393
2024-06-07 22:25:19,390 DEBUG pyroute2.ndb.140716529876704.rtnl_object: ignore error 17 for {'multipath': [], 'metrics': {}, 'deps': 0, 'target': 'testns', 'dst': '10.0.0.0', 'family': <AddressFamily.AF_INET: 2>, 'dst_len': 24, 'src': '10.0.0.2', 'src_len': 24, 'oif': 2}
2024-06-07 22:25:19,391 DEBUG pyroute2.ndb.140716529876704.rtnl_object: run fallback <function fallback_add at 0x7ffb1e9a68c0> ({'target': 'testns', 'family': <AddressFamily.AF_INET: 2>, 'dst_len': 24, 'dst': '10.0.0.0', 'oif': 2, 'src': '10.0.0.2', 'src_len': 24, 'multipath': [], 'metrics': {}, 'deps': 0})
2024-06-07 22:25:19,391 DEBUG pyroute2.ndb.140716529876704.rtnl_object: ignore incomplete idx_req in the fallback
2024-06-07 22:25:19,391 DEBUG pyroute2.ndb.140716529876704.rtnl_object: stats: apply add {objid 140716492323024, wtime 0.1, mqsize 1, nqsize 0}
2024-06-07 22:25:19,393 DEBUG pyroute2.ndb.140716529876704.rtnl_object: load_sql load: ('testns', 0, 2, 24, 0, 0, 254, 4, 0, 1, 0, '10.0.0.0', None, None, 2, None, 0, None, None, None, 254, None, '', '', None, None, None, None, 0)
2024-06-07 22:25:19,393 DEBUG pyroute2.ndb.140716529876704.rtnl_object: load_sql names: ['target', 'tflags', 'family', 'dst_len', 'src_len', 'tos', 'table', 'proto', 'scope', 'type', 'flags', 'dst', 'src', 'iif', 'oif', 'gateway', 'priority', 'prefsrc', 'protoinfo', 'flow', 'table', 'mark', 'via', 'newdst', 'pref', 'encap_type', 'route_id', 'gc_mark', 'deps']
None
Traceback (most recent call last):
File "/home/tsvetkov/tests/ssl_clnt_srv_ndb.py", line 25, in
ndb.routes.create(target='testns', dst='10.0.0.0/24', src='10.0.0.2/24', oif=2 ).commit() #
File "/home/tsvetkov/.virtualenvs/tests/lib/python3.10/site-packages/pyroute2/ndb/auth_manager.py", line 67, in guard
return f(obj, *argv, **kwarg)
File "/home/tsvetkov/.virtualenvs/tests/lib/python3.10/site-packages/pyroute2/ndb/objects/init.py", line 721, in commit
raise e_i
File "/home/tsvetkov/.virtualenvs/tests/lib/python3.10/site-packages/pyroute2/ndb/objects/init.py", line 710, in commit
return self.apply(mode='commit')
File "/home/tsvetkov/.virtualenvs/tests/lib/python3.10/site-packages/pyroute2/ndb/auth_manager.py", line 67, in guard
return f(obj, *argv, **kwarg)
File "/home/tsvetkov/.virtualenvs/tests/lib/python3.10/site-packages/pyroute2/ndb/objects/route.py", line 743, in apply
return super(Route, self).apply(rollback, req_filter, mode)
File "/home/tsvetkov/.virtualenvs/tests/lib/python3.10/site-packages/pyroute2/ndb/auth_manager.py", line 67, in guard
return f(obj, *argv, **kwarg)
File "/home/tsvetkov/.virtualenvs/tests/lib/python3.10/site-packages/pyroute2/ndb/objects/init.py", line 957, in apply
if self.check():
File "/home/tsvetkov/.virtualenvs/tests/lib/python3.10/site-packages/pyroute2/ndb/objects/init.py", line 772, in check
self.load_sql()
File "/home/tsvetkov/.virtualenvs/tests/lib/python3.10/site-packages/pyroute2/ndb/objects/route.py", line 746, in load_sql
super(Route, self).load_sql(*argv, **kwarg)
File "/home/tsvetkov/.virtualenvs/tests/lib/python3.10/site-packages/pyroute2/ndb/objects/init.py", line 1136, in load_sql
self.update_from_sql(spec)
File "/home/tsvetkov/.virtualenvs/tests/lib/python3.10/site-packages/pyroute2/ndb/objects/init.py", line 1076, in update_from_sql
self.load_value(key, value)
File "/home/tsvetkov/.virtualenvs/tests/lib/python3.10/site-packages/pyroute2/ndb/objects/init.py", line 1094, in load_value
elif key in self.fields_cmp and self.fields_cmp[key](self, value):
File "/home/tsvetkov/.virtualenvs/tests/lib/python3.10/site-packages/pyroute2/ndb/objects/route.py", line 571, in _cmp_target
right = [MPLSTarget(x) for x in json.loads(right)]
File "/usr/lib/python3.10/json/init.py", line 339, in loads
raise TypeError(f'the JSON object must be str, bytes or bytearray, '
TypeError: the JSON object must be str, bytes or bytearray, not NoneType
The text was updated successfully, but these errors were encountered:
pyroute2 0.7.12
When create namespace : "lo" is down and in the namespace no routers from eth0 and need to create route like
10.0.0.0/24 dev veth0 proto kernel scope link src 10.0.0.1
We have next errors : src and src_len lost in line 2024-06-07 22:25:19,393
2024-06-07 22:25:19,390 DEBUG pyroute2.ndb.140716529876704.rtnl_object: ignore error 17 for {'multipath': [], 'metrics': {}, 'deps': 0, 'target': 'testns', 'dst': '10.0.0.0', 'family': <AddressFamily.AF_INET: 2>, 'dst_len': 24, 'src': '10.0.0.2', 'src_len': 24, 'oif': 2}
2024-06-07 22:25:19,391 DEBUG pyroute2.ndb.140716529876704.rtnl_object: run fallback <function fallback_add at 0x7ffb1e9a68c0> ({'target': 'testns', 'family': <AddressFamily.AF_INET: 2>, 'dst_len': 24, 'dst': '10.0.0.0', 'oif': 2, 'src': '10.0.0.2', 'src_len': 24, 'multipath': [], 'metrics': {}, 'deps': 0})
2024-06-07 22:25:19,391 DEBUG pyroute2.ndb.140716529876704.rtnl_object: ignore incomplete idx_req in the fallback
2024-06-07 22:25:19,391 DEBUG pyroute2.ndb.140716529876704.rtnl_object: stats: apply add {objid 140716492323024, wtime 0.1, mqsize 1, nqsize 0}
2024-06-07 22:25:19,393 DEBUG pyroute2.ndb.140716529876704.rtnl_object: load_sql load: ('testns', 0, 2, 24, 0, 0, 254, 4, 0, 1, 0, '10.0.0.0', None, None, 2, None, 0, None, None, None, 254, None, '', '', None, None, None, None, 0)
2024-06-07 22:25:19,393 DEBUG pyroute2.ndb.140716529876704.rtnl_object: load_sql names: ['target', 'tflags', 'family', 'dst_len', 'src_len', 'tos', 'table', 'proto', 'scope', 'type', 'flags', 'dst', 'src', 'iif', 'oif', 'gateway', 'priority', 'prefsrc', 'protoinfo', 'flow', 'table', 'mark', 'via', 'newdst', 'pref', 'encap_type', 'route_id', 'gc_mark', 'deps']
None
Traceback (most recent call last):
File "/home/tsvetkov/tests/ssl_clnt_srv_ndb.py", line 25, in
ndb.routes.create(target='testns', dst='10.0.0.0/24', src='10.0.0.2/24', oif=2 ).commit() #
File "/home/tsvetkov/.virtualenvs/tests/lib/python3.10/site-packages/pyroute2/ndb/auth_manager.py", line 67, in guard
return f(obj, *argv, **kwarg)
File "/home/tsvetkov/.virtualenvs/tests/lib/python3.10/site-packages/pyroute2/ndb/objects/init.py", line 721, in commit
raise e_i
File "/home/tsvetkov/.virtualenvs/tests/lib/python3.10/site-packages/pyroute2/ndb/objects/init.py", line 710, in commit
return self.apply(mode='commit')
File "/home/tsvetkov/.virtualenvs/tests/lib/python3.10/site-packages/pyroute2/ndb/auth_manager.py", line 67, in guard
return f(obj, *argv, **kwarg)
File "/home/tsvetkov/.virtualenvs/tests/lib/python3.10/site-packages/pyroute2/ndb/objects/route.py", line 743, in apply
return super(Route, self).apply(rollback, req_filter, mode)
File "/home/tsvetkov/.virtualenvs/tests/lib/python3.10/site-packages/pyroute2/ndb/auth_manager.py", line 67, in guard
return f(obj, *argv, **kwarg)
File "/home/tsvetkov/.virtualenvs/tests/lib/python3.10/site-packages/pyroute2/ndb/objects/init.py", line 957, in apply
if self.check():
File "/home/tsvetkov/.virtualenvs/tests/lib/python3.10/site-packages/pyroute2/ndb/objects/init.py", line 772, in check
self.load_sql()
File "/home/tsvetkov/.virtualenvs/tests/lib/python3.10/site-packages/pyroute2/ndb/objects/route.py", line 746, in load_sql
super(Route, self).load_sql(*argv, **kwarg)
File "/home/tsvetkov/.virtualenvs/tests/lib/python3.10/site-packages/pyroute2/ndb/objects/init.py", line 1136, in load_sql
self.update_from_sql(spec)
File "/home/tsvetkov/.virtualenvs/tests/lib/python3.10/site-packages/pyroute2/ndb/objects/init.py", line 1076, in update_from_sql
self.load_value(key, value)
File "/home/tsvetkov/.virtualenvs/tests/lib/python3.10/site-packages/pyroute2/ndb/objects/init.py", line 1094, in load_value
elif key in self.fields_cmp and self.fields_cmp[key](self, value):
File "/home/tsvetkov/.virtualenvs/tests/lib/python3.10/site-packages/pyroute2/ndb/objects/route.py", line 571, in _cmp_target
right = [MPLSTarget(x) for x in json.loads(right)]
File "/usr/lib/python3.10/json/init.py", line 339, in loads
raise TypeError(f'the JSON object must be str, bytes or bytearray, '
TypeError: the JSON object must be str, bytes or bytearray, not NoneType
The text was updated successfully, but these errors were encountered: