| 1 |
#!/usr/bin/python |
| 2 |
|
| 3 |
# Copyright (c) 2016-2017, Hewlett Packard Enterprise Development LP |
| 4 |
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) |
| 5 |
# SPDX-License-Identifier: GPL-3.0-or-later |
| 6 |
|
| 7 |
from __future__ import annotations |
| 8 |
|
| 9 |
DOCUMENTATION = r""" |
| 10 |
module: oneview_logical_interconnect_group_info |
| 11 |
short_description: Retrieve information about one or more of the OneView Logical Interconnect Groups |
| 12 |
description: |
| 13 |
- Retrieve information about one or more of the Logical Interconnect Groups from OneView. |
| 14 |
requirements: |
| 15 |
- hpOneView >= 2.0.1 |
| 16 |
author: |
| 17 |
- Felipe Bulsoni (@fgbulsoni) |
| 18 |
- Thiago Miotto (@tmiotto) |
| 19 |
- Adriane Cardozo (@adriane-cardozo) |
| 20 |
attributes: |
| 21 |
check_mode: |
| 22 |
version_added: 3.3.0 |
| 23 |
# This was backported to 2.5.4 and 1.3.11 as well, since this was a bugfix |
| 24 |
options: |
| 25 |
name: |
| 26 |
description: |
| 27 |
- Logical Interconnect Group name. |
| 28 |
type: str |
| 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 Logical Interconnect Groups |
| 38 |
community.general.oneview_logical_interconnect_group_info: |
| 39 |
hostname: 172.16.101.48 |
| 40 |
username: administrator |
| 41 |
password: my_password |
| 42 |
api_version: 500 |
| 43 |
no_log: true |
| 44 |
delegate_to: localhost |
| 45 |
register: result |
| 46 |
|
| 47 |
- name: Print fetched information about Logical Interconnect Groups |
| 48 |
ansible.builtin.debug: |
| 49 |
msg: "{{ result.logical_interconnect_groups }}" |
| 50 |
|
| 51 |
- name: Gather paginated, filtered and sorted information about Logical Interconnect Groups |
| 52 |
community.general.oneview_logical_interconnect_group_info: |
| 53 |
params: |
| 54 |
start: 0 |
| 55 |
count: 3 |
| 56 |
sort: name:descending |
| 57 |
filter: name=LIGName |
| 58 |
hostname: 172.16.101.48 |
| 59 |
username: administrator |
| 60 |
password: my_password |
| 61 |
api_version: 500 |
| 62 |
no_log: true |
| 63 |
delegate_to: localhost |
| 64 |
register: result |
| 65 |
|
| 66 |
- name: Print fetched information about paginated, filtered and sorted list of Logical Interconnect Groups |
| 67 |
ansible.builtin.debug: |
| 68 |
msg: "{{ result.logical_interconnect_groups }}" |
| 69 |
|
| 70 |
- name: Gather information about a Logical Interconnect Group by name |
| 71 |
community.general.oneview_logical_interconnect_group_info: |
| 72 |
name: logical interconnect group name |
| 73 |
hostname: 172.16.101.48 |
| 74 |
username: administrator |
| 75 |
password: my_password |
| 76 |
api_version: 500 |
| 77 |
no_log: true |
| 78 |
delegate_to: localhost |
| 79 |
register: result |
| 80 |
|
| 81 |
- name: Print fetched information about Logical Interconnect Group found by name |
| 82 |
ansible.builtin.debug: |
| 83 |
msg: "{{ result.logical_interconnect_groups }}" |
| 84 |
""" |
| 85 |
|
| 86 |
RETURN = r""" |
| 87 |
logical_interconnect_groups: |
| 88 |
description: Has all the OneView information about the Logical Interconnect Groups. |
| 89 |
returned: Always, but can be null. |
| 90 |
type: dict |
| 91 |
""" |
| 92 |
|
| 93 |
from ansible_collections.community.general.plugins.module_utils._oneview import OneViewModuleBase |
| 94 |
|
| 95 |
|
| 96 |
class LogicalInterconnectGroupInfoModule(OneViewModuleBase): |
| 97 |
def __init__(self): |
| 98 |
argument_spec = dict( |
| 99 |
name=dict(type="str"), |
| 100 |
params=dict(type="dict"), |
| 101 |
) |
| 102 |
|
| 103 |
super().__init__( |
| 104 |
additional_arg_spec=argument_spec, |
| 105 |
supports_check_mode=True, |
| 106 |
) |
| 107 |
|
| 108 |
def execute_module(self): |
| 109 |
if self.module.params.get("name"): |
| 110 |
ligs = self.oneview_client.logical_interconnect_groups.get_by("name", self.module.params["name"]) |
| 111 |
else: |
| 112 |
ligs = self.oneview_client.logical_interconnect_groups.get_all(**self.facts_params) |
| 113 |
|
| 114 |
return dict(changed=False, logical_interconnect_groups=ligs) |
| 115 |
|
| 116 |
|
| 117 |
def main(): |
| 118 |
LogicalInterconnectGroupInfoModule().run() |
| 119 |
|
| 120 |
|
| 121 |
if __name__ == "__main__": |
| 122 |
main() |