aboutsummaryrefslogtreecommitdiffstats
path: root/resources/libraries/python
diff options
context:
space:
mode:
authorPeter Mikus <pmikus@cisco.com>2019-11-19 12:00:57 +0000
committerPeter Mikus <pmikus@cisco.com>2019-12-17 14:58:10 +0000
commit3ff919f8eb9fa7eb98887f029be7f817de7a1303 (patch)
treed8352bf3d6b51d636d3f7d5adccbe7166134f98c /resources/libraries/python
parent20083f2e3d4fcd603ecba522e08e445b932cca5f (diff)
Telemetry: Add more operational data
+ Add both NDR and PDR telemetry capture + Speedup sockets + Adjust privileges Signed-off-by: Peter Mikus <pmikus@cisco.com> Change-Id: Ia6fd5d405e6fb410651d8b705c921653753aea10
Diffstat (limited to 'resources/libraries/python')
-rw-r--r--resources/libraries/python/PapiExecutor.py16
-rw-r--r--resources/libraries/python/VPPUtil.py16
-rw-r--r--resources/libraries/python/VppCounters.py46
3 files changed, 49 insertions, 29 deletions
diff --git a/resources/libraries/python/PapiExecutor.py b/resources/libraries/python/PapiExecutor.py
index cbb3e28603..8308303b8a 100644
--- a/resources/libraries/python/PapiExecutor.py
+++ b/resources/libraries/python/PapiExecutor.py
@@ -89,7 +89,6 @@ class PapiSocketExecutor:
The reconnection is logged at WARN level, so it is prominently shown
in log.html, so we can see how frequently it happens.
- TODO: Support sockets in NFs somehow.
TODO: Support handling of retval!=0 without try/except in caller.
Note: Use only with "with" statement, e.g.:
@@ -222,6 +221,7 @@ class PapiSocketExecutor:
:returns: self
:rtype: PapiSocketExecutor
"""
+ time_enter = time.time()
# Parsing takes longer than connecting, prepare instance before tunnel.
vpp_instance = self.vpp_instance
node = self._node
@@ -244,16 +244,11 @@ class PapiSocketExecutor:
# Even if ssh can perhaps reuse this file,
# we need to remove it for readiness detection to work correctly.
run([u"rm", u"-rvf", self._local_vpp_socket])
- # On VIRL, the ssh user is not added to "vpp" group,
- # so we need to change remote socket file access rights.
- exec_cmd_no_error(
- node, u"chmod o+rwx " + self._remote_vpp_socket, sudo=True
- )
- # We use sleep command. The ssh command will exit in 10 second,
+ # We use sleep command. The ssh command will exit in 30 second,
# unless a local socket connection is established,
# in which case the ssh command will exit only when
# the ssh connection is closed again (via control socket).
- # The log level is to supress "Warning: Permanently added" messages.
+ # The log level is to suppress "Warning: Permanently added" messages.
ssh_cmd = [
u"ssh", u"-S", ssh_socket, u"-M",
u"-o", u"LogLevel=ERROR", u"-o", u"UserKnownHostsFile=/dev/null",
@@ -261,7 +256,7 @@ class PapiSocketExecutor:
u"-o", u"ExitOnForwardFailure=yes",
u"-L", self._local_vpp_socket + u":" + self._remote_vpp_socket,
u"-p", str(node[u"port"]), node[u"username"] + u"@" + node[u"host"],
- u"sleep", u"10"
+ u"sleep", u"30"
]
priv_key = node.get(u"priv_key")
if priv_key:
@@ -311,6 +306,9 @@ class PapiSocketExecutor:
break
else:
raise RuntimeError(u"Failed to connect to VPP over a socket.")
+ logger.trace(
+ f"Establishing socket connection took {time.time()-time_enter}s"
+ )
return self
def __exit__(self, exc_type, exc_val, exc_tb):
diff --git a/resources/libraries/python/VPPUtil.py b/resources/libraries/python/VPPUtil.py
index 7dabb4fc61..865775f995 100644
--- a/resources/libraries/python/VPPUtil.py
+++ b/resources/libraries/python/VPPUtil.py
@@ -117,6 +117,18 @@ class VPPUtil:
exec_cmd_no_error(node, cmd, message=u"VPP is not installed!")
@staticmethod
+ def adjust_privileges(node):
+ """Adjust privileges to control VPP without sudo.
+
+ :param node: Topology node.
+ :type node: dict
+ """
+ cmd = u"chmod -R o+rwx /run/vpp"
+ exec_cmd_no_error(
+ node, cmd, sudo=True, message=u"Failed to adjust privileges!",
+ retries=120)
+
+ @staticmethod
def verify_vpp_started(node):
"""Verify that VPP is started on the specified topology node.
@@ -137,7 +149,7 @@ class VPPUtil:
@staticmethod
def verify_vpp(node):
"""Verify that VPP is installed and started on the specified topology
- node.
+ node. Adjust privileges so user can connect without sudo.
:param node: Topology node.
:type node: dict
@@ -147,6 +159,8 @@ class VPPUtil:
try:
# Verify responsiveness of vppctl.
VPPUtil.verify_vpp_started(node)
+ # Adjust privileges.
+ VPPUtil.adjust_privileges(node)
# Verify responsiveness of PAPI.
VPPUtil.show_log(node)
VPPUtil.vpp_show_version(node)
diff --git a/resources/libraries/python/VppCounters.py b/resources/libraries/python/VppCounters.py
index e6bb51ef4e..411302ae58 100644
--- a/resources/libraries/python/VppCounters.py
+++ b/resources/libraries/python/VppCounters.py
@@ -114,7 +114,7 @@ class VppCounters:
)
@staticmethod
- def vpp_show_runtime_counters_on_all_duts(nodes):
+ def vpp_show_runtime_on_all_duts(nodes):
"""Clear VPP runtime counters on all DUTs.
:param nodes: VPP nodes.
@@ -125,8 +125,8 @@ class VppCounters:
VppCounters.vpp_show_runtime(node)
@staticmethod
- def vpp_show_hardware_verbose(node):
- """Run "show hardware-interfaces verbose" debug CLI command.
+ def vpp_show_interface(node):
+ """Run "show interface" debug CLI command.
:param node: Node to run command on.
:type node: dict
@@ -149,6 +149,17 @@ class VppCounters:
)
@staticmethod
+ def vpp_show_memory_on_all_duts(nodes):
+ """Run "show memory" on all DUTs.
+
+ :param nodes: VPP nodes.
+ :type nodes: dict
+ """
+ for node in nodes.values():
+ if node[u"type"] == NodeType.DUT:
+ VppCounters.vpp_show_memory(node)
+
+ @staticmethod
def vpp_clear_runtime(node):
"""Run "clear runtime" CLI command.
@@ -160,7 +171,7 @@ class VppCounters:
)
@staticmethod
- def vpp_clear_runtime_counters_on_all_duts(nodes):
+ def vpp_clear_runtime_on_all_duts(nodes):
"""Run "clear runtime" CLI command on all DUTs.
:param nodes: VPP nodes.
@@ -171,8 +182,8 @@ class VppCounters:
VppCounters.vpp_clear_runtime(node)
@staticmethod
- def vpp_clear_hardware_counters(node):
- """Run "clear hardware" CLI command.
+ def vpp_clear_interfaces(node):
+ """Run "clear interfaces" CLI command.
:param node: Node to run command on.
:type node: dict
@@ -180,22 +191,22 @@ class VppCounters:
:rtype: dict
"""
PapiSocketExecutor.run_cli_cmd_on_all_sockets(
- node, u"clear hardware", log=False
+ node, u"clear interfaces", log=False
)
@staticmethod
- def vpp_clear_hardware_counters_on_all_duts(nodes):
- """Clear hardware counters on all DUTs.
+ def vpp_clear_interfaces_on_all_duts(nodes):
+ """Clear interfaces on all DUTs.
:param nodes: VPP nodes.
:type nodes: dict
"""
for node in nodes.values():
if node[u"type"] == NodeType.DUT:
- VppCounters.vpp_clear_hardware_counters(node)
+ VppCounters.vpp_clear_interfaces(node)
@staticmethod
- def vpp_clear_errors_counters(node):
+ def vpp_clear_errors(node):
"""Run "clear errors" CLI command.
:param node: Node to run command on.
@@ -206,7 +217,7 @@ class VppCounters:
)
@staticmethod
- def vpp_clear_error_counters_on_all_duts(nodes):
+ def vpp_clear_errors_on_all_duts(nodes):
"""Clear VPP errors counters on all DUTs.
:param nodes: VPP nodes.
@@ -214,7 +225,7 @@ class VppCounters:
"""
for node in nodes.values():
if node[u"type"] == NodeType.DUT:
- VppCounters.vpp_clear_errors_counters(node)
+ VppCounters.vpp_clear_errors(node)
@staticmethod
def show_vpp_statistics(node):
@@ -224,9 +235,7 @@ class VppCounters:
:type node: dict
"""
VppCounters.vpp_show_errors(node)
- VppCounters.vpp_show_hardware_verbose(node)
- VppCounters.vpp_show_runtime(node)
- VppCounters.vpp_show_memory(node)
+ VppCounters.vpp_show_interface(node)
@staticmethod
def show_statistics_on_all_duts(nodes):
@@ -246,9 +255,8 @@ class VppCounters:
:param node: VPP node.
:type node: dict
"""
- VppCounters.vpp_clear_errors_counters(node)
- VppCounters.vpp_clear_hardware_counters(node)
- VppCounters.vpp_clear_runtime(node)
+ VppCounters.vpp_clear_errors(node)
+ VppCounters.vpp_clear_interfaces(node)
@staticmethod
def clear_statistics_on_all_duts(nodes):