aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/python/IPv4Util.py
diff options
context:
space:
mode:
authorZdeno Olsovsky <zolsovsk@cisco.com>2016-05-10 15:08:07 +0200
committerJan Gelety <jgelety@cisco.com>2016-06-07 19:28:45 +0000
commit6000b2abc3d6b8bb8ff2941aacf005a04a33be60 (patch)
treed2031eea37b779b77efaee90a30b89ed27f4fb83 /resources/libraries/python/IPv4Util.py
parent559a2b904cf95e4a5a82726d8b3791e57e7a9f9c (diff)
4 Vhosts setup test
-JIRA: CSIT-64 Change-Id: I0d6fc522f3214d1b4887e65d5639a323efdf7dd7 Signed-off-by: Zdeno Olsovsky <zolsovsk@cisco.com>
Diffstat (limited to 'resources/libraries/python/IPv4Util.py')
-rw-r--r--resources/libraries/python/IPv4Util.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/resources/libraries/python/IPv4Util.py b/resources/libraries/python/IPv4Util.py
index 5ee73c08fc..4fe711fbff 100644
--- a/resources/libraries/python/IPv4Util.py
+++ b/resources/libraries/python/IPv4Util.py
@@ -18,6 +18,7 @@ from robot.api.deco import keyword
from resources.libraries.python.topology import Topology
from resources.libraries.python.IPv4Setup import get_node
+from resources.libraries.python.ssh import exec_cmd
class IPv4Util(object):
@@ -160,3 +161,29 @@ class IPv4Util(object):
if net is None:
raise ValueError('Link "{0}" not found'.format(link))
return net.get('prefix')
+
+ @staticmethod
+ def send_ping_from_node_to_dst(node, destination, namespace=None,
+ ping_count=3):
+ """Send a ping from node to destination. Optionally, you can define a
+ namespace from where to send a ping.
+
+ :param node: Node to start ping on.
+ :param destination: IPv4 address where to send ping.
+ :param namespace: Namespace to send ping from.
+ :param ping_count: Number of pings to send.
+ :type node: dict
+ :type destination: str
+ :type namespace: str
+ :type ping_count: int
+ :raises RuntimeError: If no response for ping, raise error
+ """
+ cmd = ''
+ if namespace is not None:
+ cmd = 'ip netns exec {0} ping -c{1} {2}'.format(
+ namespace, ping_count, destination)
+ else:
+ cmd = 'ping -c{0} {1}'.format(ping_count, destination)
+ rc, stdout, stderr = exec_cmd(node, cmd, sudo=True)
+ if rc != 0:
+ raise RuntimeError("Ping Not Successful")