| 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_flow_control_policy_info |
| 16 |
short_description: Gather information about Flow Control Policies in Cisco Intersight |
| 17 |
description: |
| 18 |
- Gather information about Flow Control 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 Flow Control Policies will be returned. |
| 21 |
extends_documentation_fragment: intersight |
| 22 |
options: |
| 23 |
organization: |
| 24 |
description: |
| 25 |
- The name of the organization the Flow Control Policy belongs to. |
| 26 |
type: str |
| 27 |
name: |
| 28 |
description: |
| 29 |
- The name of the Flow Control Policy to gather information from. |
| 30 |
type: str |
| 31 |
author: |
| 32 |
- Ron Gershburg (@rgershbu) |
| 33 |
''' |
| 34 |
|
| 35 |
EXAMPLES = r''' |
| 36 |
- name: Fetch a specific Flow Control Policy by name |
| 37 |
cisco.intersight.intersight_flow_control_policy_info: |
| 38 |
api_private_key: "{{ api_private_key }}" |
| 39 |
api_key_id: "{{ api_key_id }}" |
| 40 |
name: "FlowControl-Auto-Policy" |
| 41 |
|
| 42 |
- name: Fetch all Flow Control Policies in a specific Organization |
| 43 |
cisco.intersight.intersight_flow_control_policy_info: |
| 44 |
api_private_key: "{{ api_private_key }}" |
| 45 |
api_key_id: "{{ api_key_id }}" |
| 46 |
organization: "org_test" |
| 47 |
|
| 48 |
- name: Fetch all Flow Control Policies |
| 49 |
cisco.intersight.intersight_flow_control_policy_info: |
| 50 |
api_private_key: "{{ api_private_key }}" |
| 51 |
api_key_id: "{{ api_key_id }}" |
| 52 |
''' |
| 53 |
|
| 54 |
RETURN = r''' |
| 55 |
api_response: |
| 56 |
description: The API response output returned by the specified resource. |
| 57 |
returned: always |
| 58 |
type: dict |
| 59 |
sample: |
| 60 |
"api_response": [ |
| 61 |
{ |
| 62 |
"Name": "FlowControl-Auto-Policy", |
| 63 |
"ObjectType": "fabric.FlowControlPolicy", |
| 64 |
"PriorityFlowControlMode": "auto", |
| 65 |
"ReceiveDirection": "Enabled", |
| 66 |
"SendDirection": "Enabled", |
| 67 |
"Tags": [ |
| 68 |
{ |
| 69 |
"Key": "Site", |
| 70 |
"Value": "DataCenter-A" |
| 71 |
} |
| 72 |
] |
| 73 |
}, |
| 74 |
{ |
| 75 |
"Name": "FlowControl-LinkLevel-Policy", |
| 76 |
"ObjectType": "fabric.FlowControlPolicy", |
| 77 |
"PriorityFlowControlMode": "off", |
| 78 |
"ReceiveDirection": "Enabled", |
| 79 |
"SendDirection": "Enabled", |
| 80 |
"Tags": [ |
| 81 |
{ |
| 82 |
"Key": "Environment", |
| 83 |
"Value": "Production" |
| 84 |
} |
| 85 |
] |
| 86 |
} |
| 87 |
] |
| 88 |
''' |
| 89 |
|
| 90 |
from ansible.module_utils.basic import AnsibleModule |
| 91 |
from ansible_collections.cisco.intersight.plugins.module_utils.intersight import IntersightModule, intersight_argument_spec |
| 92 |
|
| 93 |
|
| 94 |
def main(): |
| 95 |
argument_spec = intersight_argument_spec.copy() |
| 96 |
argument_spec.update( |
| 97 |
organization=dict(type='str'), |
| 98 |
name=dict(type='str') |
| 99 |
) |
| 100 |
module = AnsibleModule( |
| 101 |
argument_spec, |
| 102 |
supports_check_mode=True, |
| 103 |
) |
| 104 |
|
| 105 |
intersight = IntersightModule(module) |
| 106 |
intersight.result['api_response'] = {} |
| 107 |
intersight.result['trace_id'] = '' |
| 108 |
|
| 109 |
# Resource path used to fetch info |
| 110 |
resource_path = '/fabric/FlowControlPolicies' |
| 111 |
|
| 112 |
query_params = intersight.set_query_params() |
| 113 |
|
| 114 |
intersight.get_resource( |
| 115 |
resource_path=resource_path, |
| 116 |
query_params=query_params, |
| 117 |
return_list=True |
| 118 |
) |
| 119 |
|
| 120 |
module.exit_json(**intersight.result) |
| 121 |
|
| 122 |
|
| 123 |
if __name__ == '__main__': |
| 124 |
main() |