Fix "ip route" commands to work with pyroute2 APIv2
Fixed "ip route" commands to work with pyroute2 >= 0.6.10, that
introduces APIv2 for link, neighbour and route [1].
[1]bc0f5e2209
Closes-Bug: #1979031
Change-Id: Id2239b6827485a4d466b0916947428ceabef9139
This commit is contained in:
parent
0e40dfe862
commit
4dbcd76517
@ -741,8 +741,8 @@ def _make_pyroute2_route_args(namespace, ip_version, cidr, device, via, table,
|
|||||||
|
|
||||||
@privileged.default.entrypoint
|
@privileged.default.entrypoint
|
||||||
def add_ip_route(namespace, cidr, ip_version, device=None, via=None,
|
def add_ip_route(namespace, cidr, ip_version, device=None, via=None,
|
||||||
table=None, metric=None, scope=None, proto='static',
|
table=None, metric=None, scope=None,
|
||||||
**kwargs):
|
proto=rtnl.rt_proto['static'], **kwargs):
|
||||||
"""Add an IP route"""
|
"""Add an IP route"""
|
||||||
kwargs.update(_make_pyroute2_route_args(
|
kwargs.update(_make_pyroute2_route_args(
|
||||||
namespace, ip_version, cidr, device, via, table, metric, scope,
|
namespace, ip_version, cidr, device, via, table, metric, scope,
|
||||||
@ -766,7 +766,8 @@ def add_ip_route(namespace, cidr, ip_version, device=None, via=None,
|
|||||||
def list_ip_routes(namespace, ip_version, device=None, table=None, **kwargs):
|
def list_ip_routes(namespace, ip_version, device=None, table=None, **kwargs):
|
||||||
"""List IP routes"""
|
"""List IP routes"""
|
||||||
kwargs.update(_make_pyroute2_route_args(
|
kwargs.update(_make_pyroute2_route_args(
|
||||||
namespace, ip_version, None, device, None, table, None, None, None))
|
namespace, ip_version, None, device, None, table, None, 'universe',
|
||||||
|
None))
|
||||||
try:
|
try:
|
||||||
with get_iproute(namespace) as ip:
|
with get_iproute(namespace) as ip:
|
||||||
return make_serializable(ip.route('show', **kwargs))
|
return make_serializable(ip.route('show', **kwargs))
|
||||||
|
Loading…
Reference in New Issue
Block a user