[pykickstart][rhel6-branch] Add clearpart --cdl option. (#1182624)

Samantha N. Bueno sbueno+anaconda at redhat.com
Wed Jan 21 15:55:29 UTC 2015


On Tue, Jan 20, 2015 at 05:28:42PM -0800, Brian C. Lane wrote:
> On Tue, Jan 20, 2015 at 02:57:44PM -0500, Samantha N. Bueno wrote:
> > Specifying this option in a ks file will ensure that any LDL DASDs
> > will be (re)formatted to CDL format.
> > 
> > Resolves: rhbz#1182624
> > ---
> >  docs/kickstart-docs.txt           |  3 +++
> >  pykickstart/commands/clearpart.py | 18 ++++++++++++++++++
> >  pykickstart/handlers/control.py   |  2 +-
> >  tests/commands/clearpart.py       |  6 +++++-
> >  4 files changed, 27 insertions(+), 2 deletions(-)
> > 
> > diff --git a/docs/kickstart-docs.txt b/docs/kickstart-docs.txt
> > index 3e9b4d5..5674585 100644
> > --- a/docs/kickstart-docs.txt
> > +++ b/docs/kickstart-docs.txt
> > @@ -372,6 +372,9 @@ clearpart (optional)
> >  
> >          * --none (default) - Do not remove any partitions.
> >  
> > +        * --cdl - Automatically format any LDL DASDs to CDL. This option
> > +          is only really applicable to s390x.
> > +
> >  cmdline (optional)
> >        Perform the installation in a completely non-interactive command
> >        line mode. Any prompts for interaction halts the install. This mode
> > diff --git a/pykickstart/commands/clearpart.py b/pykickstart/commands/clearpart.py
> > index 88307a3..07471ae 100644
> > --- a/pykickstart/commands/clearpart.py
> > +++ b/pykickstart/commands/clearpart.py
> > @@ -86,3 +86,21 @@ class FC3_ClearPart(KickstartCommand):
> >          (opts, extra) = self.op.parse_args(args=args, lineno=self.lineno)
> >          self._setToSelf(self.op, opts)
> >          return self
> > +
> > +class RHEL6_ClearPart(FC3_ClearPart):
> > +    def __init__(self, *args, **kwargs):
> > +        FC3_ClearPart.__init__(self, *args, **kwargs)
> > +        self.cdl = kwargs.get("cdl", False)
> > +
> > +    def __str__(self):
> > +        ret = FC3_ClearPart.__str__(self)
> 
> Should be retval (or use ret below)

Oops! I changed the var name at the last moment. Everything is "retval"
now locally.
 
> > +        if cdl:
> 
> Should be self.cdl

Also fixed locally.
 
> > +            retval += " --cdl \n"
> > +
> > +        return retval
> > +
> > +    def _getParser(self):
> > +        op = FC3_ClearPart._getParser(self)
> > +
> > +        op.add_option("--cdl", dest="cdl", action="store_true", default=False)
> > +        return op
> > diff --git a/pykickstart/handlers/control.py b/pykickstart/handlers/control.py
> > index 0d73c95..6721be2 100644
> > --- a/pykickstart/handlers/control.py
> > +++ b/pykickstart/handlers/control.py
> > @@ -817,7 +817,7 @@ commandMap = {
> >          "autostep": autostep.FC3_AutoStep,
> >          "bootloader": bootloader.RHEL6_Bootloader,
> >          "cdrom": method.RHEL6_Method,
> > -        "clearpart": clearpart.FC3_ClearPart,
> > +        "clearpart": clearpart.RHEL6_ClearPart,
> >          "cmdline": displaymode.FC3_DisplayMode,
> >          "device": device.F8_Device,
> >          "deviceprobe": deviceprobe.FC3_DeviceProbe,
> > diff --git a/tests/commands/clearpart.py b/tests/commands/clearpart.py
> > index f4e6076..7da9f3c 100644
> > --- a/tests/commands/clearpart.py
> > +++ b/tests/commands/clearpart.py
> > @@ -12,6 +12,7 @@ class FC3_TestCase(CommandTest):
> 
> This should be moved to a RHEL6 testcase that inherits from the FC3 one.

Oops, I can't believe I forgot about this one, thanks. So here is just
the test file portion then:

diff --git a/tests/commands/clearpart.py b/tests/commands/clearpart.py
index f4e6076..2d93b89 100644
--- a/tests/commands/clearpart.py
+++ b/tests/commands/clearpart.py
@@ -34,5 +34,20 @@ class FC3_TestCase(CommandTest):
         # nonsensical parameter test
         self.assert_parse_error("clearpart --cheese")
 
+class RHEL6_TestCase(FC3_TestCase):
+    def runTest(self):
+        FC3_TestCase.runTest(self)
+
+        # pass
+        self.assert_parse("clearpart --all --cdl", "clearpart --all --cdl  \n")
+        self.assert_parse("clearpart --all --cdl --drives=dasda,dasdb,dasdc", "clearpart --all --cdl --drives=dasda,dasdb,dasdc \n")
+
+        # Big Everything Test
+        self.assert_parse("clearpart --drives=dasda,dasdb,dasdc --all --linux --cdl --initlabel", "clearpart --linux --cdl --initlabel --drives=dasda,dasdb,dasdc \n")
+
+        # fail
+        # cdl should not take a value
+        self.assert_parse_error("clearpart --cdl=foo")
+
 if __name__ == "__main__":
     unittest.main()


More information about the anaconda-patches mailing list