
    Vh                         d dl mZmZmZ eZdZdZdZd dl	Z	d dl
Z
dZ	 d dlmZ d dlmZmZ d Zed	k(  r e        yy# e$ r  e	j                         ZdZY 3w xY w)
    )absolute_importdivisionprint_functiona	  
module: ipmi_boot
short_description: Management of order of boot devices
description:
  - Use this module to manage order of boot devices.
extends_documentation_fragment:
  - community.general.attributes
attributes:
  check_mode:
    support: full
  diff_mode:
    support: none
options:
  name:
    description:
      - Hostname or IP address of the BMC.
    required: true
    type: str
  port:
    description:
      - Remote RMCP port.
    default: 623
    type: int
  user:
    description:
      - Username to use to connect to the BMC.
    required: true
    type: str
  password:
    description:
      - Password to connect to the BMC.
    required: true
    type: str
  key:
    description:
      - Encryption key to connect to the BMC in hex format.
    required: false
    type: str
    version_added: 4.1.0
  bootdev:
    description:
      - Set boot device to use on next reboot.
      - 'The choices for the device are:'
      - V(network) -- Request network boot.
      - V(floppy) -- Boot from floppy.
      - V(hd) -- Boot from hard drive.
      - V(safe) -- Boot from hard drive, requesting 'safe mode'.
      - V(optical) -- boot from CD/DVD/BD drive.
      - V(setup) -- Boot into setup utility.
      - V(default) -- remove any IPMI directed boot device request.
    required: true
    choices:
      - network
      - floppy
      - hd
      - safe
      - optical
      - setup
      - default
    type: str
  state:
    description:
      - Whether to ensure that boot devices is desired.
      - 'The choices for the state are: - present -- Request system turn on - absent -- Request system turn on.'
    default: present
    choices: [present, absent]
    type: str
  persistent:
    description:
      - If set, ask that system firmware uses this device beyond next boot. Be aware many systems do not honor this.
    type: bool
    default: false
  uefiboot:
    description:
      - If set, request UEFI boot explicitly. Strictly speaking, the spec suggests that if not set, the system should BIOS
        boot and offers no "do not care" option. In practice, this flag not being set does not preclude UEFI boot on any system
        I have encountered.
    type: bool
    default: false
requirements:
  - pyghmi
author: "Bulat Gaifullin (@bgaifullin) <gaifullinbf@gmail.com>"
a  
bootdev:
  description: The boot device name which will be used beyond next boot.
  returned: success
  type: str
  sample: default
persistent:
  description: If True, system firmware will use this device beyond next boot.
  returned: success
  type: bool
  sample: false
uefimode:
  description: If True, system firmware will use UEFI boot explicitly beyond next boot.
  returned: success
  type: bool
  sample: false
at  
- name: Ensure bootdevice is HD
  community.general.ipmi_boot:
    name: test.testdomain.com
    user: admin
    password: password
    bootdev: hd

- name: Ensure bootdevice is not Network
  community.general.ipmi_boot:
    name: test.testdomain.com
    user: admin
    password: password
    key: 1234567890AABBCCDEFF000000EEEE12
    bootdev: network
    state: absent
N)command)AnsibleModulemissing_required_libc                     t        t        t        d      t        dd      t        dd      t        dd      t        dd      t        d	d	d
g      t        dg d      t        dd      t        dd      	      d      } t         | j                  t	        d      t
               | j                  d   }| j                  d   }| j                  d   }| j                  d   }| j                  d   }| j                  d   }| j                  d   }| j                  d   }t               }	|d
k(  r|dk(  r| j                  d       	 | j                  d   r#t        j                  | j                  d         }
nd }
	 t        j                  ||||
!      }| j                  d"|z         |j                         }|j                  d#|       |d	k(  r |t        |||$      k7  rt        |||%      }	n.|d
k(  r|d   |k(  rt        d&      }	n | j                  d*d'di| | j                  rt        |	d   &      }n |j                   d*i |	}d(|v r| j                  |d(          d)|	v r|	d)   |d<   d|	v r|	d   |d#<    | j                  d*d'di| y # t        $ r}| j                  d        Y d }~9d }~ww xY w# t        $ r%}| j                  t#        |             Y d }~y d }~ww xY w)+NT)requiredio  int)defaulttype)r
   no_logstr)r   r   presentabsent)r   choices)networkhdfloppysafeopticalsetupr   )r
   r   Fbool)	nameportuserpasswordkeystatebootdev
persistentuefiboot)argument_specsupports_check_modepyghmi)msg	exceptionr   r   r   r   r   r    r!   r"   r   z9The bootdev 'default' cannot be used with state 'absent'.)r&   r   z(Unable to convert 'key' from hex string.)bmcuseridr   r   kgzipmi instantiated - name: "%s"uefimode)r    r!   r+   )r    r"   persist)r    changederrorr,    )r   dictr   	fail_jsonr   PYGHMI_IMP_ERRparamsbinascii	unhexlify	ExceptionCommanddebugget_bootdev
setdefault	exit_json
check_modeset_bootdevr   )moduler   r   r   r   r   r    r!   r"   requestr   eipmi_cmdcurrentresponses                  o/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/general/plugins/modules/ipmi_boot.pymainrE      s   t$c.tD145%-y9h2GH$0rsE7%f5

 !F 1(;~V== D== D== D}}Z(HMM'"EmmI&G|,J}}Z(HfGW	1XYI==$$V]]5%9:CC
%??TH4C
 	5<=&&(:x0I'T'jck-l"l7XzRGh79#5#@9-GF6U6g6GI$67H+x++6g6Hh'!23%,Y%7H\" #*:#6HZ 222A  IGHHIB  %SV$$%s1   4J  DK  	J= J88J= 	K.	K))K.__main__)
__future__r   r   r   r   __metaclass__DOCUMENTATIONRETURNEXAMPLES	tracebackr4   r2   pyghmi.ipmir   ImportError
format_excansible.module_utils.basicr   r   rE   __name__r/       rD   <module>rS      s    A @Rh
$$  #
 KG%T zF c  )Y))+NGs   = AA