mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-19 19:30:22 -07:00
Unflatmap community.general (#5461)
* Move files. * Update imports and references. * Move wrongly placed files. * Reverse redirects, deprecate long → short name redirects. * Simplify contribution guidelines for new modules. * Rewrite BOTMETA. * Add changelog fragment. * Fix ignore.txt files.
This commit is contained in:
parent
2b0bebc8fc
commit
b531ecdc9b
1033 changed files with 4802 additions and 1989 deletions
125
plugins/modules/oneview_fc_network.py
Normal file
125
plugins/modules/oneview_fc_network.py
Normal file
|
@ -0,0 +1,125 @@
|
|||
#!/usr/bin/python
|
||||
# -*- coding: utf-8 -*-
|
||||
# Copyright (c) 2016-2017 Hewlett Packard Enterprise Development LP
|
||||
# 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
|
||||
|
||||
from __future__ import (absolute_import, division, print_function)
|
||||
__metaclass__ = type
|
||||
|
||||
DOCUMENTATION = '''
|
||||
---
|
||||
module: oneview_fc_network
|
||||
short_description: Manage OneView Fibre Channel Network resources.
|
||||
description:
|
||||
- Provides an interface to manage Fibre Channel Network resources. Can create, update, and delete.
|
||||
requirements:
|
||||
- "hpOneView >= 4.0.0"
|
||||
author: "Felipe Bulsoni (@fgbulsoni)"
|
||||
options:
|
||||
state:
|
||||
description:
|
||||
- Indicates the desired state for the Fibre Channel Network resource.
|
||||
C(present) will ensure data properties are compliant with OneView.
|
||||
C(absent) will remove the resource from OneView, if it exists.
|
||||
type: str
|
||||
choices: ['present', 'absent']
|
||||
required: true
|
||||
data:
|
||||
description:
|
||||
- List with the Fibre Channel Network properties.
|
||||
type: dict
|
||||
required: true
|
||||
|
||||
extends_documentation_fragment:
|
||||
- community.general.oneview
|
||||
- community.general.oneview.validateetag
|
||||
|
||||
'''
|
||||
|
||||
EXAMPLES = '''
|
||||
- name: Ensure that the Fibre Channel Network is present using the default configuration
|
||||
community.general.oneview_fc_network:
|
||||
config: "{{ config_file_path }}"
|
||||
state: present
|
||||
data:
|
||||
name: 'New FC Network'
|
||||
|
||||
- name: Ensure that the Fibre Channel Network is present with fabricType 'DirectAttach'
|
||||
community.general.oneview_fc_network:
|
||||
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
|
||||
community.general.oneview_fc_network:
|
||||
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
|
||||
community.general.oneview_fc_network:
|
||||
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()
|
Loading…
Add table
Add a link
Reference in a new issue