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/runners/__pycache__/asam.cpython-310.pyc
o

�N�g�,�@s�dZddlZdZzddlZddlZdZGdd�dejj�ZWn	e	y'Ynwe�
e�Zdd�Z
dd
d�Zddd
�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�Zdd�ZdS) a
Novell ASAM Runner
==================

.. versionadded:: 2015.8.0

Runner to interact with Novell ASAM Fan-Out Driver

:codeauthor: Nitin Madhok <nmadhok@g.clemson.edu>

To use this runner, set up the Novell Fan-Out Driver URL, username and password in the
master configuration at ``/etc/salt/master`` or ``/etc/salt/master.d/asam.conf``:

.. code-block:: yaml

    asam:
      prov1.domain.com
        username: "testuser"
        password: "verybadpass"
        verify_ssl: true
      prov2.domain.com
        username: "testuser"
        password: "verybadpass"
        verify_ssl: true

.. note::

    Optionally, ``protocol`` and ``port`` can be specified if the Fan-Out Driver server
    is not using the defaults. Default is ``protocol: https`` and ``port: 3451``.

�NFTc@seZdZdd�Zdd�ZdS)�ASAMHTMLParsercCstjj�|�g|_dS)N)�html�parser�
HTMLParser�__init__�data)�self�r	�E/opt/saltstack/salt/lib/python3.10/site-packages/salt/runners/asam.pyr.s
zASAMHTMLParser.__init__cCs<|dkrdS|D]}|ddkrdS|j�|d�qdS)N�arZhref�)r�append)r�tagZattrs�attrr	r	r
�handle_starttag2s�zASAMHTMLParser.handle_starttagN)�__name__�
__module__�__qualname__rrr	r	r	r
r-srcCstsdSt�durdSdS)z�
    Check for ASAM Fan-Out driver configuration in master config file
    or directory and load runner only if it is specified
    FT)�HAS_LIBS�_get_asam_configurationr	r	r	r
�__virtual__Cs

r�c
Cs.dtvrtdnd}|r�ze|��D]^\}}|�dd�}|�dd�}|�dd�}|�dd�}|�d	�}|dur8d
}|r<|sFt�d|�WdSd
�|||�d�|||�d�|||�d�|||�|||d�}	|rj||kro|	WSqWnty�}
z
t�d|
�WYd}
~
dSd}
~
ww|r�t�d|�dSdS)z[
    Return the configuration read from the master configuration
    file or directory
    ZasamN�username�password�protocol�https�porti{
�
verify_sslTzNUsername or Password has not been specified in the master configuration for %sFz#{}://{}:{}/config/PlatformEdit.htmlz%{}://{}:{}/config/PlatformConfig.htmlz&{}://{}:{}/config/PlatformSetEdit.htmlz({}://{}:{}/config/PlatformSetConfig.html)�platform_edit_url�platform_config_urlZplatformset_edit_url�platformset_config_urlrrrzException encountered: %szGConfiguration for %s has not been specified in the master configuration)Z__opts__�items�get�log�error�format�	Exception)Z
driver_urlZasam_configZasam_serverZservice_configrrrrr�ret�excr	r	r
rPsb
������
��,���rcCs:tj||||dd�}|jtjjkr|��dS|j�d�S)N�x)r�auth�verify�timeout�
)�requestsZpostZstatus_codeZcodes�okZraise_for_status�text�split)�urlrr*r+�rr	r	r
�_make_post_request�sr4cCs4t�}|D]}|�d�r|�|�q|�|�q|S)Nz<META)r�
startswith�remove�feed)�html_contentr�liner	r	r
�_parse_html_content�s
r:cCsT|D]%}||vr'|�d�r'|�d�}|D]}|�d�r&|�d�dSqqdS)N�PlatformEdit.html?�&�platformSetName�=r)r5r1)rZ
platform_name�item�parameter_list�	parameterr	r	r
�_get_platformset_name�s

��rBcCsZg}|D]&}|�d�r*|�dd�d�d�}|D]}|�d�r)|�|�d�d�qq|S)Nr;rr<�platformNamer>)r5r1r
)r�
platform_listr?r@rAr	r	r
�_get_platforms�s

�rEcCsbg}|D]*}|�d�r.|�dd�d�d�}|D]}|�d�r-|�|�d�d�dd��qq|S)NzPlatformSetEdit.html?rr<r=r>z%20� )r5r1r
�replace)r�platform_set_listr?r@rAr	r	r
�_get_platform_sets�s

��rIc
Cstt|�}|sdS|d}ddi}|d|df}zt||||dd�}Wn"tyF}zd	|��}t�d
||�||iWYd}~Sd}~wwt|�}	t|	j|�}
|
r�t�|
�||d<t	|
�|d
<d|d<d|d<zt||||dd�}Wn"ty�}zd|��}t�d
||�||iWYd}~Sd}~wwt|�}	t|	j|�}
|
r�|d|��iS|d|��iS|d|��iS)z�
    To remove specified ASAM platform from the Novell Fan-Out Driver

    CLI Example:

    .. code-block:: bash

        salt-run asam.remove_platform my-test-vm prov1.domain.com
    Fr�manual�falserrr�r+z(Failed to look up existing platforms on �%s:
%sNrCr=ZplatformRemove�postTypeZYes�SubmitzFailed to delete platform from z#Successfully deleted platform from z*Specified platform name does not exist on )
rr4r&r#r$r:rBr�debug�str)�name�
server_url�configr2rr*r8r(�err_msgrZplatformset_namer	r	r
�remove_platform�sN
�
��

�
��rVc

C�t|�}|sdS|d}ddi}|d|df}zt||||dd�}WntyC}zd	}t�d
||�||iWYd}~Sd}~wwt|�}t|j�}	|	rS||	iS|diS)
z�
    To list all ASAM platforms present on the Novell Fan-Out Driver

    CLI Example:

    .. code-block:: bash

        salt-run asam.list_platforms prov1.domain.com
    FrrJrKrrrrLz$Failed to look up existing platformsrMNzNo existing platforms found)rr4r&r#r$r:rEr)
rSrTr2rr*r8r(rUrrDr	r	r
�list_platforms�(
���
rXc

CrW)
z�
    To list all ASAM platform sets present on the Novell Fan-Out Driver

    CLI Example:

    .. code-block:: bash

        salt-run asam.list_platform_sets prov1.domain.com
    Fr rJrKrrrrLz(Failed to look up existing platform setsrMNzNo existing platform sets found)rr4r&r#r$r:rIr)
rSrTr2rr*r8r(rUrrHr	r	r
�list_platform_sets+rYrZc
Cst|�}|sdSt|�}|||vr|d|��iSt|�}|||vr*|d|��iS|d}||ddddd	�}|d
|df}zt||||dd
�}	Wn"tym}
zd|��}t�d||
�||iWYd}
~
Sd}
~
wwt|�}|||vr|d|��iS|d|��iS)z�
    To add an ASAM platform using the specified ASAM platform set on the Novell
    Fan-Out Driver

    CLI Example:

    .. code-block:: bash

        salt-run asam.add_platform my-test-vm test-platform-set prov1.domain.com
    Fz%Specified platform already exists on z)Specified platform set does not exist on rrKz/config/platformAdd.htmlZPlatformAddZApply)rCr=rJZpreviousURLrNrOrrrrLzFailed to add platform on rMNzSuccessfully added platform on )rrXrZr4r&r#r$)rRZplatform_setrSrTZ	platformsZ
platform_setsr2rr*r8r(rUr	r	r
�add_platformQs<�	
��r[)r)T)�__doc__�loggingrZhtml.parserrr.rrr�ImportError�	getLoggerrr#rrr4r:rBrErIrVrXrZr[r	r	r	r
�<module>s. �


D9&&