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 2/4] controller: update parsing status message
Date: Thu, 11 Oct 2018 19:33:45 +0900	[thread overview]
Message-ID: <20181011103347.48630-3-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>

To apply with the update of spp_nfv and spp_vm, update parsing the
message of status.

In the updated message, 'ports' attribute is changed to not include
patch info and it is moved to the new 'patches' attribute. This patch
is to parse 'patches' attribute. Output of status command is not
changed.

Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
 src/controller/shell.py | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/src/controller/shell.py b/src/controller/shell.py
index 09b9e86..8fb5a1a 100644
--- a/src/controller/shell.py
+++ b/src/controller/shell.py
@@ -194,27 +194,30 @@ class Shell(cmd.Cmd, object):
             - phy:1
 
         The format of the received message is JSON and ended with
-        series of null character "\x00". The value of "ports" attribute
-        is a set of combinations of patches. If a port is not patched,
-        the "dst" is set to "null".
+        series of null character "\x00".
 
-          {"status":"idling","ports":[{"src":"phy:0", "dst": ...,]}'\x00\x00..
+          {"client-id":1,...,"patches":[{"src":"phy:0"...},...]}'\x00..
         """
 
-        msg = msg.replace("\x00", "")  # clean sec's msg
+        msg = msg.replace("\x00", "")  # Clean received msg
 
         try:
             sec_attr = json.loads(msg)
             print('- status: %s' % sec_attr['status'])
             print('- ports:')
             for port in sec_attr['ports']:
-                if port['dst'] == 'null':
-                    print('  - %s' % port['src'])
+                dst = None
+                for patch in sec_attr['patches']:
+                    if patch['src'] == port:
+                        dst = patch['dst']
+
+                if dst is None:
+                    print('  - %s' % port)
                 else:
-                    print('  - %s -> %s' % (port['src'], port['dst']))
+                    print('  - %s -> %s' % (port, dst))
         except ValueError as err:
             print('Invalid format: {0}.'.format(err))
-            print("  '%s'" % msg)
+            print("'%s'" % msg)
 
     def command_primary(self, command):
         """Send command to primary process"""
-- 
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   ` ogawa.yasufumi [this message]
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   ` [spp] [PATCH v2 4/4] spp-ctl: update parsing status 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=20181011103347.48630-3-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).