%PDF- %PDF-
Mini Shell

Mini Shell

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

�
���^c@@s-dZddlmZmZmZddlZddlZddlZddlZddl	j
jZddlm
Z
ddlmZeje�Zedd�Zd�Zd�Zdd	�Zdd
�Zdd�Zd�Zdd
�Zd�Zddd�Zded�Z dd�Z!d�Z"dS(ub
Manage JBoss 7 Application Server via CLI interface

.. versionadded:: 2015.5.0

This state uses the jboss-cli.sh script from a JBoss or Wildfly installation and parses its output to determine the execution result.

In order to run each state, a jboss_config dictionary with the following properties must be passed:

.. code-block:: yaml

   jboss:
      cli_path: '/opt/jboss/jboss-7.0/bin/jboss-cli.sh'
      controller: 10.11.12.13:9999
      cli_user: 'jbossadm'
      cli_password: 'jbossadm'

If the controller doesn't require a password, then the cli_user and cli_password parameters are optional.

Since same dictionary with configuration will be used in all the states, it may be more convenient to move JBoss configuration and other properties
to the pillar.

Example of application deployment from local filesystem:

.. code-block:: yaml

     application_deployed:
       jboss7.deployed:
         - salt_source:
             target_file: '/tmp/webapp.war'
         - jboss_config: {{ pillar['jboss'] }}

For the sake of brevity, examples for each state assume that jboss_config is contained in the pillar.


i(tabsolute_importtprint_functiontunicode_literalsN(tCommandExecutionError(tsixc	C@s�tjd|�i|d6td6id6dd6}t}i}tdd|d	|d
|�}|dr|d}|r�tdd|d	|d
|�}	|	dr�||dd
<n t|d<d|	d|d<|St}tdd|d	|d|d
|�}
|
dr||dd<n t|d<d|
d|d<|Stdd|d	|d
|�}|drm|d}qt|d<d|d|d<|Sq�tdd|d	|d|d
|�}
|
ds�t|d<d|
d|d<n
d|d<tdd|d	|d
|�}|d}n�|ddkr�tdd|d	|d|d
|�}
|
dr�tdd|d	|d
|�}|d}d|d<q�t|d<d|
d|d<ntdj|d���|dr�tjd|�tjd|�tj||�}|j	�}t
|�d kr>t}t|||�|dd!<n|j�}t
|�d krt}t|||�|dd
<n|j
�}t
|�d kr�t}t|||�|dd"<n|s�d#|d<q�n|S($u�
    Ensures that a datasource with given properties exist on the jboss instance.
    If datasource doesn't exist, it is created, otherwise only the properties that are different will be updated.

    name
        Datasource property name
    jboss_config
        Dict with connection properties (see state description)
    datasource_properties
        Dict with datasource properties
    recreate : False
        If set to True and datasource exists it will be removed and created again. However, if there are deployments that depend on the datasource, it will not me possible to remove it.
    profile : None
        The profile name for this datasource (domain mode only)

    Example:

    .. code-block:: yaml

        sampleDS:
          jboss7.datasource_exists:
           - recreate: False
           - datasource_properties:
               driver-name: mysql
               connection-url: 'jdbc:mysql://localhost:3306/sampleDatabase'
               jndi-name: 'java:jboss/datasources/sampleDS'
               user-name: sampleuser
               password: secret
               min-pool-size: 3
               use-java-context: True
           - jboss_config: {{ pillar['jboss'] }}
           - profile: full-ha

    uE ======================== STATE: jboss7.datasource_exists (name: %s) unameuresultuchangesuucommentujboss7.read_datasourcetjboss_configtnametprofileusuccessujboss7.remove_datasourceuremovedu%Could not remove datasource. Stdout: ustdoutujboss7.create_datasourcetdatasource_propertiesucreatedu%Could not create datasource. Stdout: u#Could not read datasource. Stdout: ujboss7.update_datasourcetnew_propertiesuCould not update datasource. uDatasource updated.uerr_codeu
JBAS014807uDatasource created.uUnable to handle error: {0}ufailure-descriptionuds_new_properties=%suds_current_properties=%siuaddeduchangeduDatasource not changed.(tlogtdebugtTruetFalset__salt__Rtformatt
dictdiffertdifftaddedtlent__format_ds_changestremovedtchanged(RRRtrecreateRtretthas_changedtds_current_propertiest	ds_resultt
remove_resultt
create_resulttread_resulttds_new_propertiest
update_resultRRRR((s6/usr/lib/python2.7/site-packages/salt/states/jboss7.pytdatasource_exists8s�#





%




%



%




cC@s�tjd|||�d}x�|D]�}tjd|�||kr�||kr�||dt||�dt||�d7}q#||kr�||d7}q#||kr#||dt||�d7}q#q#W|S(Nu6__format_ds_changes(keys=%s, old_dict=%s, new_dict=%s)uukey=%su:u->u
(R
Rt__get_ds_value(tkeystold_dicttnew_dicttchangestkey((s6/usr/lib/python2.7/site-packages/salt/states/jboss7.pyR�s
3&cC@sItjd|�|dkr dS||dkr4dStj||�SdS(Nu__get_value(dict,%s)upasswordu***u	undefined(R
RtNoneRt	text_type(tdctR'((s6/usr/lib/python2.7/site-packages/salt/states/jboss7.pyR"�sc
C@s�tjd||�tjd|�i|d6td6id6dd6}t}xN|D]F}tj||�}tdd	|d
|d|�}|dr|dd
}	|	|kr�tdd	|d|d
|d|�}
|
drt}t|dd|||	�qt|
d��q�qR|ddkr�tdd	|d|d
|d|�}|drut}t|dd||�q�t|d��qRt|d��qRW|r�d|d<n|S(u�
    Ensures that given JNDI binding are present on the server.
    If a binding doesn't exist on the server it will be created.
    If it already exists its value will be changed.

    jboss_config:
        Dict with connection properties (see state description)
    bindings:
        Dict with bindings to set.
    profile:
        The profile name (domain mode only)

    Example:

    .. code-block:: yaml

            jndi_entries_created:
              jboss7.bindings_exist:
               - bindings:
                  'java:global/sampleapp/environment': 'DEV'
                  'java:global/sampleapp/configurationFile': '/var/opt/sampleapp/config.properties'
               - jboss_config: {{ pillar['jboss'] }}

    uP ======================== STATE: jboss7.bindings_exist (name: %s) (profile: %s) ubindings=%sunameuresultuchangesuBindings not changed.ucommentujboss7.read_simple_bindingtbinding_nameRRusuccessuvalueujboss7.update_simple_bindingtvalueuchangedufailure-descriptionuerr_codeu
JBAS014807ujboss7.create_simple_bindinguaddeduBindings changed.(	R
RRR
RR)Rt__log_binding_changeR(RRtbindingsRRRR'R,tquery_resultt
current_valueR R((s6/usr/lib/python2.7/site-packages/salt/states/jboss7.pytbindings_exist�s8



%
%

cC@sl||krd||<n|dkrD||c|d|d7<n$||c|d|d|d7<dS(Nuu:u
u->(R((R&ttype_R'tnewtold((s6/usr/lib/python2.7/site-packages/salt/states/jboss7.pyR-s

c
C@s�tjd|�i|d6td6id6dd6}d}t||�\}}|s`t||�St|�\}}tjd|�tjd|�td	|d
|�}|dkr�t||�St||�\}	}
}|	s�t||�Stjd|
�|
dk	r)t	d||
�|
|dd
<nt	dd|d|�}tjd|�|dr�td	dd
|�}||d<||dd<n+td	dj
|�d
|�}t||�S|S(u\	Ensures that the given application is deployed on server.

    jboss_config:
        Dict with connection properties (see state description)
    salt_source:
        How to find the artifact to be deployed.
            target_file:
                Where to look in the minion's file system for the artifact to be deployed (e.g. '/tmp/application-web-0.39.war').  When source is specified,  also specifies where to save the retrieved file.
            source:
                (optional) File on salt master (e.g. salt://application-web-0.39.war).  If absent, no files will be retrieved and the artifact in target_file will be used for the deployment.
            undeploy:
                (optional) Regular expression to match against existing deployments.  When present, if there is a deployment that matches the regular expression, it will be undeployed before the new artifact is deployed.

    Examples:

    Deployment of a file from minion's local file system:

    .. code-block:: yaml

        application_deployed:
          jboss7.deployed:
            - salt_source:
                target_file: '/tmp/webapp.war'
            - jboss_config: {{ pillar['jboss'] }}

    It is assumed that /tmp/webapp.war was made available by some
    other means.  No applications will be undeployed; if an existing
    deployment that shares that name exists, then it will be replaced
    with the updated version.

    Deployment of a file from the Salt master's file system:

    .. code-block:: yaml

        application_deployed:
          jboss7.deployed:
           - salt_source:
                source: salt://application-web-0.39.war
                target_file: '/tmp/application-web-0.39.war'
                undeploy: 'application-web-.*'
           - jboss_config: {{ pillar['jboss'] }}

    Here, application-web-0.39.war file is downloaded from Salt file system to /tmp/application-web-0.39.war file on minion.
    Existing deployments are checked if any of them matches 'application-web-.*' regular expression, and if so then it
    is undeployed before deploying the application. This is useful to automate deployment of new application versions.

    If the source parameter of salt_source is specified, it can use
    any protocol that the file states use.  This includes not only
    downloading from the master but also HTTP, HTTPS, FTP,
    Amazon S3, and OpenStack Swift.

    u< ======================== STATE: jboss7.deployed (name: %s) unameuresultuchangesuucommenturesolved_source=%suget_artifact_comment=%stnew_commenttcurrent_commentu
deployment=%sujboss7.undeployu
undeployedu
jboss7.deployRtsource_fileudeploy_result=%susuccessuDeployment completed.udeployeduJDeployment failed
return code={retcode}
stdout='{stdout}'
stderr='{stderr}N(R
RRt__validate_argumentst_errort__get_artifactt__append_commentR(t__find_deploymentRR(
RRtsalt_sourceRtcommenttvalidate_successtvalidate_commenttresolved_sourcetget_artifact_commenttfind_successt
deploymenttfind_commentt
deploy_result((s6/usr/lib/python2.7/site-packages/salt/states/jboss7.pytdeployeds>5







cC@smt|dddg�\}}|dkrBt}td|�}nt|ddg||�\}}||fS(Nujboss_configucli_pathu
controlleruNo salt_source definedusalt_sourceutarget_file(t__check_dict_containsR(R
R;(RR=tresultR>((s6/usr/lib/python2.7/site-packages/salt/states/jboss7.pyR8ps!cC@s�d}t}d}td|�}|dk	r�d|kr�|dr�tj|d�}x]|D]R}|j|�r^|dk	r�t}dj|ddj|��}q�|}q^q^Wn|||fS(Nuujboss7.list_deploymentsuundeployu�More than one deployment matches regular expression: {0}. 
For deployments from Salt file system deployments on JBoss are searched to find one that matches regular expression in 'undeploy' parameter.
Existing deployments: {1}u,(	R(RRtretcompiletmatchR
Rtjoin(RR=RItsuccessR>tdeploymentst
deployment_reRD((s6/usr/lib/python2.7/site-packages/salt/states/jboss7.pyR<ys"
c!C@s�d}d}|dkr.tjd�d}n�t|t�r�tjd�d|kr�ytdd|dddd	|dd
dddddd
ddddddtdddddtdd�\}}}tdd|dd|ddd	|dd|ddd
ddddddtdddtdddtdddd�}|drW|d}n
|d}Wq�t	k
r�}tjt
j��d j|�}q�Xq�|d}d!}n||fS("Nusalt_source == NoneuNo salt_source definedufile from salt masterusourceufile.get_managedRutarget_filettemplatetsourcetsource_hashtsource_hash_nametusertgrouptmodetattrstsaltenvtcontexttdefaultstskip_verifytkwargsufile.manage_filetsfnRt
source_sumtbackuptmakedirst	show_difftcontentstdir_modeuresultucommentuUnable to manage file: {0}u(
R(R
Rt
isinstancetdictRt__env__R
Rt	Exceptiont	tracebackt
format_excR(R=RAR>R^R_tcomment_t
manage_resultte((s6/usr/lib/python2.7/site-packages/salt/states/jboss7.pyR:�sd
	






	


	i<icC@s�tjd|�i|d6td6id6dd6}td|�}|ds]|ddkrut|d<d|d<|Std|�}|ds�d
|dks�d|dkr�d}d}x^|dks�|ds�|dd	kr||krtj|�||7}td|�}q�W|dr[|dd	kr[t|d<d|d<d|dd<q�t|d<dj|�|d<|ds�t	d|d�|d<q�t	dj|d�|d�|d<nt|d<d|d|d<|S(u�
    Reloads configuration of jboss server.

    jboss_config:
        Dict with connection properties (see state description)
    timeout:
        Time to wait until jboss is back in running state. Default timeout is 60s.
    interval:
        Interval between state checks. Default interval is 5s. Decreasing the interval may slightly decrease waiting time
        but be aware that every status check is a call to jboss-cli which is a java process. If interval is smaller than
        process cleanup time it may easily lead to excessive resource consumption.

    This step performs the following operations:

    * Ensures that server is in running or reload-required state (by reading server-state attribute)
    * Reloads configuration
    * Waits for server to reload and be in running state

    Example:

    .. code-block:: yaml

        configuration_reloaded:
           jboss7.reloaded:
            - jboss_config: {{ pillar['jboss'] }}
    u< ======================== STATE: jboss7.reloaded (name: %s) unameuresultuchangesuucommentu
jboss7.statususuccessurunningureload-requiredu`Cannot reload server configuration, it should be up and in 'running' or 'reload-required' state.u
jboss7.reloadu Operation failed: Channel closedustdoutuNCommunication error: java.util.concurrent.ExecutionException: Operation failediuConfiguration reloadedu
configurationureloadedu>Could not reload the configuration. Timeout ({0} s) exceeded. u&Could not connect to JBoss controller.uServer is in {0} stateu+Could not reload the configuration, stdout:(urunningureload-requiredN(
R
RRRR
R(ttimetsleepRR;(RRttimeouttintervalRtstatusRIt	wait_time((s6/usr/lib/python2.7/site-packages/salt/states/jboss7.pytreloaded�s@




6





'
ucC@sTxG|D]?}|tj|�krt}tdj||�|�}qqW||fS(NuMissing {0} in {1}(RtiterkeysR
R;R(R*t	dict_nameR#R>RIR'((s6/usr/lib/python2.7/site-packages/salt/states/jboss7.pyRHs

"cC@sH|dkr|dkrdS|dkr,|S|dkr<|S|d|S(Nuu
(R((R5R6((s6/usr/lib/python2.7/site-packages/salt/states/jboss7.pyR;scC@st|d<||d<|S(Nuresultucomment(R
(Rterr_msg((s6/usr/lib/python2.7/site-packages/salt/states/jboss7.pyR9"s

(#t__doc__t
__future__RRRRntloggingRJRitsalt.utils.dictdiffertutilsRtsalt.exceptionsRtsalt.extRt	getLoggert__name__R
R
R(R!RR"R1R-RGR8R<R:RtRRHR;R9(((s6/usr/lib/python2.7/site-packages/salt/states/jboss7.pyt<module>%s,{		
=	_			?D

Zerion Mini Shell 1.0