Commit 40f3aa6f authored by Klaus Aehlig's avatar Klaus Aehlig
Browse files

Replace textwrapper.wrap by a custom version for networks



"gnt-network info" also provides information about the mapping of used
IPs in that network. This mapping is obtained from the query as a long
string without any spaces. It seems that textwrap.wrap does not perform
well on those strings. Therefore, manually wrap that string, thus bringing
down the time "gnt-network info" takes for a /16 from 1.5 minutes to half
a second. Fixes issue 1016.
Signed-off-by: default avatarKlaus Aehlig <aehlig@google.com>
Reviewed-by: default avatarHelga Velroyen <helgav@google.com>
parent 1ad0981c
......@@ -242,8 +242,10 @@ def ShowNetworkConfig(_, args):
ToStdout(" Free: %d (%.2f%%)", free_count,
100 * float(free_count) / float(size))
ToStdout(" Usage map:")
lenmapping = len(mapping)
idx = 0
for line in textwrap.wrap(mapping, width=64):
while idx < lenmapping:
line = mapping[idx: idx + 64]
ToStdout(" %s %s %d", str(idx).rjust(3), line.ljust(64), idx + 63)
idx += 64
ToStdout(" (X) used (.) free")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment