Mini Shell

Direktori : /lib64/python3.6/site-packages/pyanaconda/__pycache__/
Upload File :
Current File : //lib64/python3.6/site-packages/pyanaconda/__pycache__/kickstart.cpython-36.opt-1.pyc

3

Z��e�S�0@s2ddlZddlZddlZddlmZddlZddlZddlZddlZddl	Z	ddl
mZddlm
Z
ddlmZddlmZmZddlmZmZmZddlmZdd	lmZmZdd
lmZddlm Z ddl!m"Z"dd
l#m$Z$ddl%m&Z&m'Z'ddl(m)Z)m*Z*ddl+m,Z,m-Z-m.Z.m/Z/ddl0m1Z1m2Z2ddl3m4Z4ddl3m5Z6ddl7m8Z8m9Z9m:Z:m;Z;m<Z<m=Z=m>Z>m?Z?ddl@mAZAddlBmCZCddlDmEZEmFZFmGZGeEeH�ZIeF�ZJeIjKd�ZLeIjKd�ZMedd��ZNGdd�de6�ZOGdd�deO�ZPGd d!�d!e*ed"�ZQGd#d$�d$eQ�ZRejSZSGd%d&�d&ejT�ZTGd'd(�d(ejU�ZUGd)d*�d*e)�ZVGd+d,�d,e?�ZWeReReReReReReReReSeReReReReReReReReReReReTeReReReReReReReReReReReReReReReReReReReReReReReReReRd-�/ZXd(eUiZYeAe�ZZGd.d/�d/eZ�Z[Gd0d1�d1e4�Z\Gd2d3�d3e4�Z]d4d5�Z^dCd7d8�Z_d9d:�Z`d;d<�Zad=d>�Zbd?d@�ZcdAdB�ZddS)D�N)�ABCMeta)�contextmanager)�util)�conf)�VERSION�commands)�AddonSection�	AddonData�
AddonRegistry)�IPMI_ABORTED)�ScriptError�errorHandler)�flags)�_)�BOSS)�KickstartReport)�F22_PwPolicy�F22_PwPolicyData)�BaseHandler�KickstartCommand)�KS_SCRIPT_POST�
KS_SCRIPT_PRE�KS_SCRIPT_TRACEBACK�KS_SCRIPT_PREINSTALL)�KickstartError�KickstartParseWarning)�KickstartParser)�Script)�NullSection�PackageSection�PostScriptSection�PreScriptSection�PreInstallScriptSection�OnErrorScriptSection�TracebackScriptSection�Section)�returnClassForVersion)�anaconda_logging)�get_module_logger�get_stdout_logger�get_anaconda_root_logger�scriptZparsingccsNy
dVWn>tk
rH}z"t|�tjt�tjd�WYdd}~XnXdS)N�)r�printr�ipmi_reportr�sys�exit)�e�r2�!/usr/lib64/python3.6/kickstart.py�check_kickstart_errorDs

r4c@seZdZdZdd�ZdS)�AnacondaKSScriptz� Execute a kickstart script

        This will write the script to a file named /tmp/ks-script- before
        execution.
        Output is logged by the program logger, the path specified by --log
        or to /tmp/ks-script-\*.log
    c
Cs^|jr|}nd}tjdd|d�\}}tj||jjd��tj|�tj|d�|j	r�|jrld||j	f}n|j	}tj
j|�}tj
j|�s�tj
|�ndtj
j|�}tj|d	d
d��(}tj|jdtj
j|�g||d
�}WdQRX|dk�rZtjd||j�|j�rZd}	t|d��}dj|j��}	WdQRXdt_tjt|j|	��tjt �t!j"d�dS)zk Run the kickstart script
            @param chroot directory path to chroot into before execution
        �/�z
ks-script-z/tmpzutf-8i�z%s/%sz/tmp/%s.log�wi�)Zpermz/tmp/%s)�stdout�rootNrz5Error code %s running the kickstart script at line %s�rT)#ZinChroot�tempfileZmkstemp�os�writer+�encode�close�chmodZlogfile�path�dirname�exists�makedirs�basenamerZopen_with_permZexecWithRedirectZinterp�
script_log�error�linenoZerrorOnFail�open�join�	readlinesrZkspromptr
�cbrr.rr/r0)
�self�chrootZ
scriptRoot�fdrBZmessages�d�fpZrc�errr2r2r3�runXs:


zAnacondaKSScript.runN)�__name__�
__module__�__qualname__�__doc__rTr2r2r2r3r5Psr5cs$eZdZ�fdd�Zdd�Z�ZS)�AnacondaInternalScriptcst�j||�d|_dS)NT)�super�__init__Z_hidden)rN�args�kwargs)�	__class__r2r3r[�szAnacondaInternalScript.__init__cCsdS)Nr7r2)rNr2r2r3�__str__�szAnacondaInternalScript.__str__)rUrVrWr[r_�
__classcell__r2r2)r^r3rY�srYc@s eZdZdZdd�Zdd�ZdS)�RemovedCommandaKickstart command that was moved on DBus.

    This class should simplify the transition to DBus.

    Kickstart command that was moved on DBus should inherit this
    class. Methods parse, setup and execute should be modified to
    access the DBus modules or moved on DBus.
    cCsdS)z�Generate this part of a kickstart file from the module.

        This method shouldn't be overridden, because we use DBus modules
        to generate these parts of a kickstart file.

        Make sure that each DBus module is used only once.
        r7r2)rNr2r2r3r_�szRemovedCommand.__str__cCstjd|j�dS)z�Do not parse anything.

        We can keep this method for the checks if it is possible, but
        it shouldn't parse anything.
        z)Command %s will be parsed in DBus module.N)�logZwarning�
currentCmd)rNr\r2r2r3�parse�szRemovedCommand.parseN)rUrVrWrXr_rdr2r2r2r3ra�s
ra)�	metaclassc@seZdZdZdd�ZdS)�UselessCommandz�Kickstart command that was moved on DBus and doesn't do anything.

    Use this class to override the pykickstart command in our command map,
    when we don't want the command to do anything. It is not allowed to
    subclass this class.
    cKstd��dS)Nz7It is not allowed to subclass the UselessCommand class.)�	TypeError)�clsr]r2r2r3�__init_subclass__�sz UselessCommand.__init_subclass__N)rUrVrWrXrir2r2r2r3rf�srfc@seZdZdd�ZdS)�LoggingcCsvtjjtjkr0tj|j}|tj_tjt�|�tjjdkrrt	|j
�dkrr|j
}|jrfd|j
|jf}tjj|�dS)Nrz%s:%s)
r'ZloggerZloglevelZ
DEFAULT_LEVELZlogLevelMap�levelZsetHandlersLevelr*Z
remote_syslog�len�hostZportZupdateRemote)rNrkZ
remote_serverr2r2r3�execute�szLogging.executeN)rUrVrWrnr2r2r2r3rj�srjcsTeZdZdZ�fdd�Zedd��Zdd�Zedd	��Z�fd
d�Z	dd
�Z
�ZS)�RepoDatarcsf|jdd�|_|jdd�|_|jdd�|_|jdd�|_|jdd�|_|jd	d�|_t�j||�dS)
zr Add enabled kwarg

            :param enabled: The repo has been enabled
            :type enabled: bool
        �enabledT�repo_idN�treeinfo_originF�	partition�iso_path�mount_dir_suffix)	�poprprqrrrsrtrurZr[)rNr\r])r^r2r3r[�szRepoData.__init__cCs0||j|j|j|j|j|j|j|j|j|j	d�
S)N)
�name�baseurl�
mirrorlist�metalink�proxyrprrrsrtru)
rwrxryrzr{rprrrsrtru)rh�otherr2r2r3�create_copy�szRepoData.create_copycCs$|j�r |jdkr d|j�|_dS)zcGenerate persistent mount directory suffix

        This is valid only for HD repositories
        NZ	addition_)�is_harddrive_basedru�_generate_mount_dir_suffix)rNr2r2r3�generate_mount_dir�szRepoData.generate_mount_dircCst|j�}|jd7_|S)Nr,)�str�_RepoData__mount_counter)rh�suffixr2r2r3rs
z#RepoData._generate_mount_dir_suffixcs|jrt�j�SdSdS)zDon't output disabled reposr7N)rprZr_)rN)r^r2r3r_
s
zRepoData.__str__cCs
|jdk	S)N)rs)rNr2r2r3r~szRepoData.is_harddrive_based)rUrVrWr�r[�classmethodr}r�rr_r~r`r2r2)r^r3ro�s
rocs8eZdZdZdeiZdeiZ�fdd�Zdd�Z	�Z
S)�AnacondaSectionHandlerz2A handler for only the anaconda ection's commands.ZpwpolicyZPwPolicyDatacst�j|j|jd�dS)N)�mappingZdataMapping)rZr[�
commandMap�dataMap)rN)r^r2r3r["szAnacondaSectionHandler.__init__cCsTd}t|jj��}x,|D]$}x|j|D]}|t|�7}q(WqW|rPd|d}|S)zReturn the %anaconda sectionr7z
%anaconda
z%end
)�sortedZ_writeOrder�keysr�)rNZretvalZlstZprio�objr2r2r3r_%s
zAnacondaSectionHandler.__str__)rUrVrWrXrr�rr�r[r_r`r2r2)r^r3r�s
r�cs<eZdZdZdZ�fdd�Zdd�Zdd�Zd	d
�Z�Z	S)�AnacondaSectionz)A section for anaconda specific commands.z	%anacondacst�j||�d|_dS)Nr)rZr[�cmdno)rNr\r])r^r2r3r[8szAnacondaSection.__init__cCsL|js
dS|jd7_tj|dd�}|d|j_|j|j_|jj||j�S)Nr,T)Zcommentsr)�handlerr��shlex�splitrcZcurrentLineZ
dispatcher)rN�liner\r2r2r3�
handleLine<s
zAnacondaSection.handleLinecCstj|||�dS)z.Process the arguments to the %anaconda header.N)r%�handleHeader)rNrIr\r2r2r3r�FszAnacondaSection.handleHeadercCstj|�dS)z0Let %anaconda know no additional data will come.N)r%�finalize)rNr2r2r3r�JszAnacondaSection.finalize)
rUrVrWrX�sectionOpenr[r�r�r�r`r2r2)r^r3r�4s
r�)/ZauthZ
authconfigZ
authselectZautopartZbtrfsZ
bootloaderZcdromZ	clearpartZeulaZfcoeZfirewallZ	firstboot�groupZ	harddriveZhmcZ
ignorediskZiscsiZ	iscsinameZkeyboardZlangZloggingZlogvol�methodZmountZnetworkZnfsZnvdimm�partrsZraidZrealmZreqpartZrhsmZrootpwZselinuxZservicesZsshkeyZskipxZsnapshotZ
syspurposeZtimezoneZurl�userZvolgroupZxconfigZzerombrZzfcpcs.eZdZeZd�fdd�	Z�fdd�Z�ZS)�AnacondaKSHandlerNc	s�|dkrg}|dkrt}|dkr$t}t�j||d�i�_i}xf|D]^\}}tjjtjjtjj	|���}tjj
|�svqDtj||�fdd��}|rD|d|d�||<qDWt
|��_t��_dS)N)�commandUpdates�dataUpdatescst|�j�S)N)�
issubclass�AddonClassType)rh)rNr2r3�<lambda>�sz,AnacondaKSHandler.__init__.<locals>.<lambda>r)rw)r�r�rZr[ZonPartr=rBrFrC�abspath�isdirrZcollectr
�addonsr��anaconda)	rNZaddon_pathsr�r�r�Zmodule_namerBZaddon_id�classes)r^)rNr3r[�s&
zAnacondaKSHandler.__init__cs>tj�}|j�j�}t�j�d|dt|j�t|j�S)N�
z

)	r�	get_proxyZGenerateKickstart�striprZr_r�r�r�)rNr{�modules)r^r2r3r_�szAnacondaKSHandler.__str__)NNN)rUrVrWr	r�r[r_r`r2r2)r^r3r��s%r�cs.eZdZd�fdd�	Zdd�Zdd�Z�ZS)	�AnacondaPreParserTcst�j|dd�dS)NF)�missingIncludeIsFatal)rZr[)rNr��followIncludes�errorsAreFatalr�)r^r2r3r[�szAnacondaPreParser.__init__cCsdS)Nr2)rNrIr\r2r2r3�
handleCommand�szAnacondaPreParser.handleCommandcCs�|jt|jtd��|jt|jdd��|jt|jdd��|jt|jdd��|jt|jdd��|jt|jdd��|jt|jdd��|jt|jjd	d��dS)
N)�dataObjz%pre-install)r�z%postz%onerrorz
%tracebackz	%packagesz%addonz	%anaconda)�registerSectionr!r�r5rr�)rNr2r2r3�
setupSections�szAnacondaPreParser.setupSections)TTT)rUrVrWr[r�r�r`r2r2)r^r3r��sr�cs6eZdZdddef�fdd�	Zdd�Zdd�Z�ZS)�AnacondaKSParserTcs||_t�j|�dS)N)�scriptClassrZr[)rNr�r�r�r�r�)r^r2r3r[�szAnacondaKSParser.__init__cCs|js
dStj|||�S)N)r�rr�)rNrIr\r2r2r3r��szAnacondaKSParser.handleCommandcCs�|jt|j|jd��|jt|j|jd��|jt|j|jd��|jt|j|jd��|jt|j|jd��|jt|j��|jt	|j��|jt
|jj��dS)N)r�)r�r!r�r�r"r r$r#rrr�r�)rNr2r2r3r��szAnacondaKSParser.setupSections)rUrVrWr5r[r�r�r`r2r2)r^r3r��sr�c	Cs6tt��}t��|j|�WdQRXt|jj�dS)N)r�r�r4�
readKickstart�
runPreScriptsr��scripts)�f�ksparserr2r2r3�
preScriptPass�s
r�FcsXt|�}g�tj�d��fdd�	}y�tj���|t_tjdtd�|r�tj�}tj	|j
|��}x|jD]}tj|j
t�qfW|j�s�djtt|j��}	t|	��|j|��r�ttd��x�D]}
tt|
�j��q�W|r�td��WdQRXWndtk
�rR}zFtj|�ttd�t|�j��tjt�tjd	�tj d
�WYdd}~XnXdS)Ncs*�||||||�t|t�r&�j|�dS)N)r�r�append)�message�category�filenamerI�filer�)�
kswarnings�showwarningr2r3�
ksshowwarning�s
z%parseKickstart.<locals>.ksshowwarning�always)r�z

z:
Some warnings occurred during reading the kickstart file:zVPlease modify your kickstart file to fix the warnings or remove the `ksstrict` option.z[
An error occurred during reading the kickstart file:
%s

The installer will now terminate.�
r,)NN)!r��warningsr��catch_warnings�simplefilterrrr�rZfrom_structureZReadKickstartFileZwarning_messages�warnr�Zis_validrK�mapr�Zerror_messagesrr�r-rr��parsing_logrHrr.r�timeZsleepr/r0)r�r�Zstrict_modeZpass_to_bossr�r�ZbossZreportr�r�r8r1r2)r�r�r3�parseKickstart�s>





r�cCsXd}x4ttjd��D]"}t|d�}||j�7}|j�qWt|td�}|j|dd�dS)Nr7z$/usr/share/anaconda/post-scripts/*ksr;)r�F)�reset)r��globrJ�readr@r�rYZreadKickstartFromString)Zksdatar��fnr�r�r2r2r3�appendPostScripts1s
r�cCsRdd�|D�}t|�dkrdStjd�x|D]}|jtjj�q.Wtjd�dS)NcSsg|]}|jtkr|�qSr2)�typer)�.0�sr2r2r3�
<listcomp>Csz"runPostScripts.<locals>.<listcomp>rz"Running kickstart %%post script(s)z,All kickstart %%post script(s) have been run)rlrG�inforTr�targetZsystem_root)r�ZpostScriptsr+r2r2r3�runPostScriptsBs

r�cCs\dd�|D�}t|�dkrdStjd�tjtd��x|D]}|jd�q<Wtjd�dS)NcSsg|]}|jtkr|�qSr2)r�r)r�r�r2r2r3r�Osz!runPreScripts.<locals>.<listcomp>rz!Running kickstart %%pre script(s)z Running pre-installation scriptsr6z+All kickstart %%pre script(s) have been run)rlrGr��	stdoutLogrrT)r�Z
preScriptsr+r2r2r3r�Ns

r�cCsNdd�|D�}t|�dkrdStjd�x|D]}|jd�q.Wtjd�dS)NcSsg|]}|jtkr|�qSr2)r�r)r�r�r2r2r3r�^sz(runPreInstallScripts.<locals>.<listcomp>rz)Running kickstart %%pre-install script(s)r6z3All kickstart %%pre-install script(s) have been run)rlrGr�rT)r�ZpreInstallScriptsr+r2r2r3�runPreInstallScripts]s

r�cCs:tjd�x tdd�|�D]}|jd�qWtjd�dS)Nz'Running kickstart %%traceback script(s)cSs
|jtkS)N)r�r)r�r2r2r3r�msz%runTracebackScripts.<locals>.<lambda>r6z1All kickstart %%traceback script(s) have been run)rGr��filterrT)r�r+r2r2r3�runTracebackScriptsks
r�)FF)er�r=Zos.path�abcrr�r/r<r�r��
contextlibrZpyanaconda.corerZ&pyanaconda.core.configuration.anacondarZpyanaconda.core.kickstartrrZCOMMANDSZpyanaconda.addonsrr	r
Zpyanaconda.core.constantsrZpyanaconda.errorsrr
Zpyanaconda.flagsrZpyanaconda.core.i18nrZ,pyanaconda.modules.common.constants.servicesrZ.pyanaconda.modules.common.structures.kickstartrZpyanaconda.pwpolicyrrZpykickstart.baserrZpykickstart.constantsrrrrZpykickstart.errorsrrZpykickstart.parserrrZKSScriptZpykickstart.sectionsrrr r!r"r#r$r%Zpykickstart.versionr&Z
pyanacondar'Zpyanaconda.anaconda_loggersr(r)r*rUrbr�ZgetChildrGr�r4r5rYrarfZEularjror�r�r�r�Z
superclassr�r�r�r�r�r�r�r�r�r�r2r2r2r3�<module>s�(

<
=".
<