%PDF- %PDF-
Mini Shell

Mini Shell

Direktori : /lib/python2.7/site-packages/salt/pillar/
Upload File :
Create Path :
Current File : //lib/python2.7/site-packages/salt/pillar/netbox.pyc

�
���^c@@sfdZddlmZmZmZddlZddlZddlm	Z	ej
e�Zd�Z
dS(u�
A module that adds data to the Pillar structure from a NetBox API.

.. versionadded:: 2019.2.0

Configuring the NetBox ext_pillar
---------------------------------

.. code-block:: yaml

  ext_pillar:
    - netbox:
        api_url: http://netbox_url.com/api/
        api_token: 123abc

Create a token in your NetBox instance at
http://netbox_url.com/user/api-tokens/

The following options are optional, and determine whether or not
the module will attempt to configure the ``proxy`` pillar data for
use with the napalm proxy-minion:

.. code-block:: yaml

  proxy_return: True
  proxy_username: admin

By default, this module will query the NetBox API for the platform
associated with the device, and use the 'NAPALM driver' field to
set the napalm proxy-minion driver. (Currently only 'napalm' is supported
for drivertype.)

This module currently only supports the napalm proxy minion and assumes
you will use SSH keys to authenticate to the network device.  If password
authentication is desired, it is recommended to create another ``proxy``
key in pillar_roots (or git_pillar) with just the ``passwd`` key and use
:py:func:`salt.renderers.gpg <salt.renderers.gpg>` to encrypt the value.
If any additional options for the proxy setup are needed they should also be
configured in pillar_roots.

Other available options:

site_details: ``True``
    Whether should retrieve details of the site the device belongs to.

site_prefixes: ``True``
    Whether should retrieve the prefixes of the site the device belongs to.
i(tabsolute_importtprint_functiontunicode_literalsN(t	ipaddressc	O@s2|dkrtjd�iS|djd�}|jd�}|jdt�}|jdt�}|jdd:�}|jd	t�}	i}
i}|r�id
j|�d6}ndjd
|dddd�}tjj	j
|di|d6d|dt�}
d|
kr6tjd||
d�tj|
d�|
S|
dd}t|�dkrg|d|
d<n:t|�dkr�tjd|�|
Stjd|�|
S|
dd d!}|
dd d}|rxtj
d"|||�d#jd
|dddd$d%|�}tjj	j
|d|dt�}d|krctjd&||�tjd'|d|d�qx|d|
dd <n|r:tj
d(|||�djd
|dd)dd*�}tjj	j
|di|d+6d|dt�}d|krtjd,||�tjd'|d|d�q:|dd|
dd d*<n|	r.y�tjj	j
|
dd-d.d|dt�}d|kr�tjd/||d�n|djd0�}|rittj|
dd1d2�j�d36|d46d5d66|
d7<|r||
d7d8<qnWq.tk
r*tj
d9|�q.Xn|
S(;u*
    Query NetBox API for minion data
    u*u5There's no data to collect from NetBox for the Masteruapi_urlu/u	api_tokenusite_detailsu
site_prefixesuproxy_usernameuproxy_returnuToken {}u
Authorizationu{api_url}/{app}/{endpoint}tapi_urltappudcimtendpointudevicestparamsunametheader_dicttdecodeuerroru*API query failed for "%s", status code: %dustatusudicturesultsiiunetboxu#More than one device found for "%s"u#Unable to pull NetBox data for "%s"usiteuidu2Retrieving site details for "%s" - site %s (ID %d)u%{api_url}/{app}/{endpoint}/{site_id}/usitestsite_idu.Unable to retrieve site details for %s (ID %d)uStatus code: %d, error: %su3Retrieving site prefixes for "%s" - site %s (ID %d)uipamuprefixesusite_idu/Unable to retrieve site prefixes for %s (ID %d)uplatformuurluAPI query failed for "%s": %su
napalm_driveruprimary_ip4uaddressuhostudriverunapalmu	proxytypeuproxyuusernameu+Could not create proxy config data for "%s"N(tlogtinfotrstriptgettTruetNonetformattsalttutilsthttptqueryterrortlentdebugtstrRt
IPv4Interfacetipt	Exception(t	minion_idtpillartargstkwargsRt	api_tokentsite_detailst
site_prefixestproxy_usernametproxy_returntrettheaderst
device_urltdevice_resultstdevicesR
t	site_nametsite_urltsite_details_rettprefixes_urltsite_prefixes_rettplatform_resultst
napalm_driver((s6/usr/lib/python2.7/site-packages/salt/pillar/netbox.pyt
ext_pillar=s�
	
			
			
		
	
		
				
(t__doc__t
__future__RRRtloggingtsalt.utils.httpRtsalt._compatRt	getLoggert__name__RR2(((s6/usr/lib/python2.7/site-packages/salt/pillar/netbox.pyt<module>1s

Zerion Mini Shell 1.0