Anons79 Mini Shell

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

�
�Udac@`s�ddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
mZdd�Z
d
�Zd�Zed�Zedkr�e�ndS(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	communitytsupported_bys�
---
module: nclu
version_added: "2.3"
author: "Cumulus Networks (@isharacomix)"
short_description: Configure network interfaces using NCLU
description:
    - Interface to the Network Command Line Utility, developed to make it easier
      to configure operating systems running ifupdown2 and Quagga, such as
      Cumulus Linux. Command documentation is available at
      U(https://docs.cumulusnetworks.com/cumulus-linux/System-Configuration/Network-Command-Line-Utility-NCLU/)
options:
    commands:
        description:
            - A list of strings containing the net commands to run. Mutually
              exclusive with I(template).
    template:
        description:
            - A single, multi-line string with jinja2 formatting. This string
              will be broken by lines, and each line will be run through net.
              Mutually exclusive with I(commands).
    commit:
        description:
            - When true, performs a 'net commit' at the end of the block.
              Mutually exclusive with I(atomic).
        default: false
        type: bool
    abort:
        description:
            - Boolean. When true, perform a 'net abort' before the block.
              This cleans out any uncommitted changes in the buffer.
              Mutually exclusive with I(atomic).
        default: false
        type: bool
    atomic:
        description:
            - When true, equivalent to both I(commit) and I(abort) being true.
              Mutually exclusive with I(commit) and I(atomic).
        default: false
        type: bool
    description:
        description:
            - Commit description that will be recorded to the commit log if
              I(commit) or I(atomic) are true.
        default: "Ansible-originated commit"
s#

- name: Add two interfaces without committing any changes
  nclu:
    commands:
        - add int swp1
        - add int swp2

- name: Modify hostname to Cumulus-1 and commit the change
  nclu:
    commands:
        - add hostname Cumulus-1
    commit: true

- name: Add 48 interfaces and commit the change.
  nclu:
    template: |
        {% for iface in range(1,49) %}
        add int swp{{iface}}
        {% endfor %}
    commit: true
    description: "Ansible - add swps1-48"

- name: Fetch Status Of Interface
  nclu:
    commands:
        - show interface swp1
  register: output

- name: Print Status Of Interface
  debug:
    var: output

- name: Fetch Details From All Interfaces In JSON Format
  nclu:
    commands:
        - show interface json
  register: output

- name: Print Interface Details
  debug:
    var: output["msg"]

- name: Atomically add an interface
  nclu:
    commands:
        - add int swp1
    atomic: true
    description: "Ansible - add swp1"

- name: Remove IP address from interface swp1
  nclu:
    commands:
        - del int swp1 ip address 1.1.1.1/24

- name: Configure BGP AS and add 2 EBGP neighbors using BGP Unnumbered
  nclu:
    commands:
        - add bgp autonomous-system 65000
        - add bgp neighbor swp51 interface remote-as external
        - add bgp neighbor swp52 interface remote-as external
    commit: true

- name: Configure BGP AS and Add 2 EBGP neighbors Using BGP Unnumbered via Template
  nclu:
    template: |
      {% for neighbor in range(51,53) %}
      add bgp neighbor swp{{neighbor}} interface remote-as external
      add bgp autonomous-system 65000
      {% endfor %}
    atomic: true

- name: Check BGP Status
  nclu:
    commands:
        - show bgp summary json
  register: output

- name: Print BGP Status In JSON
  debug:
    var: output["msg"]
s
changed:
    description: whether the interface was changed
    returned: changed
    type: bool
    sample: True
msg:
    description: human-readable report of success or failure
    returned: always
    type: str
    sample: "interface bond0 config updated"
(t
AnsibleModulecC`s]|jd|�\}}}|s:d|ks:d|krS|jd|pL|�nt|�S(s$Run a command, catch any nclu errorss/usr/bin/net %stERRORtmsg(trun_commandt	fail_jsontstr(tmoduletcommandterrmsgt_rctoutputt_err((sH/usr/lib/python2.7/site-packages/ansible/modules/network/cumulus/nclu.pytcommand_helper�scC`s\t|dd�}d}d}||krR|j|�d}|j|d�}n|j�S(s*Check the pending diff of the nclu buffer.tpendingsKError in pending config. You may want to view `net pending` on this target.s0net add/del commands since the last 'net commit'sit(Rtsplittreplacetstrip(RRt
delimeter1tcolor1((sH/usr/lib/python2.7/site-packages/ansible/modules/network/cumulus/nclu.pyt
check_pending�scC`sgt}g}|r|}n|r0|j�}nt}	|}
|sH|r`t}	|r`t}
q`n|
rvt|d�nt|�}g}x@|D]8}
|
j�r�|t||
j�d|
�g7}q�q�Wdj|�}t|�}||kr�t}nt}|	r]t|d|�}d|kr<t}t|d�q]t|d�dkr]t}q]n||fS(NtabortsFailed on line %ss
scommit description '%s'scommit ignoredsshow commit lastR(tFalset
splitlinestTrueRRRtjoin(Rtcommand_listtcommand_stringtcommittatomicRtdescriptiont_changedtcommandst	do_committdo_aborttbeforetoutput_linestlineRtaftertresult((sH/usr/lib/python2.7/site-packages/ansible/modules/network/cumulus/nclu.pytrun_nclu�s@	
*	c
C`s�tdtdtdtdd�dtdtdd�dtdtddd	d
�dtdtddd	t�d
tdtddd	t�dtdtddd	t��ddddg�}|jjdd�}|jjdd�}|jjd
�}|jjd�}|jjd�}|jjd�}t|||||||�\}}	|sl|jd|d|	�n|r�i|d6|	d6SdS(Nt
argument_specR(trequiredttypetlistttemplateR
R&tdefaultsAnsible-originated commitRtboolR$R%tmutually_exclusivetchangedR
(R(R5(R$R%(RR%(RtdictRtparamstgettNoneR0t	exit_json(
ttestingRR"R#R$R%RR&R'R((sH/usr/lib/python2.7/site-packages/ansible/modules/network/cumulus/nclu.pytmain�s*$t__main__N(t
__future__RRRR3t
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNtansible.module_utils.basicRR=RRR0RR@t__name__(((sH/usr/lib/python2.7/site-packages/ansible/modules/network/cumulus/nclu.pyt<module>s


/S
		/

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