Soft Patch Panel
 help / color / Atom feed
* [spp] [PATCH 0/5] Update SPP Container tools
@ 2020-02-13 12:10 Yasufumi Ogawa
  2020-02-13 12:10 ` [spp] [PATCH 1/5] tools/sppc: python3 support for sppc apps Yasufumi Ogawa
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Yasufumi Ogawa @ 2020-02-13 12:10 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

Although python2 support was dropped from SPP, but remained in SPP
Container tools. This series of patches is to update to python3,
refactor some codes ambiguous in meaning, and update docs.

Yasufumi Ogawa (5):
  tools/sppc: python3 support for sppc apps
  tools/sppc: check mandatory params for suricata
  tools/sppc: refactor container image names
  tools/sppc: remove duplicated options
  docs: update list of app container launchers

 docs/guides/tools/sppc/app_launcher.rst |  1 +
 tools/sppc/app/helloworld.py            | 14 +++++++++----
 tools/sppc/app/l2fwd.py                 | 14 +++++++++----
 tools/sppc/app/l3fwd-acl.py             | 14 +++++++++----
 tools/sppc/app/l3fwd.py                 | 14 +++++++++----
 tools/sppc/app/load-balancer.py         | 14 +++++++++----
 tools/sppc/app/pktgen.py                | 14 +++++++++----
 tools/sppc/app/spp-nfv.py               | 28 ++++++++-----------------
 tools/sppc/app/spp-primary.py           | 22 ++++++++-----------
 tools/sppc/app/suricata.py              | 18 ++++++++++++----
 tools/sppc/app/testpmd.py               | 14 +++++++++----
 tools/sppc/build/main.py                |  2 +-
 tools/sppc/conf/env.py                  |  8 -------
 tools/sppc/lib/app_helper.py            | 22 ++++---------------
 tools/sppc/lib/common.py                | 16 +++++++++-----
 15 files changed, 119 insertions(+), 96 deletions(-)

-- 
2.17.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [spp] [PATCH 1/5] tools/sppc: python3 support for sppc apps
  2020-02-13 12:10 [spp] [PATCH 0/5] Update SPP Container tools Yasufumi Ogawa
@ 2020-02-13 12:10 ` Yasufumi Ogawa
  2020-02-13 12:10 ` [spp] [PATCH 2/5] tools/sppc: check mandatory params for suricata Yasufumi Ogawa
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Yasufumi Ogawa @ 2020-02-13 12:10 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

Although python2 support was dropped in SPP itself, it is still remained
in SPP container tools. This update is to make the tools run with
python3.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 tools/sppc/app/helloworld.py    | 2 +-
 tools/sppc/app/l2fwd.py         | 2 +-
 tools/sppc/app/l3fwd-acl.py     | 2 +-
 tools/sppc/app/l3fwd.py         | 2 +-
 tools/sppc/app/load-balancer.py | 2 +-
 tools/sppc/app/pktgen.py        | 2 +-
 tools/sppc/app/spp-nfv.py       | 2 +-
 tools/sppc/app/spp-primary.py   | 2 +-
 tools/sppc/app/suricata.py      | 2 +-
 tools/sppc/app/testpmd.py       | 2 +-
 tools/sppc/lib/app_helper.py    | 7 +++----
 tools/sppc/lib/common.py        | 7 +++----
 12 files changed, 16 insertions(+), 18 deletions(-)

diff --git a/tools/sppc/app/helloworld.py b/tools/sppc/app/helloworld.py
index fada61e..2d2837b 100755
--- a/tools/sppc/app/helloworld.py
+++ b/tools/sppc/app/helloworld.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2018 Nippon Telegraph and Telephone Corporation
 
diff --git a/tools/sppc/app/l2fwd.py b/tools/sppc/app/l2fwd.py
index 3b7789c..90a1270 100755
--- a/tools/sppc/app/l2fwd.py
+++ b/tools/sppc/app/l2fwd.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2018 Nippon Telegraph and Telephone Corporation
 
diff --git a/tools/sppc/app/l3fwd-acl.py b/tools/sppc/app/l3fwd-acl.py
index 059aaf2..6a7afff 100755
--- a/tools/sppc/app/l3fwd-acl.py
+++ b/tools/sppc/app/l3fwd-acl.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2019 Nippon Telegraph and Telephone Corporation
 
diff --git a/tools/sppc/app/l3fwd.py b/tools/sppc/app/l3fwd.py
index d7e8528..1732648 100755
--- a/tools/sppc/app/l3fwd.py
+++ b/tools/sppc/app/l3fwd.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2018 Nippon Telegraph and Telephone Corporation
 
diff --git a/tools/sppc/app/load-balancer.py b/tools/sppc/app/load-balancer.py
index 0f6d6e1..5ec156e 100755
--- a/tools/sppc/app/load-balancer.py
+++ b/tools/sppc/app/load-balancer.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2018 Nippon Telegraph and Telephone Corporation
 
diff --git a/tools/sppc/app/pktgen.py b/tools/sppc/app/pktgen.py
index 708633b..e673b3b 100755
--- a/tools/sppc/app/pktgen.py
+++ b/tools/sppc/app/pktgen.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2018 Nippon Telegraph and Telephone Corporation
 
diff --git a/tools/sppc/app/spp-nfv.py b/tools/sppc/app/spp-nfv.py
index 96e25e7..100d20d 100755
--- a/tools/sppc/app/spp-nfv.py
+++ b/tools/sppc/app/spp-nfv.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2018 Nippon Telegraph and Telephone Corporation
 
diff --git a/tools/sppc/app/spp-primary.py b/tools/sppc/app/spp-primary.py
index 6a71490..ac7facd 100755
--- a/tools/sppc/app/spp-primary.py
+++ b/tools/sppc/app/spp-primary.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2018 Nippon Telegraph and Telephone Corporation
 
diff --git a/tools/sppc/app/suricata.py b/tools/sppc/app/suricata.py
index 5bbff5f..f206036 100755
--- a/tools/sppc/app/suricata.py
+++ b/tools/sppc/app/suricata.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2019 Nippon Telegraph and Telephone Corporation
 
diff --git a/tools/sppc/app/testpmd.py b/tools/sppc/app/testpmd.py
index e79f3f6..f6197fe 100755
--- a/tools/sppc/app/testpmd.py
+++ b/tools/sppc/app/testpmd.py
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2018 Nippon Telegraph and Telephone Corporation
 
diff --git a/tools/sppc/lib/app_helper.py b/tools/sppc/lib/app_helper.py
index 6e25074..85762ea 100644
--- a/tools/sppc/lib/app_helper.py
+++ b/tools/sppc/lib/app_helper.py
@@ -1,8 +1,7 @@
-#!/usr/bin/env python
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2018 Nippon Telegraph and Telephone Corporation
 
-import common
+from . import common
 import os
 import sys
 
@@ -215,7 +214,7 @@ def dev_ids_to_list(dev_ids):
     for dev_id_part in dev_ids.split(','):
         if '-' in dev_id_part:
             cl = dev_id_part.split('-')
-            res = res + range(int(cl[0]), int(cl[1])+1)
+            res = res + list(range(int(cl[0]), int(cl[1])+1))
         else:
             res.append(int(dev_id_part))
     return res
@@ -287,7 +286,7 @@ def cores_to_list(core_opt):
         for core_part in core_opt['val'].split(','):
             if '-' in core_part:
                 cl = core_part.split('-')
-                res = res + range(int(cl[0]), int(cl[1])+1)
+                res = res + list(range(int(cl[0]), int(cl[1])+1))
             else:
                 res.append(int(core_part))
     else:
diff --git a/tools/sppc/lib/common.py b/tools/sppc/lib/common.py
index 7102d43..a4903cd 100644
--- a/tools/sppc/lib/common.py
+++ b/tools/sppc/lib/common.py
@@ -1,16 +1,15 @@
-#!/usr/bin/env python
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2018 Nippon Telegraph and Telephone Corporation
 
 
 def print_pretty_commands(cmds):
-    """Print given command in pretty format"""
+    """Print given command in pretty format."""
 
     print(' '.join(cmds).replace('\\', '\\\n'))
 
 
 def container_img_name(base, dist_name, dist_ver):
-    """Generate container image name
+    """Generate container image name.
 
     Return the name of container image for '-t' of docker command
     such as 'sppc/dpdk-ubuntu:16.04' or 'sppc/spp-ubuntu:18.04'.
@@ -20,7 +19,7 @@ def container_img_name(base, dist_name, dist_ver):
 
 
 def error_exit(objname):
-    """Print error message and exit
+    """Print error message and exit.
 
     This function is used for notifying an argument for the object
     is not given.
-- 
2.17.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [spp] [PATCH 2/5] tools/sppc: check mandatory params for suricata
  2020-02-13 12:10 [spp] [PATCH 0/5] Update SPP Container tools Yasufumi Ogawa
  2020-02-13 12:10 ` [spp] [PATCH 1/5] tools/sppc: python3 support for sppc apps Yasufumi Ogawa
@ 2020-02-13 12:10 ` Yasufumi Ogawa
  2020-02-13 12:10 ` [spp] [PATCH 3/5] tools/sppc: refactor container image names Yasufumi Ogawa
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Yasufumi Ogawa @ 2020-02-13 12:10 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

Suricata container app is failed if no dev ID is given because of
accessing None object. This update is to add checking this parameter.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 tools/sppc/app/suricata.py | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/tools/sppc/app/suricata.py b/tools/sppc/app/suricata.py
index f206036..ad4e053 100755
--- a/tools/sppc/app/suricata.py
+++ b/tools/sppc/app/suricata.py
@@ -29,6 +29,10 @@ def parse_args():
 def main():
     args = parse_args()
 
+    # Check for other mandatory opitons.
+    if args.dev_ids is None:
+        common.error_exit('--dev-ids')
+
     # Setup for vhost devices with given device IDs.
     dev_ids_list = app_helper.dev_ids_to_list(args.dev_ids)
     sock_files = app_helper.sock_files(dev_ids_list)
-- 
2.17.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [spp] [PATCH 3/5] tools/sppc: refactor container image names
  2020-02-13 12:10 [spp] [PATCH 0/5] Update SPP Container tools Yasufumi Ogawa
  2020-02-13 12:10 ` [spp] [PATCH 1/5] tools/sppc: python3 support for sppc apps Yasufumi Ogawa
  2020-02-13 12:10 ` [spp] [PATCH 2/5] tools/sppc: check mandatory params for suricata Yasufumi Ogawa
@ 2020-02-13 12:10 ` Yasufumi Ogawa
  2020-02-13 12:10 ` [spp] [PATCH 4/5] tools/sppc: remove duplicated options Yasufumi Ogawa
  2020-02-13 12:10 ` [spp] [PATCH 5/5] docs: update list of app container launchers Yasufumi Ogawa
  4 siblings, 0 replies; 6+ messages in thread
From: Yasufumi Ogawa @ 2020-02-13 12:10 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

A set of base names of container image is defined in `conf/env.py`
considering user uses any of container image name. However, build script
was changed to create image with default name and it is modified via
options. It means that user doesn't need to define the name anymore.
This update is to move the definition of base names from conf to common
because it is no need to edit usually.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 tools/sppc/app/helloworld.py    | 12 +++++++++---
 tools/sppc/app/l2fwd.py         | 12 +++++++++---
 tools/sppc/app/l3fwd-acl.py     | 12 +++++++++---
 tools/sppc/app/l3fwd.py         | 12 +++++++++---
 tools/sppc/app/load-balancer.py | 12 +++++++++---
 tools/sppc/app/pktgen.py        | 12 +++++++++---
 tools/sppc/app/spp-nfv.py       | 20 ++++++++------------
 tools/sppc/app/spp-primary.py   | 20 ++++++++------------
 tools/sppc/app/suricata.py      | 12 +++++++++---
 tools/sppc/app/testpmd.py       | 12 +++++++++---
 tools/sppc/build/main.py        |  2 +-
 tools/sppc/conf/env.py          |  8 --------
 tools/sppc/lib/app_helper.py    | 15 +--------------
 tools/sppc/lib/common.py        |  9 ++++++++-
 14 files changed, 98 insertions(+), 72 deletions(-)

diff --git a/tools/sppc/app/helloworld.py b/tools/sppc/app/helloworld.py
index 2d2837b..d155b64 100755
--- a/tools/sppc/app/helloworld.py
+++ b/tools/sppc/app/helloworld.py
@@ -13,8 +13,6 @@ from conf import env
 from lib import app_helper
 from lib import common
 
-target_name = 'dpdk'
-
 
 def parse_args():
     parser = argparse.ArgumentParser(
@@ -32,6 +30,14 @@ def parse_args():
 def main():
     args = parse_args()
 
+    # Container image name such as 'sppc/dpdk-ubuntu:18.04'
+    if args.container_image is not None:
+        container_image = args.container_image
+    else:
+        container_image = common.container_img_name(
+            common.IMG_BASE_NAMES['dpdk'],
+            args.dist_name, args.dist_ver)
+
     # Check for other mandatory opitons.
     if args.dev_ids is None:
         common.error_exit('--dev-ids')
@@ -43,7 +49,7 @@ def main():
     # Setup docker command.
     docker_cmd = ['sudo', 'docker', 'run', '\\']
     docker_opts = app_helper.setup_docker_opts(
-        args, target_name, sock_files)
+        args, container_image, sock_files)
 
     # Setup helloworld run on container.
     cmd_path = '%s/examples/helloworld/%s/helloworld' % (
diff --git a/tools/sppc/app/l2fwd.py b/tools/sppc/app/l2fwd.py
index 90a1270..a658d6c 100755
--- a/tools/sppc/app/l2fwd.py
+++ b/tools/sppc/app/l2fwd.py
@@ -13,8 +13,6 @@ from conf import env
 from lib import app_helper
 from lib import common
 
-target_name = 'dpdk'
-
 
 def parse_args():
     parser = argparse.ArgumentParser(
@@ -36,6 +34,14 @@ def parse_args():
 def main():
     args = parse_args()
 
+    # Container image name such as 'sppc/dpdk-ubuntu:18.04'
+    if args.container_image is not None:
+        container_image = args.container_image
+    else:
+        container_image = common.container_img_name(
+            common.IMG_BASE_NAMES['dpdk'],
+            args.dist_name, args.dist_ver)
+
     # Check for other mandatory opitons.
     if args.port_mask is None:
         common.error_exit('--port-mask')
@@ -49,7 +55,7 @@ def main():
     # Setup docker command.
     docker_cmd = ['sudo', 'docker', 'run', '\\']
     docker_opts = app_helper.setup_docker_opts(
-        args, target_name, sock_files)
+        args, container_image, sock_files)
 
     # Check if the number of ports is even for l2fwd.
     nof_ports = app_helper.count_ports(args.port_mask)
diff --git a/tools/sppc/app/l3fwd-acl.py b/tools/sppc/app/l3fwd-acl.py
index 6a7afff..d1e2178 100755
--- a/tools/sppc/app/l3fwd-acl.py
+++ b/tools/sppc/app/l3fwd-acl.py
@@ -14,8 +14,6 @@ from conf import env
 from lib import app_helper
 from lib import common
 
-target_name = 'dpdk'
-
 
 def parse_args():
     parser = argparse.ArgumentParser(
@@ -140,6 +138,14 @@ def check_jumbo_opt(enable_jumbo, max_pkt_len):
 def main():
     args = parse_args()
 
+    # Container image name such as 'sppc/dpdk-ubuntu:18.04'
+    if args.container_image is not None:
+        container_image = args.container_image
+    else:
+        container_image = common.container_img_name(
+            common.IMG_BASE_NAMES['dpdk'],
+            args.dist_name, args.dist_ver)
+
     # Check for other mandatory opitons.
     if args.port_mask is None:
         common.error_exit('--port-mask')
@@ -153,7 +159,7 @@ def main():
     # Setup docker command.
     docker_cmd = ['sudo', 'docker', 'run', '\\']
     docker_opts = app_helper.setup_docker_opts(
-        args, target_name, sock_files)
+        args, container_image, sock_files)
 
     # Parse vhost device IDs and Check the number of devices is
     # sufficient for port mask.
diff --git a/tools/sppc/app/l3fwd.py b/tools/sppc/app/l3fwd.py
index 1732648..131eb66 100755
--- a/tools/sppc/app/l3fwd.py
+++ b/tools/sppc/app/l3fwd.py
@@ -14,8 +14,6 @@ from conf import env
 from lib import app_helper
 from lib import common
 
-target_name = 'dpdk'
-
 
 def parse_args():
     parser = argparse.ArgumentParser(
@@ -175,6 +173,14 @@ def check_eth_dest(eth_dests):
 def main():
     args = parse_args()
 
+    # Container image name such as 'sppc/dpdk-ubuntu:18.04'
+    if args.container_image is not None:
+        container_image = args.container_image
+    else:
+        container_image = common.container_img_name(
+            common.IMG_BASE_NAMES['dpdk'],
+            args.dist_name, args.dist_ver)
+
     # Check for other mandatory opitons.
     if args.port_mask is None:
         common.error_exit('--port-mask')
@@ -188,7 +194,7 @@ def main():
     # Setup docker command.
     docker_cmd = ['sudo', 'docker', 'run', '\\']
     docker_opts = app_helper.setup_docker_opts(
-        args, target_name, sock_files)
+        args, container_image, sock_files)
 
     # Parse vhost device IDs and Check the number of devices is
     # sufficient for port mask.
diff --git a/tools/sppc/app/load-balancer.py b/tools/sppc/app/load-balancer.py
index 5ec156e..687bfe5 100755
--- a/tools/sppc/app/load-balancer.py
+++ b/tools/sppc/app/load-balancer.py
@@ -13,8 +13,6 @@ from conf import env
 from lib import app_helper
 from lib import common
 
-target_name = 'dpdk'
-
 
 def parse_args():
     parser = argparse.ArgumentParser(
@@ -60,6 +58,14 @@ def parse_args():
 def main():
     args = parse_args()
 
+    # Container image name such as 'sppc/dpdk-ubuntu:18.04'
+    if args.container_image is not None:
+        container_image = args.container_image
+    else:
+        container_image = common.container_img_name(
+            common.IMG_BASE_NAMES['dpdk'],
+            args.dist_name, args.dist_ver)
+
     # Check for other mandatory opitons.
     if args.dev_ids is None:
         common.error_exit('--dev-ids')
@@ -71,7 +77,7 @@ def main():
     # Setup docker command.
     docker_cmd = ['sudo', 'docker', 'run', '\\']
     docker_opts = app_helper.setup_docker_opts(
-        args, target_name, sock_files)
+        args, container_image, sock_files)
 
     app_name = 'load_balancer'
     cmd_path = '%s/examples/%s/%s/%s' % (
diff --git a/tools/sppc/app/pktgen.py b/tools/sppc/app/pktgen.py
index e673b3b..319557c 100755
--- a/tools/sppc/app/pktgen.py
+++ b/tools/sppc/app/pktgen.py
@@ -13,8 +13,6 @@ from conf import env
 from lib import app_helper
 from lib import common
 
-target_name = 'pktgen'
-
 
 def parse_args():
     parser = argparse.ArgumentParser(
@@ -69,6 +67,14 @@ def parse_args():
 def main():
     args = parse_args()
 
+    # Container image name such as 'sppc/dpdk-ubuntu:18.04'
+    if args.container_image is not None:
+        container_image = args.container_image
+    else:
+        container_image = common.container_img_name(
+            common.IMG_BASE_NAMES['pktgen'],
+            args.dist_name, args.dist_ver)
+
     # Setup for vhost devices with given device IDs.
     dev_ids_list = app_helper.dev_ids_to_list(args.dev_ids)
     sock_files = app_helper.sock_files(dev_ids_list)
@@ -80,7 +86,7 @@ def main():
         wd = '/root/pktgen-dpdk'
     docker_cmd = ['sudo', 'docker', 'run', '\\']
     docker_opts = app_helper.setup_docker_opts(
-            args, target_name, sock_files, wd)
+            args, container_image, sock_files, wd)
 
     # Setup pktgen command
     pktgen_cmd = ['pktgen', '\\']
diff --git a/tools/sppc/app/spp-nfv.py b/tools/sppc/app/spp-nfv.py
index 100d20d..34d87c9 100755
--- a/tools/sppc/app/spp-nfv.py
+++ b/tools/sppc/app/spp-nfv.py
@@ -9,12 +9,9 @@ import sys
 
 work_dir = os.path.dirname(__file__)
 sys.path.append(work_dir + '/..')
-from conf import env
 from lib import app_helper
 from lib import common
 
-target_name = 'spp'
-
 
 def parse_args():
     parser = argparse.ArgumentParser(
@@ -49,21 +46,20 @@ def main():
     docker_cmd = ['sudo', 'docker', 'run', '\\']
     docker_opts = []
 
+    # Container image name such as 'sppc/spp-ubuntu:18.04'
+    if args.container_image is not None:
+        container_image = args.container_image
+    else:
+        container_image = common.container_img_name(
+            common.IMG_BASE_NAMES['spp'],
+            args.dist_name, args.dist_ver)
+
     # This container is running in backgroud in defualt.
     if args.foreground is not True:
         docker_opts += ['-d', '\\']
     else:
         docker_opts += ['-it', '\\']
 
-    if args.container_image is not None:
-        container_image = args.container_image
-    else:
-        # Container image name, for exp 'sppc/dpdk-ubuntu:18.04'
-        container_image = common.container_img_name(
-            env.CONTAINER_IMG_NAME[target_name],
-            args.dist_name,
-            args.dist_ver)
-
     docker_opts += [
         '--privileged', '\\',  # should be privileged
         '-v', '/dev/hugepages:/dev/hugepages', '\\',
diff --git a/tools/sppc/app/spp-primary.py b/tools/sppc/app/spp-primary.py
index ac7facd..7ebee68 100755
--- a/tools/sppc/app/spp-primary.py
+++ b/tools/sppc/app/spp-primary.py
@@ -9,12 +9,9 @@ import sys
 
 work_dir = os.path.dirname(__file__)
 sys.path.append(work_dir + '/..')
-from conf import env
 from lib import app_helper
 from lib import common
 
-target_name = 'spp'
-
 
 def parse_args():
     parser = argparse.ArgumentParser(
@@ -62,6 +59,14 @@ def main():
     docker_cmd = ['sudo', 'docker', 'run', '\\']
     docker_opts = []
 
+    # Container image name such as 'sppc/spp-ubuntu:18.04'
+    if args.container_image is not None:
+        container_image = args.container_image
+    else:
+        container_image = common.container_img_name(
+            common.IMG_BASE_NAMES['spp'],
+            args.dist_name, args.dist_ver)
+
     # This container is running in backgroud in defualt.
     if args.foreground is not True:
         docker_opts += ['-d', '\\']
@@ -93,15 +98,6 @@ def main():
     else:
         dev_vhost_ids = []
 
-    if args.container_image is not None:
-        container_image = args.container_image
-    else:
-        # Container image name, for exp 'sppc/dpdk-ubuntu:18.04'
-        container_image = common.container_img_name(
-            env.CONTAINER_IMG_NAME[target_name],
-            args.dist_name,
-            args.dist_ver)
-
     docker_opts += [
         container_image, '\\']
 
diff --git a/tools/sppc/app/suricata.py b/tools/sppc/app/suricata.py
index ad4e053..2ac01c0 100755
--- a/tools/sppc/app/suricata.py
+++ b/tools/sppc/app/suricata.py
@@ -13,8 +13,6 @@ from conf import env
 from lib import app_helper
 from lib import common
 
-target_name = 'suricata'
-
 
 def parse_args():
     parser = argparse.ArgumentParser(
@@ -29,6 +27,14 @@ def parse_args():
 def main():
     args = parse_args()
 
+    # Container image name such as 'sppc/suricata-ubuntu:18.04'
+    if args.container_image is not None:
+        container_image = args.container_image
+    else:
+        container_image = common.container_img_name(
+            common.IMG_BASE_NAMES['suricata'],
+            args.dist_name, args.dist_ver)
+
     # Check for other mandatory opitons.
     if args.dev_ids is None:
         common.error_exit('--dev-ids')
@@ -40,7 +46,7 @@ def main():
     # Setup docker command.
     docker_cmd = ['sudo', 'docker', 'run', '\\']
     docker_opts = app_helper.setup_docker_opts(
-        args, target_name, sock_files)
+        args, container_image, sock_files)
 
     cmd_path = '/bin/bash'
 
diff --git a/tools/sppc/app/testpmd.py b/tools/sppc/app/testpmd.py
index f6197fe..ff84335 100755
--- a/tools/sppc/app/testpmd.py
+++ b/tools/sppc/app/testpmd.py
@@ -14,8 +14,6 @@ from conf import env
 from lib import app_helper
 from lib import common
 
-target_name = 'dpdk'
-
 
 def parse_args():
     parser = argparse.ArgumentParser(
@@ -456,6 +454,14 @@ def not_supported_exit(opt):
 def main():
     args = parse_args()
 
+    # Container image name such as 'sppc/dpdk-ubuntu:18.04'
+    if args.container_image is not None:
+        container_image = args.container_image
+    else:
+        container_image = common.container_img_name(
+            common.IMG_BASE_NAMES['dpdk'],
+            args.dist_name, args.dist_ver)
+
     # Check for other mandatory opitons.
     if args.dev_ids is None:
         common.error_exit('--dev-ids')
@@ -467,7 +473,7 @@ def main():
     # Setup docker command.
     docker_cmd = ['sudo', 'docker', 'run', '\\']
     docker_opts = app_helper.setup_docker_opts(
-        args, target_name, sock_files)
+        args, container_image, sock_files)
 
     cmd_path = 'testpmd'
 
diff --git a/tools/sppc/build/main.py b/tools/sppc/build/main.py
index 578bc42..023ec82 100755
--- a/tools/sppc/build/main.py
+++ b/tools/sppc/build/main.py
@@ -116,7 +116,7 @@ def main():
             work_dir, args.dist_name, args.target)
         # Container image name, for exp 'sppc/dpdk-ubuntu:18.04'
         container_image = common.container_img_name(
-            env.CONTAINER_IMG_NAME[args.target],
+            common.IMG_BASE_NAMES[args.target],
             args.dist_name,
             args.dist_ver)
     else:
diff --git a/tools/sppc/conf/env.py b/tools/sppc/conf/env.py
index 3fb0c2d..dc0fe12 100644
--- a/tools/sppc/conf/env.py
+++ b/tools/sppc/conf/env.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2018 Nippon Telegraph and Telephone Corporation
 
@@ -6,10 +5,3 @@
 HOMEDIR = '/root'
 RTE_SDK = '/root/dpdk'
 RTE_TARGET = 'x86_64-native-linuxapp-gcc'
-
-CONTAINER_IMG_NAME = {
-    'dpdk': 'sppc/dpdk',
-    'pktgen': 'sppc/pktgen',
-    'spp': 'sppc/spp',
-    'suricata': 'sppc/suricata',
-    }
diff --git a/tools/sppc/lib/app_helper.py b/tools/sppc/lib/app_helper.py
index 85762ea..7ab1982 100644
--- a/tools/sppc/lib/app_helper.py
+++ b/tools/sppc/lib/app_helper.py
@@ -5,10 +5,6 @@ from . import common
 import os
 import sys
 
-work_dir = os.path.dirname(__file__)
-sys.path.append(work_dir + '/..')
-from conf import env
-
 
 def add_eal_args(parser, mem_size=1024, mem_channel=4):
     parser.add_argument(
@@ -143,7 +139,7 @@ def add_sppc_args(parser):
     return parser
 
 
-def setup_docker_opts(args, target_name, sock_files, workdir=None):
+def setup_docker_opts(args, container_image, sock_files, workdir=None):
     docker_opts = []
 
     if args.foreground is True:
@@ -161,15 +157,6 @@ def setup_docker_opts(args, target_name, sock_files, workdir=None):
         docker_opts += [
             '-v', '%s:%s' % (sock['host'], sock['guest']), '\\']
 
-    if args.container_image is not None:
-        container_image = args.container_image
-    else:
-        # Container image name, for exp 'sppc/dpdk-ubuntu:18.04'
-        container_image = common.container_img_name(
-            env.CONTAINER_IMG_NAME[target_name],
-            args.dist_name,
-            args.dist_ver)
-
     docker_opts += [
         '-v', '/dev/hugepages:/dev/hugepages', '\\',
         container_image, '\\']
diff --git a/tools/sppc/lib/common.py b/tools/sppc/lib/common.py
index a4903cd..657f812 100644
--- a/tools/sppc/lib/common.py
+++ b/tools/sppc/lib/common.py
@@ -2,6 +2,14 @@
 # Copyright(c) 2018 Nippon Telegraph and Telephone Corporation
 
 
+IMG_BASE_NAMES = {
+    'dpdk': 'sppc/dpdk',
+    'pktgen': 'sppc/pktgen',
+    'spp': 'sppc/spp',
+    'suricata': 'sppc/suricata',
+    }
+
+
 def print_pretty_commands(cmds):
     """Print given command in pretty format."""
 
@@ -13,7 +21,6 @@ def container_img_name(base, dist_name, dist_ver):
 
     Return the name of container image for '-t' of docker command
     such as 'sppc/dpdk-ubuntu:16.04' or 'sppc/spp-ubuntu:18.04'.
-    'base' is defined as 'env.CONTAINER_IMG_NAME' in lib module.
     """
     return '%s-%s:%s' % (base, dist_name, dist_ver)
 
-- 
2.17.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [spp] [PATCH 4/5] tools/sppc: remove duplicated options
  2020-02-13 12:10 [spp] [PATCH 0/5] Update SPP Container tools Yasufumi Ogawa
                   ` (2 preceding siblings ...)
  2020-02-13 12:10 ` [spp] [PATCH 3/5] tools/sppc: refactor container image names Yasufumi Ogawa
@ 2020-02-13 12:10 ` Yasufumi Ogawa
  2020-02-13 12:10 ` [spp] [PATCH 5/5] docs: update list of app container launchers Yasufumi Ogawa
  4 siblings, 0 replies; 6+ messages in thread
From: Yasufumi Ogawa @ 2020-02-13 12:10 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

Remove adding docker's `-d` or `-it` options twice.

Fixes: 4956e9cc4719 ("tools/sppc: add spp-nfv app container")

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 tools/sppc/app/spp-nfv.py | 6 ------
 1 file changed, 6 deletions(-)

diff --git a/tools/sppc/app/spp-nfv.py b/tools/sppc/app/spp-nfv.py
index 34d87c9..da9853b 100755
--- a/tools/sppc/app/spp-nfv.py
+++ b/tools/sppc/app/spp-nfv.py
@@ -68,12 +68,6 @@ def main():
         container_image, '\\'
     ]
 
-    # This container is running in backgroud in defualt.
-    if args.foreground is not True:
-        docker_run_opt = '-d'
-    else:
-        docker_run_opt = '-it'
-
     # Setup spp_nfv command.
     spp_cmd = ['spp_nfv', '\\']
 
-- 
2.17.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [spp] [PATCH 5/5] docs: update list of app container launchers
  2020-02-13 12:10 [spp] [PATCH 0/5] Update SPP Container tools Yasufumi Ogawa
                   ` (3 preceding siblings ...)
  2020-02-13 12:10 ` [spp] [PATCH 4/5] tools/sppc: remove duplicated options Yasufumi Ogawa
@ 2020-02-13 12:10 ` Yasufumi Ogawa
  4 siblings, 0 replies; 6+ messages in thread
From: Yasufumi Ogawa @ 2020-02-13 12:10 UTC (permalink / raw)
  To: spp, ferruh.yigit, yasufum.o

This update is to add `suricata.py` to the list of app container
launchers.

Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
 docs/guides/tools/sppc/app_launcher.rst | 1 +
 1 file changed, 1 insertion(+)

diff --git a/docs/guides/tools/sppc/app_launcher.rst b/docs/guides/tools/sppc/app_launcher.rst
index f89dbdf..3dc4bbb 100644
--- a/docs/guides/tools/sppc/app_launcher.rst
+++ b/docs/guides/tools/sppc/app_launcher.rst
@@ -25,6 +25,7 @@ inside a container.
     |--- pktgen.py
     |--- spp-nfv.py
     |--- spp-primary.py
+    |--- suricata.py
     ---- testpmd.py
 
 
-- 
2.17.1


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, back to index

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-02-13 12:10 [spp] [PATCH 0/5] Update SPP Container tools Yasufumi Ogawa
2020-02-13 12:10 ` [spp] [PATCH 1/5] tools/sppc: python3 support for sppc apps Yasufumi Ogawa
2020-02-13 12:10 ` [spp] [PATCH 2/5] tools/sppc: check mandatory params for suricata Yasufumi Ogawa
2020-02-13 12:10 ` [spp] [PATCH 3/5] tools/sppc: refactor container image names Yasufumi Ogawa
2020-02-13 12:10 ` [spp] [PATCH 4/5] tools/sppc: remove duplicated options Yasufumi Ogawa
2020-02-13 12:10 ` [spp] [PATCH 5/5] docs: update list of app container launchers Yasufumi Ogawa

Soft Patch Panel

Archives are clonable:
	git clone --mirror http://inbox.dpdk.org/spp/0 spp/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 spp spp/ http://inbox.dpdk.org/spp \
		spp@dpdk.org
	public-inbox-index spp


Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.spp


AGPL code for this site: git clone https://public-inbox.org/ public-inbox