2
0
mirror of https://github.com/openvswitch/ovs synced 2025-08-31 14:25:26 +00:00

python: ovs: Add flowviz scheleton.

Add a new python package (just the scheleton for now) to hold a flow
visualization tool based on the flow parsing library.

flowviz dependencies are installed via "extras_require", so a user must
run:

  $ pip install .[flowviz]
  or
  $ pip install ovs[flowviz]

Acked-by: Eelco Chaudron <echaudro@redhat.com>
Signed-off-by: Adrian Moreno <amorenoz@redhat.com>
Signed-off-by: Ilya Maximets <i.maximets@ovn.org>
This commit is contained in:
Adrian Moreno
2024-09-25 12:52:04 +02:00
committed by Ilya Maximets
parent 8bac5c0c79
commit 2fb2dbe827
7 changed files with 80 additions and 6 deletions

View File

@@ -63,6 +63,14 @@ ovs_pytests = \
python/ovs/tests/test_odp.py \
python/ovs/tests/test_ofp.py
ovs_flowviz = \
python/ovs/flowviz/__init__.py \
python/ovs/flowviz/main.py \
python/ovs/flowviz/odp/__init__.py \
python/ovs/flowviz/ofp/__init__.py \
python/ovs/flowviz/ovs-flowviz
# These python files are used at build time but not runtime,
# so they are not installed.
EXTRA_DIST += \
@@ -80,10 +88,11 @@ EXTRA_DIST += \
# C extension support.
EXTRA_DIST += python/ovs/_json.c
PYFILES = $(ovs_pyfiles) python/ovs/dirs.py python/setup.py $(ovstest_pyfiles) $(ovs_pytests)
PYFILES = $(ovs_pyfiles) python/ovs/dirs.py python/setup.py $(ovstest_pyfiles) $(ovs_pytests) \
$(ovs_flowviz)
EXTRA_DIST += $(PYFILES)
PYCOV_CLEAN_FILES += $(PYFILES:.py=.py,cover)
PYCOV_CLEAN_FILES += $($(filter %.py, PYFILES):.py=.py,cover) python/ovs/flowviz/ovs-flowviz,cover
FLAKE8_PYFILES += \
$(filter-out python/ovs/compat/% python/ovs/dirs.py python/setup.py,$(PYFILES)) \
@@ -94,7 +103,7 @@ FLAKE8_PYFILES += \
python/ovs/dirs.py.template \
python/setup.py.template
nobase_pkgdata_DATA = $(ovs_pyfiles) $(ovstest_pyfiles)
nobase_pkgdata_DATA = $(ovs_pyfiles) $(ovstest_pyfiles) $(ovs_flowviz)
ovs-install-data-local:
$(MKDIR_P) python/ovs
sed \

View File

View File

@@ -0,0 +1,40 @@
# Copyright (c) 2023 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import click
class Options(dict):
"""Options dictionary"""
@click.group(
context_settings=dict(help_option_names=["-h", "--help"]),
)
@click.pass_context
def maincli(ctx):
"""
OpenvSwitch flow visualization utility.
It reads openflow and datapath flows
(such as the output of ovs-ofctl dump-flows or ovs-appctl dpctl/dump-flows)
and prints them in different formats.
"""
def main():
"""
Main Function
"""
maincli()

View File

View File

20
python/ovs/flowviz/ovs-flowviz Executable file
View File

@@ -0,0 +1,20 @@
#!/usr/bin/env python3
#
# Copyright (c) 2022,2023 Red Hat, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at:
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from ovs.flowviz import main
if __name__ == '__main__':
main.main()

View File

@@ -72,6 +72,7 @@ else:
extra_cflags = os.environ.get('extra_cflags', '').split()
extra_libs = os.environ.get('extra_libs', '').split()
flow_extras_require = ['netaddr', 'pyparsing']
setup_args = dict(
name='ovs',
@@ -81,7 +82,8 @@ setup_args = dict(
author='Open vSwitch',
author_email='dev@openvswitch.org',
packages=['ovs', 'ovs.compat', 'ovs.compat.sortedcontainers',
'ovs.db', 'ovs.unixctl', 'ovs.flow'],
'ovs.db', 'ovs.flow', 'ovs.flowviz', 'ovs.flowviz.odp',
'ovs.flowviz.ofp', 'ovs.unixctl'],
keywords=['openvswitch', 'ovs', 'OVSDB'],
license='Apache 2.0',
classifiers=[
@@ -101,8 +103,11 @@ setup_args = dict(
cmdclass={'build_ext': try_build_ext},
install_requires=['sortedcontainers'],
extras_require={':sys_platform == "win32"': ['pywin32 >= 1.0'],
'flow': ['netaddr', 'pyparsing'],
'dns': ['unbound']},
'dns': ['unbound'],
'flow': flow_extras_require,
'flowviz': [*flow_extras_require, 'click'],
},
scripts=["ovs/flowviz/ovs-flowviz"],
)
try: