%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/infoblox.pyc

�
���^c@@s0dZddlmZmZmZddlZddlmZdZ	yddl
Z
Wn"ek
rxZej
e�Z	nXdZd�ZiZd�Zd�Zd	�Zd
�Zd�Zd�Zd
�Zd�Zddded�Zd�Zdddd�Zd�Zddd�Zddddd�Zdddd�Z dd�Z!dd�Z"ded�Z#dded�Z$ddddd�Z%ddddd�Z&dddd�Z'dddd�Z(d�Z)dddd�Z*ddd �Z+d!�Z,d"�Z-dde.d#�Z/dded$�Z0dS(%u�
This module have been tested on infoblox API v1.2.1,
other versions of the API are likly workable.

:depends: libinfoblox, https://github.com/steverweber/libinfoblox

    libinfoblox can be installed using `pip install libinfoblox`

API documents can be found on your infoblox server at:

    https://INFOBLOX/wapidoc

:configuration: The following configuration defaults can be
    defined (pillar or config files '/etc/salt/master.d/infoblox.conf'):

    .. code-block:: python

        infoblox.config:
            api_sslverify: True
            api_url: 'https://INFOBLOX/wapi/v1.2.1'
            api_user: 'username'
            api_key: 'password'

    Many of the functions accept `api_opts` to override the API config.

    .. code-block:: bash

        salt-call infoblox.get_host name=my.host.com             api_url: 'https://INFOBLOX/wapi/v1.2.1'             api_user=admin             api_key=passs

i(tabsolute_importtprint_functiontunicode_literalsN(tsixuinfobloxcC@stdktfS(N(t
IMPORT_ERRtNone(((s9/usr/lib/python2.7/site-packages/salt/modules/infoblox.pyt__virtual__3scK@s�itd6dd6dd6dd6}dt�kr]djt�}|jtd	|i��nx8t|j��t|j��@D]}||||<q�W|S(
uU
    Return configuration
    user passed api_opts override salt config.get vars
    u
api_sslverifyuhttps://INFOBLOX/wapi/v1.2.1uapi_urluuapi_useruapi_keyu__salt__u
{0}.configu
config.get(tTruetglobalstformatt__virtualname__tupdatet__salt__tsettkeys(tapi_optstconfigt
config_keytk((s9/usr/lib/python2.7/site-packages/salt/modules/infoblox.pyt_get_config:s
)cK@s�t|�}dj|d|d|d�}|tkr�ttj��t|d}t|dr�|dkr�t|dSni}ttj��|d<tjd|d	d
|dd|dd|d�|d<|t|<|dS(
Nuinfoblox_session_{0},{1},{2}uapi_urluapi_useruapi_keyutimeuobji<t
api_sslverifyu
api_sslverifytapi_urltapi_usertapi_key(RR	tcachetintttimetlibinfobloxtSession(RRt	cache_keyt	timedeltatc((s9/usr/lib/python2.7/site-packages/salt/modules/infoblox.pyt
_get_infobloxNs
cC@stj||�S(u�
    Diff two complex infoblox objects.
    This is used from salt states to detect changes in objects.

    Using ``func:nextavailableip`` will not cause a diff if the ipaddress is in
    range
    (Rtdiff_obj(tobjatobjb((s9/usr/lib/python2.7/site-packages/salt/modules/infoblox.pytdiff_objects_scC@stj||�S(u�
    Return true if the ipaddress is in the range of the nextavailableip function

    CLI Example:

    .. code-block:: bash

        salt-call infoblox.is_ipaddr_in_ipfunc_range             ipaddr="10.0.2.2" ipfunc="func:nextavailableip:10.0.0.0/8"
    (Rtis_ipaddr_in_ipfunc_range(tipaddrtipfunc((s9/usr/lib/python2.7/site-packages/salt/modules/infoblox.pyR%jscK@s,td||�}td|dd||�S(u�
    Update host record. This is a helper call to update_object.

    Find a hosts ``_ref`` then call update_object with the record data.

    CLI Example:

    .. code-block:: bash

        salt-call infoblox.update_host name=fqdn data={}
    tnametobjrefu_reftdata(tget_hostt
update_object(R(R*Rto((s9/usr/lib/python2.7/site-packages/salt/modules/infoblox.pytupdate_hostxscK@sIdt�kr-tdr-idj|�d6St|�}|j||�S(u�
    Update raw infoblox object. This is a low level api call.

    CLI Example:

    .. code-block:: bash

        salt-call infoblox.update_object objref=[ref_of_object] data={}
    u__opts__utestu#Would attempt to update object: {0}uTest(Rt__opts__R	R R,(R)R*Rtinfoblox((s9/usr/lib/python2.7/site-packages/salt/modules/infoblox.pyR,�s
cK@sFdt�kr-tdr-idj|�d6St|�}|j|�S(u�
    Delete infoblox object. This is a low level api call.

    CLI Example:

    .. code-block:: bash

        salt-call infoblox.delete_object objref=[ref_of_object]
    u__opts__utestu#Would attempt to delete object: {0}uTest(RR/R	R t
delete_object(R)RR0((s9/usr/lib/python2.7/site-packages/salt/modules/infoblox.pyR1�s
cK@sIdt�kr-tdr-idj|�d6St|�}|j||�S(u�
    Create raw infoblox object. This is a low level api call.

    CLI Example:

    .. code-block:: bash

        salt-call infoblox.update_object object_type=record:host  data={}
    u__opts__utestu#Would attempt to create object: {0}uTest(RR/R	R t
create_object(tobject_typeR*RR0((s9/usr/lib/python2.7/site-packages/salt/modules/infoblox.pyR2�s
cK@s4|si}nt|�}|j|||||�S(u�
    Get raw infoblox object. This is a low level api call.

    CLI Example:

    .. code-block:: bash

        salt-call infoblox.get_object objref=[_ref of object]
    (R t
get_object(R)R*t
return_fieldstmax_resultstensure_none_or_one_resultRR0((s9/usr/lib/python2.7/site-packages/salt/modules/infoblox.pyR4�s
	cK@s"t|�}|jd|�}|S(uZ
    Create a cname record.

    CLI Example:

    .. code-block:: bash

        salt-call infoblox.create_cname data={             "comment": "cname to example server",             "name": "example.example.com",             "zone": "example.com",             "view": "Internal",             "canonical": "example-ha-0.example.com"         }
    R*(R tcreate_cname(R*RR0thost((s9/usr/lib/python2.7/site-packages/salt/modules/infoblox.pyR8�scK@s.t|�}|jd|d|d|�}|S(u�
    Get CNAME information.

    CLI Examples:

    .. code-block:: bash

        salt-call infoblox.get_cname name=example.example.com
        salt-call infoblox.get_cname canonical=example-ha-0.example.com
    R(t	canonicalR5(R t	get_cname(R(R:R5RR0R-((s9/usr/lib/python2.7/site-packages/salt/modules/infoblox.pyR;�scK@sAtd||�}|s'td��ntd|dd||�S(u�
    Update CNAME. This is a helper call to update_object.

    Find a CNAME ``_ref`` then call update_object with the record data.

    CLI Example:

    .. code-block:: bash

        salt-call infoblox.update_cname name=example.example.com data="{
                'canonical':'example-ha-0.example.com',
                'use_ttl':true,
                'ttl':200,
                'comment':'Salt managed CNAME'}"
    R(uCNAME record not foundR)u_refR*(R;t	ExceptionR,(R(R*RR-((s9/usr/lib/python2.7/site-packages/salt/modules/infoblox.pytupdate_cname�scK@s3td|d||�}|r/t|d|�StS(u"
    Delete CNAME. This is a helper call to delete_object.

    If record is not found, return True

    CLI Examples:

    .. code-block:: bash

        salt-call infoblox.delete_cname name=example.example.com
        salt-call infoblox.delete_cname canonical=example-ha-0.example.com
    R(R:u_ref(R;R1R(R(R:Rtcname((s9/usr/lib/python2.7/site-packages/salt/modules/infoblox.pytdelete_cnames
c	K@s4t|�}|jd|d|d|d|�}|S(u�
    Get host information

    CLI Examples:

    .. code-block:: bash

        salt-call infoblox.get_host hostname.domain.ca
        salt-call infoblox.get_host ipv4addr=123.123.122.12
        salt-call infoblox.get_host mac=00:50:56:84:6e:ae
    R(tmactipv4addrR5(R R+(R(RAR@R5RR0R9((s9/usr/lib/python2.7/site-packages/salt/modules/infoblox.pyR+s$cK@s.t|�}|jd|d|d|�}|S(u�
    Get all host information

    CLI Example:

    .. code-block:: bash

        salt-call infoblox.get_host_advanced hostname.domain.ca
    R(R@RA(R tget_host_advanced(R(RAR@RR0R9((s9/usr/lib/python2.7/site-packages/salt/modules/infoblox.pyRB)s
cK@s�|j�jd�}|s~td||�}|rMd|krM|dj�S|jd�dkrw||jd�dS|Snd}xS|D]K}|j�jd�}|j|�r�t|�t|�kr�|}q�q�Wt|�dkr�|SdS(u�
    Get host domain name

    If no domains are passed, the hostname is checked for a zone in infoblox,
    if no zone split on first dot.

    If domains are provided, the best match out of the list is returned.

    If none are found the return is None

    dots at end of names are ignored.

    CLI Example:

    .. code-block:: bash

        salt-call uwl.get_host_domainname name=localhost.t.domain.com             domains=['domain.com', 't.domain.com.']

        # returns: t.domain.com
    u.R(uzoneiuiN(tlowertrstripR+tcounttfindtendswithtlenR(R(tdomainsRR*tmatchtd((s9/usr/lib/python2.7/site-packages/salt/modules/infoblox.pytget_host_domainname8s 
'
cK@si|j�jd�}|s,|jd�dSt|||�}|re||kre|jd|�dS|S(u�
    Get hostname

    If no domains are passed, the hostname is checked for a zone in infoblox,
    if no zone split on first dot.

    If domains are provided, the best match out of the list is truncated from
    the fqdn leaving the hostname.

    If no matching domains are found the fqdn is returned.

    dots at end of names are ignored.

    CLI Examples:

    .. code-block:: bash

        salt-call infoblox.get_host_hostname fqdn=localhost.xxx.t.domain.com             domains="['domain.com', 't.domain.com']"
        #returns: localhost.xxx

        salt-call infoblox.get_host_hostname fqdn=localhost.xxx.t.domain.com
        #returns: localhost
    u.i(RCRDtsplitRLtrsplit(R(RIRtdomain((s9/usr/lib/python2.7/site-packages/salt/modules/infoblox.pytget_host_hostnameascK@s~td||�}|rzd|krzg}x2|dD]&}d|kr5|j|d�q5q5W|ri|S|rz|dSndS(u�
    Get mac address from host record.

    Use `allow_array` to return possible multiple values.

    CLI Example:

    .. code-block:: bash

        salt-call infoblox.get_host_mac host=localhost.domain.com
    R(u	ipv4addrsumaciN(R+tappendR(R(tallow_arrayRR*tlta((s9/usr/lib/python2.7/site-packages/salt/modules/infoblox.pytget_host_mac�scK@s�td|d||�}|r�d|kr�g}x2|dD]&}d|kr;|j|d�q;q;W|ro|S|r�|dSndS(u
    Get ipv4 address from host record.

    Use `allow_array` to return possible multiple values.

    CLI Examples:

    .. code-block:: bash

        salt-call infoblox.get_host_ipv4 host=localhost.domain.com
        salt-call infoblox.get_host_ipv4 mac=00:50:56:84:6e:ae
    R(R@u	ipv4addrsuipv4addriN(R+RQR(R(R@RRRR*RSRT((s9/usr/lib/python2.7/site-packages/salt/modules/infoblox.pyt
get_host_ipv4�s
cK@s"t|�}|j||||�S(uY
    Get host ipv4addr information

    CLI Examples:

    .. code-block:: bash

        salt-call infoblox.get_ipv4addr ipv4addr=123.123.122.12
        salt-call infoblox.get_ipv4addr mac=00:50:56:84:6e:ae
        salt-call infoblox.get_ipv4addr mac=00:50:56:84:6e:ae return_fields=host return_fields='mac,host,configure_for_dhcp,ipv4addr'
    (R tget_host_ipv4addr_object(RAR@tdiscovered_dataR5RR0((s9/usr/lib/python2.7/site-packages/salt/modules/infoblox.pytget_host_ipv4addr_info�scK@s"t|�}|j||||�S(u�
    Get host ipv6addr information

    CLI Example:

    .. code-block:: bash

        salt-call infoblox.get_host_ipv6addr_info ipv6addr=2001:db8:85a3:8d3:1349:8a2e:370:7348
    (R tget_host_ipv6addr_object(tipv6addrR@RXR5RR0((s9/usr/lib/python2.7/site-packages/salt/modules/infoblox.pytget_host_ipv6addr_info�scK@s(t|�}|jd|d|d|�S(uN
    Get list of all networks. This is helpful when looking up subnets to use
    with func:nextavailableip

    This call is offen slow and not cached!

    some return_fields
    comment,network,network_view,ddns_domainname,disable,enable_ddns

    CLI Example:

    .. code-block:: bash

        salt-call infoblox.get_network
    RAtnetworkR5(R tget_network(RAR]R5RR0((s9/usr/lib/python2.7/site-packages/salt/modules/infoblox.pyR^�scK@sCdt�kr$tdr$idd6St|�}|j|||�S(u
    Delete host

    CLI Example:

    .. code-block:: bash

        salt-call infoblox.delete_host name=example.domain.com
        salt-call infoblox.delete_host ipv4addr=123.123.122.12
        salt-call infoblox.delete_host ipv4addr=123.123.122.12 mac=00:50:56:84:6e:ae
    u__opts__utestuWould attempt to delete hostuTest(RR/R tdelete_host(R(R@RARR0((s9/usr/lib/python2.7/site-packages/salt/modules/infoblox.pyR_�scK@std||�S(u
    Add host record

    Avoid race conditions, use func:nextavailableip for ipv[4,6]addrs:

    - func:nextavailableip:network/ZG54dfgsrDFEFfsfsLzA:10.0.0.0/8/default
    - func:nextavailableip:10.0.0.0/8
    - func:nextavailableip:10.0.0.0/8,external
    - func:nextavailableip:10.0.0.3-10.0.0.10

    See your infoblox API for full `data` format.

    CLI Example:

    .. code-block:: bash

        salt-call infoblox.create_host             data =
                {'name': 'hostname.example.ca',
                'aliases': ['hostname.math.example.ca'],
            'extattrs': [{'Business Contact': {'value': 'example@example.ca'}},
                {'Pol8 Classification': {'value': 'Restricted'}},
                {'Primary OU': {'value': 'CS'}},
                {'Technical Contact': {'value': 'example@example.ca'}}],
            'ipv4addrs': [{'configure_for_dhcp': True,
                'ipv4addr': 'func:nextavailableip:129.97.139.0/24',
                'mac': '00:50:56:84:6e:ae'}],
            'ipv6addrs': [], }
    urecord:host(R2(R*R((s9/usr/lib/python2.7/site-packages/salt/modules/infoblox.pytcreate_host�scK@st|�}|j|||�S(u�
    Get ip range

    CLI Example:

    .. code-block:: bash

        salt-call infoblox.get_ipv4_range start_addr=123.123.122.12
    (R t	get_range(t
start_addrtend_addrR5RR0((s9/usr/lib/python2.7/site-packages/salt/modules/infoblox.pytget_ipv4_ranges
cK@s1t|||�}|r)t|d|�StSdS(u�
    Delete ip range.

    CLI Example:

    .. code-block:: bash

        salt-call infoblox.delete_ipv4_range start_addr=123.123.122.12
    u_refN(RdR1R(RbRcRtr((s9/usr/lib/python2.7/site-packages/salt/modules/infoblox.pytdelete_ipv4_range-s
cK@std||�S(u4
    Create a ipv4 range

    This is a helper function to `create_object`
    See your infoblox API for full `data` format.

    CLI Example:

    .. code-block:: bash

        salt-call infoblox.create_ipv4_range data={
            start_addr: '129.97.150.160',
            end_addr: '129.97.150.170'}
    urange(R2(R*R((s9/usr/lib/python2.7/site-packages/salt/modules/infoblox.pytcreate_ipv4_range>scK@std||�S(un
    Create A record.

    This is a helper function to `create_object`.
    See your infoblox API for full `data` format.

    CLI Example:

    .. code-block:: bash

        salt-call infoblox.create_a                     data =
                    name: 'fastlinux.math.example.ca'
                    ipv4addr: '127.0.0.1'
                    view: External
    urecord:a(R2(R*R((s9/usr/lib/python2.7/site-packages/salt/modules/infoblox.pytcreate_aPscK@ssi}|r||d<n|r,||d<ntdd||�}|rot|�dkro|rotd��n|S(u�
    Get A record

    CLI Examples:

    .. code-block:: bash

        salt-call infoblox.get_a name=abc.example.com
        salt-call infoblox.get_a ipv4addr=192.168.3.5
    unameuipv4addrurecord:aR*iu8More than one result, use allow_array to return the data(R4RHR<(R(RARRRR*Re((s9/usr/lib/python2.7/site-packages/salt/modules/infoblox.pytget_ads

cK@s�t||dt|�}|s"tSt|�dkr8tSt|�dkr`|r`td��ng}x(|D] }|jt|d|��qmW|S(u�
    Delete A record

    If the A record is used as a round robin you can set ``allow_array=True`` to
    delete all records for the hostname.

    CLI Examples:

    .. code-block:: bash

        salt-call infoblox.delete_a name=abc.example.com
        salt-call infoblox.delete_a ipv4addr=192.168.3.5
        salt-call infoblox.delete_a name=acname.example.com allow_array=True
    RRiiu1More than one result, use allow_array to overrideu_ref(RitFalseRRHR<RQR1(R(RARRRRetrettri((s9/usr/lib/python2.7/site-packages/salt/modules/infoblox.pytdelete_azs
(1t__doc__t
__future__RRRRtsalt.extRRRRR<texct	text_typeR
RRRR R$R%R.R,R1R2RjR4R8R;R=R?R+RBRLRPRURVRYR\R^R_R`RdRfRgRhRRiRm(((s9/usr/lib/python2.7/site-packages/salt/modules/infoblox.pyt<module>"s\												)"	!		

Zerion Mini Shell 1.0