| 1 |
#!/usr/bin/python |
| 2 |
# -*- coding: utf-8 -*- |
| 3 |
|
| 4 |
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt) |
| 5 |
|
| 6 |
from __future__ import absolute_import, division, print_function |
| 7 |
__metaclass__ = type |
| 8 |
|
| 9 |
ANSIBLE_METADATA = {'metadata_version': '1.1', |
| 10 |
'status': ['preview'], |
| 11 |
'supported_by': 'community'} |
| 12 |
|
| 13 |
DOCUMENTATION = r''' |
| 14 |
--- |
| 15 |
module: intersight_memory_persistent_policy_info |
| 16 |
short_description: Gather information about Memory Persistent Policies in Cisco Intersight |
| 17 |
description: |
| 18 |
- Gather information about Memory Persistent Policies in L(Cisco Intersight,https://intersight.com). |
| 19 |
- Information can be filtered by O(organization) and O(name). |
| 20 |
- If no filters are passed, all Memory Persistent Policies will be returned. |
| 21 |
- For more information see L(Cisco Intersight,https://intersight.com/apidocs/memory/PersistentMemoryPolicy/get/). |
| 22 |
extends_documentation_fragment: intersight |
| 23 |
options: |
| 24 |
organization: |
| 25 |
description: |
| 26 |
- The name of the organization the Memory Persistent Policy belongs to. |
| 27 |
type: str |
| 28 |
name: |
| 29 |
description: |
| 30 |
- The name of the Memory Persistent Policy to gather information from. |
| 31 |
type: str |
| 32 |
author: |
| 33 |
- Ron Gershburg (@rgershbu) |
| 34 |
''' |
| 35 |
|
| 36 |
EXAMPLES = r''' |
| 37 |
- name: Fetch a specific Memory Persistent Policy by name |
| 38 |
cisco.intersight.intersight_memory_persistent_policy_info: |
| 39 |
api_private_key: "{{ api_private_key }}" |
| 40 |
api_key_id: "{{ api_key_id }}" |
| 41 |
name: "pmem-policy-01" |
| 42 |
|
| 43 |
- name: Fetch all Memory Persistent Policies in a specific Organization |
| 44 |
cisco.intersight.intersight_memory_persistent_policy_info: |
| 45 |
api_private_key: "{{ api_private_key }}" |
| 46 |
api_key_id: "{{ api_key_id }}" |
| 47 |
organization: "default" |
| 48 |
|
| 49 |
- name: Fetch all Memory Persistent Policies |
| 50 |
cisco.intersight.intersight_memory_persistent_policy_info: |
| 51 |
api_private_key: "{{ api_private_key }}" |
| 52 |
api_key_id: "{{ api_key_id }}" |
| 53 |
''' |
| 54 |
|
| 55 |
RETURN = r''' |
| 56 |
api_response: |
| 57 |
description: The API response output returned by the specified resource. |
| 58 |
returned: always |
| 59 |
type: dict |
| 60 |
sample: |
| 61 |
"api_response": [ |
| 62 |
{ |
| 63 |
"Name": "pmem-policy-01", |
| 64 |
"ObjectType": "memory.PersistentMemoryPolicy", |
| 65 |
"ManagementMode": "configured-from-intersight", |
| 66 |
"LocalSecurity": { |
| 67 |
"Enabled": true |
| 68 |
}, |
| 69 |
"Goals": [ |
| 70 |
{ |
| 71 |
"MemoryModePercentage": 0, |
| 72 |
"PersistentMemoryType": "app-direct", |
| 73 |
"SocketId": "All Sockets" |
| 74 |
} |
| 75 |
], |
| 76 |
"RetainNamespaces": true, |
| 77 |
"LogicalNamespaces": [ |
| 78 |
{ |
| 79 |
"Name": "ns1", |
| 80 |
"SocketId": 1, |
| 81 |
"Capacity": 100000, |
| 82 |
"Mode": "raw" |
| 83 |
} |
| 84 |
] |
| 85 |
}, |
| 86 |
{ |
| 87 |
"Name": "pmem-policy-os-managed", |
| 88 |
"ObjectType": "memory.PersistentMemoryPolicy", |
| 89 |
"ManagementMode": "configured-from-operating-system" |
| 90 |
} |
| 91 |
] |
| 92 |
''' |
| 93 |
|
| 94 |
|
| 95 |
from ansible.module_utils.basic import AnsibleModule |
| 96 |
from ansible_collections.cisco.intersight.plugins.module_utils.intersight import IntersightModule, intersight_argument_spec |
| 97 |
|
| 98 |
|
| 99 |
def main(): |
| 100 |
argument_spec = intersight_argument_spec.copy() |
| 101 |
argument_spec.update( |
| 102 |
organization=dict(type='str'), |
| 103 |
name=dict(type='str') |
| 104 |
) |
| 105 |
module = AnsibleModule( |
| 106 |
argument_spec, |
| 107 |
supports_check_mode=True, |
| 108 |
) |
| 109 |
|
| 110 |
intersight = IntersightModule(module) |
| 111 |
intersight.result['api_response'] = {} |
| 112 |
intersight.result['trace_id'] = '' |
| 113 |
|
| 114 |
# Resource path used to fetch info |
| 115 |
resource_path = '/memory/PersistentMemoryPolicies' |
| 116 |
|
| 117 |
query_params = intersight.set_query_params() |
| 118 |
|
| 119 |
intersight.get_resource( |
| 120 |
resource_path=resource_path, |
| 121 |
query_params=query_params, |
| 122 |
return_list=True |
| 123 |
) |
| 124 |
|
| 125 |
module.exit_json(**intersight.result) |
| 126 |
|
| 127 |
|
| 128 |
if __name__ == '__main__': |
| 129 |
main() |