-
-
Notifications
You must be signed in to change notification settings - Fork 251
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for ip route save
and ip route restore
commands
#1203
Comments
Here's a patched implementation o class PatchedIPRoute(IPRoute):
def save_routes(self, *argv, **kwarg):
return list(self.get_routes(*argv, **kwarg))
def restore_routes(self, routes):
for route in routes:
self.put(route, msg_type=RTM_NEWROUTE, msg_flags=NLM_F_REQUEST) |
This might require some additional investigation if we need to serialize route objects — just not to exhaust all the memory on huge numbers of routes. Beside of that it might be useful to make it compatible with Ok, got it. Thanks for the request, I will dig around, and update you here next week. |
A proof of concept of a binary stream dumper. * ipr.route_dump(fd, family=AF_UNSPEC) -- save routes to a file object; it can be an open file, BytesIO() or like that * ipr.route_dumps(family=AF_UNSPEC) -- return routes as a binary string Bug-Url: #1203
@pseusys started to implement the feature, you can follow that on branch |
A proof of concept of a binary stream dumper. * ipr.route_dump(fd, family=AF_UNSPEC) -- save routes to a file object; it can be an open file, BytesIO() or like that * ipr.route_dumps(family=AF_UNSPEC) -- return routes as a binary string Bug-Url: #1203
A proof of concept of a binary stream dumper. * ipr.route_dump(fd, family=AF_UNSPEC) -- save routes to a file object; it can be an open file, BytesIO() or like that * ipr.route_dumps(family=AF_UNSPEC) -- return routes as a binary string Bug-Url: #1203
A proof of concept of a binary stream dumper. * ipr.route_dump(fd, family=AF_UNSPEC) -- save routes to a file object; it can be an open file, BytesIO() or like that * ipr.route_dumps(family=AF_UNSPEC) -- return routes as a binary string Bug-Url: #1203
A proof of concept of a binary stream dumper. * ipr.route_dump(fd, family=AF_UNSPEC) -- save routes to a file object; it can be an open file, BytesIO() or like that * ipr.route_dumps(family=AF_UNSPEC) -- return routes as a binary string Bug-Url: #1203
* ipr.route_load(fd, fmt='iproute2') -- load a dump from a file object; compatible with `iproute2 routes save` files * ipr.route_load(data, fmt='iproute2') -- load a dump from a bytes object Bug-Url: #1203
Merged into the master branch. Some more tests and docs will be added, |
@pseusys I'm closing the ticket, but don't hesitate to reopen, or to open a new one in the case there will be any issues using the feature. |
Browsing the ip command docs I have noticed three different commands for route bulk manipulation:
ip route flush
,ip route save
andip route restore
. Sadly, it seems like only the first one is implemented inpyroute2
. Is there an explanation for that? The latter two commands might be really useful for routing table manipulation. Is there any official workaround (involvingIPRoute.get_routes(table=...)
probably)? Could I maybe help adding support for that?If no support is planned, could you please let me know, how can I restore a route thaat I once received with
IPRoute.get_routes
? It is received in a form of a dictionary.The text was updated successfully, but these errors were encountered: