Beispiel #1
0
    def _setupUrl(self):
        if not userchoices.getMediaLocation():
            return

        url = userchoices.getMediaLocation()['mediaLocation']
        protocol, user, passwd, host, port, path =\
                                    networking.utils.parseFileResourceURL(url)

        self.xml.get_widget('NfsServerEntry').set_text(host)
        self.xml.get_widget('NfsDirectoryEntry').set_text(path)
Beispiel #2
0
    def _setupUrl(self):
        # since the user name / password are encoded in the url, we
        # need to remove them here to set them up in the widgets correctly
        if not userchoices.getMediaLocation():
            return

        mediaURL = userchoices.getMediaLocation()['mediaLocation']
        username, password, host, port, path = parseFTPURL(mediaURL)

        displayURL = unparseFTPURL('', '', host, port, path)
        self.xml.get_widget('FtpUrlEntry').set_text(displayURL)
        self.xml.get_widget('FtpNonAnonLoginUserEntry').set_text(username)
        self.xml.get_widget('FtpNonAnonPasswordEntry').set_text(password)
Beispiel #3
0
def reviewInstallationSource(values):
    try:
        location = userchoices.getMediaLocation()
        if not location:
            media = userchoices.getMediaDescriptor()
            if media:
                values['mediaDrive'] = htmlEscape(media.getName())
                values['mediaVersion'] = htmlEscape(media.version)
                if media.isoPath:
                    values['isoPath'] = htmlEscape(media.isoPath)
                    values['mediaISO'] = (
                        '%(subKeyStart)sISO:%(subKeyEnd)s'
                        '%(ralign)s%(isoPath)s<br/>' % values)
                else:
                    values['mediaISO'] = ''
                values['mediaTemplate'] = DRIVE_MEDIA % values
            else:
                values['mediaLocation'] = 'DVD-ROM'
                values['mediaTemplate'] = BASIC_MEDIA % values
        else:
            rawLocation = location['mediaLocation']
            values['mediaLocation'] = htmlEscape(
                networking.utils.cookPasswordInFileResourceURL(rawLocation))
            values['mediaTemplate'] = BASIC_MEDIA % values
    except KeyError:
        values['mediaTemplate'] = ''
Beispiel #4
0
def runtimeActionEjectMedia():
    if userchoices.getMediaLocation():
        # Non-CD install, don't bother.
        return
    
    if userchoices.getNoEject():
        return

    media = userchoices.getMediaDescriptor() or DEFAULT_MEDIA
    return media.eject()
Beispiel #5
0
def _genInstall():
    devChoice = userchoices.getMediaDescriptor()
    urlChoice = userchoices.getMediaLocation()

    if not urlChoice and not devChoice:
        return "install cdrom\n"

    if devChoice:
        if devChoice.partPath in cdutil.cdromDevicePaths():
            return "install cdrom\n"
        else:
            return "install usb\n"

    # XXX proxy not handled...
    return "install url %s\n" % urlChoice['mediaLocation']
Beispiel #6
0
def _genInstall():
    devChoice = userchoices.getMediaDescriptor()
    urlChoice = userchoices.getMediaLocation()

    if not urlChoice and not devChoice:
        return "install cdrom\n"

    if devChoice:
        if devChoice.partPath in cdutil.cdromDevicePaths():
            return "install cdrom\n"
        else:
            return "install usb\n"
        
    # XXX proxy not handled...
    return "install url %s\n" % urlChoice['mediaLocation']
Beispiel #7
0
def getPackagesXML(supportedPackageGroups):
    mediaLocation = userchoices.getMediaLocation()
    if mediaLocation:
        mediaRoot = mediaLocation['mediaLocation']
        url = urljoin(mediaRoot, 'packages.xml')
    else:
        mediaRoot = consts.MEDIA_DEVICE_MOUNT_POINT
        url = urljoin(URLify(os.path.join(mediaRoot, '')), 'packages.xml')
    
    try:
        packagesXMLPath = downloadLocally(url, maxAttempts=3)
    except RemoteFileError:
        msg = 'packages.xml was not found on the remote server.'
        log.error(msg)
        raise

    return PackagesXML(supportedPackageGroups, packagesXMLPath, mediaRoot)
Beispiel #8
0
def getPackagesXML(supportedPackageGroups):
    mediaLocation = userchoices.getMediaLocation()
    if mediaLocation:
        mediaRoot = mediaLocation['mediaLocation']
        url = urljoin(mediaRoot, 'packages.xml')
    else:
        mediaRoot = consts.MEDIA_DEVICE_MOUNT_POINT
        url = urljoin(URLify(os.path.join(mediaRoot, '')), 'packages.xml')

    try:
        packagesXMLPath = downloadLocally(url, maxAttempts=3)
    except RemoteFileError:
        msg = 'packages.xml was not found on the remote server.'
        log.error(msg)
        raise

    return PackagesXML(supportedPackageGroups, packagesXMLPath, mediaRoot)
Beispiel #9
0
def runtimeActionMountMedia(uiDelegate=None):
    """Mounts the installation media."""

    if not uiDelegate:
        uiDelegate = MOUNT_MEDIA_DELEGATE

    log.info("attempting to mount install media")

    if userchoices.getMediaLocation():
        log.info("  remote media in use, nothing to mount...")
        return

    while True:
        media = userchoices.getMediaDescriptor()

        if not media:
            # Check for the default media setup by the init scripts.
            media = DEFAULT_MEDIA
            media.isMounted = isInstallMediaMounted()
            if not os.path.exists(media.partPath):
                # attempt to remount the cd-rom since it may have been a SCSI
                # CD-ROM drive
                rc, stdout, stderr = \
                    execCommand("cd / && INSTALLER=1 %s %s" % (INIT_WRAPPER,
                                CDROM_MOUNT_SCRIPT))
                if rc:
                    log.critical("%s was not created" % media.partPath)
                    uiDelegate.mountMediaNoDrive()
                    sys.exit(ExitCodes.IMMEDIATELY_REBOOT)
                else:
                    media.isMounted = True

        # Make sure the media is mounted up.
        try:
            media.mount()
            if isInstallMediaMounted():
                return
            media.umount()
        except Exception, e:
            log.error(str(e))
        media.eject()
        uiDelegate.mountMediaNoPackages()
Beispiel #10
0
def hostActionUpdateEsxupdateDatabase(_context):
    '''Updates the esxudpate database with any meta-data on the source image.'''
    # In a nutshell:
    # 1. Copy metadata.zip from source image to host root (/mnt/sysimage).
    # 2. Run esxupdate syncdb command in /mnt/sysimage chroot.
    # 3. Remove metadata.zip from host root.
    # It would be nice if we could just import an esxupdate module and call a
    # function or method to do this. Unfortunately, esxupdate has a lot of
    # dependencies on configuration files and a database being in a certain
    # place, so it's just easier to call the esxupdate command line from a
    # chroot environment.
    mediaroot = userchoices.getMediaLocation().get(
                   'mediaLocation',
                   'file://' + consts.MEDIA_DEVICE_MOUNT_POINT
                )
    if not mediaroot.endswith('/'):
        mediaroot += '/'
    metasrc = urlparse.urljoin(mediaroot, 'metadata.zip')

    # Squelching any metadata.zip errors/warnings.  See PR:428781
    # We increase the log level required to print to tty6 to a ridiculous level,
    # then return it to normal.
    import scui
    err = None
    if scui.tty6Handler:
        prevLevel = scui.tty6Handler.level
        scui.tty6Handler.setLevel(9001)
    try:
        metadst = remote_files.downloadLocally(metasrc, clobberCache = True)
        if os.path.getsize(metadst) == 0:
            log.warn("The server gave '%s' as an empty file" % metadst)
            os.unlink(metadst)
            err = True
    except Exception, err:
        # downloadLocally() function doesn't distinguish between not found and
        # transfer or other error.
        log.warn('Esxupdate meta-data not present or not retrievable: %s' % err)
Beispiel #11
0
def hostActionUpdateEsxupdateDatabase(_context):
    '''Updates the esxudpate database with any meta-data on the source image.'''
    # In a nutshell:
    # 1. Copy metadata.zip from source image to host root (/mnt/sysimage).
    # 2. Run esxupdate syncdb command in /mnt/sysimage chroot.
    # 3. Remove metadata.zip from host root.
    # It would be nice if we could just import an esxupdate module and call a
    # function or method to do this. Unfortunately, esxupdate has a lot of
    # dependencies on configuration files and a database being in a certain
    # place, so it's just easier to call the esxupdate command line from a
    # chroot environment.
    mediaroot = userchoices.getMediaLocation().get(
        'mediaLocation', 'file://' + consts.MEDIA_DEVICE_MOUNT_POINT)
    if not mediaroot.endswith('/'):
        mediaroot += '/'
    metasrc = urlparse.urljoin(mediaroot, 'metadata.zip')

    # Squelching any metadata.zip errors/warnings.  See PR:428781
    # We increase the log level required to print to tty6 to a ridiculous level,
    # then return it to normal.
    import scui
    err = None
    if scui.tty6Handler:
        prevLevel = scui.tty6Handler.level
        scui.tty6Handler.setLevel(9001)
    try:
        metadst = remote_files.downloadLocally(metasrc, clobberCache=True)
        if os.path.getsize(metadst) == 0:
            log.warn("The server gave '%s' as an empty file" % metadst)
            os.unlink(metadst)
            err = True
    except Exception, err:
        # downloadLocally() function doesn't distinguish between not found and
        # transfer or other error.
        log.warn('Esxupdate meta-data not present or not retrievable: %s' %
                 err)
Beispiel #12
0
def runtimeActionUnmountMedia():
    if userchoices.getMediaLocation():
        return
    
    media = userchoices.getMediaDescriptor() or DEFAULT_MEDIA
    media.umount()
Beispiel #13
0
    def __init__(self):
        super(InstallMediaWindow, self).__init__()
        self.start = self.askMediaChoice
        self.substep = self.start

        self.mediaLocation = userchoices.getMediaLocation()
Beispiel #14
0
def main(argv):
    try:
        timedate.checkActionSaneTimedate()

        parseArgsToUserChoices(argv)

        if userchoices.getDebug():
            # Only import debugging if specified
            # We want to ensure that the debugging module has minimal impact
            # because debug mode is not a supported installation method
            import debugging
            debugging.init()
            patchLocChoice = userchoices.getDebugPatchLocation()
            if patchLocChoice:
                log.info('using the super-secret live install patching')
                patchLoc = patchLocChoice['debugPatchLocation']
                debugging.livePatch(patchLoc)

        if userchoices.getShowInstallMethod():
            # User wants to select the media themselves.  So, we unmount the
            # media set up by the init scripts since the UI will remount it
            # later.
            util.umount(MEDIA_DEVICE_MOUNT_POINT)

        runModeChoice = userchoices.getRunMode()

        # if we didn't boot via CD, make sure we prompt for the media
        if runModeChoice != userchoices.RUNMODE_SCRIPTED and \
           not os.path.exists(
              os.path.join(MEDIA_DEVICE_MOUNT_POINT, 'packages.xml')) and \
           not userchoices.getMediaLocation():
            userchoices.setShowInstallMethod(True)

        if not runModeChoice:
            log.warn("User has not chosen a Weasel run mode.")
            log.info("Weasel run mode defaulting to GUI.")
            runMode = userchoices.RUNMODE_GUI
        else:
            runMode = runModeChoice['runMode']

        if runMode != userchoices.RUNMODE_GUI:
            switchTty()

        stdoutHandler.setLevel(logging.DEBUG)
        if runMode == userchoices.RUNMODE_GUI:
            startGui = True

            if userchoices.getStartX():
                import startx
                startGui = startx.startX(userchoices.getVideoDriver())

            if startGui:
                try:
                    import gui
                    gui.Gui()
                except RuntimeError, msg:
                    # gtk looks like it's having problems
                    import pciidlib
                    devs = pciidlib.PciDeviceSet()
                    devs.scanSystem(pciidlib.PCI_CLASS_VIDEO)

                    if len(devs) < 1:
                        log.warn("Didn't find a video chipset")
                    else:
                        log.warn("X failed for chipset %s" % devs.keys()[0])
                    startGui = False

            if not startGui:
                switchTty()

                from textui.main import TextUI
                t = TextUI([])
                t.run()

        elif runMode == userchoices.RUNMODE_TEXT:
            from textui.main import TextUI

            t = TextUI([])
            t.run()
Beispiel #15
0
def main(argv):
    try:
        timedate.checkActionSaneTimedate()
    
        parseArgsToUserChoices(argv)

        if userchoices.getDebug():
            # Only import debugging if specified 
            # We want to ensure that the debugging module has minimal impact
            # because debug mode is not a supported installation method
            import debugging
            debugging.init()
            patchLocChoice = userchoices.getDebugPatchLocation()
            if patchLocChoice:
                log.info('using the super-secret live install patching')
                patchLoc = patchLocChoice['debugPatchLocation']
                debugging.livePatch(patchLoc)

        if userchoices.getShowInstallMethod():
            # User wants to select the media themselves.  So, we unmount the
            # media set up by the init scripts since the UI will remount it
            # later.
            util.umount(MEDIA_DEVICE_MOUNT_POINT)
        
        runModeChoice = userchoices.getRunMode()

        # if we didn't boot via CD, make sure we prompt for the media
        if runModeChoice != userchoices.RUNMODE_SCRIPTED and \
           not os.path.exists(
              os.path.join(MEDIA_DEVICE_MOUNT_POINT, 'packages.xml')) and \
           not userchoices.getMediaLocation():
            userchoices.setShowInstallMethod(True)

        if not runModeChoice:
            log.warn("User has not chosen a Weasel run mode.")
            log.info("Weasel run mode defaulting to GUI.")
            runMode = userchoices.RUNMODE_GUI
        else:
            runMode = runModeChoice['runMode']

        if runMode != userchoices.RUNMODE_GUI:
            switchTty()

        stdoutHandler.setLevel(logging.DEBUG)
        if runMode == userchoices.RUNMODE_GUI:
            startGui = True

            if userchoices.getStartX():
                import startx
                startGui = startx.startX(userchoices.getVideoDriver())

            if startGui:
                try:
                    import gui
                    gui.Gui()
                except RuntimeError, msg:
                    # gtk looks like it's having problems
                    import pciidlib
                    devs = pciidlib.PciDeviceSet()
                    devs.scanSystem(pciidlib.PCI_CLASS_VIDEO)

                    if len(devs) < 1:
                        log.warn("Didn't find a video chipset")
                    else:
                        log.warn("X failed for chipset %s" % 
                            devs.keys()[0])
                    startGui = False

            if not startGui:
                switchTty()

                from textui.main import TextUI
                t = TextUI([])
                t.run()

        elif runMode == userchoices.RUNMODE_TEXT:
            from textui.main import TextUI

            t = TextUI([])
            t.run()