aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/python
diff options
context:
space:
mode:
authorJuraj Sloboda <jsloboda@cisco.com>2016-02-17 16:59:09 +0100
committerStefan Kobza <skobza@cisco.com>2016-02-19 12:45:38 +0000
commitbfde681c3d8ae0008ecec131a18d3a2560a046ae (patch)
treee3a5a3ced1cf7b3d8b3637c4730cd43baeb6a8d2 /resources/libraries/python
parent8fe33363488d044c98650b4f9b778ea3d3e33327 (diff)
Convert ipv4 to use node_path
Change-Id: Ie5587d4de9accb852e8f7634c42b9ccd9292830b Signed-off-by: Juraj Sloboda <jsloboda@cisco.com> Signed-off-by: Stefan Kobza <skobza@cisco.com>
Diffstat (limited to 'resources/libraries/python')
-rw-r--r--resources/libraries/python/IPv4Util.py32
1 files changed, 32 insertions, 0 deletions
diff --git a/resources/libraries/python/IPv4Util.py b/resources/libraries/python/IPv4Util.py
index 30e185c9ff..98c089fcdb 100644
--- a/resources/libraries/python/IPv4Util.py
+++ b/resources/libraries/python/IPv4Util.py
@@ -142,3 +142,35 @@ class IPv4Util(object):
:return:
"""
get_node(node).flush_ip_addresses(port)
+
+ @staticmethod
+ def get_link_address(link, nodes_addr):
+ """Get link IPv4 address.
+
+ :param link: Link name.
+ :param nodes_addr: Available nodes IPv4 adresses.
+ :type link: str
+ :type nodes_addr: dict
+ :return: Link IPv4 address.
+ :rtype: str
+ """
+ net = nodes_addr.get(link)
+ if net is None:
+ raise ValueError('Link "{0}" not found'.format(link))
+ return net.get('net_addr')
+
+ @staticmethod
+ def get_link_prefix(link, nodes_addr):
+ """Get link IPv4 address prefix.
+
+ :param link: Link name.
+ :param nodes_addr: Available nodes IPv4 adresses.
+ :type link: str
+ :type nodes_addr: dict
+ :return: Link IPv4 address prefix.
+ :rtype: int
+ """
+ net = nodes_addr.get(link)
+ if net is None:
+ raise ValueError('Link "{0}" not found'.format(link))
+ return net.get('prefix')