[PATCH pykickstart rhel7-branch?] Add support for network team devices (#1003591)
Vratislav Podzimek
vpodzime at redhat.com
Wed Nov 6 14:06:53 UTC 2013
On Wed, 2013-11-06 at 11:02 +0100, Radek Vykydal wrote:
> ---
> pykickstart/commands/network.py | 53 ++++++++++++++++++++++++++++++
> pykickstart/handlers/control.py | 8 ++---
> tests/commands/network.py | 73 +++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 130 insertions(+), 4 deletions(-)
> create mode 100644 tests/commands/network.py
>
> diff --git a/pykickstart/commands/network.py b/pykickstart/commands/network.py
> index 6f50ac1..e7511fc 100644
> --- a/pykickstart/commands/network.py
> +++ b/pykickstart/commands/network.py
> @@ -193,6 +193,31 @@ class F19_NetworkData(F16_NetworkData):
>
> return retval
>
> +class F20_NetworkData(F19_NetworkData):
> + removedKeywords = F19_NetworkData.removedKeywords
> + removedAttrs = F19_NetworkData.removedAttrs
> +
> + def __init__(self, *args, **kwargs):
> + F19_NetworkData.__init__(self, *args, **kwargs)
> + self.teamslaves = kwargs.get("teamslaves", [])
> + self.teamconfig = kwargs.get("teamconfig", "")
> +
> + def _getArgsAsStr(self):
> + retval = F19_NetworkData._getArgsAsStr(self)
> +
> + # see the tests for format description
> + if self.teamslaves:
> + slavecfgs = []
> + for slave, config in self.teamslaves:
> + if config:
> + config = "'" + config + "'"
> + slavecfgs.append(slave+config)
> + slavecfgs = ",".join(slavecfgs).replace('"', r'\"')
> + retval += " --teamslaves=\"%s\"" % slavecfgs
> + if self.teamconfig:
> + retval += " --teamconfig=%s" % self.teamconfig.replace('"', r'\"')
> + return retval
> +
> class RHEL4_NetworkData(FC3_NetworkData):
> removedKeywords = FC3_NetworkData.removedKeywords
> removedAttrs = FC3_NetworkData.removedAttrs
> @@ -384,6 +409,34 @@ class F19_Network(F18_Network):
> default="")
> return op
>
> +class F20_Network(F19_Network):
> +
> + def _getParser(self):
> + # see the tests for format description
> + def teamslaves_cb(option, opt_str, value, parser):
> + teamslaves = []
> + if value:
> + parts = value.split("'")
> + if len(parts) % 2:
I think 'if len(parts) % 2 == 1' would be nicer.
> + if not parts[-1]:
> + parts = parts[:-1]
> + else:
> + parts.append('')
> + it = iter(parts)
> + for devs, cfg in zip(it,it):
> + devs = devs.strip(',').split(',')
> + for d in devs[:-1]:
> + teamslaves.append((d, ''))
> + teamslaves.append((devs[-1], cfg))
And this whole block processing the parts deserves a comment on what's
going on maybe with some examples of values/parts.
--
Vratislav Podzimek
Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic
More information about the anaconda-patches
mailing list