
    Vh.                         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 d dlmZ g dg d	g d
g dg dg ddZd Zedk(  r e        yy)    )absolute_importdivisionprint_functiona#  
module: redfish_command
short_description: Manages Out-Of-Band controllers using Redfish APIs
description:
  - Builds Redfish URIs locally and sends them to remote OOB controllers to perform an action.
  - Manages OOB controller ex. reboot, log management.
  - Manages OOB controller users ex. add, remove, update.
  - Manages system power ex. on, off, graceful and forced reboot.
extends_documentation_fragment:
  - community.general.attributes
  - community.general.redfish
attributes:
  check_mode:
    support: none
  diff_mode:
    support: none
options:
  category:
    required: true
    description:
      - Category to execute on OOB controller.
    type: str
  command:
    required: true
    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
  session_uri:
    description:
      - URI of the session resource.
    type: str
    version_added: 2.3.0
  id:
    required: false
    aliases: [account_id]
    description:
      - ID of account to delete/modify.
      - Can also be used in account creation to work around vendor issues where the ID of the new user is required in the
        POST request.
    type: str
  new_username:
    required: false
    aliases: [account_username]
    description:
      - Username of account to add/delete/modify.
    type: str
  new_password:
    required: false
    aliases: [account_password]
    description:
      - New password of account to add/modify.
    type: str
  roleid:
    required: false
    aliases: [account_roleid]
    description:
      - Role of account to add/modify.
    type: str
  account_types:
    required: false
    aliases: [account_accounttypes]
    description:
      - Array of account types to apply to a user account.
    type: list
    elements: str
    version_added: '7.2.0'
  oem_account_types:
    required: false
    aliases: [account_oemaccounttypes]
    description:
      - Array of OEM account types to apply to a user account.
    type: list
    elements: str
    version_added: '7.2.0'
  bootdevice:
    required: false
    description:
      - Boot device when setting boot configuration.
    type: str
  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
  boot_override_mode:
    description:
      - Boot mode when using an override.
    type: str
    choices: [Legacy, UEFI]
    version_added: 3.5.0
  uefi_target:
    required: false
    description:
      - UEFI boot target when bootdevice is "UefiTarget".
    type: str
  boot_next:
    required: false
    description:
      - BootNext target when bootdevice is "UefiBootNext".
    type: str
  update_username:
    required: false
    aliases: [account_updatename]
    description:
      - New user name for updating account_username.
    type: str
    version_added: '0.2.0'
  account_properties:
    required: false
    description:
      - Properties of account service to update.
    type: dict
    default: {}
    version_added: '0.2.0'
  resource_id:
    required: false
    description:
      - ID of the System, Manager or Chassis to modify.
    type: str
    version_added: '0.2.0'
  update_image_uri:
    required: false
    description:
      - URI of the image for the update.
    type: str
    version_added: '0.2.0'
  update_image_file:
    required: false
    description:
      - Filename, with optional path, of the image for the update.
    type: path
    version_added: '7.1.0'
  update_protocol:
    required: false
    description:
      - Protocol for the update.
    type: str
    version_added: '0.2.0'
  update_targets:
    required: false
    description:
      - List of target resource URIs to apply the update to.
    type: list
    elements: str
    default: []
    version_added: '0.2.0'
  update_creds:
    required: false
    description:
      - Credentials for retrieving the update image.
    type: dict
    version_added: '0.2.0'
    suboptions:
      username:
        required: false
        description:
          - Username for retrieving the update image.
        type: str
      password:
        required: false
        description:
          - Password for retrieving the update image.
        type: str
  update_apply_time:
    required: false
    description:
      - Time when to apply the update.
    type: str
    choices:
      - Immediate
      - OnReset
      - AtMaintenanceWindowStart
      - InMaintenanceWindowOnReset
      - OnStartUpdateRequest
    version_added: '6.1.0'
  update_oem_params:
    required: false
    description:
      - Properties for HTTP Multipart Push Updates.
    type: dict
    version_added: '7.5.0'
  update_handle:
    required: false
    description:
      - Handle to check the status of an update in progress.
    type: str
    version_added: '6.1.0'
  update_custom_oem_header:
    required: false
    description:
      - Optional OEM header, sent as separate form-data for the Multipart HTTP push update.
      - The header shall start with "Oem" according to DMTF Redfish spec 12.6.2.2.
      - For more details, see U(https://www.dmtf.org/sites/default/files/standards/documents/DSP0266_1.21.0.html).
      - If set, then O(update_custom_oem_params) is required too.
    type: str
    version_added: '10.1.0'
  update_custom_oem_params:
    required: false
    description:
      - Custom OEM properties for HTTP Multipart Push updates.
      - If set, then O(update_custom_oem_header) is required too.
      - The properties will be passed raw without any validation or conversion by Ansible. This means the content can be a
        file, a string, or any other data. If the content is a dict that should be converted to JSON, then the content must
        be converted to JSON before passing it to this module using the P(ansible.builtin.to_json#filter) filter.
    type: raw
    version_added: '10.1.0'
  update_custom_oem_mime_type:
    required: false
    description:
      - MIME Type for custom OEM properties for HTTP Multipart Push updates.
    type: str
    version_added: '10.1.0'
  virtual_media:
    required: false
    description:
      - Options for VirtualMedia commands.
    type: dict
    version_added: '0.2.0'
    suboptions:
      media_types:
        required: false
        description:
          - List of media types appropriate for the image.
        type: list
        elements: str
        default: []
      image_url:
        required: false
        description:
          - URL of the image to insert or eject.
        type: str
      inserted:
        required: false
        description:
          - Indicates that the image is treated as inserted on command completion.
        type: bool
        default: true
      write_protected:
        required: false
        description:
          - Indicates that the media is treated as write-protected.
        type: bool
        default: true
      username:
        required: false
        description:
          - Username for accessing the image URL.
        type: str
      password:
        required: false
        description:
          - Password for accessing the image URL.
        type: str
      transfer_protocol_type:
        required: false
        description:
          - Network protocol to use with the image.
        type: str
      transfer_method:
        required: false
        description:
          - Transfer method to use with the image.
        type: str
  strip_etag_quotes:
    description:
      - Removes surrounding quotes of etag used in C(If-Match) header of C(PATCH) requests.
      - Only use this option to resolve bad vendor implementation where C(If-Match) only matches the unquoted etag string.
    type: bool
    default: false
    version_added: 3.7.0
  bios_attributes:
    required: false
    description:
      - BIOS attributes that needs to be verified in the given server.
    type: dict
    version_added: 6.4.0
  reset_to_defaults_mode:
    description:
      - Mode to apply when reseting to default.
    type: str
    choices: [ResetAll, PreserveNetworkAndUsers, PreserveNetwork]
    version_added: 8.6.0
  wait:
    required: false
    description:
      - Block until the service is ready again.
    type: bool
    default: false
    version_added: 9.1.0
  wait_timeout:
    required: false
    description:
      - How long to block until the service is ready again before giving up.
    type: int
    default: 120
    version_added: 9.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)"
  - "T S Kushal (@TSKushal)"
a5  
- name: Restart system power gracefully
  community.general.redfish_command:
    category: Systems
    command: PowerGracefulRestart
    resource_id: 437XR1138R2
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"

- name: Turn system power off
  community.general.redfish_command:
    category: Systems
    command: PowerForceOff
    resource_id: 437XR1138R2

- name: Restart system power forcefully
  community.general.redfish_command:
    category: Systems
    command: PowerForceRestart
    resource_id: 437XR1138R2

- name: Shutdown system power gracefully
  community.general.redfish_command:
    category: Systems
    command: PowerGracefulShutdown
    resource_id: 437XR1138R2

- name: Turn system power on
  community.general.redfish_command:
    category: Systems
    command: PowerOn
    resource_id: 437XR1138R2

- name: Reboot system power
  community.general.redfish_command:
    category: Systems
    command: PowerReboot
    resource_id: 437XR1138R2

- name: Set one-time boot device to {{ bootdevice }}
  community.general.redfish_command:
    category: Systems
    command: SetOneTimeBoot
    resource_id: 437XR1138R2
    bootdevice: "{{ bootdevice }}"
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"

- name: Set one-time boot device to UefiTarget of "/0x31/0x33/0x01/0x01"
  community.general.redfish_command:
    category: Systems
    command: SetOneTimeBoot
    resource_id: 437XR1138R2
    bootdevice: "UefiTarget"
    uefi_target: "/0x31/0x33/0x01/0x01"
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"

- name: Set one-time boot device to BootNext target of "Boot0001"
  community.general.redfish_command:
    category: Systems
    command: SetOneTimeBoot
    resource_id: 437XR1138R2
    bootdevice: "UefiBootNext"
    boot_next: "Boot0001"
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"

- name: Set persistent boot device override
  community.general.redfish_command:
    category: Systems
    command: EnableContinuousBootOverride
    resource_id: 437XR1138R2
    bootdevice: "{{ bootdevice }}"
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"

- name: Set one-time boot to BiosSetup
  community.general.redfish_command:
    category: Systems
    command: SetOneTimeBoot
    boot_next: BiosSetup
    boot_override_mode: Legacy
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"

- name: Disable persistent boot device override
  community.general.redfish_command:
    category: Systems
    command: DisableBootOverride

- name: Set system indicator LED to blink using security token for auth
  community.general.redfish_command:
    category: Systems
    command: IndicatorLedBlink
    resource_id: 437XR1138R2
    baseuri: "{{ baseuri }}"
    auth_token: "{{ result.session.token }}"

- name: Add user
  community.general.redfish_command:
    category: Accounts
    command: AddUser
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"
    new_username: "{{ new_username }}"
    new_password: "{{ new_password }}"
    roleid: "{{ roleid }}"

- name: Add user with specified account types
  community.general.redfish_command:
    category: Accounts
    command: AddUser
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"
    new_username: "{{ new_username }}"
    new_password: "{{ new_password }}"
    roleid: "{{ roleid }}"
    account_types:
      - Redfish
      - WebUI

- name: Add user using new option aliases
  community.general.redfish_command:
    category: Accounts
    command: AddUser
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"
    account_username: "{{ account_username }}"
    account_password: "{{ account_password }}"
    account_roleid: "{{ account_roleid }}"

- name: Delete user
  community.general.redfish_command:
    category: Accounts
    command: DeleteUser
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"
    account_username: "{{ account_username }}"

- name: Disable user
  community.general.redfish_command:
    category: Accounts
    command: DisableUser
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"
    account_username: "{{ account_username }}"

- name: Enable user
  community.general.redfish_command:
    category: Accounts
    command: EnableUser
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"
    account_username: "{{ account_username }}"

- name: Add and enable user
  community.general.redfish_command:
    category: Accounts
    command: AddUser,EnableUser
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"
    new_username: "{{ new_username }}"
    new_password: "{{ new_password }}"
    roleid: "{{ roleid }}"

- name: Update user password
  community.general.redfish_command:
    category: Accounts
    command: UpdateUserPassword
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"
    account_username: "{{ account_username }}"
    account_password: "{{ account_password }}"

- name: Update user role
  community.general.redfish_command:
    category: Accounts
    command: UpdateUserRole
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"
    account_username: "{{ account_username }}"
    roleid: "{{ roleid }}"

- name: Update user name
  community.general.redfish_command:
    category: Accounts
    command: UpdateUserName
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"
    account_username: "{{ account_username }}"
    account_updatename: "{{ account_updatename }}"

- name: Update user name
  community.general.redfish_command:
    category: Accounts
    command: UpdateUserName
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"
    account_username: "{{ account_username }}"
    update_username: "{{ update_username }}"

- name: Update AccountService properties
  community.general.redfish_command:
    category: Accounts
    command: UpdateAccountServiceProperties
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"
    account_properties:
      AccountLockoutThreshold: 5
      AccountLockoutDuration: 600

- name: Update user AccountTypes
  community.general.redfish_command:
    category: Accounts
    command: UpdateUserAccountTypes
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"
    account_username: "{{ account_username }}"
    account_types:
      - Redfish
      - WebUI

- name: Clear Manager Logs with a timeout of 20 seconds
  community.general.redfish_command:
    category: Manager
    command: ClearLogs
    resource_id: BMC
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"
    timeout: 20

- name: Create session
  community.general.redfish_command:
    category: Sessions
    command: CreateSession
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"
  register: result

- name: Set chassis indicator LED to blink using security token for auth
  community.general.redfish_command:
    category: Chassis
    command: IndicatorLedBlink
    resource_id: 1U
    baseuri: "{{ baseuri }}"
    auth_token: "{{ result.session.token }}"

- name: Delete session using security token created by CreateSesssion above
  community.general.redfish_command:
    category: Sessions
    command: DeleteSession
    baseuri: "{{ baseuri }}"
    auth_token: "{{ result.session.token }}"
    session_uri: "{{ result.session.uri }}"

- name: Clear Sessions
  community.general.redfish_command:
    category: Sessions
    command: ClearSessions
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"

- name: Simple update
  community.general.redfish_command:
    category: Update
    command: SimpleUpdate
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"
    update_image_uri: https://example.com/myupdate.img

- name: Simple update with additional options
  community.general.redfish_command:
    category: Update
    command: SimpleUpdate
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"
    update_image_uri: //example.com/myupdate.img
    update_protocol: FTP
    update_targets:
      - /redfish/v1/UpdateService/FirmwareInventory/BMC
    update_creds:
      username: operator
      password: supersecretpwd

- name: Multipart HTTP push update; timeout is 600 seconds to allow for a large image transfer
  community.general.redfish_command:
    category: Update
    command: MultipartHTTPPushUpdate
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"
    timeout: 600
    update_image_file: ~/images/myupdate.img

- name: Multipart HTTP push with additional options; timeout is 600 seconds to allow for a large image transfer
  community.general.redfish_command:
    category: Update
    command: MultipartHTTPPushUpdate
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"
    timeout: 600
    update_image_file: ~/images/myupdate.img
    update_targets:
      - /redfish/v1/UpdateService/FirmwareInventory/BMC
    update_oem_params:
      PreserveConfiguration: false

- name: Multipart HTTP push with custom OEM options
  vars:
    oem_payload:
      ImageType: BMC
  community.general.redfish_command:
    category: Update
    command: MultipartHTTPPushUpdate
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"
    update_image_file: ~/images/myupdate.img
    update_targets:
      - /redfish/v1/UpdateService/FirmwareInventory/BMC
    update_custom_oem_header: OemParameters
    update_custom_oem_mime_type: "application/json"
    update_custom_oem_params: "{{ oem_payload | to_json }}"

- name: Perform requested operations to continue the update
  community.general.redfish_command:
    category: Update
    command: PerformRequestedOperations
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"
    update_handle: /redfish/v1/TaskService/TaskMonitors/735

- name: Insert Virtual Media
  community.general.redfish_command:
    category: Systems
    command: VirtualMediaInsert
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"
    virtual_media:
      image_url: 'http://example.com/images/SomeLinux-current.iso'
      media_types:
        - CD
        - DVD
    resource_id: 1

- name: Insert Virtual Media
  community.general.redfish_command:
    category: Manager
    command: VirtualMediaInsert
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"
    virtual_media:
      image_url: 'http://example.com/images/SomeLinux-current.iso'
      media_types:
        - CD
        - DVD
    resource_id: BMC

- name: Eject Virtual Media
  community.general.redfish_command:
    category: Systems
    command: VirtualMediaEject
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"
    virtual_media:
      image_url: 'http://example.com/images/SomeLinux-current.iso'
    resource_id: 1

- name: Eject Virtual Media
  community.general.redfish_command:
    category: Manager
    command: VirtualMediaEject
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"
    virtual_media:
      image_url: 'http://example.com/images/SomeLinux-current.iso'
    resource_id: BMC

- name: Restart manager power gracefully
  community.general.redfish_command:
    category: Manager
    command: GracefulRestart
    resource_id: BMC
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"

- name: Restart manager power gracefully and wait for it to be available
  community.general.redfish_command:
    category: Manager
    command: GracefulRestart
    resource_id: BMC
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"
    wait: true

- name: Restart manager power gracefully
  community.general.redfish_command:
    category: Manager
    command: PowerGracefulRestart
    resource_id: BMC

- name: Turn manager power off
  community.general.redfish_command:
    category: Manager
    command: PowerForceOff
    resource_id: BMC

- name: Restart manager power forcefully
  community.general.redfish_command:
    category: Manager
    command: PowerForceRestart
    resource_id: BMC

- name: Shutdown manager power gracefully
  community.general.redfish_command:
    category: Manager
    command: PowerGracefulShutdown
    resource_id: BMC

- name: Turn manager power on
  community.general.redfish_command:
    category: Manager
    command: PowerOn
    resource_id: BMC

- name: Reboot manager power
  community.general.redfish_command:
    category: Manager
    command: PowerReboot
    resource_id: BMC

- name: Factory reset manager to defaults
  community.general.redfish_command:
    category: Manager
    command: ResetToDefaults
    resource_id: BMC
    reset_to_defaults_mode: ResetAll

- name: Verify BIOS attributes
  community.general.redfish_command:
    category: Systems
    command: VerifyBiosAttributes
    baseuri: "{{ baseuri }}"
    username: "{{ username }}"
    password: "{{ password }}"
    bios_attributes:
      SubNumaClustering: "Disabled"
      WorkloadProfile: "Virtualization-MaxPerformance"
a  
msg:
  description: Message with action result or error description.
  returned: always
  type: str
  sample: "Action was successful"
return_values:
  description: Dictionary containing command-specific response data from the action.
  returned: on success
  type: dict
  version_added: 6.1.0
  sample: {
    "update_status": {
      "handle": "/redfish/v1/TaskService/TaskMonitors/735",
      "messages": [],
      "resets_requested": [],
      "ret": true,
      "status": "New"
    }
  }
)AnsibleModule)RedfishUtilsREDFISH_COMMON_ARGUMENT_SPEC)	to_native)PowerOnPowerForceOffPowerForceRestartPowerGracefulRestartPowerGracefulShutdownPowerReboot
PowerCyclePowerFullPowerCycleSetOneTimeBootEnableContinuousBootOverrideDisableBootOverrideIndicatorLedOnIndicatorLedOffIndicatorLedBlinkVirtualMediaInsertVirtualMediaEjectVerifyBiosAttributesr   r   r   	AddUser
EnableUser
DeleteUserDisableUserUpdateUserRoleUpdateUserPasswordUpdateUserNameUpdateUserAccountTypesUpdateAccountServiceProperties)ClearSessionsCreateSessionDeleteSession)GracefulRestart	ClearLogsr   ResetToDefaultsr   r
   r   r   r   r   r   )SimpleUpdateMultipartHTTPPushUpdatePerformRequestedOperations)SystemsChassisAccountsSessionsManagerUpdatec                     i } i }t        di dt        d      dt        ddd      dt        d      d	t               d
t        d      dt        d      dt               dt        dg      dt        dg      dt        dgd      dt        dg      dt        dddg      dt        dddg      dt        ddg      d t        d!i "      d#t               d$t        d%d&"      d't               d(t               d)t        d*d+g,      d-t               d.t               d/t        d01      d2t               d3t        ddg 4      d5t        d!1      d6t        d1      d7t        d1      d8t        d91      d:t        d!t        t               t        d      ;      <      d=t        g d>,      d?t               d@t        d!t        t        ddg 4      t               t        dAd"      t        dAd"      t               t        d      t               t               B      <      dCt        dAdD"      dEt        g dF,      dGt        d!1      dHt        dAdD"      dIt        d%dJ"      }|j                  t               t        |d;dKgdLgdLgdDM      }|j                  d   }|j                  d   }|j                  d	   |j                  d
   |j                  d   dN}|j                  d   |j                  d   |j                  d   |j                  d   |j                  d   |j                  d   |j                  d   |j                  d    d dO	}|j                  d$   }|j                  d-   }	|j                  d.   |j                  d/   |j                  d2   |j                  d3   |j                  d:   |j                  d=   |j                  d5   |j                  d6   |j                  d8   |j                  d7   |j                  d?   dP}
|j                  d#   |j                  d'   |j                  d(   |j                  d)   dQ}|j                  d@   }|j                  dC   }|j                  dG   }dR|j                  d   z   }t        |||||	d|S      }|t        vr<|j                  t        dT|dUt        t        j                                     V       |D ]6  }|t        |   vs|j                  t        dW|dXt        |         V       8 |dYk(  r|j                  |j                  |j                  |j                  |j                  |j                   |j"                  |j$                  |j&                  dZ	}|j)                         } | d[   dDu rb|j+                  |       |d\<   t-        |      d]k(  r |d^   d_k(  r|d\   r|j!                  |      } n|j                  t        | d`         V       n|D ]  } ||   |      }  n|dak(  r|j/                         } | d[   dDu r|j                  t        | d`         V       |D ]  }|j1                  db      r|j3                  |      } &|dck(  rdd|de<   |j5                  |      } B|dfk(  rdg|de<   |j5                  |      } ^|dhk(  rdi|de<   |j5                  |      } z|j1                  dj      r|j7                  |      } |dkk(  r|j9                  ||      } |dlk(  r|j;                  ||      } |dmk(  s|j=                  |      }  n|dnk(  r|j?                         } | d[   dDu r|j                  t        | d`         V       g do}tA        |D cg c]  }||v  c}      }|d]kD  rdDdpdq} n5|D ]  }||v s|jC                  |      }  n|drk(  r|jE                         }|d[   dDu r|j                  |d`   V       |D ]R  }|dsk(  r|jG                         } |dtk(  r|jI                         } /|duk(  s5|jK                  |j                  d         } T n|dvk(  r|jM                         } | d[   dDu r|j                  t        | d`         V       |D ]  }|dwk(  rdx}|j1                  db      r.|jO                  ||j                  dH   |j                  dI         } I|dyk(  r|jQ                         } _|dkk(  r|j9                  ||      } w|dlk(  r|j;                  ||      } |dzk(  s|jS                  |j                  dE         }  n|d{k(  r|jU                         }|d[   dDu r|j                  |d`   V       |D ]d  }|d|k(  r|jW                  |
      } d}| v s| d}   |d}<   '|d~k(  r|jY                  |
      } d}| v sB| d}   |d}<   K|dk(  sQ|j[                  |
d?         } f | d[   du rE| d[= | j]                  dd      }| j]                  dt                     }|j_                  ||d|       y |j                  t        | d`         V       y c c}w )NcategoryT)requiredcommandliststr)r7   typeelementsbaseuriusernamepassword)no_log
auth_tokensession_uriid
account_id)aliasesnew_usernameaccount_usernamenew_passwordaccount_password)rE   r@   roleidaccount_roleidaccount_typesaccount_accounttypes)r;   r<   rE   oem_account_typesaccount_oemaccounttypesupdate_usernameaccount_updatename)r;   rE   account_propertiesdict)r;   default
bootdevicetimeoutint<   uefi_target	boot_nextboot_override_modeLegacyUEFI)choicesresource_idupdate_image_uriupdate_image_filepath)r;   update_protocolupdate_targets)r;   r<   rT   update_oem_paramsupdate_custom_oem_headerupdate_custom_oem_mime_typeupdate_custom_oem_paramsrawupdate_creds)r>   r?   )r;   optionsupdate_apply_time)	ImmediateOnResetAtMaintenanceWindowStartInMaintenanceWindowOnResetOnStartUpdateRequestupdate_handlevirtual_mediabool)media_types	image_urlinsertedwrite_protectedr>   r?   transfer_protocol_typetransfer_methodstrip_etag_quotesFreset_to_defaults_mode)ResetAllPreserveNetworkAndUsersPreserveNetworkbios_attributeswaitwait_timeoutx   )rf   rh   )r>   rA   )required_togetherrequired_one_ofmutually_exclusivesupports_check_mode)userpswdtoken)	rD   rG   rI   rK   rM   rO   rQ   rR   account_passwordchangerequired)r`   ra   rc   rd   rj   rl   re   rf   rh   rg   rr   )rU   rY   rZ   r[   zhttps://)r_   data_modificationr{   zInvalid Category 'z'. Valid Categories = )msgzInvalid Command 'z'. Valid Commands = r1   r   retr      r   r"   r   r/   Powerr   Onceoverride_enabledr   
Continuousr   DisabledIndicatorLedr   r   r   r0   r   z7Only one IndicatorLed command should be sent at a time.)r   r   r2   r&   r'   r(   r3   r)   r   r*   r+   r4   r,   update_statusr-   r.   changedsessionzAction was successful)r   r   r   return_values )0rS   updater   r   paramsr   CATEGORY_COMMANDS_ALL	fail_jsonr	   r9   keysadd_userenable_userdelete_userdisable_userupdate_user_roleupdate_user_passwordupdate_user_nameupdate_user_accounttypes update_accountservice_properties_find_accountservice_resourcecheck_password_change_requiredlen_find_systems_resource
startswithmanage_system_powerset_boot_overridemanage_system_indicator_ledvirtual_media_insertvirtual_media_ejectverify_bios_attributes_find_chassis_resourcesummanage_chassis_indicator_led_find_sessionservice_resourceclear_sessionscreate_sessiondelete_session_find_managers_resourcemanage_manager_power
clear_logsmanager_reset_to_defaults_find_updateservice_resourcesimple_updatemultipath_http_push_update#perform_requested_update_operationsget	exit_json)resultr   argument_specmoduler6   command_listcredsr   rV   r_   update_opts	boot_optsrs   r{   r   root_urirf_utilscmdACCOUNTS_COMMANDSr8   led_commandsnum_led_commandsresourcer   r   s                            u/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/general/plugins/modules/redfish_command.pymainr   e  s   FM :t$:d%@: d#: 	:
 T": t$: F: ': #5"67: #5"6tD: -./: AW@XY: FUE^D_`: %2F1GH:  VR8:  6!:" %,#:$ F%:& &':(  6(:;):* F+:, -:. F+/:0 1:2 %D3:4 F+5:6 "&5!17:8 %)e$49:: "&5!1;:< T*
=:J  (^ _K:N fO:P  fubI&648 $&$ ?T*'+v $	
Q:j FE:k:l  $,fgm:n &)o:p vu-q:r uc2s:Mv 56$D

 '
 '
 "F }}Z(H==+L ]]:.]]:.mmL13E mmD)"MM.9"MM.9 --1 &o >#)==1D#E$mm,=>$mm,@A*.
D mmI&G --.K #MM*<=#]]+>?!==):; --(89n5#]]+>?#]]+>?$*MM2L$M$*MM2L$M'-}}5R'S7K  mmL1}}]3]];/$mm,@A	I MM/2M &9: mm$56O FMM)44HE8Wf(3t_prH ,,YYacgh}  iC  iC  iE  dF  (G  H  	I  B+H55Z]_tu}_~+  "A  BB :((".."..#00&77"*"?"?&77&.&G&G.6.W.W

 779%=E! 6>5\5\]c5dD12< A%,q/=Q*QVZ[{V|!66t<  Yve}%= >' :3*73D9: 
Y	002%=E!6%=!9:# 	JG!!'*!55g>,,06	,-!33I>::0<	,-!33I>110:	,-!33I>##N3!==gF00!66}hO//!55mXN22!88I'	J* 
Y	002%=E!6%=!9:Q |TG< 7TUa"+deF' Ll*%BB7KFL 
Z	99;E?e#%1# 	OG/)!002O+!002O+!00}1MN	O 
Y	113%=E!6%=!9:# 	eG ++0!!'*!66wf@UW]WdWdesWtuK'!,,.00!66}hO//!55mXN--!;;FMMJb<cd	e" 
X	88:E?e#%1# 
	dG.(!//<"f,5;O5LM/255!<<[I"f,5;O5LM/288!EEkRaFbc
	d e}5M**Y-**Y/'4'4 	 	6 	Yve}56Q  Us   i__main__N)
__future__r   r   r   r;   __metaclass__DOCUMENTATIONEXAMPLESRETURNansible.module_utils.basicr   Hansible_collections.community.general.plugins.module_utils.redfish_utilsr   r   +ansible.module_utils.common.text.convertersr	   r   r   __name__r       r   <module>r      s}    A @FP
aF
, 5  A
=
 JM DP X &_7D	 zF r   