Debian Codegraph @

ansible_collections/community/general/plugins/modules/oneview_fc_network_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_fc_network_info
10 short_description: Retrieve the information about one or more of the OneView Fibre Channel Networks
11 description:
12 - Retrieve the information about one or more of the Fibre Channel Networks 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 name:
25 description:
26 - Fibre Channel Network name.
27 type: str
28
29 extends_documentation_fragment:
30 - community.general._oneview
31 - community.general._oneview.factsparams
32 - community.general._attributes
33 - community.general._attributes.info_module
34 """
35
36 EXAMPLES = r"""
37 - name: Gather information about all Fibre Channel Networks
38 community.general.oneview_fc_network_info:
39 config: /etc/oneview/oneview_config.json
40 delegate_to: localhost
41 register: result
42
43 - name: Print fetched information about Fibre Channel Networks
44 ansible.builtin.debug:
45 msg: "{{ result.fc_networks }}"
46
47 - name: Gather paginated, filtered and sorted information about Fibre Channel Networks
48 community.general.oneview_fc_network_info:
49 config: /etc/oneview/oneview_config.json
50 params:
51 start: 1
52 count: 3
53 sort: 'name:descending'
54 filter: 'fabricType=FabricAttach'
55 delegate_to: localhost
56 register: result
57
58 - name: Print fetched information about paginated, filtered and sorted list of Fibre Channel Networks
59 ansible.builtin.debug:
60 msg: "{{ result.fc_networks }}"
61
62 - name: Gather information about a Fibre Channel Network by name
63 community.general.oneview_fc_network_info:
64 config: /etc/oneview/oneview_config.json
65 name: network name
66 delegate_to: localhost
67 register: result
68
69 - name: Print fetched information about Fibre Channel Network found by name
70 ansible.builtin.debug:
71 msg: "{{ result.fc_networks }}"
72 """
73
74 RETURN = r"""
75 fc_networks:
76 description: Has all the OneView information about the Fibre Channel Networks.
77 returned: Always, but can be null.
78 type: dict
79 """
80
81 from ansible_collections.community.general.plugins.module_utils._oneview import OneViewModuleBase
82
83
84 class FcNetworkInfoModule(OneViewModuleBase):
85 def __init__(self):
86 argument_spec = dict(name=dict(type="str"), params=dict(type="dict"))
87
88 super().__init__(
89 additional_arg_spec=argument_spec,
90 supports_check_mode=True,
91 )
92
93 def execute_module(self):
94 if self.module.params["name"]:
95 fc_networks = self.oneview_client.fc_networks.get_by("name", self.module.params["name"])
96 else:
97 fc_networks = self.oneview_client.fc_networks.get_all(**self.facts_params)
98
99 return dict(changed=False, fc_networks=fc_networks)
100
101
102 def main():
103 FcNetworkInfoModule().run()
104
105
106 if __name__ == "__main__":
107 main()