HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.30
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/__pycache__/jboss7.cpython-310.pyc
o

�N�g�P�@sdZddlZddlZddlmmZddlmZe�e	�Z
ddiZd/dd�Zd0dd	�Z
d0d
d�Zd0dd�Zd
d�Zdd�Zdd�Zd0dd�Zd0dd�Zd0dd�Zd0dd�Zd0dd�Zd0dd�Zd0dd �Z	d0d!d"�Zd0d#d$�Zd%d&�Zd0d'd(�Zd)d*�Zd+d,�Zd-d.�Z dS)1a�
Module for managing JBoss AS 7 through the CLI interface.

.. versionadded:: 2015.5.0

In order to run each function, jboss_config dictionary with the following properties must be passed:
 * cli_path: the path to jboss-cli script, for example: '/opt/jboss/jboss-7.0/bin/jboss-cli.sh'
 * controller: the IP address and port of controller, for example: 10.11.12.13:9999
 * cli_user: username to connect to jboss administration console if necessary
 * cli_password: password to connect to jboss administration console if necessary

Example:

.. code-block:: yaml

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

�N)�SaltInvocationError�reload_�reloadcCs\t�d�|dur|durd}n|dur |dur dj||d�}ntd��td||dd	d
�S)a�
    Get status of running jboss instance.

    jboss_config
        Configuration dictionary with properties specified above.
    host
        The name of the host. JBoss domain mode only - and required if running in domain mode.
        The host name is the "name" attribute of the "host" element in host.xml
    server_config
        The name of the Server Configuration. JBoss Domain mode only - and required
        if running in domain mode.

    CLI Example:

    .. code-block:: bash

        salt '*' jboss7.status '{"cli_path": "integration.modules.sysmod.SysModuleTest.test_valid_docs", "controller": "10.11.12.13:9999", "cli_user": "jbossadm", "cli_password": "jbossadm"}'

    z7======================== MODULE FUNCTION: jboss7.statusNz":read-attribute(name=server-state)zK/host="{host}"/server-config="{server_config}"/:read-attribute(name=status))�host�
server_configzKInvalid parameters. Must either pass both host and server_config or neither�jboss7_cli.run_operationFr)�
fail_on_errorZretries)�log�debug�formatr�__salt__)�jboss_configrr�	operation�r�G/opt/saltstack/salt/lib/python3.10/site-packages/salt/modules/jboss7.py�status#s
���rcCsjt�d�|durd}nd|�d�}td||dd�}|d	s)|d	s+d
|dvr+|Stdjd
i|����)a$
    Stop running jboss instance

    jboss_config
        Configuration dictionary with properties specified above.
    host
        The name of the host. JBoss domain mode only - and required if running in domain mode.
        The host name is the "name" attribute of the "host" element in host.xml

    CLI Example:

    .. code-block:: bash

        salt '*' jboss7.stop_server '{"cli_path": "integration.modules.sysmod.SysModuleTest.test_valid_docs", "controller": "10.11.12.13:9999", "cli_user": "jbossadm", "cli_password": "jbossadm"}'

    z<======================== MODULE FUNCTION: jboss7.stop_serverNz	:shutdown�/host="z"/:shutdownrF�r�success� Operation failed: Channel closed�stdout�QCannot handle error, return code={retcode}, stdout='{stdout}', stderr='{stderr}' r�r	r
r�	Exceptionr)r
rrZshutdown_resultrrr�stop_serverHs"
����rcCsvt�d�|durd}nd|�d�}td||dd�}|d	s/|d	s1d
|dvs/d|dvr1|Std
jdi|����)a!
    Reload running jboss instance

    jboss_config
        Configuration dictionary with properties specified above.
    host
        The name of the host. JBoss domain mode only - and required if running in domain mode.
        The host name is the "name" attribute of the "host" element in host.xml

    CLI Example:

    .. code-block:: bash

        salt '*' jboss7.reload '{"cli_path": "integration.modules.sysmod.SysModuleTest.test_valid_docs", "controller": "10.11.12.13:9999", "cli_user": "jbossadm", "cli_password": "jbossadm"}'

    z7======================== MODULE FUNCTION: jboss7.reloadNz:reloadrz	"/:reloadrFrrrrzNCommunication error: java.util.concurrent.ExecutionException: Operation failedrrr)r
rrZ
reload_resultrrrros(
�����cCsXt�d||�t|||�}dj|t||�d�}|dur#d|�d�|}td||dd	�S)
aQ
    Create datasource in running jboss instance

    jboss_config
        Configuration dictionary with properties specified above.
    name
        Datasource name
    datasource_properties
        A dictionary of datasource properties to be created:
          - 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
    profile
        The profile name (JBoss domain mode only)

    CLI Example:

    .. code-block:: bash

        salt '*' jboss7.create_datasource '{"cli_path": "integration.modules.sysmod.SysModuleTest.test_valid_docs", "controller": "10.11.12.13:9999", "cli_user": "jbossadm", "cli_password": "jbossadm"}' 'my_datasource' '{"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}'
    zW======================== MODULE FUNCTION: jboss7.create_datasource, name=%s, profile=%sz=/subsystem=datasources/data-source="{name}":add({properties}))�nameZ
propertiesN�
/profile="�"rFr)r	r
�%__get_datasource_resource_descriptionr�"__get_properties_assignment_stringr)r
r�datasource_properties�profile�ds_resource_descriptionrrrr�create_datasource�s&�����r#cCs:g}|d}|��D]
\}}|�t|||��q
d�|�S)N�
attributes�,)�items�append�__get_single_assignment_string�join)r r"Zassignment_strings�
ds_attributes�key�valrrrr�s
�
rcCs|�dt|||���S)N�=)�__format_value)r+r,r*rrrr(�sr(cCs~||d}|dkr#|dvr|St|t�r|rdSdStd|�d���|dkr+t|�S|d	kr5d
|�d
�Std|�d|����)
N�typeZBOOLEAN)�true�falser0r1zDon't know how to convert z to BOOLEAN typeZINT�STRINGrzDon't know how to format value z	 of type )�
isinstance�boolr�str)r+�valuer*Ztype_rrrr.�s
r.c
Cs�t�d||�t|||�}|d}t�||�}|��}ddd�}t|�dkrYt|||�}	|	d}
|D]&}t||||||
|�}|dsXd	|d<|d
d�	||||d�|d
<q2|S)
a�
    Update an existing datasource in running jboss instance.
    If the property doesn't exist if will be created, if it does, it will be updated with the new value

    jboss_config
        Configuration dictionary with properties specified above.
    name
        Datasource name
    new_properties
        A dictionary of datasource properties to be updated. For example:
          - 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
    profile
        The profile name (JBoss domain mode only)

    CLI Example:

    .. code-block:: bash

        salt '*' jboss7.update_datasource '{"cli_path": "integration.modules.sysmod.SysModuleTest.test_valid_docs", "controller": "10.11.12.13:9999", "cli_user": "jbossadm", "cli_password": "jbossadm"}' 'my_datasource' '{"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}'

    zW======================== MODULE FUNCTION: jboss7.update_datasource, name=%s, profile=%s�resultT�)r�commentrr$rFr9zCCould not update datasource property {} with value {},
 stdout: {}
r)
r	r
�__read_datasource�
dictdifferZ
DictDiffer�changed�lenr�__update_datasource_propertyr)
r
rZnew_propertiesr!Z	ds_resultZcurrent_properties�diffZchanged_properties�retr"r*r+Z
update_resultrrr�update_datasource�s<�
������rAcCsTt�d||�dj|d�}|durd|�d�|}td||�}|dr(|dSdS)	Nzk======================== MODULE FUNCTION: jboss7.__get_datasource_resource_description, name=%s, profile=%szE/subsystem=datasources/data-source="{name}":read-resource-description�rrrr�outcomer7)r	r
rr�r
rr!rZoperation_resultrrrr,s����rcCst�d|�t|||�S)a�
    Read datasource properties in the running jboss instance.

    jboss_config
        Configuration dictionary with properties specified above.
    name
        Datasource name
    profile
        Profile name (JBoss domain mode only)

    CLI Example:

    .. code-block:: bash

        salt '*' jboss7.read_datasource '{"cli_path": "integration.modules.sysmod.SysModuleTest.test_valid_docs", "controller": "10.11.12.13:9999", "cli_user": "jbossadm", "cli_password": "jbossadm"}'
    zI======================== MODULE FUNCTION: jboss7.read_datasource, name=%s)r	r
r:)r
rr!rrr�read_datasource@s
�rEcC�Ht�d|||�dj|t|�d�}|durd|�d�|}td||�S)a�
    Create a simple jndi binding in the running jboss instance

    jboss_config
        Configuration dictionary with properties specified above.
    binding_name
        Binding name to be created
    value
        Binding value
    profile
        The profile name (JBoss domain mode only)

    CLI Example:

    .. code-block:: bash

        salt '*' jboss7.create_simple_binding \
                '{"cli_path": "integration.modules.sysmod.SysModuleTest.test_valid_docs", \
                "controller": "10.11.12.13:9999", "cli_user": "jbossadm", "cli_password": "jbossadm"}' \
                my_binding_name my_binding_value
       zm======================== MODULE FUNCTION: jboss7.create_simple_binding, binding_name=%s, value=%s, profile=%szT/subsystem=naming/binding="{binding_name}":add(binding-type=simple, value="{value}")��binding_namer6Nrrr�r	r
r�__escape_binding_valuer�r
rHr6r!rrrr�create_simple_bindingXs���rLcCrF)aM
    Update the simple jndi binding in the running jboss instance

    jboss_config
        Configuration dictionary with properties specified above.
    binding_name
        Binding name to be updated
    value
        New binding value
    profile
        The profile name (JBoss domain mode only)

    CLI Example:

    .. code-block:: bash

        salt '*' jboss7.update_simple_binding '{"cli_path": "integration.modules.sysmod.SysModuleTest.test_valid_docs", "controller": "10.11.12.13:9999", "cli_user": "jbossadm", "cli_password": "jbossadm"}' my_binding_name my_binding_value
    zm======================== MODULE FUNCTION: jboss7.update_simple_binding, binding_name=%s, value=%s, profile=%szW/subsystem=naming/binding="{binding_name}":write-attribute(name=value, value="{value}")rGNrrrrIrKrrr�update_simple_binding�s���rMcCst�d|�t|||d�S)a

    Read jndi binding in the running jboss instance

    jboss_config
        Configuration dictionary with properties specified above.
    binding_name
        Binding name to be created
    profile
        The profile name (JBoss domain mode only)

    CLI Example:

        .. code-block:: bash

        salt '*' jboss7.read_simple_binding '{"cli_path": "integration.modules.sysmod.SysModuleTest.test_valid_docs", "controller": "10.11.12.13:9999", "cli_user": "jbossadm", "cli_password": "jbossadm"}' my_binding_name
    zH======================== MODULE FUNCTION: jboss7.read_simple_binding, %s)r!)r	r
�__read_simple_binding)r
rHr!rrr�read_simple_binding�s
�rOcCs2dj|d�}|durd|�d�|}td||�S)Nz8/subsystem=naming/binding="{binding_name}":read-resource)rHrrr�rr)r
rHr!rrrrrN�s�rNcCsTt�d||||�dj||t|||�d�}|dur!d|�d�|}td||dd�S)	Nz�======================== MODULE FUNCTION: jboss7.__update_datasource_property, datasource_name=%s, name=%s, value=%s, profile=%szc/subsystem=datasources/data-source="{datasource_name}":write-attribute(name="{name}",value={value}))�datasource_namerr6rrrFr)r	r
rr.r)r
rQrr6r*r!rrrrr>�s"�	
��r>cCs6dj|d�}|durd|�d�|}td||�}|S)Nz9/subsystem=datasources/data-source="{name}":read-resourcerBrrrrPrDrrrr:�s�r:cCs|�dd�}|S)N�\z\\\\)�replace)rHr7rrrrJ�srJcCsDt�d||�d|�d�}|durd|�d�|}td||dd	�S)
a
    Remove an existing datasource from the running jboss instance.

    jboss_config
        Configuration dictionary with properties specified above.
    name
        Datasource name
    profile
        The profile (JBoss domain mode only)

    CLI Example:

    .. code-block:: bash

        salt '*' jboss7.remove_datasource '{"cli_path": "integration.modules.sysmod.SysModuleTest.test_valid_docs", "controller": "10.11.12.13:9999", "cli_user": "jbossadm", "cli_password": "jbossadm"}' my_datasource_name
    zW======================== MODULE FUNCTION: jboss7.remove_datasource, name=%s, profile=%sz#/subsystem=datasources/data-source=z:removeNrrrFr�r	r
r)r
rr!rrrr�remove_datasource�s��rUcCs*t�d|�d|�d�}td||dd�S)a�
    Deploy the application on the jboss instance from the local file system where minion is running.

    jboss_config
        Configuration dictionary with properties specified above.
    source_file
        Source file to deploy from

    CLI Example:

    .. code-block:: bash

        salt '*' jboss7.deploy '{"cli_path": "integration.modules.sysmod.SysModuleTest.test_valid_docs", "controller": "10.11.12.13:9999", "cli_user": "jbossadm", "cli_password": "jbossadm"}' /opt/deploy_files/my_deploy
    zG======================== MODULE FUNCTION: jboss7.deploy, source_file=%szdeploy z	 --force �jboss7_cli.run_commandFrrT)r
Zsource_file�commandrrr�deploys��rXcCsLt�d�td|d�}g}t|d�dkrt�d|d�}t�d|�|S)a�
    List all deployments on the jboss instance

    jboss_config
        Configuration dictionary with properties specified above.

     CLI Example:

     .. code-block:: bash

         salt '*' jboss7.list_deployments '{"cli_path": "integration.modules.sysmod.SysModuleTest.test_valid_docs", "controller": "10.11.12.13:9999", "cli_user": "jbossadm", "cli_password": "jbossadm"}'

    zA======================== MODULE FUNCTION: jboss7.list_deploymentsrVrXrrz\s*zdeployments=%s)r	r
rr=�re�split)r
Zcommand_resultZdeploymentsrrr�list_deployments-s
r[cCs&t�d|�d|�d�}td||�S)a�
    Undeploy the application from jboss instance

    jboss_config
        Configuration dictionary with properties specified above.
    deployment
        Deployment name to undeploy

    CLI Example:

    .. code-block:: bash

        salt '*' jboss7.undeploy '{"cli_path": "integration.modules.sysmod.SysModuleTest.test_valid_docs", "controller": "10.11.12.13:9999", "cli_user": "jbossadm", "cli_password": "jbossadm"}' my_deployment
    zH======================== MODULE FUNCTION: jboss7.undeploy, deployment=%sz	undeploy � rVrT)r
Z
deploymentrWrrr�undeployDs�r])NN)N)!�__doc__�loggingrYZsalt.utils.dictdiffer�utilsr;Zsalt.exceptionsr�	getLogger�__name__r	Z__func_alias__rrrr#rr(r.rArrErLrMrOrNr>r:rJrUrXr[r]rrrr�<module>s:


%
'
+2

<


(
%

�

!