Anons79 Mini Shell

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

�
�Udac@`sddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
Z
ddlZddlm
Z
dd
lmZddlmZmZmZddlmZmZmZddlmZmZmZddlmZddlmZmZyddlm Z m!Z!Wn'e"k
rGddl#m Z m!Z!nXyddlm$Z$WnOe"k
r�yddl#m$Z$Wq�e"k
r�ddl%m&Z&e&Z$q�XnXe'Z(dZ)d�Z*d�Z+dd�Z,d�Z-d�Z.d�Z/d�Z0e1dkre0�ndS( i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatustnetworktsupported_bys�
---
module: junos_config
version_added: "2.1"
author: "Peter Sprygada (@privateip)"
short_description: Manage configuration on devices running Juniper JUNOS
description:
  - This module provides an implementation for working with the active
    configuration running on Juniper JUNOS devices.  It provides a set
    of arguments for loading configuration, performing rollback operations
    and zeroing the active configuration on the device.
extends_documentation_fragment: junos
options:
  lines:
    description:
      - This argument takes a list of C(set) or C(delete) configuration
        lines to push into the remote device.  Each line must start with
        either C(set) or C(delete).  This argument is mutually exclusive
        with the I(src) argument.
  src:
    description:
      - The I(src) argument provides a path to the configuration file
        to load into the remote system. The path can either be a full
        system path to the configuration file if the value starts with /
        or relative to the root of the implemented role or playbook.
        This argument is mutually exclusive with the I(lines) argument.
    version_added: "2.2"
  src_format:
    description:
      - The I(src_format) argument specifies the format of the configuration
        found int I(src).  If the I(src_format) argument is not provided,
        the module will attempt to determine the format of the configuration
        file specified in I(src).
    choices: ['xml', 'set', 'text', 'json']
    version_added: "2.2"
  rollback:
    description:
      - The C(rollback) argument instructs the module to rollback the
        current configuration to the identifier specified in the
        argument.  If the specified rollback identifier does not
        exist on the remote device, the module will fail.  To rollback
        to the most recent commit, set the C(rollback) argument to 0.
  zeroize:
    description:
      - The C(zeroize) argument is used to completely sanitize the
        remote device configuration back to initial defaults.  This
        argument will effectively remove all current configuration
        statements on the remote device.
    type: bool
  confirm:
    description:
      - The C(confirm) argument will configure a time out value in minutes
        for the commit to be confirmed before it is automatically
        rolled back.  If the C(confirm) argument is set to False, this
        argument is silently ignored.  If the value for this argument
        is set to 0, the commit is confirmed immediately.
    default: 0
  comment:
    description:
      - The C(comment) argument specifies a text string to be used
        when committing the configuration.  If the C(confirm) argument
        is set to False, this argument is silently ignored.
    default: configured by junos_config
  replace:
    description:
      - The C(replace) argument will instruct the remote device to
        replace the current configuration hierarchy with the one specified
        in the corresponding hierarchy of the source configuration loaded
        from this module.
      - Note this argument should be considered deprecated.  To achieve
        the equivalent, set the I(update) argument to C(replace). This argument
        will be removed in a future release. The C(replace) and C(update) argument
        is mutually exclusive.
    type: bool
    default: 'no'
  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. If the C(backup_options) value is not given,
        the backup file is written to the C(backup) folder in the playbook
        root directory or role root directory, if playbook is part of an
        ansible role. If the directory does not exist, it is created.
    type: bool
    default: 'no'
    version_added: "2.2"
  update:
    description:
      - This argument will decide how to load the configuration
        data particularly when the candidate configuration and loaded
        configuration contain conflicting statements. Following are
        accepted values.
        C(merge) combines the data in the loaded configuration with the
        candidate configuration. If statements in the loaded configuration
        conflict with statements in the candidate configuration, the loaded
        statements replace the candidate ones.
        C(override) discards the entire candidate configuration and replaces
        it with the loaded configuration.
        C(replace) substitutes each hierarchy level in the loaded configuration
        for the corresponding level.
        C(update) is similar to the override option. The new configuration completely
        replaces the existing configuration. The difference comes when the configuration
        is later committed. This option performs a 'diff' between the new candidate
        configuration and the existing committed configuration. It then only notifies
        system processes responsible for the changed portions of the configuration, and
        only marks the actual configuration changes as 'changed'.
    default: merge
    choices: ['merge', 'override', 'replace', 'update']
    version_added: "2.3"
  confirm_commit:
    description:
      - This argument will execute commit operation on remote device.
        It can be used to confirm a previous commit.
    type: bool
    default: 'no'
    version_added: "2.4"
  check_commit:
    description:
      - This argument will check correctness of syntax; do not apply changes.
      - Note that this argument can be used to confirm verified configuration done via commit confirmed operation
    type: bool
    default: 'no'
    version_added: "2.8"
  backup_options:
    description:
      - This is a dict object containing configurable options related to backup file path.
        The value of this option is read only when C(backup) is set to I(yes), if C(backup) is set
        to I(no) this option will be silently ignored.
    suboptions:
      filename:
        description:
          - The filename to be used to store the backup configuration. If the the filename
            is not given it will be generated based on the hostname, current time and date
            in format defined by <hostname>_config.<current-date>@<current-time>
      dir_path:
        description:
          - This option provides the path ending with directory name in which the backup
            configuration file will be stored. If the directory does not exist it will be first
            created and the filename is either the value of C(filename) or default filename
            as described in C(filename) options description. If the path value is not given
            in that case a I(backup) directory will be created in the current working directory
            and backup configuration will be copied in C(filename) within I(backup) directory.
        type: path
    type: dict
    version_added: "2.8"
requirements:
  - ncclient (>=v0.5.2)
notes:
  - This module requires the netconf system service be enabled on
    the remote device being managed.
  - Abbreviated commands are NOT idempotent, see
    L(Network FAQ,../network/user_guide/faq.html#why-do-the-config-modules-always-return-changed-true-with-abbreviated-commands).
  - Loading JSON-formatted configuration I(json) is supported
    starting in Junos OS Release 16.1 onwards.
  - Update C(override) not currently compatible with C(set) notation.
  - Tested against vSRX JUNOS version 15.1X49-D15.4, vqfx-10000 JUNOS Version 15.1X53-D60.4.
  - Recommended connection is C(netconf). See L(the Junos OS Platform Options,../network/user_guide/platform_junos.html).
  - This module also works with C(local) connections for legacy playbooks.
s�
- name: load configure file into device
  junos_config:
    src: srx.cfg
    comment: update config

- name: load configure lines into device
  junos_config:
    lines:
      - set interfaces ge-0/0/1 unit 0 description "Test interface"
      - set vlans vlan01 description "Test vlan"
    comment: update config

- name: Set routed VLAN interface (RVI) IPv4 address
  junos_config:
    lines:
      - set vlans vlan01 vlan-id 1
      - set interfaces irb unit 10 family inet address 10.0.0.1/24
      - set vlans vlan01 l3-interface irb.10

- name: Check correctness of commit configuration
  junos_config:
    check_commit: yes

- name: rollback the configuration to id 10
  junos_config:
    rollback: 10

- name: zero out the current configuration
  junos_config:
    zeroize: yes

- name: Set VLAN access and trunking
  junos_config:
    lines:
      - set vlans vlan02 vlan-id 6
      - set interfaces ge-0/0/6.0 family ethernet-switching interface-mode access vlan members vlan02
      - set interfaces ge-0/0/6.0 family ethernet-switching interface-mode trunk vlan members vlan02

- name: confirm a previous commit
  junos_config:
    confirm_commit: yes

- name: for idempotency, use full-form commands
  junos_config:
    lines:
      # - set int ge-0/0/1 unit 0 desc "Test interface"
      - set interfaces ge-0/0/1 unit 0 description "Test interface"

- name: configurable backup path
  junos_config:
    src: srx.cfg
    backup: yes
    backup_options:
      filename: backup.cfg
      dir_path: /home/user
sL
backup_path:
  description: The full path to the backup file
  returned: when backup is yes
  type: str
  sample: /playbooks/ansible/backup/config.2016-07-16@22:28:34
filename:
  description: The name of the backup file
  returned: when backup is yes and filename is not specified in backup options
  type: str
  sample: junos01_config.2016-07-16@22:28:34
shortname:
  description: The full path to the backup file excluding the timestamp
  returned: when backup is yes and filename is not specified in backup options
  type: str
  sample: /playbooks/ansible/backup/junos01_config
date:
  description: The date extracted from the backup file name
  returned: when backup is yes
  type: str
  sample: "2016-07-16"
time:
  description: The time extracted from the backup file name
  returned: when backup is yes
  type: str
  sample: "22:28:34"
N(t
AnsibleModule(texec_rpc(tget_difftload_configtget_configuration(tcommit_configurationtdiscard_changest
locked_config(tjunos_argument_spectload_configurationttostring(tstring_types(t	to_nativetto_text(tElementt
fromstring(t
ParseError(t
ExpatErrorsconfigured by junos_configcC`s*|jddk	r&|jdd�ndS(Ntreplacetmsgs*argument replace is deprecated, use update(tparamstNonet	fail_json(tmoduletwarnings((sN/usr/lib/python2.7/site-packages/ansible/modules/network/junos/junos_config.pyt
check_args#scC`st|ttd��dt�S(Nsrequest-system-zeroizetignore_warning(R	RRtFalse(R((sN/usr/lib/python2.7/site-packages/ansible/modules/network/junos/junos_config.pytzeroize(st0cC`s
t||�S(N(R
(teletid((sN/usr/lib/python2.7/site-packages/ansible/modules/network/junos/junos_config.pytrollback,scC`suytj|�dSWntk
r(nXyt|�dSWntk
rNnX|jd�sm|jd�rqdSdS(Ntjsontxmltsettdeletettext(R)tloadst
ValueErrorRRt
startswith(tconfig((sN/usr/lib/python2.7/site-packages/ansible/modules/network/junos/junos_config.pytguess_format0s



c	C`s�t|dd�}|jd�}|dkr1|St|jdd�}|}xcttt|���D]I\}}|jd�rft	j
dd|�}||kr�||=q�qfqfW|S(NtformatR+s.//configuration-settencodingslatin-1R,s^delete(RtfindRRR-treversedtlistt	enumerateR0tretsub(	Rt	candidatetreplytmatchR1tmodified_candidatetindextlinetnewline((sN/usr/lib/python2.7/site-packages/ansible/modules/network/junos/junos_config.pytfilter_delete_statementsCs%cC`si}d}|jdr�|jdp5tt|��}|dkrb|jidd6dd6�q�|ji|d6|jdd6�nt|t�r�|jd�}nt|jd	|dkf�r�t	||�}d|d<d|d<nt
||||�S(
Ntsrct
src_formatR+R-R3tactiontupdates
tlines(RRR2tstrRFt
isinstanceRtsplittanyRBR(RR R;tkwargst
config_format((sN/usr/lib/python2.7/site-packages/ansible/modules/network/junos/junos_config.pytconfigure_deviceUs
%

cC`sGtdt�dtdd��}tdtddgdd�d	tdd�d
tddd
ddg�dtdddddddg�dtdd�dtdddd�dtdt�dtdddt�dtdddt�dtdddt�dtddd|�d tdd�d!tdtdd��
}|jt�d3g}td"|d#|d$t�}t�}t||�|j	dp�|j	d	}|j
}itd%6|d&6}|j	dr6xYdd
gD];}t|d'|�}	|	jd(|�}
|
d,k	r�Pq�q�W|jd)d*�|
jj�|d+<n|j	d }|r�t||�}|r�i|j	dd6}
t|��"t|d |�t||
�Wd,QX|jr�i|d-6|d.<q�nt|d%<ng|j	d!r�|r�t|�nt|d%<n:|r�t|���t|||�}|r�|r�i|j	dd6|j	dd/6}
|j	d}|dkr�|
jitd6t|d0d1�d26�nt||
�n
t|�t|d%<|jr�i|d-6|d.<q�nWd,QXnW|j	dr�t|d/t�n7|j	dr6t|��t|�Wd,QXt|d%<n|j|�d,S(4s+ main entry point for module execution
    tfilenametdir_pathttypetpathRGtaliasestcommandsR7RCRDtchoicesR*R-R+R)RFtdefaulttmergetoverrideRtbooltconfirmitinttcommenttconfirm_committcheck_committbackuptbackup_optionstdicttoptionsR(R$t
argument_spectmutually_exclusivetsupports_check_modetchangedR R3s.//configuration-%sRs'unable to retrieve device configurationt
__backup__Ntpreparedtdifftcheckterrorstsurrogate_then_replacetconfirm_timeout(RGRCR(R$(RatDEFAULT_COMMENTR#RFRRtTrueR7R!Rt
check_modeRR5RRR-tstripR(RRR
t_diffR$RNRRt	exit_json(tbackup_specRcRdRR R;tcommittresulttconf_formatR<R=trollback_idRiRLRZ((sN/usr/lib/python2.7/site-packages/ansible/modules/network/junos/junos_config.pytmainns�	!
			




	





	

	 



t__main__(2t
__future__RRRRQt
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNR9R)tansible.module_utils.basicRt+ansible.module_utils.network.common.netconfR	t(ansible.module_utils.network.junos.junosR
RRR
RRRRRtansible.module_utils.sixRtansible.module_utils._textRRt
lxml.etreeRRtImportErrortxml.etree.ElementTreeRtxml.parsers.expatRRotUSE_PERSISTENT_CONNECTIONRnR!R$R(R2RBRNRyt__name__(((sN/usr/lib/python2.7/site-packages/ansible/modules/network/junos/junos_config.pyt<module>sN


�:


						t

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