%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python2.7/site-packages/salt/runners/
Upload File :
Create Path :
Current File : //lib/python2.7/site-packages/salt/runners/asam.pyo

�
���^c@@sdZddlmZmZmZddlZddljjZe	Z
y<ddlZddlm
Z
eZ
de
fd��YZWnek
r�nXeje�Zd�Zdd	�Zed
�Zd�Zd�Zd
�Zd�Zd�Zd�Zd�Zd�ZdS(u�
Novell ASAM Runner
==================

.. versionadded:: Beryllium

Runner to interact with Novell ASAM Fan-Out Driver

:codeauthor: Nitin Madhok <nmadhok@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"
      prov2.domain.com
        username: "testuser"
        password: "verybadpass"

.. 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``.

i(tabsolute_importtprint_functiontunicode_literalsN(t
HTMLParsertASAMHTMLParsercB@seZd�Zd�ZRS(cC@stj|�g|_dS(N(Rt__init__tdata(tself((s5/usr/lib/python2.7/site-packages/salt/runners/asam.pyR.s
cC@sM|dkrdSx6|D].}|ddkr1dS|jj|d�qWdS(Nuaiuhrefi(Rtappend(Rttagtattrstattr((s5/usr/lib/python2.7/site-packages/salt/runners/asam.pythandle_starttag2s
(t__name__t
__module__RR(((s5/usr/lib/python2.7/site-packages/salt/runners/asam.pyR-s	cC@s!ts
tSt�tkrtStS(u�
    Check for ASAM Fan-Out driver configuration in master config file
    or directory and load runner only if it is specified
    (tHAS_LIBStFalset_get_asam_configurationtTrue(((s5/usr/lib/python2.7/site-packages/salt/runners/asam.pyt__virtual__@s
uc
C@s{dtkrtdnd}|rwyx
tj|�D]�\}}|jdd�}|jdd�}|jdd�}|jdd�}|s�|r�tjd|�tSid	j|||�d
6dj|||�d6d
j|||�d6dj|||�d6|d6|d6}|s*||kr5|Sq5WWn$t	k
rY}	tjd|	�tSX|rwtjd|�tSntS(u[
    Return the configuration read from the master configuration
    file or directory
    uasamuusernameupassworduprotocoluhttpsuporti{
uNUsername or Password has not been specified in the master configuration for %su&{0}://{1}:{2}/config/PlatformEdit.htmluplatform_edit_urlu({0}://{1}:{2}/config/PlatformConfig.htmluplatform_config_urlu){0}://{1}:{2}/config/PlatformSetEdit.htmluplatformset_edit_urlu+{0}://{1}:{2}/config/PlatformSetConfig.htmluplatformset_config_urluException encountered: %suGConfiguration for %s has not been specified in the master configurationN(
t__opts__tNonetsixt	iteritemstgettlogterrorRtformatt	Exception(
t
driver_urltasam_configtasam_servertservice_configtusernametpasswordtprotocoltporttrettexc((s5/usr/lib/python2.7/site-packages/salt/runners/asam.pyRMs>
cC@sWtj|d|d|d|�}|jtjjkrC|j�n|jjd�SdS(NRtauthtverifyu
(trequeststposttstatus_codetcodestoktraise_for_statusttexttsplit(turlRR'R(tr((s5/usr/lib/python2.7/site-packages/salt/runners/asam.pyt_make_post_request|s!
cC@sJt�}x:|D]2}|jd�r5|j|�q|j|�qW|S(Nu<META(Rt
startswithtremovetfeed(thtml_contenttparsertline((s5/usr/lib/python2.7/site-packages/salt/runners/asam.pyt_parse_html_content�s	
cC@ssxl|D]d}||kr|jd�r|jd�}x1|D]&}|jd�r>|jd�dSq>WqqWdS(NuPlatformEdit.html?u&uplatformSetNameu=i(R4R0R(Rt
platform_nametitemtparameter_listt	parameter((s5/usr/lib/python2.7/site-packages/salt/runners/asam.pyt_get_platformset_name�s

cC@s�g}x||D]t}|jd�r
|jdd�djd�}x=|D]2}|jd�rH|j|jd�d�qHqHWq
q
W|S(NuPlatformEdit.html?iu&uplatformNameu=(R4R0R(Rt
platform_listR<R=R>((s5/usr/lib/python2.7/site-packages/salt/runners/asam.pyt_get_platforms�s

(cC@s�g}x�|D]�}|jd�r
|jdd�djd�}xI|D]>}|jd�rH|j|jd�djdd��qHqHWq
q
W|S(NuPlatformSetEdit.html?iu&uplatformSetNameu=u%20u (R4R0Rtreplace(Rtplatform_set_listR<R=R>((s5/usr/lib/python2.7/site-packages/salt/runners/asam.pyt_get_platform_sets�s

4cC@s�t|�}|stS|d}idd6}|d|df}yt|||dt�}Wn=tk
r�}dj|�}tjd||�i||6SXt|�}	t|	j	|�}
|
r�tj
|
�||d	<tj|
�|d
<d|d<d
|d<yt|||dt�}Wn=tk
rZ}dj|�}tjd||�i||6SXt|�}	t|	j	|�}
|
r�idj|�|6Sidj|�|6Snidj|�|6SdS(u�
    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
    uplatform_config_urlufalseumanualuusernameupasswordR(u+Failed to look up existing platforms on {0}u%s:
%suplatformNameuplatformSetNameuplatformRemoveupostTypeuYesuSubmitu"Failed to delete platform from {1}u"Failed to delete platform from {0}u&Successfully deleted platform from {0}u-Specified platform name does not exist on {0}N(
RRR3RRRRR:R?RtdebugRt	text_type(tnamet
server_urltconfigR1RR'R7R&terr_msgR8tplatformset_name((s5/usr/lib/python2.7/site-packages/salt/runners/asam.pytremove_platform�sD







c
C@s�t|�}|stS|d}idd6}|d|df}yt|||dt�}Wn4tk
r�}d}tjd||�i||6SXt|�}t|j�}	|	r�i|	|6Sid	|6Sd
S(u�
    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
    uplatform_config_urlufalseumanualuusernameupasswordR(u$Failed to look up existing platformsu%s:
%suNo existing platforms foundN(	RRR3RRRR:RAR(
RHRIR1RR'R7R&RJR8R@((s5/usr/lib/python2.7/site-packages/salt/runners/asam.pytlist_platforms�s&



c
C@s�t|�}|stS|d}idd6}|d|df}yt|||dt�}Wn4tk
r�}d}tjd||�i||6SXt|�}t|j�}	|	r�i|	|6Sid	|6Sd
S(u�
    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
    uplatformset_config_urlufalseumanualuusernameupasswordR(u(Failed to look up existing platform setsu%s:
%suNo existing platform sets foundN(	RRR3RRRR:RDR(
RHRIR1RR'R7R&RJR8RC((s5/usr/lib/python2.7/site-packages/salt/runners/asam.pytlist_platform_setss&



cC@sht|�}|stSt|�}|||krFidj|�|6St|�}|||krvidj|�|6S|d}i|d6|d6dd6dd	6d
d6dd
6}|d|df}yt|||dt�}	Wn=tk
r}
dj|�}tjd||
�i||6SXt|�}|||krPidj|�|6Sidj|�|6SdS(u�
    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
    u(Specified platform already exists on {0}u,Specified platform set does not exist on {0}uplatform_edit_urluplatformNameuplatformSetNameufalseumanualu/config/platformAdd.htmlupreviousURLuPlatformAddupostTypeuApplyuSubmituusernameupasswordR(uFailed to add platform on {0}u%s:
%su"Successfully added platform on {0}N(	RRRMRRNR3RRR(RGtplatform_setRHRIt	platformst
platform_setsR1RR'R7R&RJ((s5/usr/lib/python2.7/site-packages/salt/runners/asam.pytadd_platform>s:


(t__doc__t
__future__RRRtloggingtsalt.ext.sixtextRRRR)tsalt.ext.six.moves.html_parserRRRtImportErrort	getLoggerR
RRRR3R:R?RARDRLRMRNRR(((s5/usr/lib/python2.7/site-packages/salt/runners/asam.pyt<module>s.

	
/					:	)	)

Zerion Mini Shell 1.0