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 8/9] controller: move topo_resize command to SppTopo
Date: Thu, 18 Oct 2018 20:25:17 +0900	[thread overview]
Message-ID: <20181018112518.77556-9-ogawa.yasufumi@lab.ntt.co.jp> (raw)
In-Reply-To: <20181018112518.77556-1-ogawa.yasufumi@lab.ntt.co.jp>

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

Add graph size to SppTopo and change 'topo_resize' command to change
this attiribute.

Signed-off-by: Yasufumi Ogawa <ogawa.yasufumi@lab.ntt.co.jp>
---
 src/controller/commands/topo.py | 23 +++++++++++++++++++----
 src/controller/shell.py         | 18 +++---------------
 2 files changed, 22 insertions(+), 19 deletions(-)

diff --git a/src/controller/commands/topo.py b/src/controller/commands/topo.py
index fc22a98..53cc8b5 100644
--- a/src/controller/commands/topo.py
+++ b/src/controller/commands/topo.py
@@ -1,4 +1,3 @@
-#!/usr/bin/env python
 # SPDX-License-Identifier: BSD-3-Clause
 # Copyright(c) 2017-2018 Nippon Telegraph and Telephone Corporation
 
@@ -23,18 +22,19 @@ class SppTopo(object):
 
     delim_node = '_'
 
-    def __init__(self, spp_ctl_cli, sec_ids, subgraphs):
+    def __init__(self, spp_ctl_cli, sec_ids, subgraphs, size):
         self.spp_ctl_cli = spp_ctl_cli
         self.sec_ids = sec_ids
         self.subgraphs = subgraphs
+        self.graph_size = size
 
-    def run(self, args, topo_size):
+    def run(self, args):
         args_ary = args.split()
         if len(args_ary) == 0:
             print("Usage: topo dst [ftype]")
             return False
         elif (args_ary[0] == "term") or (args_ary[0] == "http"):
-            self.show(args_ary[0], topo_size)
+            self.show(args_ary[0], self.graph_size)
         elif len(args_ary) == 1:
             ftype = args_ary[0].split(".")[-1]
             self.output(args_ary[0], ftype)
@@ -320,6 +320,21 @@ class SppTopo(object):
             topo_doc += "commands/experimental.html"
             print("See '%s' for required packages." % topo_doc)
 
+    def resize_graph(self, args):
+        if args == '':
+            print(self.graph_size)
+        else:
+            if '%' in args:
+                self.graph_size = args
+                print(self.graph_size)
+            elif '.' in args:
+                ii = float(args) * 100
+                self.graph_size = str(ii) + '%'
+                print(self.graph_size)
+            else:  # TODO(yasufum) add check for no number
+                self.graph_size = str(float(args) * 100) + '%'
+                print(self.graph_size)
+
     def format_sec_status(self, sec_id, stat):
         """Return formatted secondary status as a hash
 
diff --git a/src/controller/shell.py b/src/controller/shell.py
index 0f95447..bdc41fe 100644
--- a/src/controller/shell.py
+++ b/src/controller/shell.py
@@ -48,7 +48,7 @@ class Shell(cmd.Cmd, object):
         self.spp_secondary = sec.SppSecondary(self.spp_ctl_cli)
         self.spp_topo = topo.SppTopo(self.spp_ctl_cli,
                                      self.get_sec_ids('nfv'),
-                                     {})
+                                     {}, self.topo_size)
 
     def default(self, line):
         """Define defualt behaviour.
@@ -664,19 +664,7 @@ class Shell(cmd.Cmd, object):
 
         """
 
-        if args == '':
-            print(self.topo_size)
-        else:
-            if '%' in args:
-                self.topo_size = args
-                print(self.topo_size)
-            elif '.' in args:
-                ii = float(args) * 100
-                self.topo_size = str(ii) + '%'
-                print(self.topo_size)
-            else:  # TODO(yasufum) add check for no number
-                self.topo_size = str(float(args) * 100) + '%'
-                print(self.topo_size)
+        self.spp_topo.resize_graph(args)
 
     def do_topo(self, args):
         """Output network topology.
@@ -694,7 +682,7 @@ class Shell(cmd.Cmd, object):
         spp > topo network_conf.js# text
         """
 
-        self.spp_topo.run(args, self.topo_size)
+        self.spp_topo.run(args)
 
     def complete_topo(self, text, line, begidx, endidx):
 
-- 
2.13.1

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

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-18 11:25 [spp] [PATCH 0/9] Change SPP controller to use spp-ctl ogawa.yasufumi
2018-10-18 11:25 ` [spp] [PATCH 1/9] controller: add spp-ctl client for SPP controller ogawa.yasufumi
2018-10-18 11:25 ` [spp] [PATCH 2/9] controller: change controller to use spp-ctl ogawa.yasufumi
2018-10-18 11:25 ` [spp] [PATCH 3/9] spp-ctl: add IP address binding ogawa.yasufumi
2018-10-18 11:25 ` [spp] [PATCH 4/9] controller: add IP address and port binding ogawa.yasufumi
2018-10-18 11:25 ` [spp] [PATCH 5/9] controller: move pri command to SppPrimary ogawa.yasufumi
2018-10-18 11:25 ` [spp] [PATCH 6/9] controller: move sec command to SppSecondary ogawa.yasufumi
2018-10-18 11:25 ` [spp] [PATCH 7/9] controller: move topo command to SppTopo ogawa.yasufumi
2018-10-18 11:25 ` ogawa.yasufumi [this message]
2018-10-18 11:25 ` [spp] [PATCH 9/9] controller: move bye command to SppBye 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=20181018112518.77556-9-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).