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 v2 4/4] spp-ctl: update parsing status
Date: Thu, 11 Oct 2018 19:33:47 +0900	[thread overview]
Message-ID: <20181011103347.48630-5-ogawa.yasufumi@lab.ntt.co.jp> (raw)
In-Reply-To: <20181011103347.48630-1-ogawa.yasufumi@lab.ntt.co.jp>

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

Update parsing the result of status. Spp_nfv and spp_vm are changed to
return the same status message as spp-ctl, so it can be used without
modifying.

Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
 src/spp-ctl/spp_webapi.py | 39 ++++++++++-----------------------------
 1 file changed, 10 insertions(+), 29 deletions(-)

diff --git a/src/spp-ctl/spp_webapi.py b/src/spp-ctl/spp_webapi.py
index ddf6513..c81d0b7 100644
--- a/src/spp-ctl/spp_webapi.py
+++ b/src/spp-ctl/spp_webapi.py
@@ -321,33 +321,15 @@ class V1NFVHandler(BaseHandler):
     def convert_nfv_info(self, sec_id, data):
         nfv = {}
 
-        # spp_nfv returns status info in two lines. First line is
-        # status of running or idling, and second is patch info.
-        # 'null' means that it has no dst port.
-        #   "status: idling\nports: 'phy:0-phy:1,phy:1-null'\x00\x00.."
-        entries = data.split('\n')
-        if len(entries) != 2:
-            return {}
-
-        nfv['client_id'] = int(sec_id)
-        nfv['status'] = entries[0].split()[1]
-
-        patch_list = entries[1].split()[1].replace("'", '')
-
-        ports = []
-        nfv['patches'] = []
-
-        for port_cmb in patch_list.split(','):
-            p_src, p_dst = port_cmb.split('-')
-            if p_src != 'null' and p_dst != 'null':
-                nfv['patches'].append({'src': p_src, 'dst': p_dst})
-
-            for port in [p_src, p_dst]:
-                if port != 'null':
-                    ports.append(port)
-
-        nfv['ports'] = list(set(ports))
+        # spp_nfv returns status info in JSON format. 'null' means
+        # that it has no dst port.
+        #   {"status":"idling","ports":[{"src":"phy:0","dst":"null"},...
 
+        # TODO(yasufum) modify after nfv and vm is updated for new data definition.
+        try:
+            nfv = json.loads(data)
+        except json.JSONDecodeError as e:
+            print("%s" % e)
         return nfv
 
     def nfv_get(self, proc):
@@ -376,11 +358,10 @@ class V1NFVHandler(BaseHandler):
     def nfv_port(self, proc, body):
         self._validate_nfv_port(body)
 
-        if_type, if_num = body['port'].split(":")
         if body['action'] == "add":
-            proc.port_add(if_type, if_num)
+            proc.port_add(body['port'])
         else:
-            proc.port_del(if_type, if_num)
+            proc.port_del(body['port'])
 
     def _validate_nfv_patch(self, body):
         for key in ['src', 'dst']:
-- 
2.7.4

      parent reply	other threads:[~2018-10-11 10:33 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-09 10:50 [spp] [PATCH 0/4] Update response of status of spp_nfv and spp_vm ogawa.yasufumi
2018-10-09 10:50 ` [spp] [PATCH 1/4] shared: update status format of spp_nfv ogawa.yasufumi
2018-10-09 10:50 ` [spp] [PATCH 2/4] controller: update parsing status message ogawa.yasufumi
2018-10-09 10:50 ` [spp] [PATCH 3/4] spp-ctl: update syntax of add and del command ogawa.yasufumi
2018-10-09 21:56   ` Itsuro ODA
2018-10-10  4:41     ` Yasufumi Ogawa
2018-10-09 10:50 ` [spp] [PATCH 4/4] spp-ctl: update parsing status ogawa.yasufumi
2018-10-11 10:33 ` [spp] [PATCH v2 0/4] Update response of status of spp_nfv and spp_vm ogawa.yasufumi
2018-10-11 10:33   ` [spp] [PATCH v2 1/4] shared: update status format of spp_nfv ogawa.yasufumi
2018-10-11 10:33   ` [spp] [PATCH v2 2/4] controller: update parsing status message ogawa.yasufumi
2018-10-11 10:33   ` [spp] [PATCH v2 3/4] spp-ctl: update syntax of add and del command ogawa.yasufumi
2018-10-11 10:33   ` ogawa.yasufumi [this message]

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=20181011103347.48630-5-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).