�
�Udac @ s� i d d 6d g d 6d d 6Z d Z d Z d Z d d
l Z d d l m Z m Z m Z d d l m Z d d
l
m Z d d l m
Z
d � Z d � Z d � Z d � Z d � Z e d k r� e � n d
S( s 1.1t metadata_versiont previewt statust networkt supported_bys�
---
module: nxos_gir_profile_management
extends_documentation_fragment: nxos
version_added: "2.2"
short_description: Create a maintenance-mode or normal-mode profile for GIR.
description:
- Manage a maintenance-mode or normal-mode profile with configuration
commands that can be applied during graceful removal
or graceful insertion.
author:
- Gabriele Gerbino (@GGabriele)
notes:
- Tested against NXOSv 7.3.(0)D1(1) on VIRL
- C(state=absent) removes the whole profile.
options:
commands:
description:
- List of commands to be included into the profile.
mode:
description:
- Configure the profile as Maintenance or Normal mode.
required: true
choices: ['maintenance', 'normal']
state:
description:
- Specify desired state of the resource.
default: present
choices: ['present','absent']
s�
# Create a maintenance-mode profile
- nxos_gir_profile_management:
mode: maintenance
commands:
- router eigrp 11
- isolate
# Remove the maintenance-mode profile
- nxos_gir_profile_management:
mode: maintenance
state: absent
s�
proposed:
description: list of commands passed into module.
returned: verbose mode
type: list
sample: ["router eigrp 11", "isolate"]
existing:
description: list of existing profile commands.
returned: verbose mode
type: list
sample: ["router bgp 65535","isolate","router eigrp 10","isolate",
"diagnostic bootup level complete"]
end_state:
description: list of profile entries after module execution.
returned: verbose mode
type: list
sample: ["router bgp 65535","isolate","router eigrp 10","isolate",
"diagnostic bootup level complete","router eigrp 11", "isolate"]
updates:
description: commands sent to the device
returned: always
type: list
sample: ["configure maintenance profile maintenance-mode",
"router eigrp 11","isolate"]
changed:
description: check to see if a change was made on the device
returned: always
type: bool
sample: true
i����N( t
get_configt load_configt run_commands( t nxos_argument_spec( t
AnsibleModule( t CustomNetworkConfigc C s� g } t d d d t | � � } | j d d k r@ d g } n d g } | j | � } | r� | j � } g | D] } | j � ^ qq } | j d � n | S( Nt indenti t contentst modet maintenances. configure maintenance profile maintenance-modes) configure maintenance profile normal-modei ( R
R t paramst get_sectiont
splitlinest stript pop( t modulet existingt netcfgt parentst configt cmd( ( s\ /usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_gir_profile_management.pyt get_existingl s c C s` t � } | | k r | S| j | � | j d d k rL | j d d � n | j d d � | S( NR
R i s. configure maintenance profile maintenance-modes) configure maintenance profile normal-mode( t listt extendR t insert( R R t commandst cmds( ( s\ /usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_gir_profile_management.pyt
state_present~ s
c C s, | j d d k r d g } n d g } | S( NR
R s1 no configure maintenance profile maintenance-modes, no configure maintenance profile normal-mode( R ( R R R R ( ( s\ /usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_gir_profile_management.pyt state_absent� s c O s) t � j | � } | r% | | | � Sd S( N( t globalst get( t namet argst kwargst func( ( s\ /usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_gir_profile_management.pyt invoke� s c
C s� t d t d t d d � d t d t d d d g � d t d d
d g d d � � } | j t � t d
| d t � } t � } | j d } | j d p� g } | d
k r� | r� | j d d � n t d | � } | } t } i } g } | d k s | d
k rr| rrt d | | | | � } | j
rD| j d t d | � qr| rrt | | � t } t d | � } qrn | | d <| j
d k r�t d | � } | | d <| | d <| | d <| | d <n | | d <| j | � d S( NR t requiredt typeR R
t choicesR t normalt statet absentt presentt defaultt
argument_spect supports_check_modet msgs- when state is absent, no command can be used.R s state_%st changedi t end_stateR t proposedt updatest warnings( t dictt Falset Truet updateR R R R t fail_jsonR( t
check_modet exit_jsonR t
_verbosity(
R1 R R8 R- R R R5 R4 t resultR ( ( s\ /usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_gir_profile_management.pyt main� sD
t __main__( t ANSIBLE_METADATAt
DOCUMENTATIONt EXAMPLESt RETURNt ret&