%PDF- %PDF-
Mini Shell

Mini Shell

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

�
���^c@@sdZddlmZmZmZddlZddlZddlZddlZ	ddl
mZddlm
Z
ddlmZyddlZeZWnek
r�eZnXeje�Zd�Zdd	�Zd
d�Zd�Zd
�Zd�Zd�Zdd�ZdS(ua
Wrapper around Server Density API
=================================

.. versionadded:: 2014.7.0
i(tabsolute_importtunicode_literalstprint_functionN(tCommandExecutionError(tsix(tmapcC@ststdfSdS(uZ
    Return virtual name of the module.

    :return: The virtual name of the module.
    u-The requests python module cannot be importeduserverdensity_device(tENABLEDtFalse(((sE/usr/lib/python2.7/site-packages/salt/modules/serverdensity_device.pyt__virtual__ s
u
serverdensitycC@s�tj|�}tjd|�|sMtjd|�tdj|���ny||SWn6tk
r�tjd|�tdj|���nXdS(u�
    Returns requested Server Density authentication value from pillar.

    CLI Example:

    .. code-block:: bash

        salt '*' serverdensity_device.get_sd_auth <val>
    uServer Density Pillar: %suCould not load %s pillaru){0} pillar is required for authenticationu!Could not find value %s in pillaru!{0} value was not found in pillarN(t
__pillar__tgettlogtdebugterrorRtformattKeyError(tvaltsd_auth_pillar_namet	sd_pillar((sE/usr/lib/python2.7/site-packages/salt/modules/serverdensity_device.pytget_sd_auth+s

u__cC@sBttt|jg|D]}|j|�r|^q���|S(uM
    Pops out variables from params which starts with `variable_prefix`.
    (tlistRtpopt
startswith(tparamstvariable_prefixtk((sE/usr/lib/python2.7/site-packages/salt/modules/serverdensity_device.pyt_clean_salt_variablesDs>cK@s�tjd|�t|�}||d<tjdditd�d6d|�}tjd|�tjd	|j�|jd
kr�ytj	j
j|j�SWq�tk
r�tj
d|j�tdj|���q�Xnd
Sd
S(ua
    Function to create device in Server Density. For more info, see the `API
    docs`__.

    .. __: https://apidocs.serverdensity.com/Inventory/Devices/Creating

    CLI Example:

    .. code-block:: bash

        salt '*' serverdensity_device.create lama
        salt '*' serverdensity_device.create rich_lama group=lama_band installedRAM=32768
    uServer Density params: %sunameu/https://api.serverdensity.io/inventory/devices/Ru	api_tokenutokentdatauServer Density API Response: %su'Server Density API Response content: %si�u(Could not parse API Response content: %su#Failed to create, API Response: {0}N(RRRtrequeststpostRtcontenttstatus_codetsalttutilstjsontloadst
ValueErrorR
RRtNone(tnameRtapi_response((sE/usr/lib/python2.7/site-packages/salt/modules/serverdensity_device.pytcreateLs"
	
cC@s�tjd|ditd�d6�}tjd|�tjd|j�|jdkr�ytjj	j
|j�SWq�tk
r�tjd|j�t
d	j|���q�Xnd
Sd
S(u
    Delete a device from Server Density. For more information, see the `API
    docs`__.

    .. __: https://apidocs.serverdensity.com/Inventory/Devices/Deleting

    CLI Example:

    .. code-block:: bash

        salt '*' serverdensity_device.delete 51f7eafcdba4bb235e000ae4
    u/https://api.serverdensity.io/inventory/devices/Ru	api_tokenutokenuServer Density API Response: %su'Server Density API Response content: %si�u(Could not parse API Response content: %su#Failed to create, API Response: {0}N(RtdeleteRRRRRR R!R"R#R$R
RRR%(t	device_idR'((sE/usr/lib/python2.7/site-packages/salt/modules/serverdensity_device.pyR)qs


cK@s(t|�}d}|r!d}nx0tj|�D]\}}tj|�||<q1Wtjdj|�ditd�d6tj	j
j|�d6�}tj
d|�tj
d	|j�|jd
kr ytj	j
j|j�SWq$tk
rtjd|j�tdj|���q$Xnd
Sd
S(u2
    List devices in Server Density

    Results will be filtered by any params passed to this function. For more
    information, see the API docs on listing_ and searching_.

    .. _listing: https://apidocs.serverdensity.com/Inventory/Devices/Listing
    .. _searching: https://apidocs.serverdensity.com/Inventory/Devices/Searching

    CLI Example:

    .. code-block:: bash

        salt '*' serverdensity_device.ls
        salt '*' serverdensity_device.ls name=lama
        salt '*' serverdensity_device.ls name=lama group=lama_band installedRAM=32768
    udevicesu	resourcesu*https://api.serverdensity.io/inventory/{0}Ru	api_tokenutokenufilteruServer Density API Response: %su'Server Density API Response content: %si�u7Could not parse Server Density API Response content: %su2Failed to create, Server Density API Response: {0}N(RRt	iteritemst	text_typeRR
RRR R!R"tdumpsRRRRR#R$R
RR%(RtendpointtkeyRR'((sE/usr/lib/python2.7/site-packages/salt/modules/serverdensity_device.pytls�s,	,

cK@s�t|�}tjd|ditd�d6d|�}tjd|�tjd|j�|jdkr�ytj	j
j|j�SWq�tk
r�tj
d	|j�td
j|���q�XndSdS(u�
    Updates device information in Server Density. For more information see the
    `API docs`__.

    .. __: https://apidocs.serverdensity.com/Inventory/Devices/Updating

    CLI Example:

    .. code-block:: bash

        salt '*' serverdensity_device.update 51f7eafcdba4bb235e000ae4 name=lama group=lama_band
        salt '*' serverdensity_device.update 51f7eafcdba4bb235e000ae4 name=better_lama group=rock_lamas swapSpace=512
    u/https://api.serverdensity.io/inventory/devices/Ru	api_tokenutokenRuServer Density API Response: %su'Server Density API Response content: %si�u7Could not parse Server Density API Response content: %su#Failed to create, API Response: {0}N(RRtputRRRRRR R!R"R#R$R
RRR%(R*RR'((sE/usr/lib/python2.7/site-packages/salt/modules/serverdensity_device.pytupdate�s"
	

ic	C@stjjtdd�}tjj|�s;tj|�ntjd|dddt�}|j	}|j
�d}d}|d	kr�d
}d}nt|�}tdd
dj
||�d|�tdd
dj
|�d|�tdd
dj
d|d|d|�d|�S(u�
    Function downloads Server Density installation agent, and installs sd-agent
    with agent_key. Optionally the agent_version would select the series to
    use (defaults on the v1 one).

    CLI Example:

    .. code-block:: bash

        salt '*' serverdensity_device.install_agent c2bbdd6689ff46282bdaa07555641498
        salt '*' serverdensity_device.install_agent c2bbdd6689ff46282bdaa07555641498 2
    ucachedirutmptdirtsuffixu.shR)uaccount_urlu8https://www.serverdensity.com/downloads/agent-install.shiuaccount_nameu2https://archive.serverdensity.com/agent-install.shucmd.runtcmducurl -L {0} -o {1}tcwduchmod +x {0}u&{filename} -a {account} -k {agent_key}tfilenametaccountt	agent_key(tostpathtjoint__opts__tisdirtmkdirttempfiletNamedTemporaryFileRR&tcloseRt__salt__R(R9t
agent_versiontwork_dirtinstall_filetinstall_filenamet
account_fieldturlR8((sE/usr/lib/python2.7/site-packages/salt/modules/serverdensity_device.pyt
install_agent�s,
		
	
 
	( t__doc__t
__future__RRRtloggingR:R@tsalt.utils.jsonR tsalt.exceptionsRtsalt.extRtsalt.ext.six.movesRRtTrueRtImportErrorRt	getLoggert__name__RRRRR(R)R0R2RJ(((sE/usr/lib/python2.7/site-packages/salt/modules/serverdensity_device.pyt<module>s,


		%		4	&

Zerion Mini Shell 1.0