Related: rhbz#1075195
commit 69bfafc1be25c0793dc9b5e69672b2c728406243 from rhel7-branch fixing network test cases of the original patch also squashed in this one
--- pykickstart/commands/network.py | 22 ++++++++++++++++++++++ tests/commands/network.py | 25 +++++++++++++++++++++++++ 2 files changed, 47 insertions(+)
diff --git a/pykickstart/commands/network.py b/pykickstart/commands/network.py index 77c16f7..1632c72 100644 --- a/pykickstart/commands/network.py +++ b/pykickstart/commands/network.py @@ -288,11 +288,17 @@ class RHEL7_NetworkData(F20_NetworkData): def __init__(self, *args, **kwargs): F20_NetworkData.__init__(self, *args, **kwargs) self.interfacename = kwargs.get("interfacename", "") + self.bridgeslaves = kwargs.get("bridgeslaves", "") + self.bridgeopts = kwargs.get("bridgeopts", "")
def _getArgsAsStr(self): retval = F20_NetworkData._getArgsAsStr(self) if self.interfacename: retval += " --interfacename=%s" % self.interfacename + if self.bridgeslaves != "": + retval += " --bridgeslaves=%s" % self.bridgeslaves + if self.bridgeopts != "": + retval += " --bridgeopts=%s" % self.bridgeopts
return retval
@@ -589,6 +595,10 @@ class RHEL7_Network(F20_Network): op = F20_Network._getParser(self) op.add_option("--interfacename", dest="interfacename", action="store", default="") + op.add_option("--bridgeslaves", dest="bridgeslaves", action="store", + default="") + op.add_option("--bridgeopts", dest="bridgeopts", action="store", + default="") return op
def parse(self, args): @@ -601,4 +611,16 @@ class RHEL7_Network(F20_Network): if error_message is not None: raise KickstartValueError(formatErrorMsg(self.lineno,msg=error_message))
+ if retval.bridgeopts: + if not retval.bridgeslaves: + msg = formatErrorMsg(self.lineno, msg=_("Option --bridgeopts requires "\ + "--bridgeslaves to be specified")) + raise KickstartValueError(msg) + opts = retval.bridgeopts.split(",") + for opt in opts: + key, _sep, value = opt.partition("=") + if not value or "=" in value: + msg = formatErrorMsg(self.lineno, msg=_("Bad format of --bridgeopts, expecting key=value options separated by ','")) + raise KickstartValueError(msg) + return retval diff --git a/tests/commands/network.py b/tests/commands/network.py index 23e8491..c48d329 100644 --- a/tests/commands/network.py +++ b/tests/commands/network.py @@ -72,6 +72,7 @@ class F20_TestCase(CommandTest): class RHEL7_TestCase(F20_TestCase): def runTest(self): F20_TestCase.runTest(self) + # there needs to be a vlan id after a dot & only one dot is allowed self.assert_parse_error("network --interfacename=abc.", KickstartValueError) self.assert_parse_error("network --interfacename=abc.def", KickstartValueError) @@ -101,5 +102,29 @@ class RHEL7_TestCase(F20_TestCase): self.assert_parse_error("network --interfacename=vlan9001", KickstartValueError) self.assert_parse_error("network --interfacename=abc.9001", KickstartValueError)
+ # bridge options + # pass + self.assert_parse("network --device bridge0 --bootproto dhcp "\ + "--bridgeslaves=ens3,ens7 "\ + "--bridgeopts=priority=40000") + self.assert_parse("network --device bridge0 --bootproto dhcp "\ + "--bridgeslaves=ens3,ens7 "\ + "--bridgeopts=priority=40000,hello-time=3") + + # fail + # slaves missing + self.assert_parse_error("network --device bridge0 --bootproto dhcp "\ + "--bridgeopts=priority=40000", KickstartValueError) + # bad options format + self.assert_parse_error("network --device bridge0 --bootproto dhcp "\ + "--bridgeslaves=ens3,ens7 "\ + '--bridgeopts="priority=40000 hello-time=3"', + KickstartValueError) + self.assert_parse_error("network --device bridge0 --bootproto dhcp "\ + "--bridgeslaves=ens3,ens7 "\ + "--bridgeopts=priority", + KickstartValueError) + + if __name__ == "__main__": unittest.main()
On Thu, 2014-10-23 at 12:47 +0200, Radek Vykydal wrote:
Related: rhbz#1075195
commit 69bfafc1be25c0793dc9b5e69672b2c728406243 from rhel7-branch fixing network test cases of the original patch also squashed in this one
pykickstart/commands/network.py | 22 ++++++++++++++++++++++ tests/commands/network.py | 25 +++++++++++++++++++++++++ 2 files changed, 47 insertions(+)
diff --git a/pykickstart/commands/network.py b/pykickstart/commands/network.py index 77c16f7..1632c72 100644 --- a/pykickstart/commands/network.py +++ b/pykickstart/commands/network.py @@ -288,11 +288,17 @@ class RHEL7_NetworkData(F20_NetworkData): def __init__(self, *args, **kwargs): F20_NetworkData.__init__(self, *args, **kwargs) self.interfacename = kwargs.get("interfacename", "")
self.bridgeslaves = kwargs.get("bridgeslaves", "")
self.bridgeopts = kwargs.get("bridgeopts", "")
def _getArgsAsStr(self): retval = F20_NetworkData._getArgsAsStr(self) if self.interfacename: retval += " --interfacename=%s" % self.interfacename
if self.bridgeslaves != "":
retval += " --bridgeslaves=%s" % self.bridgeslaves
if self.bridgeopts != "":
retval += " --bridgeopts=%s" % self.bridgeopts return retval
@@ -589,6 +595,10 @@ class RHEL7_Network(F20_Network): op = F20_Network._getParser(self) op.add_option("--interfacename", dest="interfacename", action="store", default="")
op.add_option("--bridgeslaves", dest="bridgeslaves", action="store",
default="")
op.add_option("--bridgeopts", dest="bridgeopts", action="store",
default="") return op
def parse(self, args):
@@ -601,4 +611,16 @@ class RHEL7_Network(F20_Network): if error_message is not None: raise KickstartValueError(formatErrorMsg(self.lineno,msg=error_message))
if retval.bridgeopts:
if not retval.bridgeslaves:
msg = formatErrorMsg(self.lineno, msg=_("Option --bridgeopts requires "\
"--bridgeslaves to be specified"))
raise KickstartValueError(msg)
opts = retval.bridgeopts.split(",")
for opt in opts:
key, _sep, value = opt.partition("=")
if not value or "=" in value:
msg = formatErrorMsg(self.lineno, msg=_("Bad format of --bridgeopts, expecting key=value options separated by ','"))
raise KickstartValueError(msg)
return retval
diff --git a/tests/commands/network.py b/tests/commands/network.py index 23e8491..c48d329 100644 --- a/tests/commands/network.py +++ b/tests/commands/network.py @@ -72,6 +72,7 @@ class F20_TestCase(CommandTest): class RHEL7_TestCase(F20_TestCase): def runTest(self): F20_TestCase.runTest(self)
# there needs to be a vlan id after a dot & only one dot is allowed self.assert_parse_error("network --interfacename=abc.", KickstartValueError) self.assert_parse_error("network --interfacename=abc.def", KickstartValueError)
@@ -101,5 +102,29 @@ class RHEL7_TestCase(F20_TestCase): self.assert_parse_error("network --interfacename=vlan9001", KickstartValueError) self.assert_parse_error("network --interfacename=abc.9001", KickstartValueError)
# bridge options
# pass
self.assert_parse("network --device bridge0 --bootproto dhcp "\
"--bridgeslaves=ens3,ens7 "\
"--bridgeopts=priority=40000")
self.assert_parse("network --device bridge0 --bootproto dhcp "\
"--bridgeslaves=ens3,ens7 "\
"--bridgeopts=priority=40000,hello-time=3")
# fail
# slaves missing
self.assert_parse_error("network --device bridge0 --bootproto dhcp "\
"--bridgeopts=priority=40000", KickstartValueError)
# bad options format
self.assert_parse_error("network --device bridge0 --bootproto dhcp "\
"--bridgeslaves=ens3,ens7 "\
'--bridgeopts="priority=40000 hello-time=3"',
KickstartValueError)
self.assert_parse_error("network --device bridge0 --bootproto dhcp "\
"--bridgeslaves=ens3,ens7 "\
"--bridgeopts=priority",
KickstartValueError)
if __name__ == "__main__": unittest.main()
ACK.
anaconda-patches@lists.fedorahosted.org