Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/modules/network/enos/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/modules/network/enos/enos_facts.pyc

�
�Udac	@`s�ddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
Z
ddlmZm
Z
mZdd
lmZddlmZddlmZddlmZdefd��YZdefd��YZdefd��YZdefd��YZdefd��YZedededede�Zeej ��Z!dZ"d �Z#e$d!kr�e#�ndS("i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	communitytsupported_bys

---
module: enos_facts
version_added: "2.5"
author: "Anil Kumar Muraleedharan (@amuraleedhar)"
short_description: Collect facts from remote devices running Lenovo ENOS
description:
  - Collects a base set of device facts from a remote Lenovo device
    running on ENOS.  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.
extends_documentation_fragment: enos
notes:
  - Tested against ENOS 8.4.1
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�
Tasks: The following are examples of using the module enos_facts.
---
- name: Test Enos Facts
  enos_facts:
    provider={{ cli }}

  vars:
    cli:
      host: "{{ inventory_hostname }}"
      port: 22
      username: admin
      password: admin
      transport: cli
      timeout: 30
      authorize: True
      auth_pass:

---
# Collect all facts from the device
- enos_facts:
    gather_subset: all
    provider: "{{ cli }}"

# Collect only the config and default facts
- enos_facts:
    gather_subset:
      - config
    provider: "{{ cli }}"

# Do not collect hardware facts
- enos_facts:
    gather_subset:
      - "!hardware"
    provider: "{{ cli }}"

s�
  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 Lenovo ENOS device
    returned: always
    type: str
  ansible_net_serialnum:
    description: The serial number of the Lenovo ENOS device
    returned: always
    type: str
  ansible_net_version:
    description: The ENOS 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
  ansible_net_image:
    description: Indicates the active image for 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
# 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.
      This gives information on description, mac address, mtu, speed,
      duplex and operstatus
    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_commandstenos_argument_spect
check_args(tto_text(t
AnsibleModule(t	iteritems(tzipt	FactsBasecB`s,eZe�Zd�Zd�Zd�ZRS(cC`s+||_t�|_d|_d|_dS(Ni<(tmoduletdicttfactstNonet	responsestPERSISTENT_COMMAND_TIMEOUT(tselfR((sK/usr/lib/python2.7/site-packages/ansible/modules/network/enos/enos_facts.pyt__init__�s		cC`s"t|j|jdt�|_dS(Ntcheck_rc(RRtCOMMANDStFalseR(R((sK/usr/lib/python2.7/site-packages/ansible/modules/network/enos/enos_facts.pytpopulate�scC`st|j|dt�S(NR(RRR(Rtcmd((sK/usr/lib/python2.7/site-packages/ansible/modules/network/enos/enos_facts.pytrun�s(t__name__t
__module__tlistRRRR(((sK/usr/lib/python2.7/site-packages/ansible/modules/network/enos/enos_facts.pyR�s			tDefaultcB`sJeZddgZd�Zd�Zd�Zd�Zd�Zd�ZRS(sshow versionsshow runcC`s�tt|�j�|jd}|jd}|r�|j|�|jd<|j|�|jd<|j|�|jd<|j|�|jd<n|r�|j	|�|jd<ndS(Niitversiont	serialnumtmodeltimagethostname(
tsuperR!RRt
parse_versionRtparse_serialnumtparse_modeltparse_imagetparse_hostname(Rtdatatdata_run((sK/usr/lib/python2.7/site-packages/ansible/modules/network/enos/enos_facts.pyR�s

cC`s6tjd|tjtjB�}|r2|jd�SdS(Ns^Software Version (.*?) i(tretsearchtMtItgroup(RR-tmatch((sK/usr/lib/python2.7/site-packages/ansible/modules/network/enos/enos_facts.pyR(�scC`srxk|jd�D]Z}|j�}tjd|tjtjB�}|r|j�}|djd�}|SqWdS(Ns
shostname (.*?)is"tNA(tsplittstripR/R4R1R2(RR.tlineR4thostsR&((sK/usr/lib/python2.7/site-packages/ansible/modules/network/enos/enos_facts.pyR,�scC`s6tjd|tjtjB�}|r2|jd�SdS(Ns^Lenovo RackSwitch (\S+)i(R/R0R1R2R3(RR-R4((sK/usr/lib/python2.7/site-packages/ansible/modules/network/enos/enos_facts.pyR*�scC`s1tjd|tjtjB�}|r)dSdSdS(Ns(.*) image1(.*)tImage1tImage2(R/R0R1R2(RR-R4((sK/usr/lib/python2.7/site-packages/ansible/modules/network/enos/enos_facts.pyR+�scC`s6tjd|tjtjB�}|r2|jd�SdS(Ns^Switch Serial No:  (\S+)i(R/R0R1R2R3(RR-R4((sK/usr/lib/python2.7/site-packages/ansible/modules/network/enos/enos_facts.pyR)�s(	RRRRR(R,R*R+R)(((sK/usr/lib/python2.7/site-packages/ansible/modules/network/enos/enos_facts.pyR!�s			
		tHardwarecB`s,eZdgZd�Zd�Zd�ZRS(sshow system memorycC`s�tt|�j�|jdg�}t|dd�j�}|jdd�}|r�|j|�|jd<|j	|�|jd<ndS(Nsshow system memoryterrorstsurrogate_or_stricts\ns
tmemtotal_mbt
memfree_mb(
R'R<RRRR7treplacetparse_memtotalRt
parse_memfree(RR-((sK/usr/lib/python2.7/site-packages/ansible/modules/network/enos/enos_facts.pyR�scC`s@tjd|tjtjB�}|r<t|jd��dSdS(Ns^MemTotal:\s*(.*) kBii(R/R0R1R2tintR3(RR-R4((sK/usr/lib/python2.7/site-packages/ansible/modules/network/enos/enos_facts.pyRB�scC`s@tjd|tjtjB�}|r<t|jd��dSdS(Ns^MemFree:\s*(.*) kBii(R/R0R1R2RDR3(RR-R4((sK/usr/lib/python2.7/site-packages/ansible/modules/network/enos/enos_facts.pyRC�s(RRRRRBRC(((sK/usr/lib/python2.7/site-packages/ansible/modules/network/enos/enos_facts.pyR<�s				tConfigcB`seZdgZd�ZRS(sshow running-configcC`s:tt|�j�|jd}|r6||jd<ndS(Nitconfig(R'RERRR(RR-((sK/usr/lib/python2.7/site-packages/ansible/modules/network/enos/enos_facts.pyR�s
(RRRR(((sK/usr/lib/python2.7/site-packages/ansible/modules/network/enos/enos_facts.pyRE�s	t
InterfacescB`sYeZdgZd�Zd�Zd�Zd�Zd�Zd�Zd�Z	d�Z
RS(	sshow interface statuscC`stt|�j�t�|jd<t�|jd<|jdg�}t|dd�j�}|jdd�}|jdg�}t|dd�j�}|jdd�}d}d}|r�|j
|�}n|r�|j
|�}n|dk	r|dk	r|j||�|jd	<n|jd
g�}t|dd�j�}|jdd�}d}|ru|j|�}n|dk	r�|j
|�|jd<n|jdg�}|d
jd�}d}|r|j|�}|j|�}	|	|jd<|j|�}
|
|jd<ndS(Ntall_ipv4_addressestall_ipv6_addressessshow interface statusR=R>s\ns
sshow lldp portt
interfacessshow lldp remote-device portt	neighborssshow interface ipi(R'RGRR RRRR7RARtparse_interfacestpopulate_interfacestparse_neighborstpopulate_neighborsR6tparse_ipaddressestset_ipv4_interfacestset_ipv6_interfaces(Rtdata1tdata2tlines1tlines2tdata3tlines3tdata4tlines4tipv4_interfacestipv6_interfaces((sK/usr/lib/python2.7/site-packages/ansible/modules/network/enos/enos_facts.pyR	sD
cC`s�t�}x�|D]�}t|�dkr.qq|j�}t|�dkrRqntjd|tjtjB�}|r�|j�}|j|�ntjd|tjtjB�}|r|j�}|j|�qqW|S(NitIP4tIP6(	R tlenR7R/R0R1R2R3tappend(RRYtparsedR8R4tkey((sK/usr/lib/python2.7/site-packages/ansible/modules/network/enos/enos_facts.pyRP1s 	
cC`sNt�}x>|D]6}|j�}|ddkr|j|d�qqW|S(NiR]i(R R6R`(Rtline4tipv4_addressesR8t	ipv4Split((sK/usr/lib/python2.7/site-packages/ansible/modules/network/enos/enos_facts.pyRQDs	
cC`sNt�}x>|D]6}|j�}|ddkr|j|d�qqW|S(NiR^i(R R6R`(RRctipv6_addressesR8t	ipv6Split((sK/usr/lib/python2.7/site-packages/ansible/modules/network/enos/enos_facts.pyRRLs	
cC`s�t�}x�|D]�}|jd�}t�}|dj�|d<|dj�|d<|dj�}|dk	r�|dj�|d<n
d|d<|||d	j�<qW|S(
Nt|isRemote Chassis IDisRemote PortisRemote System NameR5i(RR6R7R(RRXRKR8t
neighborSplitt	innerDatatsysName((sK/usr/lib/python2.7/site-packages/ansible/modules/network/enos/enos_facts.pyROTs	
	
c	C`s[t�}xKt||�D]:\}}|d|}|j�}t�}|dj�|d<|dj�|d<|dj�|d<|dj�|d	<|d
j�|d<|dj�|d
<d|dj�kr?d|dj�kr?|dj�|d<|dj�|d<|dj�|d<|dj�|d
<n|||dj�<qW|S(Ns  itdescriptionit
macaddressi	tmtuitspeeditduplexit
operstatustuptdownii
i(RRR6R7(	RRURVRJtline1tline2R8t	intfSplitRj((sK/usr/lib/python2.7/site-packages/ansible/modules/network/enos/enos_facts.pyRMcs$		,cC`s't�}x|jd�D]}t|�dkr7qq|j�}tjd|�}|rz|jd�}|j|�ntjd|�}|r�|jd�}|j|�ntjd|�}|r�|jd�}|j|�ntjd|�}|r|jd�}|j|�qqW|S(Ns
is	^([0-9]+)is^(INT+)s^(EXT+)s^(MGT+)(R R6R_R7R/R4R3R`(RRKRaR8R4Rb((sK/usr/lib/python2.7/site-packages/ansible/modules/network/enos/enos_facts.pyRNws,	cC`s't�}x|jd�D]}t|�dkr7qq|j�}tjd|�}|rz|jd�}|j|�ntjd|�}|r�|jd�}|j|�ntjd|�}|r�|jd�}|j|�ntjd|�}|r|jd�}|j|�qqW|S(Ns
is	^([0-9]+)is^(INT+)s^(EXT+)s^(MGT+)(R R6R_R7R/R4R3R`(RR-RaR8R4Rb((sK/usr/lib/python2.7/site-packages/ansible/modules/network/enos/enos_facts.pyRL�s,	(RRRRRPRQRRRORMRNRL(((sK/usr/lib/python2.7/site-packages/ansible/modules/network/enos/enos_facts.pyRGs		(						tdefaultthardwareRJRFi<cC`s*tdtddgdd��}|jt�td|dt�}|jd}t�}t�}x�|D]�}|dkr�|jt�qin|jd	�r�|d
}|dkr�|jt�qint}nt	}|tkr�|j
dd�n|r
|j|�qi|j|�qiW|s1|jt�n|j|�|jd�t�}t
|�|d<t
�}x%|D]}	|jt|	|��qtWx(|D] }
|
j�|j|
j�q�Wt�}x.t|�D] \}	}d
|	}	|||	<q�Wt
�}
t||
�|jd|d|
�dS(s*main entry point for module execution
    t
gather_subsetRws!configttypeR t
argument_spectsupports_check_modetallt!itmsgs
Bad subsetsansible_net_%st
ansible_factstwarningsN(RtupdateR	RtTruetparamstsett
VALID_SUBSETSt
startswithRt	fail_jsontaddtdifference_updateR R`tFACT_SUBSETSRRR
R
t	exit_json(R{RRytrunable_subsetstexclude_subsetstsubsettexcludeRt	instancesRbtinstR�tvalueR�((sK/usr/lib/python2.7/site-packages/ansible/modules/network/enos/enos_facts.pytmain�sV
	
		



	

		


	
	
t__main__(%t
__future__RRRRzt
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNR/t&ansible.module_utils.network.enos.enosRR	R
tansible.module_utils._textRtansible.module_utils.basicRtansible.module_utils.sixR
tansible.module_utils.six.movesRtobjectRR!R<RERGRR�t	frozensettkeysR�RR�R(((sK/usr/lib/python2.7/site-packages/ansible/modules/network/enos/enos_facts.pyt<module>s8


%81�		C

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