
    VhkW                         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g dd	d
gdgg dg ddgdZddd	dddddZd Zedk(  r e        yy)    )absolute_importdivisionprint_functiona  
module: redfish_info
short_description: Manages Out-Of-Band controllers using Redfish APIs
description:
  - Builds Redfish URIs locally and sends them to remote OOB controllers to get information back.
  - Information retrieved is placed in a location specified by the user.
extends_documentation_fragment:
  - community.general.attributes
  - community.general.attributes.info_module
  - community.general.redfish
attributes:
  check_mode:
    version_added: 3.3.0
    # This was backported to 2.5.4 and 1.3.11 as well, since this was a bugfix
options:
  category:
    required: false
    description:
      - List of categories to execute on OOB controller.
    default: ['Systems']
    type: list
    elements: str
  command:
    required: false
    description:
      - List of commands to execute on OOB controller.
    type: list
    elements: str
  baseuri:
    required: true
    description:
      - Base URI of OOB controller.
    type: str
  username:
    description:
      - Username for authenticating to OOB controller.
    type: str
  password:
    description:
      - Password for authenticating to OOB controller.
    type: str
  auth_token:
    description:
      - Security token for authenticating to OOB controller.
    type: str
    version_added: 2.3.0
  manager:
    description:
      - Name of manager on OOB controller to target.
    type: str
    version_added: '8.3.0'
  timeout:
    description:
      - Timeout in seconds for HTTP requests to OOB controller.
      - The default value for this parameter changed from V(10) to V(60) in community.general 9.0.0.
    type: int
    default: 60
  update_handle:
    required: false
    description:
      - Handle to check the status of an update in progress.
    type: str
    version_added: '6.1.0'
  ciphers:
    version_added: 9.2.0
  validate_certs:
    version_added: 10.6.0
  ca_path:
    version_added: 10.6.0

author: "Jose Delarosa (@jose-delarosa)"
at!  
- name: Get CPU inventory
  community.general.redfish_info:
    category: Systems
    command: GetCpuInventory
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"
  register: result

- name: Print fetched information
  ansible.builtin.debug:
    msg: "{{ result.redfish_facts.cpu.entries | to_nice_json }}"

- name: Get CPU model
  community.general.redfish_info:
    category: Systems
    command: GetCpuInventory
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"
  register: result

- name: Print fetched information
  ansible.builtin.debug:
    msg: "{{ result.redfish_facts.cpu.entries.0.Model }}"

- name: Get memory inventory
  community.general.redfish_info:
    category: Systems
    command: GetMemoryInventory
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"
  register: result

- name: Get fan inventory with a timeout of 20 seconds
  community.general.redfish_info:
    category: Chassis
    command: GetFanInventory
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"
    timeout: 20
  register: result

- name: Get Virtual Media information
  community.general.redfish_info:
    category: Manager
    command: GetVirtualMedia
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"
  register: result

- name: Print fetched information
  ansible.builtin.debug:
    msg: "{{ result.redfish_facts.virtual_media.entries | to_nice_json }}"

- name: Get Virtual Media information from Systems
  community.general.redfish_info:
    category: Systems
    command: GetVirtualMedia
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"
  register: result

- name: Print fetched information
  ansible.builtin.debug:
    msg: "{{ result.redfish_facts.virtual_media.entries | to_nice_json }}"

- name: Get Volume Inventory
  community.general.redfish_info:
    category: Systems
    command: GetVolumeInventory
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"
  register: result
- name: Print fetched information
  ansible.builtin.debug:
    msg: "{{ result.redfish_facts.volume.entries | to_nice_json }}"

- name: Get Session information
  community.general.redfish_info:
    category: Sessions
    command: GetSessions
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"
  register: result

- name: Print fetched information
  ansible.builtin.debug:
    msg: "{{ result.redfish_facts.session.entries | to_nice_json }}"

- name: Get default inventory information
  community.general.redfish_info:
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"
  register: result
- name: Print fetched information
  ansible.builtin.debug:
    msg: "{{ result.redfish_facts | to_nice_json }}"

- name: Get several inventories
  community.general.redfish_info:
    category: Systems
    command: GetNicInventory,GetBiosAttributes
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"

- name: Get configuration of the AccountService
  community.general.redfish_info:
    category: Accounts
    command: GetAccountServiceConfig
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"

- name: Get default system inventory and user information
  community.general.redfish_info:
    category: Systems,Accounts
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"

- name: Get default system, user and firmware information
  community.general.redfish_info:
    category: ["Systems", "Accounts", "Update"]
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"

- name: Get Manager NIC inventory information
  community.general.redfish_info:
    category: Manager
    command: GetManagerNicInventory
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"

- name: Get boot override information
  community.general.redfish_info:
    category: Systems
    command: GetBootOverride
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"

- name: Get chassis inventory
  community.general.redfish_info:
    category: Chassis
    command: GetChassisInventory
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"

- name: Get all information available in the Manager category
  community.general.redfish_info:
    category: Manager
    command: all
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"

- name: Get firmware update capability information
  community.general.redfish_info:
    category: Update
    command: GetFirmwareUpdateCapabilities
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"

- name: Get firmware inventory
  community.general.redfish_info:
    category: Update
    command: GetFirmwareInventory
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"

- name: Get service identification
  community.general.redfish_info:
    category: Manager
    command: GetServiceIdentification
    manager: "{{ manager }}"
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"

- name: Get software inventory
  community.general.redfish_info:
    category: Update
    command: GetSoftwareInventory
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"

- name: Get the status of an update operation
  community.general.redfish_info:
    category: Update
    command: GetUpdateStatus
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"
    update_handle: /redfish/v1/TaskService/TaskMonitors/735

- name: Get Manager Services
  community.general.redfish_info:
    category: Manager
    command: GetNetworkProtocols
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"

- name: Get all information available in all categories
  community.general.redfish_info:
    category: all
    command: all
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"

- name: Get system health report
  community.general.redfish_info:
    category: Systems
    command: GetHealthReport
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"

- name: Get chassis health report
  community.general.redfish_info:
    category: Chassis
    command: GetHealthReport
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"

- name: Get manager health report
  community.general.redfish_info:
    category: Manager
    command: GetHealthReport
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"

- name: Get manager Redfish Host Interface inventory
  community.general.redfish_info:
    category: Manager
    command: GetHostInterfaces
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"

- name: Get Manager Inventory
  community.general.redfish_info:
    category: Manager
    command: GetManagerInventory
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"

- name: Get HPE Thermal Config
  community.general.redfish_info:
    category: Chassis
    command: GetHPEThermalConfig
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"

- name: Get HPE Fan Percent Minimum
  community.general.redfish_info:
    category: Chassis
    command: GetHPEFanPercentMin
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"

- name: Get BIOS registry
  community.general.redfish_info:
    category: Systems
    command: GetBiosRegistries
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"

- name: Get power restore policy
  community.general.redfish_info:
    category: Systems
    command: GetPowerRestorePolicy
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"

- name: Check the availability of the service with a timeout of 5 seconds
  community.general.redfish_info:
    category: Service
    command: CheckAvailability
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"
    timeout: 5
  register: result
z~
result:
  description: Different results depending on task.
  returned: always
  type: dict
  sample: List of CPUs on system
)AnsibleModule)RedfishUtilsREDFISH_COMMON_ARGUMENT_SPEC)GetSystemInventoryGetPsuInventoryGetCpuInventoryGetMemoryInventoryGetNicInventoryGetHealthReportGetStorageControllerInventoryGetDiskInventoryGetVolumeInventoryGetBiosAttributesGetBootOrderGetBootOverrideGetVirtualMediaGetBiosRegistriesGetPowerRestorePolicy)GetFanInventoryr
   GetChassisPowerGetChassisThermalsGetChassisInventoryr   GetHPEThermalConfigGetHPEFanPercentMin	ListUsersGetAccountServiceConfigGetSessions)GetFirmwareInventoryGetFirmwareUpdateCapabilitiesGetSoftwareInventoryGetUpdateStatus)GetManagerNicInventoryr   GetLogsGetNetworkProtocolsr   GetHostInterfacesGetManagerInventoryGetServiceIdentificationCheckAvailability)SystemsChassisAccountsSessionsUpdateManagerServicer	   r   r!   r%   )r,   r-   r.   r0   r/   r1   r2   c                     i } g }t        t        dddg      t        dd      t        d      t               t        d      t        d      t        d	d
      t               t               	      }|j                  t               t        |dgdgdgd      }|j                  d   |j                  d   |j                  d   d}|j                  d   }|j                  d   }|j                  d   }d|j                  d   z   }t        ||||      }	d|j                  d   v rt        D ]  }
|j                  |
        n|j                  d   }|D ]  }g }|t        v r|j                  d   s|j                  t        |          nd|j                  d   v r<t        t        t        |               D ]  }
|j                  t        |   |
           nM|j                  d   }|D ]#  }|t        |   vs|j                  d|z         % n|j                  d|z         |dk(  r!|D ]  }|d k(  s	|	j                         | d!<    |dk(  r|	j                         }|d"   d#u r|j                  |d$          |D ]g  }|d%k(  r|	j                         | d&<   |d'k(  r|	j                         | d(<   6|d)k(  r|	j!                         | d*<   O|d+k(  r|	j#                  |      | d,<   i|d-k(  r|	j%                         | d.<   |d/k(  r|	j'                         | d0<   |d1k(  r|	j)                         | d2<   |d3k(  r|	j+                         | d4<   |d5k(  r|	j-                         | d6<   |d7k(  r|	j/                         | d8<   |d9k(  r|	j1                         | d:<   |d;k(  r|	j3                  |      | d<<   4|d=k(  r|	j5                         | d><   N|d?k(  sU|	j7                         | d@<   j |dAk(  r|	j9                         }|d"   d#u r|j                  |d$          |D ]  }|dBk(  r|	j;                         | dC<   |dDk(  r|	j=                         | dE<   5|dFk(  r|	j?                         | dG<   N|dHk(  r|	jA                         | dI<   g|dJk(  r|	jC                         | dK<   |d9k(  r|	jE                         | d:<   |dLk(  r|	jG                         | dM<   |dNk(  s|	jI                         | dO<    |dPk(  rg|	jK                         }|d"   d#u r|j                  |d$          |D ]4  }|dQk(  r|	jM                         | dR<   |dSk(  s"|	jO                         | dT<   6 |dUk(  r|	jQ                         }|d"   d#u r|j                  |d$          |D ]g  }|dVk(  r|	jS                         | dW<   |dXk(  r|	jU                         | dY<   5|dZk(  r|	jW                         | d[<   N|d\k(  sT|	jY                  |      | d]<   i |d^k(  rN|	j[                         }|d"   d#u r|j                  |d$          |D ]  }|d_k(  s	|	j]                         | d`<    |dak(  s|	j_                         }|d"   d#u r|j                  |d$          |D ]  }|dbk(  r|	j#                  |      | dc<   |d;k(  r|	j3                  |      | d<<   7|ddk(  r|	ja                         | de<   P|dfk(  r|	jc                         | dg<   i|d9k(  r|	je                         | d:<   |dhk(  r|	jg                         | di<   |djk(  r|	ji                         | d<   |dkk(  s|	jk                  |      | dl<     |jm                  | m       y )nNliststrr,   )typeelementsdefault)r6   r7   T)required)no_logint<   )r6   r8   )	categorycommandbaseuriusernamepassword
auth_tokentimeoutupdate_handlemanager)r@   rA   )r@   rB   )required_togetherrequired_one_ofmutually_exclusivesupports_check_moder@   rA   rB   )userpswdtokenrC   rD   rE   zhttps://r?   allr=   r>   zInvalid Command: %s)msgzInvalid Category: %sr2   r+   serviceretFrN   r	   systemr   cpur   memoryr   nicr   storage_controllerr   diskr   volumer   bios_attributer   
boot_orderr   boot_overrider   health_reportr   virtual_mediar   bios_registriesr   power_restore_policyr-   r   fanr
   psur   thermalsr   chassis_powerr   chassisr   hpe_thermal_configr   hpe_fan_percent_minr.   r   rJ   r   accountservice_configr0   r!   firmwarer#   softwarer"   firmware_update_capabilitiesr$   update_statusr/   r    sessionr1   r%   manager_nicsr&   logr'   network_protocolsr(   host_interfacesr)   r*   
service_id)redfish_facts)7dictupdater   r   paramsr   CATEGORY_COMMANDS_ALLappendCATEGORY_COMMANDS_DEFAULTrangelen	fail_jsoncheck_service_availability_find_systems_resourceget_multi_system_inventoryget_multi_cpu_inventoryget_multi_memory_inventoryget_multi_nic_inventory&get_multi_storage_controller_inventoryget_multi_disk_inventoryget_multi_volume_inventoryget_multi_bios_attributesget_multi_boot_orderget_multi_boot_overrideget_multi_system_health_reportget_multi_virtualmediaget_bios_registriesget_multi_power_restore_policy_find_chassis_resourceget_fan_inventoryget_psu_inventoryget_chassis_thermalsget_chassis_powerget_chassis_inventoryget_multi_chassis_health_reportget_hpe_thermal_configget_hpe_fan_percent_min_find_accountservice_resource
list_usersget_accountservice_properties_find_updateservice_resourceget_firmware_inventoryget_software_inventory get_firmware_update_capabilitiesget_update_status_find_sessionservice_resourceget_sessions_find_managers_resourceget_logsget_network_protocolsget_multi_manager_health_reportget_hostinterfacesget_multi_manager_inventoryget_service_identification	exit_json)resultcategory_listargument_specmodulecredsrC   rD   rE   root_urirf_utilsentryr=   command_listcmdr>   resources                   r/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/general/plugins/modules/redfish_info.pymainr     sj   FM6EI;G&51d#T"t$%,f
M 56$
 '
 '
 !F ]]:.]]:.mmL13E
 mmI&G MM/2M mmI&G FMM)44HE8Wf=H j))* 	(E  '	( j1! UX,,==+##$=h$GH&--	22"3'<X'F#GH PE ''(=h(G(NOP  &}}Y7' JC"7"AA((-BS-H(IJ !7(!BC y ' N11(0(K(K(MF9%N "668H%'  Xe_ 5' _22'/'J'J'LF8$ 11$,$D$D$FF5M 44'/'J'J'LF8$ 11$,$D$DX$NF5M ??3;3b3b3dF/0 22%-%F%F%HF6N 44'/'J'J'LF8$ 33/7/Q/Q/SF+,.+3+H+H+JF<( 11.6.N.N.PF?+ 11.6.U.U.WF?+ 11.6.M.Mh.WF?+ 33080L0L0NF,- 775=5\5\5^F129_< "668H%'  Xe_ 5' W//$,$>$>$@F5M 11$,$>$>$@F5M 44)1)F)F)HF:& 11.6.H.H.JF?+ 55(0(F(F(HF9% 11.6.V.V.XF?+ 553;3R3R3TF/0 554<4T4T4VF01!W$ #==?H%'  Xe_ 5' _k)%-%8%8%:F6N 996>6\6\6^F23	_ !<<>H%'  Xe_ 5' X44)1)H)H)JF:& 66)1)H)H)JF:& ??=E=f=f=hF9: 11.6.H.H.WF?+X #==?H%'  Xe_ 5' @m+(0(=(=(?F9%@ "779H%'  Xe_ 5' X66-5-M-Mh-WF>* 11.6.M.Mh.WF?+	)$,$5$5$7F5M 552:2P2P2RF./ 11.6.V.V.XF?+ 33080K0K0MF,- 55(0(L(L(NF9% ::+3+N+Nw+WF<(!XKUXp 6*    __main__N)
__future__r   r   r   r6   __metaclass__DOCUMENTATIONEXAMPLESRETURNansible.module_utils.basicr   Hansible_collections.community.general.plugins.module_utils.redfish_utilsr   r   ru   rw   r   __name__ r   r   <module>r      s    A @GRtl	
 5 )
~78"k#$ $ $ $'" O+d zF r   