Mini Shell

Direktori : /usr/lib64/python3.6/site-packages/pyanaconda/__pycache__/
Upload File :
Current File : //usr/lib64/python3.6/site-packages/pyanaconda/__pycache__/startup_utils.cpython-36.pyc

3

C��egI�@s�ddlmZddlmZddlmZmZmZe�Zddlm	Z	e	e
�ZddlZddl
Z
ddlZddlmZmZddlmZddlmZdd	lmZdd
lmZddlmZddlmZmZmZdd
lmZddlmZddl m!Z!m"Z"m#Z#m$Z$ddl%m&Z&ddl'm(Z(m)Z)ddl*Z*dd�Z+d7dd�Z,dd�Z-dd�Z.dd�Z/dd�Z0dd�Z1d d!�Z2d"d#�Z3d8d%d&�Z4d'd(�Z5d)d*�Z6d+d,�Z7d-d.�Z8d/d0�Z9d1d2�Z:d3d4�Z;d5d6�Z<dS)9�)�conf)�_)�get_stdout_logger�get_storage_logger�get_packaging_logger)�get_module_loggerN)�util�	constants)�product)�anaconda_logging)�network)�	safe_dbus)�	kickstart)�TEXT_ONLY_TARGET�SETUP_ON_BOOT_DEFAULT�SETUP_ON_BOOT_ENABLED)�flags)�inhibit_screensaver)�TIMEZONE�LOCALIZATION�SERVICES�SECURITY)�is_module_available)�AnacondaThread�	threadMgrcCsVddl}|jdd�ddlm}|j|jj|jj|d�}|j	|�|j
�|j�dS)a#A simple warning dialog for use during early startup of the Anaconda GUI.

    :param str title: title of the warning dialog
    :param str reason: warning message

    TODO: this should be abstracted out to some kind of a "warning API" + UI code
          that shows the actual warning
    rN�Gtkz3.0)r)�typeZbuttonsZmessage_format)�giZrequire_versionZ
gi.repositoryrZ
MessageDialogZMessageTypeZERRORZButtonsTypeZCLOSEZ	set_titleZrunZdestroy)�title�reasonrrZdialog�r �%/usr/lib64/python3.6/startup_utils.py�gtk_warning3s	

r"cCs�ddlm}td�}td�}td�}td�}td�}td�}	|jrFd	S|sP|j}|}
t|j�d
�}t|j�}t|j�}
t	j
�s�||j7}|
|j7}
tj
d|||
�|js�tjd�d	Stj||d
�}||k�r<|jr�tj|
|�t||
|�n2|
|7}
t|
|�ttd��ttd��t�t	jtj�tjd�|tjjk�r�tj�r�|
}|
|d<|}
||k�r�|j�r�|
|7}
tj|
|�|}t||
|�t	jtj�tjd�n*|
|	7}
tj|
|�tjj|_t j!d�d	S)a Check is the system has enough RAM for installation.

    :param anaconda: instance of the Anaconda class
    :param options: command line/boot options
    :param display_mode: a display mode to use for the check
                         (graphical mode usually needs more RAM, etc.)
    r)�isyszv%(product_name)s requires %(needed_ram)s MB of memory to install, but you only have %(total_ram)s MB on this machine.
zsThe %(product_name)s graphical installer requires %(needed_ram)s MB of memory, but you only have %(total_ram)s MB.
z&
Press [Enter] to reboot your system.
zNot enough RAMzX Try the text mode installer by running:

'/usr/bin/liveinst -T'

 from a root terminal.z Starting text mode.Niz1check_memory(): total:%s, needed:%s, graphical:%szCHECK_MEMORY DISABLED)Zproduct_name�
needed_ram�	total_ramz@The installation cannot continue and the system will be rebootedzPress ENTER to continue�r$�)"�
pyanacondar#rZrescue�display_mode�intZtotal_memoryZMIN_RAMZMIN_GUI_RAMrZpersistent_root_imageZSQUASHFS_EXTRA_RAM�log�infoZmemcheck�warningr
�productName�liveinst�
stdout_logr"�print�input�ipmi_reportr	�IPMI_ABORTED�sys�exit�DisplayModes�TUIr�usevnc�timeZsleep)�anaconda�optionsr)r#Z
reason_strictZreason_graphicalZreboot_extraZlivecd_titleZlivecd_extraZnolivecd_extrarr%r$Z
graphical_ramZreason_argsrr r r!�check_memoryHsj	









r=cCs�|js|jr|jrd|_|jr~|jtjkr~tjd|j�tj|j}|tj_tjt|�t	�}tj||�t
�}tj||�tjj
r�|jr�tjj|j�|jr�y,|jjdd�\}}t|�}tjj||�Wn"tk
r�tjd|j�YnXdS)zConfigure logging according to Anaconda command line/boot options.

    :param options: Anaconda command line/boot options
    �debugzSwitching logging level to %s�:r&z!Could not setup remotelog with %sN)r>Z	updateSrcZloglevelrZlogLevelMapr+r,ZloggerZsetHandlersLevelrrr�systemZcan_modify_syslogZsyslogZupdateRemoteZ	remotelog�splitr*Zsetup_remotelog�
ValueError�error)r<�levelZstorage_logZ
packaging_log�hostZportr r r!�setup_logging_from_options�s*rFcCs"ddl}tj�}|s4tjd�tjtj�t	j
d�|}y|j|�}Wn:|jk
r�}ztj
d||�tj�}WYdd}~XnXt|�dkr�|d}|jd�dkr�d|f}|dk	r�|jd	�r�|dk	r�d
|j|d�|f}n|dk	r�d|f}nd}|�rtjtd
�|�ntjtd��dS)zCPrompt the user to ssh to the installation environment on the s390.rNz4No IP addresses found, cannot continue installation.r&z2Exception caught trying to get host name of %s: %s�r?z[%s]Z	localhostz%s (%s))�namez%sz+Please ssh install@%s to begin the install.z5Please ssh install@HOSTNAME to continue installation.���)�socketrZget_first_ip_addressr0rCrr3r	r4r5r6Z
gethostbyaddrZherrorr>Zget_hostname�len�find�
startswithZgetfqdnr,r)rJZipZipstrZhinfo�erHZ	connxinfor r r!�prompt_for_ssh�s0


rOcCstjdtjddd�dS)a�Remove files stored in nonvolatile ram created by the pstore subsystem.

    Files in pstore are Linux (not distribution) specific, but we want to
    make sure the entirety of them are removed so as to ensure that there
    is sufficient free space on the flash part.  On some machines this will
    take effect immediately, which is the best case.  Unfortunately on some,
    an intervening reboot is needed.
    z/sys/fs/pstoreTF)�files�dirsN)rZdir_tree_map�os�unlinkr r r r!�clean_pstore�s	rTcCs�dtjdd�tjtjf}d}d}d}d}d}d	}tjrFtd
|�ntd|�|jr�|jr�t|�t	j
j�s�dtj
kr�tj
jd
�dkr�t|�q�t|�n|js�t|�|jtjjkr�t|�t|�dS)z�Print Anaconda version and short usage instructions.

    Print Anaconda version and short usage instruction to the TTY where Anaconda is running.

    :param options: command line/boot options
    z%s for %s %sT)Zbuild_time_versionzD * installation log files are stored in /tmp during the installationz * shell is available on TTY2zL * shell is available on TTY2 and in second TMUX pane (ctrl+b, then press 2)z@ * shell is available in second TMUX pane (ctrl+b, then press 2)z� * if the graphical installation interface fails to start, try again with the
   inst.text bootoption to start text installationzM * when reporting a bug add logs from /tmp as separate text/plain attachmentszanaconda %s started.z"anaconda %s (pre-release) started.ZTMUXZTERMZscreenN)rZget_anaconda_version_stringr
r.ZproductVersionZisFinalr1ZimagesZ
dirinstall�blivetZarchZis_s390rR�environ�get�ksfiler)r	r7r8)r<ZverdescZ	logs_noteZshell_and_tmux_noteZshell_only_noteZtmux_only_noteZtext_mode_noteZseparate_attachements_noter r r!�print_startup_note�s,


rYcCsPytj�|_Wn0tjk
r>}ztjd|�WYdd}~XnXt|j�|_dS)zYLive environment startup tasks.

    :param anaconda: instance of the Anaconda class
    z)Unable to connect to DBus session bus: %sN)r
Zget_new_session_connectionZdbus_session_connectionZ
DBusCallErrorr+r,rZdbus_inhibit_id)r;rNr r r!�live_startups
rZcCs�|jrV|jrVtjj|j�s@tjd|j�tjt	j
�tjd�dt
_dt
_|jg}n0tjjd�r~|jr~dt
_dt
_dg}nddg}x|D]}tjj|�s�q�|SWdS)	a�Find a kickstart to parse.

    If we were given a kickstart file, return that one. Otherwise, return
    a default kickstart file shipped with the installation media.

    Pick up any changes from interactive-defaults.ks that would otherwise
    be covered by the dracut kickstart parser.

    :param options: command line/boot options
    :returns: a path to a kickstart file or None
    zKickstart file %s is missing.r&TFz/run/install/ks.cfgz$/tmp/updates/interactive-defaults.ksz+/usr/share/anaconda/interactive-defaults.ksN)rXr/rR�path�existsr0rCrr3r	r4r5r6r�automatedInstallZeject)r<Zks_files�ksr r r!�find_kickstart*s&


r_cCs|dk	rtj|�dS)zIRun %pre scripts.

    :param ks: a path to a kickstart file or None
    N)rZ
preScriptPass)r^r r r!�run_pre_scriptsRsr`FcCs8tj|d�}|dk	r4tjd|�tj|||dd�|S)z�Parse the given kickstart file.

    :param ks: a path to a kickstart file or None
    :param addon_paths: a dictionary of addon paths
    :param strict_mode: process warnings as errors if True
    :returns: kickstart parsed to a data model
    r^NzParsing kickstart: %sT)�strict_modeZpass_to_boss)rZAnacondaKSHandlerr+r,ZparseKickstart)r^Zaddon_pathsraZksdatar r r!�parse_kickstart[s
rbcCsRtjjstjd�dStt�s"dSddlm}tj	�}t
jtt
j||fd��dS)zInitialize the system clock.zSkip the clock initialization.Nr)�time_initialize)rH�target�args)rr@Zcan_initialize_system_clockr+r>rrZpyanaconda.timezonerc�	get_proxyr�addrr	ZTHREAD_TIME_INIT)rc�timezone_proxyr r r!�initialize_system_clockls
ricCsntjjstjd�dStt�s"dSddlm}tj	�}|j
}|rZ|j|�\}}|j||�|j
rjtjd�dS)zkStart the NTP daemon chronyd.

    Set up NTP servers and start NTP daemon if not requested otherwise.
    zSkip the time synchronization.Nr)�ntpZchronyd)rr@Zcan_set_time_synchronizationr+r>rrr(rjrfZ
NTPServersZinternal_to_pools_and_serversZsave_servers_to_configZ
NTPEnabledrZ
start_service)rjrhZkickstart_ntpserversZpoolsZserversr r r!�
start_chronyds
rkcCsltt�sdSddlm}tj�}|jrD|jrD|j|j�|jd�|jrht	j
jr^|j|�n
|j
|�dS)z�Activate keyboard.

    Set up keyboard layout from the command line option and
    let it override from kickstart if/when X is initialized.

    :param opts: the command line/boot options
    Nr)�keyboardT)rrr(rlrfZkeymapZKeyboardKickstartedZSetKeyboardZSetKeyboardKickstartedrr@Zcan_activate_keyboard�activate_keyboardZpopulate_missing_items)�optsrl�localization_proxyr r r!rm�s
rmcCstddlm}d}d}tt�rLtj�}|jr@|j|j�|jd�|jrL|j	}|j
||d�|jtj
d||d�dS)z�Initialize locale.

    :param opts: the command line/boot options
    :param text_mode: is the locale being set up for the text mode?
    r)�localizationNT)�	text_mode�LANG)r(rprrrfZlangZSetLanguageZSetLanguageKickstartedZLanguageKickstartedZLanguageZsetup_locale_environment�setup_localerRrV)rnrqrpZ
locale_optionror r r!�initialize_locale�s
rtcCsDddlm}d}tt�r tj�}tjd�|jtj	d||d�dS)z�Reinitialize locale.

    :param opts: the command line/boot options
    :param text_mode: is the locale being set up for the text mode?
    r)rpNz<reinitializing locale due to failed attempt to start the GUIrr)rq)
r(rprrrfr+r-rsrRrV)rnrqrpror r r!�reinitialize_locale�s
rucCs>tt�sdStj�}|jr:|s&tjr:tjd�|jt	�dS)a�Initialize the default systemd target.

    If we're in text mode, the resulting system should be too
    unless the kickstart specified otherwise.

    NOTE:

        Installation controlled via VNC is considered to be
        a text mode installation, as the installation run itself
        is effectively headless.

    :param text_mode: does the installer run in the text mode?
    NzMno default systemd target set & in text/vnc mode - setting multi-user.target.)
rrrfZ
DefaultTargetrr9r+r>ZSetDefaultTargetr)rq�services_proxyr r r!�!initialize_default_systemd_target�s
rwcCs2tt�sdStj�}|jtkr.tjs.|jt�dS)z$Initialize the setup on boot action.N)	rrrfZSetupOnBootrrr]ZSetSetupOnBootr)rvr r r!�initialize_first_boot_action�s
rxcCsDtt�sdStj�}tjjtjkr0|jtjj�t	j
s@|jd�dS)z&Initialize the security configuration.NT)rrrfrZsecurityZselinuxr	ZSELINUX_DEFAULTZ
SetSELinuxrr]ZSetFingerprintAuthEnabled)Zsecurity_proxyr r r!�initialize_securitysry)N)F)=Z&pyanaconda.core.configuration.anacondarZpyanaconda.core.i18nrZpyanaconda.anaconda_loggersrrrr0r�__name__r+r5r:rRZpyanaconda.corerr	r(r
rrr
rZpyanaconda.core.constantsrrrZpyanaconda.flagsrZpyanaconda.screensaverrZ,pyanaconda.modules.common.constants.servicesrrrrZpyanaconda.modules.common.utilrZpyanaconda.threadingrrrUr"r=rFrOrTrYrZr_r`rbrirkrmrtrurwrxryr r r r!�<module>sN
X )(
(