Anons79 Mini Shell

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

�
�Udac@`s�ddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
mZddlm
Z
dd
lmZmZddlZd�Zdddd�Zd�Zd�Zedkr�e�ndS(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	communitytsupported_bys~
---
module: ios_ping
short_description: Tests reachability using ping from Cisco IOS network devices
description:
- Tests reachability using ping from switch to a remote destination.
- For a general purpose network module, see the M(net_ping) module.
- For Windows targets, use the M(win_ping) module instead.
- For targets running Python, use the M(ping) module instead.
author:
- Jacob McGill (@jmcgill298)
version_added: '2.4'
extends_documentation_fragment: ios
options:
  count:
    description:
    - Number of packets to send.
    default: 5
  dest:
    description:
    - The IP Address or hostname (resolvable by switch) of the remote node.
    required: true
  source:
    description:
    - The source IP Address.
  state:
    description:
    - Determines if the expected result is success or fail.
    choices: [ absent, present ]
    default: present
  vrf:
    description:
    - The VRF to use for forwarding.
    default: default
notes:
  - For a general purpose network module, see the M(net_ping) module.
  - For Windows targets, use the M(win_ping) module instead.
  - For targets running Python, use the M(ping) module instead.
s�
- name: Test reachability to 10.10.10.10 using default vrf
  ios_ping:
    dest: 10.10.10.10

- name: Test reachability to 10.20.20.20 using prod vrf
  ios_ping:
    dest: 10.20.20.20
    vrf: prod

- name: Test unreachability to 10.30.30.30 using default vrf
  ios_ping:
    dest: 10.30.30.30
    state: absent

- name: Test reachability to 10.40.40.40 using prod vrf and setting count and source
  ios_ping:
    dest: 10.40.40.40
    source: loopback0
    vrf: prod
    count: 20
s5
commands:
  description: Show the command sent.
  returned: always
  type: list
  sample: ["ping vrf prod 10.40.40.40 count 20 source loopback0"]
packet_loss:
  description: Percentage of packets lost.
  returned: always
  type: str
  sample: "0%"
packets_rx:
  description: Packets successfully received.
  returned: always
  type: int
  sample: 20
packets_tx:
  description: Packets successfully transmitted.
  returned: always
  type: int
  sample: 20
rtt:
  description: Show RTT stats.
  returned: always
  type: dict
  sample: {"avg": 2, "max": 8, "min": 1}
(t
AnsibleModule(trun_commands(tios_argument_spect
check_argsNcC`s,tdtdd�dtdddt�dtdd�dtddd	d
dgdd�d
tdd��}|jt�td|�}|jd}|jd}|jd}|jd
}t�}t||�i}|r�||d<nt||||�g|d<t	|d|d�}|dj
d�}	d}
x&|	D]}|jd�r=|}
q=q=Wt|
�\}}
}}t
dt|��}t|�d|d<t|
�|d<t|�|d<x=|j�D]/\}}||dk	r�t|�||<q�q�W||d<t|||�|j|�dS(s+ main entry point for module execution
    tcountttypetinttdesttstrtrequiredtsourcetstatetchoicestabsenttpresenttdefaulttvrft
argument_spectwarningstcommandsis
ttSuccessidt%tpacket_losst
packets_rxt
packets_txtrttN(tdicttTruetupdateR
RtparamstlistRt
build_pingR	tsplitt
startswitht
parse_pingtabsRRtitemstNonetvalidate_resultst	exit_json(RtmoduleRRRRRtresultstping_resultstping_results_listtstatstlinetsuccesstrxttxR"tlosstktv((sH/usr/lib/python2.7/site-packages/ansible/modules/network/ios/ios_ping.pytmainnsF!




	




cC`s~|dk	r!dj||�}ndj|�}|dk	rX|djt|��7}n|dk	rz|dj|�7}n|S(s�
    Function to build the command to send to the terminal for the switch
    to execute. All args come from the module's unique params.
    sping vrf {0} {1}sping {0}s repeat {0}s source {0}N(R.tformatR(RRRRtcmd((sH/usr/lib/python2.7/site-packages/ansible/modules/network/ios/ios_ping.pyR(�scC`smtjd�}tjd�}|j|�}|j|�}|jd�|jd�|jd�|j�fS(s
    Function used to parse the statistical information from the ping response.
    Example: "Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/8 ms"
    Returns the percent of packet loss, received packets, transmitted packets, and RTT dict.
    sC^\w+\s+\w+\s+\w+\s+(?P<pct>\d+)\s+\w+\s+\((?P<rx>\d+)/(?P<tx>\d+)\)sM.*,\s+\S+\s+\S+\s+=\s+(?P<min>\d+)/(?P<avg>\d+)/(?P<max>\d+)\s+\w+\s*$|.*\s*$tpctR8R9(tretcompiletmatchtgroupt	groupdict(t
ping_statstrate_retrtt_retrateR"((sH/usr/lib/python2.7/site-packages/ansible/modules/network/ios/ios_ping.pyR+�s
cC`sm|jd}|dkr;|dkr;|jdd|�n.|dkri|dkri|jdd|�ndS(	sg
    This function is used to validate whether the ping results were unexpected per "state" param.
    RRidtmsgsPing failed unexpectedlyRsPing succeeded unexpectedlyN(R&t	fail_json(R1R:R2R((sH/usr/lib/python2.7/site-packages/ansible/modules/network/ios/ios_ping.pyR/�s

t__main__(t
__future__RRRR
t
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNtansible.module_utils.basicRt$ansible.module_utils.network.ios.iosR	R
RRAR=R.R(R+R/t__name__(((sH/usr/lib/python2.7/site-packages/ansible/modules/network/ios/ios_ping.pyt<module>s"


(	7		

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