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

Brian C. Lane bcl at redhat.com
Wed Jan 21 01:28:42 UTC 2015


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)

> +        if cdl:

Should be self.cdl

> +            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):
>          # pass
>          self.assert_parse("clearpart")
>          self.assert_parse("clearpart --all", "clearpart --all  \n")
> +        self.assert_parse("clearpart --all --cdl", "clearpart --all --cdl  \n")
>          # Passing multiple competing type options should accept only the last one
>          self.assert_parse("clearpart --linux --none --all", "clearpart --all  \n")
>          # Setting --initlabel or --drives without a type option should 'fail'
> @@ -23,14 +24,17 @@ class FC3_TestCase(CommandTest):
>          self.assert_parse("clearpart --all --drives sda,sdb", "clearpart --all  --drives=sda,sdb\n")
>          self.assert_parse("clearpart --all --drives=sda", "clearpart --all  --drives=sda\n")
>          self.assert_parse("clearpart --all --drives=sda,sdb", "clearpart --all  --drives=sda,sdb\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=sda,sdb --all --linux --initlabel", "clearpart --linux --initlabel --drives=sda,sdb\n")
> +        self.assert_parse("clearpart --drives=sda,sdb --all --cdl --linux --initlabel", "clearpart --linux --initlabel --cdl --drives=sda,sdb\n")
>  
>          # fail
>          # initlabel should not take a value
>          self.assert_parse_error("clearpart --initlabel=foo")
>          # drives must take a value
>          self.assert_parse_error("clearpart --all --drives")
> +        # cdl should not take a value
> +        self.assert_parse_error("clearpart --cdl=foo")
>          # nonsensical parameter test
>          self.assert_parse_error("clearpart --cheese")

This should be moved to a RHEL6 testcase that inherits from the FC3 one.

-- 
Brian C. Lane | Anaconda Team | IRC: bcl #anaconda | Port Orchard, WA (PST8PDT)


More information about the anaconda-patches mailing list