From: yasufum.o@gmail.com
To: spp@dpdk.org, ferruh.yigit@intel.com, yasufum.o@gmail.com
Subject: [spp] [PATCH] cli: fix TODOs in pri command
Date: Tue, 6 Aug 2019 21:07:05 +0900 [thread overview]
Message-ID: <20190806120705.13265-1-yasufum.o@gmail.com> (raw)
From: Yasufumi Ogawa <yasufum.o@gmail.com>
This update is to fix following TODOs in `commands/pri.py`. For second
one, add util method print_compl_warinig().
* Not accept if given sec ID is already used.
* Warn if enough number of empty lcores cannot be assinged.
Signed-off-by: Yasufumi Ogawa <yasufum.o@gmail.com>
---
src/cli/commands/pri.py | 16 +++++++++-------
src/cli/shell_lib/common.py | 11 +++++++++++
2 files changed, 20 insertions(+), 7 deletions(-)
diff --git a/src/cli/commands/pri.py b/src/cli/commands/pri.py
index eb4d7d4..da5eca6 100644
--- a/src/cli/commands/pri.py
+++ b/src/cli/commands/pri.py
@@ -238,9 +238,6 @@ class SppPrimary(object):
if (tokens[2] in spp_common.SEC_TYPES) and \
(int(tokens[3])-1 in range(max_secondary)):
ptype = tokens[2]
-
- # TODO(yasufum) Not accept if given sec ID is already
- # used.
sid = tokens[3]
# Option of secondary ID is different between spp_nfv
@@ -290,21 +287,26 @@ class SppPrimary(object):
empty_lcores = self._get_empty_lcores()
empty_lcores = sum(empty_lcores, [])
+ # Check if enough number of lcores available.
+ if len(empty_lcores) < nof_slaves:
+ common.print_compl_warinig(
+ 'No available lcores remained!')
+ return []
+
if 'sec_m_lcore' in cli_config.keys():
master_lcore = cli_config['sec_m_lcore']['val']
else:
logger.error('Config "sec_m_lcore" is not defined!')
has_invalid_param = True
- # Decide lcore option based on configured number of
- # lcores.
+ # Decide lcore option based on configured number of lcores.
slave_lcores = []
for l in empty_lcores:
# Master lcore ID should be smaller than slaves.
if l > int(master_lcore):
slave_lcores.append(str(l))
- # TODO(yasufum) warn if enough number of empty
- # lcores cannot be assinged.
+
+ # Check if required number of lcores are found.
if len(slave_lcores) > (nof_slaves - 1):
break
diff --git a/src/cli/shell_lib/common.py b/src/cli/shell_lib/common.py
index ad34e56..b936348 100644
--- a/src/cli/shell_lib/common.py
+++ b/src/cli/shell_lib/common.py
@@ -282,3 +282,14 @@ def validate_config_val(key, val):
# No need to check others.
return True
+
+
+def print_compl_warinig(msg):
+ """Print warning message for completion.
+
+ Printing message while complition disturbs user's input, but it should be
+ printed in some error cases. This method is just for printing warning
+ message simply.
+ """
+
+ print('// WARN: {msg}'.format(msg=msg))
--
2.17.1
reply other threads:[~2019-08-06 12:07 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20190806120705.13265-1-yasufum.o@gmail.com \
--to=yasufum.o@gmail.com \
--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).