
    Vhh                     x   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 dlZd dlmZmZ d dlmZmZ d dlmZ d d	lmZmZ d d
lmZmZmZmZmZ dZdZdZdZ dZ!dZ"dZ#dZ$dZ%dZ&dZ'dZ(dZ)dZ*dZ+dZ,dZ-dZ.dZ/dZ0dZ1d Z2d!Z3d"Z4d#Z5d$Z6d%Z7d&Z8d'Z9d(Z:g d)Z;d*d+gZ<d,d-gZ=d.Z>d/Z? G d0 d1      Z@ G d2 d3      ZAd4 ZBeCd5k(  r eB        yy)6    )absolute_importdivisionprint_functiona  
---
module: idrac_reset
short_description: Factory reset the iDRACs
version_added: "2.1.0"
description:
  - This module resets the iDRAC to factory default settings.
extends_documentation_fragment:
  - dellemc.openmanage.idrac_x_auth_options
options:
  reset_to_default:
    type: str
    description:
        - If this value is not set the default behaviour is to restart the iDRAC.
        - C(All) Discards all settings and reset to default credentials.
        - C(ResetAllWithRootDefaults) Discards all settings and reset the default username to root and password to the shipping value.
        - C(Default) Discards all settings, but preserves user and network settings.
        - C(CustomDefaults) All configuration is set to custom defaults.This option is supported on firmware version 7.00.00.00 and newer versions.
    choices: ['Default', 'All', 'ResetAllWithRootDefaults', 'CustomDefaults']
    version_added: 9.2.0
  custom_defaults_file:
    description:
      - Name of the custom default configuration file in the XML format.
      - This option is applicable when I(reset_to_default) is C(CustomDefaults).
      - I(custom_defaults_file) is mutually exclusive with I(custom_defaults_buffer).
    type: str
    version_added: 9.2.0
  custom_defaults_buffer:
    description:
      - This parameter provides the option to import the buffer input in XML format as a custom default configuration.
      - This option is applicable when I(reset_to_default) is C(CustomDefaults).
      - I(custom_defaults_buffer) is mutually exclusive with I(custom_defaults_file).
    type: str
    version_added: 9.2.0
  wait_for_idrac:
    description:
      - This parameter provides the option to wait for the iDRAC to reset and lifecycle controller status to be ready.
    type: bool
    default: true
    version_added: 9.2.0
  job_wait_timeout:
    description:
      - Time in seconds to wait for job completion.
      - This is applicable when I(wait_for_idrac) is C(true).
    type: int
    default: 600
    version_added: 9.2.0
  force_reset:
    description:
      - This parameter provides the option to force reset the iDRAC without checking the iDRAC lifecycle controller status.
      - This option is applicable only for iDRAC9.
    type: bool
    default: false
    version_added: 9.2.0
  default_username:
    description:
      - This parameter is only applied when I(reset_to_default) is C(All) or C(ResetAllWithRootDefaults).
      - This parameter is required to track LifeCycle status of the server after the reset operation is
        performed. If this parameter is not provided, then the LifeCycle status is not tracked after the
        reset operation.
    type: str
    version_added: 9.4.0
  default_password:
    description:
      - This parameter is only applied when I(reset_to_default) is C(All) or C(ResetAllWithRootDefaults).
      - This parameter is required to track LifeCycle status of the server after the reset operation is
        performed. If this parameter is not provided, then the LifeCycle status is not tracked after the
        reset operation.
    type: str
    version_added: 9.4.0


requirements:
  - "python >= 3.9.6"
author:
  - "Felix Stephen (@felixs88)"
  - "Anooja Vardhineni (@anooja-vardhineni)"
  - "Lovepreet Singh (@singh-lovepreet1)"
  - "Abhishek Sinha (@ABHISHEK-SINHA10)"
notes:
    - Run this module from a system that has direct access to Dell iDRAC.
    - This module supports both IPv4 and IPv6 address for I(idrac_ip).
    - This module supports C(check_mode).
    - If reset_to_default option is not specified, then this module triggers a graceful restart.
    - This module skips the execution if reset options are not supported by the iDRAC.
a  
---
- name: Reset the iDRAC to default and do not wait till the iDRAC is accessible.
  dellemc.openmanage.idrac_reset:
   idrac_ip: "192.168.0.1"
   idrac_user: "user_name"
   idrac_password: "user_password"
   ca_path: "/path/to/ca_cert.pem"
   reset_to_default: "Default"
   wait_for_idrac: false

- name: Reset the iDRAC to All and wait for lifecycle controller status to be ready.
  dellemc.openmanage.idrac_reset:
   idrac_ip: "192.168.0.1"
   idrac_user: "user_name"
   idrac_password: "user_password"
   ca_path: "/path/to/ca_cert.pem"
   reset_to_default: "All"
   wait_for_idrac: true
   default_username: "user_name"
   default_password: "user_password"

- name: Force reset the iDRAC to default.
  dellemc.openmanage.idrac_reset:
   idrac_ip: "192.168.0.1"
   idrac_user: "user_name"
   idrac_password: "user_password"
   ca_path: "/path/to/ca_cert.pem"
   reset_to_default: "Default"
   force_reset: true

- name: Gracefully restart the iDRAC.
  dellemc.openmanage.idrac_reset:
   idrac_ip: "192.168.0.1"
   idrac_user: "user_name"
   idrac_password: "user_password"
   ca_path: "/path/to/ca_cert.pem"

- name: Reset the iDRAC to custom defaults XML and do not wait till the iDRAC is accessible.
  dellemc.openmanage.idrac_reset:
   idrac_ip: "192.168.0.1"
   idrac_user: "user_name"
   idrac_password: "user_password"
   ca_path: "/path/to/ca_cert.pem"
   reset_to_default: "CustomDefaults"
   custom_defaults_file: "/path/to/custom_defaults.xml"

- name: Reset the iDRAC to custom defaults buffer input and do not wait till the iDRAC is accessible.
  dellemc.openmanage.idrac_reset:
   idrac_ip: "192.168.0.1"
   idrac_user: "user_name"
   idrac_password: "user_password"
   ca_path: "/path/to/ca_cert.pem"
   reset_to_default: "CustomDefaults"
   custom_defaults_buffer: "<SystemConfiguration Model=\"PowerEdge R7525\" ServiceTag=\"ABCD123\">\n<Component FQDD=\"iDRAC.Embedded.1\">\n
                               <Attribute Name=\"IPMILan.1#Enable\">Disabled</Attribute>\n </Component>\n\n</SystemConfiguration>"
aq  
---
msg:
  type: str
  description: Status of the iDRAC reset operation.
  returned: always
  sample: "Successfully performed iDRAC reset."
reset_status:
  type: dict
  description: Details of iDRAC reset operation.
  returned: reset operation is triggered.
  sample: {
    "idracreset": {
            "Data": {
                "StatusCode": 204
            },
            "Message": "none",
            "Status": "Success",
            "StatusCode": 204,
            "retval": true
        }
    }
error_info:
  description: Details of the HTTP Error.
  returned: on HTTP error
  type: dict
  sample: {
    "error": {
      "code": "Base.1.0.GeneralError",
      "message": "A general error has occurred. See ExtendedInfo for more information.",
      "@Message.ExtendedInfo": [
        {
          "MessageId": "GEN1234",
          "RelatedProperties": [],
          "Message": "Unable to process the request because an error occurred.",
          "MessageArgs": [],
          "Severity": "Critical",
          "Resolution": "Retry the operation. If the issue persists, contact your system administrator."
        }
      ]
    }
  }
N)	HTTPErrorURLError)iDRACRedfishAPIIdracAnsibleModule)LooseVersion)ConnectionErrorSSLValidationError)get_idrac_firmware_version
remove_keyget_dynamic_uri&validate_and_get_first_resource_id_uriidrac_redfish_job_trackingz/redfish/v1/ManagersOemDellActions2      z3/redfish/v1/Managers/iDRAC.Embedded.1/Jobs/{job_id}z{reset_to_default} is not supported. The supported values are {supported_values}. Enter the valid values and retry the operation.z${reset_to_default} is not supported.z{reset_to_default} is not supported on this firmware version of iDRAC. The supported values are {supported_values}. Enter the valid values and retry the operation.z/iDRAC restart operation completed successfully.z#Successfully performed iDRAC reset.z-iDRAC reset operation triggered successfully.z/iDRAC restart operation triggered successfully.z,Provided directory path '{path}' is invalid.z&Failed to perform the reset operation.zhiDRAC reset is in progress. Changes will apply once the iDRAC reset operation is successfully completed.ztThe value of `job_wait_timeout` parameter cannot be negative or zero. Enter the valid value and retry the operation.zRFile extension is invalid. Supported extension for 'custom_default_file' is: .xml.z]Lifecycle controller status check is {lc_status} after {retries} number of retries, Exiting..zlProvided directory path '{path}' is not writable. Please check if the directory has appropriate permissions.z3Lifecycle controller status check is not supported.z7.00.00zNo changes found to commit!zChanges found to commit!z	@odata.id(.*?)@odataz</Attribute>SuccessFailed)         i  i  AllResetAllWithRootDefaultsz Oem.#DellManager.ResetToDefaults#Manager.Resetc                   >    e Zd Zd Zd Zd Zd Zd Zd Zd Z	d
d	Z
y)
Validationc                 J    || _         || _        | j                         | _        y )N)idracmoduleget_base_uribase_uri)selfr#   r$   s      r/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/dellemc/openmanage/plugins/modules/idrac_reset.py__init__zValidation.__init__   s     
))+    c                     t        | j                  | j                  t              \  }}|r| j                  j	                  |d       |S )NTmsgfailed)r   r$   r#   MANAGERS_URI	exit_json)r'   uri	error_msgs      r(   r%   zValidation.get_base_uri  s>    ?KK\3YKK!!i!=
r*   c                    | j                   j                  | j                  d      }| j                  j                  j                  d      }|j                  dd      }d}d }|d   |j                  d   v rF|d   |j                  d   |d      v r,|j                  d   |d      |d      }|d   }|}||vrd	}||fS d	}||fS )
NGETreset_to_default.   Tr   r   !ResetType@Redfish.AllowableValuesF)r#   invoke_requestr&   r$   paramsgetsplit	json_data)	r'   api_keyresr5   key_listis_validallowed_valuesreset_to_defaults_valreset_type_valuess	            r(   validate_reset_optionsz!Validation.validate_reset_options
  s    jj''u=;;--112DE==a(A;#--	22x{cmmT]F^_ghi_jFk7k$'MM)$<Xa[$I(ST+$V! 56Y Z.N'88  x'' Hx''r*   c                     | j                   j                  | j                  d      }d}||j                  d   v r|j                  d   |   }|d   }d|vrd}|S d}|S )Nr4   Tr   r8   GracefulRestartF)r#   r9   r&   r=   )r'   r>   r?   rA   rC   rD   s         r(    validate_graceful_restart_optionz+Validation.validate_graceful_restart_option  ss    jj''u=cmmI..$'MM)$<W$E! 56Y Z (99   Hr*   c                     | j                   j                  j                  d      rK| j                   j                  j                  d      dk  r"| j                   j                  t        d       y y y )Nwait_for_idracjob_wait_timeoutr   Tr,   )r$   r:   r;   r0   TIMEOUT_NEGATIVE_OR_ZERO_MSGr'   s    r(   validate_job_timeoutzValidation.validate_job_timeout&  sZ    ;;!!"238J8J8N8NOa8bfg8gKK!!&B4!P 9h3r*   c                 P   t         j                  j                  |      s1| j                  j	                  t
        j                  |      d       t        j                  |t         j                        s2| j                  j	                  t        j                  |      d       y y )N)pathTr,   )
osrP   existsr$   r0   INVALID_DIRECTORY_MSGformataccessW_OK%INSUFFICIENT_DIRECTORY_PERMISSION_MSG)r'   	file_paths     r(   validate_pathzValidation.validate_path*  sx    y)KK!!&;&B&B	&B&R[_!`yyBGG,KK!!&K&R&RXa&R&bko!p -r*   c                 j    |j                  d      s"| j                  j                  t        d       y y )Nz.xmlTr,   )endswithr$   r0   INVALID_FILE_MSG)r'   	file_names     r(   validate_file_formatzValidation.validate_file_format0  s-    ""6*KK!!&6t!D +r*   Nc                    d }t        | j                  | j                  t              }|r&|j	                  t
        i       j	                  di       }	 |r| j                  j                  |d       yy# t        $ rS}|j                  t        v r7| j                  j                  t        j                  ||      d       Y d }~y Y d }~y d }~ww xY w)NCustomDefaultsDownloadURIr4   TFr5   supported_valuesr-   skipped)r   r#   r&   OEMr;   MANUFACTURERr9   r   codeERR_STATUS_CODEr$   r0   RESET_TO_DEFAULT_ERRORrT   )r'   r5   allowed_choicesurlresperrs         r(   validate_custom_optionz!Validation.validate_custom_option4  s    tzz4==#>((<,001LbQC	\

))#u5 	\xx?*%%*@*G*GYi  }L*G  +M  W[%  \  \ +	\s   A1 1	C:ACCNN)__name__
__module____qualname__r)   r%   rE   rH   rN   rY   r^   rn    r*   r(   r!   r!      s.    ,
( 
QqE\r*   r!   c                   d    e Zd Zd Zd Zd Zd Zd ZddZd Z	d Z
d	 Zdd
Zd Zd Zd Zd Zy)FactoryResetc                    || _         || _        || _        | j                  j                  j	                  d      | _        | j                  j                  j	                  d      | _        | j                  j                  j	                  d      | _        t        | j                   | j                        | _	        | j                  j                  | _        t        | j                         | _        y )Nr5   force_resetrJ   )r#   r$   rj   r:   r;   r5   rw   rJ   r!   validate_objr&   r1   r   idrac_firmware_version)r'   r#   r$   rj   s       r(   r)   zFactoryReset.__init__D  s    
. $ 2 2 6 67I J;;--11-@"kk00445EF&tzz4;;?$$--&@&L#r*   c                 z   d\  }}| j                   j                          | j                         }|s| j                  r| j                   j	                  t
              \  }}| j                  j                  r"|s | j                  j                  t               |s;| j                  j                  t        j                  | j                        d       | j                  j                  r| j                  |       |r*| j                  r| j                  s| j                  d       dD ci c]  }|| j                   }}|j!                  | j"                  | j$                  d	        |t'        | j                                  \  }}|r(| j(                  r| j                  r| j                          ||fS c c}w )
Nro   r-   )r5   Trc   F)post_op)Defaultr   r   )CustomDefaultsNone)rx   rN   is_check_idrac_latestr5   rE   	RESET_KEYr$   
check_moder0   CHANGES_NOT_FOUNDRESET_TO_DEFAULT_ERROR_MSGrT   check_mode_outputrw   check_lcstatusreset_to_default_mappedupdatereset_custom_defaultsgraceful_restartstrrJ   )r'   msg_resjob_res	is_idrac9rB   is_valid_optionkeyreset_status_mappings           r(   executezFactoryReset.executeO  s   %..0..0	T22.2.?.?.V.VW`.a+NO{{%%o%%*;%<"%%*D*K*K]a]r]r*K*s.2 & 4;;!!""9-..t7G7G.M{|cT%A%A A||##"88))%
 	 L/D4I4I0JKM,,1F1F!  }s   ,F8c                    |rK| j                   dk(  r<t        | j                        t        k  r | j                  j                  t               | j                   r#| j                  j                  t              \  }}n| j                  j                  t              }| j                  j                  j                  d      }| j                  j                  j                  d      }|r"| j                  j                  t        d       y | j                   r5| j                   dk(  r&|s|r"| j                  j                  t        d       y | j                  j                  t               y )Nr~   r{   custom_defaults_filecustom_defaults_bufferTr-   changed)r5   r
   ry   "MINIMUM_SUPPORTED_FIRMWARE_VERSIONr$   r0   r   rx   rE   r   rH   GRACEFUL_RESTART_KEYr:   r;   CHANGES_FOUND)r'   r   rB   r   custom_default_filecustom_default_buffers         r(   r   zFactoryReset.check_mode_outputh  s!   ..2BB|TXToToGp  tV  HVKK!!&7!8  .2.?.?.V.VW`.a+NO"//PPQefO"kk00445KL $ 2 2 6 67O PKK!!mT!B""t'<'<@P'PVi  nCKK!!mT!BKK!!&7!8r*   c                 6    t        | j                        dk\  ryy )Nz3.0T)r
   ry   rM   s    r(   r   z"FactoryReset.is_check_idrac_latestx  s    334= >r*   c                     | j                   j                  j                  d      x}rK| j                   j                  j                  d      x}r#|| j                  _        || j                  _        yy y )Ndefault_usernamedefault_passwordT)r$   r:   r;   r#   usernamepassword)r'   r   r   s      r(   +update_credentials_for_post_lc_statuc_checkz8FactoryReset.update_credentials_for_post_lc_statuc_check|  sm     $ 2 2 6 67I JJJ $ 2 2 6 67I JJJ"2DJJ"2DJJ	 K Kr*   c                    | j                   t        v r|r| j                         sy i }d|d<   d}t        | j                  | j
                  d      }|j                  t        i       j                  t        i       j                  di       j                  t        i       }|rMt        | j                  |      }|j                  t        i       j                  di       j                  di       }n!| j                  j                  t        d	       |t        k  ry	 | j                  j                  d
dd      }|j                   j                  d      }	|	|d<   |j                  d      dk(  rn$t#        j$                  d       |dz   }|t        k  ry|t        k(  rW|j                  d      dk7  rB| j                  j                  t(        j+                  |j                  d      |      d	       y y y # t&        $ r\ t#        j$                  d       |dz   }|t        k(  r6| j                  j                  t(        j+                  dt              d       Y w xY w)N LCStatusr7   LinksDellLCServicez)#DellLCService.GetRemoteServicesAPIStatustargetTr,   POSTz{}F)datadumpReady
   unreachable)	lc_statusretriesr-   r   )r5   PASSWORD_CHANGE_OPTIONSr   r   r#   r1   r;   re   rf   ODATA_IDACTIONSr$   r0   UNSUPPORTED_LC_STATUS_MSGIDRAC_RESET_RETRIESr9   r=   timesleepr   LC_STATUS_MSGrT   )
r'   r|   lc_status_dictretry_countrl   rk   action_resplc_urllcstatuslcstatus_datas
             r(   r   zFactoryReset.check_lcstatus  s$     $;;??A%'z"tzz488W=hhsB##L"599/2NRRS[]_`)$**c:K __Wb1556acefjjksuwxFKK!!&?!M//L::44VV$UZ4[ ( 2 2 6 6z B-:z*!%%j1W<

2)Ao // --.2D2DZ2PT[2[KK!!m&:&:^EWEWXbEcmx&:&y  CG!  H 3\-  L

2)Ao"55KK))m.B.B]dw.B.x  GK)  L	Ls   AG1 ,G1 1A"IIc                    i }i }i |d<   d|i|d   d<   ||d   d<   d\  }}|t         v r| j                  r3| j                         \  }}}|r| j                  j	                  |d       | j                  rt
        nt        |d<   d|d<   | j                  rt
        nt        |d   d	<   d
|d   d<   d|d   d<   n*t        |d<   d|d<   t        |d   d	<   d|d   d<   d|d   d<   | j                  rd }||fS )N
idracreset
StatusCodeDataro   Tr   r-   r   Messager   StatusretValFFAILED)	STATUS_SUCCESSrJ   wait_for_port_openr$   r0   IDRAC_RESET_SUCCESS_MSGIDRAC_RESET_RESET_TRIGGER_MSGFAILED_RESET_MSGr5   )r'   statusresulttmp_restrack_failedwait_msgstatus_codes          r(   create_outputzFactoryReset.create_output  s3   !|(4f'=|V$-3|\*!+h^#""6:6M6M6O3k8KK))h)E8<8K8K4QnGEN!%GIIMI\I\.EbF< +-6F< *-1F< *-GEN!&GI.>F< +-5F< *-2F< *  Fr*   c                 N   d\  }}d }t        | j                  | j                  t              }|r6|j	                  t
        i       j	                  di       j	                  di       }| j                  j                  |d|      }|j                  }| j                  |      \  }}||fS )Nro   z#DellManager.ResetToDefaultsr   r   r   )	r   r#   r1   r   r;   re   r9   r   r   )r'   payloadr   r?   rk   rl   run_reset_statusr   s           r(   perform_operationzFactoryReset.perform_operation  s    !tzz488W=((3#''(FKOOPXZ\]C::44S&w4O!--))&1|r*   c                    d|i}| j                   j                  j                  d      }d }t        | j                  | j
                  t              }|r6|j                  t        i       j                  di       j                  di       }| j                  j                  |d|      }|j                  j                  d      x}r|j                  d      d	   }t        j                  |
      }	t        | j                  |	|d      \  }
}}}t        |d      }|
r.| j                   j                  |j                  d      |d       y y y )Nr~   rK   z#DellManager.SetCustomDefaultsr   r   r   Location/)job_idr7   )max_job_wait_secsleep_interval_secsr   )regex_patternr   T)r-   
job_statusr.   )r$   r:   r;   r   r#   r1   r   re   r9   headersr<   IDRAC_JOB_URIrT   r   r   r0   )r'   r   r   rK   rk   rl   job_respjob_tracking_urir   job_uri
job_failedr-   job_dict	wait_times                 r(   upload_cd_contentzFactoryReset.upload_cd_content  s5   #T*;;--112DEtzz488W=((3#''(H"MQQRZ\^_C::,,S&w,G ( 0 0 4 4Z @@@%++C04F#**&*9G3MdjjZa_obc4e0JXy "(-HH%%(,,y*Ah_c%d  Ar*   c                 6   | j                   j                  j                  d      }t        j                  |       t
        }|}d}d}t        |      dkD  rA	 | j                  j                  t        d       t        j                  |       t        }d}d}	 |||fS # t        $ r@}|j                  }|dk(  r%t        j                  |d	z         t        }d}Y d }~DY d }~n,d }~wt        $ r t        j                  |       ||z
  }Y nw xY wt        |      dkD  rŌ)
NrK   Ti  r   r4   Fr   i     )r$   r:   r;   r   r   RESET_UNTRACKintr#   r9   r/   r   r   rg   	Exception)r'   intervaltimeout_waitr-   waitr   r   rm   s           r(   r   zFactoryReset.wait_for_port_open  s    {{))--.@A

8$i!m'

)),>

8$-$! [#--  !hh#%JJx1}-1C#(L	 &
  '

8$h' $i!ms   ?B 	D$1C&DDc                    d| j                   i}| j                  j                  t              \  | _        }|sF| j
                  j                  t        j                  | j                   | j                        d       | j                  |      S )N	ResetTypera   Trc   )
r5   rx   rE   r   rj   r$   r0   ri   rT   r   )r'   r   r   s      r(   r   z$FactoryReset.reset_to_default_mapped  s     5 56040A0A0X0XYb0c-oKK!!&<&C&CUYUjUj  ~B  ~R  ~R&C  'S*. " 0%%g..r*   c                 j    t        |d      5 }|j                         }d d d        |S # 1 sw Y   S xY w)Nr)openread)r'   rX   filexml_contents       r(   get_xml_contentzFactoryReset.get_xml_content   s5    )S! 	&T))+K	&	&s   (2c                    | j                   j                  t              \  | _        }t	        | j
                        t        k  rF| j                  j                  t        j                  | j                  | j                        d       | j                  j                  j                  d      }| j                  j                  j                  d      }d}d }|rJ| j                   j                  |       | j                   j                  |       d}| j!                  |      }n|rd}|}|r| j#                  |       | j                   j%                  | j                  | j                         | j'                         S )Nra   Trc   r   r   F)rx   rE   r   rj   r
   ry   r   r$   r0   CUSTOM_ERRORrT   r5   r:   r;   rY   r^   r   r   rn   r   )r'   r   r   r   upload_perfomdefault_datas         r(   r   z"FactoryReset.reset_custom_defaults  sH   040A0A0X0XYb0c-o3347YYKK!!l&9&94K`K`KOK_K_ ': 'ajn " p"kk00445KL $ 2 2 6 67O P++,?@223FG M//0CDL" M0L""<0001F1FH\H\]++--r*   c                    d }t        | j                  | j                  t              }|r"|j	                  di       j	                  di       }ddi}| j                  j                  |d|      }|j                  }| j                  |      \  }}|t        v r't        |d<   | j                  rt        nt        |d   d	<   ||fS )
Nr   r   r   rG   r   r   r-   r   r   )r   r#   r1   r   r;   r9   r   r   r   r   rJ   IDRAC_RESET_RESTART_SUCCESS_MSGIDRAC_RESET_RESTART_TRIGGER_MSG)r'   rk   rl   r   r   r   r   s          r(   r   zFactoryReset.graceful_restart  s    tzz488W=((+R044XrBC 12::44S&w4O!--**62^#4GENOSObOb,K  iHDy)}r*   N)T)-   )rp   rq   rr   r)   r   r   r   r   r   r   r   r   r   r   r   r   r   rs   r*   r(   ru   ru   C  sL    	M 29 HB6	e$.6/
.,r*   ru   c            
         dg diddiddiddddd	ddd
dddidddd} t        | dgdgd      }	 t        |j                        5 }| d   d   }t        |||      }|j	                         \  }}|rX|j                  d      s#|j                  |j                  d      |d       |j                  |j                  d      |d       nU|j                  d      s"|j                  |j                  d      d       |j                  |j                  d      d       d d d        y # 1 sw Y   y xY w# t        $ r:}|j                  t        |      t        j                  |      d       Y d }~y d }~wt        $ r&}|j                  t        |      d       Y d }~y d }~wt        t        t        t        t         t"        t$        f$ r&}|j                  t        |      d       Y d }~y d }~ww xY w)Nchoices)r   r   r}   r~   typer   boolT)r  defaultr   iX  F)r  no_log)r5   r   r   rJ   rK   rw   r   r   )r   r   )r   r   )argument_specmutually_exclusiverequired_togethersupports_check_moder5   r   r-   )r-   reset_statusr.   )r-   r  r   r,   r   )r-   
error_infor.   r   )r	   r   r:   ru   r   r;   r0   r   r   jsonloadr   RuntimeErrorr   r   	TypeErrorKeyError
ValueErrorOSError)specsr$   r#   rj   	reset_objmessage_respoutputrm   s           r(   mainr  *  s   &(hi!'#)5/#)d;%*s; &59#UO%*d;	E  NOCD 	"F
4V]]+ 	Lu#$67	BO$UFODI#,#4#4#6 L&#''	2$$)9)9%)@v^b$c  \%5%5e%<6[_ `#''	2$$)9)9%)@$N  \%5%5e%<d K	L 	L 	L  OSX$))C.NN 9SX488,oy(T^`gh 4SXd334sN   D6 	CD*!D6 *D3/D6 3D6 6	G2?0E44G2 F!!+G2G--G2__main__)D
__future__r   r   r   r  __metaclass__DOCUMENTATIONEXAMPLESRETURNrQ   r  r   urllib.errorr   r   Iansible_collections.dellemc.openmanage.plugins.module_utils.idrac_redfishr   r	   #ansible.module_utils.compat.versionr
   ansible.module_utils.urlsr   r   Aansible_collections.dellemc.openmanage.plugins.module_utils.utilsr   r   r   r   r   r/   re   rf   r   r   LC_STATUS_CHECK_SLEEPr   ri   r   r   r  r   r   r  rS   r   r   rL   r\   r   rW   r   r   r   r   r   ODATA_REGEX	ATTRIBUTESUCCESS_STATUSFAILED_STATUSr   rh   r   r   r   r!   ru   r  rp   rs   r*   r(   <module>r-     s]   C BUn8t*
X 
   , y < IA A &
  E ] C 1"S ?  O "S F ; z  V g o )W %Q %. "1 *	 * "<= .	' C\ C\Ld dN#4L zF r*   