
    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_smtp
version_added: "1.0.0"
author:
    - WangBaoshan (@ispim)
short_description: Set SMTP information
description:
   - Set SMTP information on Inspur server.
   - Only the M5 models support this feature.
notes:
   - Does not support C(check_mode).
options:
    interface:
        description:
            - LAN Channel,eth0 is shared,eth1 is dedicated.
        choices: ['eth0', 'eth1', 'bond0']
        type: str
        required: true
    email:
        description:
            - Sender email.
        type: str
    primary_status:
        description:
            - Primary SMTP Support.
        choices: ['enable', 'disable']
        type: str
    primary_ip:
        description:
            - Primary SMTP server IP.
        type: str
    primary_name:
        description:
            - Primary SMTP server name.
        type: str
    primary_port:
        description:
            - Primary SMTP server port,The Identification for retry count configuration(1-65535).
        type: int
    primary_auth:
        description:
            - Primary SMTP server authentication.
        choices: ['enable', 'disable']
        type: str
    primary_username:
        description:
            - Primary SMTP server Username,lenth be 4 to 64 bits,
            - must start with letters and cannot contain ','(comma) ':'(colon) ' '(space) ';'(semicolon) '\'(backslash).
        type: str
    primary_password:
        description:
            - Primary SMTP server Password,lenth be 4 to 64 bits,cannot contain ' '(space).
            - Required when I(primary_auth=enable).
        type: str
    secondary_status:
        description:
            - Secondary SMTP Support.
        choices: ['enable', 'disable']
        type: str
    secondary_ip:
        description:
            - Secondary SMTP server IP.
        type: str
    secondary_name:
        description:
            - Secondary SMTP server name.
        type: str
    secondary_port:
        description:
            - Secondary SMTP server port,The Identification for retry count configuration(1-65535).
        type: int
    secondary_auth:
        description:
            - S.econdary SMTP server authentication
        choices: ['enable', 'disable']
        type: str
    secondary_username:
        description:
            - Secondary SMTP server Username,lenth be 4 to 64 bits,
            - must start with letters and cannot contain ','(comma) ':'(colon) ' '(space) ';'(semicolon) '\'(backslash).
        type: str
    secondary_password:
        description:
            - Secondary SMTP server Password,lenth be 4 to 64 bits,cannot contain ' '(space).
            - Required when I(secondary_auth=enable).
        type: str
extends_documentation_fragment:
    - inspur.ispim.ism
a0  
- name: Smtp test
  hosts: ism
  no_log: true
  connection: local
  gather_facts: no
  vars:
    ism:
      host: "{{ ansible_ssh_host }}"
      username: "{{ username }}"
      password: "{{ password }}"

  tasks:

  - name: "Set smtp information"
    inspur.ispim.edit_smtp:
      interface: "eth0"
      email: "inspur@Inspur.com"
      primary_status: "enable"
      primary_ip: "100.2.2.2"
      primary_name: "inspur"
      primary_auth: "disable"
      provider: "{{ ism }}"

  - name: "Set smtp information"
    inspur.ispim.edit_smtp:
      interface: "eth0"
      email: "inspur@Inspur.com"
      primary_status: "enable"
      primary_ip: "100.2.2.2"
      primary_name: "inspur"
      primary_auth: "enable"
      primary_username: "test"
      primary_password: my_password
      provider: "{{ ism }}"
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)ism_argument_specget_connectionc                   *    e Zd Zd Zd Zd Zd Zd Zy)SMTPc                 ^    || _         d | _        | j                          t               | _        y )N)specmoduleinit_moduledictresults)selfargument_specs     j/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/inspur/ispim/plugins/modules/edit_smtp.py__init__zSMTP.__init__   s%    !	v    c                 <    t        | j                  d      | _        y)zInit module objectF)r   supports_check_modeN)r   r   r   r   s    r   r   zSMTP.init_module   s     $))@r   c                     d| j                   j                  d<   t        | j                         | _        | j                  d   dk(  rd| j                  d<   y y )Nsetsmtp
subcommandStateSuccessTchanged)r   paramsr   r   r   s    r   run_commandzSMTP.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SMTP.show_result   s    --r   c                 D    | j                          | j                          y)WorkerN)r    r$   r   s    r   workz	SMTP.work   s    r   N)__name__
__module____qualname__r   r   r    r$   r'   r"   r   r   r
   r
      s    @+.r   r
   c                  X   t        di dt        ddg d      dt        dd      d	t        ddd
dg      dt        dd      dt        dd      dt        dd      dt        ddd
dg      dt        dd      dt        ddd      dt        ddd
dg      dt        dd      dt        dd      dt        dd      dt        ddd
dg      dt        dd      dt        ddd      } | j                  t               t        |       }|j	                          y )N	interfacestrT)eth0eth1bond0)typerequiredchoicesemailF)r1   r2   primary_statusenabledisable
primary_ipprimary_nameprimary_portintprimary_authprimary_usernameprimary_password)r1   r2   no_logsecondary_statussecondary_ipsecondary_namesecondary_portsecondary_authsecondary_usernamesecondary_passwordr"   )r   updater   r
   r'   )r   smtp_objs     r   mainrI      s_    ED:ST. 9@UV UU3	
 uu5 uu5 uux>ST 559 55F 558YBWX uu5 7 7 9@UV  UU;   UU4H!M& *+M"HMMOr   __main__N)
__future__r   r   r   r1   __metaclass__DOCUMENTATIONEXAMPLESRETURNansible.module_utils.basicr   9ansible_collections.inspur.ispim.plugins.module_utils.ismr   r   objectr
   rI   r(   r"   r   r   <module>rS      sX    C BYv#J
 5 i6 :2 zF r   