BGP: Make RouteFamily class hashable

In Python 3, the key objects of dict must be hashable,
but RouteFamily class does not have '__hash__' method.
This patch adds this method.

Signed-off-by: IWASE Yusuke <iwase.yusuke0@gmail.com>
Signed-off-by: FUJITA Tomonori <fujita.tomonori@lab.ntt.co.jp>
This commit is contained in:
IWASE Yusuke 2016-05-17 10:52:15 +09:00 committed by FUJITA Tomonori
parent 13ae023f2d
commit a20b9e1fcd

View File

@ -579,6 +579,9 @@ class RouteFamily(StringifyMixin):
def __eq__(self, other):
return (self.afi, self.safi) == (other.afi, other.safi)
def __hash__(self):
return hash((self.afi, self.safi))
# Route Family Singleton
RF_IPv4_UC = RouteFamily(addr_family.IP, subaddr_family.UNICAST)
RF_IPv6_UC = RouteFamily(addr_family.IP6, subaddr_family.UNICAST)