Commit c86432a1 authored by Florent Fourcot's avatar Florent Fourcot

ipset: return boolean for test method (#333)

Bug-Url: https://github.com/svinota/pyroute2/issues/333
parent 0f498131
......@@ -35,6 +35,7 @@ from pyroute2.netlink.nfnetlink.ipset import IPSET_FLAG_WITH_COUNTERS
from pyroute2.netlink.nfnetlink.ipset import IPSET_FLAG_WITH_COMMENT
from pyroute2.netlink.nfnetlink.ipset import IPSET_FLAG_WITH_FORCEADD
from pyroute2.netlink.nfnetlink.ipset import IPSET_DEFAULT_MAXELEM
from pyroute2.netlink.nfnetlink.ipset import IPSET_ERR_EXIST
def _nlmsg_error(msg):
......@@ -224,8 +225,14 @@ class IPSet(NetlinkSocket):
'''
Test if a member is part of an ipset
'''
return self._add_delete_test(name, entry, family, IPSET_CMD_TEST,
False, etype=etype)
try:
self._add_delete_test(name, entry, family, IPSET_CMD_TEST,
False, etype=etype)
return True
except IPSetError as e:
if e.code == IPSET_ERR_EXIST:
return False
raise e
def swap(self, set_a, set_b):
'''
......
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