Debian Codegraph @

ansible_collections/community/general/plugins/modules/oneview_san_manager_info.py

raw
1 #!/usr/bin/python
2 # Copyright (c) 2016-2017 Hewlett Packard Enterprise Development LP
3 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
4 # SPDX-License-Identifier: GPL-3.0-or-later
5
6 from __future__ import annotations
7
8 DOCUMENTATION = r"""
9 module: oneview_san_manager_info
10 short_description: Retrieve information about one or more of the OneView SAN Managers
11 description:
12 - Retrieve information about one or more of the SAN Managers from OneView.
13 requirements:
14 - hpOneView >= 2.0.1
15 author:
16 - Felipe Bulsoni (@fgbulsoni)
17 - Thiago Miotto (@tmiotto)
18 - Adriane Cardozo (@adriane-cardozo)
19 attributes:
20 check_mode:
21 version_added: 3.3.0
22 # This was backported to 2.5.4 and 1.3.11 as well, since this was a bugfix
23 options:
24 provider_display_name:
25 description:
26 - Provider Display Name.
27 type: str
28 params:
29 description:
30 - List of params to delimit, filter and sort the list of resources.
31 - 'Params allowed:'
32 - 'V(start): The first item to return, using 0-based indexing.'
33 - 'V(count): The number of resources to return.'
34 - 'V(query): A general query string to narrow the list of resources returned.'
35 - 'V(sort): The sort order of the returned data set.'
36 type: dict
37 extends_documentation_fragment:
38 - community.general._oneview
39 - community.general._attributes
40 - community.general._attributes.info_module
41 """
42
43 EXAMPLES = r"""
44 - name: Gather information about all SAN Managers
45 community.general.oneview_san_manager_info:
46 config: /etc/oneview/oneview_config.json
47 delegate_to: localhost
48 register: result
49
50 - name: Print fetched information about SAN Managers
51 ansible.builtin.debug:
52 msg: "{{ result.san_managers }}"
53
54 - name: Gather paginated, filtered and sorted information about SAN Managers
55 community.general.oneview_san_manager_info:
56 config: /etc/oneview/oneview_config.json
57 params:
58 start: 0
59 count: 3
60 sort: name:ascending
61 query: isInternal eq false
62 delegate_to: localhost
63 register: result
64
65 - name: Print fetched information about paginated, filtered and sorted list of SAN Managers
66 ansible.builtin.debug:
67 msg: "{{ result.san_managers }}"
68
69 - name: Gather information about a SAN Manager by provider display name
70 community.general.oneview_san_manager_info:
71 config: /etc/oneview/oneview_config.json
72 provider_display_name: Brocade Network Advisor
73 delegate_to: localhost
74 register: result
75
76 - name: Print fetched information about SAN Manager found by provider display name
77 ansible.builtin.debug:
78 msg: "{{ result.san_managers }}"
79 """
80
81 RETURN = r"""
82 san_managers:
83 description: Has all the OneView information about the SAN Managers.
84 returned: Always, but can be null.
85 type: dict
86 """
87
88 from ansible_collections.community.general.plugins.module_utils._oneview import OneViewModuleBase
89
90
91 class SanManagerInfoModule(OneViewModuleBase):
92 argument_spec = dict(provider_display_name=dict(type="str"), params=dict(type="dict"))
93
94 def __init__(self):
95 super().__init__(
96 additional_arg_spec=self.argument_spec,
97 supports_check_mode=True,
98 )
99 self.resource_client = self.oneview_client.san_managers
100
101 def execute_module(self):
102 if self.module.params.get("provider_display_name"):
103 provider_display_name = self.module.params["provider_display_name"]
104 san_manager = self.oneview_client.san_managers.get_by_provider_display_name(provider_display_name)
105 if san_manager:
106 resources = [san_manager]
107 else:
108 resources = []
109 else:
110 resources = self.oneview_client.san_managers.get_all(**self.facts_params)
111
112 return dict(changed=False, san_managers=resources)
113
114
115 def main():
116 SanManagerInfoModule().run()
117
118
119 if __name__ == "__main__":
120 main()