�
�Udac @` s� d d l m Z m Z m Z e Z i d d 6d g d 6d d 6Z d Z d Z d
Z d d l
Z
d d l m Z m
Z
d d
l m Z d d l m Z d � Z d � Z d � Z d � Z d � Z e d k r� e � n d S( i ( t absolute_importt divisiont print_functions 1.1t metadata_versiont previewt statust communityt supported_bys�
---
module: intersight_rest_api
short_description: REST API configuration for Cisco Intersight
description:
- Direct REST API configuration for Cisco Intersight.
- All REST API resources and properties must be specified.
- For more information see L(Cisco Intersight,https://intersight.com/apidocs).
extends_documentation_fragment: intersight
options:
resource_path:
description:
- Resource URI being configured related to api_uri.
type: str
required: yes
query_params:
description:
- Query parameters for the Intersight API query language.
type: dict
update_method:
description:
- The HTTP method used for update operations.
- Some Intersight resources require POST operations for modifications.
type: str
choices: [ patch, post ]
default: patch
api_body:
description:
- The payload for API requests used to modify resources.
type: dict
state:
description:
- If C(present), will verify the resource is present and will create if needed.
- If C(absent), will verify the resource is absent and will delete if needed.
choices: [present, absent]
default: present
author:
- David Soper (@dsoper2)
- CiscoUcs (@CiscoUcs)
version_added: '2.8'
so
- name: Configure Boot Policy
intersight_rest_api:
api_private_key: "{{ api_private_key }}"
api_key_id: "{{ api_key_id }}"
api_key_uri: "{{ api_key_uri }}"
validate_certs: "{{ validate_certs }}"
resource_path: /boot/PrecisionPolicies
query_params:
$filter: "Name eq 'vmedia-localdisk'"
api_body: {
"Name": "vmedia-hdd",
"ConfiguredBootMode": "Legacy",
"BootDevices": [
{
"ObjectType": "boot.VirtualMedia",
"Enabled": true,
"Name": "remote-vmedia",
"Subtype": "cimc-mapped-dvd"
},
{
"ObjectType": "boot.LocalDisk",
"Enabled": true,
"Name": "localdisk",
"Slot": "MRAID",
"Bootloader": null
}
],
}
state: present
- name: Delete Boot Policy
intersight_rest_api:
api_private_key: "{{ api_private_key }}"
api_key_id: "{{ api_key_id }}"
api_key_uri: "{{ api_key_uri }}"
validate_certs: "{{ validate_certs }}"
resource_path: /boot/PrecisionPolicies
query_params:
$filter: "Name eq 'vmedia-localdisk'"
state: absent
s�
api_repsonse:
description: The API response output returned by the specified resource.
returned: always
type: dict
sample:
"api_response": {
"BootDevices": [
{
"Enabled": true,
"Name": "remote-vmedia",
"ObjectType": "boot.VirtualMedia",
"Subtype": "cimc-mapped-dvd"
},
{
"Bootloader": null,
"Enabled": true,
"Name": "boot-lun",
"ObjectType": "boot.LocalDisk",
"Slot": "MRAID"
}
],
"ConfiguredBootMode": "Legacy",
"Name": "vmedia-localdisk",
"ObjectType": "boot.PrecisionPolicy",
}
N( t IntersightModulet intersight_argument_spec( t
AnsibleModule( t iteritemsc C` sb i d d 6| j j d d 6| j j d d 6} | j | � } | j d � r^ | d d } n | S( s9
GET a resource and return the 1st element found
t gett http_methodt
resource_patht query_paramst Resultsi ( t modulet paramst call_apiR ( t
intersightt optionst
response_dict( ( sd /usr/lib/python2.7/site-packages/ansible/modules/remote_management/intersight/intersight_rest_api.pyt get_resource� s c C` s� y` xU t | � D]G \ } } t j d | � s | | k r@ q n t | | | � s t Sq Wt SWn. t t f k
r� | r� | | k r� t St SXd S( Ns P(ass)?w(or)?d( R t ret searcht compare_valuest Falset Truet AttributeErrort TypeError( t expectedt actualt keyt value( ( sd /usr/lib/python2.7/site-packages/ansible/modules/remote_management/intersight/intersight_rest_api.pyR � s c C` s | j j s� | r� i | j j d d 6| j j d d 6| j j d d 6| d 6} | j | � } | j d � r� | d d | j d <q� q� i d
d 6| j j d d 6| j j d d 6} | j | � } d | k r� t | � } n | | j d <n t | j d <d S(
Nt
update_methodR
R t api_bodyt bodyt moidR i t api_responset postt Moidt changed( R t
check_modeR R R t resultR R ( R R&