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

�
�Udac@`s�ddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
Z
ddlmZdd
l
mZmZddl
mZddlmZddlmZd�Zd�Zedkr�e�ndS(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	communitytsupported_bysO
---
module: enos_command
version_added: "2.5"
author: "Anil Kumar Muraleedharan (@amuraleedhar)"
short_description: Run arbitrary commands on Lenovo ENOS devices
description:
  - Sends arbitrary commands to an ENOS node and returns the results
    read from the device. The C(enos_command) 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.
extends_documentation_fragment: enos
options:
  commands:
    description:
      - List of commands to send to the remote 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 retires as 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
sM
# Note: examples below use the following provider dict to handle
#       transport and authentication to the node.
---
vars:
  cli:
    host: "{{ inventory_hostname }}"
    port: 22
    username: admin
    password: admin
    timeout: 30

---
- name: test contains operator
  enos_command:
    commands:
      - show version
      - show system memory
    wait_for:
      - "result[0] contains 'Lenovo'"
      - "result[1] contains 'MemFree'"
    provider: "{{ cli }}"
  register: result

- assert:
    that:
      - "result.changed == false"
      - "result.stdout is defined"

- name: get output for single command
  enos_command:
    commands: ['show version']
    provider: "{{ cli }}"
  register: result

- assert:
    that:
      - "result.changed == false"
      - "result.stdout is defined"

- name: get output for multiple commands
  enos_command:
    commands:
      - show version
      - show interface information
    provider: "{{ cli }}"
  register: result

- assert:
    that:
      - "result.changed == false"
      - "result.stdout is defined"
      - "result.stdout | length == 2"
s�
stdout:
  description: the set of responses from the commands
  returned: always
  type: list
  sample: ['...', '...']
stdout_lines:
  description: The value of stdout split into a list
  returned: always
  type: list
  sample: [['...', '...'], ['...'], ['...']]
failed_conditions:
  description: the conditionals that failed
  returned: failed
  type: list
  sample: ['...', '...']
N(t
AnsibleModule(trun_commandst
check_args(tenos_argument_spec(tConditional(tstring_typescc`sAx:|D]2}t|t�r4t|�jd�}n|VqWdS(Ns
(t
isinstanceR
tstrtsplit(tstdouttitem((sM/usr/lib/python2.7/site-packages/ansible/modules/network/enos/enos_command.pytto_lines�s
cC`stdtdddt�dtdd�dtddd	dd
g�dtdddd
�dtdddd
��}|jt�td|dt�}itd6}|jdp�t�}g|D]}t|�^q�}|jd}|jd}|jd}|jd}	x�|dkr�t	||�}
xIt|�D];}||
�r5|	d
kr`t�}Pn|j
|�q5q5W|s~Pntj|�|d8}q
W|r�g|D]}|j
^q�}d}
|jd|
d|�n|jitd6|
d6tt|
��d6�|j|�dS(Ntcommandsttypetlisttrequiredtwait_fortmatchtdefaulttalltchoicestanytretriesi
tinttintervalit
argument_spectsupports_check_modetchangedis:One or more conditional statements have not been satisfiedtmsgtfailed_conditionsRtstdout_lines(tdicttTruetupdateRRtFalsetparamsRRR	tremovettimetsleeptrawt	fail_jsonRt	exit_json(tspectmoduletresultRtctconditionalsRRR Rt	responsesRR%R$((sM/usr/lib/python2.7/site-packages/ansible/modules/network/enos/enos_command.pytmain�sH





	
	t__main__(t
__future__RRRRt
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNR-tansible.module_utils.basicRt&ansible.module_utils.network.enos.enosR	R
Rt+ansible.module_utils.network.common.parsingRtansible.module_utils.sixR
RR8t__name__(((sM/usr/lib/python2.7/site-packages/ansible/modules/network/enos/enos_command.pyt<module>s"


77		7

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