Anons79 Mini Shell

Directory : /lib/python2.7/site-packages/ansible/modules/remote_management/dellemc/
Upload File :
Current File : //lib/python2.7/site-packages/ansible/modules/remote_management/dellemc/ome_device_info.pyo

�
�Udac@`skddlmZmZmZeZidd6dgd6dd6ZdZd	Zd
Z	ddl
mZddlm
Z
dd
lmZmZddlmZmZdZdZdZdZdZiZiidd6e6idd6e6idd6e6idd6e6Zd�Zd�Zd�Zd�Zd�Zd�Z d�Z!d �Z"d!�Z#e$d"krge#�nd#S($i(tabsolute_importtdivisiontprint_functions1.1tmetadata_versiontpreviewtstatust	communitytsupported_bys1	
---
module: ome_device_info
short_description: Retrieves the information about Device.
version_added: "2.9"
description:
   - This module retrieves the list of all devices information with the exhaustive inventory of each
     device.
options:
    hostname:
        description:
            - Target IP Address or hostname.
        type: str
        required: True
    username:
        description:
            - Target username.
        type: str
        required: True
    password:
        description:
            - Target user password.
        type: str
        required: True
    port:
        description:
            - Target HTTPS port.
        type: int
        default: 443
    fact_subset:
        description:
            - C(basic_inventory) returns the list of the devices.
            - C(detailed_inventory) returns the inventory details of specified devices.
            - C(subsystem_health) returns the health status of specified devices.
        type: str
        choices: [basic_inventory, detailed_inventory, subsystem_health ]
        default: basic_inventory
    system_query_options:
        description:
            - I(system_query_options) applicable for the choices of the fact_subset. Either I(device_id) or I(device_service_tag)
              is mandatory for C(detailed_inventory) and C(subsystem_health) or both can be applicable.
        type: dict
        suboptions:
            device_id:
                 description:
                    - A list of unique identifier is applicable
                      for C(detailed_inventory) and C(subsystem_health).
                 type: list
            device_service_tag:
                 description:
                    - A list of service tags are applicable for C(detailed_inventory)
                      and C(subsystem_health).
                 type: list
            inventory_type:
                description:
                    - For C(detailed_inventory), it returns details of the specified inventory type.
                type: str
            filter:
                description:
                    - For C(basic_inventory), it filters the collection of devices.
                      I(filter) query format should be aligned with OData standards.
                type: str

requirements:
    - "python >= 2.7.5"
author: "Sajna Shetty(@Sajna-Shetty)"
s
---
- name: Retrieve basic inventory of all devices.
  ome_device_info:
    hostname: "192.168.0.1"
    username: "username"
    password: "password"

- name: Retrieve basic inventory for devices identified by IDs 33333 or 11111 using filtering.
  ome_device_info:
    hostname: "192.168.0.1"
    username: "username"
    password: "password"
    fact_subset: "basic_inventory"
    system_query_options:
      filter: "Id eq 33333 or Id eq 11111"

- name: Retrieve inventory details of specified devices identified by IDs 11111 and 22222.
  ome_device_info:
    hostname: "192.168.0.1"
    username: "username"
    password: "password"
    fact_subset: "detailed_inventory"
    system_query_options:
      device_id:
        - 11111
        - 22222

- name: Retrieve inventory details of specified devices identified by service tags MXL1234 and MXL4567.
  ome_device_info:
    hostname: "192.168.0.1"
    username: "username"
    password: "password"
    fact_subset: "detailed_inventory"
    system_query_options:
      device_service_tag:
        - MXL1234
        - MXL4567

- name: Retrieve details of specified inventory type of specified devices identified by ID and service tags.
  ome_device_info:
    hostname: "192.168.0.1"
    username: "username"
    password: "password"
    fact_subset: "detailed_inventory"
    system_query_options:
      device_id:
        - 11111
      device_service_tag:
        - MXL1234
        - MXL4567
      inventory_type: "serverDeviceCards"

- name: Retrieve subsystem health of specified devices identified by service tags.
  ome_device_info:
    hostname: "192.168.0.1"
    username: "username"
    password: "password"
    fact_subset: "subsystem_health"
    system_query_options:
      device_service_tag:
        - MXL1234
        - MXL4567

s�
---
msg:
  type: str
  description: Over all device information status.
  returned: on error
  sample: "Failed to fetch the device information"
device_info:
  type: dict
  description: Returns the information collected from the Device.
  returned: success
  sample: {
  "value": [
        {
            "Actions": null,
            "AssetTag": null,
            "ChassisServiceTag": null,
            "ConnectionState": true,
            "DeviceManagement": [
                {
                    "DnsName": "dnsname.host.com",
                    "InstrumentationName": "MX-12345",
                    "MacAddress": "11:10:11:10:11:10",
                    "ManagementId": 12345,
                    "ManagementProfile": [
                        {
                            "HasCreds": 0,
                            "ManagementId": 12345,
                            "ManagementProfileId": 12345,
                            "ManagementURL": "https://192.168.0.1:443",
                            "Status": 1000,
                            "StatusDateTime": "2019-01-21 06:30:08.501"
                        }
                    ],
                    "ManagementType": 2,
                    "NetworkAddress": "192.168.0.1"
                }
            ],
            "DeviceName": "MX-0003I",
            "DeviceServiceTag": "MXL1234",
            "DeviceSubscription": null,
            "LastInventoryTime": "2019-01-21 06:30:08.501",
            "LastStatusTime": "2019-01-21 06:30:02.492",
            "ManagedState": 3000,
            "Model": "PowerEdge MX7000",
            "PowerState": 17,
            "SlotConfiguration": {},
            "Status": 4000,
            "SystemId": 2031,
            "Type": 2000
        }
    ]
  }
(t
AnsibleModule(tRestOME(tURLErrort	HTTPError(tConnectionErrortSSLValidationErrortdetailed_inventorytsubsystem_healthtinventory_typetbasic_inventorysHTTP Error 404: Not FoundsDeviceService/Devicestresources,DeviceService/Devices({Id})/InventoryDetailss?DeviceService/Devices({Id})/InventoryDetails('{InventoryType}')s+DeviceService/Devices({Id})/SubSystemHealthc

C`s	y�ttd}|jd|�}|jr�|jd}i}x=|D]5}|d|krF|ji|d|d6�qFqFW|j�}tt|�t|��}t	jt
d�|D���nt|j��Wn+tt
ttttfk
r}	|	�nX|S(s�
    Get device ids from device service tag
    Returns :dict : device_id to service_tag map
    :arg service_tags: service tag
    :arg rest_obj: RestOME class object in case of request with session.
    :returns: dict eg: {1345:"MXL1245"}
    RtGETtvaluetDeviceServiceTagtIdcs`s|]}|tfVqdS(N(tDESC_HTTP_ERROR(t.0ttag((s]/usr/lib/python2.7/site-packages/ansible/modules/remote_management/dellemc/ome_device_info.pys	<genexpr>�s(tDEVICE_RESOURCE_COLLECTIONtDEVICE_LISTtinvoke_requesttsuccesst	json_datatupdatetvaluestlisttsettdevice_fact_error_reporttdictt
ValueErrorR
RR
Rt	TypeError(
tservice_tagstrest_objtpathtresptdevices_listtservice_tag_dicttitemtavailable_service_tagstnot_available_service_tagterr((s]/usr/lib/python2.7/site-packages/ansible/modules/remote_management/dellemc/ome_device_info.pyt _get_device_id_from_service_tags�s 	

# !
cC`s+yt|�tSWntk
r&tSXdS(s5check when device_id numeric represented value is intN(tinttTrueR%tFalse(tval((s]/usr/lib/python2.7/site-packages/ansible/modules/remote_management/dellemc/ome_device_info.pytis_ints


cC`s�|r�g|D]$}|r
t|�r
t|�^q
}tt|�t|j��@�}x9|D].}tjidj|�||6�||=q`WndS(s�If service_tag is duplicate of device_id, then updates the message as Duplicate report
    :arg1: device_id_list : list of device_id
    :arg2: service_tag_id_dict: dictionary of device_id to service tag maps"Duplicate report of device_id: {0}N(R6R2R!R"tkeysR#Rtformat(tdevice_id_listR,t	device_idtdevice_id_represents_intt
common_val((s]/usr/lib/python2.7/site-packages/ansible/modules/remote_management/dellemc/ome_device_info.pyt_check_duplicate_device_ids1"
cC`s�|jd�}i}|dk	r�|jd�}|jd�}|rttd�tt|��D��}||d<n|r�t||�}t||�||d<q�n|S(s�
    Builds the identifiers mapping
    :returns: the dict of device_id to server_tag map
     eg: {"device_id":{1234: None},"device_service_tag":{1345:"MXL1234"}}tsystem_query_optionsR:tdevice_service_tagcs`s|]}|dfVqdS(N(tNone(RR:((s]/usr/lib/python2.7/site-packages/ansible/modules/remote_management/dellemc/ome_device_info.pys	<genexpr>#sN(tgetR@R$R!R"R1R=(t
module_paramsR(tsystem_query_options_paramtdevice_id_service_tag_dictR9tdevice_service_tag_listtdevice_id_dictR,((s]/usr/lib/python2.7/site-packages/ansible/modules/remote_management/dellemc/ome_device_info.pyt_get_device_identifier_maps"
	
cC`sG|jd�}d}|rC|jd�}|rCi|d6}qCn|S(s�
    Builds query parameter
    :returns: dictionary, which is applicable builds the query format
     eg : {"$filter":"Type eq 2000"}
     R>tfilters$filterN(RAR@(RBRCtquery_parametert
filter_by_val((s]/usr/lib/python2.7/site-packages/ansible/modules/remote_management/dellemc/ome_device_info.pyt_get_query_parameters.scC`s'|d}i}|tkrd}t||�}|tkr^|jd�}|jt�}n|rjtn|}x�|j�D]�\}}	i||<xj|	j�D]\\}
}|dkr�|n|
}t|djd|
d|�}
||j	i|
|6�q�Wq}Wn|j	ittdt6�|S(s0
    Identifies the resource path by different states
    :returns: dictionary containing identifier with respective resource path
        eg:{"device_id":{1234:""DeviceService/Devices(1234)/InventoryDetails"},
        "device_service_tag":{"MXL1234":"DeviceService/Devices(1345)/InventoryDetails"}}
    tfact_subsetR>R?RRt
InventoryTypeN(
RR@RGtDEVICES_INVENTORY_DETAILSRAtDEVICES_INVENTORY_TYPEtitemsRR8R(RBR(RLt	path_dictRRDR>tpath_identifiertidentifier_typetidentifier_dictR:tservice_tagtkey_identifierR)((s]/usr/lib/python2.7/site-packages/ansible/modules/remote_management/dellemc/ome_device_info.pyt_get_resource_parameters=s$

	#c`sc|jd���dksD�dk	r_t�fd�|D��r_tdj||���ndS(s�"
     Throws error if arguments detailed_inventory, subsystem_health
     not exists with qualifier device_id or device_service_tagR>c3`s|]}�j|�VqdS(N(RA(Rt	qualifier(RC(s]/usr/lib/python2.7/site-packages/ansible/modules/remote_management/dellemc/ome_device_info.pys	<genexpr>_ss,One of the following {0} is required for {1}N(RAR@tanyR%R8(R5RBt
required_args((RCs]/usr/lib/python2.7/site-packages/ansible/modules/remote_management/dellemc/ome_device_info.pyt#_check_mutually_inclusive_argumentsYscC`s3|d}|dkr/t||ddg�ndS(svalidates input parametersRLRR:R?N(R[(RBRL((s]/usr/lib/python2.7/site-packages/ansible/modules/remote_management/dellemc/ome_device_info.pyt_validate_inputscs
c
C`s�idd6td6iidd6d6idd6d6idd6d6idd6td6d	6d
6}tdiitd6dd6d6itd6dd6d
6itd6dd6td6d6itd6dd6dd6d6itd6dd6dddgd6d6|d6ddddggdddgggdt�}y�t|j�t|jdt��C}t|j|�}g}|jd�r�t|j�}|j	d|dd|�}|j
}|j|j�n�x�|j
�D]�\}}xu|j
�D]g\}	}
y/|j	d|
�}|j
}|j|j�Wntk
r9}t|�}nX|||	<q�Wq�Wtt�r�d|krx|djt�q�t|d<nWdQXd|kr�|jd |�n|jd!d"�Wn;ttttttfk
r�}|jd!t|��nXdS(#NR$ttypetrequiredR!R:R?tstrRRHtoptionst
argument_specthostnametusernametno_logtpasswordi�tdefaultR2tportRRRtchoicesRLR>trequired_iftsupports_check_modetreq_sessionRtquery_parami�tdevice_infotmsgs&Failed to fetch the device information(R4RR3R\tparamsR	RWRARKRRtappendtstatus_codeRPRR_RYR#Rt	exit_jsont	fail_jsonR
R
RR&R%(
R>tmoduleR(tdevice_factstresp_statusRlR*RSt
path_dict_mapt
identifierR)tdataR0((s]/usr/lib/python2.7/site-packages/ansible/modules/remote_management/dellemc/ome_device_info.pytmainjsZ
	
		!t__main__N(%t
__future__RRRR]t
__metaclass__tANSIBLE_METADATAt
DOCUMENTATIONtEXAMPLEStRETURNtansible.module_utils.basicRt2ansible.module_utils.remote_management.dellemc.omeR	t+ansible.module_utils.six.moves.urllib.errorR
Rtansible.module_utils.urlsRR
RNtDEVICES_SUBSYSTEM_HEALTHRORRR#RR1R6R=RGRKRWR[R\Rzt__name__(((s]/usr/lib/python2.7/site-packages/ansible/modules/remote_management/dellemc/ome_device_info.pyt<module>sB


DB7				
				
		7

Anons79 File Manager Version 1.0, Coded By Anons79
Email: [email protected]