aboutsummaryrefslogtreecommitdiffstats
path: root/extras/vpp_config/vpplib/VPPUtil.py
diff options
context:
space:
mode:
authorJohn DeNisco <jdenisco@cisco.com>2017-10-17 11:07:22 -0400
committerDave Barach <openvpp@barachs.net>2017-10-17 16:48:26 +0000
commita3db0782d4c069733fa2e3ac1763efd4499b1de7 (patch)
treebcb1ab374cc9cdbe6182f04c50e3204dd974427d /extras/vpp_config/vpplib/VPPUtil.py
parentcdeb7f2ae0acb19e7f74431d03b6c80035898f80 (diff)
Initial commit for phase 2, Add some simple validation.
Change-Id: I5b1d5600cdef4b05cc7c2f1cddb60aed2cc49ac2 Signed-off-by: John DeNisco <jdenisco@cisco.com>
Diffstat (limited to 'extras/vpp_config/vpplib/VPPUtil.py')
-rw-r--r--extras/vpp_config/vpplib/VPPUtil.py41
1 files changed, 40 insertions, 1 deletions
diff --git a/extras/vpp_config/vpplib/VPPUtil.py b/extras/vpp_config/vpplib/VPPUtil.py
index 350b7759a03..f042e80bd8f 100644
--- a/extras/vpp_config/vpplib/VPPUtil.py
+++ b/extras/vpp_config/vpplib/VPPUtil.py
@@ -373,6 +373,45 @@ class VPPUtil(object):
self.exec_command('vppctl sh {}'.format(value))
@staticmethod
+ def get_int_ip(node):
+ """
+ Get the VPP interfaces and IP addresses
+
+ :param node: VPP node.
+ :type node: dict
+ :returns: Dictionary containing VPP interfaces and IP addresses
+ :rtype: dictionary
+ """
+ interfaces = {}
+ cmd = 'vppctl show int addr'
+ (ret, stdout, stderr) = VPPUtil.exec_command(cmd)
+ if ret != 0:
+ return interfaces
+
+ lines = stdout.split('\n')
+ if len(lines[0]) is not 0:
+ if lines[0].split(' ')[0] == 'FileNotFoundError':
+ return interfaces
+
+ for line in lines:
+ if len(line) is 0:
+ continue
+
+ # If the first character is not whitespace
+ # create a new interface
+ if len(re.findall(r'\s', line[0])) is 0:
+ spl = line.split()
+ name = spl[0]
+ if name == 'local0':
+ continue
+ interfaces[name] = {}
+ interfaces[name]['state'] = spl[1].lstrip('(').rstrip('):\r')
+ else:
+ interfaces[name]['address'] = line.lstrip(' ').rstrip('\r')
+
+ return interfaces
+
+ @staticmethod
def get_hardware(node):
"""
Get the VPP hardware information and return it in a
@@ -380,7 +419,7 @@ class VPPUtil(object):
:param node: VPP node.
:type node: dict
- :returns: Dictionary containing improtant VPP information
+ :returns: Dictionary containing VPP hardware information
:rtype: dictionary
"""