X-Git-Url: https://gerrit.fd.io/r/gitweb?a=blobdiff_plain;f=resources%2Flibraries%2Fpython%2FIPUtil.py;h=2109997e993ec9af1a16eea6148280dc49dfa5e0;hb=6da7266754c28754c04cf37d1974e39766a261f6;hp=0212ead1d7a3146a819c75045815900dc851a45a;hpb=f88a3d9178dfbd73d0479f9aa2f5224e0c89ca1f;p=csit.git diff --git a/resources/libraries/python/IPUtil.py b/resources/libraries/python/IPUtil.py index 0212ead1d7..2109997e99 100644 --- a/resources/libraries/python/IPUtil.py +++ b/resources/libraries/python/IPUtil.py @@ -55,7 +55,7 @@ class FibPathType(IntEnum): class FibPathFlags(IntEnum): """FIB path flags.""" FIB_PATH_FLAG_NONE = 0 - FIB_PATH_FLAG_RESOLVE_VIA_ATTACHED = 1 + FIB_PATH_FLAG_RESOLVE_VIA_ATTACHED = 1 #pylint: disable=invalid-name FIB_PATH_FLAG_RESOLVE_VIA_HOST = 2 @@ -445,6 +445,21 @@ class IPUtil(object): return dict(ip6=ip_addr.packed) if ip_addr.version == 6 \ else dict(ip4=ip_addr.packed) + @staticmethod + def create_ip_address_object(ip_addr): + """Create IP address object. + + :param ip_addr: IPv4 or IPv6 address + :type ip_addr: IPv4Address or IPv6Address + :returns: IP address object. + :rtype: dict + """ + return dict( + af=getattr( + AddressFamily, 'ADDRESS_IP6' if ip_addr.version == 6 + else 'ADDRESS_IP4').value, + un=IPUtil.union_addr(ip_addr)) + @staticmethod def compose_vpp_route_structure(node, network, prefix_len, **kwargs): """Create route object for ip_route_add_del api call. @@ -476,11 +491,7 @@ class IPUtil(object): net_addr = ip_address(unicode(network)) - addr = dict( - af=getattr( - AddressFamily, 'ADDRESS_IP6' if net_addr.version == 6 - else 'ADDRESS_IP4').value, - un=None) + addr = IPUtil.create_ip_address_object(net_addr) prefix = dict( len=int(prefix_len), address=addr) @@ -517,7 +528,6 @@ class IPUtil(object): prefix=prefix, n_paths=len(paths), paths=paths) - return route @staticmethod @@ -583,8 +593,6 @@ class IPUtil(object): IPUtil.union_addr(net_addr + i) history = False if 1 < i < kwargs.get('count', 1) else True papi_exec.add(cmd, history=history, **args) - if i > 0 and i % Constants.PAPI_MAX_API_BULK == 0: - papi_exec.get_replies(err_msg) papi_exec.get_replies(err_msg) @staticmethod