
    Vh                     x    d dl mZmZmZ eZddgddZdZdZdZ	d d	l
mZ d d
lmZmZ d Zd Zedk(  r e        yy)    )absolute_importdivisionprint_functionz1.1preview	community)metadata_versionstatussupported_bya  
---
module: intersight_info
short_description: Gather information about Intersight
description:
- Gathers information about servers in L(Cisco Intersight,https://intersight.com).
- This module was called C(intersight_facts) before Ansible 2.9. The usage did not change.
extends_documentation_fragment: intersight
options:
  server_names:
    description:
    - Server names to retrieve information from.
    - An empty list will return all servers.
    type: list
    elements: str
author:
- David Soper (@dsoper2)
- CiscoUcs (@CiscoUcs)
a|  
- name: Get info for all servers
  intersight_info:
    api_private_key: ~/Downloads/SecretKey.txt
    api_key_id: 64612d300d0982/64612d300d0b00/64612d300d3650
    server_names:
- debug:
    msg: "server name {{ item.Name }}, moid {{ item.Moid }}"
  loop: "{{ intersight_servers }}"
  when: intersight_servers is defined

- name: Get info for servers by name
  intersight_info:
    api_private_key: ~/Downloads/SecretKey.txt
    api_key_id: 64612d300d0982/64612d300d0b00/64612d300d3650
    server_names:
      - SJC18-L14-UCS1-1
- debug:
    msg: "server moid {{ intersight_servers[0].Moid }}"
  when: intersight_servers[0] is defined
a  
intersight_servers:
  description: A list of Intersight Servers.  See L(Cisco Intersight,https://intersight.com/apidocs) for details.
  returned: always
  type: complex
  contains:
    Name:
      description: The name of the server.
      returned: always
      type: str
      sample: SJC18-L14-UCS1-1
    Moid:
      description: The unique identifier of this Managed Object instance.
      returned: always
      type: str
      sample: 5978bea36ad4b000018d63dc
)AnsibleModule)IntersightModuleintersight_argument_specc                     g }| j                   d   r(| j                   d   D ]  }|j                  d|z          dj                  |      }dd|ddd} |j                  d
i |}|j	                  d	      S )Nserver_nameszName eq '%s'z or getz/compute/PhysicalSummariesi  )z$filterz$top)http_methodresource_pathquery_paramsResults )paramsappendjoincall_apir   )module
intersight
query_listserver	query_stroptionsresponse_dicts          t/home/dcms/DCMS/lib/python3.12/site-packages/ansible_collections/cisco/intersight/plugins/modules/intersight_info.pyget_serversr"   M   s    J}}^$mmN3 	7Fnv56	7J'I5 
G (J''2'2MY''    c                      t        j                         } | j                  t        dd             t	        | d      }t        |      }|j                  t        ||             y )Nliststr)typeelements)r   T)supports_check_mode)intersight_servers)r   copyupdatedictr   r   	exit_jsonr"   )argument_specr   r   s      r!   mainr0   `   se    ,113Mv6    F
 "&)J FJ(GHr#   __main__N)
__future__r   r   r   r'   __metaclass__ANSIBLE_METADATADOCUMENTATIONEXAMPLESRETURNansible.module_utils.basicr   Dansible_collections.cisco.intersight.plugins.module_utils.intersightr   r   r"   r0   __name__r   r#   r!   <module>r;      sb    A @(-(k$/1 (,
$ 5 {(&I" zF r#   