Anons79 Mini Shell

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

�
�Udac	@`sRddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
Z
ddlmZdd
l
mZddlmZdefd��YZdefd��YZdefd��YZdefd��YZdefd��YZedededede�Zeej��Zd�ZedkrNe�ndS(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	communitytsupported_bys�
---
module: nos_facts
version_added: "2.7"
author: "Lindsay Hill (@LindsayHill)"
short_description: Collect facts from devices running Extreme NOS
description:
  - Collects a base set of device facts from a remote device that
    is running NOS. 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 NOS 7.2.0
options:
  gather_subset:
    description:
      - When supplied, this argument will restrict the facts collected
        to a given subset. Possible values for this argument include
        all, hardware, config, and interfaces. Can specify a list of
        values to include a larger subset. Values can also be used
        with an initial C(M(!)) to specify that a specific subset should
        not be collected.
    required: false
    default: '!config'
s�
# Collect all facts from the device
- nos_facts:
    gather_subset: all

# Collect only the config and default facts
- nos_facts:
    gather_subset:
      - config

# Do not collect hardware facts
- nos_facts:
    gather_subset:
      - "!hardware"
sH
ansible_net_gather_subset:
  description: The list of fact subsets collected from the device
  returned: always
  type: list

# default
ansible_net_model:
  description: The model name returned from the device
  returned: always
  type: str
ansible_net_serialnum:
  description: The serial number of the remote device
  returned: always
  type: str
ansible_net_version:
  description: The operating system version running on the remote device
  returned: always
  type: str
ansible_net_hostname:
  description: The configured hostname of the device
  returned: always
  type: str

# hardware
ansible_net_memfree_mb:
  description: The available free memory on the remote device in Mb
  returned: when hardware is configured
  type: int
ansible_net_memtotal_mb:
  description: The total memory on the remote device in Mb
  returned: when hardware is configured
  type: int

# 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 Primary 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_neighbors:
  description: The list of LLDP neighbors from the remote device
  returned: when interfaces is configured
  type: dict
N(trun_commands(t
AnsibleModule(t	iteritemst	FactsBasecB`s,eZe�Zd�Zd�Zd�ZRS(cC`s"||_t�|_d|_dS(N(tmoduletdicttfactstNonet	responses(tselfR((sI/usr/lib/python2.7/site-packages/ansible/modules/network/nos/nos_facts.pyt__init__�s	cC`st|j|j�|_dS(N(RRtCOMMANDSR(R((sI/usr/lib/python2.7/site-packages/ansible/modules/network/nos/nos_facts.pytpopulate�scC`st|j|�S(N(RR(Rtcmd((sI/usr/lib/python2.7/site-packages/ansible/modules/network/nos/nos_facts.pytrun�s(t__name__t
__module__tlistRRRR(((sI/usr/lib/python2.7/site-packages/ansible/modules/network/nos/nos_facts.pyR�s			tDefaultcB`sDeZdddgZd�Zd�Zd�Zd�Zd�ZRS(sshow versionsshow inventory chassiss(show running-config | include host\-namecC`s�tt|�j�|jd}|r?|j|�|jd<n|jd}|r�|j|�|jd<|j|�|jd<n|jd}|r�|j|�|jd<ndS(Nitversionitmodelt	serialnumithostname(	tsuperRRRt
parse_versionRtparse_modeltparse_serialnumtparse_hostname(Rtdata((sI/usr/lib/python2.7/site-packages/ansible/modules/network/nos/nos_facts.pyR�s


cC`s)tjd|�}|r%|jd�SdS(Ns'Network Operating System Version: (\S+)i(tretsearchtgroup(RR$tmatch((sI/usr/lib/python2.7/site-packages/ansible/modules/network/nos/nos_facts.pyR �scC`s/tjd|tj�}|r+|jd�SdS(Ns	SID:(\S+)i(R%R&tMR'(RR$R(((sI/usr/lib/python2.7/site-packages/ansible/modules/network/nos/nos_facts.pyR!�scC`s/tjd|tj�}|r+|jd�SdS(Ns!switch-attributes host-name (\S+)i(R%R&R)R'(RR$R(((sI/usr/lib/python2.7/site-packages/ansible/modules/network/nos/nos_facts.pyR#�scC`s/tjd|tj�}|r+|jd�SdS(NsSN:(\S+)i(R%R&R)R'(RR$R(((sI/usr/lib/python2.7/site-packages/ansible/modules/network/nos/nos_facts.pyR"�s(RRRRR R!R#R"(((sI/usr/lib/python2.7/site-packages/ansible/modules/network/nos/nos_facts.pyR�s					tHardwarecB`s,eZdgZd�Zd�Zd�ZRS(sshow process memory summarycC`s�tt|�j�|jd}|r�ttt|j|��dd��|jd<ttt|j|��dd��|jd<ndS(Niitmemtotal_mbt
memfree_mb(	RR*RRtinttroundtparse_memtotalRt
parse_memfree(RR$((sI/usr/lib/python2.7/site-packages/ansible/modules/network/nos/nos_facts.pyR�s

/cC`s/tjd|tj�}|r+|jd�SdS(NsTotalMemory: (\d+)\si(R%R&R)R'(RR$R(((sI/usr/lib/python2.7/site-packages/ansible/modules/network/nos/nos_facts.pyR/�scC`s/tjd|tj�}|r+|jd�SdS(NsTotal Free: (\d+)\si(R%R&R)R'(RR$R(((sI/usr/lib/python2.7/site-packages/ansible/modules/network/nos/nos_facts.pyR0�s(RRRRR/R0(((sI/usr/lib/python2.7/site-packages/ansible/modules/network/nos/nos_facts.pyR*�s			tConfigcB`seZdgZd�ZRS(sshow running-configcC`s:tt|�j�|jd}|r6||jd<ndS(Nitconfig(RR1RRR(RR$((sI/usr/lib/python2.7/site-packages/ansible/modules/network/nos/nos_facts.pyR�s
(RRRR(((sI/usr/lib/python2.7/site-packages/ansible/modules/network/nos/nos_facts.pyR1�s	t
InterfacescB`s�eZdddgZd�Zd�Zd�Zd�Zd�Zd�Zd	�Z	d
�Z
d�Zd�Zd
�Z
d�Zd�Zd�Zd�Zd�ZRS(sshow interfacesshow ipv6 interface briefsMshow lldp nei detail | inc ^Local\ Interface|^Remote\ Interface|^System\ NamecC`s�tt|�j�t�|jd<t�|jd<|jd}|r{|j|�}|j|�|jd<|j|�n|jd}|r�|j	|�n|jd}|r�|j
|�|jd<nt�|jd<dS(Ntall_ipv4_addressestall_ipv6_addressesit
interfacesiit	neighbors(RR3RRRRtparse_interfacestpopulate_interfacestpopulate_ipv4_interfacestpopulate_ipv6_interfacestparse_neighborsR
(RR$R6((sI/usr/lib/python2.7/site-packages/ansible/modules/network/nos/nos_facts.pyR�s


cC`s�t�}x�t|�D]�\}}t�}|j|�|d<|j|�|d<|j|�|d<|j|�|d<|j|�|d<|j|�|d<|j|�|d<|j	|�|d<|||<qW|S(	Ntdescriptiont
macaddresstmtut	bandwidthtduplextlineprotocolt
operstatusttype(
R
R
tparse_descriptiontparse_macaddresst	parse_mtutparse_bandwidthtparse_duplextparse_lineprotocoltparse_operstatust
parse_type(RR6Rtkeytvaluetintf((sI/usr/lib/python2.7/site-packages/ansible/modules/network/nos/nos_facts.pyR9s		c
C`s	x|j�D]�\}}t�|jd|d<g}}tjd|tj�}tjd|tj�}|swq
n|j|d�xv|D]n}|jd�\}}td|j	�d|j	��}	|j
|j	�d�|jd|dj|	�q�Wq
WdS(	NR6tipv4s!Primary Internet Address is (\S+)s#Secondary Internet Address is (\S+)it/taddresstsubnet(titemsRRR%tfindallR)tappendtsplitR
tstriptadd_ip_address(
RR$RMRNtprimary_addresst	addressesRRtaddrRSRP((sI/usr/lib/python2.7/site-packages/ansible/modules/network/nos/nos_facts.pyR:s

!c	C`s�tjd|�dj�}tjd|tj�}x�|D]�}|d}t�|jd|d<|djd�\}}td|d	t|��}|j	|dd�|jd|dj
|�q;WdS(
Ns=+is#(\S+ \S+) +[\w-]+.+\s+([\w:/]+/\d+)iR6tipv6RQRRtmasklen(R%RWRXRUR)RRR
R-RYRV(	RR$R6tmatchesR(t	interfaceRRR^R]((sI/usr/lib/python2.7/site-packages/ansible/modules/network/nos/nos_facts.pyR;&s

cC`s;|dkr#|jdj|�n|jdj|�dS(NRPR4R5(RRV(RRRtfamily((sI/usr/lib/python2.7/site-packages/ansible/modules/network/nos/nos_facts.pyRY1scC`s�t�}|jd�}|s"|Sx�|D]�}tjd|tj�}|r)|jd�}||krxt�||<nt�}|jd�|d<|jd�|d<||j|�q)q)W|S(NsLocal Interface: sh(\w+ \S+)\s+\(Local Int.+?\)[\s\S]+Remote Interface: (\S+.+?) \(Remote Int.+?\)[\s\S]+System Name: (\S+)iithostitport(R
RWR%R&R)R'RRV(RR7RtlinestlineR(ROtfact((sI/usr/lib/python2.7/site-packages/ansible/modules/network/nos/nos_facts.pyR<7s	
	cC`s^t�}xN|jd�D]=}tjd|tj�}|sCqq|||jd�<qW|S(Ns

s
^(\S+ \S+)i(R
RWR%R(R)R'(RR$tparsedR`R(((sI/usr/lib/python2.7/site-packages/ansible/modules/network/nos/nos_facts.pyR8Hs	cC`s/tjd|tj�}|r+|jd�SdS(NsDescription: (.+)$i(R%R&R)R'(RR$R(((sI/usr/lib/python2.7/site-packages/ansible/modules/network/nos/nos_facts.pyRERscC`s)tjd|�}|r%|jd�SdS(Ns&Hardware is Ethernet, address is (\S+)i(R%R&R'(RR$R(((sI/usr/lib/python2.7/site-packages/ansible/modules/network/nos/nos_facts.pyRFWscC`sStjd|�}|rO|jd�jd�\}}td|dt|��SdS(Ns%Primary Internet Address is ([^\s,]+)iRQRRR^(R%R&R'RWR
R-(RR$R(R\R^((sI/usr/lib/python2.7/site-packages/ansible/modules/network/nos/nos_facts.pyt
parse_ipv4\scC`s/tjd|�}|r+t|jd��SdS(NsMTU (\d+) bytesi(R%R&R-R'(RR$R(((sI/usr/lib/python2.7/site-packages/ansible/modules/network/nos/nos_facts.pyRGbscC`s)tjd|�}|r%|jd�SdS(NsLineSpeed Actual\s+:\s(.+)i(R%R&R'(RR$R(((sI/usr/lib/python2.7/site-packages/ansible/modules/network/nos/nos_facts.pyRHgscC`s/tjd|tj�}|r+|jd�SdS(Ns
Duplex: (\S+)i(R%R&R)R'(RR$R(((sI/usr/lib/python2.7/site-packages/ansible/modules/network/nos/nos_facts.pyRIlscC`s/tjd|tj�}|r+|jd�SdS(NsHardware is (.+),i(R%R&R)R'(RR$R(((sI/usr/lib/python2.7/site-packages/ansible/modules/network/nos/nos_facts.pyRLqscC`s/tjd|tj�}|r+|jd�SdS(Nsline protocol is (\S+)i(R%R&R)R'(RR$R(((sI/usr/lib/python2.7/site-packages/ansible/modules/network/nos/nos_facts.pyRJvscC`s/tjd|tj�}|r+|jd�SdS(Ns^(?:.+) is (.+),i(R%R(R)R'(RR$R(((sI/usr/lib/python2.7/site-packages/ansible/modules/network/nos/nos_facts.pyRK{s(RRRRR9R:R;RYR<R8RERFRhRGRHRIRLRJRK(((sI/usr/lib/python2.7/site-packages/ansible/modules/network/nos/nos_facts.pyR3�s&								
								tdefaultthardwareR6R2cC`stdtddgdd��}td|dt�}|jd}t�}t�}x�|D]�}|dkr�|jt�q\n|jd	�r�|d
}|dkr�|jt�q\nt}nt}|tkr�|j	dd�n|r�|j
|�q\|j
|�q\W|s$|jt�n|j|�|j
d�t�}t|�|d<t�}x%|D]}	|j
t|	|��qgWx(|D] }
|
j�|j|
j�q�Wt�}x.t|�D] \}	}d
|	}	|||	<q�Wt�}
|jd|d|
�dS(s*main entry point for module execution
    t
gather_subsetRis!configRDRt
argument_spectsupports_check_modetallt!itmsgs
Bad subsetsansible_net_%st
ansible_factstwarningsN(R
R	tTruetparamstsettupdatet
VALID_SUBSETSt
startswithtFalset	fail_jsontaddtdifference_updateRRVtFACT_SUBSETSRRR
t	exit_json(RlRRktrunable_subsetstexclude_subsetstsubsettexcludeRt	instancesRMtinstRqRNRr((sI/usr/lib/python2.7/site-packages/ansible/modules/network/nos/nos_facts.pytmain�sR	
		



	

		


	
	t__main__(t
__future__RRRRDt
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNR%t$ansible.module_utils.network.nos.nosRtansible.module_utils.basicR	tansible.module_utils.sixR
tobjectRRR*R1R3R
R}t	frozensettkeysRwR�R(((sI/usr/lib/python2.7/site-packages/ansible/modules/network/nos/nos_facts.pyt<module>s2


;,�		@

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