Debian Codegraph @

ansible_collections/community/vmware/plugins/modules/vmware_vasa_info.py

raw
1 #!/usr/bin/python
2 # -*- coding: utf-8 -*-
3
4 # Copyright: (c) 2023, Pure Storage, Inc.
5 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
6 # SPDX-License-Identifier: GPL-3.0-or-later
7
8 from __future__ import absolute_import, division, print_function
9 __metaclass__ = type
10
11
12 DOCUMENTATION = r'''
13 ---
14 module: vmware_vasa_info
15 version_added: '3.8.0'
16 short_description: Gather information about vSphere VASA providers.
17 description:
18 - Returns basic information on the vSphere VASA providers registered in the
19 vcenter.
20 author:
21 - Eugenio Grosso (@genegr) <[email protected]>
22 extends_documentation_fragment:
23 - vmware.vmware.base_options
24
25 '''
26
27 EXAMPLES = r'''
28 - name: Get VASA providers info
29 community.vmware.vmware_vasa_info:
30 hostname: '{{ vcenter_hostname }}'
31 username: '{{ vcenter_username }}'
32 password: '{{ vcenter_password }}'
33 delegate_to: localhost
34 register: providers
35 '''
36
37 RETURN = r'''
38 vasa_providers:
39 description: list of dictionary of VASA info
40 returned: success
41 type: list
42 sample: [
43 {
44 "certificate_status": "valid",
45 "description": "IOFILTER VASA Provider on host host01.domain.local",
46 "name": "IOFILTER Provider host01.domain.local",
47 "related_storage_array": [
48 {
49 "active": "True",
50 "array_id": "IOFILTERS:616d4715-7de2-7be2-997a-10f920c5fdbe",
51 "manageable": "True",
52 "priority": "1"
53 }
54 ],
55 "status": "online",
56 "uid": "02e10bc5-dd77-4ce4-9100-5aee44e7abaa",
57 "url": "https://host01.domain.local:9080/version.xml",
58 "version": "1.0"
59 },
60 ]
61 '''
62
63
64 from ansible.module_utils.basic import AnsibleModule
65 from ansible_collections.community.vmware.plugins.module_utils.vmware_sms import SMS
66 from ansible_collections.vmware.vmware.plugins.module_utils.argument_spec import base_argument_spec
67
68
69 class SMSClient(SMS):
70 def __init__(self, module):
71 super(SMSClient, self).__init__(module)
72
73 def get_vasa_provider_info(self):
74 self.get_sms_connection()
75
76 results = dict(changed=False, vasa_providers=[])
77 storage_manager = self.sms_si.QueryStorageManager()
78 storage_providers = storage_manager.QueryProvider()
79
80 for provider in storage_providers:
81 provider_info = provider.QueryProviderInfo()
82 temp_provider_info = {
83 'name': provider_info.name,
84 'uid': provider_info.uid,
85 'description': provider_info.description,
86 'version': provider_info.version,
87 'certificate_status': provider_info.certificateStatus,
88 'url': provider_info.url,
89 'status': provider_info.status,
90 'related_storage_array': []
91 }
92 for a in provider_info.relatedStorageArray:
93 temp_storage_array = {
94 'active': str(a.active),
95 'array_id': a.arrayId,
96 'manageable': str(a.manageable),
97 'priority': str(a.priority)
98 }
99 temp_provider_info['related_storage_array'].append(temp_storage_array)
100
101 results['vasa_providers'].append(temp_provider_info)
102
103 self.module.exit_json(**results)
104
105
106 def main():
107 argument_spec = base_argument_spec()
108
109 module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True)
110
111 sms_client = SMSClient(module)
112 sms_client.get_vasa_provider_info()
113
114
115 if __name__ == '__main__':
116 main()