Debian Codegraph @

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