def _usbOption(match): '''Handle the "ks=usb" and "ks=usb:<path>" option.''' try: ksFile = match.group(1) except IndexError: ksFile = "ks.cfg" firstTime = True while True: if not firstTime: # XXX Maybe we should just stop retrying after awhile? log.info("Insert a USB storage device that contains '%s' " "file to perform a scripted install..." % ksFile) util.rawInputCountdown("\rrescanning in %2d second(s), " "press <enter> to rescan immediately", 10) firstTime = False diskSet = devices.DiskSet(forceReprobe=True) usbDisks = [disk for disk in diskSet.values() if disk.driverName == devices.DiskDev.DRIVER_USB_STORAGE] if not usbDisks: log.info("") # XXX just for spacing log.warn("No USB storage found.") continue kickstartPath = os.path.join(USB_MOUNT_PATH, ksFile.lstrip('/')) if not os.path.exists(USB_MOUNT_PATH): os.makedirs(USB_MOUNT_PATH) for disk in usbDisks: for part in disk.partitions: if part.partitionId == -1: continue if (part.getFsTypeName() not in ("ext2", "ext3", "vfat")): # Don't try mounting partitions with filesystems that aren't # likely to be on a usb key. continue if util.mount(part.consoleDevicePath, USB_MOUNT_PATH, fsTypeName=part.getFsTypeName()): log.warn("Unable to mount '%s'" % part.consoleDevicePath) continue if os.path.exists(kickstartPath): userchoices.addDriveUse(disk.name, 'kickstart') return [('-s', kickstartPath)] if util.umount(USB_MOUNT_PATH): failWithLog("Unable to umount '%s'" % USB_MOUNT_PATH) log.info("") log.warn("%s was not found on any attached USB storage." % ksFile)
def _ksFileUUIDOption(match): uuid = match.group(1) path = match.group(2) diskSet = devices.DiskSet(forceReprobe=True) diskPartTuple = diskSet.findFirstPartitionMatching(uuid=uuid) if diskPartTuple: disk, _part = diskPartTuple userchoices.addDriveUse(disk.name, 'kickstart') mountPath = os.path.join(UUID_MOUNT_PATH, uuid) if not os.path.exists(mountPath): os.makedirs(mountPath) if util.mount(uuid, mountPath, isUUID=True): os.rmdir(mountPath) failWithLog("error: cannot mount partition with UUID: %s\n" % uuid) ksPath = os.path.join(mountPath, path[1:]) return [('-s', ksPath)]
def getNext(self): selectedMedia = self._getSelectedMedia() if not selectedMedia or not selectedMedia.hasPackages: MessageWindow(None, "Media Selection Error", "Select a valid installation medium.") raise exception.StayOnScreen if selectedMedia.diskName: userchoices.addDriveUse(selectedMedia.diskName, 'media') userchoices.setMediaDescriptor(selectedMedia) userchoices.clearMediaLocation() try: # Mount the media in case it is needed later on. selectedMedia.mount() except Exception, e: log.exception("unable to mount media") MessageWindow(None, "Media Error", "Unable to mount media. Rescan and select " "the media again.") raise exception.StayOnScreen