Anons79 Mini Shell

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

�
�Udac@`sDddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
Z
ddlZddlZddl
mZmZdd
lmZmZddlmZddlmZddlmZddlmZd�Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!e"dkr@e!�ndS(i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	communitytsupported_bys�
---
module: ordnance_config
version_added: "2.3"
author: "Alexander Turner (@alexanderturner) <[email protected]>"
short_description: Manage Ordnance configuration sections
description:
  - Ordnance router configurations use a simple block indent file syntax
    for segmenting configuration into sections.  This module provides
    an implementation for working with these configuration sections in
    a deterministic way.
options:
  lines:
    description:
      - The ordered set of commands that should be configured in the
        section.  The commands must be the exact same commands as found
        in the device running-config.  Be sure to note the configuration
        command syntax as some commands are automatically modified by the
        device config parser.
    aliases: ['commands']
  parents:
    description:
      - The ordered set of parents that uniquely identify the section or hierarchy
        the commands should be checked against.  If the parents argument
        is omitted, the commands are checked against the set of top
        level or global commands.
  src:
    description:
      - Specifies the source path to the file that contains the configuration
        or configuration template to load.  The path to the source file can
        either be the full path on the Ansible control host or a relative
        path from the playbook or role root directory.  This argument is mutually
        exclusive with I(lines), I(parents).
  before:
    description:
      - The ordered set of commands to push on to the command stack if
        a change needs to be made.  This allows the playbook designer
        the opportunity to perform configuration commands prior to pushing
        any changes without affecting how the set of commands are matched
        against the system.
  after:
    description:
      - The ordered set of commands to append to the end of the command
        stack if a change needs to be made.  Just like with I(before) this
        allows the playbook designer to append a set of commands to be
        executed after the command set.
  match:
    description:
      - Instructs the module on the way to perform the matching of
        the set of commands against the current device config.  If
        match is set to I(line), commands are matched line by line.  If
        match is set to I(strict), command lines are matched with respect
        to position.  If match is set to I(exact), command lines
        must be an equal match.  Finally, if match is set to I(none), the
        module will not attempt to compare the source configuration with
        the running configuration on the remote device.
    default: line
    choices: ['line', 'strict', 'exact', 'none']
  replace:
    description:
      - Instructs the module on the way to perform the configuration
        on the device.  If the replace argument is set to I(line) then
        the modified lines are pushed to the device in configuration
        mode.  If the replace argument is set to I(block) then the entire
        command block is pushed to the device in configuration mode if any
        line is not correct.
    default: line
    choices: ['line', 'block']
  multiline_delimiter:
    description:
      - This argument is used when pushing a multiline configuration
        element to the Ordnance router.  It specifies the character to use
        as the delimiting character.  This only applies to the
        configuration action
    default: "@"
  backup:
    description:
      - This argument will cause the module to create a full backup of
        the current C(running-config) from the remote device before any
        changes are made.  The backup file is written to the C(backup)
        folder in the playbook root directory.  If the directory does not
        exist, it is created.
    type: bool
    default: 'no'
  config:
    description:
      - The C(config) argument allows the playbook designer to supply
        the base configuration to be used to validate configuration
        changes necessary.  If this argument is provided, the module
        will not download the running-config from the remote node.
  defaults:
    description:
      - This argument specifies whether or not to collect all defaults
        when getting the remote device running config.  When enabled,
        the module will get the current config by issuing the command
        C(show running-config all).
    type: bool
    default: 'no'
  save:
    description:
      - The C(save) argument instructs the module to save the running-
        config to the startup-config at the conclusion of the module
        running.  If check mode is specified, this argument is ignored.
    type: bool
    default: 'no'
s�
---
# Note: examples below use the following provider dict to handle
#       transport and authentication to the node.
vars:
  cli:
    host: "{{ inventory_hostname }}"
    username: RouterName
    password: password
    transport: cli

---
- name: configure top level configuration
  ordnance_config:
    lines: hostname {{ inventory_hostname }}
    provider: "{{ cli }}"

- name: configure interface settings
  ordnance_config:
    lines:
      - description test interface
      - ip address 172.31.1.1 255.255.255.0
    parents: interface Ethernet1
    provider: "{{ cli }}"

- name: configure bgp router
  ordnance_config:
    lines:
      - neighbor 1.1.1.1 remote-as 1234
      - network 10.0.0.0/24
    parents: router bgp 65001
    provider: "{{ cli }}"

sY
updates:
  description: The set of commands that will be pushed to the remote device
  returned: Only when commands is specified.
  type: list
  sample: ['...', '...']
backup_path:
  description: The full path to the backup file
  returned: when backup is yes
  type: str
  sample: /playbooks/ansible/backup/ordnance_config.2016-07-16@22:28:34
N(t
NetworkModuletNetworkError(t
NetworkConfigtdumps(tCommand(t
get_config(t	iteritems(t	to_nativecC`s]|jdr<t|jd�dkr<|jdd�q<n|jdrY|jd�ndS(Ntmultiline_delimiteritmsgs8multiline_delimiter value can only be a single charactertforcesmThe force argument is deprecated, please use match=none instead.  This argument will be removed in the future(tparamstlent	fail_jsontappend(tmoduletwarnings((sT/usr/lib/python2.7/site-packages/ansible/modules/network/ordnance/ordnance_config.pyt
check_args�s


cC`s�i}tjd|tj�}x\|D]T}d|}tj||tj�}|r%d|}|jd�j�||<q%q%WxZ|D]R}d|}tj||tj�}|r�|jt|jd��d�}q�q�Wtj	dd|�}||fS(Ns
^banner (\w+)sbanner %s \^C(.+?)(?=\^C)s	banner %sitsbanner \w+ \^C\^Cs!! banner removed(
tretfindalltMtsearchtStgrouptstriptreplacetstrtsub(tconfigtbannerstbanner_cmdstcmdtregextmatchtkey((sT/usr/lib/python2.7/site-packages/ansible/modules/network/ordnance/ordnance_config.pytextract_banners�s


 

(cC`sIi}x<t|�D].\}}||j|�kr|||<qqW|S(N(Rtget(twantthavet	candidateR+tvalue((sT/usr/lib/python2.7/site-packages/ansible/modules/network/ordnance/ordnance_config.pytdiff_banners�s
cC`s�|jd}x�t|�D]w\}}|d|7}x=d|||dgD]&}|d7}|jjjj|�qJWtjd�|jjj�qWdS(NRs %ssconfig terminaltends
i(RRt
connectiontshelltsendallttimetsleeptreceive(RR&t	delimiterR+R1R(((sT/usr/lib/python2.7/site-packages/ansible/modules/network/ordnance/ordnance_config.pytload_banners�s


cC`sc|jd}|s8|jd}|jjd|�}nt|�\}}tddd|�|fS(NR%tdefaultstinclude_defaultstindentitcontents(RR%R
R,R
(RtresultR?R<R&((sT/usr/lib/python2.7/site-packages/ansible/modules/network/ordnance/ordnance_config.pyR
�s

cC`s�tdd�}i}|jdrKt|jd�\}}|j|�n@|jdr�|jdpkt�}|j|jdd|�n||fS(NR>itsrctlinestparents(R
RR,tloadtlisttadd(RR0R&RARC((sT/usr/lib/python2.7/site-packages/ansible/modules/network/ordnance/ordnance_config.pyt
get_candidate�s

cC`s�|jd}|jd}|jd}t|�\}}|dkr�t||�\}}|jd}|j|d|d|d|�}	n|j}	i}t||�}
|	s�|
r{t|	d�jd�}|jdr"|jd	r�|jd	|d
*n|jdr"|j|jd�q"n||d<|
|d
<|j	sn|rU|j
|�n|
rnt||
�qnnt|d<n|jdr�|j	s�|j
j
�nt|d<ndS(NR*R"RCtnonetpathtcommandss
RBtbeforeitaftertupdatesR&tchangedtsave(RRGR
t
differencetitemsR2Rtsplittextendt
check_modeR%R;tTruetsave_config(RR@R*R"RIR0twant_bannersR%thave_bannerst
configobjsR&RJ((sT/usr/lib/python2.7/site-packages/ansible/modules/network/ordnance/ordnance_config.pytruns>



	




	

	cC`s5tdtdd�dtddgdd�dtdd�d	tdd�d
tdd�dtdd
dd
dddg�dtdd
dd
dg�dtdd�dt�dtdddt�dtdddt�dtdtdd��}d'd(g}dddgfdddgfdddgfg}td|dtd|d|dt�}|jd tkryd|jd<nt�}t||�td!td"|�}|jdr�|jj�|d#<nyt	||�Wn?t
k
r}|j�|jd$t
|�d%tj��nX|j�|j|�d&S()s+ main entry point for module execution
    RAttypeRIRBtaliasesRJRERCRKRLR*tdefaulttlinetchoiceststricttexactRHR"tblockRt@R%R<tbooltbackupROt
argument_spectconnect_on_loadtmutually_exclusivetrequired_iftsupports_check_modeRRNRt
__backup__Rt	exceptionN(RBRA(RCRA(tdicttFalseRRURRERR%R
RZR	t
disconnectRRt	tracebackt
format_exct	exit_json(RfRhRiRRR@te((sT/usr/lib/python2.7/site-packages/ansible/modules/network/ordnance/ordnance_config.pytmain/sJ!				


&
t__main__(#t
__future__RRRR[t
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNRR7Rpt+ansible.module_utils.network.common.networkRR	t*ansible.module_utils.network.common.configR
Rt+ansible.module_utils.network.common.parsingRt.ansible.module_utils.network.ordnance.ordnanceR
tansible.module_utils.sixRtansible.module_utils._textRRR,R2R;RGRZRtt__name__(((sT/usr/lib/python2.7/site-packages/ansible/modules/network/ordnance/ordnance_config.pyt<module>s4


l#
					
		/	:

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