|
|
@ -201,11 +201,12 @@ def get_target(module, array):
|
|
|
|
def create_volume(module, array):
|
|
|
|
def create_volume(module, array):
|
|
|
|
"""Create Volume"""
|
|
|
|
"""Create Volume"""
|
|
|
|
changed = False
|
|
|
|
changed = False
|
|
|
|
|
|
|
|
volfact = []
|
|
|
|
api_version = array._list_available_rest_versions()
|
|
|
|
api_version = array._list_available_rest_versions()
|
|
|
|
if module.params['qos'] and QOS_API_VERSION in api_version:
|
|
|
|
if module.params['qos'] and QOS_API_VERSION in api_version:
|
|
|
|
if 549755813888 >= int(human_to_bytes(module.params['qos'])) >= 1048576:
|
|
|
|
if 549755813888 >= int(human_to_bytes(module.params['qos'])) >= 1048576:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
volume = array.create_volume(module.params['name'],
|
|
|
|
volfact = array.create_volume(module.params['name'],
|
|
|
|
module.params['size'],
|
|
|
|
module.params['size'],
|
|
|
|
bandwidth_limit=module.params['qos'])
|
|
|
|
bandwidth_limit=module.params['qos'])
|
|
|
|
changed = True
|
|
|
|
changed = True
|
|
|
@ -215,23 +216,23 @@ def create_volume(module, array):
|
|
|
|
module.fail_json(msg='QoS value {0} out of range.'.format(module.params['qos']))
|
|
|
|
module.fail_json(msg='QoS value {0} out of range.'.format(module.params['qos']))
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
volume = array.create_volume(module.params['name'], module.params['size'])
|
|
|
|
volfact = array.create_volume(module.params['name'], module.params['size'])
|
|
|
|
changed = True
|
|
|
|
changed = True
|
|
|
|
except Exception:
|
|
|
|
except Exception:
|
|
|
|
module.fail_json(msg='Volume {0} creation failed.'.format(module.params['name']))
|
|
|
|
module.fail_json(msg='Volume {0} creation failed.'.format(module.params['name']))
|
|
|
|
|
|
|
|
|
|
|
|
module.exit_json(changed=changed, volume=volume)
|
|
|
|
module.exit_json(changed=changed, volume=volfact)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def copy_from_volume(module, array):
|
|
|
|
def copy_from_volume(module, array):
|
|
|
|
"""Create Volume Clone"""
|
|
|
|
"""Create Volume Clone"""
|
|
|
|
changed = False
|
|
|
|
changed = False
|
|
|
|
|
|
|
|
volfact = []
|
|
|
|
tgt = get_target(module, array)
|
|
|
|
tgt = get_target(module, array)
|
|
|
|
|
|
|
|
|
|
|
|
if tgt is None:
|
|
|
|
if tgt is None:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
volume = array.copy_volume(module.params['name'],
|
|
|
|
volfact = array.copy_volume(module.params['name'],
|
|
|
|
module.params['target'])
|
|
|
|
module.params['target'])
|
|
|
|
changed = True
|
|
|
|
changed = True
|
|
|
|
except Exception:
|
|
|
|
except Exception:
|
|
|
@ -239,7 +240,7 @@ def copy_from_volume(module, array):
|
|
|
|
module.params['target']))
|
|
|
|
module.params['target']))
|
|
|
|
elif tgt is not None and module.params['overwrite']:
|
|
|
|
elif tgt is not None and module.params['overwrite']:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
volume = array.copy_volume(module.params['name'],
|
|
|
|
volfact = array.copy_volume(module.params['name'],
|
|
|
|
module.params['target'],
|
|
|
|
module.params['target'],
|
|
|
|
overwrite=module.params['overwrite'])
|
|
|
|
overwrite=module.params['overwrite'])
|
|
|
|
changed = True
|
|
|
|
changed = True
|
|
|
@ -247,12 +248,13 @@ def copy_from_volume(module, array):
|
|
|
|
module.fail_json(msg='Copy volume {0} to volume {1} failed.'.format(module.params['name'],
|
|
|
|
module.fail_json(msg='Copy volume {0} to volume {1} failed.'.format(module.params['name'],
|
|
|
|
module.params['target']))
|
|
|
|
module.params['target']))
|
|
|
|
|
|
|
|
|
|
|
|
module.exit_json(changed=changed, volume=volume)
|
|
|
|
module.exit_json(changed=changed, volume=volfact)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def update_volume(module, array):
|
|
|
|
def update_volume(module, array):
|
|
|
|
"""Update Volume size and/or QoS"""
|
|
|
|
"""Update Volume size and/or QoS"""
|
|
|
|
changed = False
|
|
|
|
changed = False
|
|
|
|
|
|
|
|
volfact = []
|
|
|
|
api_version = array._list_available_rest_versions()
|
|
|
|
api_version = array._list_available_rest_versions()
|
|
|
|
vol = array.get_volume(module.params['name'])
|
|
|
|
vol = array.get_volume(module.params['name'])
|
|
|
|
if QOS_API_VERSION in api_version:
|
|
|
|
if QOS_API_VERSION in api_version:
|
|
|
@ -263,7 +265,7 @@ def update_volume(module, array):
|
|
|
|
if human_to_bytes(module.params['size']) != vol['size']:
|
|
|
|
if human_to_bytes(module.params['size']) != vol['size']:
|
|
|
|
if human_to_bytes(module.params['size']) > vol['size']:
|
|
|
|
if human_to_bytes(module.params['size']) > vol['size']:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
volume = array.extend_volume(module.params['name'], module.params['size'])
|
|
|
|
volfact = array.extend_volume(module.params['name'], module.params['size'])
|
|
|
|
changed = True
|
|
|
|
changed = True
|
|
|
|
except Exception:
|
|
|
|
except Exception:
|
|
|
|
module.fail_json(msg='Volume {0} resize failed.'.format(module.params['name']))
|
|
|
|
module.fail_json(msg='Volume {0} resize failed.'.format(module.params['name']))
|
|
|
@ -271,13 +273,13 @@ def update_volume(module, array):
|
|
|
|
if human_to_bytes(module.params['qos']) != vol_qos['bandwidth_limit']:
|
|
|
|
if human_to_bytes(module.params['qos']) != vol_qos['bandwidth_limit']:
|
|
|
|
if module.params['qos'] == '0':
|
|
|
|
if module.params['qos'] == '0':
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
volume = array.set_volume(module.params['name'], bandwidth_limit='')
|
|
|
|
volfact = array.set_volume(module.params['name'], bandwidth_limit='')
|
|
|
|
changed = True
|
|
|
|
changed = True
|
|
|
|
except Exception:
|
|
|
|
except Exception:
|
|
|
|
module.fail_json(msg='Volume {0} QoS removal failed.'.format(module.params['name']))
|
|
|
|
module.fail_json(msg='Volume {0} QoS removal failed.'.format(module.params['name']))
|
|
|
|
elif 549755813888 >= int(human_to_bytes(module.params['qos'])) >= 1048576:
|
|
|
|
elif 549755813888 >= int(human_to_bytes(module.params['qos'])) >= 1048576:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
volume = array.set_volume(module.params['name'],
|
|
|
|
volfact = array.set_volume(module.params['name'],
|
|
|
|
bandwidth_limit=module.params['qos'])
|
|
|
|
bandwidth_limit=module.params['qos'])
|
|
|
|
changed = True
|
|
|
|
changed = True
|
|
|
|
except Exception:
|
|
|
|
except Exception:
|
|
|
@ -285,35 +287,37 @@ def update_volume(module, array):
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
module.fail_json(msg='QoS value {0} out of range. Check documentation.'.format(module.params['qos']))
|
|
|
|
module.fail_json(msg='QoS value {0} out of range. Check documentation.'.format(module.params['qos']))
|
|
|
|
|
|
|
|
|
|
|
|
module.exit_json(changed=changed, volume=volume)
|
|
|
|
module.exit_json(changed=changed, volume=volfact)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def delete_volume(module, array):
|
|
|
|
def delete_volume(module, array):
|
|
|
|
""" Delete Volume"""
|
|
|
|
""" Delete Volume"""
|
|
|
|
changed = False
|
|
|
|
changed = False
|
|
|
|
|
|
|
|
volfact = []
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
volume = array.destroy_volume(module.params['name'])
|
|
|
|
volume = array.destroy_volume(module.params['name'])
|
|
|
|
if module.params['eradicate']:
|
|
|
|
if module.params['eradicate']:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
volume = array.eradicate_volume(module.params['name'])
|
|
|
|
volfact = array.eradicate_volume(module.params['name'])
|
|
|
|
except Exception:
|
|
|
|
except Exception:
|
|
|
|
module.fail_json(msg='Eradicate volume {0} failed.'.format(module.params['name']))
|
|
|
|
module.fail_json(msg='Eradicate volume {0} failed.'.format(module.params['name']))
|
|
|
|
changed = True
|
|
|
|
changed = True
|
|
|
|
except Exception:
|
|
|
|
except Exception:
|
|
|
|
module.fail_json(msg='Delete volume {0} failed.'.format(module.params['name']))
|
|
|
|
module.fail_json(msg='Delete volume {0} failed.'.format(module.params['name']))
|
|
|
|
module.exit_json(changed=changed, volume=volume)
|
|
|
|
module.exit_json(changed=changed, volume=volfact)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def eradicate_volume(module, array):
|
|
|
|
def eradicate_volume(module, array):
|
|
|
|
""" Eradicate Deleted Volume"""
|
|
|
|
""" Eradicate Deleted Volume"""
|
|
|
|
changed = False
|
|
|
|
changed = False
|
|
|
|
|
|
|
|
volfact = []
|
|
|
|
if module.params['eradicate']:
|
|
|
|
if module.params['eradicate']:
|
|
|
|
try:
|
|
|
|
try:
|
|
|
|
volume = array.eradicate_volume(module.params['name'])
|
|
|
|
volume = array.eradicate_volume(module.params['name'])
|
|
|
|
changed = True
|
|
|
|
changed = True
|
|
|
|
except Exception:
|
|
|
|
except Exception:
|
|
|
|
module.fail_json(msg='Eradication of volume {0} failed'.format(module.params['name']))
|
|
|
|
module.fail_json(msg='Eradication of volume {0} failed'.format(module.params['name']))
|
|
|
|
module.exit_json(changed=changed, volume=volume)
|
|
|
|
module.exit_json(changed=changed, volume=volfact)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def main():
|
|
|
|
def main():
|
|
|
|