
    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
mZmZ d dlm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 d Zd Zedk(  r e        yy# e$ r Y w xY w)    )absolute_importdivisionprint_functionaV  
---
module: idrac_syslog
short_description: Enable or disable the syslog on iDRAC
version_added: "2.1.0"
deprecated:
  removed_at_date: "2027-05-27"
  why: Replaced with M(dellemc.openmanage.idrac_attributes).
  alternative: Use M(dellemc.openmanage.idrac_attributes) instead.
  removed_from_collection: dellemc.openmanage
description:
  - This module allows to enable or disable the iDRAC syslog.
extends_documentation_fragment:
  - dellemc.openmanage.idrac_auth_options
  - dellemc.openmanage.network_share_options
options:
  syslog:
    description: Enables or disables an iDRAC syslog.
    choices: [Enabled, Disabled]
    type: str
    default: Enabled
requirements:
  - "omsdk >= 1.2.488"
  - "python >= 3.9.6"
author:
  - "Felix Stephen (@felixs88)"
  - "Anooja Vardhineni (@anooja-vardhineni)"
  - "Abhishek Sinha (@ABHISHEK-SINHA10)"
notes:
    - This module requires 'Administrator' privilege for I(idrac_user).
    - 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).
a  
---
- name: Enable iDRAC syslog
  dellemc.openmanage.idrac_syslog:
       idrac_ip: "192.168.0.1"
       idrac_user: "user_name"
       idrac_password: "user_password"
       ca_path: "/path/to/ca_cert.pem"
       share_name: "192.168.0.2:/share"
       share_password: "share_user_pwd"
       share_user: "share_user_name"
       share_mnt: "/mnt/share"
       syslog: "Enabled"

- name: Disable iDRAC syslog
  dellemc.openmanage.idrac_syslog:
       idrac_ip: "192.168.0.1"
       idrac_user: "user_name"
       idrac_password: "user_password"
       ca_path: "/path/to/ca_cert.pem"
       share_name: "192.168.0.2:/share"
       share_password: "share_user_pwd"
       share_user: "share_user_name"
       share_mnt: "/mnt/share"
       syslog: "Disabled"
a  
---
msg:
  description: Overall status of the syslog export operation.
  returned: always
  type: str
  sample: "Successfully fetch the syslogs."
syslog_status:
    description: Job details of the syslog operation.
    returned: success
    type: dict
    sample: {
        "@odata.context": "/redfish/v1/$metadata#DellJob.DellJob",
        "@odata.id": "/redfish/v1/Managers/iDRAC.Embedded.1/Jobs/JID_852940632485",
        "@odata.type": "#DellJob.v1_0_2.DellJob",
        "CompletionTime": "2020-03-27T02:27:45",
        "Description": "Job Instance",
        "EndTime": null,
        "Id": "JID_852940632485",
        "JobState": "Completed",
        "JobType": "ImportConfiguration",
        "Message": "Successfully imported and applied Server Configuration Profile.",
        "MessageArgs": [],
        "MessageArgs@odata.count": 0,
        "MessageId": "SYS053",
        "Name": "Import Configuration",
        "PercentComplete": 100,
        "StartTime": "TIME_NOW",
        "Status": "Success",
        "TargetSettingsURI": null,
        "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)iDRACConnectionidrac_auth_params)AnsibleModule)URLError	HTTPError)ConnectionErrorSSLValidationError)file_share_manager)UserCredentialsc           
         d| _         t        j                  |j                  d   |j                  d   dt	        |j                  d   |j                  d               }|j
                  s|j                  d       | j                  j                  |       |j                  ry|j                  d	   d
k(  r| j                  j                  d       n.|j                  d	   dk(  r| j                  j                  d       | j                  j                         }|S |j                  d	   d
k(  r| j                  j                         }|S |j                  d	   dk(  r| j                  j                         }S )NT
share_name	share_mnt
share_usershare_password)
share_pathmount_pointisFoldercredspUnable to access the share. Ensure that the share name, share mount, and share credentials provided are correct.msgsyslogEnabledF)apply_changesDisabled)use_redfishr   create_share_objparamsr   IsValid	fail_json
config_mgrset_liason_share
check_modeenable_syslogdisable_syslogis_change_applicable)idracmodule	upd_sharer   s       s/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/dellemc/openmanage/plugins/modules/idrac_syslog.pyrun_setup_idrac_syslogr.      s\   E"33v}}\?Z@Fk@Z=A:I8>l8S8>FV8W;YZI  X 	Y	%%i0=="i/***?]]8$
2++%+@335 J	 =="i/""002C J ]]8$
2""113CJ    c            	      P   dddddddddgddddddddgdd	d
} | j                  t               t        | d      }	 t        |j                        5 }t        ||      }d}|j                  d      dk(  rd}|j                  d      dk(  rd}d d d        |j                  d       y # 1 sw Y   xY w# t        $ r9}|j                  t        |      t        j                  |             Y d }~^d }~wt        $ r&}|j                  t        |      d       Y d }~d }~wt        $ r)}dt        |      v r|j                  d       Y d }~d }~wt        t         t"        t$        t&        t(        t*        f$ r&}|j                  t        |             Y d }~d }~ww xY w)NTstr)requiredtypeF	share_pwd)r2   r3   aliasesno_logr   r   )r2   choicesdefault)r   r   r   r   r   )argument_specsupports_check_modeStatusSuccessMessagezNo changes found to commit!)r   
error_info)r   unreachableNoneTyper   r   zSuccessfully fetch the syslogs.)r   syslog_statuschanged)updater   r   r   r!   r.   getr
   r#   r1   jsonloadr	   	exit_jsonAttributeErrorRuntimeErrorr   r   KeyErrorImportError
ValueError	TypeError)specsr+   r*   r   rB   erres          r-   mainrQ      s   #'7#(%8',eaef"'7$)Z1HU^_E 
LL"# "F%V]]+ 	$u(7CGwwx I-779%)FF#G	$$ :#&  9%	$ 	$  BSX$))C.AA 9SX488 ]S! "\ ],oxY0 %SV$$%sT   B: ;B.B: .B73B: :	F%/C77F%D$$F%0E+F%?F  F%__main__)
__future__r   r   r   r3   __metaclass__DOCUMENTATIONEXAMPLESRETURNrE   Iansible_collections.dellemc.openmanage.plugins.module_utils.dellemc_idracr   r   ansible.module_utils.basicr   +ansible.module_utils.six.moves.urllib.errorr	   r
   ansible.module_utils.urlsr   r   omsdk.sdkfiler   omsdk.sdkcredsr   rK   r.   rQ   __name__ r/   r-   <module>r`      sz    C B!F64
n  x 4 K I	0.
4!9H zF E  		s   A AA