2020-03-09 10:11:07 +01:00
|
|
|
#!/usr/bin/python
|
2021-08-08 10:40:22 +02:00
|
|
|
# -*- coding: utf-8 -*-
|
2020-03-09 10:11:07 +01:00
|
|
|
# Copyright (c) 2016-2017 Hewlett Packard Enterprise Development LP
|
2022-08-05 12:28:29 +02:00
|
|
|
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
|
|
|
|
# SPDX-License-Identifier: GPL-3.0-or-later
|
2020-03-09 10:11:07 +01:00
|
|
|
|
|
|
|
from __future__ import (absolute_import, division, print_function)
|
|
|
|
__metaclass__ = type
|
|
|
|
|
|
|
|
DOCUMENTATION = '''
|
|
|
|
---
|
|
|
|
module: oneview_fc_network
|
2022-11-09 13:57:41 +01:00
|
|
|
short_description: Manage OneView Fibre Channel Network resources
|
2020-03-09 10:11:07 +01:00
|
|
|
description:
|
|
|
|
- Provides an interface to manage Fibre Channel Network resources. Can create, update, and delete.
|
|
|
|
requirements:
|
|
|
|
- "hpOneView >= 4.0.0"
|
|
|
|
author: "Felipe Bulsoni (@fgbulsoni)"
|
Add attributes to atomic, memset, one, oneview, packet, proxmox, and xenserver modules (#5958)
Add attributes to atomic, memset, one, oneview, packet, proxmox, and xenserver modules.
2023-02-20 17:27:38 +01:00
|
|
|
attributes:
|
|
|
|
check_mode:
|
|
|
|
support: none
|
|
|
|
diff_mode:
|
|
|
|
support: none
|
2020-03-09 10:11:07 +01:00
|
|
|
options:
|
|
|
|
state:
|
|
|
|
description:
|
|
|
|
- Indicates the desired state for the Fibre Channel Network resource.
|
2023-06-20 08:14:02 +02:00
|
|
|
V(present) will ensure data properties are compliant with OneView.
|
|
|
|
V(absent) will remove the resource from OneView, if it exists.
|
2021-03-24 14:16:33 +01:00
|
|
|
type: str
|
2020-03-09 10:11:07 +01:00
|
|
|
choices: ['present', 'absent']
|
2020-11-28 14:06:28 +01:00
|
|
|
required: true
|
2020-03-09 10:11:07 +01:00
|
|
|
data:
|
|
|
|
description:
|
|
|
|
- List with the Fibre Channel Network properties.
|
2021-03-24 14:16:33 +01:00
|
|
|
type: dict
|
2020-03-09 10:11:07 +01:00
|
|
|
required: true
|
|
|
|
|
|
|
|
extends_documentation_fragment:
|
Add attributes to atomic, memset, one, oneview, packet, proxmox, and xenserver modules (#5958)
Add attributes to atomic, memset, one, oneview, packet, proxmox, and xenserver modules.
2023-02-20 17:27:38 +01:00
|
|
|
- community.general.oneview
|
|
|
|
- community.general.oneview.validateetag
|
|
|
|
- community.general.attributes
|
2020-03-09 10:11:07 +01:00
|
|
|
|
|
|
|
'''
|
|
|
|
|
|
|
|
EXAMPLES = '''
|
|
|
|
- name: Ensure that the Fibre Channel Network is present using the default configuration
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.oneview_fc_network:
|
2020-03-09 10:11:07 +01:00
|
|
|
config: "{{ config_file_path }}"
|
|
|
|
state: present
|
|
|
|
data:
|
|
|
|
name: 'New FC Network'
|
|
|
|
|
|
|
|
- name: Ensure that the Fibre Channel Network is present with fabricType 'DirectAttach'
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.oneview_fc_network:
|
2020-03-09 10:11:07 +01:00
|
|
|
config: "{{ config_file_path }}"
|
|
|
|
state: present
|
|
|
|
data:
|
|
|
|
name: 'New FC Network'
|
|
|
|
fabricType: 'DirectAttach'
|
|
|
|
|
|
|
|
- name: Ensure that the Fibre Channel Network is present and is inserted in the desired scopes
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.oneview_fc_network:
|
2020-03-09 10:11:07 +01:00
|
|
|
config: "{{ config_file_path }}"
|
|
|
|
state: present
|
|
|
|
data:
|
|
|
|
name: 'New FC Network'
|
|
|
|
scopeUris:
|
|
|
|
- '/rest/scopes/00SC123456'
|
|
|
|
- '/rest/scopes/01SC123456'
|
|
|
|
|
|
|
|
- name: Ensure that the Fibre Channel Network is absent
|
2020-07-13 21:50:31 +02:00
|
|
|
community.general.oneview_fc_network:
|
2020-03-09 10:11:07 +01:00
|
|
|
config: "{{ config_file_path }}"
|
|
|
|
state: absent
|
|
|
|
data:
|
|
|
|
name: 'New FC Network'
|
|
|
|
'''
|
|
|
|
|
|
|
|
RETURN = '''
|
|
|
|
fc_network:
|
|
|
|
description: Has the facts about the managed OneView FC Network.
|
|
|
|
returned: On state 'present'. Can be null.
|
|
|
|
type: dict
|
|
|
|
'''
|
|
|
|
|
|
|
|
from ansible_collections.community.general.plugins.module_utils.oneview import OneViewModuleBase
|
|
|
|
|
|
|
|
|
|
|
|
class FcNetworkModule(OneViewModuleBase):
|
|
|
|
MSG_CREATED = 'FC Network created successfully.'
|
|
|
|
MSG_UPDATED = 'FC Network updated successfully.'
|
|
|
|
MSG_DELETED = 'FC Network deleted successfully.'
|
|
|
|
MSG_ALREADY_PRESENT = 'FC Network is already present.'
|
|
|
|
MSG_ALREADY_ABSENT = 'FC Network is already absent.'
|
|
|
|
RESOURCE_FACT_NAME = 'fc_network'
|
|
|
|
|
|
|
|
def __init__(self):
|
|
|
|
|
|
|
|
additional_arg_spec = dict(data=dict(required=True, type='dict'),
|
|
|
|
state=dict(
|
|
|
|
required=True,
|
|
|
|
choices=['present', 'absent']))
|
|
|
|
|
|
|
|
super(FcNetworkModule, self).__init__(additional_arg_spec=additional_arg_spec,
|
|
|
|
validate_etag_support=True)
|
|
|
|
|
|
|
|
self.resource_client = self.oneview_client.fc_networks
|
|
|
|
|
|
|
|
def execute_module(self):
|
|
|
|
resource = self.get_by_name(self.data['name'])
|
|
|
|
|
|
|
|
if self.state == 'present':
|
|
|
|
return self._present(resource)
|
|
|
|
else:
|
|
|
|
return self.resource_absent(resource)
|
|
|
|
|
|
|
|
def _present(self, resource):
|
|
|
|
scope_uris = self.data.pop('scopeUris', None)
|
|
|
|
result = self.resource_present(resource, self.RESOURCE_FACT_NAME)
|
|
|
|
if scope_uris is not None:
|
|
|
|
result = self.resource_scopes_set(result, 'fc_network', scope_uris)
|
|
|
|
return result
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
FcNetworkModule().run()
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == '__main__':
|
|
|
|
main()
|