wingo - in flumotion/trunk: . flumotion/common flumotion/test
flumotion-commit at lists.fluendo.com
flumotion-commit at lists.fluendo.com
Thu Feb 22 16:34:19 CET 2007
Author: wingo
Date: Thu Feb 22 16:34:16 2007
New Revision: 4513
Modified:
flumotion/trunk/ChangeLog
flumotion/trunk/flumotion/common/netutils.py
flumotion/trunk/flumotion/test/test_common_netutils.py
Log:
2007-02-22 Andy Wingo <wingo at pobox.com>
* flumotion/common/netutils.py (RoutingTable.iterHumanReadable):
New method, iterate the routes as the route, network IP as a
string, and prefix length as an int.
* flumotion/test/test_common_netutils.py
(TestRoutingTable.testIterHumanReadable): Test new function.
Modified: flumotion/trunk/ChangeLog
==============================================================================
--- flumotion/trunk/ChangeLog (original)
+++ flumotion/trunk/ChangeLog Thu Feb 22 16:34:16 2007
@@ -1,5 +1,12 @@
2007-02-22 Andy Wingo <wingo at pobox.com>
+ * flumotion/common/netutils.py (RoutingTable.iterHumanReadable):
+ New method, iterate the routes as the route, network IP as a
+ string, and prefix length as an int.
+
+ * flumotion/test/test_common_netutils.py
+ (TestRoutingTable.testIterHumanReadable): Test new function.
+
* flumotion/test/test_common_netutils.py
(TestIpv4Parse.testIpv4ParseString): Test validation.
Modified: flumotion/trunk/flumotion/common/netutils.py
==============================================================================
--- flumotion/trunk/flumotion/common/netutils.py (original)
+++ flumotion/trunk/flumotion/common/netutils.py Thu Feb 22 16:34:16 2007
@@ -179,6 +179,10 @@
def __iter__(self):
return self.avltree.iterreversed()
+ def iterHumanReadable(self):
+ for mask, net, route in self:
+ yield route, ipv4IntToString(net), 32-countTrailingZeroes32(mask)
+
def __len__(self):
return len(self.avltree)
Modified: flumotion/trunk/flumotion/test/test_common_netutils.py
==============================================================================
--- flumotion/trunk/flumotion/test/test_common_netutils.py (original)
+++ flumotion/trunk/flumotion/test/test_common_netutils.py Thu Feb 22 16:34:16 2007
@@ -99,6 +99,15 @@
ar('192.168.0.255', None)
ar('192.168.2.0', None)
+ def testIterHumanReadable(self):
+ routes = [('foo', '192.168.1.0', 32),
+ ('bar', '192.168.1.0', 24)]
+ net = RoutingTable()
+ for route, ip, mask in routes:
+ net.addSubnet(route, ip, mask)
+ for expected, actual in zip(routes, net.iterHumanReadable()):
+ self.assertEquals(expected, actual)
+
def testRoutingPrecedence(self):
net = RoutingTable()
More information about the flumotion-commit
mailing list