
    Vh                     z    d dl mZmZmZ eZdZdZdZd dl	m
Z
 d dlmZmZ  G d de      Zd	 Zed
k(  r e        yy)    )absolute_importdivisionprint_functiona
  
---
module: edit_snmp
version_added: "1.0.0"
author:
    - WangBaoshan (@ieisystem)
short_description: Set snmp
description:
   - Set snmp on kaytus Server.
notes:
   - Does not support C(check_mode).
options:
    version:
        description:
            - SNMP trap version option, 0 - 'v1', 1 - 'v2c', 2 - 'v3', 3 - 'all', 4 - 'customize'.
            - Only the M5 models support this feature.
        choices: [0, 1, 2, 3, 4]
        type: int
    snmp_status:
        description:
            - NMP read/write status of customize.
            - The input parameters are 'v1get', 'v1set', 'v2cget', 'v2cset', 'v3get', 'v3set', separated by commas, such as v1get, v1set, v2cget.
            - Only the M5 models support this feature.
        type: list
        elements: str
    community:
        description:
            - Community of v1/v2c or v1get/v1set/v2cget/v2cset.
            - Only the M5 models support this feature.
        type: str
    v1status:
        description:
            - SNMP V1 enable.
        choices: ['enable', 'disable']
        type: str
    v2status:
        description:
            - SNMP V2 enable.
        choices: ['enable', 'disable']
        type: str
    v3status:
        description:
            - SNMP V3 enable.
        choices: ['enable', 'disable']
        type: str
    read_community:
        description:
            - Read Only Community, Community should between 1 and 16 characters.
            - Only the M6 models support this feature.
        type: str
    read_write_community:
        description:
            - Read And Write Community, Community should between 1 and 16 characters.
            - Only the M6 models support this feature.
        type: str
    v3username:
        description:
            - Set a username for the V3 trap or v3get/v3set.
        type: str
    auth_protocol:
        description:
            - Choose the authentication protocol for the V3 trap or v3get/v3set.
        choices: ['NONE', 'SHA', 'MD5']
        type: str
    auth_password:
        description:
            - Set the authentication password for the V3 trap or v3get/v3set.
            - The password is a string of 8 to 16 alphanumeric characters.
            - Required when I(auth_protocol) is either C(SHA) or C(MD5).
        type: str
    priv_protocol:
        description:
            - Choose the privacy protocol for the V3 trap or v3get/v3set.
        choices: ['NONE', 'DES', 'AES']
        type: str
    priv_password:
        description:
            - Set the privacy password for the V3 trap or v3get/v3set.
            - The password is a string of 8 to 16 alphanumeric characters.
            - Required when I(priv_protocol) is either C(DES) or C(AES).
        type: str
extends_documentation_fragment:
    - kaytus.ksmanage.ksmanage
au  
- name: Snmp test
  hosts: ksmanage
  no_log: true
  connection: local
  gather_facts: false
  vars:
    ksmanage:
      host: "{{ ansible_ssh_host }}"
      username: "{{ username }}"
      password: "{{ password }}"

  tasks:

  - name: "Set snmp get/set"
    kaytus.ksmanage.edit_snmp:
      community: "test"
      v3username: "test"
      provider: "{{ ksmanage }}"

a1  
message:
    description: Messages returned after module execution.
    returned: always
    type: str
state:
    description: Status after module execution.
    returned: always
    type: str
changed:
    description: Check to see if a change was made on the device.
    returned: always
    type: bool
)AnsibleModule)ksmanage_argument_specget_connectionc                   *    e Zd Zd Zd Zd Zd Zd Zy)SNMPc                 ^    || _         d | _        | j                          t               | _        y )N)specmoduleinit_moduledictresults)selfargument_specs     m/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/kaytus/ksmanage/plugins/modules/edit_snmp.py__init__zSNMP.__init__   s%    !	v    c                 <    t        | j                  d      | _        y)zInit module objectF)r   supports_check_modeN)r   r   r   r   s    r   r   zSNMP.init_module   s     $))@r   c                     d| j                   j                  d<   t        | j                         | _        | j                  d   dk(  rd| j                  d<   y y )Nsetsnmp
subcommandStateSuccessTchanged)r   paramsr   r   r   s    r   run_commandzSNMP.run_command   sJ    +4<(%dkk2<< I-&*DLL# .r   c                 P     | j                   j                  di | j                   y)zShow resultN )r   	exit_jsonr   r   s    r   show_resultzSNMP.show_result   s    --r   c                 D    | j                          | j                          y)WorkerN)r    r$   r   s    r   workz	SNMP.work   s    r   N)__name__
__module____qualname__r   r   r    r$   r'   r"   r   r   r
   r
      s    @+.r   r
   c                     t        t        ddg d      t        ddd      t        dd      t        ddd	d
g      t        ddd	d
g      t        ddd	d
g      t        dd      t        dd      t        dd      t        ddg d      t        ddd      t        ddg d      t        ddd            } | j                  t               t        |       }|j	                          y )NintF)r               )typerequiredchoicesliststr)r1   elementsr2   )r1   r2   enabledisable)NONESHAMD5T)r1   r2   no_log)r9   DESAES)versionsnmp_status	communityv1statusv2statusv3statusread_communityread_write_community
v3usernameauth_protocolauth_passwordpriv_protocolpriv_password)r   updater   r
   r'   )r   snmp_objs     r   mainrN      s    %%IfuuEEE2558Y:OP558Y:OP558Y:OP7!uu=UU3?UVdC?UVdCM /0M"HMMOr   __main__N)
__future__r   r   r   r1   __metaclass__DOCUMENTATIONEXAMPLESRETURNansible.module_utils.basicr   Aansible_collections.kaytus.ksmanage.plugins.module_utils.ksmanager   r   objectr
   rN   r(   r"   r   r   <module>rX      sW    C BSj,
 5 v6 :* zF r   