Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/modules/network/frr/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/modules/network/frr/frr_facts.pyo

�
�Udac	@`sdddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
Z
ddlZddlm
Z
mZdd
lmZddlmZdefd��YZdefd��YZdefd��YZdefd��YZdefd��YZedededede�Zeej��Zd�Zedkr`e�ndS(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatustnetworktsupported_bys�
---
module: frr_facts
version_added: "2.8"
author: "Nilashish Chakraborty (@NilashishC)"
short_description: Collect facts from remote devices running Free Range Routing (FRR).
description:
  - Collects a base set of device facts from a remote device that
    is running FRR.  This module prepends all of the
    base network fact keys with C(ansible_net_<fact>).  The facts
    module will always collect a base set of facts from the device
    and can enable or disable collection of additional facts.
notes:
  - Tested against FRR 6.0.
options:
  gather_subset:
    description:
      - When supplied, this argument restricts the facts collected
         to a given subset.
      - Possible values for this argument include
         C(all), C(hardware), C(config), and C(interfaces).
      - Specify a list of values to include a larger subset.
      - Use a value with an initial C(!) to collect all facts except that subset.
    required: false
    default: '!config'
s{
- name: Collect all facts from the device
  frr_facts:
    gather_subset: all

- name: Collect only the config and default facts
  frr_facts:
    gather_subset:
      - config

- name: Collect the config and hardware facts
  frr_facts:
    gather_subset:
      - config
      - hardware

- name: Do not collect hardware facts
  frr_facts:
    gather_subset:
      - "!hardware"
s�
ansible_net_gather_subset:
  description: The list of fact subsets collected from the device
  returned: always
  type: list

# default
ansible_net_hostname:
  description: The configured hostname of the device
  returned: always
  type: str
ansible_net_version:
  description: The FRR version running on the remote device
  returned: always
  type: str
ansible_net_api:
  description: The name of the transport
  returned: always
  type: str
ansible_net_python_version:
  description: The Python version that the Ansible controller is using
  returned: always
  type: str

# hardware
ansible_net_mem_stats:
  description: The memory statistics fetched from the device
  returned: when hardware is configured
  type: dict

# config
ansible_net_config:
  description: The current active config from the device
  returned: when config is configured
  type: str

# interfaces
ansible_net_all_ipv4_addresses:
  description: All IPv4 addresses configured on the device
  returned: when interfaces is configured
  type: list
ansible_net_all_ipv6_addresses:
  description: All IPv6 addresses configured on the device
  returned: when interfaces is configured
  type: list
ansible_net_interfaces:
  description: A hash of all interfaces running on the system
  returned: when interfaces is configured
  type: dict
ansible_net_mpls_ldp_neighbors:
  description: The list of MPLS LDP neighbors from the remote device
  returned: when interfaces is configured and LDP daemon is running on the device
  type: dict
N(trun_commandstget_capabilities(t
AnsibleModule(t	iteritemst	FactsBasecB`s5eZe�Zd�Zd�Zd�Zd�ZRS(cC`s4||_t�|_d|_t|j�|_dS(N(tmoduletdicttfactstNonet	responsesR	t
_capabilities(tselfR
((sI/usr/lib/python2.7/site-packages/ansible/modules/network/frr/frr_facts.pyt__init__�s		cC`s%t|jd|jdt�|_dS(Ntcommandstcheck_rc(RR
tCOMMANDStFalseR(R((sI/usr/lib/python2.7/site-packages/ansible/modules/network/frr/frr_facts.pytpopulate�scC`std|dt�S(NRR(RR(Rtcmd((sI/usr/lib/python2.7/site-packages/ansible/modules/network/frr/frr_facts.pytrun�scC`s:d}tj||tj�}|r6|jd�}n|S(Ni(RtretsearchtMtgroup(Rtpatterntdatatvaluetmatch((sI/usr/lib/python2.7/site-packages/ansible/modules/network/frr/frr_facts.pytparse_facts�s
(t__name__t
__module__tlistRRRRR$(((sI/usr/lib/python2.7/site-packages/ansible/modules/network/frr/frr_facts.pyRs
				tDefaultcB`s#eZdgZd�Zd�ZRS(sshow versioncC`s-tt|�j�|jj|j��dS(N(tsuperR(RRtupdatetplatform_facts(R((sI/usr/lib/python2.7/site-packages/ansible/modules/network/frr/frr_facts.pyR�scC`s�i}|j}|d}|d|d<x4d
D],}|jd|�}|r.|||<q.q.W|d|d<tj�|d	<|S(Ntdevice_infot
network_ostsystemtversionthostnames
network_os_%stnetwork_apitapitpython_version(sversionR0(RtgettplatformR3(RR+trespR,titemtval((sI/usr/lib/python2.7/site-packages/ansible/modules/network/frr/frr_facts.pyR+�s	

(R%R&RRR+(((sI/usr/lib/python2.7/site-packages/ansible/modules/network/frr/frr_facts.pyR(�s		tHardwarecB`s,eZdgZd�Zd�Zd�ZRS(sshow memorycC`s/tjd|tj�}|r+|jd�SdS(NsMemory statistics for (\w+)i(RRRR(RR!R#((sI/usr/lib/python2.7/site-packages/ansible/modules/network/frr/frr_facts.pyt_parse_daemons�sc	C`s�|jd�}i}i	dd6dd6dd6dd	6d
d6dd
6dd6dd6dd6}x^|D]V}|j|�}i||<x4t|�D]&\}}|j||�|||<q�WqaW|S(Ns

s Total heap allocated:(?:\s*)(.*)ttotal_heap_allocateds!Holding block headers:(?:\s*)(.*)tholding_block_headerssUsed small blocks:(?:\s*)(.*)tused_small_blockss Used ordinary blocks:(?:\s*)(.*)tused_ordinary_blockssFree small blocks:(?:\s*)(.*)tfree_small_blockss Free ordinary blocks:(?:\s*)(.*)tfree_ordinary_blockssOrdinary blocks:(?:\s*)(.*)tordinary_blockssSmall blocks:(?:\s*)(.*)tsmall_blockssHolding blocks:(?:\s*)(.*)tholding_blocks(tsplitR:RR$(	RR!tmem_detailst	mem_statstmem_countersR7tdaemontfactR ((sI/usr/lib/python2.7/site-packages/ansible/modules/network/frr/frr_facts.pytgather_memory_facts�s$


"cC`sCtt|�j�|jd}|r?|j|�|jd<ndS(NiRF(R)R9RRRJR(RR!((sI/usr/lib/python2.7/site-packages/ansible/modules/network/frr/frr_facts.pyR�s
(R%R&RR:RJR(((sI/usr/lib/python2.7/site-packages/ansible/modules/network/frr/frr_facts.pyR9�s			tConfigcB`seZdgZd�ZRS(sshow running-configcC`sXtt|�j�|jd}|rTtjdd|dtj�}||jd<ndS(Nis3^Building configuration...\s+Current configuration:ttflagstconfig(R)RKRRRtsubt	MULTILINER(RR!((sI/usr/lib/python2.7/site-packages/ansible/modules/network/frr/frr_facts.pyR�s

(R%R&RR(((sI/usr/lib/python2.7/site-packages/ansible/modules/network/frr/frr_facts.pyRK�s	t
InterfacescB`sPeZdgZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	RS(sshow interfacecC`s�|jdd}|r*|jjd�ntt|�j�|jd}t�|jd<t�|jd<|r�|j	|�}|j
|�|jd<|j|�|j|�n|r�|jd}|r�|j
|�|jd	<q�ndS(
Ntsupported_protocolstldpsshow mpls ldp discoveryitall_ipv4_addressestall_ipv6_addressest
interfacesitmpls_ldp_neighbors(RRtappendR)RQRRR'Rtparse_interfacestpopulate_interfacestpopulate_ipv4_interfacestpopulate_ipv6_interfacestpopulate_mpls_ldp_neighbors(Rt
ldp_supportedR!RV((sI/usr/lib/python2.7/site-packages/ansible/modules/network/frr/frr_facts.pyR�s 


cC`s�t�}d}x�|jd�D]y}t|�dkr=qq|ddkrd||cd|7<qtjd|�}|r|jd�}|||<qqW|S(NRLs
it s
%ss^Interface (\S+)i(RRDtlenRR#R(RR!tparsedtkeytlineR#((sI/usr/lib/python2.7/site-packages/ansible/modules/network/frr/frr_facts.pyRYs	c	C`s�t�}idd6dd6dd6dd6d	d
6dd6d
d6dd6}x`t|�D]R\}}t�}x0t|�D]"\}}|j||�||<qvW|||<qTW|S(NsDescription: (.+)tdescriptions
HWaddr: (\S+)t
macaddresssType: (\S+)ttypes
vrf: (\S+)tvrfs	mtu (\d+)tmtusbandwidth (\d+)t	bandwidthsline protocol is (\S+)tlineprotocols^(?:.+) is (.+),t
operstatus(RRR$(	RRVRtcountersRbR"tintfRIR ((sI/usr/lib/python2.7/site-packages/ansible/modules/network/frr/frr_facts.pyRZs 	
	c
C`sx|j�D]\}}t�|jd|d<g}}tjd|tj�}tjd|tj�}t|�dkr�q
n|j|d�xv|D]n}|jd�\}}t	d|j
�d|j
��}	|j|j
�d�|jd|dj|	�q�Wq
WdS(	NRVtipv4s&inet (\S+) broadcast (?:\S+)(?:\s{2,})s,inet (\S+) broadcast (?:\S+)(?:\s+)secondaryit/taddresstsubnet(titemsR'RRtfindallRR`RXRDRtstriptadd_ip_address(
RR!RbR"tprimary_addresst	addressesRptaddrRqRn((sI/usr/lib/python2.7/site-packages/ansible/modules/network/frr/frr_facts.pyR[#s

!c	C`s�x�|j�D]�\}}t�|jd|d<tjd|tj�}xv|D]n}|jd�\}}td|j�d|j��}|j	|j�d�|jd|dj
|�qPWq
WdS(NRVtipv6sinet6 (\S+)RoRpRq(RrR'RRRsRRDRRtRuRX(	RR!RbR"RwRpRxRqRy((sI/usr/lib/python2.7/site-packages/ansible/modules/network/frr/frr_facts.pyR\2s
!cC`s;|dkr#|jdj|�n|jdj|�dS(NRnRTRU(RRX(RRptfamily((sI/usr/lib/python2.7/site-packages/ansible/modules/network/frr/frr_facts.pyRu<scC`s�i}|j�}x�|D]�}|jd�r4qn|j�}t|�dkri}|d|d<|d|d<g||d<||dj|�qqW|S(NtAFiitneighboritsource(t
splitlinest
startswithRDR`RX(RR!RtentriestxRS((sI/usr/lib/python2.7/site-packages/ansible/modules/network/frr/frr_facts.pyR]Bs
(
R%R&RRRYRZR[R\RuR](((sI/usr/lib/python2.7/site-packages/ansible/modules/network/frr/frr_facts.pyRQ�s						
	tdefaultthardwareRNRVc
C`stdtddgdd��}td|dt�}|jd}t�}t�}x�|D]�}|dkr�|jt�q\n|jd	�r�|d
}|dkr�|jt�q\nt}nt}|tkr�|j	ddd
j
t�|f�n|r|j|�q\|j|�q\W|s7|jt�n|j|�|jd�t�}t
|�|d<t
�}x%|D]}	|jt|	|��qzWx(|D] }
|
j�|j|
j�q�Wt�}x.t|�D] \}	}d|	}	|||	<q�W|jd|�dS(s*main entry point for module execution
    t
gather_subsetR�s!configRfR't
argument_spectsupports_check_modetallt!itmsgs"Subset must be one of [%s], got %ss, sansible_net_%st
ansible_factsN(RR
tTruetparamstsetR*t
VALID_SUBSETSRRt	fail_jsontjointaddtdifference_updateR'RXtFACT_SUBSETSRRRt	exit_json(
R�R
R�trunable_subsetstexclude_subsetstsubsettexcludeRt	instancesRbtinstR�R"((sI/usr/lib/python2.7/site-packages/ansible/modules/network/frr/frr_facts.pytmain]sP	
		



	&

		


	
t__main__( t
__future__RRRRft
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNR5Rt$ansible.module_utils.network.frr.frrRR	tansible.module_utils.basicR
tansible.module_utils.sixRtobjectRR(R9RKRQRR�t	frozensettkeysR�R�R%(((sI/usr/lib/python2.7/site-packages/ansible/modules/network/frr/frr_facts.pyt<module>s4


7'n		>

Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]