
    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: update_fw
version_added: "1.0.0"
author:
    - WangBaoshan (@ieisystem)
short_description: Update firmware
description:
   - Update firmware on ieisystem Server.
notes:
   - Does not support C(check_mode).
options:
    url:
        description:
            - Firmware image url.
        required: true
        type: str
    mode:
        description:
            - Active mode, Manual or Auto(default).
        default: Auto
        choices: ['Auto', 'Manual']
        type: str
    type:
        description:
            - Firmware type.
        choices: ['BMC', 'BIOS']
        type: str
    over_ride:
        description:
            - Reserve Configurations, 0-reserve, 1-override.
        default: 0
        choices: [0, 1]
        type: int
    has_me:
        description:
            - Update me or not when update bios, only work in INTEL platform, 0-no, 1-yes.
            - Only the M5 model supports this parameter.
        default: 1
        choices: [0, 1]
        type: int
    dual_image:
        description:
            - Update dual image(default) or not.
            - Only the M5 model supports this parameter.
        default: dual
        choices: ['single', 'dual']
        type: str
extends_documentation_fragment:
    - ieisystem.inmanage.inmanage
aa  
- name: Update fw test
  hosts: inmanage
  connection: local
  gather_facts: false
  vars:
    inmanage:
      host: "{{ ansible_ssh_host }}"
      username: "{{ username }}"
      password: "{{ password }}"

  tasks:

  - name: "update bios"
    ieisystem.inmanage.update_fw:
      url: "/home/wbs/SA5112M5_BIOS_4.1.8_Standard_20200117.bin"
      type: "BIOS"
      provider: "{{ inmanage }}"

  - name: "update bmc"
    ieisystem.inmanage.update_fw:
      url: "/home/wbs/SA5112M5_BMC_4.17.7_Standard_20200430"
      mode: "Auto"
      type: "BMC"
      dual_image: "dual"
      provider: "{{ inmanage }}"
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)inmanage_argument_specget_connectionc                   *    e Zd Zd Zd Zd Zd Zd Zy)Updatec                 ^    || _         d | _        | j                          t               | _        y )N)specmoduleinit_moduledictresults)selfargument_specs     p/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/ieisystem/inmanage/plugins/modules/update_fw.py__init__zUpdate.__init__o   s%    !	v    c                 <    t        | j                  d      | _        y)zInit module objectF)r   supports_check_modeN)r   r   r   r   s    r   r   zUpdate.init_moduleu   s     $))@r   c                     d| j                   j                  d<   t        | j                         | _        | j                  d   dk(  rd| j                  d<   y y )Nfwupdate
subcommandStateSuccessTchanged)r   paramsr   r   r   s    r   run_commandzUpdate.run_command{   sJ    +5<(%dkk2<< I-&*DLL# .r   c                 P     | j                   j                  di | j                   y)zShow resultN )r   	exit_jsonr   r   s    r   show_resultzUpdate.show_result   s    --r   c                 D    | j                          | j                          y)WorkerN)r    r$   r   s    r   workzUpdate.work   s    r   N)__name__
__module____qualname__r   r   r    r$   r'   r"   r   r   r
   r
   n   s    @+.r   r
   c                  (   t        t        dd      t        ddddg      t        dddd	g      t        dd
ddg      t        dd	dd	g      t        ddddg            } | j                  t               t        |       }|j	                          y )NstrT)typerequiredAutoManual)r-   defaultchoicesintr      FBMCBIOS)r-   r.   r2   dualsingle)urlmode	over_rider-   has_me
dual_image)r   updater   r
   r'   )r   
update_objs     r   mainr@      s    ed+ufvx6HIE1q!f=uuufoFAq6:UFXv<NOM /0&JOOr   __main__N)
__future__r   r   r   r-   __metaclass__DOCUMENTATIONEXAMPLESRETURNansible.module_utils.basicr   Dansible_collections.ieisystem.inmanage.plugins.module_utils.inmanager   r   objectr
   r@   r(   r"   r   r   <module>rJ      sV    C B2h8
 5 yV : zF r   