aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/python/IPUtil.py
diff options
context:
space:
mode:
authorJan Gelety <jgelety@cisco.com>2019-06-14 04:42:57 +0200
committerJan Gelety <jgelety@cisco.com>2019-07-11 17:33:20 +0200
commita1fc500f02538b35f88abd620f426f02f447933d (patch)
tree167aa2662fc6531fd3a2cc66d0a9e91602fa2342 /resources/libraries/python/IPUtil.py
parentf88a3d9178dfbd73d0479f9aa2f5224e0c89ca1f (diff)
CSIT-1469: Migrate IPsecUtil library from VAT to PAPI
Change-Id: Iac790bf5755a70697e4c4eff32242b04f8e7f789 Signed-off-by: Jan Gelety <jgelety@cisco.com>
Diffstat (limited to 'resources/libraries/python/IPUtil.py')
-rw-r--r--resources/libraries/python/IPUtil.py22
1 files changed, 16 insertions, 6 deletions
diff --git a/resources/libraries/python/IPUtil.py b/resources/libraries/python/IPUtil.py
index 0212ead1d7..f88e234a1a 100644
--- a/resources/libraries/python/IPUtil.py
+++ b/resources/libraries/python/IPUtil.py
@@ -446,6 +446,21 @@ class IPUtil(object):
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
.se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
# Set the default behavior, in case people don't have core.autocrlf set.
* text=auto

# Explicitly declare text files you want to always be normalized and converted
# to native line endings on checkout.
*.robot text
*.rst text
*.yaml text
*.vat text

## Declare files that will always have CRLF line endings on checkout.
#*.sln text eol=crlf

# Denote all files that are truly binary and should not be modified.
*.png binary
*.jpg binary