%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /usr/lib/python2.7/site-packages/salt/modules/
Upload File :
Create Path :
Current File : //usr/lib/python2.7/site-packages/salt/modules/solarispkg.pyc

�
���^c@@s)dZddlmZmZmZddlZddlZddlZddlZ	ddl
Z	ddlZ	ddlZ	ddl
mZmZeje�ZdZd�Zd�Zed�Zd	�Ze	jjjed
�Zd�Zd�Zddd
d�Z ddd
d�Z!ddd�Z"dS(u
Package support for Solaris

.. important::
    If you feel that Salt should be using this module to manage packages on a
    minion, and it is using a different module (or gives an error similar to
    *'pkg.install' is not available*), see :ref:`here
    <module-provider-override>`.
i(tabsolute_importtprint_functiontunicode_literalsN(tCommandExecutionErrortMinionErrorupkgcC@s4tddkr*ttd�dkr*tStdfS(u9
    Set the virtual pkg module if the os is Solaris
    u	os_familyuSolarisu
kernelreleasegffffff@uPThe solarispkg execution module failed to load: only available on Solaris <= 10.(t
__grains__tfloatt__virtualname__tFalse(((s;/usr/lib/python2.7/site-packages/salt/modules/solarispkg.pyt__virtual__s&cC@s�|jdd�}|jdd�}|jdd�}|jdd�}|jdd�}|jd	d�}|jd
d�}|jdd�}|jdd�}	|jd
d�}
|jdd�}tjjjdd�}d�}
tjjj|d���}|
|dj|��|
|dj|��|
|dj|��|
|dj|��|
|dj|��|
|dj|��|
|dj|��|
|dj|��|
|dj|	��|
|dj|
��|
|dj|��WdQX|S( u`
    Create a temporary adminfile based on the keyword arguments passed to
    pkg.install.
    uemailuuinstanceuquitupartialunocheckurunleveluidependurdependuspaceusetuiduconflictuactionubasedirudefaulttprefixusalt-cS@s |jtjjj|��dS(N(twritetsalttutilststringutilstto_str(tfp_tline((s;/usr/lib/python2.7/site-packages/salt/modules/solarispkg.pyt_write_line?suwu
email={0}
u
instance={0}
upartial={0}
u
runlevel={0}
uidepend={0}
urdepend={0}
u
space={0}
usetuid={0}
u
conflict={0}
uaction={0}
ubasedir={0}
N(tgetRR
tfilestmkstemptfopentformat(tkwargstemailtinstancetpartialtrunleveltidependtrdependtspacetsetuidtconflicttactiontbasedirt	adminfileRR((s;/usr/lib/python2.7/site-packages/salt/modules/solarispkg.pyt_write_adminfile*s4	c
K@stjjj|�}tgdD]$}tjjj|j|��^q�rPiSdtkr�|rjtdStjtd�}t	d|�|Sni}d}t	d|ddd	t
�j�}x�t|�D]r\}}|d
dkr|j
�dj�}n|d
dkr�|j
�dj�}	t	d
|||	�q�q�Wt	d|�tj|�td<|s{t	d|�n|S(u�
    List the packages currently installed as a dict:

    .. code-block:: python

        {'<package_name>': '<version>'}

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.list_pkgs
    uremovedu
purge_desiredu
pkg.list_pkgsupkg_resource.stringifyu/usr/bin/pkginfo -xucmd.runtoutput_loglevelutracetpython_shelliiiupkg_resource.add_pkgupkg_resource.sort_pkglist(uremovedu
purge_desired(RR
tdatatis_truetanyRt__context__tcopytdeepcopyt__salt__Rt
splitlinest	enumeratetsplittstrip(
tversions_as_listRtxtrettcmdtlinestindexRtnametversion_num((s;/usr/lib/python2.7/site-packages/salt/modules/solarispkg.pyt	list_pkgsRs61cO@s]|jdt�i}|s dSx|D]}d||<q'Wt|�dkrY||dS|S(u�
    Return the latest version of the named package available for upgrade or
    installation. If more than one package name is specified, a dict of
    name/version pairs is returned.

    If the latest version of a given package is already installed, an empty
    string will be returned for that package.

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.latest_version <package name>
        salt '*' pkg.latest_version <package1> <package2> <package3> ...

    NOTE: As package repositories are not presently supported for Solaris
    pkgadd, this function will always return an empty string for a given
    package.
    urefreshuii(tpoptTruetlen(tnamesRR5R9((s;/usr/lib/python2.7/site-packages/salt/modules/solarispkg.pytlatest_version�s
uavailable_versioncC@st|�dkS(u�
    Check whether or not an upgrade is available for a given package

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.upgrade_available <package name>
    u(R@(R9((s;/usr/lib/python2.7/site-packages/salt/modules/solarispkg.pytupgrade_available�s
cO@std||�S(uY
    Returns a string representing the package version or an empty string if not
    installed. If more than one package name is specified, a dict of
    name/version pairs is returned.

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.version <package name>
        salt '*' pkg.version <package1> <package2> <package3> ...
    upkg_resource.version(R.(R?R((s;/usr/lib/python2.7/site-packages/salt/modules/solarispkg.pytversion�s
ubasec
K@sAtjjj|jd��r.tjd�n|jdd�}y#t	d||||�\}}Wnt
k
r�}t|��nX|dks�t|�dkr�iS|s�tj
d�iSzAd|kr�t	d|d|�}nt|�}t�}	d	d
d|g}
|jd�d
kr0|
d7}
ng}xk|D]c}|
d|dg}
t	d|
dddt�}|ddkr=|dr=|j|d�q=q=Wtjdd�t�}tjjj|	|�}|r�tddi|d6|d6��nWdd|kr<ytj|�Wq<ttfk
r8q<XnX|S(u�
    Install the passed package. Can install packages from the following
    sources:

    * Locally (package already exists on the minion
    * HTTP/HTTPS server
    * FTP server
    * Salt master

    Returns a dict containing the new package names and versions:

    .. code-block:: python

        {'<package>': {'old': '<old-version>',
                       'new': '<new-version>'}}

    CLI Examples:

    .. code-block:: bash

        # Installing a data stream pkg that already exists on the minion

        salt '*' pkg.install sources='[{"<pkg name>": "/dir/on/minion/<pkg filename>"}]'
        salt '*' pkg.install sources='[{"SMClgcc346": "/var/spool/pkg/gcc-3.4.6-sol10-sparc-local.pkg"}]'

        # Installing a data stream pkg that exists on the salt master

        salt '*' pkg.install sources='[{"<pkg name>": "salt://pkgs/<pkg filename>"}]'
        salt '*' pkg.install sources='[{"SMClgcc346": "salt://pkgs/gcc-3.4.6-sol10-sparc-local.pkg"}]'

    CLI Example:

    .. code-block:: bash

        # Installing a data stream pkg that exists on a HTTP server
        salt '*' pkg.install sources='[{"<pkg name>": "http://packages.server.com/<pkg filename>"}]'
        salt '*' pkg.install sources='[{"SMClgcc346": "http://packages.server.com/gcc-3.4.6-sol10-sparc-local.pkg"}]'

    If working with solaris zones and you want to install a package only in the
    global zone you can pass 'current_zone_only=True' to salt to have the
    package only installed in the global zone. (Behind the scenes this is
    passing '-G' to the pkgadd command.) Solaris default when installing a
    package in the global zone is to install it in all zones. This overrides
    that and installs the package only in the global.

    CLI Example:

    .. code-block:: bash

        # Installing a data stream package only in the global zone:
        salt 'global_zone' pkg.install sources='[{"SMClgcc346": "/var/spool/pkg/gcc-3.4.6-sol10-sparc-local.pkg"}]' current_zone_only=True

    By default salt automatically provides an adminfile, to automate package
    installation, with these options set::

        email=
        instance=quit
        partial=nocheck
        runlevel=nocheck
        idepend=nocheck
        rdepend=nocheck
        space=nocheck
        setuid=nocheck
        conflict=nocheck
        action=nocheck
        basedir=default

    You can override any of these options in two ways. First you can optionally
    pass any of the options as a kwarg to the module/state to override the
    default value or you can optionally pass the 'admin_source' option
    providing your own adminfile to the minions.

    Note: You can find all of the possible options to provide to the adminfile
    by reading the admin man page:

    .. code-block:: bash

        man -s 4 admin

    CLI Example:

    .. code-block:: bash

        # Overriding the 'instance' adminfile option when calling the module directly
        salt '*' pkg.install sources='[{"<pkg name>": "salt://pkgs/<pkg filename>"}]' instance="overwrite"

    SLS Example:

    .. code-block:: yaml

        # Overriding the 'instance' adminfile option when used in a state

        SMClgcc346:
          pkg.installed:
            - sources:
              - SMClgcc346: salt://srv/salt/pkgs/gcc-3.4.6-sol10-sparc-local.pkg
            - instance: overwrite

    .. note::
        The ID declaration is ignored, as the package name is read from the
        ``sources`` parameter.

    CLI Example:

    .. code-block:: bash

        # Providing your own adminfile when calling the module directly

        salt '*' pkg.install sources='[{"<pkg name>": "salt://pkgs/<pkg filename>"}]' admin_source='salt://pkgs/<adminfile filename>'

        # Providing your own adminfile when using states

        <pkg name>:
          pkg.installed:
            - sources:
              - <pkg name>: salt://pkgs/<pkg filename>
            - admin_source: salt://pkgs/<adminfile filename>

    .. note::
        The ID declaration is ignored, as the package name is read from the
        ``sources`` parameter.
    urefreshu8'refresh' argument not implemented for solarispkg moduleupkgsupkg_resource.parse_targetsiu5"sources" param required for solaris pkg_add installsuadmin_sourceu
cp.cache_fileu/usr/sbin/pkgaddu-nu-aucurrent_zone_onlyuTrueu-G u-duallucmd.run_allR&utraceR'uretcodeustderru
pkg.list_pkgsu)Problem encountered installing package(s)tinfouerrorsuchangesN(RR
R(R)RtlogtwarningR<tNoneR.RRR>terrorR%R;RtappendR+t
compare_dictstostremovet	NameErrortOSError(R9tsourcestsaltenvRtpkgst
pkg_paramstpkg_typetexcR$toldt
cmd_prefixterrorstpkgR6touttnewR5((s;/usr/lib/python2.7/site-packages/salt/modules/solarispkg.pytinstall�sT{
	


		c	K@s�ytd||�d}Wntk
r<}t|��nXt�}g|D]}||krM|^qM}|suiSz�d|kr�td|d|�}	nt|�}	ddd|	g|}
td|
d	td
d�}|ddkr|d
r|d
g}ng}tjdd�t�}
t	j
jj||
�}|rftddi|d6|d6��nWdd|kr�yt
j|	�Wq�ttfk
r�q�XnX|S(uu
    Remove packages with pkgrm

    name
        The name of the package to be deleted

    By default salt automatically provides an adminfile, to automate package
    removal, with these options set::

        email=
        instance=quit
        partial=nocheck
        runlevel=nocheck
        idepend=nocheck
        rdepend=nocheck
        space=nocheck
        setuid=nocheck
        conflict=nocheck
        action=nocheck
        basedir=default

    You can override any of these options in two ways. First you can optionally
    pass any of the options as a kwarg to the module/state to override the
    default value or you can optionally pass the 'admin_source' option
    providing your own adminfile to the minions.

    Note: You can find all of the possible options to provide to the adminfile
    by reading the admin man page:

    .. code-block:: bash

        man -s 4 admin


    Multiple Package Options:

    pkgs
        A list of packages to delete. Must be passed as a python list. The
        ``name`` parameter will be ignored if this option is passed.

    .. versionadded:: 0.16.0


    Returns a dict containing the changes.

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.remove <package name>
        salt '*' pkg.remove SUNWgit
        salt '*' pkg.remove <package1>,<package2>,<package3>
        salt '*' pkg.remove pkgs='["foo", "bar"]'
    upkg_resource.parse_targetsiuadmin_sourceu
cp.cache_fileu/usr/sbin/pkgrmu-nu-aucmd.run_allR'R&utraceuretcodeustderru
pkg.list_pkgsu'Problem encountered removing package(s)RCuerrorsuchangesN(R.RRR;R%RR+R<RFRR
R(RIRJRKRLRM(R9RPRORRQRSRTR4ttargetsR$R6RXRVRYR5((s;/usr/lib/python2.7/site-packages/salt/modules/solarispkg.pyRK�s@7	%
		cK@std|d||�S(u\
    Package purges are not supported, this function is identical to
    ``remove()``.

    name
        The name of the package to be deleted


    Multiple Package Options:

    pkgs
        A list of packages to delete. Must be passed as a python list. The
        ``name`` parameter will be ignored if this option is passed.

    .. versionadded:: 0.16.0


    Returns a dict containing the changes.

    CLI Example:

    .. code-block:: bash

        salt '*' pkg.purge <package name>
        salt '*' pkg.purge <package1>,<package2>,<package3>
        salt '*' pkg.purge pkgs='["foo", "bar"]'
    R9RP(RK(R9RPR((s;/usr/lib/python2.7/site-packages/salt/modules/solarispkg.pytpurge�s(#t__doc__t
__future__RRRR,RJtloggingtsalt.utils.dataRtsalt.utils.functoolstsalt.utils.filestsalt.utils.stringutilstsalt.exceptionsRRt	getLoggert__name__RDRR	R%RR;R@R
t	functoolstalias_functiontavailable_versionRARBRFRZRKR\(((s;/usr/lib/python2.7/site-packages/salt/modules/solarispkg.pyt<module>
s*		(4	#	
	�g

Zerion Mini Shell 1.0