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/states/__pycache__/glassfish.cpython-310.pyc
o

�N�g6U�@s�dZddlZddlmZzddlZdZWneydZYnwdd�Zdd	�Z	d
d�Z
d,dd
�Zd,dd�Z												d-dd�Z
d.dd�Z	d/dd�Zd,dd�Z			 	!				"	#							d0d$d%�Zd.d&d'�Zd,d(d)�Zd,d*d+�ZdS)1a)
Manage Glassfish/Payara server
.. versionadded:: 2016.11.0

Management of glassfish using its RESTful API
You can setup connection parameters like this

.. code-block:: yaml

    - server:
      - ssl: true
      - url: localhost
      - port: 4848
      - user: admin
      - password: changeit
�N)�CommandExecutionErrorTFcCsdtvrtrdSdS)z4
    Only load if glassfish module is available
    zglassfish.enum_connector_c_poolT)Fz$glassfish module could not be loaded)�__salt__�HAS_LIBS�rr�I/opt/saltstack/salt/lib/python3.10/site-packages/salt/states/glassfish.py�__virtual__srcCsVi}|��D]"\}}t|t�s$t|t�rt|�||<qt|���||<q|||<q|S)z@
    Encode json values in unicode to match that of the API
    )�items�
isinstance�str�dict�_json_to_unicode�lower)�data�ret�key�valuerrrr&s


rcCs�i}ttjj�tjjj|dd���}tjj�tjjj|dd��}|��D]/\}}t|���}||vr:t||���}|dksB|dkrDd}||vrS||krS||d�||<q$|S)z?
    Compare the API results to the current statefile data
    F)�ensure_ascii�nullZnone�)�old�new)	r�salt�utils�json�loads�dumpsrr
r
)Zold_confZnew_conf�changedrrZoldvalZnewvalrrr�_is_updated6s"���rc	
Cs�idddd�}z
td|���}Wn0tjyA}z#tdr1||d�|d<d|d	<|WYd}~Sd
|d<|WYd}~Sd}~ww|rH||vr�||d�|d<d|d	<tds�ztd|��|fd
|i|��W|Sty�}z||d<|WYd}~Sd}~ww|S|r�t|�r�td|��||d�}t||�}|r�d|d<||d<tds�ztd|��|fd
|i|��W|Sty�}z||d<WYd}~|Sd}~ww|S)z9
    Generic function to create or update an element
    FN)�changes�update�create�error�glassfish.enum_�test)�NameZParamsrTr �Can't connect to the serverr!zglassfish.create_�serverzglassfish.get_�r&rzglassfish.update_)r�requests�ConnectionError�__opts__r�anyr)	�name�	elem_typerr&r�elementsr!Zcurrent_dataZ	data_diffrrr�_do_element_presentOs^��	 ����
������r/c
Cs�ddd�}z
td|���}Wn)tjy8}ztdr(d|d<|WYd}~Sd|d	<|WYd}~Sd}~ww|rq||vrqd|d
<tdsqztd|��|fd|i|��W|Styp}z||d	<WYd}~|Sd}~ww|S)
z/
    Generic function to delete an element
    FN)�deleter!r"r#Tr r%r!r0zglassfish.delete_r&�rr(r)r*r)r,r-rr&rr.r!rrr�_do_element_absentxs.
�� ���r2�connection_factoryr����,�<c
Cs4|ddid�}
i}i}|�d�}|dkrd|d<n|dkr"d|d<n|d	kr+d
|d<n
d|
d<d
|
d<|
S||d<||d<||d<||d<||d<||d<||d<||d<|d|d<|	|d<|
r�|
dkrjd|d<n|
dkrsd|d<n|
dkr|d|d<n
d|
d<d |
d<|
S||d!<t|d"||�}t|d#||�}|d$�s|d$�std%s�d&|
d<|d's�|d'r�|d(|
d(d)<|d(|
d(d*<td%r�d+|
d<|
Sd,|
d<|
S|d-s�|d-r�|d(|
d(d)<|d(|
d(d*<td%r�d.|
d<|
Sd/|
d<|
Sd&|
d<i|
d(<d0|
d<|
Sd|
d<d1�|d$|d$�|
d<|
S)2a:
    Ensures that the Connection Factory is present

    name
        Name of the connection factory

    restype
        Type of the connection factory, can be either ``connection_factory``,
        ``queue_connection_factory` or ``topic_connection_factory``,
        defaults to ``connection_factory``

    description
        Description of the connection factory

    enabled
        Is the connection factory enabled? defaults to ``true``

    min_size
        Minimum and initial number of connections in the pool, defaults to ``1``

    max_size
        Maximum number of connections that can be created in the pool, defaults to ``250``

    resize_quantity
        Number of connections to be removed when idle_timeout expires, defaults to ``2``

    idle_timeout
        Maximum time a connection can remain idle in the pool, in seconds, defaults to ``300``

    wait_timeout
        Maximum time a caller can wait before timeout, in seconds, defaults to ``60``

    reconnect_on_failure
        Close all connections and reconnect on failure (or reconnect only when used), defaults to ``false``
    transaction_support
        Level of transaction support, can be either ``XATransaction``, ``LocalTransaction`` or ``NoTransaction``

    connection_validation
        Connection validation is required, defaults to ``false``
    N�r,�result�commentr�-Connection-PoolZtopic_connection_factoryz javax.jms.TopicConnectionFactoryZconnectionDefinitionNameZqueue_connection_factoryz javax.jms.QueueConnectionFactoryr3zjavax.jms.ConnectionFactoryFr:�Invalid restyper;�description�enabled�poolName�steadyPoolSize�maxPoolSize�poolResizeQuantity�idleTimeoutInSeconds���maxWaitTimeInMillisZfailAllConnectionsZxa_transactionZ
XATransactionZtransactionSupportZlocal_transactionZLocalTransactionZno_transactionZ
NoTransactionzInvalid transaction_supportZisConnectionValidationRequired�connector_c_poolZconnector_resourcer!r#Tr r�pool�resourcez$Connection factory set to be createdzConnection factory createdrz$Connection factory set to be updatedzConnection factory updatedz(Connection factory is already up-to-date�ERROR: {} // {}�r/r*�format)r,�restyper>r?�min_size�max_size�resize_quantity�idle_timeout�wait_timeoutZreconnect_on_failureZtransaction_supportZconnection_validationr&r�	pool_data�res_data�	pool_name�pool_ret�res_retrrr�connection_factory_present�s|7






���	��rXcCs�|ddid�}|�d�}t|dd|i|�}|ds?tdr'|dr'd	|d
<|S|dr5d|d<d
|d
<|Sd|d<d|d
<|Sd|d<d�|d�|d
<|S)z�
    Ensures the transaction factory is absent.

    name
        Name of the connection factory

    both
        Delete both the pool and the resource, defaults to ``true``
    Nr9r<rG�cascader!r#r0z$Connection Factory set to be deletedr;Tr:zConnection Factory deletedz Connection Factory doesn't existF�	Error: {}�r2r*rL)r,�bothr&rrUrVrrr�connection_factory_absents&

�
���r]�queuec	CsF|ddid�}i}|dkrd|d<d|d<n|dkr#d	|d<d
|d<n
d|d<d
|d<|Sd|i|d<||d<||d<t|d||�}|ds�tdsNd|d<|dr\tdr\d|d<|S|drl|d|d<d|d<|S|drztdrzd|d<|S|dr�|d|d<d|d<|Sd|d<d|d<|Sd|d<d�|d�|d<|S) a|
    Ensures that the JMS Destination Resource (queue or topic) is present

    name
        The JMS Queue/Topic name

    physical
        The Physical destination name

    restype
        The JMS Destination resource type, either ``queue`` or ``topic``, defaults is ``queue``

    description
        A description of the resource

    enabled
        Defaults to ``True``
    Nr9r^zjavax.jms.Queue�resTypezcom.sun.messaging.QueueZ	classNameZtopiczjavax.jms.Topiczcom.sun.messaging.TopicFr:r=r;r$�
propertiesr>r?�admin_object_resourcer!r#Tr zJMS Queue set to be createdrzJMS queue createdrzJMS Queue set to be updatedzJMS Queue updatedzJMS Queue already up-to-datezError from API: {}rK)	r,ZphysicalrMr>r?r&r�params�jms_retrrr�destination_present.sL

��
���rdcCs�|ddid�}t|di|�}|ds8tdr |dr d|d<|S|dr.d	|d
<d|d<|Sd	|d
<d|d<|Sd
|d
<d�|d�|d<|S)zg
    Ensures that the JMS Destination doesn't exists

    name
        Name of the JMS Destination
    Nr9rar!r#r0zJMS Queue set to be deletedr;Tr:zJMS Queue deletedzJMS Queue doesn't existFrZr[)r,r&rrcrrr�destination_absentls 
���re�
datasource�mysql�� cCsv|ddid�}d|��}i}i}i}|dkrd|d<n|dkr$d|d<n|d	kr-d
|d<n|dkr5d|d<i}d
dddd�|d<ddddd�|d<ddddd�|d<|dkr_||d|d<n||||d<||d<||d <||d!<||d"<||d#<||d#<||d$<||d%<||d&<|	|d'<|
|d(<||d)<|d*|d+<|
|d,<||d-<||d.<t|d/||�}t|d0||�}|d1�s)|d1�s)td2s�d3|d4<|d5s�|d5r�|d6|d6d7<|d6|d6d8<td2r�d9|d:<|Sd;|d:<|S|d<s�|d<�r|d6|d6d7<|d6|d6d8<td2�rd=|d:<|Sd>|d:<|Sd3|d4<i|d6<d?|d:<|Sd@|d4<dA�|d1|d1�|d:<|S)Bas
    Ensures that the JDBC Datasource exists

    name
        Name of the datasource

    description
        Description of the datasource

    enabled
        Is the datasource enabled? defaults to ``true``

    restype
        Resource type, can be ``datasource``, ``xa_datasource``,
        ``connection_pool_datasource`` or ``driver``, defaults to ``datasource``

    vendor
        SQL Server type, currently supports ``mysql``,
        ``postgresql`` and ``mssql``, defaults to ``mysql``

    sql_url
        URL of the server in jdbc form

    sql_user
        Username for the server

    sql_password
        Password for that username

    min_size
        Minimum and initial number of connections in the pool, defaults to ``8``

    max_size
        Maximum number of connections that can be created in the pool, defaults to ``32``

    resize_quantity
        Number of connections to be removed when idle_timeout expires, defaults to ``2``

    idle_timeout
        Maximum time a connection can remain idle in the pool, in seconds, defaults to ``300``

    wait_timeout
        Maximum time a caller can wait before timeout, in seconds, defaults to ``60``

    non_transactional
        Return non-transactional connections

    transaction_isolation
        Defaults to the JDBC driver default

    isolation_guaranteed
        All connections use the same isolation level
    Nr9zjdbc/rfzjavax.sql.DataSourcer_�
xa_datasourcezjavax.sql.XADataSource�connection_pool_datasourcez"javax.sql.ConnectionPoolDataSource�driverzjavax.sql.Driverzcom.mysql.jdbc.Driverz-com.mysql.jdbc.jdbc2.optional.MysqlDataSourcez/com.mysql.jdbc.jdbc2.optional.MysqlXADataSourcez;com.mysql.jdbc.jdbc2.optional.MysqlConnectionPoolDataSource)rlrfrjrkrgzorg.postgresql.Driverz$org.postgresql.ds.PGSimpleDataSourcez org.postgresql.xa.PGXADataSourcez,org.postgresql.ds.PGConnectionPoolDataSourceZ
postgresqlz,com.microsoft.sqlserver.jdbc.SQLServerDriverz0com.microsoft.sqlserver.jdbc.SQLServerDataSourcez2com.microsoft.sqlserver.jdbc.SQLServerXADataSourcez>com.microsoft.sqlserver.jdbc.SQLServerConnectionPoolDataSourceZmssqlZdriverClassnameZdatasourceClassname�url�user�passwordr`r>r@r?rArBrCrDrErFZnonTransactionalConnectionsZtransactionIsolationLevelZisIsolationLevelGuaranteed�jdbc_connection_poolZ
jdbc_resourcer!r#Tr:r rrHrIz!JDBC Datasource set to be createdr;zJDBC Datasource createdrz!JDBC Datasource set to be updatedzJDBC Datasource updatedz%JDBC Datasource is already up-to-dateFrJrK)r,r>r?rM�vendorZsql_urlZsql_userZsql_passwordrNrOrPrQrRZnon_transactionalZtransaction_isolationZisolation_guaranteedr&rZres_namerSZpool_data_propertiesrTZdatasourcesrVrWrrr�jdbc_datasource_present�s�H




�	
�
�	��
�	��rrcCs�|ddid�}t|dd|i|�}|ds:tdr"|dr"d|d	<|S|dr0d
|d<d|d	<|Sd
|d<d
|d	<|Sd|d<d�|d�|d	<|S)z�
    Ensures the JDBC Datasource doesn't exists

    name
        Name of the datasource
    both
        Delete both the pool and the resource, defaults to ``true``
    Nr9rprYr!r#r0z!JDBC Datasource set to be deletedr;Tr:zJDBC Datasource deletedzJDBC Datasource doesn't existFrZr[)r,r\r&rrVrrr�jdbc_datasource_absent*s$	�
���rsc
KsHdddid�}|d=z	td|d�}Wn-tjy@}z tdr0||d<d|d	<|WYd}~Sd
|d<|WYd}~Sd}~ww||d�|d<||ks�|�|�tds�ztd
||d�||d<d|d	<d|d<W|Sty�}z||d<d|d	<WYd}~|Sd}~wwd|d	<||d<d|d<|Si|d<d|d	<d|d<|S)zf
    Ensures that the system properties are present

    properties
        The system properties
    rNr9r,�glassfish.get_system_propertiesr'r#rr:r%r!)r�kwargsz"glassfish.update_system_propertiesTzSystem properties updatedr;Fz)System properties would have been updatedZcomentz(System properties are already up-to-date)rr(r)r*rr)r&rurrr!rrr�system_properties_presentGsJ��	

�	���rvc
Csdddid�}z	td|d�}Wn/tjy?}z"tdr/d|i|d<d|d	<|WYd}~Sd
|d<|WYd}~Sd}~ww||vr�tdsuztd||d�d
|d	<d|d<Wn"tyt}z||d<d|d	<WYd}~n
d}~wwd|d	<d|d<d|i|d<|Sd
|d	<d|d<|S)zg
    Ensures that the system property doesn't exists

    name
        Name of the system property
    rNr9rtr'r#r$rr:r%r!z"glassfish.delete_system_propertiesTzSystem properties deletedr;Fz)System properties would have been deletedz$System properties are already absentr1)r,r&rrr!rrr�system_properties_absentss<��	���rw)N)r3rTr4r5r6r7r8FrFN)TN)r^rTN)rTrfrgrrrrhrir6r7r8FrTN)�__doc__Zsalt.utils.jsonrZsalt.exceptionsrr(r�ImportErrorrrrr/r2rXr]rdrerrrsrvrwrrrr�<module>sh�	

)
�
~ 
�
>
�
'
,