Re: [master 1/2] Turn sshd setup, kicstart execution and the rescue mode into dispatch steps.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> @@ -249,9 +249,9 @@ class Bootloader(commands.bootloader.F15_Bootloader):
>              self.anaconda.bootloader.update_only = True
>  
>          if location is None:
> -            self.anaconda.ksdata.permanentSkipSteps.append("instbootloader")
> +            self.anaconda.dispatch.skipStep("instbootloader", permanent=1)
>          else:
> -            self.anaconda.ksdata.showSteps.append("bootloader")
> +            self.anaconda.dispatch.skipStep("bootloader", skip=0)
>  
>              if self.appendLine:
>                  args = self.appendLine.split()
> @@ -276,7 +276,8 @@ class Bootloader(commands.bootloader.F15_Bootloader):
>  
>              self.anaconda.bootloader.drive_order = self.driveorder
>  
> -        self.anaconda.ksdata.permanentSkipSteps.extend(["upgbootloader", "bootloader"])
> +        map(lambda step: self.anaconda.dispatch.skipStep(step, permanent=1),
> +            ["upgbootloader", "bootloader"])

Careful here - note above that bootloader is added to showSteps, which
gets processed after skipSteps in the setSteps method.  Because of how
this Bootloader class is arranged, you're going to have to guard that
last map from ever happening, or the bootloader step will get skipped
when it shouldn't be.

>  class ClearPart(commands.clearpart.FC3_ClearPart):
>      def parse(self, args):
> @@ -306,7 +307,7 @@ class ClearPart(commands.clearpart.FC3_ClearPart):
>              self.anaconda.storage.config.reinitializeDisks = self.initAll
>  
>          clearPartitions(self.anaconda.storage)
> -        self.anaconda.ksdata.skipSteps.append("cleardiskssel")
> +        self.anaconda.dispatch.skipStep("cleardiskssel")
>  
>  class Fcoe(commands.fcoe.F13_Fcoe):
>      def parse(self, args):
> @@ -359,7 +360,7 @@ class IgnoreDisk(commands.ignoredisk.RHEL6_IgnoreDisk):
>  
>      def execute(self):
>          if not self.interactive:
> -            self.anaconda.ksdata.skipSteps.extend(["filter", "filtertype"])
> +            map(self.anaconda.dispatch.skipStep, ["filter", "filtertype"])
>  
>  class Iscsi(commands.iscsi.F10_Iscsi):
>      class Login(object):
> @@ -408,14 +409,14 @@ class Keyboard(commands.keyboard.FC3_Keyboard):
>      def execute(self):
>          self.anaconda.keyboard.set(self.keyboard)
>          self.anaconda.keyboard.beenset = 1
> -        self.anaconda.ksdata.skipSteps.append("keyboard")
> +        self.anaconda.dispatch.skipStep("keyboard")
>  
>  class Lang(commands.lang.FC3_Lang):
>      def execute(self):
>          self.anaconda.instLanguage.instLang = self.lang
>          self.anaconda.instLanguage.systemLang = self.lang
>          self.anaconda.instLanguage.buildLocale()
> -        self.anaconda.ksdata.skipSteps.append("language")
> +        self.anaconda.dispatch.skipStep("language")
>  
>  class LogVolData(commands.logvol.F15_LogVolData):
>      def execute(self):
> @@ -457,7 +458,7 @@ class LogVolData(commands.logvol.F15_LogVolData):
>  
>              dev.format.mountpoint = self.mountpoint
>              dev.format.mountopts = self.fsopts
> -            self.anaconda.ksdata.skipSteps.extend(["partition", "zfcpconfig", "parttype"])
> +            map(self.anaconda.dispatch.skipStep, ["partition", "zfcpconfig", "parttype"])
>              return
>  
>          # Make sure this LV name is not already used in the requested VG.
> @@ -540,7 +541,7 @@ class LogVolData(commands.logvol.F15_LogVolData):
>                                       parents=request)
>              storage.createDevice(luksdev)
>  
> -        self.anaconda.ksdata.skipSteps.extend(["partition", "zfcpconfig", "parttype"])
> +        map(self.anaconda.dispatch.skipStep, ["partition", "zfcpconfig", "parttype"])
>  
>  class Logging(commands.logging.FC6_Logging):
>      def execute(self):
> @@ -768,7 +769,7 @@ class PartitionData(commands.partition.F12_PartData):
>  
>              dev.format.mountpoint = self.mountpoint
>              dev.format.mountopts = self.fsopts
> -            self.anaconda.ksdata.skipSteps.extend(["partition", "zfcpconfig", "parttype"])
> +            map(self.anaconda.dispatch.skipStep, ["partition", "zfcpconfig", "parttype"])
>              return
>  
>          # Now get a format to hold a lot of these extra values.
> @@ -857,11 +858,11 @@ class PartitionData(commands.partition.F12_PartData):
>                                       parents=request)
>              storage.createDevice(luksdev)
>  
> -        self.anaconda.ksdata.skipSteps.extend(["partition", "zfcpconfig", "parttype"])
> +        map(self.anaconda.dispatch.skipStep, ["partition", "zfcpconfig", "parttype"])
>  
>  class Reboot(commands.reboot.FC6_Reboot):
>      def execute(self):
> -        self.anaconda.ksdata.skipSteps.append("complete")
> +        self.anaconda.dispatch.skipStep("complete")
>  
>  class RaidData(commands.raid.F15_RaidData):
>      def execute(self):
> @@ -910,7 +911,7 @@ class RaidData(commands.raid.F15_RaidData):
>  
>              dev.format.mountpoint = self.mountpoint
>              dev.format.mountopts = self.fsopts
> -            self.anaconda.ksdata.skipSteps.extend(["partition", "zfcpconfig", "parttype"])
> +            map(self.anaconda.dispatch.skipStep, ["partition", "zfcpconfig", "parttype"])
>              return
>  
>          # Get a list of all the RAID members.
> @@ -1003,14 +1004,14 @@ class RaidData(commands.raid.F15_RaidData):
>                                       parents=request)
>              storage.createDevice(luksdev)
>  
> -        self.anaconda.ksdata.skipSteps.extend(["partition", "zfcpconfig", "parttype"])
> +        map(self.anaconda.dispatch.skipStep, ["partition", "zfcpconfig", "parttype"])
>  
>  class RootPw(commands.rootpw.F8_RootPw):
>      def execute(self):
>          self.anaconda.users.rootPassword["password"] = self.password
>          self.anaconda.users.rootPassword["isCrypted"] = self.isCrypted
>          self.anaconda.users.rootPassword["lock"] = self.lock
> -        self.anaconda.ksdata.skipSteps.append("accounts")
> +        self.anaconda.dispatch.skipStep("accounts")
>  
>  class SELinux(commands.selinux.FC3_SELinux):
>      def execute(self):
> @@ -1030,7 +1031,7 @@ class Timezone(commands.timezone.FC6_Timezone):
>              log.warning("Timezone %s set in kickstart is not valid." % (self.timezone,))
>  
>          self.anaconda.timezone.setTimezoneInfo(self.timezone, self.isUtc)
> -        self.anaconda.ksdata.skipSteps.append("timezone")
> +        self.anaconda.dispatch.skipStep("timezone")
>  
>  class Upgrade(commands.upgrade.F11_Upgrade):
>      def execute(self):
> @@ -1151,9 +1152,6 @@ class AnacondaKSHandler(superclass):
>          superclass.__init__(self, commandUpdates=commandMap, dataUpdates=dataMap)
>          self.packages = AnacondaKSPackages()
>  
> -        self.permanentSkipSteps = []
> -        self.skipSteps = []
> -        self.showSteps = []
>          self.anaconda = anaconda
>          self.onPart = {}
>  
> @@ -1266,6 +1264,13 @@ class AnacondaKSParser(KickstartParser):
>          self.handler.add(retval)
>          return retval
>  
> +def doKickstart(anaconda):
> +    storage.storageInitialize(anaconda)
> +    # Having initialized storage, we can apply all the other kickstart commands.
> +    # This gives us the ability to check that storage commands are correctly
> +    # formed and refer to actual devices.
> +    anaconda.ksdata.execute()
> +
>  def preScriptPass(anaconda, file):
>      # The first pass through kickstart file processing - look for %pre scripts
>      # and run them.  This must come in a separate pass in case a script
> @@ -1476,6 +1481,7 @@ def setSteps(anaconda):
>      else:
>          anaconda.instClass.setSteps(anaconda)
>          dispatch.skipStep("findrootparts")
> +    dispatch.skipStep("kickstart", skip = 0)
>  
>      dispatch.skipStep("betanag")
>      dispatch.skipStep("network")
> @@ -1496,25 +1502,19 @@ def setSteps(anaconda):
>  
>      # If the package section included anything, skip group selection.
>      if ksdata.upgrade.upgrade:
> -        ksdata.skipSteps.extend(["tasksel", "group-selection"])
> +        map(anaconda.dispatch.skipStep, ["tasksel", "group-selection"])
>  
>          # Special check for this, since it doesn't make any sense.
>          if ksdata.packages.seen:
>              warnings.warn("Ignoring contents of %packages section due to upgrade.")
>      elif havePackages(ksdata.packages):
> -        ksdata.skipSteps.extend(["tasksel", "group-selection"])
> +        map(anaconda.dispatch.skipStep, ["tasksel", "group-selection"])
>      else:
>          if ksdata.packages.seen:
> -            ksdata.skipSteps.extend(["tasksel", "group-selection"])
> +            map(anaconda.dispatch.skipStep, ["tasksel", "group-selection"])
>          else:
> -            ksdata.showSteps.extend(["tasksel", "group-selection"])
> -
> -    for n in ksdata.skipSteps:
> -        dispatch.skipStep(n)
> -    for n in ksdata.permanentSkipSteps:
> -        dispatch.skipStep(n, permanent=1)
> -    for n in ksdata.showSteps:
> -        dispatch.skipStep(n, skip = 0)
> +            map(lambda step: anaconda.dispatch.skipStep(step, skip=0),
> +                ["tasksel", "group-selection"])
>  
>      # Text mode doesn't have all the steps that graphical mode does, so we
>      # can't stop and prompt for missing information.  Make sure we've got

> +def createSshKey(algorithm, keyfile):
> +    path = '/etc/ssh/%s' % (keyfile,)
> +    argv = ['-q','-t',algorithm,'-f',path,'-C','','-N','']
> +    if os.access(path, os.R_OK):
> +        return
> +    log.debug("running \"%s\"" % (" ".join(['ssh-keygen']+argv),))
> +
> +    so = "/tmp/ssh-keygen-%s-stdout.log" % (algorithm,)
> +    se = "/tmp/ssh-keygen-%s-stderr.log" % (algorithm,)
> +    iutil.execWithRedirect('ssh-keygen', argv, stdout=so, stderr=se)
> +
> +def doSshd(anaconda):
> +    if flags.sshd:
> +        # we need to have a libuser.conf that points to the installer root for
> +        # sshpw, but after that we start sshd, we need one that points to the
> +        # install target.
> +        luserConf = users.createLuserConf(instPath="")
> +        handleSshPw(anaconda)
> +        startSsh()
> +        del(os.environ["LIBUSER_CONF"])
> +    else:
> +        log.info("sshd: not enabled, skipping.")
> +
> +    users.createLuserConf(anaconda.rootPath)

I'd love to see all this ssh stuff move to using systemd.  Perhaps the
service file doesn't need to be enabled by default (given all the
configuation we do), but we could at least use systemctl to have it
started.
_______________________________________________
Anaconda-devel-list mailing list
Anaconda-devel-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/anaconda-devel-list


[Index of Archives]     [Kickstart]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]
  Powered by Linux