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_command.pyc

�
�Udac@`s�ddlmZmZmZidd6dgd6dd6ZdZd	Zd
ZddlZddl	Z	ddl
mZdd
lm
Z
ddlmZddlmZddlmZeZd�Zd�Zd�Zedkr�e�ndS(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	communitytsupported_bysb	
---
module: nos_command
version_added: "2.7"
author: "Lindsay Hill (@LindsayHill)"
short_description: Run commands on remote devices running Extreme Networks NOS
description:
  - Sends arbitrary commands to a NOS device and returns the results
    read from the device. This module includes an
    argument that will cause the module to wait for a specific condition
    before returning or timing out if the condition is not met.
  - This module does not support running commands in configuration mode.
    Please use M(nos_config) to configure NOS devices.
notes:
  - Tested against NOS 7.2.0
  - If a command sent to the device requires answering a prompt, it is possible
    to pass a dict containing I(command), I(answer) and I(prompt). See examples.
options:
  commands:
    description:
      - List of commands to send to the remote NOS device over the
        configured provider. The resulting output from the command
        is returned. If the I(wait_for) argument is provided, the
        module is not returned until the condition is satisfied or
        the number of retries has expired.
    required: true
  wait_for:
    description:
      - List of conditions to evaluate against the output of the
        command. The task will wait for each condition to be true
        before moving forward. If the conditional is not true
        within the configured number of retries, the task fails.
        See examples.
  match:
    description:
      - The I(match) argument is used in conjunction with the
        I(wait_for) argument to specify the match policy. Valid
        values are C(all) or C(any). If the value is set to C(all)
        then all conditionals in the wait_for must be satisfied. If
        the value is set to C(any) then only one of the values must be
        satisfied.
    default: all
    choices: ['any', 'all']
  retries:
    description:
      - Specifies the number of retries a command should by tried
        before it is considered failed. The command is run on the
        target device every retry and evaluated against the
        I(wait_for) conditions.
    default: 10
  interval:
    description:
      - Configures the interval in seconds to wait between retries
        of the command. If the command does not pass the specified
        conditions, the interval indicates how long to wait before
        trying the command again.
    default: 1
sZ
tasks:
  - name: run show version on remote devices
    nos_command:
      commands: show version

  - name: run show version and check to see if output contains NOS
    nos_command:
      commands: show version
      wait_for: result[0] contains NOS

  - name: run multiple commands on remote nodes
    nos_command:
      commands:
        - show version
        - show interfaces

  - name: run multiple commands and evaluate the output
    nos_command:
      commands:
        - show version
        - show interface status
      wait_for:
        - result[0] contains NOS
        - result[1] contains Te
  - name: run command that requires answering a prompt
    nos_command:
      commands:
        - command: 'clear sessions'
          prompt: 'This operation will logout all the user sessions. Do you want to continue (yes/no)?:'
          answer: y
s�
stdout:
  description: The set of responses from the commands
  returned: always apart from low level errors (such as action plugin)
  type: list
  sample: ['...', '...']
stdout_lines:
  description: The value of stdout split into a list
  returned: always apart from low level errors (such as action plugin)
  type: list
  sample: [['...', '...'], ['...'], ['...']]
failed_conditions:
  description: The list of conditionals that have failed
  returned: failed
  type: list
  sample: ['...', '...']
N(trun_commands(t
AnsibleModule(tComplexList(tConditional(tstring_typescc`sAx:|D]2}t|t�r4t|�jd�}n|VqWdS(Ns
(t
isinstanceRtstrtsplit(tstdouttitem((sK/usr/lib/python2.7/site-packages/ansible/modules/network/nos/nos_command.pytto_lines�s
cC`s�ttdtdt�dt�dt��|�}||jd�}x�t|�D]�}tjd|d�}|jrS|r�|jd�dkr�|j	dd
�n|dj
d�s�|jd|d�|j|�q�qSqSW|S(Ntcommandtkeytprompttanswertcommandssconf(?:\w*)(?:\s+(\w+))?itconfirmtreplacetreverttnetworktmsgsXnos_command does not support running config mode commands. Please use nos_config insteadtshowsJonly show commands are supported when using check mode, not executing `%s`(RsreplaceRR(
R
tdicttTruetparamstlisttretmatcht
check_modetgroupt	fail_jsont
startswithtappendtremove(tmoduletwarningsRRRtconfigure_type((sK/usr/lib/python2.7/site-packages/ansible/modules/network/nos/nos_command.pytparse_commands�s$						
cC`s!tdtdddt�dtdd�dtddd	dd
g�dtdddd
�dtdddd
��}td|dt�}itd6}t�}t||�}||d<|jdp�t�}g|D]}t|�^q�}|jd}|jd}	|jd}
x�|dkr�t||�}xIt|�D];}||�r=|
d
krht�}Pn|j	|�q=q=W|s�Pnt
j|	�|d8}qW|r�g|D]}|j^q�}
d}|j
d|d|
�n|jitd6|d6tt|��d6�|j|�dS(s*main entry point for module execution
    RttypeR!trequiredtwait_forR#tdefaulttalltchoicestanytretriesi
tinttintervalit
argument_spectsupports_check_modetchangedR+is:One or more conditional statements have not been satisfiedRtfailed_conditionsRtstdout_linesN(RRR	tFalseR!R-R RRR)ttimetsleeptrawR&tupdateRt	exit_json(R8R*tresultR+RR0tctconditionalsR5R7R#t	responsesRR;R((sK/usr/lib/python2.7/site-packages/ansible/modules/network/nos/nos_command.pytmain�sL	
	



	
	t__main__(t
__future__RRRtANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNR"R>t$ansible.module_utils.network.nos.nosRtansible.module_utils.basicR	t)ansible.module_utils.network.common.utilsR
t+ansible.module_utils.network.common.parsingRtansible.module_utils.sixRR.t
__metaclass__RR-RGt__name__(((sK/usr/lib/python2.7/site-packages/ansible/modules/network/nos/nos_command.pyt<module>s&


<!			;

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