Soft Patch Panel
 help / color / mirror / Atom feed
From: ogawa.yasufumi@lab.ntt.co.jp
To: spp@dpdk.org, ferruh.yigit@intel.com, ogawa.yasufumi@lab.ntt.co.jp
Subject: [spp] [PATCH 2/5] controller: add checking syntax for vf port cmd
Date: Mon,  4 Feb 2019 12:11:16 +0900	[thread overview]
Message-ID: <1549249879-31580-3-git-send-email-ogawa.yasufumi@lab.ntt.co.jp> (raw)
In-Reply-To: <1549249879-31580-1-git-send-email-ogawa.yasufumi@lab.ntt.co.jp>

From: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>

This update is add checking the number of params for `port` sub command
of vf to avoid SPP CLI is terminated if its syntax is invalid.

Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
 src/controller/commands/vf.py | 26 +++++++++++++++-----------
 1 file changed, 15 insertions(+), 11 deletions(-)

diff --git a/src/controller/commands/vf.py b/src/controller/commands/vf.py
index 7518c04..ff08231 100644
--- a/src/controller/commands/vf.py
+++ b/src/controller/commands/vf.py
@@ -279,6 +279,7 @@ class SppVf(object):
                     print('Error: unknown response.')
 
     def _run_port(self, params):
+        req_params = None
         if len(params) == 4:
             if params[0] == 'add':
                 action = 'attach'
@@ -314,17 +315,20 @@ class SppVf(object):
                           'dir': params[2],
                           'vlan': {'operation': op, 'id': int(params[5]),
                                    'pcp': int(params[6])}}
+        else:
+            print('Error: Invalid syntax.')
 
-        res = self.spp_ctl_cli.put('vfs/%d/components/%s/ports'
-                                   % (self.sec_id, params[3]), req_params)
-        if res is not None:
-            error_codes = self.spp_ctl_cli.rest_common_error_codes
-            if res.status_code == 204:
-                print("Succeeded to %s port" % params[0])
-            elif res.status_code in error_codes:
-                pass
-            else:
-                print('Error: unknown response.')
+        if req_params is not None:
+            res = self.spp_ctl_cli.put('vfs/%d/components/%s/ports'
+                                       % (self.sec_id, params[3]), req_params)
+            if res is not None:
+                error_codes = self.spp_ctl_cli.rest_common_error_codes
+                if res.status_code == 204:
+                    print("Succeeded to %s port" % params[0])
+                elif res.status_code in error_codes:
+                    pass
+                else:
+                    print('Error: unknown response.')
 
     def _run_cls_table(self, params):
         req_params = None
@@ -337,7 +341,7 @@ class SppVf(object):
                           'vlan': params[2], 'mac_address': params[3],
                           'port': params[4]}
         else:
-            print('Error: Invalid params')
+            print('Error: Invalid syntax.')
 
         if req_params is not None:
             req = 'vfs/%d/classifier_table' % self.sec_id
-- 
2.7.4

  parent reply	other threads:[~2019-02-04  3:13 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-04  3:11 [spp] [PATCH 0/5] Fix bugs of SPP CLI ogawa.yasufumi
2019-02-04  3:11 ` [spp] [PATCH 1/5] controller: fix bug to add vf comps on same core ogawa.yasufumi
2019-02-04  3:11 ` ogawa.yasufumi [this message]
2019-02-04  3:11 ` [spp] [PATCH 3/5] controller: fix bug of history command ogawa.yasufumi
2019-02-04  3:11 ` [spp] [PATCH 4/5] controller: fix bug of completion of pri ogawa.yasufumi
2019-02-04  3:11 ` [spp] [PATCH 5/5] controller: refactor configuration of logfile ogawa.yasufumi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1549249879-31580-3-git-send-email-ogawa.yasufumi@lab.ntt.co.jp \
    --to=ogawa.yasufumi@lab.ntt.co.jp \
    --cc=ferruh.yigit@intel.com \
    --cc=spp@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).