示例#1
0
    def startup(self, intf, exclusiveDisks, zeroMbr, cdl):
        """ Look for any unformatted DASDs in the system and offer the user
            the option for format them with dasdfmt or exit the installer.

            Also check if any DASDs are LDL formatted and show a warning to
            users, since these disks will not be usable during installation.
        """
        if self.started:
            return

        self.started = True

        if not iutil.isS390():
            return

        # Trigger udev data about the dasd devices on the system
        udev_trigger(action="change", name="dasd*")

        log.info("Checking for unformatted and LDL DASD devices:")

        for device in os.listdir("/sys/block"):
            if not device.startswith("dasd"):
                continue

            statusfile = "/sys/block/%s/device/status" % (device, )
            if not os.path.isfile(statusfile):
                continue

            f = open(statusfile, "r")
            status = f.read().strip()
            f.close()

            bypath = deviceNameToDiskByPath(device)
            if not bypath:
                bypath = "/dev/" + device

            if status in ["unformatted"] and device not in exclusiveDisks:
                log.info("    %s (%s) status is %s, needs dasdfmt" % (
                    device,
                    bypath,
                    status,
                ))
                self._dasdlist.append((device, bypath))

            elif isys.isLdlDasd(device):
                log.info("     %s (%s) is an LDL DASD, needs dasdfmt" %
                         (device, bypath))
                self._ldldasdlist.append((device, bypath))

        if not intf and (not zeroMbr or not cdl):
            log.info("    non-interactive kickstart install without zerombr "
                     "or clearpart --cdl "
                     "command, unable to run dasdfmt, exiting installer")
            sys.exit(0)

        # now onto formatting our DASDs
        if not len(self._dasdlist):
            log.info("    no unformatted DASD devices found")
        else:
            self.format_dasds(intf, not zeroMbr, self._dasdlist)

        if not len(self._ldldasdlist):
            log.info("    no LDL DASD devices found")
        else:
            self.format_dasds(intf, not cdl, self._ldldasdlist)
示例#2
0
    import dispatch
    import warnings
    import vnc
    import users
    import kickstart
    import storage.storage_log
    from flags import flags

    # the following makes me very sad. -- katzj
    # we have a slightly different set of udev rules in the second
    # stage than the first stage.  why this doesn't get picked up
    # automatically, I don't know.  but we need to trigger so that we
    # have all the information about netdevs that we care about for
    # NetworkManager in the udev database
    from baseudev import udev_trigger, udev_settle
    udev_trigger("net")
    udev_trigger("block")  # trigger the block subsys too while at it
    udev_settle()
    # and for added fun, once doesn't seem to be enough?  so we
    # do it twice, it works and we scream at the world "OH WHY?"
    udev_trigger("net")
    udev_settle()

    import gettext
    _ = lambda x: gettext.ldgettext("anaconda", x)

    import platform
    anaconda.platform = platform.getPlatform(anaconda)

    if not iutil.isS390() and os.access("/dev/tty3", os.W_OK):
        anaconda_log.logger.addFileHandler("/dev/tty3", log)
示例#3
0
    import dispatch
    import warnings
    import vnc
    import users
    import kickstart
    import storage.storage_log
    from flags import flags

    # the following makes me very sad. -- katzj
    # we have a slightly different set of udev rules in the second 
    # stage than the first stage.  why this doesn't get picked up
    # automatically, I don't know.  but we need to trigger so that we
    # have all the information about netdevs that we care about for 
    # NetworkManager in the udev database
    from baseudev import udev_trigger, udev_settle
    udev_trigger("net")
    udev_trigger("block") # trigger the block subsys too while at it
    udev_settle()
    # and for added fun, once doesn't seem to be enough?  so we 
    # do it twice, it works and we scream at the world "OH WHY?"
    udev_trigger("net")
    udev_settle()

    import gettext
    _ = lambda x: gettext.ldgettext("anaconda", x)

    import platform
    anaconda.platform = platform.getPlatform(anaconda)

    if not iutil.isS390() and os.access("/dev/tty3", os.W_OK):
        anaconda_log.logger.addFileHandler ("/dev/tty3", log)
    def startup(self, intf, exclusiveDisks, zeroMbr):
        """ Look for any unformatted DASDs in the system and offer the user
            the option for format them with dasdfmt or exit the installer.
        """
        if self.started:
            return

        self.started = True
        out = "/dev/tty5"
        err = "/dev/tty5"

        if not iutil.isS390():
            return

        # Trigger udev data about the dasd devices on the system
        udev_trigger(action="change", name="dasd*")

        log.info("Checking for unformatted DASD devices:")

        for device in os.listdir("/sys/block"):
            if not device.startswith("dasd"):
                continue

            statusfile = "/sys/block/%s/device/status" % (device, )
            if not os.path.isfile(statusfile):
                continue

            f = open(statusfile, "r")
            status = f.read().strip()
            f.close()

            if status in ["unformatted"] and device not in exclusiveDisks:
                bypath = deviceNameToDiskByPath(device)
                if not bypath:
                    bypath = "/dev/" + device

                log.info("    %s (%s) status is %s, needs dasdfmt" % (
                    device,
                    bypath,
                    status,
                ))
                self._dasdlist.append((device, bypath))

        if not len(self._dasdlist):
            log.info("    no unformatted DASD devices found")
            return

        askUser = True

        if zeroMbr:
            askUser = False
        elif not intf and not zeroMbr:
            log.info("    non-interactive kickstart install without zerombr "
                     "command, unable to run dasdfmt, exiting installer")
            sys.exit(0)

        c = len(self._dasdlist)

        if intf and askUser:
            devs = ''
            for dasd, bypath in self._dasdlist:
                devs += "%s\n" % (bypath, )

            rc = intf.questionInitializeDASD(c, devs)
            if rc == 1:
                log.info("    not running dasdfmt, continuing installation")
                return

        # gather total cylinder count
        argv = ["-t", "-v"] + self.commonArgv
        for dasd, bypath in self._dasdlist:
            buf = iutil.execWithCapture(self.dasdfmt,
                                        argv + ["/dev/" + dasd],
                                        stderr=err)
            for line in buf.splitlines():
                if line.startswith("Drive Geometry: "):
                    # line will look like this:
                    # Drive Geometry: 3339 Cylinders * 15 Heads =  50085 Tracks
                    cyls = long(filter(lambda s: s, line.split(' '))[2])
                    self.totalCylinders += cyls
                    break

        # format DASDs
        argv = ["-P"] + self.commonArgv
        update = self._updateProgressWindow

        title = P_("Formatting DASD Device", "Formatting DASD Devices", c)
        msg = P_("Preparing %d DASD device for use with Linux..." % c,
                 "Preparing %d DASD devices for use with Linux..." % c, c)

        if intf:
            if self.totalCylinders:
                pw = intf.progressWindow(title, msg, 1.0)
            else:
                pw = intf.progressWindow(title, msg, 100, pulse=True)

        for dasd, bypath in self._dasdlist:
            log.info("Running dasdfmt on %s" % (bypath, ))
            arglist = argv + ["/dev/" + dasd]

            try:
                if intf and self.totalCylinders:
                    rc = iutil.execWithCallback(self.dasdfmt,
                                                arglist,
                                                stdout=out,
                                                stderr=err,
                                                callback=update,
                                                callback_data=pw,
                                                echo=False)
                elif intf:
                    rc = iutil.execWithPulseProgress(self.dasdfmt,
                                                     arglist,
                                                     stdout=out,
                                                     stderr=err,
                                                     progress=pw)
                else:
                    rc = iutil.execWithRedirect(self.dasdfmt,
                                                arglist,
                                                stdout=out,
                                                stderr=err)
            except Exception as e:
                raise DasdFormatError(e, bypath)

            if rc:
                raise DasdFormatError("dasdfmt failed: %s" % rc, bypath)

        if intf:
            pw.pop()
示例#5
0
文件: dasd.py 项目: 274914765/python
    def startup(self, intf, exclusiveDisks, zeroMbr):
        """ Look for any unformatted DASDs in the system and offer the user
            the option for format them with dasdfmt or exit the installer.
        """
        if self.started:
            return

        self.started = True
        out = "/dev/tty5"
        err = "/dev/tty5"

        if not iutil.isS390():
            return

        # Trigger udev data about the dasd devices on the system
        udev_trigger(action="change", name="dasd*")

        log.info("Checking for unformatted DASD devices:")

        for device in os.listdir("/sys/block"):
            if not device.startswith("dasd"):
                continue

            statusfile = "/sys/block/%s/device/status" % (device,)
            if not os.path.isfile(statusfile):
                continue

            f = open(statusfile, "r")
            status = f.read().strip()
            f.close()

            if status in ["unformatted"] and device not in exclusiveDisks:
                bypath = deviceNameToDiskByPath(device)
                if not bypath:
                    bypath = "/dev/" + device

                log.info("    %s (%s) status is %s, needs dasdfmt" % (device,
                                                                      bypath,
                                                                      status,))
                self._dasdlist.append((device, bypath))

        if not len(self._dasdlist):
            log.info("    no unformatted DASD devices found")
            return

        askUser = True

        if zeroMbr:
            askUser = False
        elif not intf and not zeroMbr:
            log.info("    non-interactive kickstart install without zerombr "
                     "command, unable to run dasdfmt, exiting installer")
            sys.exit(0)

        c = len(self._dasdlist)

        if intf and askUser:
            devs = ''
            for dasd, bypath in self._dasdlist:
                devs += "%s\n" % (bypath,)

            rc = intf.questionInitializeDASD(c, devs)
            if rc == 1:
                log.info("    not running dasdfmt, continuing installation")
                return

        # gather total cylinder count
        argv = ["-t", "-v"] + self.commonArgv
        for dasd, bypath in self._dasdlist:
            buf = iutil.execWithCapture(self.dasdfmt, argv + ["/dev/" + dasd],
                                        stderr=err)
            for line in buf.splitlines():
                if line.startswith("Drive Geometry: "):
                    # line will look like this:
                    # Drive Geometry: 3339 Cylinders * 15 Heads =  50085 Tracks
                    cyls = long(filter(lambda s: s, line.split(' '))[2])
                    self.totalCylinders += cyls
                    break

        # format DASDs
        argv = ["-P"] + self.commonArgv
        update = self._updateProgressWindow

        title = P_("Formatting DASD Device", "Formatting DASD Devices", c)
        msg = P_("Preparing %d DASD device for use with Linux..." % c,
                 "Preparing %d DASD devices for use with Linux..." % c, c)

        if intf:
            if self.totalCylinders:
                pw = intf.progressWindow(title, msg, 1.0)
            else:
                pw = intf.progressWindow(title, msg, 100, pulse=True)

        for dasd, bypath in self._dasdlist:
            log.info("Running dasdfmt on %s" % (bypath,))
            arglist = argv + ["/dev/" + dasd]

            try:
                if intf and self.totalCylinders:
                    rc = iutil.execWithCallback(self.dasdfmt, arglist,
                                                stdout=out, stderr=err,
                                                callback=update,
                                                callback_data=pw,
                                                echo=False)
                elif intf:
                    rc = iutil.execWithPulseProgress(self.dasdfmt, arglist,
                                                     stdout=out, stderr=err,
                                                     progress=pw)
                else:
                    rc = iutil.execWithRedirect(self.dasdfmt, arglist,
                                                stdout=out, stderr=err)
            except Exception as e:
                raise DasdFormatError(e, bypath)

            if rc:
                raise DasdFormatError("dasdfmt failed: %s" % rc, bypath)

        if intf:
            pw.pop()