�
�Udac @` s� d d l m Z m Z m Z e Z i d d 6d g d 6d d 6Z d Z d Z d
Z d d l
m Z d d l m
Z
m Z m Z d d
l m Z d � Z d � Z e d k r� e � n d S( i ( t absolute_importt divisiont print_functions 1.1t metadata_versiont previewt statust communityt supported_bys
---
module: pn_snmp_vacm
author: "Pluribus Networks (@rajaspachipulusu17)"
version_added: "2.8"
short_description: CLI command to create/modify/delete snmp-vacm
description:
- This module can be used to create View Access Control Models (VACM),
modify VACM and delete VACM.
options:
pn_cliswitch:
description:
- Target switch to run the CLI on.
type: str
required: false
state:
description:
- State the action to perform. Use C(present) to create snmp-vacm and
C(absent) to delete snmp-vacm and C(update) to modify snmp-vacm.
type: str
required: true
choices: ['present', 'absent', 'update']
pn_oid_restrict:
description:
- restrict OID.
type: str
pn_priv:
description:
- privileges.
type: bool
pn_auth:
description:
- authentication required.
type: bool
pn_user_type:
description:
- SNMP user type.
type: str
choices: ['rouser', 'rwuser']
pn_user_name:
description:
- SNMP administrator name.
type: str
s�
- name: create snmp vacm
pn_snmp_vacm:
pn_cliswitch: "sw01"
state: "present"
pn_user_name: "foo"
pn_user_type: "rouser"
- name: update snmp vacm
pn_snmp_vacm:
pn_cliswitch: "sw01"
state: "update"
pn_user_name: "foo"
pn_user_type: "rwuser"
- name: delete snmp vacm
pn_snmp_vacm:
pn_cliswitch: "sw01"
state: "absent"
pn_user_name: "foo"
s�
command:
description: the CLI command run on the target node.
returned: always
type: str
stdout:
description: set of responses from the snmp-vacm command.
returned: always
type: list
stderr:
description: set of error responses from the snmp-vacm command.
returned: on error
type: list
changed:
description: indicates whether the CLI caused changes on the target.
returned: always
type: bool
( t
AnsibleModule( t pn_clit run_clit booleanArgs( t run_commandsc C` s� | j d } | } | d 7} t | | � \ } } } | rP | | j � k rP n d S| } | d 7} t | | � d } | r� | j � } n | | k r� t St S( s�
This method checks for idempotency using the snmp-vacm-show command.
If a user with given name exists, return True else False.
:param module: The Ansible module to fetch input parameters
:param cli: The CLI string
t pn_user_names0 snmp-user-show format user-name no-show-headerss0 snmp-vacm-show format user-name no-show-headersi N( t paramsR t splitt Nonet Truet False( t modulet clit user_namet showt rct outt err( ( sQ /usr/lib/python2.7/site-packages/ansible/modules/network/netvisor/pn_snmp_vacm.pyt check_clij s
c C` sB t d d d d d d � } t d t d t d t d
d � d t d t d
d d
| j � � d t d t d
d � d t d t d
d � d t d t d
d � d t d t d
d d
d d g � d t d t d
d � � d d d d g g d d d g g d d d g g f � } | j d } | j d } | j d } | j d } | j d } | j d } | j d } | | } t | | � }
t | |
� } |
d | | f 7}
| d k r| d% k r�| j d t d d | � n | t k r| j d t d d | � qn | d k rd| d% k r8| j d t d d | � n | t k rd| j
d t d d | � qdn | d k r�| d% k r�| j d t d d | � n | t k r�| j
d t d d | � q�n | d k r.| r�|
d | 7}
n | r�|
d | 7}
n |
t | d! d"