[PATCH] Add liveimg install method

Vratislav Podzimek vpodzime at redhat.com
Thu May 9 09:45:55 UTC 2013


On Thu, 2013-05-02 at 17:54 -0700, Brian C. Lane wrote:
> From: "Brian C. Lane" <bcl at redhat.com>
> 
> ---
>  pykickstart/commands/method.py  | 52 +++++++++++++++++++++++++++++++++++++++++
>  pykickstart/handlers/control.py | 18 +++++++-------
>  tests/commands/method.py        | 28 ++++++++++++++++++++++
>  3 files changed, 90 insertions(+), 8 deletions(-)
> 
> diff --git a/pykickstart/commands/method.py b/pykickstart/commands/method.py
> index f91bf59..272e9bf 100644
> --- a/pykickstart/commands/method.py
> +++ b/pykickstart/commands/method.py
> @@ -293,3 +293,55 @@ class F18_Method(F14_Method):
>                  raise KickstartValueError, formatErrorMsg(self.lineno, msg=_("One of --url or --mirrorlist must be specified for url command."))
>  
>          return retval
> +
> +class F19_Method(F18_Method):
> +    removedKeywords = F18_Method.removedKeywords
> +    removedAttrs = F18_Method.removedAttrs
> +
> +    def __init__(self, *args, **kwargs):
> +        F18_Method.__init__(self, *args, **kwargs)
> +        self.checksum = ""
> +
> +    def __eq__(self, other):
> +        if not F18_Method.__eq__(self, other):
> +            return False
> +
> +        if self.method == "liveimg":
> +            return self.url == other.url and self.proxy == other.proxy and \
> +                   self.noverifyssl == other.noverifyssl and \
> +                   self.checksum == other.checksum
> +        else:
> +            return True
> +
> +    def __str__(self):
> +        if self.method == "liveimg":
> +            retval = KickstartCommand.__str__(self)
> +            retval += "# Use live disk image installation\n"
> +
> +            retval += "liveimg --url=\"%s\"" % self.url
> +
> +            if self.proxy:
> +                retval += " --proxy=\"%s\"" % self.proxy
> +
> +            if self.noverifyssl:
> +                retval += " --noverifyssl"
> +
> +            if self.checksum:
> +                retval += " --checksum=\"%s\"" % self.checksum
> +
> +            return retval + "\n"
> +        else:
> +            retval = F18_Method.__str__(self)
> +
> +        return retval
> +
> +    def _getParser(self):
> +        op = F18_Method._getParser(self)
> +
> +        if self.currentCmd == "liveimg":
> +            op.add_option("--url", required=1)
> +            op.add_option("--proxy")
> +            op.add_option("--noverifyssl", action="store_true", default=False)
> +            op.add_option("--checksum")
> +
> +        return op
> diff --git a/pykickstart/handlers/control.py b/pykickstart/handlers/control.py
> index 1993478..77349f3 100644
> --- a/pykickstart/handlers/control.py
> +++ b/pykickstart/handlers/control.py
> @@ -952,7 +952,7 @@ commandMap = {
>          "autostep": autostep.FC3_AutoStep,
>          "bootloader": bootloader.F18_Bootloader,
>          "btrfs": btrfs.F17_BTRFS,
> -        "cdrom": method.F18_Method,
> +        "cdrom": method.F19_Method,
>          "clearpart": clearpart.F17_ClearPart,
>          "cmdline": displaymode.FC3_DisplayMode,
>          "device": device.F8_Device,
> @@ -965,19 +965,20 @@ commandMap = {
>          "graphical": displaymode.FC3_DisplayMode,
>          "group": group.F12_Group,
>          "halt": reboot.F18_Reboot,
> -        "harddrive": method.F18_Method,
> +        "harddrive": method.F19_Method,
>          "ignoredisk": ignoredisk.F14_IgnoreDisk,
>          "install": upgrade.F11_Upgrade,
>          "iscsi": iscsi.F17_Iscsi,
>          "iscsiname": iscsiname.FC6_IscsiName,
>          "keyboard": keyboard.F18_Keyboard,
>          "lang": lang.F19_Lang,
> +        "liveimg": method.F19_Method,
>          "logging": logging.FC6_Logging,
>          "logvol": logvol.F18_LogVol,
>          "mediacheck": mediacheck.FC4_MediaCheck,
>          "multipath": multipath.FC6_MultiPath,
>          "network": network.F19_Network,
> -        "nfs": method.F18_Method,
> +        "nfs": method.F19_Method,
>          "part": partition.F18_Partition,
>          "partition": partition.F18_Partition,
>          "poweroff": reboot.F18_Reboot,
> @@ -995,7 +996,7 @@ commandMap = {
>          "timezone": timezone.F18_Timezone,
>          "updates": updates.F7_Updates,
>          "upgrade": upgrade.F11_Upgrade,
> -        "url": method.F18_Method,
> +        "url": method.F19_Method,
>          "user": user.F19_User,
>          "vnc": vnc.F9_Vnc,
>          "volgroup": volgroup.FC16_VolGroup,
> @@ -1232,7 +1233,7 @@ commandMap = {
>          "autopart": autopart.F16_AutoPart,
>          "autostep": autostep.FC3_AutoStep,
>          "bootloader": bootloader.F17_Bootloader,
> -        "cdrom": method.F14_Method,
> +        "cdrom": method.F19_Method,
>          "clearpart": clearpart.FC3_ClearPart,
>          "cmdline": displaymode.FC3_DisplayMode,
>          "device": device.F8_Device,
> @@ -1245,19 +1246,20 @@ commandMap = {
>          "graphical": displaymode.FC3_DisplayMode,
>          "group": group.F12_Group,
>          "halt": reboot.FC6_Reboot,
> -        "harddrive": method.F14_Method,
> +        "harddrive": method.F19_Method,
>          "ignoredisk": ignoredisk.F14_IgnoreDisk,
>          "install": upgrade.F11_Upgrade,
>          "iscsi": iscsi.F10_Iscsi,
>          "iscsiname": iscsiname.FC6_IscsiName,
>          "keyboard": keyboard.FC3_Keyboard,
>          "lang": lang.FC3_Lang,
> +        "liveimg": method.F19_Method,
>          "logging": logging.FC6_Logging,
>          "logvol": logvol.F15_LogVol,
>          "mediacheck": mediacheck.FC4_MediaCheck,
>          "multipath": multipath.FC6_MultiPath,
>          "network": network.F19_Network,
> -        "nfs": method.F14_Method,
> +        "nfs": method.F19_Method,
>          "part": partition.F14_Partition,
>          "partition": partition.F14_Partition,
>          "poweroff": reboot.FC6_Reboot,
> @@ -1276,7 +1278,7 @@ commandMap = {
>          "unsupported_hardware": unsupported_hardware.RHEL6_UnsupportedHardware,
>          "updates": updates.F7_Updates,
>          "upgrade": upgrade.F11_Upgrade,
> -        "url": method.F14_Method,
> +        "url": method.F19_Method,
>          "user": user.F19_User,
>          "vnc": vnc.F9_Vnc,
>          "volgroup": volgroup.FC16_VolGroup,
> diff --git a/tests/commands/method.py b/tests/commands/method.py
> index b80ca5e..7ca643b 100644
> --- a/tests/commands/method.py
> +++ b/tests/commands/method.py
> @@ -133,5 +133,33 @@ class F18_TestCase(F14_TestCase):
>          self.assert_parse_error("url --url=www.wherever.com --mirrorlist=www.wherever.com",
>                                  KickstartValueError)
>  
> +class F19_TestCase(F18_TestCase):
> +    def runTest(self):
> +        # run F18 test case.
> +        F18_TestCase.runTest(self)
> +
> +        # liveimg pass
> +        self.assert_parse("liveimg --url=http://someplace/somewhere --proxy=http://wherever/other "
> +                          "--noverifyssl --checksum=e7a9fe500330a1cae4ca114833bb3df014e6d14e63ea9566896a848f3832d0ba",
> +                          "liveimg --url=\"http://someplace/somewhere\" --proxy=\"http://wherever/other\" "
> +                          "--noverifyssl --checksum=\"e7a9fe500330a1cae4ca114833bb3df014e6d14e63ea9566896a848f3832d0ba\"\n")
> +        self.assert_parse("liveimg --url=http://someplace/somewhere --proxy=http://wherever/other "
> +                          "--noverifyssl",
> +                          "liveimg --url=\"http://someplace/somewhere\" --proxy=\"http://wherever/other\" "
> +                          "--noverifyssl\n")
> +        self.assert_parse("liveimg --url=http://someplace/somewhere --proxy=http://wherever/other ",
> +                          "liveimg --url=\"http://someplace/somewhere\" --proxy=\"http://wherever/other\"\n")
> +        self.assert_parse("liveimg --url=http://someplace/somewhere",
> +                          "liveimg --url=\"http://someplace/somewhere\"\n")
> +
> +        # liveimg fail
> +        self.assert_parse_error("liveimg", KickstartValueError)
> +        self.assert_parse_error("liveimg --url", KickstartParseError)
> +        self.assert_parse_error("liveimg --url=http://someplace/somewhere --proxy", KickstartParseError)
> +        self.assert_parse_error("liveimg --proxy=http://someplace/somewhere", KickstartValueError)
> +        self.assert_parse_error("liveimg --noverifyssl", KickstartValueError)
> +        self.assert_parse_error("liveimg --checksum=e7a9fe500330a1cae4ca114833bb3df014e6d14e63ea9566896a848f3832d0ba", KickstartValueError)
> +
> +
>  if __name__ == "__main__":
>      unittest.main()
This looks good to me.

-- 
Vratislav Podzimek

Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic



More information about the anaconda-patches mailing list