mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-27 23:21:22 -07:00
New options of na_ontap_aggregate (#48906)
* add new options for na_ontap_aggregate * add gpl line * remove dup option * Put files in wrong directory * change unit test to match the request from PR 48941 * Changed for review comments * pep8
This commit is contained in:
parent
34c57b4c42
commit
62dd1fe29e
2 changed files with 279 additions and 13 deletions
|
@ -15,7 +15,6 @@ ANSIBLE_METADATA = {'metadata_version': '1.1',
|
|||
DOCUMENTATION = '''
|
||||
|
||||
module: na_ontap_aggregate
|
||||
|
||||
short_description: NetApp ONTAP manage aggregates.
|
||||
extends_documentation_fragment:
|
||||
- netapp.na_ontap
|
||||
|
@ -80,7 +79,7 @@ options:
|
|||
raid_type:
|
||||
description:
|
||||
- Specifies the type of RAID groups to use in the new aggregate.
|
||||
- The default value is raid4 on most platforms.
|
||||
choices: ['raid4', 'raid_dp', 'raid_tec']
|
||||
version_added: '2.7'
|
||||
|
||||
unmount_volumes:
|
||||
|
@ -90,6 +89,34 @@ options:
|
|||
- before the offline operation is executed.
|
||||
- By default, the system will reject any attempt to offline an aggregate that hosts one or more online volumes.
|
||||
|
||||
disks:
|
||||
type: list
|
||||
description:
|
||||
- Specific list of disks to use for the new aggregate.
|
||||
- To create a "mirrored" aggregate with a specific list of disks, both 'disks' and 'mirror_disks' options must be supplied.
|
||||
Additionally, the same number of disks must be supplied in both lists.
|
||||
version_added: '2.8'
|
||||
|
||||
is_mirrored:
|
||||
type: bool
|
||||
description:
|
||||
- Specifies that the new aggregate be mirrored (have two plexes).
|
||||
- If set to true, then the indicated disks will be split across the two plexes. By default, the new aggregate will not be mirrored.
|
||||
- This option cannot be used when a specific list of disks is supplied with either the 'disks' or 'mirror_disks' options.
|
||||
version_added: '2.8'
|
||||
|
||||
mirror_disks:
|
||||
type: list
|
||||
description:
|
||||
- List of mirror disks to use. It must contain the same number of disks specified in 'disks'.
|
||||
version_added: '2.8'
|
||||
|
||||
spare_pool:
|
||||
description:
|
||||
- Specifies the spare pool from which to select spare disks to use in creation of a new aggregate.
|
||||
choices: ['Pool0', 'Pool1']
|
||||
version_added: '2.8'
|
||||
|
||||
'''
|
||||
|
||||
EXAMPLES = """
|
||||
|
@ -118,8 +145,8 @@ EXAMPLES = """
|
|||
na_ontap_aggregate:
|
||||
state: present
|
||||
service_state: online
|
||||
name: ansibleAggr
|
||||
rename: ansibleAggr2
|
||||
from_name: ansibleAggr
|
||||
name: ansibleAggr2
|
||||
disk_count: 1
|
||||
hostname: "{{ netapp_hostname }}"
|
||||
username: "{{ netapp_username }}"
|
||||
|
@ -155,32 +182,41 @@ class NetAppOntapAggregate(object):
|
|||
def __init__(self):
|
||||
self.argument_spec = netapp_utils.na_ontap_host_argument_spec()
|
||||
self.argument_spec.update(dict(
|
||||
state=dict(required=False, choices=[
|
||||
'present', 'absent'], default='present'),
|
||||
service_state=dict(required=False, choices=['online', 'offline']),
|
||||
name=dict(required=True, type='str'),
|
||||
from_name=dict(required=False, type='str'),
|
||||
disks=dict(required=False, type='list'),
|
||||
disk_count=dict(required=False, type='int', default=None),
|
||||
disk_type=dict(required=False, choices=['ATA', 'BSAS', 'FCAL', 'FSAS', 'LUN', 'MSATA', 'SAS', 'SSD',
|
||||
'VMDISK']),
|
||||
raid_type=dict(required=False, type='str'),
|
||||
disk_size=dict(required=False, type='int'),
|
||||
disk_type=dict(required=False, choices=['ATA', 'BSAS', 'FCAL', 'FSAS', 'LUN', 'MSATA', 'SAS', 'SSD', 'VMDISK']),
|
||||
from_name=dict(required=False, type='str'),
|
||||
mirror_disks=dict(required=False, type='list'),
|
||||
nodes=dict(required=False, type='list'),
|
||||
is_mirrored=dict(required=False, type='bool'),
|
||||
raid_size=dict(required=False, type='int'),
|
||||
raid_type=dict(required=False, choices=['raid4', 'raid_dp', 'raid_tec']),
|
||||
service_state=dict(required=False, choices=['online', 'offline']),
|
||||
spare_pool=dict(required=False, choices=['Pool0', 'Pool1']),
|
||||
state=dict(required=False, choices=['present', 'absent'], default='present'),
|
||||
unmount_volumes=dict(required=False, type='bool'),
|
||||
))
|
||||
|
||||
self.module = AnsibleModule(
|
||||
argument_spec=self.argument_spec,
|
||||
required_if=[
|
||||
('service_state', 'offline', ['unmount_volumes'])
|
||||
('service_state', 'offline', ['unmount_volumes']),
|
||||
],
|
||||
mutually_exclusive=[
|
||||
('is_mirrored', 'disks'),
|
||||
('is_mirrored', 'mirror_disks'),
|
||||
('is_mirrored', 'spare_pool'),
|
||||
('spare_pool', 'disks')
|
||||
],
|
||||
supports_check_mode=True
|
||||
)
|
||||
|
||||
self.na_helper = NetAppModule()
|
||||
self.parameters = self.na_helper.set_parameters(self.module.params)
|
||||
|
||||
if self.parameters.get('mirror_disks') is not None and self.parameters.get('disks') is None:
|
||||
self.module.fail_json(mgs="mirror_disks require disks options to be set")
|
||||
if HAS_NETAPP_LIB is False:
|
||||
self.module.fail_json(msg="the python NetApp-Lib module is required")
|
||||
else:
|
||||
|
@ -279,12 +315,28 @@ class NetAppOntapAggregate(object):
|
|||
options['raid-type'] = self.parameters['raid_type']
|
||||
if self.parameters.get('disk_size'):
|
||||
options['disk-size'] = str(self.parameters['disk_size'])
|
||||
if self.parameters.get('is_mirrored'):
|
||||
options['is-mirrored'] = str(self.parameters['is_mirrored'])
|
||||
if self.parameters.get('spare_pool'):
|
||||
options['spare-pool'] = self.parameters['spare_pool']
|
||||
if self.parameters.get('raid_type'):
|
||||
options['raid-type'] = self.parameters['raid_type']
|
||||
aggr_create = netapp_utils.zapi.NaElement.create_node_with_children('aggr-create', **options)
|
||||
if self.parameters.get('nodes'):
|
||||
nodes_obj = netapp_utils.zapi.NaElement('nodes')
|
||||
aggr_create.add_child_elem(nodes_obj)
|
||||
for node in self.parameters['nodes']:
|
||||
nodes_obj.add_new_child('node-name', node)
|
||||
if self.parameters.get('disks'):
|
||||
disks_obj = netapp_utils.zapi.NaElement('disk-info')
|
||||
for disk in self.parameters.get('disks'):
|
||||
disks_obj.add_new_child('name', disk)
|
||||
aggr_create.add_child_elem(disks_obj)
|
||||
if self.parameters.get('mirror_disks'):
|
||||
mirror_disks_obj = netapp_utils.zapi.NaElement('disk-info')
|
||||
for disk in self.parameters.get('mirror_disks'):
|
||||
mirror_disks_obj.add_new_child('name', disk)
|
||||
aggr_create.add_child_elem(mirror_disks_obj)
|
||||
|
||||
try:
|
||||
self.server.invoke_successfully(aggr_create, enable_tunneling=False)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue