| 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_server_pool_qualification_policy_info |
| 16 |
short_description: Gather information about Server Pool Qualification Policies in Cisco Intersight |
| 17 |
description: |
| 18 |
- Gather information about Server Pool Qualification 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 Server Pool Qualification Policies will be returned. |
| 21 |
- Server Pool Qualification Policies define conditions to qualify servers for resource pools based on hardware and configuration attributes. |
| 22 |
extends_documentation_fragment: intersight |
| 23 |
options: |
| 24 |
organization: |
| 25 |
description: |
| 26 |
- The name of the organization the Server Pool Qualification Policy belongs to. |
| 27 |
type: str |
| 28 |
name: |
| 29 |
description: |
| 30 |
- The name of the Server Pool Qualification Policy to gather information from. |
| 31 |
type: str |
| 32 |
author: |
| 33 |
- Ron Gershburg (@rgershbu) |
| 34 |
''' |
| 35 |
|
| 36 |
EXAMPLES = r''' |
| 37 |
- name: Fetch a specific Server Pool Qualification Policy by name |
| 38 |
cisco.intersight.intersight_server_pool_qualification_policy_info: |
| 39 |
api_private_key: "{{ api_private_key }}" |
| 40 |
api_key_id: "{{ api_key_id }}" |
| 41 |
name: "ServerPool-Qual-Policy-01" |
| 42 |
|
| 43 |
- name: Fetch all Server Pool Qualification Policies in a specific Organization |
| 44 |
cisco.intersight.intersight_server_pool_qualification_policy_info: |
| 45 |
api_private_key: "{{ api_private_key }}" |
| 46 |
api_key_id: "{{ api_key_id }}" |
| 47 |
organization: "Production" |
| 48 |
|
| 49 |
- name: Fetch all Server Pool Qualification Policies |
| 50 |
cisco.intersight.intersight_server_pool_qualification_policy_info: |
| 51 |
api_private_key: "{{ api_private_key }}" |
| 52 |
api_key_id: "{{ api_key_id }}" |
| 53 |
|
| 54 |
- name: Register Server Pool Qualification Policy info and display |
| 55 |
cisco.intersight.intersight_server_pool_qualification_policy_info: |
| 56 |
api_private_key: "{{ api_private_key }}" |
| 57 |
api_key_id: "{{ api_key_id }}" |
| 58 |
name: "ServerPool-Comprehensive-Policy" |
| 59 |
register: policy_info |
| 60 |
|
| 61 |
- name: Display the policy qualifiers |
| 62 |
ansible.builtin.debug: |
| 63 |
var: policy_info.api_response[0].Qualifiers |
| 64 |
''' |
| 65 |
|
| 66 |
RETURN = r''' |
| 67 |
api_response: |
| 68 |
description: The API response output returned by the specified resource. |
| 69 |
returned: always |
| 70 |
type: dict |
| 71 |
sample: |
| 72 |
"api_response": [ |
| 73 |
{ |
| 74 |
"Name": "ServerPool-Qual-Policy-01", |
| 75 |
"ObjectType": "resourcepool.QualificationPolicy", |
| 76 |
"Organization": { |
| 77 |
"Moid": "675450ee69726530014753e2", |
| 78 |
"ObjectType": "organization.Organization" |
| 79 |
}, |
| 80 |
"Qualifiers": [ |
| 81 |
{ |
| 82 |
"FabricInterConnectPids": ["UCS-FI-6454", "UCS-FI-64108"], |
| 83 |
"DomainNames": ["AC08-6454"], |
| 84 |
"ObjectType": "resource.DomainQualifier" |
| 85 |
}, |
| 86 |
{ |
| 87 |
"RackIdRange": [{"MinValue": 2, "MaxValue": 4}], |
| 88 |
"Pids": ["UCSC-C245-M8SX", "UCSC-C220-M8S"], |
| 89 |
"AssetTags": ["production"], |
| 90 |
"ObjectType": "resource.RackServerQualifier" |
| 91 |
}, |
| 92 |
{ |
| 93 |
"MemoryCapacityRange": {"MinValue": 64, "MaxValue": 512}, |
| 94 |
"ObjectType": "resource.MemoryQualifier" |
| 95 |
}, |
| 96 |
{ |
| 97 |
"GpuEvaluationType": "ServerWithoutGpu", |
| 98 |
"ObjectType": "resource.GpuQualifier" |
| 99 |
}, |
| 100 |
{ |
| 101 |
"CpuCoresRange": {"MinValue": 16, "MaxValue": 64}, |
| 102 |
"Vendor": "Intel(R) Corporation", |
| 103 |
"ObjectType": "resource.ProcessorQualifier" |
| 104 |
} |
| 105 |
] |
| 106 |
}, |
| 107 |
{ |
| 108 |
"Name": "ServerPool-GPU-Policy", |
| 109 |
"ObjectType": "resourcepool.QualificationPolicy", |
| 110 |
"Description": "Policy for servers with NVIDIA GPUs", |
| 111 |
"Qualifiers": [ |
| 112 |
{ |
| 113 |
"GpuEvaluationType": "ServerWithGpu", |
| 114 |
"GpuCountRange": {"MinValue": 2, "MaxValue": 4}, |
| 115 |
"Vendor": "NVIDIA", |
| 116 |
"ObjectType": "resource.GpuQualifier" |
| 117 |
} |
| 118 |
] |
| 119 |
} |
| 120 |
] |
| 121 |
''' |
| 122 |
|
| 123 |
from ansible.module_utils.basic import AnsibleModule |
| 124 |
from ansible_collections.cisco.intersight.plugins.module_utils.intersight import IntersightModule, intersight_argument_spec |
| 125 |
|
| 126 |
|
| 127 |
def main(): |
| 128 |
argument_spec = intersight_argument_spec.copy() |
| 129 |
argument_spec.update( |
| 130 |
organization=dict(type='str'), |
| 131 |
name=dict(type='str') |
| 132 |
) |
| 133 |
module = AnsibleModule( |
| 134 |
argument_spec, |
| 135 |
supports_check_mode=True, |
| 136 |
) |
| 137 |
|
| 138 |
intersight = IntersightModule(module) |
| 139 |
intersight.result['api_response'] = {} |
| 140 |
intersight.result['trace_id'] = '' |
| 141 |
|
| 142 |
# Resource path used to fetch info |
| 143 |
resource_path = '/resourcepool/QualificationPolicies' |
| 144 |
|
| 145 |
query_params = intersight.set_query_params() |
| 146 |
|
| 147 |
intersight.get_resource( |
| 148 |
resource_path=resource_path, |
| 149 |
query_params=query_params, |
| 150 |
return_list=True |
| 151 |
) |
| 152 |
|
| 153 |
module.exit_json(**intersight.result) |
| 154 |
|
| 155 |
|
| 156 |
if __name__ == '__main__': |
| 157 |
main() |