mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-05-21 08:29:08 -07:00
New options for na_ontap_aggregate (wait_for_online, and time_out) (#52353)
* Revert "changes to clusteR" This reverts commit 33ee1b71e4bc8435fb315762a871f8c4cb6c5f80. * updates * fix author * Revert "Revert "changes to clusteR"" This reverts commit 8e56b999e6cf6a65de339e516f7134a6b6b39cba. * update copyright * fix doc
This commit is contained in:
parent
a60740a37d
commit
42fe43a0c7
2 changed files with 38 additions and 4 deletions
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/python
|
#!/usr/bin/python
|
||||||
|
|
||||||
# (c) 2018, NetApp, Inc
|
# (c) 2018-2019, NetApp, Inc
|
||||||
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
from __future__ import absolute_import, division, print_function
|
from __future__ import absolute_import, division, print_function
|
||||||
|
@ -117,15 +117,32 @@ options:
|
||||||
choices: ['Pool0', 'Pool1']
|
choices: ['Pool0', 'Pool1']
|
||||||
version_added: '2.8'
|
version_added: '2.8'
|
||||||
|
|
||||||
|
wait_for_online:
|
||||||
|
description:
|
||||||
|
- Set this parameter to 'true' for synchronous execution during create (wait until aggregate status is online)
|
||||||
|
- Set this parameter to 'false' for asynchronous execution
|
||||||
|
- For asynchronous, execution exits as soon as the request is sent, without checking aggregate status
|
||||||
|
type: bool
|
||||||
|
default: false
|
||||||
|
version_added: '2.8'
|
||||||
|
|
||||||
|
time_out:
|
||||||
|
description:
|
||||||
|
- time to wait for aggregate creation in seconds
|
||||||
|
- default is set to 100 seconds
|
||||||
|
default: 100
|
||||||
|
version_added: "2.8"
|
||||||
'''
|
'''
|
||||||
|
|
||||||
EXAMPLES = """
|
EXAMPLES = """
|
||||||
- name: Create Aggregates
|
- name: Create Aggregates and wait 5 minutes until aggregate is online
|
||||||
na_ontap_aggregate:
|
na_ontap_aggregate:
|
||||||
state: present
|
state: present
|
||||||
service_state: online
|
service_state: online
|
||||||
name: ansibleAggr
|
name: ansibleAggr
|
||||||
disk_count: 1
|
disk_count: 1
|
||||||
|
wait_for_online: True
|
||||||
|
time_out: 300
|
||||||
hostname: "{{ netapp_hostname }}"
|
hostname: "{{ netapp_hostname }}"
|
||||||
username: "{{ netapp_username }}"
|
username: "{{ netapp_username }}"
|
||||||
password: "{{ netapp_password }}"
|
password: "{{ netapp_password }}"
|
||||||
|
@ -166,6 +183,7 @@ EXAMPLES = """
|
||||||
RETURN = """
|
RETURN = """
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
|
|
||||||
from ansible.module_utils.basic import AnsibleModule
|
from ansible.module_utils.basic import AnsibleModule
|
||||||
|
@ -197,6 +215,8 @@ class NetAppOntapAggregate(object):
|
||||||
spare_pool=dict(required=False, choices=['Pool0', 'Pool1']),
|
spare_pool=dict(required=False, choices=['Pool0', 'Pool1']),
|
||||||
state=dict(required=False, choices=['present', 'absent'], default='present'),
|
state=dict(required=False, choices=['present', 'absent'], default='present'),
|
||||||
unmount_volumes=dict(required=False, type='bool'),
|
unmount_volumes=dict(required=False, type='bool'),
|
||||||
|
wait_for_online=dict(required=False, type='bool', default=False),
|
||||||
|
time_out=dict(required=False, type='int', default=100)
|
||||||
))
|
))
|
||||||
|
|
||||||
self.module = AnsibleModule(
|
self.module = AnsibleModule(
|
||||||
|
@ -235,12 +255,13 @@ class NetAppOntapAggregate(object):
|
||||||
query = netapp_utils.zapi.NaElement('query')
|
query = netapp_utils.zapi.NaElement('query')
|
||||||
query.add_child_elem(query_details)
|
query.add_child_elem(query_details)
|
||||||
aggr_get_iter.add_child_elem(query)
|
aggr_get_iter.add_child_elem(query)
|
||||||
|
result = None
|
||||||
try:
|
try:
|
||||||
result = self.server.invoke_successfully(aggr_get_iter, enable_tunneling=False)
|
result = self.server.invoke_successfully(aggr_get_iter, enable_tunneling=False)
|
||||||
except netapp_utils.zapi.NaApiError as error:
|
except netapp_utils.zapi.NaApiError as error:
|
||||||
# Error 13040 denotes an aggregate not being found.
|
# Error 13040 denotes an aggregate not being found.
|
||||||
if to_native(error.code) == "13040":
|
if to_native(error.code) == "13040":
|
||||||
return None
|
pass
|
||||||
else:
|
else:
|
||||||
self.module.fail_json(msg=to_native(error), exception=traceback.format_exc())
|
self.module.fail_json(msg=to_native(error), exception=traceback.format_exc())
|
||||||
return result
|
return result
|
||||||
|
@ -340,6 +361,16 @@ class NetAppOntapAggregate(object):
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.server.invoke_successfully(aggr_create, enable_tunneling=False)
|
self.server.invoke_successfully(aggr_create, enable_tunneling=False)
|
||||||
|
if self.parameters.get('wait_for_online'):
|
||||||
|
# round off time_out
|
||||||
|
retries = (self.parameters['time_out'] + 5) / 10
|
||||||
|
current = self.get_aggr()
|
||||||
|
status = None if current is None else current['service_state']
|
||||||
|
while status != 'online' and retries > 0:
|
||||||
|
time.sleep(10)
|
||||||
|
retries = retries - 1
|
||||||
|
current = self.get_aggr()
|
||||||
|
status = None if current is None else current['service_state']
|
||||||
except netapp_utils.zapi.NaApiError as error:
|
except netapp_utils.zapi.NaApiError as error:
|
||||||
self.module.fail_json(msg="Error provisioning aggregate %s: %s"
|
self.module.fail_json(msg="Error provisioning aggregate %s: %s"
|
||||||
% (self.parameters['name'], to_native(error)),
|
% (self.parameters['name'], to_native(error)),
|
||||||
|
|
|
@ -1,3 +1,6 @@
|
||||||
|
# (c) 2018-2019, NetApp, Inc
|
||||||
|
# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
|
||||||
|
|
||||||
""" unit tests for Ansible module: na_ontap_aggregate """
|
""" unit tests for Ansible module: na_ontap_aggregate """
|
||||||
|
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
@ -14,7 +17,7 @@ from ansible.modules.storage.netapp.na_ontap_aggregate \
|
||||||
import NetAppOntapAggregate as my_module # module under test
|
import NetAppOntapAggregate as my_module # module under test
|
||||||
|
|
||||||
if not netapp_utils.has_netapp_lib():
|
if not netapp_utils.has_netapp_lib():
|
||||||
pytestmark = pytest.skip('skipping as missing required netapp_lib')
|
pytestmark = pytest.mark.skip('skipping as missing required netapp_lib')
|
||||||
|
|
||||||
|
|
||||||
def set_module_args(args):
|
def set_module_args(args):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue