diff options
author | Jan Gelety <jgelety@cisco.com> | 2017-08-14 16:25:46 +0200 |
---|---|---|
committer | Tibor Frank <tifrank@cisco.com> | 2017-10-11 13:45:40 +0000 |
commit | bdfca054d8425a57496cca8308da36c118b5340f (patch) | |
tree | 4fd5627975df0ac3fbd35bab64ba6bd493084919 /resources/libraries/python/IPUtil.py | |
parent | 66039913f070f4bb81e10f6ed503e0f2242ff70d (diff) |
CSIT-778: Add mac-ip binding acl l2bd perf test
Change-Id: Iaced68458b0e4070f861be7854ee428ae8ca4e13
Signed-off-by: Jan Gelety <jgelety@cisco.com>
Diffstat (limited to 'resources/libraries/python/IPUtil.py')
-rw-r--r-- | resources/libraries/python/IPUtil.py | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/resources/libraries/python/IPUtil.py b/resources/libraries/python/IPUtil.py index 4bd8869cb6..d2f2adcf28 100644 --- a/resources/libraries/python/IPUtil.py +++ b/resources/libraries/python/IPUtil.py @@ -25,6 +25,30 @@ class IPUtil(object): """Common IP utilities""" @staticmethod + def ip_to_int(ip_str): + """Convert IP address from string format (e.g. 10.0.0.1) to integer + representation (167772161). + + :param ip_str: IP address in string representation. + :type ip_str: str + :returns: Integer representation of IP address. + :rtype: int + """ + return int(ip_address(unicode(ip_str))) + + @staticmethod + def int_to_ip(ip_int): + """Convert IP address from integer representation (e.g. 167772161) to + string format (10.0.0.1). + + :param ip_int: IP address in integer representation. + :type ip_int: int + :returns: String representation of IP address. + :rtype: str + """ + return str(ip_address(ip_int)) + + @staticmethod def vpp_ip_probe(node, interface, addr, if_type="key"): """Run ip probe on VPP node. |