There are still some issues in the patch.
This string is not accepted: "tso off tx off; gso off tso off"
It must be "tso off tx off;gso off tso off"
^^^^
String "tso off tx off;gso off tso off" generates
|
V
(['tso', 'gso', 'tx'], [[('tso', 'off'),
('gso', 'on'), ('tx', 'off')],
[('tso', 'off'), ('gso', 'off'), ('tx',
'on')]])
But I did not specify gso on and I do not like such magic here. Simply
parse what has been specified.
And one more comment inline.
-Jan
Fri, Oct 14, 2016 at 11:55:56AM CEST, kjerabek(a)redhat.com wrote:
This module provides functions that are related to Offloads.
The function parse_offloads in the module is intended to be use for parsing
offloads alias.
It takes argument offloads string and returns tuple of used offloads and its
combinations.
Signed-off-by: Kamil Jerabek <kjerabek(a)redhat.com>
---
lnst/RecipeCommon/Offloads.py | 49 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
create mode 100644 lnst/RecipeCommon/Offloads.py
diff --git a/lnst/RecipeCommon/Offloads.py b/lnst/RecipeCommon/Offloads.py
new file mode 100644
index 0000000..6484a58
--- /dev/null
+++ b/lnst/RecipeCommon/Offloads.py
@@ -0,0 +1,49 @@
+"""
+This module defines the functions for Offloads tuning that can be imported
+directly into LNST Python tasks.
+
+Copyright 2016 Red Hat, Inc.
+Licensed under the GNU General Public License, version 2 as
+published by the Free Software Foundation; see COPYING for details.
+"""
+
+__author__ = """
+kjerabek(a)redhat.com (Kamil Jerabek)
+"""
+
+import re
+
+def parse_offloads(offloads):
+ """Parse offloads combination in string to list.
+
+ Keyword arguments:
+ offloads -- string of offloads combination separated with ';'
+ """
+
+ if offloads is None:
+ return None
+
+ is_valid = re.compile(r"^([a-z]+\s+off(\s*[;]|\s*))+$")
+ opts_split = re.compile(r".*?(?=;)|.+$")
+ opts_offloads_split = re.compile(r"([a-z]+(?=\s+(off)))+")
+ offloads_split = re.compile(r"([a-z]+)(?=\s+off)")
+
+ if re.match(is_valid, offloads) is None:
+ raise Exception('Invalid offloads format')
+
+ offload_set = (list(set(re.findall(offloads_split, offloads))),[])
+ opts_match = filter(None, re.findall(opts_split, offloads))
+
+ for opts in opts_match:
+ sett = []
+ match = re.findall(opts_offloads_split, opts)
+
+ for off in offload_set[0]:
^^^ could you make this offload
... since it's quite
similar to off as in 'offload turned off'
>+ if (off, 'off') in match:
>+ sett.append((off, 'off'))
>+ else:
>+ sett.append((off, 'on'))
>+
>+ offload_set[1].append(sett)
>+
>+ return offload_set
>--
>2.5.5
>_______________________________________________
>LNST-developers mailing list -- lnst-developers(a)lists.fedorahosted.org
>To unsubscribe send an email to lnst-developers-leave(a)lists.fedorahosted.org