summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHanoh Haim <hhaim@cisco.com>2016-03-10 17:37:03 +0200
committerHanoh Haim <hhaim@cisco.com>2016-03-10 17:37:03 +0200
commit54fb838e24607af8532f725997b670f482abfe96 (patch)
treee3249eb6ef7b41f36b8fe2ef37bec6554859f2ec
parent8ea0aeb8506b4da6b574700519ff4ca77b833c62 (diff)
first Stateless API doc
-rw-r--r--scripts/automation/trex_control_plane/doc_stl/Makefile192
-rw-r--r--scripts/automation/trex_control_plane/doc_stl/_static/no_scrollbars.css10
-rw-r--r--scripts/automation/trex_control_plane/doc_stl/api/client_code.rst17
-rw-r--r--scripts/automation/trex_control_plane/doc_stl/api/index.rst13
-rw-r--r--scripts/automation/trex_control_plane/doc_stl/conf.py312
-rw-r--r--scripts/automation/trex_control_plane/doc_stl/index.rst31
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py693
7 files changed, 1016 insertions, 252 deletions
diff --git a/scripts/automation/trex_control_plane/doc_stl/Makefile b/scripts/automation/trex_control_plane/doc_stl/Makefile
new file mode 100644
index 00000000..37a28d0f
--- /dev/null
+++ b/scripts/automation/trex_control_plane/doc_stl/Makefile
@@ -0,0 +1,192 @@
+# Makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line.
+SPHINXOPTS =
+SPHINXBUILD = sphinx-build
+PAPER =
+BUILDDIR = _build
+
+# User-friendly check for sphinx-build
+ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
+$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)
+endif
+
+# Internal variables.
+PAPEROPT_a4 = -D latex_paper_size=a4
+PAPEROPT_letter = -D latex_paper_size=letter
+ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+# the i18n builder cannot share the environment and doctrees with the others
+I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+
+.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest coverage gettext
+
+help:
+ @echo "Please use \`make <target>' where <target> is one of"
+ @echo " html to make standalone HTML files"
+ @echo " dirhtml to make HTML files named index.html in directories"
+ @echo " singlehtml to make a single large HTML file"
+ @echo " pickle to make pickle files"
+ @echo " json to make JSON files"
+ @echo " htmlhelp to make HTML files and a HTML help project"
+ @echo " qthelp to make HTML files and a qthelp project"
+ @echo " applehelp to make an Apple Help Book"
+ @echo " devhelp to make HTML files and a Devhelp project"
+ @echo " epub to make an epub"
+ @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
+ @echo " latexpdf to make LaTeX files and run them through pdflatex"
+ @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
+ @echo " text to make text files"
+ @echo " man to make manual pages"
+ @echo " texinfo to make Texinfo files"
+ @echo " info to make Texinfo files and run them through makeinfo"
+ @echo " gettext to make PO message catalogs"
+ @echo " changes to make an overview of all changed/added/deprecated items"
+ @echo " xml to make Docutils-native XML files"
+ @echo " pseudoxml to make pseudoxml-XML files for display purposes"
+ @echo " linkcheck to check all external links for integrity"
+ @echo " doctest to run all doctests embedded in the documentation (if enabled)"
+ @echo " coverage to run coverage check of the documentation (if enabled)"
+
+clean:
+ rm -rf $(BUILDDIR)/*
+
+html:
+ $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
+ @echo
+ @echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
+
+dirhtml:
+ $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
+ @echo
+ @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
+
+singlehtml:
+ $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
+ @echo
+ @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
+
+pickle:
+ $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
+ @echo
+ @echo "Build finished; now you can process the pickle files."
+
+json:
+ $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
+ @echo
+ @echo "Build finished; now you can process the JSON files."
+
+htmlhelp:
+ $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
+ @echo
+ @echo "Build finished; now you can run HTML Help Workshop with the" \
+ ".hhp project file in $(BUILDDIR)/htmlhelp."
+
+qthelp:
+ $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
+ @echo
+ @echo "Build finished; now you can run "qcollectiongenerator" with the" \
+ ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
+ @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/T-RexProjectControlPlain.qhcp"
+ @echo "To view the help file:"
+ @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/T-RexProjectControlPlain.qhc"
+
+applehelp:
+ $(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp
+ @echo
+ @echo "Build finished. The help book is in $(BUILDDIR)/applehelp."
+ @echo "N.B. You won't be able to view it unless you put it in" \
+ "~/Library/Documentation/Help or install it in your application" \
+ "bundle."
+
+devhelp:
+ $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
+ @echo
+ @echo "Build finished."
+ @echo "To view the help file:"
+ @echo "# mkdir -p $$HOME/.local/share/devhelp/T-RexProjectControlPlain"
+ @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/T-RexProjectControlPlain"
+ @echo "# devhelp"
+
+epub:
+ $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
+ @echo
+ @echo "Build finished. The epub file is in $(BUILDDIR)/epub."
+
+latex:
+ $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+ @echo
+ @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
+ @echo "Run \`make' in that directory to run these through (pdf)latex" \
+ "(use \`make latexpdf' here to do that automatically)."
+
+latexpdf:
+ $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+ @echo "Running LaTeX files through pdflatex..."
+ $(MAKE) -C $(BUILDDIR)/latex all-pdf
+ @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
+
+latexpdfja:
+ $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+ @echo "Running LaTeX files through platex and dvipdfmx..."
+ $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
+ @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
+
+text:
+ $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
+ @echo
+ @echo "Build finished. The text files are in $(BUILDDIR)/text."
+
+man:
+ $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
+ @echo
+ @echo "Build finished. The manual pages are in $(BUILDDIR)/man."
+
+texinfo:
+ $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
+ @echo
+ @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
+ @echo "Run \`make' in that directory to run these through makeinfo" \
+ "(use \`make info' here to do that automatically)."
+
+info:
+ $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
+ @echo "Running Texinfo files through makeinfo..."
+ make -C $(BUILDDIR)/texinfo info
+ @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
+
+gettext:
+ $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
+ @echo
+ @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
+
+changes:
+ $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
+ @echo
+ @echo "The overview file is in $(BUILDDIR)/changes."
+
+linkcheck:
+ $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
+ @echo
+ @echo "Link check complete; look for any errors in the above output " \
+ "or in $(BUILDDIR)/linkcheck/output.txt."
+
+doctest:
+ $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
+ @echo "Testing of doctests in the sources finished, look at the " \
+ "results in $(BUILDDIR)/doctest/output.txt."
+
+coverage:
+ $(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage
+ @echo "Testing of coverage in the sources finished, look at the " \
+ "results in $(BUILDDIR)/coverage/python.txt."
+
+xml:
+ $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
+ @echo
+ @echo "Build finished. The XML files are in $(BUILDDIR)/xml."
+
+pseudoxml:
+ $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
+ @echo
+ @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
diff --git a/scripts/automation/trex_control_plane/doc_stl/_static/no_scrollbars.css b/scripts/automation/trex_control_plane/doc_stl/_static/no_scrollbars.css
new file mode 100644
index 00000000..f86e823a
--- /dev/null
+++ b/scripts/automation/trex_control_plane/doc_stl/_static/no_scrollbars.css
@@ -0,0 +1,10 @@
+/* override table width restrictions */
+.wy-table-responsive table td, .wy-table-responsive table th {
+ /* !important prevents the common CSS stylesheets from
+ overriding this as on RTD they are loaded after this stylesheet */
+ white-space: normal !important;
+}
+
+.wy-table-responsive {
+ overflow: visible !important;
+} \ No newline at end of file
diff --git a/scripts/automation/trex_control_plane/doc_stl/api/client_code.rst b/scripts/automation/trex_control_plane/doc_stl/api/client_code.rst
new file mode 100644
index 00000000..ef7feb61
--- /dev/null
+++ b/scripts/automation/trex_control_plane/doc_stl/api/client_code.rst
@@ -0,0 +1,17 @@
+
+Module documentation
+================================
+
+STLClient class
+-----------------
+
+.. autoclass:: trex_stl_lib.trex_stl_client.STLClient
+ :members:
+
+Stream class
+-----------------
+
+.. automodule:: trex_stl_lib.trex_stl_streams
+ :members:
+
+
diff --git a/scripts/automation/trex_control_plane/doc_stl/api/index.rst b/scripts/automation/trex_control_plane/doc_stl/api/index.rst
new file mode 100644
index 00000000..4e4be230
--- /dev/null
+++ b/scripts/automation/trex_control_plane/doc_stl/api/index.rst
@@ -0,0 +1,13 @@
+
+TRex Stateless API Reference
+============================
+
+**TRex Modules**
+
+.. toctree::
+ :maxdepth: 4
+
+ client_code
+
+**TRex JSON Template**
+
diff --git a/scripts/automation/trex_control_plane/doc_stl/conf.py b/scripts/automation/trex_control_plane/doc_stl/conf.py
new file mode 100644
index 00000000..6dfb4f70
--- /dev/null
+++ b/scripts/automation/trex_control_plane/doc_stl/conf.py
@@ -0,0 +1,312 @@
+# -*- coding: utf-8 -*-
+#
+# TRex Control Plain documentation build configuration file, created by
+# sphinx-quickstart on Tue Jun 2 07:48:10 2015.
+#
+# This file is execfile()d with the current directory set to its
+# containing dir.
+#
+# Note that not all possible configuration values are present in this
+# autogenerated file.
+#
+# All configuration values have a default; values that are commented out
+# serve to show the default.
+
+import sys
+import os
+import shlex
+
+
+# If extensions (or modules to document with autodoc) are in another directory,
+# add these directories to sys.path here. If the directory is relative to the
+# documentation root, use os.path.abspath to make it absolute, like shown here.
+sys.path.insert(0, os.path.abspath('../stl'))
+## add all external libs path manually
+external_libs_path = os.path.join(os.pardir, os.pardir, os.pardir, "external_libs")
+external_libs_pkgs = [os.path.join(external_libs_path, p)
+ for p in os.listdir(external_libs_path)
+ if os.path.isdir(os.path.join(external_libs_path, p))]
+for p in external_libs_pkgs:
+ sys.path.insert(1, p)
+
+# -- General configuration ------------------------------------------------
+
+# If your documentation needs a minimal Sphinx version, state it here.
+#needs_sphinx = '1.0'
+
+# Add any Sphinx extension module names here, as strings. They can be
+# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
+# ones.
+extensions = [
+ 'sphinx.ext.autodoc',
+ 'sphinx.ext.todo',
+ 'sphinx.ext.viewcode',
+]
+
+# Add any paths that contain templates here, relative to this directory.
+templates_path = ['_templates']
+
+# The suffix(es) of source filenames.
+# You can specify multiple suffix as a list of string:
+# source_suffix = ['.rst', '.md']
+source_suffix = '.rst'
+
+# The encoding of source files.
+#source_encoding = 'utf-8-sig'
+
+# The master toctree document.
+master_doc = 'index'
+
+# General information about the project.
+project = u'TRex Stateless Python API'
+copyright = u'2015, Cisco Systems Inc.'
+author = u'TRex team, Cisco Systems Inc.'
+
+# The version info for the project you're documenting, acts as replacement for
+# |version| and |release|, also used in various other places throughout the
+# built documents.
+#
+# The short X.Y version.
+version = '1.94'
+# The full version, including alpha/beta/rc tags.
+release = '1.7.1'
+
+# The language for content autogenerated by Sphinx. Refer to documentation
+# for a list of supported languages.
+#
+# This is also used if you do content translation via gettext catalogs.
+# Usually you set "language" from the command line for these cases.
+language = None
+
+# There are two options for replacing |today|: either, you set today to some
+# non-false value, then it is used:
+#today = ''
+# Else, today_fmt is used as the format for a strftime call.
+#today_fmt = '%B %d, %Y'
+
+# List of patterns, relative to source directory, that match files and
+# directories to ignore when looking for source files.
+exclude_patterns = ['_build']
+
+# The reST default role (used for this markup: `text`) to use for all
+# documents.
+#default_role = None
+
+# If true, '()' will be appended to :func: etc. cross-reference text.
+#add_function_parentheses = True
+
+# If true, the current module name will be prepended to all description
+# unit titles (such as .. function::).
+#add_module_names = True
+
+# If true, sectionauthor and moduleauthor directives will be shown in the
+# output. They are ignored by default.
+#show_authors = False
+
+# The name of the Pygments (syntax highlighting) style to use.
+pygments_style = 'sphinx'
+
+# A list of ignored prefixes for module index sorting.
+#modindex_common_prefix = []
+
+# If true, keep warnings as "system message" paragraphs in the built documents.
+#keep_warnings = False
+
+# If true, `todo` and `todoList` produce output, else they produce nothing.
+todo_include_todos = True
+
+
+# -- Options for HTML output ----------------------------------------------
+
+# The theme to use for HTML and HTML Help pages. See the documentation for
+# a list of builtin themes.
+#html_theme = 'sphinx_rtd_theme'
+#html_theme = 'classic'
+html_theme = 'sphinxdoc'
+
+#html_theme_options = {
+# "rightsidebar": "true"
+# }
+
+autodoc_docstring_signature = True
+
+# Theme options are theme-specific and customize the look and feel of a theme
+# further. For a list of options available for each theme, see the
+# documentation.
+#html_theme_options = {}
+
+# Add any paths that contain custom themes here, relative to this directory.
+#html_theme_path = []
+
+# The name for this set of Sphinx documents. If None, it defaults to
+# "<project> v<release> documentation".
+#html_title = None
+
+# A shorter title for the navigation bar. Default is the same as html_title.
+#html_short_title = None
+
+# The name of an image file (relative to this directory) to place at the top
+# of the sidebar.
+#html_logo = None
+
+# The name of an image file (within the static path) to use as favicon of the
+# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
+# pixels large.
+#html_favicon = None
+
+# Add any paths that contain custom static files (such as style sheets) here,
+# relative to this directory. They are copied after the builtin static files,
+# so a file named "default.css" will overwrite the builtin "default.css".
+html_static_path = ['_static']
+
+# Add any extra paths that contain custom files (such as robots.txt or
+# .htaccess) here, relative to this directory. These files are copied
+# directly to the root of the documentation.
+#html_extra_path = []
+
+# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
+# using the given strftime format.
+#html_last_updated_fmt = '%b %d, %Y'
+
+# If true, SmartyPants will be used to convert quotes and dashes to
+# typographically correct entities.
+#html_use_smartypants = True
+
+# Custom sidebar templates, maps document names to template names.
+#html_sidebars = {}
+
+# Additional templates that should be rendered to pages, maps page names to
+# template names.
+#html_additional_pages = {}
+
+# If false, no module index is generated.
+#html_domain_indices = True
+
+# If false, no index is generated.
+#html_use_index = True
+
+# If true, the index is split into individual pages for each letter.
+#html_split_index = False
+
+# If true, links to the reST sources are added to the pages.
+#html_show_sourcelink = True
+
+# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
+#html_show_sphinx = True
+
+# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
+#html_show_copyright = True
+
+# If true, an OpenSearch description file will be output, and all pages will
+# contain a <link> tag referring to it. The value of this option must be the
+# base URL from which the finished HTML is served.
+#html_use_opensearch = ''
+
+# This is the file name suffix for HTML files (e.g. ".xhtml").
+#html_file_suffix = None
+
+# Language to be used for generating the HTML full-text search index.
+# Sphinx supports the following languages:
+# 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja'
+# 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr'
+#html_search_language = 'en'
+
+# A dictionary with options for the search language support, empty by default.
+# Now only 'ja' uses this config value
+#html_search_options = {'type': 'default'}
+
+# The name of a javascript file (relative to the configuration directory) that
+# implements a search results scorer. If empty, the default will be used.
+#html_search_scorer = 'scorer.js'
+
+# Output file base name for HTML help builder.
+htmlhelp_basename = 'TRexControlPlaindoc'
+
+# -- Options for LaTeX output ---------------------------------------------
+
+latex_elements = {
+# The paper size ('letterpaper' or 'a4paper').
+#'papersize': 'letterpaper',
+
+# The font size ('10pt', '11pt' or '12pt').
+#'pointsize': '10pt',
+
+# Additional stuff for the LaTeX preamble.
+#'preamble': '',
+
+# Latex figure (float) alignment
+#'figure_align': 'htbp',
+}
+
+# Grouping the document tree into LaTeX files. List of tuples
+# (source start file, target name, title,
+# author, documentclass [howto, manual, or own class]).
+latex_documents = [
+ (master_doc, 'TRexControlPlain.tex', u'TRex Control Plain Documentation',
+ u'hhaim', 'manual'),
+]
+
+# The name of an image file (relative to this directory) to place at the top of
+# the title page.
+#latex_logo = None
+
+# For "manual" documents, if this is true, then toplevel headings are parts,
+# not chapters.
+#latex_use_parts = False
+
+# If true, show page references after internal links.
+#latex_show_pagerefs = False
+
+# If true, show URL addresses after external links.
+#latex_show_urls = False
+
+# Documents to append as an appendix to all manuals.
+#latex_appendices = []
+
+# If false, no module index is generated.
+#latex_domain_indices = True
+
+
+# -- Options for manual page output ---------------------------------------
+
+# One entry per manual page. List of tuples
+# (source start file, name, description, authors, manual section).
+man_pages = [
+ (master_doc, 'TRexcontrolplain', u'TRex Control Plain Documentation',
+ [author], 1)
+]
+
+# If true, show URL addresses after external links.
+#man_show_urls = False
+
+
+# -- Options for Texinfo output -------------------------------------------
+
+# Grouping the document tree into Texinfo files. List of tuples
+# (source start file, target name, title, author,
+# dir menu entry, description, category)
+texinfo_documents = [
+ (master_doc, 'TRexControlPlain', u'TRex Control Plain Documentation',
+ author, 'TRexControlPlain', 'One line description of project.',
+ 'Miscellaneous'),
+]
+
+# Documents to append as an appendix to all manuals.
+#texinfo_appendices = []
+
+# If false, no module index is generated.
+#texinfo_domain_indices = True
+
+# How to display URL addresses: 'footnote', 'no', or 'inline'.
+#texinfo_show_urls = 'footnote'
+
+# If true, do not generate a @detailmenu in the "Top" node's menu.
+#texinfo_no_detailmenu = False
+
+
+# show documentation for both __init__ methods and class methods
+autoclass_content = "both"
+
+# A workaround for the responsive tables always having annoying scrollbars.
+def setup(app):
+ app.add_stylesheet("no_scrollbars.css") \ No newline at end of file
diff --git a/scripts/automation/trex_control_plane/doc_stl/index.rst b/scripts/automation/trex_control_plane/doc_stl/index.rst
new file mode 100644
index 00000000..fe58db25
--- /dev/null
+++ b/scripts/automation/trex_control_plane/doc_stl/index.rst
@@ -0,0 +1,31 @@
+.. TRex Stateless Python API documentation
+ sphinx-quickstart on Tue Jun 2 07:48:10 2015.
+ contain the root `toctree` directive.
+
+TRex Stateless Python API
+==============================================
+
+TRex is a **traffic generator**
+
+This site covers the Python API of TRex and explains how to utilize it to your needs.
+To understand the entirely how the API works and how to set up the server side, check out the `trex-core Wiki <https://github.com/cisco-system-traffic-generator/trex-core/wiki>`_ under the documentation section of TRex website.
+
+**Use the table of contents below or the menu to your left to navigate through the site**
+
+API Reference
+=============
+.. toctree::
+ :maxdepth: 2
+
+ api/index
+
+Indices and tables
+==================
+
+* :ref:`genindex`
+* :ref:`modindex`
+* :ref:`search`
+
+
+.. rubric:: Footnotes
+
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py
index a13e2793..130fee2c 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_client.py
@@ -13,7 +13,7 @@ from trex_stl_async_client import CTRexAsyncClient
from utils import parsing_opts, text_tables, common
from utils.text_opts import *
-
+from functools import wraps
from collections import namedtuple
from yaml import YAMLError
@@ -380,7 +380,7 @@ class CCommLink(object):
############################ #############################
class STLClient(object):
- """docstring for STLClient"""
+ """TRex Stateless client object- gives operations per TRex/user"""
def __init__(self,
username = common.get_current_user(),
@@ -390,7 +390,29 @@ class STLClient(object):
verbose_level = LoggerApi.VERBOSE_QUIET,
logger = None,
virtual = False):
+ """
+ Set the connection setting
+
+ :parameters:
+ username : string
+ the user name, for example imarom
+
+ server : string
+ the server name or ip
+ sync_port : int
+ the RPC port
+
+ async_port : int
+ the ASYNC port
+
+ :return:
+ None
+
+ :raises:
+ None
+
+ """
self.username = username
@@ -829,6 +851,7 @@ class STLClient(object):
def __api_check(connected = True):
def wrap (f):
+ @wraps(f)
def wrap2(*args, **kwargs):
client = args[0]
@@ -867,36 +890,141 @@ class STLClient(object):
# return verbose level of the logger
def get_verbose (self):
+ """
+ get the verbose mode
+
+ :parameters:
+ none
+
+ :return:
+ get the verbose mode as Bool
+
+ :raises:
+ None
+
+ """
return self.logger.get_verbose()
# is the client on read only mode ?
def is_all_ports_acquired (self):
+ """
+ is_all_ports_acquired
+
+ :parameters:
+ none
+
+ :return:
+ return True if all ports are acquired
+
+ :raises:
+ None
+
+ """
+
return not (self.get_all_ports() == self.get_acquired_ports())
# is the client connected ?
def is_connected (self):
+ """
+
+ :parameters:
+ none
+
+ :return:
+ is_connected
+
+ :raises:
+ None
+
+ """
+
return self.connected and self.comm_link.is_connected
# get connection info
def get_connection_info (self):
+ """
+
+ :parameters:
+ none
+
+ :return:
+ connection dict
+
+ :raises:
+ None
+
+ """
+
return self.connection_info
# get supported commands by the server
def get_server_supported_cmds(self):
+ """
+
+ :parameters:
+ none
+
+ :return:
+ connection dict
+
+ :raises:
+ None
+
+ """
+
return self.supported_cmds
# get server version
def get_server_version(self):
+ """
+
+ :parameters:
+ none
+
+ :return:
+ connection dict
+
+ :raises:
+ None
+
+ """
+
return self.server_version
# get server system info
def get_server_system_info(self):
+ """
+
+ :parameters:
+ none
+
+ :return:
+ connection dict
+
+ :raises:
+ None
+
+ """
+
return self.system_info
# get port count
def get_port_count(self):
+ """
+
+ :parameters:
+ none
+
+ :return:
+ connection dict
+
+ :raises:
+ None
+
+ """
+
return len(self.ports)
@@ -911,6 +1039,19 @@ class STLClient(object):
# get all ports as IDs
def get_all_ports (self):
+ """
+
+ :parameters:
+ none
+
+ :return:
+ connection dict
+
+ :raises:
+ None
+
+ """
+
return self.ports.keys()
# get all acquired ports
@@ -976,20 +1117,20 @@ class STLClient(object):
############################ #############################
- """
- Sets verbose level
+ def set_verbose (self, level):
+ """
+ Sets verbose level
- :parameters:
- level : str
- "high"
- "low"
- "normal"
+ :parameters:
+ level : str
+ "high"
+ "low"
+ "normal"
- :raises:
- None
+ :raises:
+ None
- """
- def set_verbose (self, level):
+ """
modes = {'low' : LoggerApi.VERBOSE_QUIET, 'normal': LoggerApi.VERBOSE_REGULAR, 'high': LoggerApi.VERBOSE_HIGH}
if not level in modes.keys():
@@ -998,35 +1139,38 @@ class STLClient(object):
self.logger.set_verbose(modes[level])
- """
- Connects to the TRex server
+ @__api_check(False)
+ def connect (self):
+ """
+ def connect(self):
- :parameters:
- None
+ Connects to the TRex server
- :raises:
- + :exc:`STLError`
+ :parameters:
+ None
+
+ :raises:
+ + :exc:`STLError`
+
+ """
- """
- @__api_check(False)
- def connect (self):
rc = self.__connect()
if not rc:
raise STLError(rc)
- """
- Disconnects from the server
-
- :parameters:
- stop_traffic : bool
- tries to stop traffic before disconnecting
- release_ports : bool
- tries to release all the acquired ports
-
- """
@__api_check(False)
def disconnect (self, stop_traffic = True, release_ports = True):
+ """
+ Disconnects from the server
+
+ :parameters:
+ stop_traffic : bool
+ tries to stop traffic before disconnecting
+ release_ports : bool
+ tries to release all the acquired ports
+
+ """
# try to stop ports but do nothing if not possible
if stop_traffic:
@@ -1043,21 +1187,21 @@ class STLClient(object):
- """
- Acquires ports for executing commands
+ @__api_check(True)
+ def acquire (self, ports = None, force = False):
+ """
+ Acquires ports for executing commands
- :parameters:
- ports : list
- ports to execute the command
- force : bool
- force acquire the ports
+ :parameters:
+ ports : list
+ ports to execute the command
+ force : bool
+ force acquire the ports
- :raises:
- + :exc:`STLError`
+ :raises:
+ + :exc:`STLError`
- """
- @__api_check(True)
- def acquire (self, ports = None, force = False):
+ """
# by default use all ports
ports = ports if ports is not None else self.get_all_ports()
@@ -1078,19 +1222,19 @@ class STLClient(object):
raise STLError(rc)
- """
- Release ports
+ @__api_check(True)
+ def release (self, ports = None):
+ """
+ Release ports
- :parameters:
- ports : list
- ports to execute the command
+ :parameters:
+ ports : list
+ ports to execute the command
- :raises:
- + :exc:`STLError`
+ :raises:
+ + :exc:`STLError`
- """
- @__api_check(True)
- def release (self, ports = None):
+ """
ports = ports if ports is not None else self.get_acquired_ports()
ports = self._validate_port_list(ports)
@@ -1102,19 +1246,20 @@ class STLClient(object):
if not rc:
raise STLError(rc)
- """
- Pings the server
+ @__api_check(True)
+ def ping(self):
+ """
+ Pings the server
- :parameters:
- None
-
+ :parameters:
+ None
- :raises:
- + :exc:`STLError`
- """
- @__api_check(True)
- def ping(self):
+ :raises:
+ + :exc:`STLError`
+
+ """
+
self.logger.pre_cmd( "Pinging the server on '{0}' port '{1}': ".format(self.connection_info['server'],
self.connection_info['sync_port']))
rc = self._transmit("ping")
@@ -1126,6 +1271,18 @@ class STLClient(object):
@__api_check(True)
def get_active_pgids(self):
+ """
+ Get active group ids
+
+ :parameters:
+ None
+
+
+ :raises:
+ + :exc:`STLError`
+
+ """
+
self.logger.pre_cmd( "Getting active packet group ids")
rc = self._transmit("get_active_pgids")
@@ -1136,20 +1293,21 @@ class STLClient(object):
raise STLError(rc)
- """
- force acquire ports, stop the traffic, remove all streams and clear stats
+ @__api_check(True)
+ def reset(self, ports = None):
+ """
+ force acquire ports, stop the traffic, remove all streams and clear stats
- :parameters:
- ports : list
- ports to execute the command
-
+ :parameters:
+ ports : list
+ ports to execute the command
- :raises:
- + :exc:`STLError`
- """
- @__api_check(True)
- def reset(self, ports = None):
+ :raises:
+ + :exc:`STLError`
+
+ """
+
ports = ports if ports is not None else self.get_all_ports()
ports = self._validate_port_list(ports)
@@ -1160,20 +1318,21 @@ class STLClient(object):
self.clear_stats(ports)
- """
- remove all streams from port(s)
+ @__api_check(True)
+ def remove_all_streams (self, ports = None):
+ """
+ remove all streams from port(s)
- :parameters:
- ports : list
- ports to execute the command
-
+ :parameters:
+ ports : list
+ ports to execute the command
- :raises:
- + :exc:`STLError`
- """
- @__api_check(True)
- def remove_all_streams (self, ports = None):
+ :raises:
+ + :exc:`STLError`
+
+ """
+
ports = ports if ports is not None else self.get_acquired_ports()
ports = self._validate_port_list(ports)
@@ -1186,24 +1345,25 @@ class STLClient(object):
raise STLError(rc)
- """
- add a list of streams to port(s)
+ @__api_check(True)
+ def add_streams (self, streams, ports = None):
+ """
+ add a list of streams to port(s)
- :parameters:
- ports : list
- ports to execute the command
- streams: list
- streams to attach (or profile)
+ :parameters:
+ ports : list
+ ports to execute the command
+ streams: list
+ streams to attach (or profile)
- :returns:
- list of stream IDs in order of the stream list
+ :returns:
+ list of stream IDs in order of the stream list
- :raises:
- + :exc:`STLError`
+ :raises:
+ + :exc:`STLError`
+
+ """
- """
- @__api_check(True)
- def add_streams (self, streams, ports = None):
ports = ports if ports is not None else self.get_acquired_ports()
ports = self._validate_port_list(ports)
@@ -1229,22 +1389,23 @@ class STLClient(object):
return [stream.get_id() for stream in streams]
- """
- remove a list of streams from ports
+ @__api_check(True)
+ def remove_streams (self, stream_id_list, ports = None):
+ """
+ remove a list of streams from ports
- :parameters:
- ports : list
- ports to execute the command
- stream_id_list: list
- stream id list to remove
+ :parameters:
+ ports : list
+ ports to execute the command
+ stream_id_list: list
+ stream id list to remove
- :raises:
- + :exc:`STLError`
+ :raises:
+ + :exc:`STLError`
+
+ """
- """
- @__api_check(True)
- def remove_streams (self, stream_id_list, ports = None):
ports = ports if ports is not None else self.get_acquired_ports()
ports = self._validate_port_list(ports)
@@ -1267,34 +1428,6 @@ class STLClient(object):
- """
- start traffic on port(s)
-
- :parameters:
- ports : list
- ports to execute command
-
- mult : str
- multiplier in a form of pps, bps, or line util in %
- examples: "5kpps", "10gbps", "85%", "32mbps"
-
- force : bool
- imply stopping the port of active and also
- forces a profile that exceeds the L1 BW
-
- duration : int
- limit the run for time in seconds
- -1 means unlimited
-
- total : bool
- should the B/W be divided by the ports
- or duplicated for each
-
-
- :raises:
- + :exc:`STLError`
-
- """
@__api_check(True)
def start (self,
ports = None,
@@ -1302,6 +1435,34 @@ class STLClient(object):
force = False,
duration = -1,
total = False):
+ """
+ start traffic on port(s)
+
+ :parameters:
+ ports : list
+ ports to execute command
+
+ mult : str
+ multiplier in a form of pps, bps, or line util in %
+ examples: "5kpps", "10gbps", "85%", "32mbps"
+
+ force : bool
+ imply stopping the port of active and also
+ forces a profile that exceeds the L1 BW
+
+ duration : int
+ limit the run for time in seconds
+ -1 means unlimited
+
+ total : bool
+ should the B/W be divided by the ports
+ or duplicated for each
+
+
+ :raises:
+ + :exc:`STLError`
+
+ """
ports = ports if ports is not None else self.get_acquired_ports()
@@ -1349,19 +1510,19 @@ class STLClient(object):
- """
- stop port(s)
+ @__api_check(True)
+ def stop (self, ports = None):
+ """
+ stop port(s)
- :parameters:
- ports : list
- ports to execute the command
+ :parameters:
+ ports : list
+ ports to execute the command
- :raises:
- + :exc:`STLError`
+ :raises:
+ + :exc:`STLError`
- """
- @__api_check(True)
- def stop (self, ports = None):
+ """
ports = ports if ports is not None else self.get_active_ports()
ports = self._validate_port_list(ports)
@@ -1377,32 +1538,33 @@ class STLClient(object):
raise STLError(rc)
- """
- update traffic on port(s)
+ @__api_check(True)
+ def update (self, ports = None, mult = "1", total = False, force = False):
+ """
+ update traffic on port(s)
- :parameters:
- ports : list
- ports to execute command
+ :parameters:
+ ports : list
+ ports to execute command
- mult : str
- multiplier in a form of pps, bps, or line util in %
- and also with +/-
- examples: "5kpps+", "10gbps-", "85%", "32mbps", "20%+"
+ mult : str
+ multiplier in a form of pps, bps, or line util in %
+ and also with +/-
+ examples: "5kpps+", "10gbps-", "85%", "32mbps", "20%+"
- force : bool
- forces a profile that exceeds the L1 BW
+ force : bool
+ forces a profile that exceeds the L1 BW
- total : bool
- should the B/W be divided by the ports
- or duplicated for each
-
+ total : bool
+ should the B/W be divided by the ports
+ or duplicated for each
- :raises:
- + :exc:`STLError`
- """
- @__api_check(True)
- def update (self, ports = None, mult = "1", total = False, force = False):
+ :raises:
+ + :exc:`STLError`
+
+ """
+
ports = ports if ports is not None else self.get_active_ports()
ports = self._validate_port_list(ports)
@@ -1430,19 +1592,20 @@ class STLClient(object):
- """
- pause traffic on port(s)
+ @__api_check(True)
+ def pause (self, ports = None):
+ """
+ pause traffic on port(s). works only for ports that are active and all streams are in cont mode
- :parameters:
- ports : list
- ports to execute command
+ :parameters:
+ ports : list
+ ports to execute command
- :raises:
- + :exc:`STLError`
+ :raises:
+ + :exc:`STLError`
+
+ """
- """
- @__api_check(True)
- def pause (self, ports = None):
ports = ports if ports is not None else self.get_transmitting_ports()
ports = self._validate_port_list(ports)
@@ -1454,19 +1617,20 @@ class STLClient(object):
if not rc:
raise STLError(rc)
- """
- resume traffic on port(s)
+ @__api_check(True)
+ def resume (self, ports = None):
+ """
+ resume traffic on port(s)
- :parameters:
- ports : list
- ports to execute command
+ :parameters:
+ ports : list
+ ports to execute command
- :raises:
- + :exc:`STLError`
+ :raises:
+ + :exc:`STLError`
+
+ """
- """
- @__api_check(True)
- def resume (self, ports = None):
ports = ports if ports is not None else self.get_paused_ports()
ports = self._validate_port_list(ports)
@@ -1480,31 +1644,32 @@ class STLClient(object):
raise STLError(rc)
- """
- validate port(s) configuration
+ @__api_check(True)
+ def validate (self, ports = None, mult = "1", duration = "-1", total = False):
+ """
+ validate port(s) configuration
- :parameters:
- ports : list
- ports to execute command
+ :parameters:
+ ports : list
+ ports to execute command
- mult : str
- multiplier in a form of pps, bps, or line util in %
- examples: "5kpps", "10gbps", "85%", "32mbps"
+ mult : str
+ multiplier in a form of pps, bps, or line util in %
+ examples: "5kpps", "10gbps", "85%", "32mbps"
- duration : int
- limit the run for time in seconds
- -1 means unlimited
+ duration : int
+ limit the run for time in seconds
+ -1 means unlimited
- total : bool
- should the B/W be divided by the ports
- or duplicated for each
+ total : bool
+ should the B/W be divided by the ports
+ or duplicated for each
- :raises:
- + :exc:`STLError`
+ :raises:
+ + :exc:`STLError`
+
+ """
- """
- @__api_check(True)
- def validate (self, ports = None, mult = "1", duration = "-1", total = False):
ports = ports if ports is not None else self.get_acquired_ports()
ports = self._validate_port_list(ports)
@@ -1531,22 +1696,22 @@ class STLClient(object):
self.ports[port].print_profile(mult_obj, duration)
- """
- clear stats on port(s)
+ @__api_check(False)
+ def clear_stats (self, ports = None, clear_global = True):
+ """
+ clear stats on port(s)
- :parameters:
- ports : list
- ports to execute command
-
- clear_global : bool
- clear the global stats
+ :parameters:
+ ports : list
+ ports to execute command
- :raises:
- + :exc:`STLError`
+ clear_global : bool
+ clear the global stats
- """
- @__api_check(False)
- def clear_stats (self, ports = None, clear_global = True):
+ :raises:
+ + :exc:`STLError`
+
+ """
ports = ports if ports is not None else self.get_all_ports()
ports = self._validate_port_list(ports)
@@ -1562,25 +1727,49 @@ class STLClient(object):
+ @__api_check(True)
+ def is_traffic_active (self, ports = None):
+ """
+ retrun if specify port(s) has traffic
+ :parameters:
+ ports : list
+ ports to execute command
- """
- block until specify port(s) traffic has ended
- :parameters:
- ports : list
- ports to execute command
-
- timeout : int
- timeout in seconds
+ :raises:
+ + :exc:`STLTimeoutError` - in case timeout has expired
+ + :exe:'STLError'
+
+ """
+
+ ports = ports if ports is not None else self.get_acquired_ports()
+ ports = self._validate_port_list(ports)
+
+
+ expr = time.time() + timeout
+
+ return set(self.get_active_ports()).intersection(ports)
+
- :raises:
- + :exc:`STLTimeoutError` - in case timeout has expired
- + :exe:'STLError'
- """
@__api_check(True)
def wait_on_traffic (self, ports = None, timeout = 60):
+ """
+ block until specify port(s) traffic has ended
+
+ :parameters:
+ ports : list
+ ports to execute command
+
+ timeout : int
+ timeout in seconds
+
+ :raises:
+ + :exc:`STLTimeoutError` - in case timeout has expired
+ + :exe:'STLError'
+
+ """
ports = ports if ports is not None else self.get_acquired_ports()
ports = self._validate_port_list(ports)
@@ -1595,19 +1784,18 @@ class STLClient(object):
raise STLTimeoutError(timeout)
- #
- """
- set port(s) attributes
+ @__api_check(True)
+ def set_port_attr (self, ports = None, promiscuous = None):
+ """
+ set port(s) attributes
- :parameters:
- promiscuous - set this to True or False
+ :parameters:
+ promiscuous - set this to True or False
- :raises:
- None
+ :raises:
+ None
- """
- @__api_check(True)
- def set_port_attr (self, ports = None, promiscuous = None):
+ """
ports = ports if ports is not None else self.get_acquired_ports()
ports = self._validate_port_list(ports)
@@ -1631,17 +1819,17 @@ class STLClient(object):
if not rc:
raise STLError(rc)
- """
- clear all events
+ def clear_events (self):
+ """
+ clear all events
- :parameters:
- None
+ :parameters:
+ None
- :raises:
- None
+ :raises:
+ None
- """
- def clear_events (self):
+ """
self.event_handler.clear_events()
@@ -1651,6 +1839,7 @@ class STLClient(object):
# console decorator
def __console(f):
+ @wraps(f)
def wrap(*args):
client = args[0]