Пример #1
0
    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()
Пример #2
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)
Пример #3
0
    def startup(self, *args, **kwargs):
        """ 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

        if not iutil.isS390():
            return

        intf = kwargs.get("intf")
        zeroMbr = kwargs.get("zeroMbr")

        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 == "unformatted":
                log.info("    %s is an unformatted DASD" % (device,))
                self._dasdlist.append(device)

        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)

        tmplist = map(lambda s: "/dev/" + s, self._dasdlist)
        self._dasdlist = map(lambda s: deviceNameToDiskByPath(s), tmplist)
        c = len(self._dasdlist)

        if intf and askUser:
            title = P_("Unformatted DASD Device Found",
                       "Unformatted DASD Devices Found", c)
            msg = P_("Format uninitialized DASD device?\n\n"
                     "There is %d uninitialized DASD device on this "
                     "system.  To continue installation, the device must "
                     "be formatted.  Formatting will remove any data on "
                     "this device." % c,
                     "Format uninitialized DASD devices?\n\n"
                     "There are %d uninitialized DASD devices on this "
                     "system.  To continue installation, the devices must "
                     "be formatted.  Formatting will remove any data on "
                     "these devices." % c,
                     c)

            devs = ''
            for dasd in self._dasdlist:
                devs += "%s\n" % (dasd,)

            icon = "/usr/share/icons/gnome/32x32/status/dialog-error.png"
            buttons = [_("_Format"), _("_Exit installer")]
            rc = intf.detailedMessageWindow(title, msg, devs.strip(),
                                                 type="custom",
                                                 custom_icon=icon,
                                                 custom_buttons=buttons)
            if rc == 1:
                log.info("    not running dasdfmt, exiting installer")
                sys.exit(0)

        argv = ["-y", "-P", "-d", "cdl", "-b", "4096"]

        if intf:
            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)
            pw = intf.progressWindow(title, msg, 1.0)

            for dasd in self._dasdlist:
                log.info("Running dasdfmt on %s" % (dasd,))
                iutil.execWithCallback("/sbin/dasdfmt", argv + [dasd],
                                       stdout="/dev/tty5", stderr="/dev/tty5",
                                       callback=self._updateProgressWindow,
                                       callback_data=pw, echo=False)

            pw.pop()
        else:
            for dasd in self._dasdlist:
                log.info("Running dasdfmt on %s" % (dasd,))
                iutil.execWithRedirect("/sbin/dasdfmt", argv + [dasd],
                                       stdout="/dev/tty5", stderr="/dev/tty5")
    def getScreen (self, anaconda):
        # We can't just use exclusiveDisks here because of kickstart.  First,
        # the kickstart file could have used ignoredisk --drives= in which case
        # exclusiveDisks would be empty.  Second, ignoredisk is entirely
        # optional in which case neither list would be populated.  Luckily,
        # storage.disks takes isIgnored into account and that handles both these
        # issues.
        disks = filter(lambda d: not d.format.hidden, anaconda.id.storage.disks)

        # Skip this screen as well if there's only one disk to use.
        if len(disks) == 1:
            anaconda.id.storage.clearPartDisks = [disks[0].name]
            anaconda.id.bootloader.drivelist = [disks[0].name]
            return None

        (xml, self.vbox) = gui.getGladeWidget("cleardisks.glade", "vbox")
        self.leftScroll = xml.get_widget("leftScroll")
        self.rightScroll = xml.get_widget("rightScroll")
        self.addButton = xml.get_widget("addButton")
        self.removeButton = xml.get_widget("removeButton")
        self.installTargetImage = xml.get_widget("installTargetImage")
        self.installTargetTip = xml.get_widget("installTargetTip")

        self.anaconda = anaconda

        self.leftVisible = 1
        self.leftActive = 2
        self.rightVisible = 4
        self.rightActive = 5

        # One store for both views.  First the obejct, then a visible/active for
        # the left hand side, then a visible/active for the right hand side, then
        # all the other stuff.
        #
        # NOTE: the third boolean is a placeholder.  DeviceSelector uses the third
        # slot in the store to determine whether the row is immutable or not.  We
        # just need to put False in there for everything.
        self.store = gtk.TreeStore(gobject.TYPE_PYOBJECT,
                                   gobject.TYPE_BOOLEAN, gobject.TYPE_BOOLEAN,
                                   gobject.TYPE_BOOLEAN,
                                   gobject.TYPE_BOOLEAN, gobject.TYPE_BOOLEAN,
                                   gobject.TYPE_STRING, gobject.TYPE_STRING,
                                   gobject.TYPE_STRING, gobject.TYPE_STRING,
                                   gobject.TYPE_STRING)
        self.store.set_sort_column_id(6, gtk.SORT_ASCENDING)

        # The left view shows all the drives that will just be mounted, but
        # can still be moved to the right hand side.
        self.leftFilteredModel = self.store.filter_new()
        self.leftSortedModel = gtk.TreeModelSort(self.leftFilteredModel)
        self.leftTreeView = gtk.TreeView(self.leftSortedModel)

        self.leftFilteredModel.set_visible_func(lambda model, iter, view: model.get_value(iter, self.leftVisible), self.leftTreeView)

        self.leftScroll.add(self.leftTreeView)

        self.leftDS = DeviceSelector(self.store, self.leftSortedModel,
                                     self.leftTreeView, visible=self.leftVisible,
                                     active=self.leftActive)
        self.leftDS.createMenu()
        self.leftDS.addColumn(_("Model"), 6)
        self.leftDS.addColumn(_("Capacity"), 7)
        self.leftDS.addColumn(_("Vendor"), 8)
        self.leftDS.addColumn(_("Identifier"), 9)
        self.leftDS.addColumn(_("Interconnect"), 10, displayed=False)

        # The right view show all the drives that will be wiped during install.
        self.rightFilteredModel = self.store.filter_new()
        self.rightSortedModel = gtk.TreeModelSort(self.rightFilteredModel)
        self.rightTreeView = gtk.TreeView(self.rightSortedModel)

        self.rightFilteredModel.set_visible_func(lambda model, iter, view: model.get_value(iter, self.rightVisible), self.rightTreeView)

        self.rightScroll.add(self.rightTreeView)

        self.rightDS = DeviceSelector(self.store, self.rightSortedModel,
                                      self.rightTreeView, visible=self.rightVisible,
                                      active=self.rightActive)
        self.rightDS.createSelectionCol(title=_("Boot\nLoader"), radioButton=True)
        self.rightDS.createMenu()
        self.rightDS.addColumn(_("Model"), 6)
        self.rightDS.addColumn(_("Capacity"), 7)
        self.rightDS.addColumn(_("Identifier"), 9)

        # Store the first disk (according to our detected BIOS order) for
        # auto boot device selection
        names = map(lambda d: d.name, disks)
        self.bootDisk = sorted(names, self.anaconda.id.storage.compareDisks)[0]

        # The device filtering UI set up exclusiveDisks as a list of the names
        # of all the disks we should use later on.  Now we need to go get those,
        # look up some more information in the devicetree, and set up the
        # selector.
        for d in disks:
            rightVisible = d.name in self.anaconda.id.storage.clearPartDisks
            rightActive = rightVisible and \
                          d.name in self.anaconda.id.bootloader.drivelist[:1]
            leftVisible = not rightVisible

            if hasattr(d, "wwid"):
                ident = d.wwid
            else:
                try:
                    ident = deviceNameToDiskByPath(d.name)
                    if ident.startswith("/dev/disk/by-path/"):
                        ident = ident.replace("/dev/disk/by-path/", "")
                except DeviceNotFoundError:
                    ident = d.name

            self.store.append(None, (d,
                                     leftVisible, True, False,
                                     rightVisible, rightActive,
                                     d.model,
                                     str(int(d.size)) + " MB",
                                     d.vendor, ident, d.bus))

        self.addButton.connect("clicked", self._add_clicked)
        self.removeButton.connect("clicked", self._remove_clicked)

        # Also allow moving devices back and forth with double click, enter, etc.
        self.leftTreeView.connect("row-activated", self._add_clicked)
        self.rightTreeView.connect("row-activated", self._remove_clicked)

        # And let the user select multiple devices at a time.
        self.leftTreeView.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
        self.rightTreeView.get_selection().set_mode(gtk.SELECTION_MULTIPLE)

        if self.anaconda.id.storage.clearPartType == CLEARPART_TYPE_LINUX:
            self.installTargetTip.set_markup(_("<b>Tip:</b> All Linux filesystems on install target devices will be reformatted and wiped of any data.  Make sure you have backups."))
        elif self.anaconda.id.storage.clearPartType == CLEARPART_TYPE_ALL:
            self.installTargetTip.set_markup(_("<b>Tip:</b> Install target devices will be reformatted and wiped of any data.  Make sure you have backups."))
        else:
            self.installTargetTip.set_markup(_("<b>Tip:</b> Your filesystems on install target devices will not be wiped unless you choose to do so during customization."))

        return self.vbox
Пример #5
0
    def getScreen (self, anaconda):
        # We can't just use exclusiveDisks here because of kickstart.  First,
        # the kickstart file could have used ignoredisk --drives= in which case
        # exclusiveDisks would be empty.  Second, ignoredisk is entirely
        # optional in which case neither list would be populated.  Luckily,
        # storage.disks takes isIgnored into account and that handles both these
        # issues.
        disks = filter(lambda d: not d.format.hidden, anaconda.id.storage.disks)

        # Skip this screen as well if there's only one disk to use.
        if len(disks) == 1:
            anaconda.id.storage.clearPartDisks = [disks[0].name]
            anaconda.id.bootloader.drivelist = [disks[0].name]
            return None

        (xml, self.vbox) = gui.getGladeWidget("cleardisks.glade", "vbox")
        self.leftScroll = xml.get_widget("leftScroll")
        self.rightScroll = xml.get_widget("rightScroll")
        ############################
        
        self.leftScroll.set_size_request(500,300)
        self.rightScroll.set_size_request(300,300)
        ###########################
        self.addButton = xml.get_widget("addButton")
        self.removeButton = xml.get_widget("removeButton")
        self.installTargetImage = xml.get_widget("installTargetImage")
        self.installTargetTip = xml.get_widget("installTargetTip")

        self.anaconda = anaconda

        self.leftVisible = 1
        self.leftActive = 2
        self.rightVisible = 4
        self.rightActive = 5
        self.delete_col = 6
        
        # One store for both views.  First the obejct, then a visible/active for
        # the left hand side, then a visible/active for the right hand side, then
        # all the other stuff.
        #
        # NOTE: the third boolean is a placeholder.  DeviceSelector uses the third
        # slot in the store to determine whether the row is immutable or not.  We
        # just need to put False in there for everything.
        self.store = gtk.TreeStore(gobject.TYPE_PYOBJECT,
                                   gobject.TYPE_BOOLEAN, gobject.TYPE_BOOLEAN,
                                   gobject.TYPE_BOOLEAN,
                                   gobject.TYPE_BOOLEAN, gobject.TYPE_BOOLEAN,
                                   gobject.TYPE_BOOLEAN,
                                   gobject.TYPE_STRING, gobject.TYPE_STRING,
                                   gobject.TYPE_STRING, gobject.TYPE_STRING,
                                   gobject.TYPE_STRING)
        self.store.set_sort_column_id(7, gtk.SORT_ASCENDING)

        # The left view shows all the drives that will just be mounted, but
        # can still be moved to the right hand side.
        self.leftFilteredModel = self.store.filter_new()
        self.leftSortedModel = gtk.TreeModelSort(self.leftFilteredModel)
        self.leftTreeView = gtk.TreeView(self.leftSortedModel)

        self.leftFilteredModel.set_visible_func(lambda model, iter, view: model.get_value(iter, self.leftVisible), self.leftTreeView)

        self.leftScroll.add(self.leftTreeView)

        self.leftDS = DeviceSelector(self.store, self.leftSortedModel,
                                     self.leftTreeView, visible=self.leftVisible,
                                     active=self.leftActive,delete_col=self.delete_col)
        self.leftDS.createSelectionCol_2(title=_("格式化"), radioButton=True)
        self.leftDS.createMenu()
        xxx = 7
        self.leftDS.addColumn(_("Model"), xxx)
        self.leftDS.addColumn(_("Capacity"), xxx+1)
        self.leftDS.addColumn(_("Vendor"), xxx+2)
        self.leftDS.addColumn(_("Identifier"), xxx+3)
        self.leftDS.addColumn(_("Interconnect"), xxx+4, displayed=False)

        # The right view show all the drives that will be wiped during install.
        self.rightFilteredModel = self.store.filter_new()
        self.rightSortedModel = gtk.TreeModelSort(self.rightFilteredModel)
        self.rightTreeView = gtk.TreeView(self.rightSortedModel)

        self.rightFilteredModel.set_visible_func(lambda model, iter, view: model.get_value(iter, self.rightVisible), self.rightTreeView)

        self.rightScroll.add(self.rightTreeView)

        self.rightDS = DeviceSelector(self.store, self.rightSortedModel,
                                      self.rightTreeView, visible=self.rightVisible,
                                      active=self.rightActive)
        self.rightDS.createSelectionCol(title=_("Boot\nLoader"), radioButton=True)
        self.rightDS.createMenu()
        yyy = 7
        self.rightDS.addColumn(_("Model"), yyy)
        self.rightDS.addColumn(_("Capacity"), yyy+1)
        self.rightDS.addColumn(_("Identifier"), yyy+3)

        # Store the first disk (according to our detected BIOS order) for
        # auto boot device selection
        names = map(lambda d: d.name, disks)
        self.bootDisk = sorted(names, self.anaconda.id.storage.compareDisks)[0]

        # The device filtering UI set up exclusiveDisks as a list of the names
        # of all the disks we should use later on.  Now we need to go get those,
        # look up some more information in the devicetree, and set up the
        # selector.
        for d in disks:
            rightVisible = d.name in self.anaconda.id.storage.clearPartDisks
            rightActive = rightVisible and \
                          d.name in self.anaconda.id.bootloader.drivelist[:1]
            leftVisible = not rightVisible
            
            deletexxx = d.name in self.anaconda.id.storage.destroyDisks
            
            if hasattr(d, "wwid"):
                ident = d.wwid
            else:
                try:
                    ident = deviceNameToDiskByPath(d.name)
                    if ident.startswith("/dev/disk/by-path/"):
                        ident = ident.replace("/dev/disk/by-path/", "")
                except DeviceNotFoundError:
                    ident = d.name

            self.store.append(None, (d,
                                     leftVisible, True, False,
                                     rightVisible, rightActive,
                                     deletexxx,
                                     d.model,
                                     str(int(d.size)) + " MB",
                                     d.vendor, ident, d.bus))

        self.addButton.connect("clicked", self._add_clicked)
        self.removeButton.connect("clicked", self._remove_clicked)

        # Also allow moving devices back and forth with double click, enter, etc.
        self.leftTreeView.connect("row-activated", self._add_clicked)
        self.rightTreeView.connect("row-activated", self._remove_clicked)

        # And let the user select multiple devices at a time.
        self.leftTreeView.get_selection().set_mode(gtk.SELECTION_MULTIPLE)
        self.rightTreeView.get_selection().set_mode(gtk.SELECTION_MULTIPLE)

        if self.anaconda.id.storage.clearPartType == CLEARPART_TYPE_LINUX:
            self.installTargetTip.set_markup(_("<b>Tip:</b> All Linux filesystems on install target devices will be reformatted and wiped of any data.  Make sure you have backups."))
        elif self.anaconda.id.storage.clearPartType == CLEARPART_TYPE_ALL:
            self.installTargetTip.set_markup(_("<b>Tip:</b> Install target devices will be reformatted and wiped of any data.  Make sure you have backups."))
        else:
            self.installTargetTip.set_markup(_("<b>Tip:</b> Your filesystems on install target devices will not be wiped unless you choose to do so during customization."))

        """return self.vbox"""
        #####################################################
        
        isBlack = False
        '''
        f = open("/root/isotype")
        lines = f.readlines()
        f.close()
    
        for x in lines:
            if x.find("vServer") != -1 or x.find("vCenter") != -1:
                isBlack = True
                break
        '''
        import fvi 
        x = fvi.get_iso_type()
        if x.find("vServer") != -1 or x.find("vCenter") != -1:
            isBlack = True
                
        if isBlack:
            bgcolor = "#333333"
            fontcolor = "#e6e6e6"
        else:
            bgcolor = "#cccccc"
            fontcolor = "#333333"
        
        eboximage = gtk.EventBox()
        eboximage.set_app_paintable(True) 
        eboximage.modify_bg(gtk.STATE_NORMAL,gtk.gdk.color_parse(bgcolor))
        eboximage.set_size_request(1024,100)
        
        fixed = gtk.Fixed()
        i = gtk.Image()
        path = "/usr/share/anaconda/pixmaps/icon4_storage_select.png"
        i.set_from_file(path)
        i.show()
        fixed.put(i,45,15)
        label1 = gtk.Label()
        lstr = "<span font_desc=' 16' weight='bold' foreground='"+fontcolor+"'><b>存储设备:</b></span>"
        label1.set_markup(lstr)
        fixed.put(label1,160,23)
        label2 = gtk.Label()
        lstr = "<span font_desc=' 11.5' weight='bold' foreground='"+fontcolor+"'><b>选择操作系统安装位置</b></span>"
        label2.set_markup(lstr)
        fixed.put(label2,160,58)
        eboximage.add(fixed) 
        eboximage.show_all()
        
        vbox = gtk.VBox(False,0)
        vbox.pack_start(eboximage,False,False,0)
        #####################################################
        
        tmphbox = gtk.HBox(False,0)
        tmphbox.pack_start(self.vbox,True,True,0)
        
        fix = gtk.Fixed()
        fix.put(tmphbox,35,35)
        #fix.set_size_request(900,400)
        vbox.pack_start(fix,True,True,0)
        
        l = xml.get_widget("label1")
        text = "下面是您选择用于这个安装的存储设备。请使用下面的箭头指定您要用做数据驱动器的设备(这些设备不会被格式化,只被挂载)以及用做系统驱动器的设备(这些设备将被格式化)。还请指定在哪个系统驱动器中安装引导装载程序。"
        lstr = "<span foreground='#333333'><b>"+text+"</b></span>"
        l.set_markup(lstr)
        l = xml.get_widget("label4")
        lstr = "<span foreground='#333333'><b>"+l.get_text()+"</b></span>"
        l.set_markup(lstr)
        l = xml.get_widget("label5")
        lstr = "<span foreground='#333333'><b>"+l.get_text()+"</b></span>"
        l.set_markup(lstr)
        
        return vbox
Пример #6
0
    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()
Пример #7
0
    def startup(self, *args, **kwargs):
        """ 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

        if not iutil.isS390():
            return

        intf = kwargs.get("intf")
        zeroMbr = kwargs.get("zeroMbr")

        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 == "unformatted":
                log.info("    %s is an unformatted DASD" % (device, ))
                self._dasdlist.append(device)

        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)

        tmplist = map(lambda s: "/dev/" + s, self._dasdlist)
        self._dasdlist = map(lambda s: deviceNameToDiskByPath(s), tmplist)
        c = len(self._dasdlist)

        if intf and askUser:
            title = P_("Unformatted DASD Device Found",
                       "Unformatted DASD Devices Found", c)
            msg = P_(
                "Format uninitialized DASD device?\n\n"
                "There is %d uninitialized DASD device on this "
                "system.  To continue installation, the device must "
                "be formatted.  Formatting will remove any data on "
                "this device." % c, "Format uninitialized DASD devices?\n\n"
                "There are %d uninitialized DASD devices on this "
                "system.  To continue installation, the devices must "
                "be formatted.  Formatting will remove any data on "
                "these devices." % c, c)

            devs = ''
            for dasd in self._dasdlist:
                devs += "%s\n" % (dasd, )

            icon = "/usr/share/icons/gnome/32x32/status/dialog-error.png"
            buttons = [_("_Format"), _("_Exit installer")]
            rc = intf.detailedMessageWindow(title,
                                            msg,
                                            devs.strip(),
                                            type="custom",
                                            custom_icon=icon,
                                            custom_buttons=buttons)
            if rc == 1:
                log.info("    not running dasdfmt, exiting installer")
                sys.exit(0)

        argv = ["-y", "-P", "-d", "cdl", "-b", "4096"]

        if intf:
            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)
            pw = intf.progressWindow(title, msg, 1.0)

            for dasd in self._dasdlist:
                log.info("Running dasdfmt on %s" % (dasd, ))
                iutil.execWithCallback("/sbin/dasdfmt",
                                       argv + [dasd],
                                       stdout="/dev/tty5",
                                       stderr="/dev/tty5",
                                       callback=self._updateProgressWindow,
                                       callback_data=pw,
                                       echo=False)

            pw.pop()
        else:
            for dasd in self._dasdlist:
                log.info("Running dasdfmt on %s" % (dasd, ))
                iutil.execWithRedirect("/sbin/dasdfmt",
                                       argv + [dasd],
                                       stdout="/dev/tty5",
                                       stderr="/dev/tty5")