Unfortunately, documentation of pyroute2
module is rather specific, so I couldn’t find an answer for one specific issue I had.
My goal is to save all the routes from one specific table (let’s name it table A
) – and then restore them. I can (apparently) receive a route dump and clear the table with single command: IPRoute().flush_routes(table=A)
. The routes are stored as a tuple of dicts. Apaprently I would like to restore them with IPRoute().route("add", table=A, ...)
, but what should be the parameters?
The code that I would ideally like to have would look something like this:
routes_dump = IPRoute().flush_routes(table=A)
# some processing (while table A has no routes in it)...
for route in routes_dump:
IPRoute().route("add", table=A, ...)
Would be grateful for any ideas about how is it feasible!