�
�Udac @ s� i d d 6d g d 6d d 6Z d Z d Z d Z d d
l Z d d
l Z d d l m Z d d l m Z m
Z
d d
l m Z m Z d � Z
d � Z d � Z d � Z d � 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_snapshot
extends_documentation_fragment: nxos
version_added: "2.2"
short_description: Manage snapshots of the running states of selected features.
description:
- Create snapshots of the running states of selected features, add
new show commands for snapshot creation, delete and compare
existing snapshots.
author:
- Gabriele Gerbino (@GGabriele)
notes:
- Tested against NXOSv 7.3.(0)D1(1) on VIRL
- C(transport=cli) may cause timeout errors.
- The C(element_key1) and C(element_key2) parameter specify the tags used
to distinguish among row entries. In most cases, only the element_key1
parameter needs to specified to be able to distinguish among row entries.
- C(action=compare) will always store a comparison report on a local file.
options:
action:
description:
- Define what snapshot action the module would perform.
required: true
choices: [ add, compare, create, delete, delete_all ]
snapshot_name:
description:
- Snapshot name, to be used when C(action=create)
or C(action=delete).
description:
description:
- Snapshot description to be used when C(action=create).
snapshot1:
description:
- First snapshot to be used when C(action=compare).
snapshot2:
description:
- Second snapshot to be used when C(action=compare).
comparison_results_file:
description:
- Name of the file where snapshots comparison will be stored when C(action=compare).
compare_option:
description:
- Snapshot options to be used when C(action=compare).
choices: ['summary','ipv4routes','ipv6routes']
section:
description:
- Used to name the show command output, to be used
when C(action=add).
show_command:
description:
- Specify a new show command, to be used when C(action=add).
row_id:
description:
- Specifies the tag of each row entry of the show command's
XML output, to be used when C(action=add).
element_key1:
description:
- Specify the tags used to distinguish among row entries,
to be used when C(action=add).
element_key2:
description:
- Specify the tags used to distinguish among row entries,
to be used when C(action=add).
save_snapshot_locally:
description:
- Specify to locally store a new created snapshot,
to be used when C(action=create).
type: bool
default: 'no'
path:
description:
- Specify the path of the file where new created snapshot or
snapshots comparison will be stored, to be used when
C(action=create) and C(save_snapshot_locally=true) or
C(action=compare).
default: './'
s
# Create a snapshot and store it locally
- nxos_snapshot:
action: create
snapshot_name: test_snapshot
description: Done with Ansible
save_snapshot_locally: true
path: /home/user/snapshots/
# Delete a snapshot
- nxos_snapshot:
action: delete
snapshot_name: test_snapshot
# Delete all existing snapshots
- nxos_snapshot:
action: delete_all
# Add a show command for snapshots creation
- nxos_snapshot:
section: myshow
show_command: show ip interface brief
row_id: ROW_intf
element_key1: intf-name
# Compare two snapshots
- nxos_snapshot:
action: compare
snapshot1: pre_snapshot
snapshot2: post_snapshot
comparison_results_file: compare_snapshots.txt
compare_option: summary
path: '../snapshot_reports/'
s�
commands:
description: commands sent to the device
returned: verbose mode
type: list
sample: ["snapshot create post_snapshot Post-snapshot"]
i����N( t
AnsibleModule( t load_configt run_commands( t nxos_argument_spect
check_argsc C s$ i | d 6d d 6g } t | | � S( Nt commandt textt output( R ( R
t module( ( sN /usr/lib/python2.7/site-packages/ansible/modules/network/nxos/nxos_snapshot.pyt execute_show_command� s
c
C s� g } d } t | | � d } | r� | j � } d } x� | D] } i } y_ t j | | t j � } | j � } | d | d <| d | d <| d | d <| j | � Wq>