def loadPlugins(self, app): if not os.path.exists(self.plugindir): return if self.plugindir not in sys.path: sys.path.append(self.plugindir) info = _("insert-ethers loading plugins: ") modlist = os.listdir(self.plugindir + '/insertethers') modlist.sort() for f in modlist: modname, ext = os.path.splitext(f) if modname == '__init__' or ext != '.py': continue info += "%s " % modname mods = __import__('insertethers.%s' % modname) m = getattr(mods, modname) try: plugin_class = getattr(m, 'Plugin') if not issubclass(plugin_class, rocks.sql.InsertEthersPlugin): raise Exception, 'Invalid class' # Instantiate plugin p = plugin_class(app) self.plugins.append(p) except: info += _("(invalid, skipping) ") syslog(info)
def clickCB(self, row, data): model = self.lvmlist.get_model() pvlist = self.getSelectedPhysicalVolumes(model) # get the selected row iter = model.get_iter((string.atoi(data),)) # we invert val because we get called before checklist # changes the toggle state val = not model.get_value(iter, 0) partname = model.get_value(iter, 1) id = self.partitions.getRequestByDeviceName(partname).uniqueID if val: pvlist.append(id) else: pvlist.remove(id) (availSpaceMB, neededSpaceMB, fspace) = self.computeSpaceValues(alt_pvlist=pvlist) if availSpaceMB < neededSpaceMB: self.intf.messageWindow(_("Not enough space"), _("You cannot remove this physical " "volume because otherwise the " "volume group will be too small to " "hold the currently defined logical " "volumes."), custom_icon="error") return False self.updateVGSpaceLabels(alt_pvlist = pvlist) return True
def sanityCheckMountPoint(mntpt, fstype, preexisting): """Sanity check that the mountpoint is valid. mntpt is the mountpoint being used. fstype is the file system being used on the request. preexisting is whether the request was preexisting (request.preexist) """ if mntpt: passed = 1 if not mntpt: passed = 0 else: if mntpt[0] != '/' or (len(mntpt) > 1 and mntpt[-1:] == '/'): passed = 0 elif mntpt.find(' ') > -1: passed = 0 if not passed: return _("The mount point is invalid. Mount points must start " "with '/' and cannot end with '/', and must contain " "printable characters and no spaces.") else: return None else: if (fstype and fstype.isMountable() and not preexisting): return _("Please specify a mount point for this partition.") else: # its an existing partition so don't force a mount point return None
def dehydrate(self): widget = None # test if empty empty = 1 for e in ['entry1', 'entry2', 'entry3', 'entry4']: if len(string.strip(self.entrys[e].get_text())) > 0: empty = 0 break if empty: raise IPMissing, (_("IP Address is missing"), widget) try: widget = self.entrys['entry1'] if int(widget.get_text()) > 255 or int(widget.get_text()) <= 0: raise IPError, ( _("IP Addresses must contain numbers between 1 and 255"), widget) for ent in ['entry2', 'entry3', 'entry4']: widget = self.entrys[ent] if int(widget.get_text()) > 255: raise IPError, (_( "IP Addresses must contain numbers between 0 and 255"), widget) except ValueError, msg: raise IPError, ( _("IP Addresses must contain numbers between 0 and 255"), widget)
def reIPL(anaconda, loader_pid): instruction = _( "After shutdown, please perform a manual IPL from the device " "now containing /boot to continue installation" ) reipl_path = "/sys/firmware/reipl" iplfs = anaconda.id.fsset.getEntryByMountPoint("/boot") if iplfs is None: iplfs = anaconda.id.fsset.getEntryByMountPoint("/") if iplfs is None: message = _("Could not get information for mount point /boot or /") log.warning(message) return (message, instruction) try: ipldev = iplfs.device.device except: ipldev = None if ipldev is None: message = _("Error determining mount point type") log.warning(message) return (message, instruction) message = (_("The mount point /boot or / is on a disk that we are not familiar with"), instruction) if ipldev.startswith("dasd"): message = reIPLonCCW(ipldev, reipl_path) elif ipldev.startswith("sd"): message = reIPLonFCP(ipldev, reipl_path) # the final return is either None if reipl configuration worked (=> reboot), # or a two-item list with errorMessage and rebootInstr (=> shutdown) return message
def listenKs(self, line): """Look in log line for a kickstart request.""" # Track accesses both with and without local certs. interesting = line.count('install/sbin/public/kickstart.cgi') \ or line.count('install/sbin/kickstart.cgi') \ or line.count('install/sbin/public/jumpstart.cgi') if not interesting: return fields = line.split() try: status = int(fields[8]) except: raise InsertError, _("Apache log file not well formed!") nodeid = int(self.sql.getNodeId(fields[0])) self.sql.execute('select name from nodes where id=%d' % nodeid) try: name, = self.sql.fetchone() except: if status == 200: raise InsertError, \ _("Unknown node %s got a kickstart file!") \ % fields[0] return if name not in self.kickstarted: return self.kickstarted[name] = status self.statusGUI()
def getScreen(self, anaconda): self.anaconda = anaconda return ConfirmWindow.getScreen(self, _("Click next to begin upgrade of %s.") % (productName,), _("A complete log of the upgrade can be found in " "the file '%s' after rebooting your system.") % (u'/root/upgrade.log',))
def __call__(self, screen, textInterface, instLanguage): languages = instLanguage.available() current = instLanguage.getCurrent() height = min((8, len(languages))) buttons = [TEXT_OK_BUTTON, TEXT_BACK_BUTTON] translated = [] for lang in languages: translated.append(_(lang)) (button, choice) = \ ListboxChoiceWindow(screen, _("Language Selection"), _("What language would you like to use during the " "installation process?"), translated, buttons, width = 30, default = _(current), scroll = 1, height = height, help = "lang") if button == TEXT_BACK_CHECK: return INSTALL_BACK choice = languages[choice] if ((instLanguage.getFontFile(choice) == "None")): ButtonChoiceWindow(screen, "Language Unavailable", "%s display is unavailable in text mode. The " "installation will continue in English." % (choice, ), buttons=[TEXT_OK_BUTTON]) instLanguage.setRuntimeDefaults(choice) return INSTALL_OK if (flags.setupFilesystems and instLanguage.getFontFile(choice) == "bterm" and not isys.isPsudoTTY(0) and not flags.serial and not isys.isVioConsole()): # bterm to the rescue... have to shut down the screen and # create a new one, though (and do a sleep) log("starting bterm") try: screen.finish() rc = isys.startBterm() time.sleep(1) except Exception, e: log("got an exception starting bterm: %s" % (e, )) rc = 1 newscreen = SnackScreen() textInterface.setScreen(newscreen) screen = newscreen if rc == 1: ButtonChoiceWindow(screen, "Language Unavailable", "%s display is unavailable in text mode. " "The installation will continue in " "English." % (choice, ), buttons=[TEXT_OK_BUTTON]) instLanguage.setRuntimeDefaults(choice) return INSTALL_OK
def _ok(self, *args): combo = self.xml.get_widget("interfaceCombo") active = combo.get_active_iter() val = combo.get_model().get_value(active, 1) netdev = self.network.available()[val] # FIXME: need to do input validation if self.xml.get_widget("dhcpCheckbutton").get_active(): self.window.hide() w = gui.WaitWindow(_("Dynamic IP"), _("Sending request for IP information " "for %s...") %(netdev.get("device"))) ns = isys.dhcpNetDevice(netdev.get("device")) w.pop() if ns is not None: self.rc = gtk.RESPONSE_OK if ns: f = open("/etc/resolv.conf", "w") f.write("nameserver %s\n" % ns) f.close() isys.resetResolv() else: ipv4addr = self.xml.get_widget("ipv4Address").get_text() ipv4nm = self.xml.get_widget("ipv4Netmask").get_text() gateway = self.xml.get_widget("gatewayEntry").get_text() ns = self.xml.get_widget("nameserverEntry").get_text() try: network.sanityCheckIPString(ipv4addr) except network.IPMissing, msg: self._handleIPMissing(_("IP Address")) return except network.IPError, msg: self._handleIPError(_("IP Address"), msg) return
def __call__ (self, screen, anaconda): nfs_repository = anaconda.id.abiquo_rs.abiquo_nfs_repository abiquo_server_ip = anaconda.id.abiquo_rs.abiquo_rabbitmq_host toplevel = GridFormHelp (screen, "Abiquo Remote Services Configuration", "abiquo_rs", 1, 4) toplevel.add (TextboxReflowed(37, "Abiquo NFS Repository URI. " "The NFS host and path where the Abiquo VM " "Repository is located. "), 0, 0, (0, 0, 0, 1)) entry1 = Entry (20, password = 0, text = nfs_repository) nfsgrid = Grid (2, 2) nfsgrid.setField (Label (_("NFS Repository:")), 0, 0, (0, 0, 1, 0), anchorLeft = 1) nfsgrid.setField (entry1, 1, 0) toplevel.add (nfsgrid, 0, 1, (0, 0, 0, 1)) entry2 = Entry (20, password = 0, text = abiquo_server_ip) rsipgrid = Grid (2, 2) rsipgrid.setField (Label (_("Abiquo Server IP:")), 0, 0, (0, 0, 1, 0), anchorLeft = 1) rsipgrid.setField (entry1, 1, 0) toplevel.add (rsipgrid, 0, 1, (0, 0, 0, 1)) bb = ButtonBar (screen, (TEXT_OK_BUTTON, TEXT_BACK_BUTTON)) toplevel.add (bb, 0, 2, growx = 1) toplevel.setCurrent (entry1) result = toplevel.run () rc = bb.buttonPressed (result) if rc == TEXT_BACK_CHECK: screen.popWindow() return INSTALL_BACK anaconda.id.abiquo_rs.abiquo_nfs_repository = entry1.value() anaconda.id.abiquo_rs.abiquo_rabbitmq_host = entry2.value() screen.popWindow() return INSTALL_OK
def _handleIPError(self, field, errmsg): d = gtk.MessageDialog(_("Error With Data"), 0, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, _("An error occurred converting the value " "entered for \"%s\":\n%s") %(field, errmsg)) d.run() d.destroy()
def _handleIPMissing(self, field): d = gtk.MessageDialog(_("Error With Data"), 0, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, _("A value is required for the field %s.") % (field,)) d.run() d.destroy()
def printRetrieveHash(amount, total, speed = 0, secs = 0): cfg = config.initUp2dateConfig() hashesTotal = 26 if total: percent = int(100 * (float(amount) / total)) hashesNeeded = int(hashesTotal * (float(amount) / total)) else: percent = 100 hashesNeeded = hashesTotal if cfg["isatty"]: for i in range(hashesNeeded): sys.stdout.write('#') for i in range(hashesNeeded, hashesTotal): sys.stdout.write(' ') if cfg["isatty"]: if amount == total: print "%-25s" % _(" Done.") else: print "%4d k/sec, %02d:%02d:%02d rem." % \ (speed / 1024, secs / (60*60), (secs % 3600) / 60, secs % 60), for i in range(hashesTotal + 25): sys.stdout.write("\b") elif amount == total: print _("Retrieved.")
def findRootParts(anaconda): if anaconda.dir == DISPATCH_BACK: return if anaconda.id.rootParts is None: anaconda.id.rootParts = findExistingRoots(anaconda) anaconda.id.upgradeRoot = [] for (dev, fs, meta, label) in anaconda.id.rootParts: anaconda.id.upgradeRoot.append( (dev, fs) ) if len(anaconda.id.rootParts) == 0 and anaconda.isKickstart: log.critical("A kickstart upgrade was attempted on a system with " "no valid upgrade candidates.") message = _("Anaconda did not find any partitions that are " "valid upgrade candidates. Note that upgrades " "between major releases is not supported.") anaconda.intf.messageWindow(_("No valid upgrade partition"), message) sys.exit(0) if anaconda.id.rootParts is not None and len(anaconda.id.rootParts) > 0: anaconda.dispatch.skipStep("findinstall", skip = 0) if productName.find("Red Hat Enterprise Linux") == -1: anaconda.dispatch.skipStep("installtype", skip = 1) else: anaconda.dispatch.skipStep("findinstall", skip = 1) anaconda.dispatch.skipStep("installtype", skip = 0)
def save(self): if self.fileName == None: return # this really shouldn't happen, since it means that the # /etc/sysconfig/rhn directory doesn't exist, which is way broken # and note the attempted fix breaks useage of this by the applet # since it reuses this code to create its config file, and therefore # tries to makedirs() the users home dir again (with a specific perms) # and fails (see #130391) if not os.access(self.fileName, os.R_OK): if not os.access(os.path.dirname(self.fileName), os.R_OK): print _("%s was not found" % os.path.dirname(self.fileName)) return f = open(self.fileName, "w") os.chmod(self.fileName, 0600) f.write("# Automatically generated Red Hat Update Agent "\ "config file, do not edit.\n") f.write("# Format: 1.0\n") f.write("") for key in self.dict.keys(): val = self.dict[key] f.write("%s[comment]=%s\n" % (key, val[0])) if type(val[1]) == type([]): f.write("%s=%s;\n" % (key, string.join(map(str, val[1]), ';'))) else: f.write("%s=%s\n" % (key, val[1])) f.write("\n") f.close()
def mountRootPartition(anaconda, rootInfo, oldfsset, allowDirty = 0, warnDirty = 0, readOnly = 0): (root, rootFs) = rootInfo diskset = partedUtils.DiskSet(anaconda) encryptedDevices = anaconda.id.partitions.encryptedDevices diskset.openDevices() for cryptoDev in encryptedDevices.values(): cryptoDev.openDevice() diskset.startMPath() diskset.startDmRaid() diskset.startMdRaid() for cryptoDev in encryptedDevices.values(): cryptoDev.openDevice() lvm.vgscan() lvm.vgactivate() for cryptoDev in encryptedDevices.values(): if cryptoDev.openDevice(): log.warning("failed to open encrypted device %s" % (cryptoDev.getDevice(encrypted=True))) log.info("going to mount %s on %s as %s" %(root, anaconda.rootPath, rootFs)) isys.mount(root, anaconda.rootPath, rootFs) oldfsset.reset() newfsset = readFstab(anaconda) for entry in newfsset.entries: oldfsset.add(entry) isys.umount(anaconda.rootPath) dirtyDevs = oldfsset.hasDirtyFilesystems(anaconda.rootPath) if not allowDirty and dirtyDevs != []: lvm.vgdeactivate() diskset.stopMdRaid() diskset.stopDmRaid() diskset.stopMPath() anaconda.intf.messageWindow(_("Dirty File Systems"), _("The following file systems for your Linux system " "were not unmounted cleanly. Please boot your " "Linux installation, let the file systems be " "checked and shut down cleanly to upgrade.\n" "%s" %(getDirtyDevString(dirtyDevs),))) sys.exit(0) elif warnDirty and dirtyDevs != []: rc = anaconda.intf.messageWindow(_("Dirty File Systems"), _("The following file systems for your Linux " "system were not unmounted cleanly. Would " "you like to mount them anyway?\n" "%s" % (getDirtyDevString(dirtyDevs,))), type = "yesno") if rc == 0: return -1 if flags.setupFilesystems: oldfsset.mountFilesystems(anaconda, readOnly = readOnly) if (not oldfsset.getEntryByMountPoint("/") or not oldfsset.getEntryByMountPoint("/").fsystem or not oldfsset.getEntryByMountPoint("/").fsystem.isMountable()): raise RuntimeError, "/etc/fstab did not list a fstype for the root partition which we support"
def warning(self): rc = self.intf.messageWindow(_("Warning"), _("It is stongly recommended that you create a swap " "file. Failure to do so could cause the installer " "to abort abnormally. Are you sure that you wish " "to continue?"), type = "yesno") return rc
def FinishedWindow(): bootstr = "" buttonstr = _("Reboot") screen = SnackScreen() if rhpl.getArch() in ['s390', 's390x']: floppystr = _("Press <Enter> to end the installation process.\n\n") bottomstr = _("<Enter> to exit") if not anaconda.canReIPL: buttonstr = _("Shutdown") if not anaconda.reIPLMessage is None: floppystr = anaconda.reIPLMessage + "\n\n" + floppystr else: floppystr = ("Remove any media used during the installation " "process and press <Enter> to reboot your system." "\n\n") bottomstr = ("<Enter> to reboot") screen.pushHelpLine (string.center(bottomstr, screen.width)) txt = ("Congratulations, your %s installation is " "complete.\n\n" "%s%s") %("aaa", "bbbbbbb", "ccccccccc") foo = ("For information on errata (updates and bug fixes), visit " "http://www.redhat.com/errata/.\n\n" "Information on using your " "system is available in the %s manuals at " "http://www.redhat.com/docs/.") %("dddddddddddddd",) rc = ButtonChoiceWindow (screen, ("Complete"), txt, [ buttonstr ], help = "finished", width=60) screen.finish() #return INSTALL_OK return 1
def swapTooBig(self): rc = self.intf.messageWindow(_("Warning"), _("There is not enough space on the device you " "selected for the swap partition."), type = "okcancel") return rc
def containsImmutablePart(self, part): """Returns whether the partition contains parts we can't delete.""" if not part or (type(part) == type("RAID")) or (type(part) == type(1)): return None if not part.type & parted.PARTITION_EXTENDED: return None disk = part.disk while part: if not part.is_active(): part = disk.next_partition(part) continue device = partedUtils.get_partition_name(part) request = self.getRequestByDeviceName(device) if request: if request.getProtected(): return _("the partition in use by the installer.") if self.isRaidMember(request): return _("a partition which is a member of a RAID array.") if self.isLVMVolumeGroupMember(request): return _( "a partition which is a member of a LVM Volume Group.") part = disk.next_partition(part) return None
def sanityCheckSyncRates(self, screen, hval, vval): hgood = isValidSyncRange(hval) vgood = isValidSyncRange(vval) if not hgood: badtitle = _("horizontal") badone = hval elif not vgood: badtitle = _("vertical") badone = vval if not (hgood and vgood): ButtonChoiceWindow( screen, _("Invalid Sync Rates"), _("The %s sync rate is invalid:\n\n %s\n\n" "A valid sync rate can be of the form:\n\n" " 31.5 a single number\n" " 50.1-90.2 a range of numbers\n" "31.5,35.0,39.3-40.0 a list of numbers/ranges\n") % (badtitle, badone), buttons=[TEXT_OK_BUTTON], width=45) return 0 return 1
def isNotChangable(request, requestlist): if request: if request.getProtected(): return _("This partition is holding the data " "for the hard drive install.") if requestlist.isRaidMember(request): parentreq = requestlist.getRaidMemberParent(request) if parentreq.raidminor is not None: return _( "This partition is part of " "the RAID device /dev/md%s.") % (parentreq.raidminor, ) else: return _("This partition is part of a RAID device.") if requestlist.isLVMVolumeGroupMember(request): parentreq = requestlist.getLVMVolumeGroupMemberParent(request) if parentreq.volumeGroupName is not None: return _( "This partition is part of the " "LVM volume group '%s'.") % (parentreq.volumeGroupName, ) else: return _("This partition is part of a LVM volume group.") return None
def clickCB(self, row, data): model = self.lvmlist.get_model() pvlist = self.getSelectedPhysicalVolumes(model) # get the selected row iter = model.get_iter((string.atoi(data), )) # we invert val because we get called before checklist # changes the toggle state val = not model.get_value(iter, 0) partname = model.get_value(iter, 1) id = self.partitions.getRequestByDeviceName(partname).uniqueID if val: pvlist.append(id) else: pvlist.remove(id) (availSpaceMB, neededSpaceMB, fspace) = self.computeSpaceValues(alt_pvlist=pvlist) if availSpaceMB < neededSpaceMB: self.intf.messageWindow(_("Not enough space"), _("You cannot remove this physical " "volume because otherwise the " "volume group will be too small to " "hold the currently defined logical " "volumes."), custom_icon="error") return gtk.FALSE self.updateVGSpaceLabels(alt_pvlist=pvlist) return gtk.TRUE
def checkDasdFmt(disk, intf): if iutil.getArch() != "s390": return 0 if disk.type.name != "dasd": return 0 # FIXME: there has to be a better way to check LDL vs CDL # how do I test ldl vs cdl? if disk.max_primary_partition_count > 1: return 0 if intf: try: devs = isys.getDasdDevPort() dev = "/dev/%s (%s" %(disk.dev.path[5:], devs[device]) except Exception, e: log("exception getting dasd dev ports: %s" %(e,)) dev = "/dev/%s" %(disk.dev.path[5:],) rc = intf.messageWindow(_("Warning"), _("The device %s is LDL formatted instead of " "CDL formatted. LDL formatted DASDs are not " "supported for usage during an install of %s. " "If you wish to use this disk for installation, " "it must be re-initialized causing the loss of " "ALL DATA on this drive.\n\n" "Would you like to reformat this DASD using CDL " "format?") %(dev, productName), type = "yesno") if rc == 0: return 1 else: return -1
def addLogicalVolumeCB(self, widget): if self.numAvailableLVSlots() < 1: self.intf.messageWindow(_("No free slots"), _("You cannot create more than %s logical " "volumes per volume group.") % (lvm.MAX_LV_SLOTS, ), custom_icon="error") return (tspace, uspace, fspace) = self.computeSpaceValues() if fspace <= 0: self.intf.messageWindow(_("No free space"), _("There is no room left in the " "volume group to create new logical " "volumes. " "To add a logical volume you will need " "to reduce the size of one or more of " "the currently existing " "logical volumes"), custom_icon="error") return request = LogicalVolumeRequestSpec(fileSystemTypeGetDefault(), size=fspace) self.editLogicalVolume(request, isNew=1) return
def delLogicalVolumeCB(self, widget): iter = self.getCurrentLogicalVolume() if iter is None: return logvolname = self.logvolstore.get_value(iter, 0) if logvolname is None: return rc = self.intf.messageWindow( _("Confirm Delete"), _("Are you sure you want to Delete the " "logical volume \"%s\"?") % (logvolname, ), type="custom", custom_buttons=["gtk-cancel", _("_Delete")], custom_icon="warning") if not rc: return for lv in self.logvolreqs: if lv.logicalVolumeName == logvolname: self.logvolreqs.remove(lv) self.logvolstore.remove(iter) self.updateVGSpaceLabels() return
def _edit(self, *args): r = self.__getSelectedRepo() if r is None: d = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, _("No repository selected")) d.run() d.destroy() return path = os.path.normpath(r.repofile) if len(self.ayum.rpmdb.searchFiles(path)) > 0: d = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_WARNING, gtk.BUTTONS_OK_CANCEL, _("The %s repository is included in the " "%s package. Editing of this repository " "may result in your system not " "functioning properly. Are you sure " "you want to continue?") %(r.id , self.ayum.rpmdb.searchFiles(path)[0])) rc = d.run() d.destroy() if rc == gtk.RESPONSE_CANCEL: return return self._repoEditor(r)
def mountMedia(self, cdNum): if self.mediaIsMounted: raise SystemError, "trying to mount already-mounted iso image!" self.mountDirectory() retry = True while retry: try: isoImage = self.isoDir + '/' + self.path + '/' + self.discImages[cdNum] isys.makeDevInode("loop3", "/tmp/loop3") isys.losetup("/tmp/loop3", isoImage, readOnly = 1) isys.mount("loop3", self.tree, fstype = 'iso9660', readOnly = 1); self.mediaIsMounted = cdNum retry = False except: ans = self.messageWindow( _("Missing ISO 9660 Image"), _("The installer has tried to mount " "image #%s, but cannot find it on " "the hard drive.\n\n" "Please copy this image to the " "drive and click Retry. Click Reboot " " to abort the installation.") % (cdNum,), type="custom", custom_icon="warning", custom_buttons=[_("_Reboot"), _("Re_try")]) if ans == 0: sys.exit(0) elif ans == 1: self.discImages = findIsoImages(self.isoPath, self.messageWindow)
def readHeaderBlob(blob, filename=None): # Read two unsigned int32 #print "blob: %s" % blob #FIXME: for some reason, this fails alot # not, but with current rpm, we dont really # need it that much... # i0, i1 = struct.unpack("!2I", blob[:8]) # if len(blob) != i0 * 16 + i1 + 8: # # Corrupt header # print "ugh, the header corruption test fails:" # log.trace_me() # return None # if this header is corrupt, rpmlib exits and we stop ;-< try: hdr = rpm.headerLoad(blob) except: if filename: print _("rpm was unable to load the header: %s" % filename) else: print _("rpm was unable to load a header") return None # Header successfully read #print hdr['name'] return hdr
def __call__(self, screen, dispatch, intf, id, chroot): if id.upgradeRoot is None: return INSTALL_NOOP rc = ButtonChoiceWindow(screen, _("Customize Packages to Upgrade"), _("The packages you have installed, " "and any other packages which are " "needed to satisfy their " "dependencies, have been selected " "for installation. Would you like " "to customize the set of packages " "that will be upgraded?"), buttons=[_("Yes"), _("No"), TEXT_BACK_BUTTON], help="custupgrade") if rc == TEXT_BACK_CHECK: return INSTALL_BACK if rc == string.lower(_("No")): dispatch.skipStep("indivpackage") else: dispatch.skipStep("indivpackage", skip=0) return INSTALL_OK
def findExistingRoots(anaconda, upgradeany = 0): if not flags.setupFilesystems: relstr = partedUtils.getReleaseString (anaconda.rootPath) if ((flags.cmdline.has_key("upgradeany")) or (upgradeany == 1) or (partedUtils.productMatches(relstr, productName))): return [(anaconda.rootPath, 'ext2', "")] return [] # make ibft configured iscsi disks available anaconda.id.iscsi.startup(anaconda.intf) anaconda.id.diskset.openDevices() anaconda.id.partitions.getEncryptedDevices(anaconda.id.diskset) win = anaconda.intf.progressWindow(_("Searching"), _("Searching for %s installations...") % (productName,), 5) rootparts = anaconda.id.diskset.findExistingRootPartitions(upgradeany = upgradeany) for i in range(1, 6): time.sleep(0.25) win.set(i) win.pop() # close the devices to make sure we don't leave things sitting open anaconda.id.diskset.closeDevices() # this is a hack... need to clear the skipped disk list after this partedUtils.DiskSet.skippedDisks = [] partedUtils.DiskSet.exclusiveDisks = [] return rootparts
def turnOnFilesystems(anaconda): if anaconda.dir == DISPATCH_BACK: log.info("unmounting filesystems") anaconda.id.fsset.umountFilesystems(anaconda.rootPath) return if flags.setupFilesystems: if not anaconda.id.upgrade: anaconda.id.partitions.doMetaDeletes(anaconda.id.diskset) anaconda.id.fsset.setActive(anaconda.id.diskset) if not anaconda.id.fsset.isActive(): anaconda.id.diskset.savePartitions() anaconda.id.partitions.doEncryptionRetrofits() anaconda.id.fsset.checkBadblocks(anaconda.rootPath) if not anaconda.id.fsset.volumesCreated: try: anaconda.id.fsset.createLogicalVolumes(anaconda.rootPath) except SystemError, e: log.error("createLogicalVolumes failed with %s", str(e)) anaconda.intf.messageWindow( _("LVM operation failed"), str(e) + "\n\n" + _("The installer will now exit..."), type="custom", custom_icon="error", custom_buttons=[_("_Reboot")]) sys.exit(0) anaconda.id.fsset.formatSwap(anaconda.rootPath) anaconda.id.fsset.turnOnSwap(anaconda.rootPath) anaconda.id.fsset.makeFilesystems(anaconda.rootPath) anaconda.id.fsset.mountFilesystems(anaconda)
def __call__(self, screen, language): langs = language.getSupported() current = language.getDefault() if not langs or len(langs) <= 1: language.setDefault(current) return INSTALL_NOOP langs.sort() height = min((screen.height - 16, len(langs))) buttons = [TEXT_OK_BUTTON, TEXT_BACK_BUTTON] (button, choice) = ListboxChoiceWindow( screen, _("Default Language"), _("Choose the default language for this system: "), langs, buttons, width=30, default=current, scroll=1, height=height, help="langdefault") if (button == TEXT_BACK_CHECK): return INSTALL_BACK language.setDefault(langs[choice]) return INSTALL_OK
def doMountPointLinuxFSChecks(self): """Return an error string if the mountpoint is not valid for Linux FS.""" mustbeonroot = ('/bin','/dev','/sbin','/etc','/lib','/root', '/mnt', 'lost+found', '/proc') mustbeonlinuxfs = ('/', '/boot', '/var', '/tmp', '/usr', '/home', '/usr/share', '/usr/lib' ) # these are symlinks so you cant make them mount points otherexcept = ('/var/mail', '/usr/bin/X11', '/usr/lib/X11', '/usr/tmp') if not self.mountpoint: return None if self.fstype is None: return None if self.fstype.isMountable(): if self.mountpoint in mustbeonroot: return _("This mount point is invalid. The %s directory must " "be on the / file system.") % (self.mountpoint,) elif self.mountpoint in otherexcept: return _("The mount point %s cannot be used. It must " "be a symbolic link for proper system " "operation. Please select a different " "mount point.") % (self.mountpoint,) if not self.fstype.isLinuxNativeFS(): if self.mountpoint in mustbeonlinuxfs: return _("This mount point must be on a linux file system.") return None
def mountImage(self, cdNum): if (self.currentMedia): raise SystemError, "trying to mount already-mounted iso image!" retrymount = True while retrymount: try: isoImage = self.isoPath + '/' + self.discImages[cdNum] isys.makeDevInode("loop3", "/tmp/loop3") isys.losetup("/tmp/loop3", isoImage, readOnly = 1) isys.mount("loop3", "/tmp/isomedia", fstype = 'iso9660', readOnly = 1); self.mntPoint = "/tmp/isomedia/" self.currentMedia = [ cdNum ] retrymount = False except: ans = self.messageWindow( _("Missing ISO 9660 Image"), _("The installer has tried to mount " "image #%s, but cannot find it on " "the server.\n\n" "Please copy this image to the " "remote server's share path and " "click Retry. Click Reboot to " "abort the installation.") % (cdNum,), type="custom", custom_icon="warning", custom_buttons=[_("_Reboot"), _("Re_try")]) if ans == 0: sys.exit(0) elif ans == 1: self.discImages = findIsoImages(self.isoPath, self.messageWindow)
def doSizeSanityCheck(self): """Sanity check that the size of the partition is sane.""" if not self.fstype: return None if not self.format: return None ret = RequestSpec.doSizeSanityCheck(self) if ret is not None: return ret if (self.size and self.maxSizeMB and (self.size > self.maxSizeMB)): return (_("The size of the requested partition (size = %s MB) " "exceeds the maximum size of %s MB.") % (self.size, self.maxSizeMB)) if self.size and self.size < 0: return _("The size of the requested partition is " "negative! (size = %s MB)") % (self.size) if self.start and self.start < 1: return _("Partitions can't start below the first cylinder.") if self.end and self.end < 1: return _("Partitions can't end on a negative cylinder.") return None
def systemMounted(self, fsset, chroot): if self.tree is None: return self.loopbackFile = "%s%s%s" % (chroot, fsset.filesystemSpace(chroot)[0][0], "/rhinstall-stage2.img") try: win = self.waitWindow (_("Copying File"), _("Transferring install image to hard drive...")) shutil.copyfile("%s/images/stage2.img" % (self.tree,), self.loopbackFile) win.pop() except Exception, e: if win: win.pop() log.critical("error transferring stage2.img: %s" %(e,)) self.messageWindow(_("Error"), _("An error occurred transferring the install image " "to your hard drive. You are probably out of disk " "space.")) os.unlink(self.loopbackFile) return 1
def sanityCheckRaid(self, partitions): if not self.raidmembers or not self.raidlevel: return _("No members in RAID request, or not RAID " "level specified.") # XXX fix this code to look to see if there is a bootable partition bootreq = partitions.getBootableRequest() if not bootreq and self.mountpoint: # XXX 390 can't have boot on raid if (self.mountpoint in partitions.getBootableMountpoints() and not raid.isRaid1(self.raidlevel)): return _("Bootable partitions can only be on RAID1 devices.") minmembers = raid.get_raid_min_members(self.raidlevel) if len(self.raidmembers) < minmembers: return _("A RAID device of type %s " "requires at least %s members.") % (self.raidlevel, minmembers) if len(self.raidmembers) > 27: return "RAID devices are limited to 27 members." if self.raidspares: if (len(self.raidmembers) - self.raidspares) < minmembers: return _("This RAID device can have a maximum of %s spares. " "To have more spares you will need to add members to " "the RAID device.") % (len(self.raidmembers) - minmembers ) return None
def __call__(self, screen): bb = ButtonBar(screen, [_("OK"), _("Cancel")]) t = TextboxReflowed(40, _("Select the appropriate number")) l = Listbox(5, scroll = 0, returnExit = 0) capitalize = Checkbox(_("Capitalize?"), isOn = 1) nums = [ "one", "two", "three", "four", "five" ] for index, num in enumerate(nums): l.append("%s" % (index + 1), num) l.setCurrent("three") g = GridFormHelp(screen, _("Number Selection"), "num", 1, 4) g.add(t, 0, 0) g.add(l, 0, 1, padding = (0, 1, 0, 1)) g.add(capitalize, 0, 2, padding = (0, 0, 0, 1)) g.add(bb, 0, 3, growx = 1) rc = g.runOnce() button = bb.buttonPressed(rc) if button == "cancel": return -1 value = l.current() if capitalize.selected(): value = string.capitalize(value); return value
def doMountPointLinuxFSChecks(self): """Return an error string if the mountpoint is not valid for Linux FS.""" mustbeonroot = ('/bin', '/dev', '/sbin', '/etc', '/lib', '/root', '/mnt', 'lost+found', '/proc') mustbeonlinuxfs = ('/', '/boot', '/var', '/tmp', '/usr', '/home', '/usr/share', '/usr/lib') # these are symlinks so you cant make them mount points otherexcept = ('/var/mail', '/usr/bin/X11', '/usr/lib/X11', '/usr/tmp') if not self.mountpoint: return None if self.fstype is None: return None if self.fstype.isMountable(): if self.mountpoint in mustbeonroot: return _("This mount point is invalid. The %s directory must " "be on the / file system.") % (self.mountpoint, ) elif self.mountpoint in otherexcept: return _("The mount point %s cannot be used. It must " "be a symbolic link for proper system " "operation. Please select a different " "mount point.") % (self.mountpoint, ) if not self.fstype.isLinuxNativeFS(): if self.mountpoint in mustbeonlinuxfs: return _("This mount point must be on a linux file system.") return None
def turnOnFilesystems(anaconda): if anaconda.dir == DISPATCH_BACK: log.info("unmounting filesystems") anaconda.id.fsset.umountFilesystems(anaconda.rootPath) return if flags.setupFilesystems: if not anaconda.id.upgrade: anaconda.id.partitions.doMetaDeletes(anaconda.id.diskset) anaconda.id.fsset.setActive(anaconda.id.diskset) if not anaconda.id.fsset.isActive(): anaconda.id.diskset.savePartitions () anaconda.id.partitions.doEncryptionRetrofits() anaconda.id.fsset.checkBadblocks(anaconda.rootPath) if not anaconda.id.fsset.volumesCreated: try: anaconda.id.fsset.createLogicalVolumes(anaconda.rootPath) except SystemError, e: log.error("createLogicalVolumes failed with %s", str(e)) anaconda.intf.messageWindow(_("LVM operation failed"), str(e)+"\n\n"+_("The installer will now exit..."), type="custom", custom_icon="error", custom_buttons=[_("_Reboot")]) sys.exit(0) anaconda.id.fsset.formatSwap(anaconda.rootPath) anaconda.id.fsset.turnOnSwap(anaconda.rootPath) anaconda.id.fsset.makeFilesystems (anaconda.rootPath) anaconda.id.fsset.mountFilesystems (anaconda)
def sanityCheckRaid(self, partitions): if not self.raidmembers or not self.raidlevel: return _("No members in RAID request, or not RAID " "level specified.") # XXX fix this code to look to see if there is a bootable partition bootreq = partitions.getBootableRequest() if not bootreq and self.mountpoint: # XXX 390 can't have boot on raid if (self.mountpoint in partitions.getBootableMountpoints() and not raid.isRaid1(self.raidlevel)): return _("Bootable partitions can only be on RAID1 devices.") minmembers = raid.get_raid_min_members(self.raidlevel) if len(self.raidmembers) < minmembers: return _( "A RAID device of type %s " "requires at least %s members.") % (self.raidlevel, minmembers) if len(self.raidmembers) > 27: return "RAID devices are limited to 27 members." if self.raidspares: if (len(self.raidmembers) - self.raidspares) < minmembers: return _( "This RAID device can have a maximum of %s spares. " "To have more spares you will need to add members to " "the RAID device.") % (len(self.raidmembers) - minmembers) return None
def checkForSwapNoMatch(intf, diskset, partitions): """Check for any partitions of type 0x82 which don't have a swap fs.""" for request in partitions.requests: if not request.device or not request.fstype: continue part = partedUtils.get_partition_by_name(diskset.disks, request.device) if (part and (not part.type & parted.PARTITION_FREESPACE) and (part.native_type == 0x82) and (request.fstype and request.fstype.getName() != "swap") and (not request.format)): rc = intf.messageWindow(_("Format as Swap?"), _("/dev/%s has a partition type of 0x82 " "(Linux swap) but does not appear to " "be formatted as a Linux swap " "partition.\n\n" "Would you like to format this " "partition as a swap partition?") % (request.device), type="yesno", custom_icon="question") if rc == 1: request.format = 1 request.fstype = fsset.fileSystemTypeGet("swap") if request.fstype.getName() == "software RAID": part.set_flag(parted.PARTITION_RAID, 1) else: part.set_flag(parted.PARTITION_RAID, 0) partedUtils.set_partition_file_system_type( part, request.fstype)
def add_host(self, args): try: opts, args = getopt.getopt(args[1:], "hvu:p:f:m:l:d:e:", ["help", "verbose", "profile=", "hostname=", "ip=", "registration_token=", "arch=", "cpu_speed=", "cpu_count=", "memory=", "kernel_options=", "kickstart_metadata=", "list_group=", "mac_address=", "is_container=", "puppet_node_diff=", "netboot_enabled=", "is_locked=", "status=", "last_heartbeat="]) except getopt.error, e: print _("Error parsing list arguments: %s") % e
def main(argv): """ Start things up. """ config_obj = config_data.Config() config = config_obj.get() databases = config['databases'] url = databases['primary'] # connect db.Database(url) textdomain(I18N_DOMAIN) taskatron = Taskatron() if len(sys.argv) > 2 and sys.argv[1].lower() == "--test": print taskatron.node_comm(sys.argv[2],"test_add",1,2) elif len(sys.argv) > 1 and sys.argv[1].lower() == "--daemon": taskatron.clean_up_tasks() utils.daemonize("/var/run/vf_taskatron.pid") taskatron.run_forever() elif len(sys.argv) > 1 and sys.argv[1].lower() == "--infinity": taskatron.clean_up_tasks() taskatron.run_forever() elif len(sys.argv) == 1: print _("Running single task in debug mode, since --daemon wasn't specified...") taskatron.clean_up_tasks() taskatron.dotick(socket.gethostname(), True) else: useage = _("""Usage: vf_taskatron --test server.fqdn vf_taskatron --daemon vf_tasktron (no args) (just runs through one pass) """) print useage
def main(argv): regtoken = "UNSET" username = None password = None server_url = None profile_name = "" virtual = False bridge_config_ok = False # ensure we have somewhere to save parameters to, the node daemon will want # to know them later. if not os.path.exists("/etc/sysconfig/virt-factory"): os.makedirs("/etc/sysconfig/virt-factory") try: opts, args = getopt.getopt(argv[1:], "ht:u:p:s:P:vB", [ "help", "token=", "username="******"password="******"serverurl=", "profilename=", "virtual", "allow-bridge-config" ]) except getopt.error, e: print _("Error parsing command list arguments: %s") % e showHelp() sys.exit(1)
def checkDiskLabel(disk, intf): """Check that the disk label on disk is valid for this machine type.""" arch = iutil.getArch() if arch in archLabels.keys(): if disk.type.name in archLabels[arch]: # this is kind of a hack since we don't want LDL to be used return checkDasdFmt(disk, intf) else: if disk.type.name == "msdos": return 0 if intf: rc = intf.messageWindow(_("Warning"), _("The partition table on device /dev/%s is of an " "unexpected type %s for your architecture. To " "use this disk for installation of %s, " "it must be re-initialized causing the loss of " "ALL DATA on this drive.\n\n" "Would you like to initialize this drive?") % (disk.dev.path[5:], disk.type.name, productName), type = "yesno") if rc == 0: return 1 else: return -1 else: return 1
def getScreen (self, anaconda): hbox = gtk.HBox (False, 5) pix = gui.readImageFromFile ("done.png") if pix: a = gtk.Alignment () a.add (pix) a.set (0.5, 0.5, 1.0, 1.0) a.set_size_request(200, -1) hbox.pack_start (a, False, False, 36) bootstr = "" if rhpl.getArch() in ['s390', 's390x']: floppystr = "" if not anaconda.canReIPL: self.rebootButton.set_label(_("Shutdown")) if not anaconda.reIPLMessage is None: floppystr = anaconda.reIPLMessage else: floppystr = _("Remove any media used during the installation " "process and press the \"Reboot\" button to " "reboot your system." "\n\n") txt = _("Congratulations, the installation is complete.\n\n" "%s%s") %(floppystr, bootstr) label = gui.WrappingLabel(txt) hbox.pack_start (label, True, True) gtk.gdk.beep() return hbox
def systemMounted(self, fsset, chroot): if self.tree is None: return self.loopbackFile = "%s%s%s" % (chroot, fsset.filesystemSpace(chroot)[0][0], "/rhinstall-stage2.img") try: win = self.waitWindow( _("Copying File"), _("Transferring install image to hard drive...")) shutil.copyfile("%s/images/stage2.img" % (self.tree, ), self.loopbackFile) win.pop() except Exception, e: if win: win.pop() log.critical("error transferring stage2.img: %s" % (e, )) self.messageWindow( _("Error"), _("An error occurred transferring the install image " "to your hard drive. You are probably out of disk " "space.")) os.unlink(self.loopbackFile) return 1
def launch(self, doDebug = None): if doDebug: print "initializing sbcomplete module" self.vbox = gtk.VBox() self.vbox.set_size_request(400, 200) msg = (_("Setup Complete")) title_pix = functions.imageFromFile("workstation.png") internalVBox = gtk.VBox() internalVBox.set_border_width(10) label = gtk.Label(_("Your SpeechBridge setup is almost complete, but you still need to install your license key(s) and configure SpeechBridge from the administration website. " "If you are installing a SpeechBridge Pro system, or are including the TTS upgrade, you will need to log in and run the following command from a terminal:\n /home/speechbridge/software/neoinstall.sh\n" # "After you click 'Finish', click the \"Restart\" link at the bottom of the login screen in order to make sure all of the settings have taken effect. " # "After the system reboots, you will be taken to the login screen where " "After you click 'Finish' you will be taken to the login screen where " "you can start the SpeechBridge web administration " "site by launching Firefox and going to \"https://localhost\", or " "you can also start it from a browser on another machine by replacing " "\"localhost\" with the IP address you specified in the network configuration earlier. Enjoy! " "")) label.set_line_wrap(True) label.set_alignment(0.0, 0.5) label.set_size_request(500, -1) internalVBox.pack_start(label, False, True) self.vbox.pack_start(internalVBox, False, 5) pix = functions.ditheredImageFromFile("splash-small.png") self.vbox.pack_start(pix, True, True, 5) return self.vbox, title_pix, msg
def distDone(self): if os.path.exists(self.rocksdist_lockFile): self.warningGUI( _("Rocks distribution is not ready\n\n") + _("Please wait for 'rocks create distro' to complete\n")) return 0 return 1
def printHelp(self, screen, header): sg = Grid(2, 2) bb = ButtonBar(screen, (TEXT_OK_BUTTON, )) sg.setField(Label(_("Package :")), 0, 0, (0, 0, 1, 0), anchorLeft=1) sg.setField(Label("%s-%s-%s" % (header[rpm.RPMTAG_NAME], header[rpm.RPMTAG_VERSION], header[rpm.RPMTAG_RELEASE])), 1, 0, anchorLeft=1) sg.setField(Label(_("Size :")), 0, 1, (0, 0, 1, 0), anchorLeft=1) sg.setField(Label( _("%.1f KBytes") % (header[rpm.RPMTAG_SIZE] / 1024.0)), 1, 1, anchorLeft=1) txt = TextboxReflowed(60, self.get_rpm_desc(header), maxHeight=10) g = GridForm(screen, header[rpm.RPMTAG_NAME], 1, 3) g.add(sg, 0, 0, (0, 0, 0, 1), anchorLeft=1) g.add(txt, 0, 1, (0, 0, 0, 1)) g.add(bb, 0, 2, growx=1) g.runOnce()
def setupOptionsVbox(self): self.options_vbox = gtk.VBox(False, 5) self.options_vbox.set_border_width(5) self.forceLBA = gtk.CheckButton(_("_Force LBA32 (not normally required)")) self.options_vbox.pack_start(self.forceLBA, False) self.forceLBA.set_active(self.bl.forceLBA32) label = gui.WrappingLabel(_("If you wish to add default options to the " "boot command, enter them into " "the 'General kernel parameters' field.")) label.set_alignment(0.0, 0.0) self.options_vbox.pack_start(label, False) label = gui.MnemonicLabel(_("_General kernel parameters")) self.appendEntry = gtk.Entry() label.set_mnemonic_widget(self.appendEntry) args = self.bl.args.get() if args: self.appendEntry.set_text(args) box = gtk.HBox(False, 0) box.pack_start(label) box.pack_start(self.appendEntry) al = gtk.Alignment(0.0, 0.0) al.add(box) self.options_vbox.pack_start(al, False)
def __call__(self, screen, defaultByLang, kbd): if flags.serial: return INSTALL_NOOP keyboards = kbd.modelDict.keys() keyboards.sort() if kbd.beenset: default = kbd.get() else: default = defaultByLang (button, choice) = \ ListboxChoiceWindow(screen, _("Keyboard Selection"), _("Which model keyboard is attached to this computer?"), keyboards, buttons = [TEXT_OK_BUTTON, TEXT_BACK_BUTTON], width = 30, scroll = 1, height = 8, default = default, help = "kybd") if button == TEXT_BACK_CHECK: return INSTALL_BACK kbd.set(keyboards[choice]) kbd.beenset = 1 kbd.activate() # FIXME: eventually, kbd.activate will do this try: isys.loadKeymap(keyboards[choice]) except SystemError, (errno, msg): log("Could not install keymap %s: %s" % (keyboards[choice], msg))
def _remove(self, *args): repo = self.__getSelectedRepo() if repo is None: d = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_ERROR, gtk.BUTTONS_OK, _("No repository selected")) d.run() d.destroy() return path = os.path.normpath(repo.repofile) if len(self.ayum.rpmdb.searchFiles(path)) > 0: d = gtk.MessageDialog(None, gtk.DIALOG_MODAL, gtk.MESSAGE_WARNING, gtk.BUTTONS_OK_CANCEL, _("The %s repository is included in the " "%s package. Removal of this repository " "may result in your system not " "functioning properly. Are you sure " "you want to continue?") %(repo.id , self.ayum.rpmdb.searchFiles(path)[0])) rc = d.run() d.destroy() if rc == gtk.RESPONSE_CANCEL: return repo.cfg.remove_section(repo.id) repo.cfg.write(file(repo.repofile, 'w')) if len(repo.cfg.sections()) == 0: try: os.unlink(repo.repofile) except OSError, e: print >> sys.stderr, "Error removing repo file %s: %s" %(repo.repofile, e)
def sanityCheckMountPoint(mntpt, fstype, preexisting, format): """Sanity check that the mountpoint is valid. mntpt is the mountpoint being used. fstype is the file system being used on the request. preexisting is whether the request was preexisting (request.preexist) format is whether the request is being formatted or not """ if mntpt: passed = 1 if not mntpt: passed = 0 else: if mntpt[0] != '/' or (len(mntpt) > 1 and mntpt[-1:] == '/'): passed = 0 elif mntpt.find(' ') > -1: passed = 0 if not passed: return _("The mount point %s is invalid. Mount points must start " "with '/' and cannot end with '/', and must contain " "printable characters and no spaces." % mntpt) else: return None else: if (fstype and fstype.isMountable() and (not preexisting or format)): return _("Please specify a mount point for this partition.") else: # its an existing partition so don't force a mount point return None