[spp] [PATCH 1/2] tools/sppc: change env var SPP_CTRL_IP

yasufum.o at gmail.com yasufum.o at gmail.com
Thu Aug 22 10:28:05 CEST 2019


From: Yasufumi Ogawa <yasufum.o at gmail.com>

The name of `SPP_CTRL_IP` of spp-ctl is ambiguous and it is better to
renmae `SPP_CTL_IP`.

Signed-off-by: Yasufumi Ogawa <yasufum.o at gmail.com>
---
 tools/sppc/app/spp-nfv.py     | 19 ++++++++++---------
 tools/sppc/app/spp-primary.py | 27 ++++++++++++++-------------
 2 files changed, 24 insertions(+), 22 deletions(-)

diff --git a/tools/sppc/app/spp-nfv.py b/tools/sppc/app/spp-nfv.py
index 6506fed..96e25e7 100755
--- a/tools/sppc/app/spp-nfv.py
+++ b/tools/sppc/app/spp-nfv.py
@@ -28,14 +28,14 @@ def parse_args():
         type=int,
         help='Secondary ID')
     parser.add_argument(
-        '-ip', '--ctrl-ip',
+        '-ip', '--ctl-ip',
         type=str,
-        help="IP address of SPP controller")
+        help="IP address of spp-ctl")
     parser.add_argument(
-        '--ctrl-port',
+        '--ctl-port',
         type=int,
         default=6666,
-        help="Port of SPP controller")
+        help="Port for secondary of spp-ctl")
 
     parser = app_helper.add_sppc_args(parser)
 
@@ -99,12 +99,13 @@ def main():
     else:
         spp_opts += ['-n', str(args.sec_id), '\\']
 
-    # IP address of SPP controller.
-    ctrl_ip = os.getenv('SPP_CTRL_IP', args.ctrl_ip)
-    if ctrl_ip is None:
-        common.error_exit('SPP_CTRL_IP')
+    # IP address of spp-ctl.
+    ctl_ip = os.getenv('SPP_CTL_IP', args.ctl_ip)
+    if ctl_ip is None:
+        print('Env variable "SPP_CTL_IP" is not defined!')
+        exit()
     else:
-        spp_opts += ['-s', '%s:%d' % (ctrl_ip, args.ctrl_port), '\\']
+        spp_opts += ['-s', '{}:{}'.format(ctl_ip, args.ctl_port), '\\']
 
     cmds = docker_cmd + docker_opts + spp_cmd + eal_opts + spp_opts
     if cmds[-1] == '\\':
diff --git a/tools/sppc/app/spp-primary.py b/tools/sppc/app/spp-primary.py
index 6a004f6..6a71490 100755
--- a/tools/sppc/app/spp-primary.py
+++ b/tools/sppc/app/spp-primary.py
@@ -41,14 +41,14 @@ def parse_args():
         type=str,
         help='TAP device IDs')
     parser.add_argument(
-        '-ip', '--ctrl-ip',
+        '-ip', '--ctl-ip',
         type=str,
-        help="IP address of SPP controller")
+        help="IP address of spp-ctl")
     parser.add_argument(
-        '--ctrl-port',
+        '--ctl-port',
         type=int,
         default=5555,
-        help="Port of SPP controller")
+        help="Port for primary of spp-ctl")
 
     parser = app_helper.add_sppc_args(parser)
 
@@ -88,8 +88,8 @@ def main():
         socks = []
         for dev_id in dev_vhost_ids:
             socks.append({
-                'host': '/tmp/sock%d' % dev_id,
-                'guest': '/tmp/sock%d' % dev_id})
+                'host': '/tmp/sock{}'.format(dev_id),
+                'guest': '/tmp/sock{}'.format(dev_id)})
     else:
         dev_vhost_ids = []
 
@@ -122,13 +122,13 @@ def main():
     # Add TAP vdevs
     for i in range(len(dev_tap_ids)):
         eal_opts += [
-            '--vdev', 'net_tap%d,iface=foo%d' % (
+            '--vdev', 'net_tap{},iface=foo{}'.format(
                 dev_tap_ids[i], dev_tap_ids[i]), '\\']
 
     # Add vhost vdevs
     for i in range(len(dev_vhost_ids)):
         eal_opts += [
-            '--vdev', 'eth_vhost%d,iface=%s' % (
+            '--vdev', 'eth_vhost{},iface={}'.format(
                 dev_vhost_ids[i], socks[i]['guest']), '\\']
 
     eal_opts += ['--', '\\']
@@ -142,12 +142,13 @@ def main():
 
     spp_opts += ['-n', str(args.nof_ring), '\\']
 
-    # IP address of SPP controller.
-    ctrl_ip = os.getenv('SPP_CTRL_IP', args.ctrl_ip)
-    if ctrl_ip is None:
-        common.error_exit('SPP_CTRL_IP')
+    # IP address of spp-ctl.
+    ctl_ip = os.getenv('SPP_CTL_IP', args.ctl_ip)
+    if ctl_ip is None:
+        print('Env variable "SPP_CTL_IP" is not defined!')
+        exit()
     else:
-        spp_opts += ['-s', '%s:%d' % (ctrl_ip, args.ctrl_port), '\\']
+        spp_opts += ['-s', '{}:{}'.format(ctl_ip, args.ctl_port), '\\']
 
     cmds = docker_cmd + docker_opts + spp_cmd + eal_opts + spp_opts
     if cmds[-1] == '\\':
-- 
2.17.1



More information about the spp mailing list