%PDF- %PDF-
Mini Shell

Mini Shell

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

�
���^c
@@s�dZddlmZmZmZddlZddlZddlZddlm	Z	ddl
mZddlZ
ddlZ
ddlZ
ddlZ
ddlmZddlmZmZeje�Zdd	d
dgZd�Zi)dd6dd6dd6dd6d d!6d"d#6d$d6d%d&6d'd(6d)d*6d'd+6d,d-6d.d6d/d6d0d16d.d26d3d46d5d66d,d76d,d86d9d6d,d:6d;d6d<d=6d>d?6d@d6dAd6dBd6dCdD6dEd6dFd
6dBdG6dCdH6d,dI6dJdK6dJdL6dMdN6dOd6dPdQ6dRd6dSdT6ZdUZdV�ZdW�ZddX�Z!dY�Z"e#dZ�Z$d[�Z%dd\d]�Z&e#d^�Z'dd_�Z(d`�Z)da�Z*db�Z+dc�Z,dddd�Z-de�Z.ddf�Z/dg�Z0dh�Z1di�Z2dj�Z3dk�Z4ddddl�Z5ddddm�Z6dn�Z7do�Z8dp�Z9dq�Z:ddddddr�Z;dddds�Z<dt�Z=du�Z>dv�Z?dw�Z@dx�ZAdy�ZBdddddz�ZCdddd{�ZDdd|�ZEd}�ZFd~�ZGdd�d�d�dd��ZHd��ZId��ZJddddde#d��ZKd��ZLd��ZMd��ZNd��ZOd��ZPd��ZQddd��ZRd��ZSd��ZTe#e#d��ZUdddd��ZVd��ZWdd�d��ZXdS(�u�
Support for Zabbix

:optdepends:    - zabbix server

:configuration: This module is not usable until the zabbix user and zabbix password are specified either in a pillar
    or in the minion's config file. Zabbix url should be also specified.

    .. code-block:: yaml

        zabbix.user: Admin
        zabbix.password: mypassword
        zabbix.url: http://127.0.0.1/zabbix/api_jsonrpc.php


    Connection arguments from the minion config file can be overridden on the CLI by using arguments with
    ``_connection_`` prefix.

    .. code-block:: bash

        zabbix.apiinfo_version _connection_user=Admin _connection_password=zabbix _connection_url=http://host/zabbix/

:codeauthor: Jiri Kotlin <jiri.kotlin@ultimum.io>
i(tabsolute_importtprint_functiontunicode_literalsN(tsix(t
SaltException(tLooseVersion(t	HTTPErrortURLErroriB'i�ioi90u	hostgrouputemplateuhostumaintenanceuactionudruleuserviceuproxyuscreenu	usergroupu	mediatypeuscriptuvaluemapuactionidualertidualertu
applicationiduapplicationudhostidudhostu
dserviceidudserviceudcheckidudcheckudruleidueventidueventugraphidugraphugitemidu	graphitemugraphprototypeuitemiduhistoryuhostidugroupiduinterfaceidu
hostinterfaceu
hostprototypeu	iconmapiduiconmapuimageiduimageuitemu
itemprototypeu	serviceidu
discoveryruleu
maintenanceidusysmapidumapumediaidu	usermediaumediatypeiduproxyiduscreeniduscreenitemidu
screenitemuscriptidu
templateidutemplatescreenutemplatescreenitemutrendu	triggeridutriggerutriggerprototypeuuseriduuseruusrgrpidu
globalmacroidu	usermacrou
valuemapidu
httptestiduhttptestuzabbixcC@stS(uE
    Only load the module if all modules are imported correctly.
    (t__virtualname__(((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pyt__virtual__escC@s�tj�}d|d}yey#tjjj|�}|d}Wn"tk
rd}tj|�}nX|j	d�rx|St
�Wntt
fk
r�tSXdS(uT
    Tries to guess the url of zabbix frontend.

    .. versionadded:: 2016.3.0
    uhttp://u/zabbix/api_jsonrpc.phpuerroru412: Precondition FailedN(
tsockettgethostnametsalttutilsthttptqueryRRt	text_typetfindtKeyErrort
ValueErrortFalse(thostnametfrontend_urltresponseterrorthttp_e((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pyt
_frontend_urlls
c
C@s�ddg}idd6}idd6dd6|d	6|d
6}||krT||d<ntjjj|�}tjdtj|�tj|��y�tjjj	|d
dd|d|dddt
dt
dt
�}tjdtj|��d|krtdj|d|d���n|j
di�}d|kratdj|dd|dd���n|SWnRtk
r�}	tdj|	���n+tjk
r�}	tdj|	���nXd S(!u�
    JSON request to Zabbix API.

    .. versionadded:: 2016.3.0

    :param method: actual operation to perform via the API
    :param params: parameters required for specific method
    :param url: url of zabbix api
    :param auth: auth token for zabbix api (only for methods with required authentication)

    :return: Response from API with desired data in JSON format. In case of error returns more specific description.

    .. versionchanged:: 2017.7
    u
user.loginuapiinfo.versionuapplication/jsonuContent-typeu2.0ujsonrpciuidumethoduparamsuauthu_QUERY input:
url: %s
data: %stmethoduPOSTtdatatheader_dicttdecode_typeujsontdecodetstatustheadersu_QUERY result: %suerroruZabbix API: Status: {0} ({1})ustatusudictuZabbix API: {} ({})umessageudatau2URL or HTTP headers are probably not correct! ({})uCheck hostname in URL! ({})N(RR
tjsontdumpstlogtinfoRRRRtTrueRtformattgetRR
R(
Rtparamsturltauthtunauthenticated_methodsRRtresulttretterr((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pyt_query�s6
"
%	#+c@s(t��d��fd�}|dd�|dd�|dd�d�krat��d<ny��dr��dr��dr�i�dd6�dd6}d}t||�d�}|d	}|�d
<�jdd��jdd��St�Wn(tk
r#}tdj|���nXdS(
u%
    Log in to the API and generate the authentication token.

    .. versionadded:: 2016.3.0

    :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
    :param _connection_password: Optional - zabbix password (can also be set in opts or pillar, see module's docstring)
    :param _connection_url: Optional - url of zabbix frontend (can also be set in opts, pillar, see module's docstring)

    :return: On success connargs dictionary with auth token and frontend url, False on failure.

    c@s�|dkr|}n|�kr2�|�|<nvd}|j|�rsy|t|�}Wqstk
rodSXntddj|�d�}|dk	r�|�|<ndS(up
        Add key to connargs, only if name exists in our kwargs or, as zabbix.<name> in __opts__ or __pillar__

        Evaluate in said order - kwargs, opts, then pillar. To avoid collision with other functions,
        kwargs-based connection arguments are prefixed with 'connection_' (i.e. '_connection_user', etc.).

        Inspired by mysql salt module.
        u_connection_Nu
config.optionu
zabbix.{0}(tNonet
startswithtlent
IndexErrort__salt__R'(tnametkeytprefixtval(tconnargstkwargs(s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pyt_connarg�s		
u_connection_useruuseru_connection_passwordupasswordu_connection_urluurlu
user.loginuresultuauthu!URL is probably not correct! ({})N(tdictR1RR0tpopRRR'(R;R<R)RR.R+R/((R:R;s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pyt_login�s(
	





cK@s�x4|D],}|jd�s|j|||�qqW|r�|jdd�d|kro|jd�|d<q�d|kr�|jd�|d<q�n|S(uG
    Extends the params dictionary by values from keyword arguments.

    .. versionadded:: 2016.3.0

    :param params: Dictionary with parameters for zabbix API.
    :param _ignore_name: Salt State module is passing first line as 'name' parameter. If API uses optional parameter
    'name' (for ex. host_create, user_create method), please use 'visible_name' or 'firstname' instead of 'name' to
    not mess these values.
    :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
    :param _connection_password: Optional - zabbix password (can also be set in opts or pillar, see module's docstring)
    :param _connection_url: Optional - url of zabbix frontend (can also be set in opts, pillar, see module's docstring)

    :return: Extended params dictionary with parameters.

    u_unameu	firstnameuvisible_nameN(R2t
setdefaultR>R1(R)t_ignore_nameR;R7((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pyt_params_extend�s
cC@stS(u�
    .. versionadded:: 2017.7

    Make ZABBIX_ID_MAPPER constant available to state modules.

    :return: ZABBIX_ID_MAPPER
    (tZABBIX_ID_MAPPER(((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pytget_zabbix_id_mappersunamec@s"�dkri�nt|t�rJg|D]}t|����^q+St|t�rd|kr�i}|dtkr�|j��ny7|jii|d�6d6�t|d|��SWqtk
r�t	dj
|���qXq���fd�|j�D�Sn
tj
|�SdS(up
    .. versionadded:: 2017.7

    Go through Zabbix object params specification and if needed get given object ID from Zabbix API and put it back
    as a value. Definition of the object is done via dict with keys "query_object" and "query_name".

    :param input_object: Zabbix object type specified in state file
    :param extend_params: Specify query with params
    :param filter_key: Custom filtering key (default: name)
    :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
    :param _connection_password: Optional - zabbix password (can also be set in opts or pillar, see module's docstring)
    :param _connection_url: Optional - url of zabbix frontend (can also be set in opts, pillar, see module's docstring)

    :return: Params structure with values converted to string for further comparison purposes
    uquery_objectu
query_nameufilteru>Qyerying object ID requested but object name not provided: {0}c@s.i|]$\}}t|����|�qS((tsubstitute_params(t.0R7R9(t
extend_paramst
filter_keyR;(s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pys
<dictcomp>?s	N(R1t
isinstancetlistRER=tZABBIX_TOP_LEVEL_OBJECTStupdatetget_object_id_by_paramsRRR'titemsRR(tinput_objectRGRHR;toitemtquery_params((RGRHR;s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pyREs$	&
	cC@smt|t|��sBtdjt|�t|�||���ntjjj|�s�tj	|�tj	|�kr�|r�itj	|�d6tj	|�d6Stj	|�tj	|�kr�|r�tj	|�Snt|t
�r�t|�t|�kr$tj
d�|r i|d6|d6S|Sg}xz|D]r}g}xG|D]?}t|||�}|rv|j|d�qD|j|�qDWt|�r1|j|�q1q1Wt|�r�|r�i|d6|d6St|�r�|r�|Snt|t�riy4t|�t|�krt|�t|�@}|r?iid6id6ni}	x�|D]�}
t||
||
|�}|r�|s�|rt|t
�r|	dji||
|
6�|	dji||
|
6�qqL|s�|rLt|t
�rL|	ji||
|
6�qLqLW|	S|r#i|d6|d6S|SWqitk
retdjt|�t|�||���qiXndS(u
    .. versionadded:: 2017.7

    Compares Zabbix object definition against existing Zabbix object.

    :param defined: Zabbix object definition taken from sls file.
    :param existing: Existing Zabbix object taken from result of an API call.
    :param return_old_value: Default False. If True, returns dict("old"=old_val, "new"=new_val) for rollback purpose.
    :return: Params that are different from existing object. Result extended by
        object ID can be passed directly to Zabbix API update method.
    u{Zabbix object comparison failed (data type mismatch). Expecting {0}, got {1}. Existing value: "{2}", defined value: "{3}").unewuolduDifferent list length!N(RIttypeRR'RR
Rtis_iterRRRJR3R$R%tcompare_paramstappendtalltanyR=tsetRLt	TypeError(tdefinedtexistingtreturn_old_valuetdifflisttditemtd_in_eteitemtcomptintersectiontdiffdictti((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pyRTGsd
			$$%


 
" 
			cK@s|dkri}nt|d||�}|r\t|�dkr\tj|dt|�Stdj|d||���dS(u>
    .. versionadded:: 2017.7

    Get ID of single Zabbix object specified by its name.

    :param obj: Zabbix object type
    :param params: Parameters by which object is uniquely identified
    :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
    :param _connection_password: Optional - zabbix password (can also be set in opts or pillar, see module's docstring)
    :param _connection_url: Optional - url of zabbix frontend (can also be set in opts, pillar, see module's docstring)

    :return: object ID
    u.getiiu�Zabbix API: Object does not exist or bad Zabbix user permissions or other unexpected result. Called method {0} with params {1}. Result: {2}N(R1t	run_queryR3RRRCRR'(tobjR)tconnection_argstres((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pyRM�s		cK@slt|�}t}yA|rLd}i}t|||d|d�}|dSt�Wntk
rgtSXdS(uQ
    Retrieve the version of the Zabbix API.

    .. versionadded:: 2016.3.0

    :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
    :param _connection_password: Optional - zabbix password (can also be set in opts or pillar, see module's docstring)
    :param _connection_url: Optional - url of zabbix frontend (can also be set in opts, pillar, see module's docstring)

    :return: On success string with Zabbix API version, False on failure.

    CLI Example:
    .. code-block:: bash

        salt '*' zabbix.apiinfo_version
    uapiinfo.versionuurluauthuresultN(R?RR0R(Rgt	conn_argsR.RR)((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pytapiinfo_version�s

c	K@s�t|�}t}y�|r�d}i|d6|d6gd6}t|t�sW|g}nx&|D]}|dji|d6�q^Wt|dt|�}t|||d|d�}|d	d
St�Wntk
r�|SXdS(uh
    .. versionadded:: 2016.3.0

    Create new zabbix user

    .. note::
        This function accepts all standard user properties: keyword argument
        names differ depending on your zabbix version, see here__.

        .. __: https://www.zabbix.com/documentation/2.0/manual/appendix/api/user/definitions#user

    :param alias: user alias
    :param passwd: user's password
    :param usrgrps: user groups to add the user to

    :param _connection_user: zabbix user (can also be set in opts or pillar, see module's docstring)
    :param _connection_password: zabbix password (can also be set in opts or pillar, see module's docstring)
    :param _connection_url: url of zabbix frontend (can also be set in opts or pillar, see module's docstring)

    :param firstname: string with firstname of the user, use 'firstname' instead of 'name' parameter to not mess
                      with value supplied from Salt sls file.

    :return: On success string with id of the created user.

    CLI Example:
    .. code-block:: bash

        salt '*' zabbix.user_create james password007 '[7, 12]' firstname='James Bond'
    uuser.createualiasupasswduusrgrpsuusrgrpidRAuurluauthuresultuuseridsN(	R?RRIRJRURBR&R0R(	taliastpasswdtusrgrpsRgRiR.RR)tusrgrp((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pytuser_create�s 


cK@s�t|�}t}y`|rkd}t|t�s<|g}n|}t|||d|d�}|ddSt�Wntk
r�|SXdS(ue
    Delete zabbix users.

    .. versionadded:: 2016.3.0

    :param users: array of users (userids) to delete
    :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
    :param _connection_password: Optional - zabbix password (can also be set in opts or pillar, see module's docstring)
    :param _connection_url: Optional - url of zabbix frontend (can also be set in opts, pillar, see module's docstring)

    :return: On success array with userids of deleted users.

    CLI Example:
    .. code-block:: bash

        salt '*' zabbix.user_delete 15
    uuser.deleteuurluauthuresultuuseridsN(R?RRIRJR0R(tusersRgRiR.RR)((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pytuser_deletes

cK@s�t|�}t}yl|rwd}idd6i|d6d6}t|||d|d�}t|d�d	krstStSt�Wntk
r�|SXd
S(uT
    Checks if user with given alias exists.

    .. versionadded:: 2016.3.0

    :param alias: user alias
    :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
    :param _connection_password: Optional - zabbix password (can also be set in opts or pillar, see module's docstring)
    :param _connection_url: Optional - url of zabbix frontend (can also be set in opts, pillar, see module's docstring)

    :return: True if user exists, else False.

    CLI Example:
    .. code-block:: bash

        salt '*' zabbix.user_exists james
    uuser.getuextenduoutputualiasufilteruurluauthuresultiN(R?RR0R3R&R(RkRgRiR.RR)((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pytuser_exists$s

cK@s�t|�}t}y�|r�d}idd6id6}|rU|rUitd6dd6S|rr|djd|�n|r�|jd	|�nt||�}t|||d
|d�}t|d�dkr�|dStSt�Wntk
r�|SXd
S(u�
    Retrieve users according to the given parameters.

    .. versionadded:: 2016.3.0

    :param alias: user alias
    :param userids: return only users with the given IDs
    :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
    :param _connection_password: Optional - zabbix password (can also be set in opts or pillar, see module's docstring)
    :param _connection_url: Optional - url of zabbix frontend (can also be set in opts, pillar, see module's docstring)

    :return: Array with details of convenient users, False on failure of if no user found.

    CLI Example:
    .. code-block:: bash

        salt '*' zabbix.user_get james
    uuser.getuextenduoutputufilteruresultu;Please submit alias or userids parameter to retrieve users.ucommentualiasuuseridsuurluauthiN(R?RR@RBR0R3R(RktuseridsRgRiR.RR)((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pytuser_getDs$"

cK@s�t|�}t}ya|rld}i|d6}t|dt|�}t|||d|d�}|ddSt�Wntk
r�|SXdS(	um
    .. versionadded:: 2016.3.0

    Update existing users

    .. note::
        This function accepts all standard user properties: keyword argument
        names differ depending on your zabbix version, see here__.

        .. __: https://www.zabbix.com/documentation/2.0/manual/appendix/api/user/definitions#user

    :param userid: id of the user to update
    :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
    :param _connection_password: Optional - zabbix password (can also be set in opts or pillar, see module's docstring)
    :param _connection_url: Optional - url of zabbix frontend (can also be set in opts, pillar, see module's docstring)

    :return: Id of the updated user on success.

    CLI Example:
    .. code-block:: bash

        salt '*' zabbix.user_update 16 visible_name='James Brown'
    uuser.updateuuseridRAuurluauthuresultuuseridsN(R?RRBR&R0R(tuseridRgRiR.RR)((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pytuser_updatels


cK@s�t|�}t}yf|rqd}|r7i|d6}ni}t||�}t|||d|d�}|dSt�Wntk
r�|SXdS(u�
    .. versionadded:: 2016.3.0

    Retrieve media according to the given parameters

    .. note::
        This function accepts all standard usermedia.get properties: keyword
        argument names differ depending on your zabbix version, see here__.

        .. __: https://www.zabbix.com/documentation/3.2/manual/api/reference/usermedia/get

    :param userids: return only media that are used by the given users

    :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
    :param _connection_password: Optional - zabbix password (can also be set in opts or pillar, see module's docstring)
    :param _connection_url: Optional - url of zabbix frontend (can also be set in opts, pillar, see module's docstring)

    :return: List of retrieved media, False on failure.

    CLI Example:
    .. code-block:: bash

        salt '*' zabbix.user_getmedia
    u
usermedia.getuuseridsuurluauthuresultN(R?RRBR0R(RsRgRiR.RR)((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pyt
user_getmedia�s

cK@s�t|�}t}y�|r�d}	igd6}
t|t�sI|g}nx&|D]}|
dji|d6�qPWi|d6|d6|d6|d6|d6g|
d	<t|	|
|d
|d�}|dd
St�Wntk
r�|SXdS(u#
    Add new media to multiple users.

    .. versionadded:: 2016.3.0

    :param userids: ID of the user that uses the media
    :param active: Whether the media is enabled (0 enabled, 1 disabled)
    :param mediatypeid: ID of the media type used by the media
    :param period: Time when the notifications can be sent as a time period
    :param sendto: Address, user name or other identifier of the recipient
    :param severity: Trigger severities to send notifications about
    :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
    :param _connection_password: Optional - zabbix password (can also be set in opts or pillar, see module's docstring)
    :param _connection_url: Optional - url of zabbix frontend (can also be set in opts, pillar, see module's docstring)

    :return: IDs of the created media.

    CLI Example:
    .. code-block:: bash

        salt '*' zabbix.user_addmedia 4 active=0 mediatypeid=1 period='1-7,00:00-24:00' sendto='support2@example.com'
        severity=63

    u
user.addmediauusersuuseriduactiveumediatypeiduperiodusendtouseverityumediasuurluauthuresultumediaidsN(R?RRIRJRUR0R(RstactivetmediatypeidtperiodtsendtotseverityRgRiR.RR)tuser((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pyt
user_addmedia�s"



cK@s�t|�}t}y`|rkd}t|t�s<|g}n|}t|||d|d�}|ddSt�Wntk
r�|SXdS(u`
    Delete media by id.

    .. versionadded:: 2016.3.0

    :param mediaids: IDs of the media to delete
    :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
    :param _connection_password: Optional - zabbix password (can also be set in opts or pillar, see module's docstring)
    :param _connection_url: Optional - url of zabbix frontend (can also be set in opts, pillar, see module's docstring)

    :return: IDs of the deleted media, False on failure.

    CLI Example:
    .. code-block:: bash

        salt '*' zabbix.user_deletemedia 27
    uuser.deletemediauurluauthuresultumediaidsN(R?RRIRJR0R(tmediaidsRgRiR.RR)((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pytuser_deletemedia�s

cK@sst|�}t}yH|rSd}idd6}t|||d|d�}|dSt�Wntk
rn|SXdS(u%
    Retrieve all of the configured users.

    .. versionadded:: 2016.3.0

    :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
    :param _connection_password: Optional - zabbix password (can also be set in opts or pillar, see module's docstring)
    :param _connection_url: Optional - url of zabbix frontend (can also be set in opts, pillar, see module's docstring)

    :return: Array with user details.

    CLI Example:
    .. code-block:: bash

        salt '*' zabbix.user_list
    uuser.getuextenduoutputuurluauthuresultN(R?RR0R(RgRiR.RR)((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pyt	user_lists


cK@s�t|�}t}y[|rfd}i|d6}t||�}t|||d|d�}|ddSt�Wntk
r�|SXdS(ui
    .. versionadded:: 2016.3.0

    Create new user group

    .. note::
        This function accepts all standard user group properties: keyword
        argument names differ depending on your zabbix version, see here__.

        .. __: https://www.zabbix.com/documentation/2.0/manual/appendix/api/usergroup/definitions#user_group

    :param name: name of the user group
    :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
    :param _connection_password: Optional - zabbix password (can also be set in opts or pillar, see module's docstring)
    :param _connection_url: Optional - url of zabbix frontend (can also be set in opts, pillar, see module's docstring)

    :return:  IDs of the created user groups.

    CLI Example:
    .. code-block:: bash

        salt '*' zabbix.usergroup_create GroupName
    uusergroup.createunameuurluauthuresultu	usrgrpidsN(R?RRBR0R(R6RgRiR.RR)((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pytusergroup_create0s


cK@s�t|�}t}y`|rkd}t|t�s<|g}n|}t|||d|d�}|ddSt�Wntk
r�|SXdS(uF
    .. versionadded:: 2016.3.0

    :param usergroupids: IDs of the user groups to delete

    :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
    :param _connection_password: Optional - zabbix password (can also be set in opts or pillar, see module's docstring)
    :param _connection_url: Optional - url of zabbix frontend (can also be set in opts, pillar, see module's docstring)

    :return: IDs of the deleted user groups.

    CLI Example:
    .. code-block:: bash

        salt '*' zabbix.usergroup_delete 28
    uusergroup.deleteuurluauthuresultu	usrgrpidsN(R?RRIRJR0R(tusergroupidsRgRiR.RR)((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pytusergroup_deleteWs

c	K@s9t|�}t|�}t}y|rt|�td�krj|sNd}nt|d
|�}t|�Sd}i}|r�|r�|r�itd6dd6S|r�||d<nt|�td�kr�|r�||d	<n|r�||d
<q�nt|||d|d�}|dSnt�Wntk
r4|SXd
S(u{
    Checks if at least one user group that matches the given filter criteria exists

    .. versionadded:: 2016.3.0

    :param name: names of the user groups
    :param node: name of the node the user groups must belong to (This will override the nodeids parameter.)
    :param nodeids: IDs of the nodes the user groups must belong to

    :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
    :param _connection_password: Optional - zabbix password (can also be set in opts or pillar, see module's docstring)
    :param _connection_url: Optional - url of zabbix frontend (can also be set in opts, pillar, see module's docstring)

    :return: True if at least one user group that matches the given filter criteria exists, else False.

    CLI Example:
    .. code-block:: bash

        salt '*' zabbix.usergroup_exists Guests
    u2.5uuusergroup.existsuresultuYPlease submit name, node or nodeids parameter to check if at least one user group exists.ucommentunameu2.4unodeunodeidsuurluauthN(	R?RjRt
_LooseVersiont
usergroup_getR1tboolR0R(	R6tnodetnodeidsRgRitzabbix_versionR.RR)((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pytusergroup_existsxs4	




c	K@sMt|�}t|�}t}y|r-d}t|�td�krcidd6dd6id6}nidd6id6}|r�|r�|r�tS|r�|djd|�n|r�|jd|�n|r�|jd	|�nt||�}t|||d
|d�}t|d�d
kr%tS|dSt�Wntk
rH|SXdS(u.
    .. versionadded:: 2016.3.0

    Retrieve user groups according to the given parameters

    .. note::
        This function accepts all usergroup_get properties: keyword argument
        names differ depending on your zabbix version, see here__.

        .. __: https://www.zabbix.com/documentation/2.4/manual/api/reference/usergroup/get

    :param name: names of the user groups
    :param usrgrpids: return only user groups with the given IDs
    :param userids: return only user groups that contain the given users
    :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
    :param _connection_password: Optional - zabbix password (can also be set in opts or pillar, see module's docstring)
    :param _connection_url: Optional - url of zabbix frontend (can also be set in opts, pillar, see module's docstring)

    :return: Array with convenient user groups details, False if no user group found or on failure.

    CLI Example:
    .. code-block:: bash

        salt '*' zabbix.usergroup_get Guests
    u
usergroup.getu2.5uextenduselectRightsuoutputufilterunameu	usrgrpidsuuseridsuurluauthuresultiN(	R?RjRR�R@RBR0R3R(	R6t	usrgrpidsRsRgRiR�R.RR)((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pyR��s."

cK@s�t|�}t}y[|rfd}i|d6}t||�}t|||d|d�}|ddSt�Wntk
r�|SXdS(u�
    .. versionadded:: 2016.3.0

    Update existing user group

    .. note::
        This function accepts all standard user group properties: keyword
        argument names differ depending on your zabbix version, see here__.

        .. __: https://www.zabbix.com/documentation/2.4/manual/api/reference/usergroup/object#user_group

    :param usrgrpid: ID of the user group to update.
    :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
    :param _connection_password: Optional - zabbix password (can also be set in opts or pillar, see module's docstring)
    :param _connection_url: Optional - url of zabbix frontend (can also be set in opts, pillar, see module's docstring)

    :return: IDs of the updated user group, False on failure.

    CLI Example:
    .. code-block:: bash

        salt '*' zabbix.usergroup_update 8 name=guestsRenamed
    uusergroup.updateuusrgrpiduurluauthuresultu	usrgrpidsN(R?RRBR0R(tusrgrpidRgRiR.RR)((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pytusergroup_update�s


cK@sst|�}t}yH|rSd}idd6}t|||d|d�}|dSt�Wntk
rn|SXdS(uG
    Retrieve all enabled user groups.

    .. versionadded:: 2016.3.0

    :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
    :param _connection_password: Optional - zabbix password (can also be set in opts or pillar, see module's docstring)
    :param _connection_url: Optional - url of zabbix frontend (can also be set in opts, pillar, see module's docstring)

    :return: Array with enabled user groups details, False on failure.

    CLI Example:
    .. code-block:: bash

        salt '*' zabbix.usergroup_list
    u
usergroup.getuextenduoutputuurluauthuresultN(R?RR0R(RgRiR.RR)((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pytusergroup_list
s


c
K@st|�}t}y�|r�d}i|d6}t|t�sI|g}ng}x"|D]}	|ji|	d6�qVW||d<t|t�s�|g}n||d<t|dt|�}t|||d|d�}|d	d
St�Wntk
r�|SXdS(u/
    .. versionadded:: 2016.3.0

    Create new host

    .. note::
        This function accepts all standard host properties: keyword argument
        names differ depending on your zabbix version, see here__.

        .. __: https://www.zabbix.com/documentation/2.4/manual/api/reference/host/object#host

    :param host: technical name of the host
    :param groups: groupids of host groups to add the host to
    :param interfaces: interfaces to be created for the host
    :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
    :param _connection_password: Optional - zabbix password (can also be set in opts or pillar, see module's docstring)
    :param _connection_url: Optional - url of zabbix frontend (can also be set in opts, pillar, see module's docstring)
    :param visible_name: string with visible name of the host, use
        'visible_name' instead of 'name' parameter to not mess with value
        supplied from Salt sls file.

    return: ID of the created host.

    CLI Example:

    .. code-block:: bash

        salt '*' zabbix.host_create technicalname 4
        interfaces='{type: 1, main: 1, useip: 1, ip: "192.168.3.1", dns: "", port: 10050}'
        visible_name='Host Visible Name' inventory_mode=0 inventory='{"alias": "something"}'
    uhost.createuhostugroupidugroupsu
interfacesRAuurluauthuresultuhostidsN(	R?RRIRJRURBR&R0R(
thosttgroupst
interfacesRgRiR.RR)tgrpstgroup((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pythost_create,s* 





cK@s�t|�}t}y`|rkd}t|t�s<|g}n|}t|||d|d�}|ddSt�Wntk
r�|SXdS(uE
    Delete hosts.

    .. versionadded:: 2016.3.0

    :param hostids: Hosts (hostids) to delete.
    :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
    :param _connection_password: Optional - zabbix password (can also be set in opts or pillar, see module's docstring)
    :param _connection_url: Optional - url of zabbix frontend (can also be set in opts, pillar, see module's docstring)

    :return: IDs of the deleted hosts.

    CLI Example:
    .. code-block:: bash

        salt '*' zabbix.host_delete 10106
    uhost.deleteuurluauthuresultuhostidsN(R?RRIRJR0R(thostidsRgRiR.RR)((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pythost_deletefs

c
K@s�t|�}t|�}t}yW|rnt|�td�kr�|sNd}n|s]d}n|sld}nt||||�}t|�Sd}	i}
|r�||
d<n|r�||
d<n|r�||
d<nt|�td�kr|r�||
d<n|r||
d<qn|rF|rF|rF|rF|rFitd	6d
d6St|	|
|d|d
�}|d	Snt�Wntk
r�|SXdS(u�
    Checks if at least one host that matches the given filter criteria exists.

    .. versionadded:: 2016.3.0

    :param host: technical name of the host
    :param hostids: Hosts (hostids) to delete.
    :param name: visible name of the host
    :param node: name of the node the hosts must belong to (zabbix API < 2.4)
    :param nodeids: IDs of the node the hosts must belong to (zabbix API < 2.4)
    :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
    :param _connection_password: Optional - zabbix password (can also be set in opts or pillar, see module's docstring)
    :param _connection_url: Optional - url of zabbix frontend (can also be set in opts, pillar, see module's docstring)

    :return: IDs of the deleted hosts, False on failure.

    CLI Example:
    .. code-block:: bash

        salt '*' zabbix.host_exists 'Zabbix server'
    u2.5uhost.existsuhostiduhostunameu2.4unodeunodeidsuresultu�Please submit hostid, host, name, node or nodeids parameter tocheck if at least one host that matches the given filter criteria exists.ucommentuurluauthN(	R?RjRR�R1thost_getR�R0R(R�thostidR6R�R�RgRiR�R.RR)((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pythost_exists�sD			




#

cK@st|�}t}y�|r�d}idd6id6}|rN|rN|rNtS|rk|djd|�n|r�|jd|�n|r�|djd|�nt||�}t|||d|d	�}t|d
�dkr�|d
StSt�Wntk
r
|SXdS(
u�
    .. versionadded:: 2016.3.0

    Retrieve hosts according to the given parameters

    .. note::
        This function accepts all optional host.get parameters: keyword
        argument names differ depending on your zabbix version, see here__.

        .. __: https://www.zabbix.com/documentation/2.4/manual/api/reference/host/get

    :param host: technical name of the host
    :param name: visible name of the host
    :param hostids: ids of the hosts
    :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
    :param _connection_password: Optional - zabbix password (can also be set in opts or pillar, see module's docstring)
    :param _connection_url: Optional - url of zabbix frontend (can also be set in opts, pillar, see module's docstring)


    :return: Array with convenient hosts details, False if no host found or on failure.

    CLI Example:
    .. code-block:: bash

        salt '*' zabbix.host_get 'Zabbix server'
    uhost.getuextenduoutputufilterunameuhostidsuhostuurluauthuresultiN(R?RR@RBR0R3R(R�R6R�RgRiR.RR)((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pyR��s("

cK@s�t|�}t}ya|rld}i|d6}t|dt|�}t|||d|d�}|ddSt�Wntk
r�|SXdS(	u�
    .. versionadded:: 2016.3.0

    Update existing hosts

    .. note::
        This function accepts all standard host and host.update properties:
        keyword argument names differ depending on your zabbix version, see the
        documentation for `host objects`_ and the documentation for `updating
        hosts`_.

        .. _`host objects`: https://www.zabbix.com/documentation/2.4/manual/api/reference/host/object#host
        .. _`updating hosts`: https://www.zabbix.com/documentation/2.4/manual/api/reference/host/update

    :param hostid: ID of the host to update
    :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
    :param _connection_password: Optional - zabbix password (can also be set in opts or pillar, see module's docstring)
    :param _connection_url: Optional - url of zabbix frontend (can also be set in opts, pillar, see module's docstring)
    :param visible_name: string with visible name of the host, use
        'visible_name' instead of 'name' parameter to not mess with value
        supplied from Salt sls file.

    :return: ID of the updated host.

    CLI Example:
    .. code-block:: bash

        salt '*' zabbix.host_update 10084 name='Zabbix server2'
    uhost.updateuhostidRAuurluauthuresultuhostidsN(R?RRBR&R0R(R�RgRiR.RR)((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pythost_update�s


cK@s�t|�}t}y�|r�d}idd6}|rG|jd|�nt||�}t|||d|d�}t|ddd	�dkr�|ddd	StSt�Wntk
r�|SXd
S(u<
    Retrieve host inventory according to the given parameters.
    See: https://www.zabbix.com/documentation/2.4/manual/api/reference/host/object#host_inventory

    .. versionadded:: 2019.2.0

    :param hostids: Return only host interfaces used by the given hosts.
    :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
    :param _connection_password: Optional - zabbix password (can also be set in opts or pillar, see module's docstring)
    :param _connection_url: Optional - url of zabbix frontend (can also be set in opts, pillar, see module's docstring)

    :return: Array with host interfaces details, False if no convenient host interfaces found or on failure.

    CLI Example:
    .. code-block:: bash

        salt '*' zabbix.host_inventory_get 101054
    uhost.getuextenduselectInventoryuhostidsuurluauthuresultiu	inventoryN(R?RR@RBR0R3R(R�RgRiR.RR)((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pythost_inventory_get)s
2

c	K@s-t|�}t}y|r
i}t}d}|jd�rEt}n|jdd�tt||��}x|D]}|j|d�qqW|r�|jd|�n|r�d|d<t	|||d|d�}nd|d<||d	<t	|||d|d�}|d
St
�Wnt
k
r(|SXdS(u�
    Update host inventory items
    NOTE: This function accepts all standard host: keyword argument names for inventory
    see: https://www.zabbix.com/documentation/2.4/manual/api/reference/host/object#host_inventory

    .. versionadded:: 2019.2.0

    :param hostid: ID of the host to update
    :param clear_old: Set to True in order to remove all existing inventory items before setting the specified items
    :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
    :param _connection_password: Optional - zabbix password (can also be set in opts or pillar, see module's docstring)
    :param _connection_url: Optional - url of zabbix frontend (can also be set in opts, pillar, see module's docstring)

    :return: ID of the updated host, False on failure.

    CLI Example:
    .. code-block:: bash

        salt '*' zabbix.host_inventory_set 101054 asset_tag=jml3322 type=vm clear_old=True
    uhost.updateu	clear_olduhostidu-1uinventory_modeuurluauthu0u	inventoryuresultN(R?RR(R&R>R1R=RBR@R0R(	R�RgRiR.R)t	clear_oldRtinventory_paramsR7((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pythost_inventory_setMs2	

 



cK@sst|�}t}yH|rSd}idd6}t|||d|d�}|dSt�Wntk
rn|SXdS(u,
    Retrieve all hosts.

    .. versionadded:: 2016.3.0

    :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
    :param _connection_password: Optional - zabbix password (can also be set in opts or pillar, see module's docstring)
    :param _connection_url: Optional - url of zabbix frontend (can also be set in opts, pillar, see module's docstring)

    :return: Array with details about hosts, False on failure.

    CLI Example:
    .. code-block:: bash

        salt '*' zabbix.host_list
    uhost.getuextenduoutputuurluauthuresultN(R?RR0R(RgRiR.RR)((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pyt	host_list�s


cK@s�t|�}t}y[|rfd}i|d6}t||�}t|||d|d�}|ddSt�Wntk
r�|SXdS(ua
    .. versionadded:: 2016.3.0

    Create a host group

    .. note::
        This function accepts all standard host group properties: keyword
        argument names differ depending on your zabbix version, see here__.

        .. __: https://www.zabbix.com/documentation/2.4/manual/api/reference/hostgroup/object#host_group

    :param name: name of the host group
    :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
    :param _connection_password: Optional - zabbix password (can also be set in opts or pillar, see module's docstring)
    :param _connection_url: Optional - url of zabbix frontend (can also be set in opts, pillar, see module's docstring)

    :return: ID of the created host group.

    CLI Example:
    .. code-block:: bash

        salt '*' zabbix.hostgroup_create MyNewGroup
    uhostgroup.createunameuurluauthuresultugroupidsN(R?RRBR0R(R6RgRiR.RR)((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pythostgroup_create�s


cK@s�t|�}t}y`|rkd}t|t�s<|g}n|}t|||d|d�}|ddSt�Wntk
r�|SXdS(ur
    Delete the host group.

    .. versionadded:: 2016.3.0

    :param hostgroupids: IDs of the host groups to delete
    :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
    :param _connection_password: Optional - zabbix password (can also be set in opts or pillar, see module's docstring)
    :param _connection_url: Optional - url of zabbix frontend (can also be set in opts, pillar, see module's docstring)

    :return: ID of the deleted host groups, False on failure.

    CLI Example:
    .. code-block:: bash

        salt '*' zabbix.hostgroup_delete 23
    uhostgroup.deleteuurluauthuresultugroupidsN(R?RRIRJR0R(thostgroupidsRgRiR.RR)((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pythostgroup_delete�s

c
	K@sbt|�}t|�}t}y+|rBt|�td�kry|sNd
}n|s]d
}nt|||�}t|�Si}d}	|r�||d<n|r�||d<nt|�td�kr�|r�||d<n|r�||d<q�n|r|r|r|ritd6d	d
6St|	||d|d�}|dSnt�Wntk
r]|SXd
S(u�
    Checks if at least one host group that matches the given filter criteria exists.

    .. versionadded:: 2016.3.0

    :param name: names of the host groups
    :param groupid: host group IDs
    :param node: name of the node the host groups must belong to (zabbix API < 2.4)
    :param nodeids: IDs of the nodes the host groups must belong to (zabbix API < 2.4)
    :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
    :param _connection_password: Optional - zabbix password (can also be set in opts or pillar, see module's docstring)
    :param _connection_url: Optional - url of zabbix frontend (can also be set in opts, pillar, see module's docstring)

    :return: True if at least one host group exists, False if not or on failure.

    CLI Example:
    .. code-block:: bash

        salt '*' zabbix.hostgroup_exists MyNewGroup
    u2.5uhostgroup.existsugroupidunameu2.4unodeunodeidsuresultu�Please submit groupid, name, node or nodeids parameter tocheck if at least one host group that matches the given filter criteria exists.ucommentuurluauthN(	R?RjRR�R1t
hostgroup_getR�R0R(
R6tgroupidR�R�RgRiR�R.R)R((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pythostgroup_exists�s<		





c	K@s
t|�}t}y�|r�d}idd6}|rG|rG|rGtS|rmi|d6}|jd|�n|r�|jd|�n|r�|jd|�nt||�}t|||d|d	�}t|d
�dkr�|d
StSt�Wntk
r|SXdS(
u�
    .. versionadded:: 2016.3.0

    Retrieve host groups according to the given parameters

    .. note::
        This function accepts all standard hostgroup.get properities: keyword
        argument names differ depending on your zabbix version, see here__.

        .. __: https://www.zabbix.com/documentation/2.2/manual/api/reference/hostgroup/get

    :param name: names of the host groups
    :param groupid: host group IDs
    :param node: name of the node the host groups must belong to
    :param nodeids: IDs of the nodes the host groups must belong to
    :param hostids: return only host groups that contain the given hosts

    :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
    :param _connection_password: Optional - zabbix password (can also be set in opts or pillar, see module's docstring)
    :param _connection_url: Optional - url of zabbix frontend (can also be set in opts, pillar, see module's docstring)

    :return: Array with host groups details, False if no convenient host group found or on failure.

    CLI Example:
    .. code-block:: bash

        salt '*' zabbix.hostgroup_get MyNewGroup
    u
hostgroup.getuextenduoutputunameufilterugroupidsuhostidsuurluauthuresultiN(R?RR@RBR0R3R(	R6tgroupidsR�RgRiR.RR)t	name_dict((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pyR�)s*

"

cK@s�t|�}t}yn|ryd}i|d6}|rA||d<nt||�}t|||d|d�}|ddSt�Wntk
r�|SXdS(	u�
    .. versionadded:: 2016.3.0

    Update existing hosts group

    .. note::
        This function accepts all standard host group properties: keyword
        argument names differ depending on your zabbix version, see here__.

        .. __: https://www.zabbix.com/documentation/2.4/manual/api/reference/hostgroup/object#host_group

    :param groupid: ID of the host group to update
    :param name: name of the host group
    :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
    :param _connection_password: Optional - zabbix password (can also be set in opts or pillar, see module's docstring)
    :param _connection_url: Optional - url of zabbix frontend (can also be set in opts, pillar, see module's docstring)

    :return: IDs of updated host groups.

    CLI Example:
    .. code-block:: bash

        salt '*' zabbix.hostgroup_update 24 name='Renamed Name'
    uhostgroup.updateugroupidunameuurluauthuresultugroupidsN(R?RRBR0R(R�R6RgRiR.RR)((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pythostgroup_update^s



cK@sst|�}t}yH|rSd}idd6}t|||d|d�}|dSt�Wntk
rn|SXdS(u=
    Retrieve all host groups.

    .. versionadded:: 2016.3.0

    :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
    :param _connection_password: Optional - zabbix password (can also be set in opts or pillar, see module's docstring)
    :param _connection_url: Optional - url of zabbix frontend (can also be set in opts, pillar, see module's docstring)

    :return: Array with details about host groups, False on failure.

    CLI Example:
    .. code-block:: bash

        salt '*' zabbix.hostgroup_list
    u
hostgroup.getuextenduoutputuurluauthuresultN(R?RR0R(RgRiR.RR)((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pythostgroup_list�s


cK@s�t|�}t}y�|r�d}idd6}|rG|jd|�nt||�}t|||d|d�}t|d�dkr�|dStSt�Wntk
r�|SXd	S(
u�
    .. versionadded:: 2016.3.0

    Retrieve host groups according to the given parameters

    .. note::
        This function accepts all standard hostinterface.get properities:
        keyword argument names differ depending on your zabbix version, see
        here__.

        .. __: https://www.zabbix.com/documentation/2.4/manual/api/reference/hostinterface/get

    :param hostids: Return only host interfaces used by the given hosts.

    :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)

    :param _connection_password: Optional - zabbix password (can also be set in opts or pillar, see module's docstring)

    :param _connection_url: Optional - url of zabbix frontend (can also be set in opts, pillar, see module's docstring)

    :return: Array with host interfaces details, False if no convenient host interfaces found or on failure.

    CLI Example:
    .. code-block:: bash

        salt '*' zabbix.hostinterface_get 101054
    uhostinterface.getuextenduoutputuhostidsuurluauthuresultiN(R?RR@RBR0R3R(R�RgRiR.RR)((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pythostinterface_get�s
"

uicK@s�t|�}t}	|s%t|}ny�|r�d}
i|d6|d6|d6|d6|d6|d6|d6}t||�}t|
||d	|d
�}	|	ddSt�Wntk
r�|	SXd
S(u�
    .. versionadded:: 2016.3.0

    Create new host interface

    .. note::
        This function accepts all standard host group interface: keyword
        argument names differ depending on your zabbix version, see here__.

        .. __: https://www.zabbix.com/documentation/3.0/manual/api/reference/hostinterface/object

    :param hostid: ID of the host the interface belongs to

    :param ip_: IP address used by the interface

    :param dns: DNS name used by the interface

    :param main: whether the interface is used as default on the host (0 - not default, 1 - default)

    :param port: port number used by the interface

    :param type: Interface type (1 - agent; 2 - SNMP; 3 - IPMI; 4 - JMX)

    :param useip: Whether the connection should be made via IP (0 - connect
        using host DNS name; 1 - connect using host IP address for this host
        interface)

    :param _connection_user: Optional - zabbix user (can also be set in opts or
        pillar, see module's docstring)

    :param _connection_password: Optional - zabbix password (can also be set in
        opts or pillar, see module's docstring)

    :param _connection_url: Optional - url of zabbix frontend (can also be set
        in opts, pillar, see module's docstring)

    :return: ID of the created host interface, False on failure.

    CLI Example:
    .. code-block:: bash

        salt '*' zabbix.hostinterface_create 10105 192.193.194.197
    uhostinterface.createuhostiduipudnsumainuportutypeuuseipuurluauthuresultuinterfaceidsN(R?RtINTERFACE_DEFAULT_PORTSRBR0R(R�tip_tdnstmaintif_typetuseiptportRgRiR.RR)((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pythostinterface_create�s(,




cK@s�t|�}t}y`|rkd}t|t�r9|}n	|g}t|||d|d�}|ddSt�Wntk
r�|SXdS(uy
    Delete host interface

    .. versionadded:: 2016.3.0

    :param interfaceids: IDs of the host interfaces to delete
    :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
    :param _connection_password: Optional - zabbix password (can also be set in opts or pillar, see module's docstring)
    :param _connection_url: Optional - url of zabbix frontend (can also be set in opts, pillar, see module's docstring)

    :return: ID of deleted host interfaces, False on failure.

    CLI Example:
    .. code-block:: bash

        salt '*' zabbix.hostinterface_delete 50
    uhostinterface.deleteuurluauthuresultuinterfaceidsN(R?RRIRJR0R(tinterfaceidsRgRiR.RR)((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pythostinterface_deletes		

cK@s�t|�}t}y[|rfd}i|d6}t||�}t|||d|d�}|ddSt�Wntk
r�|SXdS(u�
    .. versionadded:: 2016.3.0

    Update host interface

    .. note::
        This function accepts all standard hostinterface: keyword argument
        names differ depending on your zabbix version, see here__.

        .. __: https://www.zabbix.com/documentation/2.4/manual/api/reference/hostinterface/object#host_interface

    :param interfaceid: ID of the hostinterface to update

    :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)

    :param _connection_password: Optional - zabbix password (can also be set in opts or pillar, see module's docstring)

    :param _connection_url: Optional - url of zabbix frontend (can also be set in opts, pillar, see module's docstring)

    :return: ID of the updated host interface, False on failure.

    CLI Example:
    .. code-block:: bash

        salt '*' zabbix.hostinterface_update 6 ip_=0.0.0.2
    uhostinterface.updateuinterfaceiduurluauthuresultuinterfaceidsN(R?RRBR0R(tinterfaceidRgRiR.RR)((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pythostinterface_update<s


cK@s�t|�}t}y~|r�d}	idd6id6}
|r�t|t�rndtj|j�d�d}n|jd�r�|jd�r�d|d}n|
dj	d|�n|r�|
j	d	|�n|r�|
j	d
|�n|r|
j	d|�n|r t
}|
j	d|�n|r;t|
d
t
�}
nt|
|�}
t|	|
|d|d�}t
|d�dkr�|dStSt�Wntk
r�|SXdS(u
    Retrieve user macros according to the given parameters.

    Args:
        macro:          name of the usermacro
        hostids:        Return macros for the given hostids
        templateids:    Return macros for the given templateids
        hostmacroids:   Return macros with the given hostmacroids
        globalmacroids: Return macros with the given globalmacroids (implies globalmacro=True)
        globalmacro:    if True, returns only global macros


        optional connection_args:
                _connection_user: zabbix user (can also be set in opts or pillar, see module's docstring)
                _connection_password: zabbix password (can also be set in opts or pillar, see module's docstring)
                _connection_url: url of zabbix frontend (can also be set in opts or pillar, see module's docstring)

    Returns:
        Array with usermacro details, False if no usermacro found or on failure.

    CLI Example:
    .. code-block:: bash

        salt '*' zabbix.usermacro_get macro='{$SNMP_COMMUNITY}'
    u
usermacro.getuextenduoutputufilteru{iu}umacrouhostidsutemplateidsuhostmacroidsuglobalmacroidstglobalmacrouurluauthuresultN(R?RRIR=RRtkeysR2tendswithR@R&RBR0R3R(tmacroR�ttemplateidsthostmacroidstglobalmacroidsR�RgRiR.RR)((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pyt
usermacro_getfs:$ "

cK@st|�}t}y�|r�i}d}|r�t|t�r`dtj|j�d�d}n|jd�r�|jd�r�d|d}n||d<n||d<||d<t	|dt
|�}t|||d	|d
�}|dddSt�Wntk
r|SXd
S(u�
    Create new host usermacro.

    :param macro: name of the host usermacro
    :param value: value of the host usermacro
    :param hostid: hostid or templateid
    :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
    :param _connection_password: Optional - zabbix password (can also be set in opts or pillar, see module's docstring)
    :param _connection_url: Optional - url of zabbix frontend (can also be set in opts, pillar, see module's docstring)

    return: ID of the created host usermacro.

    CLI Example:

    .. code-block:: bash

        salt '*' zabbix.usermacro_create '{$SNMP_COMMUNITY}' 'public' 1
    uusermacro.createu{iu}umacrouvalueuhostidRAuurluauthuresultuhostmacroidsN(
R?RRIR=RRR�R2R�RBR&R0R(R�tvalueR�RgRiR.R)R((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pytusermacro_create�s($ 




cK@s
t|�}t}y�|r�i}d}|r�t|t�r`dtj|j�d�d}n|jd�r�|jd�r�d|d}n||d<n||d<t	|dt
|�}t|||d|d	�}|d
ddSt�Wntk
r|SXdS(
u�
    Create new global usermacro.

    :param macro: name of the global usermacro
    :param value: value of the global usermacro
    :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
    :param _connection_password: Optional - zabbix password (can also be set in opts or pillar, see module's docstring)
    :param _connection_url: Optional - url of zabbix frontend (can also be set in opts, pillar, see module's docstring)

    return: ID of the created global usermacro.

    CLI Example:

    .. code-block:: bash

        salt '*' zabbix.usermacro_createglobal '{$SNMP_COMMUNITY}' 'public'
    uusermacro.createglobalu{iu}umacrouvalueRAuurluauthuresultuglobalmacroidsN(
R?RRIR=RRR�R2R�RBR&R0R(R�R�RgRiR.R)R((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pytusermacro_createglobal�s&$ 



cK@s�t|�}t}y`|rkd}t|t�r9|}n	|g}t|||d|d�}|ddSt�Wntk
r�|SXdS(uA
    Delete host usermacros.

    :param macroids: macroids of the host usermacros

    :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
    :param _connection_password: Optional - zabbix password (can also be set in opts or pillar, see module's docstring)
    :param _connection_url: Optional - url of zabbix frontend (can also be set in opts, pillar, see module's docstring)

    return: IDs of the deleted host usermacro.

    CLI Example:

    .. code-block:: bash

        salt '*' zabbix.usermacro_delete 21
    uusermacro.deleteuurluauthuresultuhostmacroidsN(R?RRIRJR0R(tmacroidsRgRiR.RR)((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pytusermacro_delete�s		

cK@s�t|�}t}y`|rkd}t|t�r9|}n	|g}t|||d|d�}|ddSt�Wntk
r�|SXdS(uM
    Delete global usermacros.

    :param macroids: macroids of the global usermacros

    :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
    :param _connection_password: Optional - zabbix password (can also be set in opts or pillar, see module's docstring)
    :param _connection_url: Optional - url of zabbix frontend (can also be set in opts, pillar, see module's docstring)

    return: IDs of the deleted global usermacro.

    CLI Example:

    .. code-block:: bash

        salt '*' zabbix.usermacro_deleteglobal 21
    uusermacro.deleteglobaluurluauthuresultuglobalmacroidsN(R?RRIRJR0R(R�RgRiR.RR)((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pytusermacro_deleteglobals		

cK@s�t|�}t}yr|r}i}d}||d<||d<t|dt|�}t|||d|d�}|ddd	St�Wntk
r�|SXd
S(u|
    Update existing host usermacro.

    :param hostmacroid: id of the host usermacro
    :param value: new value of the host usermacro
    :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
    :param _connection_password: Optional - zabbix password (can also be set in opts or pillar, see module's docstring)
    :param _connection_url: Optional - url of zabbix frontend (can also be set in opts, pillar, see module's docstring)

    return: ID of the update host usermacro.

    CLI Example:

    .. code-block:: bash

        salt '*' zabbix.usermacro_update 1 'public'
    uusermacro.updateuhostmacroiduvalueRAuurluauthuresultuhostmacroidsiN(R?RRBR&R0R(thostmacroidR�RgRiR.R)R((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pytusermacro_update<s



cK@s�t|�}t}yr|r}i}d}||d<||d<t|dt|�}t|||d|d�}|ddd	St�Wntk
r�|SXd
S(u�
    Update existing global usermacro.

    :param globalmacroid: id of the host usermacro
    :param value: new value of the host usermacro
    :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
    :param _connection_password: Optional - zabbix password (can also be set in opts or pillar, see module's docstring)
    :param _connection_url: Optional - url of zabbix frontend (can also be set in opts, pillar, see module's docstring)

    return: ID of the update global usermacro.

    CLI Example:

    .. code-block:: bash

        salt '*' zabbix.usermacro_updateglobal 1 'public'
    uusermacro.updateglobalu
globalmacroiduvalueRAuurluauthuresultuglobalmacroidsiN(R?RRBR&R0R(t
globalmacroidR�RgRiR.R)R((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pytusermacro_updateglobal_s



cK@s�t|�}t}y�|r�d}idd6id6}|rR|djd|�n|rk|jd|�nt||�}t|||d|d�}t|d	�d
kr�|d	StSt�Wntk
r�|SXdS(u�
    Retrieve mediatypes according to the given parameters.

    Args:
        name:         Name or description of the mediatype
        mediatypeids: ids of the mediatypes

        optional connection_args:
                _connection_user: zabbix user (can also be set in opts or pillar, see module's docstring)
                _connection_password: zabbix password (can also be set in opts or pillar, see module's docstring)
                _connection_url: url of zabbix frontend (can also be set in opts or pillar, see module's docstring)

                all optional mediatype.get parameters: keyword argument names depends on your zabbix version, see:

                https://www.zabbix.com/documentation/2.2/manual/api/reference/mediatype/get

    Returns:
        Array with mediatype details, False if no mediatype found or on failure.

    CLI Example:
    .. code-block:: bash

        salt '*' zabbix.mediatype_get name='Email'
        salt '*' zabbix.mediatype_get mediatypeids="['1', '2', '3']"
    u
mediatype.getuextenduoutputufilterudescriptionumediatypeidsuurluauthuresultiN(R?RR@RBR0R3R(R6tmediatypeidsRgRiR.RR)((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pyt
mediatype_get�s "

cK@s�t|�}t}yk|rvd}i|d6}||d<t|dt|�}t|||d|d�}|ddSt�Wntk
r�|SXd	S(
uR
    Create new mediatype

    .. note::
        This function accepts all standard mediatype properties: keyword
        argument names differ depending on your zabbix version, see here__.

        .. __: https://www.zabbix.com/documentation/3.0/manual/api/reference/mediatype/object

    :param mediatype: media type - 0: email, 1: script, 2: sms, 3: Jabber, 100: Ez Texting
    :param exec_path: exec path - Required for script and Ez Texting types, see Zabbix API docs
    :param gsm_modem: exec path - Required for sms type, see Zabbix API docs
    :param smtp_email: email address from which notifications will be sent, required for email type
    :param smtp_helo: SMTP HELO, required for email type
    :param smtp_server: SMTP server, required for email type
    :param status: whether the media type is enabled - 0: enabled, 1: disabled
    :param username: authentication user, required for Jabber and Ez Texting types
    :param passwd: authentication password, required for Jabber and Ez Texting types
    :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
    :param _connection_password: Optional - zabbix password (can also be set in opts or pillar, see module's docstring)
    :param _connection_url: Optional - url of zabbix frontend (can also be set in opts, pillar, see module's docstring)

    return: ID of the created mediatype.

    CLI Example:

    .. code-block:: bash

        salt '*' zabbix.mediatype_create 'Email' 0 smtp_email='noreply@example.com'
        smtp_server='mailserver.example.com' smtp_helo='zabbix.example.com'
    umediatype.createudescriptionutypeRAuurluauthuresultumediatypeidN(R?RRBR&R0R(R6t	mediatypeRgRiR.RR)((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pytmediatype_create�s 



cK@s�t|�}t}y`|rkd}t|t�r9|}n	|g}t|||d|d�}|ddSt�Wntk
r�|SXdS(uE
    Delete mediatype


    :param interfaceids: IDs of the mediatypes to delete
    :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
    :param _connection_password: Optional - zabbix password (can also be set in opts or pillar, see module's docstring)
    :param _connection_url: Optional - url of zabbix frontend (can also be set in opts, pillar, see module's docstring)

    :return: ID of deleted mediatype, False on failure.

    CLI Example:
    .. code-block:: bash

        salt '*' zabbix.mediatype_delete 3
    umediatype.deleteuurluauthuresultumediatypeidsN(R?RRIRJR0R(R�RgRiR.RR)((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pytmediatype_delete�s		

cK@s�t|�}t}y�|r�d}i|d6}|rA||d<n|rT||d<nt||�}t|||d|d�}|ddSt�Wntk
r�|SXd	S(
ug
    Update existing mediatype

    .. note::
        This function accepts all standard mediatype properties: keyword
        argument names differ depending on your zabbix version, see here__.

        .. __: https://www.zabbix.com/documentation/3.0/manual/api/reference/mediatype/object

    :param mediatypeid: ID of the mediatype to update
    :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
    :param _connection_password: Optional - zabbix password (can also be set in opts or pillar, see module's docstring)
    :param _connection_url: Optional - url of zabbix frontend (can also be set in opts, pillar, see module's docstring)

    :return: IDs of the updated mediatypes, False on failure.

    CLI Example:
    .. code-block:: bash

        salt '*' zabbix.usergroup_update 8 name="Email update"
    umediatype.updateumediatypeidudescriptionutypeuurluauthuresultumediatypeidsN(R?RRBR0R(RyR6R�RgRiR.RR)((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pytmediatype_update	s 




cK@s�t|�}t}y�|r�d}idd6id6}|rR|djd|�n|ro|djd|�n|r�|jd|�nt||�}t|||d|d	�}t|d
�dkr�|d
StSt�Wntk
r�|SXdS(
u"
    Retrieve templates according to the given parameters.

    Args:
        host: technical name of the template
        name: visible name of the template
        hostids: ids of the templates

        optional connection_args:
                _connection_user: zabbix user (can also be set in opts or pillar, see module's docstring)
                _connection_password: zabbix password (can also be set in opts or pillar, see module's docstring)
                _connection_url: url of zabbix frontend (can also be set in opts or pillar, see module's docstring)

                all optional template.get parameters: keyword argument names depends on your zabbix version, see:

                https://www.zabbix.com/documentation/2.4/manual/api/reference/template/get

    Returns:
        Array with convenient template details, False if no template found or on failure.

    CLI Example:
    .. code-block:: bash

        salt '*' zabbix.template_get name='Template OS Linux'
        salt '*' zabbix.template_get templateids="['10050', '10001']"
    utemplate.getuextenduoutputufilterunameuhostutemplateidsuurluauthuresultiN(R?RR@RBR0R3R(R6R�R�RgRiR.RR)((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pyttemplate_get*	s$"

cK@s�t|�}t}y�|r�|}|}t||�}t|||d|d�}t|dt�rn|dSt|d�dkr�|dStSt�Wntk
r�|SXdS(u�
    Send Zabbix API call

    Args:
        method: actual operation to perform via the API
        params: parameters required for specific method

        optional connection_args:
                _connection_user: zabbix user (can also be set in opts or pillar, see module's docstring)
                _connection_password: zabbix password (can also be set in opts or pillar, see module's docstring)
                _connection_url: url of zabbix frontend (can also be set in opts or pillar, see module's docstring)

                all optional template.get parameters: keyword argument names depends on your zabbix version, see:

                https://www.zabbix.com/documentation/2.4/manual/api/reference/

    Returns:
        Response from Zabbix API

    CLI Example:
    .. code-block:: bash

        salt '*' zabbix.run_query proxy.create '{"host": "zabbixproxy.domain.com", "status": "5"}'
    uurluauthuresultiN(R?RRBR0RIR�R3R(RR)RgRiR.((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pyReZ	s"

uxmlc
K@sB|dkri}niitd6td6td6d6itd6td6td6d6itd6td6td6d6itd6d6itd6td6d6itd6td6d	6itd6td6td6d
6itd6td6d6itd6td6d6itd6d
6itd6td6d6itd6td6td6d6itd6td6td6d6itd6td6d6}t|�}|r�xC|D]8}||kr�||j||�qv||||<qvWnd|kr!tjjj�}t	d||�}|st
jj|�dkrRi|d6td6dd6Sn1|}t
jj
|�sRi|d6td6dd6Stjjj|dd��}	|	j�}
WdQXd|kr�tjjj|�ni|d6|d6|
d6}tjd tj|d��y-td!||�i|d6td6d"d6SWn2tk
r=}i|d6td6tj|�d6SXdS(#u�
    .. versionadded:: 2017.7

    Imports Zabbix configuration specified in file to Zabbix server.

    :param config_file: File with Zabbix config (local or remote)
    :param rules: Optional - Rules that have to be different from default (defaults are the same as in Zabbix web UI.)
    :param file_format: Config file format (default: xml)
    :param _connection_user: Optional - zabbix user (can also be set in opts or pillar, see module's docstring)
    :param _connection_password: Optional - zabbix password (can also be set in opts or pillar, see module's docstring)
    :param _connection_url: Optional - url of zabbix frontend (can also be set in opts, pillar, see module's docstring)

    CLI Example:

    .. code-block:: bash

        salt '*' zabbix.configuration_import salt://zabbix/config/zabbix_templates.xml         "{'screens': {'createMissing': True, 'updateExisting': True}}"
    u
createMissinguupdateExistingu
deleteMissinguapplicationsudiscoveryRulesugraphsugroupsuhostsuimagesuitemsumapsuscreensutemplateLinkageu	templatesutemplateScreensutriggersu	valueMapsusalt://ucp.get_fileiunameuresultuFailed to fetch config file.umessageuInvalid file path.tmodeurNuformaturulesusourceuCONFIGURATION IMPORT: rules: %suconfiguration.importu=Zabbix API "configuration.import" method called successfully.(R1R&RR=RLRR
tfilestmkstempR5tostpathtgetsizetisfiletfopentreadtsafe_rmR$R%RRReR(
tconfig_filetrulestfile_formatRgt
default_rulest	new_rulestrulettmpfiletcfiletfp_txmlR)texc((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pytconfiguration_import�	sV	


(
u	hostgrouputemplateuhostumaintenanceuactionudruleuserviceuproxyuscreenu	usergroupu	mediatypeuscriptuvaluemap(Yt__doc__t
__future__RRRtloggingR
R�tsalt.extRtsalt.exceptionsRtsalt.utils.dataRtsalt.utils.filestsalt.utils.httptsalt.utils.jsontsalt.utils.versionsRR�tsalt.ext.six.moves.urllib.errorRRt	getLoggert__name__R$R�RKRCRR	RR1R0R?RRBRDRERTRMRjRoRqRrRtRvRwR~R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�R�ReR�(((s7/usr/lib/python2.7/site-packages/salt/modules/zabbix.pyt<module>s�
		2	?!	(N		3	$	 (	'+	0	#		'	!77	'		:	#A2	-	$	7		'	#<5*		-E	#	*;	+	)	#	#	#	#-	0	")0	*

Zerion Mini Shell 1.0