
    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 d dlmZ d dlmZ d	d
giZd Zedk(  r e        yy)    )absolute_importdivisionprint_functiona  
module: ocapi_info
version_added: 6.3.0
short_description: Manages Out-Of-Band controllers using Open Composable API (OCAPI)
description:
  - Builds OCAPI URIs locally and sends them to remote OOB controllers to get information back.
extends_documentation_fragment:
  - community.general.attributes
  - community.general.attributes.info_module
options:
  category:
    required: true
    description:
      - Category to execute on OOB controller.
    type: str
  command:
    required: true
    description:
      - Command to execute on OOB controller.
    type: str
  baseuri:
    required: true
    description:
      - Base URI of OOB controller.
    type: str
  proxy_slot_number:
    description: For proxied inband requests, the slot number of the IOM. Only applies if O(baseuri) is a proxy server.
    type: int
  username:
    required: true
    description:
      - Username for authenticating to OOB controller.
    type: str
  password:
    required: true
    description:
      - Password for authenticating to OOB controller.
    type: str
  timeout:
    description:
      - Timeout in seconds for URL requests to OOB controller.
    default: 10
    type: int
  job_name:
    description:
      - Name of job for fetching status.
    type: str


author: "Mike Moerk (@mikemoerk)"
z
- name: Get job status
  community.general.ocapi_info:
    category: Status
    command: JobStatus
    baseuri: "http://iom1.wdc.com"
    jobName: FirmwareUpdate
    username: "{{ username }}"
    password: "{{ password }}"
a  
msg:
  description: Message with action result or error description.
  returned: always
  type: str
  sample: "Action was successful"

percentComplete:
  description: Percent complete of the relevant operation. Applies to O(command=JobStatus).
  returned: when supported
  type: int
  sample: 99

operationStatus:
  description: Status of the relevant operation. Applies to O(command=JobStatus). See OCAPI documentation for details.
  returned: when supported
  type: str
  sample: "Activate needed"

operationStatusId:
  description: Integer value of status (corresponds to operationStatus). Applies to O(command=JobStatus). See OCAPI documentation
    for details.
  returned: when supported
  type: int
  sample: 65540

operationHealth:
  description: Health of the operation. Applies to O(command=JobStatus). See OCAPI documentation for details.
  returned: when supported
  type: str
  sample: "OK"

operationHealthId:
  description: >-
    Integer value for health of the operation (corresponds to RV(operationHealth)). Applies to O(command=JobStatus). See OCAPI
    documentation for details.
  returned: when supported
  type: str
  sample: "OK"

details:
  description: Details of the relevant operation. Applies to O(command=JobStatus).
  returned: when supported
  type: list
  elements: str

status:
  description: Dictionary containing status information. See OCAPI documentation for details.
  returned: when supported
  type: dict
  sample:
    {
      "Details": [
        "None"
      ],
      "Health": [
        {
          "ID": 5,
          "Name": "OK"
        }
      ],
      "State": {
        "ID": 16,
        "Name": "In service"
      }
    }
)AnsibleModule)
OcapiUtils)	to_native)urljoinJobs	JobStatusc                  
   i } t        t        t        d      t        dd      t        d      t        dd      t        d      t        d      t        dd      t        dd	      
      d      }|j                  d   }|j                  d   }|j                  d   |j                  d   d}|j                  d   }d|j                  d   z   }|j                  j                  d      }t	        |||||      }|t
        vr<|j                  t        d|dt        t
        j                                            |t
        |   vr(|j                  t        d|dt
        |                |dk(  rh|dk(  rc|j                  j                  d      |j                  t        d             t        |d|j                  d   z         }	|j                  |	      } | d   d u r|j                  t        | d!                y | d= d }
| j                  d"t                     }|
||j                  sd#n| j                  d!d$      d%}| D cg c]	  }||vs| }}|D ]
  }| |   ||<     |j                  d&i | y c c}w )'NT)requiredstr)r   type)r   int)r   no_log
   )r   default)categorycommandjob_namebaseuriproxy_slot_numberusernamepasswordtimeout)argument_specsupports_check_moder   r   r   r   )userpswdr   zhttps://r   r   zInvalid Category 'z'. Valid Categories = )msgzInvalid Command 'z'. Valid Commands = r
   r   r   z(job_name required for JobStatus command.zJobs/retFr    sessionzAction was successful.z"No action performed in check mode.)changedr"   r     )r   dictparamsgetr   CATEGORY_COMMANDS_ALL	fail_jsonr   listkeysr	   get_job_status
check_mode	exit_json)resultmoduler   r   credsr   base_urir   ocapi_utilsjob_urir#   r"   kwargs
result_keyresult_keyss                  p/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/community/general/plugins/modules/ocapi_info.pymainr9      s   F4($U3u%$U3".4(45eR0	
 !F }}Z(HmmI&G j)j)E mmI&GFMM)44H))*=>UH.?&QK ,,YYacgh}  iC  iC  iE  dF  (G  H  	I +H55YV]_tu}_~'  A  	B 6k!}}  ,4  Y>&@  Ah&--
2K(KLG //8Fe}Yve}565M**Y/393D3D+&**;K
 5;WjjPV>VzWW% 	4J!'
!3F:	4"6" Xs   	J J __main__N)
__future__r   r   r   r   __metaclass__DOCUMENTATIONEXAMPLESRETURNansible.module_utils.basicr   Fansible_collections.community.general.plugins.module_utils.ocapi_utilsr   +ansible.module_utils.common.text.convertersr   +ansible.module_utils.six.moves.urllib.parser	   r(   r9   __name__r$       r8   <module>rF      se    A @2h	B
H 5 ] A ? [M 
A#H zF rE   