1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Add support for AC pods, Virtual Groups and Offload Targets in Pure Storage (#45760)

FA Fact module
This commit is contained in:
Simon Dodsley 2018-10-27 14:39:37 -04:00 committed by ansibot
parent 8f7c857960
commit 9903ef2a0f

View file

@ -30,7 +30,7 @@ options:
- When supplied, this argument will define the facts to be collected. - When supplied, this argument will define the facts to be collected.
Possible values for this include all, minimum, config, performance, Possible values for this include all, minimum, config, performance,
capacity, network, subnet, interfaces, hgroups, pgroups, hosts, capacity, network, subnet, interfaces, hgroups, pgroups, hosts,
volumes and snapshots. volumes, snapshots, pods, vgroups and offload.
required: false required: false
default: minimum default: minimum
extends_documentation_fragment: extends_documentation_fragment:
@ -250,6 +250,15 @@ ansible_facts:
"speed": 1000000000 "speed": 1000000000
} }
} }
"offload": {
"nfstarget": {
"address": "10.0.2.53",
"mount_options": null,
"mount_point": "/offload",
"protocol": "nfs",
"status": "scanning"
}
}
"performance": { "performance": {
"input_per_sec": 8191, "input_per_sec": 8191,
"output_per_sec": 0, "output_per_sec": 0,
@ -271,6 +280,25 @@ ansible_facts:
] ]
} }
} }
"pods": {
"srm-pod": {
"arrays": [
{
"array_id": "52595f7e-b460-4b46-8851-a5defd2ac192",
"mediator_status": "online",
"name": "sn1-405-c09-37",
"status": "online"
},
{
"array_id": "a2c32301-f8a0-4382-949b-e69b552ce8ca",
"mediator_status": "online",
"name": "sn1-420-c11-31",
"status": "online"
}
],
"source": null
}
}
"snapshots": { "snapshots": {
"consisgroup.cgsnapshot": { "consisgroup.cgsnapshot": {
"created": "2018-03-28T09:34:02Z", "created": "2018-03-28T09:34:02Z",
@ -279,6 +307,13 @@ ansible_facts:
} }
} }
"subnet": {} "subnet": {}
"vgroups": {
"vvol--vSphere-HA-0ffc7dd1-vg": {
"volumes": [
"vvol--vSphere-HA-0ffc7dd1-vg/Config-aad5d7c6"
]
}
}
"volumes": { "volumes": {
"ansible_data": { "ansible_data": {
"bandwidth": null, "bandwidth": null,
@ -469,8 +504,8 @@ def generate_vol_dict(array):
for vvol in range(0, len(vvols)): for vvol in range(0, len(vvols)):
volume = vvols[vvol]['name'] volume = vvols[vvol]['name']
volume_facts[volume] = { volume_facts[volume] = {
'source': vols[vol]['source'], 'source': vvols[vvol]['source'],
'serial': vols[vol]['serial'], 'serial': vvols[vvol]['serial'],
'hosts': [] 'hosts': []
} }
cvols = array.list_volumes(connect=True) cvols = array.list_volumes(connect=True)
@ -509,6 +544,51 @@ def generate_pgroups_dict(array):
return pgroups_facts return pgroups_facts
def generate_pods_dict(array):
pods_facts = {}
api_version = array._list_available_rest_versions()
if AC_REQUIRED_API_VERSION in api_version:
pods = array.list_pods()
for pod in range(0, len(pods)):
acpod = pods[pod]['name']
pods_facts[acpod] = {
'source': pods[pod]['source'],
'arrays': pods[pod]['arrays'],
}
return pods_facts
def generate_vgroups_dict(array):
vgroups_facts = {}
api_version = array._list_available_rest_versions()
if AC_REQUIRED_API_VERSION in api_version:
vgroups = array.list_vgroups()
for vgroup in range(0, len(vgroups)):
virtgroup = vgroups[vgroup]['name']
vgroups_facts[virtgroup] = {
'volumes': vgroups[vgroup]['volumes'],
}
return vgroups_facts
def generate_offload_dict(array):
offload_facts = {}
api_version = array._list_available_rest_versions()
if AC_REQUIRED_API_VERSION in api_version:
offload = array.list_nfs_offload()
for target in range(0, len(offload)):
offloadt = offload[target]['name']
offload_facts[offloadt] = {
'status': offload[target]['status'],
'mount_point': offload[target]['mount_point'],
'protocol': offload[target]['protocol'],
'mount_options': offload[target]['mount_options'],
'address': offload[target]['address'],
}
return offload_facts
def generate_hgroups_dict(array): def generate_hgroups_dict(array):
hgroups_facts = {} hgroups_facts = {}
hgroups = array.list_hgroups() hgroups = array.list_hgroups()
@ -556,7 +636,7 @@ def main():
subset = [test.lower() for test in module.params['gather_subset']] subset = [test.lower() for test in module.params['gather_subset']]
valid_subsets = ('all', 'minimum', 'config', 'performance', 'capacity', valid_subsets = ('all', 'minimum', 'config', 'performance', 'capacity',
'network', 'subnet', 'interfaces', 'hgroups', 'pgroups', 'network', 'subnet', 'interfaces', 'hgroups', 'pgroups',
'hosts', 'volumes', 'snapshots') 'hosts', 'volumes', 'snapshots', 'pods', 'vgroups', 'offload')
subset_test = (test in valid_subsets for test in subset) subset_test = (test in valid_subsets for test in subset)
if not all(subset_test): if not all(subset_test):
module.fail_json(msg="value must gather_subset must be one or more of: %s, got: %s" module.fail_json(msg="value must gather_subset must be one or more of: %s, got: %s"
@ -588,6 +668,12 @@ def main():
facts['hgroups'] = generate_hgroups_dict(array) facts['hgroups'] = generate_hgroups_dict(array)
if 'pgroups' in subset or 'all' in subset: if 'pgroups' in subset or 'all' in subset:
facts['pgroups'] = generate_pgroups_dict(array) facts['pgroups'] = generate_pgroups_dict(array)
if 'pods' in subset or 'all' in subset:
facts['pods'] = generate_pods_dict(array)
if 'vgroups' in subset or 'all' in subset:
facts['vgroups'] = generate_vgroups_dict(array)
if 'offload' in subset or 'all' in subset:
facts['offload'] = generate_offload_dict(array)
result = dict(ansible_purefa_facts=facts,) result = dict(ansible_purefa_facts=facts,)