Update bare exceptions to specify Exception.

This will keep us from accidentally catching program-exiting exceptions
like KeyboardInterupt and SystemExit.
This commit is contained in:
Toshio Kuratomi 2018-09-07 17:59:46 -07:00
commit 3fba006207
320 changed files with 659 additions and 656 deletions

View file

@ -88,7 +88,7 @@ try:
from storops.exception import VNXCredentialError, VNXStorageGroupError, \
VNXAluAlreadyAttachedError, VNXAttachAluError, VNXDetachAluNotFoundError
HAS_LIB = True
except:
except Exception:
HAS_LIB = False

View file

@ -102,7 +102,7 @@ def get_filesystem(module, system):
"""Return Filesystem or None"""
try:
return system.filesystems.get(name=module.params['filesystem'])
except:
except Exception:
return None

View file

@ -104,7 +104,7 @@ def get_export(module, system):
try:
export = system.exports.get(export_path=module.params['export'])
except:
except Exception:
module.fail_json(msg="Export with export path {} not found".format(module.params['export']))
return export

View file

@ -76,7 +76,7 @@ def get_pool(module, system):
"""Return Pool or None"""
try:
return system.pools.get(name=module.params['pool'])
except:
except Exception:
return None
@ -85,7 +85,7 @@ def get_filesystem(module, system):
"""Return Filesystem or None"""
try:
return system.filesystems.get(name=module.params['name'])
except:
except Exception:
return None
@ -143,7 +143,7 @@ def main():
if module.params['size']:
try:
Capacity(module.params['size'])
except:
except Exception:
module.fail_json(msg='size (Physical Capacity) should be defined in MB, GB, TB or PB units')
state = module.params['state']

View file

@ -143,7 +143,7 @@ def main():
if module.params['volume']:
try:
system.volumes.get(name=module.params['volume'])
except:
except Exception:
module.fail_json(msg='Volume {} not found'.format(module.params['volume']))
if host and state == 'present':

View file

@ -95,7 +95,7 @@ def get_pool(module, system):
"""Return Pool on None"""
try:
return system.pools.get(name=module.params['name'])
except:
except Exception:
return None
@ -185,13 +185,13 @@ def main():
if module.params['size']:
try:
Capacity(module.params['size'])
except:
except Exception:
module.fail_json(msg='size (Physical Capacity) should be defined in MB, GB, TB or PB units')
if module.params['vsize']:
try:
Capacity(module.params['vsize'])
except:
except Exception:
module.fail_json(msg='vsize (Virtual Capacity) should be defined in MB, GB, TB or PB units')
state = module.params['state']

View file

@ -76,7 +76,7 @@ def get_pool(module, system):
"""Return Pool or None"""
try:
return system.pools.get(name=module.params['pool'])
except:
except Exception:
return None
@ -85,7 +85,7 @@ def get_volume(module, system):
"""Return Volume or None"""
try:
return system.volumes.get(name=module.params['name'])
except:
except Exception:
return None
@ -141,7 +141,7 @@ def main():
if module.params['size']:
try:
Capacity(module.params['size'])
except:
except Exception:
module.fail_json(msg='size (Physical Capacity) should be defined in MB, GB, TB or PB units')
state = module.params['state']

View file

@ -125,7 +125,7 @@ import time
HAS_SF_SDK = netapp_utils.has_sf_sdk()
try:
import solidfire.common
except:
except Exception:
HAS_SF_SDK = False

View file

@ -82,7 +82,7 @@ from ansible.module_utils.netapp_module import NetAppModule
HAS_SF_SDK = netapp_utils.has_sf_sdk()
try:
import solidfire.common
except:
except Exception:
HAS_SF_SDK = False

View file

@ -108,7 +108,7 @@ import ansible.module_utils.netapp as netapp_utils
HAS_SF_SDK = netapp_utils.has_sf_sdk()
try:
import solidfire.common
except:
except Exception:
HAS_SF_SDK = False

View file

@ -165,7 +165,7 @@ HAS_SF_SDK = netapp_utils.has_sf_sdk()
try:
from solidfire.models import Network, NetworkConfig
HAS_SF_SDK = True
except:
except Exception:
HAS_SF_SDK = False

View file

@ -187,7 +187,7 @@ HAS_SF_SDK = netapp_utils.has_sf_sdk()
try:
from solidfire.custom.models import DaysOfWeekFrequency, Weekday, DaysOfMonthFrequency
from solidfire.common import ApiServerError
except:
except Exception:
HAS_SF_SDK = False

View file

@ -112,7 +112,7 @@ from ansible.module_utils.netapp_elementsw_module import NaElementSWModule
HAS_SF_SDK = netapp_utils.has_sf_sdk()
try:
import solidfire.common
except:
except Exception:
HAS_SF_SDK = False

View file

@ -147,7 +147,7 @@ from ansible.module_utils.netapp_elementsw_module import NaElementSWModule
HAS_SF_SDK = netapp_utils.has_sf_sdk()
try:
import solidfire.common
except:
except Exception:
HAS_SF_SDK = False

View file

@ -116,7 +116,7 @@ from ansible.module_utils.netapp_module import NetAppModule
HAS_SF_SDK = netapp_utils.has_sf_sdk()
try:
import solidfire.common
except:
except Exception:
HAS_SF_SDK = False

View file

@ -150,7 +150,7 @@ class NetAppOntapVolumeClone(object):
clone_obj.add_new_child("volume", self.volume)
try:
results = self.server.invoke_successfully(clone_obj, True)
except:
except Exception:
return False
attributes = results.get_child_by_name('attributes')
info = attributes.get_child_by_name('volume-clone-info')

View file

@ -114,7 +114,7 @@ def request(url, data=None, headers=None, method='GET', use_proxy=True,
data = json.loads(raw_data)
else:
raw_data = None
except:
except Exception:
if ignore_errors:
pass
else:
@ -138,7 +138,7 @@ def has_match(module, ssid, api_url, api_pwd, api_usr, body, name):
try:
amg_rc, amgs = request(url, url_username=api_usr, url_password=api_pwd,
headers=HEADERS)
except:
except Exception:
module.fail_json(msg="Failed to find AMGs on storage array. Id [%s]" % (ssid))
for amg in amgs:

View file

@ -143,7 +143,7 @@ def request(url, data=None, headers=None, method='GET', use_proxy=True,
data = json.loads(raw_data)
else:
raw_data = None
except:
except Exception:
if ignore_errors:
pass
else:

View file

@ -110,7 +110,7 @@ from ansible.module_utils._text import to_native
try:
from urlparse import urlparse, urlunparse
except:
except Exception:
from urllib.parse import urlparse, urlunparse

View file

@ -120,7 +120,7 @@ def request(url, data=None, headers=None, method='GET', use_proxy=True,
data = json.loads(raw_data)
else:
raw_data = None
except:
except Exception:
if ignore_errors:
pass
else:
@ -207,7 +207,7 @@ def set_password(module, ssid, api_url, user, pwd, current_password=None, new_pa
try:
rc, data = request(url, method='POST', data=post_body, headers=HEADERS, url_username=user, url_password=pwd,
validate_certs=module.validate_certs)
except:
except Exception:
# TODO(lorenp): Resolve ignored rc, data
module.fail_json(msg="Wrong or no admin password supplied. Please update your playbook and try again")

View file

@ -89,7 +89,7 @@ def request(url, data=None, headers=None, method='GET', use_proxy=True,
data = json.loads(raw_data)
else:
data = None
except:
except Exception:
if ignore_errors:
pass
else:

View file

@ -118,7 +118,7 @@ def request(url, data=None, headers=None, method='GET', use_proxy=True,
data = json.loads(raw_data)
else:
raw_data = None
except:
except Exception:
if ignore_errors:
pass
else:

View file

@ -150,7 +150,7 @@ def request(url, data=None, headers=None, method='GET', use_proxy=True,
data = json.loads(raw_data)
else:
raw_data = None
except:
except Exception:
if ignore_errors:
pass
else:

View file

@ -159,7 +159,7 @@ def request(url, data=None, headers=None, method='GET', use_proxy=True,
data = json.loads(raw_data)
else:
raw_data = None
except:
except Exception:
if ignore_errors:
pass
else:

View file

@ -106,7 +106,7 @@ def request(url, data=None, headers=None, method='GET', use_proxy=True,
data = json.loads(raw_data)
else:
raw_data = None
except:
except Exception:
if ignore_errors:
pass
else:

View file

@ -133,7 +133,7 @@ def request(url, data=None, headers=None, method='GET', use_proxy=True,
data = json.loads(raw_data)
else:
raw_data = None
except:
except Exception:
if ignore_errors:
pass
else:

View file

@ -119,7 +119,7 @@ def request(url, data=None, headers=None, method='GET', use_proxy=True,
data = json.loads(raw_data)
else:
raw_data = None
except:
except Exception:
if ignore_errors:
pass
else:

View file

@ -81,7 +81,7 @@ def delete_dns(module, array):
try:
array.set_dns(domain='', nameservers=[])
changed = True
except:
except Exception:
module.fail_json(msg='Delete DNS settigs failed')
module.exit_json(changed=changed)
@ -95,7 +95,7 @@ def create_dns(module, array):
array.set_dns(domain=module.params['domain'],
nameservers=module.params['nameservers'][0:3])
changed = True
except:
except Exception:
module.fail_json(msg='Set DNS settings failed: Check configuration')
module.exit_json(changed=changed)

View file

@ -158,7 +158,7 @@ def enable_ds(module, array):
try:
array.enable_directory_service()
changed = True
except:
except Exception:
module.fail_json(msg='Enable Directory Service failed: Check Configuration')
module.exit_json(changed=changed)
@ -170,7 +170,7 @@ def disable_ds(module, array):
try:
array.disable_directory_service()
changed = True
except:
except Exception:
module.fail_json(msg='Disable Directory Service failed')
module.exit_json(changed=changed)
@ -190,7 +190,7 @@ def delete_ds(module, array):
array_admin_group="",
certificate="")
changed = True
except:
except Exception:
module.fail_json(msg='Delete Directory Service failed')
module.exit_json(changed=changed)
@ -215,7 +215,7 @@ def create_ds(module, array):
array_admin_group=module.params['aa_group'])
array.set_directory_service(enabled=module.params['enable'])
changed = True
except:
except Exception:
module.fail_json(msg='Create Directory Service failed: Check configuration')
module.exit_json(changed=changed)

View file

@ -125,7 +125,7 @@ def make_hostgroup(module, array):
try:
array.create_hgroup(module.params['hostgroup'])
except:
except Exception:
changed = False
if module.params['host']:
array.set_hgroup(module.params['hostgroup'], hostlist=module.params['host'])
@ -146,7 +146,7 @@ def update_hostgroup(module, array):
try:
array.set_hgroup(module.params['hostgroup'], addhostlist=new_hosts)
changed = True
except:
except Exception:
module.fail_josn(msg='Failed to add host(s) to hostgroup')
if module.params['volume']:
if volumes:
@ -156,14 +156,14 @@ def update_hostgroup(module, array):
try:
array.connect_hgroup(module.params['hostgroup'], cvol)
changed = True
except:
except Exception:
changed = False
else:
for cvol in module.params['volume']:
try:
array.connect_hgroup(module.params['hostgroup'], cvol)
changed = True
except:
except Exception:
changed = False
else:
if module.params['host']:
@ -172,7 +172,7 @@ def update_hostgroup(module, array):
try:
array.set_hgroup(module.params['hostgroup'], remhostlist=old_hosts)
changed = True
except:
except Exception:
changed = False
if module.params['volume']:
old_volumes = list(set(module.params['volume']).difference(set([vol['name'] for vol in volumes])))
@ -180,7 +180,7 @@ def update_hostgroup(module, array):
try:
array.disconnect_hgroup(module.params['hostgroup'], cvol)
changed = True
except:
except Exception:
changed = False
module.exit_json(changed=changed)
@ -193,18 +193,18 @@ def delete_hostgroup(module, array):
for vol in vols:
try:
array.disconnect_hgroup(module.params['hostgroup'], vol["vol"])
except:
except Exception:
changed = False
host = array.get_hgroup(module.params['hostgroup'])
try:
array.set_hgroup(module.params['hostgroup'], remhostlist=host['hosts'])
try:
array.delete_hgroup(module.params['hostgroup'])
except:
except Exception:
changed = False
except:
except Exception:
changed = False
except:
except Exception:
changed = False
module.exit_json(changed=changed)
@ -231,14 +231,14 @@ def main():
try:
for hst in module.params['host']:
array.get_host(hst)
except:
except Exception:
module.fail_json(msg='Host {0} not found'.format(hst))
if module.params['volume']:
try:
for vol in module.params['volume']:
array.get_volume(vol)
except:
except Exception:
module.fail_json(msg='Volume {0} not found'.format(vol))
if hostgroup and state == 'present':

View file

@ -159,21 +159,21 @@ def _set_host_initiators(module, array):
try:
array.set_host(module.params['host'],
nqnlist=module.params['nqn'])
except:
except Exception:
module.fail_json(msg='Setting of NVMeF NQN failed.')
if module.params['protocol'] in ['iscsi', 'mixed']:
if module.params['iqn']:
try:
array.set_host(module.params['host'],
iqnlist=module.params['iqn'])
except:
except Exception:
module.fail_json(msg='Setting of iSCSI IQN failed.')
if module.params['protocol'] in ['fc', 'mixed']:
if module.params['wwns']:
try:
array.set_host(module.params['host'],
wwnlist=module.params['wwns'])
except:
except Exception:
module.fail_json(msg='Setting of FC WWNs failed.')
@ -184,21 +184,21 @@ def _update_host_initiators(module, array):
try:
array.set_host(module.params['host'],
nqnlist=module.params['nqn'])
except:
except Exception:
module.fail_json(msg='Change of NVMeF NQN failed.')
if module.params['protocol'] in ['iscsi', 'mixed']:
if module.params['iqn']:
try:
array.set_host(module.params['host'],
iqnlist=module.params['iqn'])
except:
except Exception:
module.fail_json(msg='Change of iSCSI IQN failed.')
if module.params['protocol'] in ['fc', 'mixed']:
if module.params['wwns']:
try:
array.set_host(module.params['host'],
addwwnlist=module.params['wwns'])
except:
except Exception:
module.fail_json(msg='FC WWN additiona failed.')
@ -211,7 +211,7 @@ def _connect_new_volume(module, array, answer=False):
module.params['volume'],
lun=module.params['lun'])
answer = True
except:
except Exception:
module.fail_json(msg='LUN ID {0} invalid. Check for duplicate LUN IDs.'.format(module.params['lun']))
else:
array.connect_host(module.params['host'], module.params['volume'])
@ -260,7 +260,7 @@ def make_host(module, array):
try:
array.create_host(module.params['host'])
changed = True
except:
except Exception:
module.fail_json(msg='Host {0} creation failed.'.format(module.params['host']))
try:
_set_host_initiators(module, array)
@ -274,7 +274,7 @@ def make_host(module, array):
lun=module.params['lun'])
else:
array.connect_host(module.params['host'], module.params['volume'])
except:
except Exception:
module.fail_json(msg='Host {0} configuration failed.'.format(module.params['host']))
module.exit_json(changed=changed)
@ -303,7 +303,7 @@ def delete_host(module, array):
array.disconnect_host(module.params['host'], vol["vol"])
array.delete_host(module.params['host'])
changed = True
except:
except Exception:
module.fail_json(msg='Host {0} deletion failed'.format(module.params['host']))
module.exit_json(changed=changed)
@ -341,7 +341,7 @@ def main():
if module.params['volume']:
try:
array.get_volume(module.params['volume'])
except:
except Exception:
module.fail_json(msg='Volume {} not found'.format(module.params['volume']))
if host is None and state == 'present':

View file

@ -79,7 +79,7 @@ def delete_ntp(module, array):
try:
array.set(ntpserver=[])
changed = True
except:
except Exception:
module.fail_json(msg='Deletion of NTP servers failed')
module.exit_json(changed=changed)
@ -92,7 +92,7 @@ def create_ntp(module, array):
try:
array.set(ntpserver=module.params['ntp_servers'][0:4])
changed = True
except:
except Exception:
module.fail_json(msg='Update of NTP servers failed')
module.exit_json(changed=changed)

View file

@ -174,36 +174,36 @@ def make_pgroup(module, array):
if set(module.params['target'][0:4]).issubset(connected_arrays):
try:
array.create_pgroup(module.params['pgroup'], targetlist=[module.params['target'][0:4]])
except:
except Exception:
module.fail_json(msg='Creation of replicated pgroup {0} failed.'.format(module.params['pgroup']))
else:
module.fail_json(msg='Target arrays {0} not connected to source array.'.format(module.params['target']))
else:
try:
array.create_pgroup(module.params['pgroup'])
except:
except Exception:
module.fail_json(msg='Creation of pgroup {0} failed.'.format(module.params['pgroup']))
try:
if module.params['target']:
array.set_pgroup(module.params['pgroup'], replicate_enabled=module.params['enabled'])
else:
array.set_pgroup(module.params['pgroup'], snap_enabled=module.params['enabled'])
except:
except Exception:
module.fail_json(msg='Enabling pgroup {0} failed.'.format(module.params['pgroup']))
if module.params['volume']:
try:
array.set_pgroup(module.params['pgroup'], vollist=module.params['volume'])
except:
except Exception:
module.fail_json(msg='Adding volumes to pgroup {0} failed.'.format(module.params['pgroup']))
if module.params['host']:
try:
array.set_pgroup(module.params['pgroup'], hostlist=module.params['host'])
except:
except Exception:
module.fail_json(msg='Adding hosts to pgroup {0} failed.'.format(module.params['pgroup']))
if module.params['hostgroup']:
try:
array.set_pgroup(module.params['pgroup'], hgrouplist=module.params['hostgroup'])
except:
except Exception:
module.fail_json(msg='Adding hostgroups to pgroup {0} failed.'.format(module.params['pgroup']))
changed = True
module.exit_json(changed=changed)
@ -220,20 +220,20 @@ def update_pgroup(module, array):
try:
array.set_pgroup(module.params['pgroup'], targetlist=[module.params['target'][0:4]])
changed = True
except:
except Exception:
module.fail_json(msg='Changing targets for pgroup {0} failed.'.format(module.params['pgroup']))
if module.params['target'] and module.params['enabled'] != get_pgroup_sched(module, array)['replicate_enabled']:
try:
array.set_pgroup(module.params['pgroup'], replicate_enabled=module.params['enabled'])
changed = True
except:
except Exception:
module.fail_json(msg='Changing enabled status of pgroup {0} failed.'.format(module.params['pgroup']))
elif not module.params['target'] and module.params['enabled'] != get_pgroup_sched(module, array)['snap_enabled']:
try:
array.set_pgroup(module.params['pgroup'], snap_enabled=module.params['enabled'])
changed = True
except:
except Exception:
module.fail_json(msg='Changing enabled status of pgroup {0} failed.'.format(module.params['pgroup']))
if module.params['volume'] and get_pgroup(module, array)['hosts'] is None and get_pgroup(module, array)['hgroups'] is None:
@ -241,14 +241,14 @@ def update_pgroup(module, array):
try:
array.set_pgroup(module.params['pgroup'], vollist=module.params['volume'])
changed = True
except:
except Exception:
module.fail_json(msg='Adding volumes to pgroup {0} failed.'.format(module.params['pgroup']))
else:
if not all(x in get_pgroup(module, array)['volumes'] for x in module.params['volume']):
try:
array.set_pgroup(module.params['pgroup'], vollist=module.params['volume'])
changed = True
except:
except Exception:
module.fail_json(msg='Changing volumes in pgroup {0} failed.'.format(module.params['pgroup']))
if module.params['host'] and get_pgroup(module, array)['volumes'] is None and get_pgroup(module, array)['hgroups'] is None:
@ -256,14 +256,14 @@ def update_pgroup(module, array):
try:
array.set_pgroup(module.params['pgroup'], hostlist=module.params['host'])
changed = True
except:
except Exception:
module.fail_json(msg='Adding hosts to pgroup {0} failed.'.format(module.params['pgroup']))
else:
if not all(x in get_pgroup(module, array)['hosts'] for x in module.params['host']):
try:
array.set_pgroup(module.params['pgroup'], hostlist=module.params['host'])
changed = True
except:
except Exception:
module.fail_json(msg='Changing hosts in pgroup {0} failed.'.format(module.params['pgroup']))
if module.params['hostgroup'] and get_pgroup(module, array)['hosts'] is None and get_pgroup(module, array)['volumes'] is None:
@ -271,14 +271,14 @@ def update_pgroup(module, array):
try:
array.set_pgroup(module.params['pgroup'], hgrouplist=module.params['hostgroup'])
changed = True
except:
except Exception:
module.fail_json(msg='Adding hostgroups to pgroup {0} failed.'.format(module.params['pgroup']))
else:
if not all(x in get_pgroup(module, array)['hgroups'] for x in module.params['hostgroup']):
try:
array.set_pgroup(module.params['pgroup'], hgrouplist=module.params['hostgroup'])
changed = True
except:
except Exception:
module.fail_json(msg='Changing hostgroups in pgroup {0} failed.'.format(module.params['pgroup']))
module.exit_json(changed=changed)
@ -319,14 +319,14 @@ def main():
try:
for hst in module.params['host']:
array.get_host(hst)
except:
except Exception:
module.fail_json(msg='Host {} not found'.format(hst))
if module.params['hostgroup']:
try:
for hstg in module.params['hostgroup']:
array.get_hgroup(hstg)
except:
except Exception:
module.fail_json(msg='Hostgroup {} not found'.format(hstg))
if pgroup and state == 'present':

View file

@ -112,7 +112,7 @@ def get_pgroup(module, array):
"""Return Protection Group or None"""
try:
return array.get_pgroup(module.params['name'])
except:
except Exception:
return None
@ -123,7 +123,7 @@ def get_pgroupvolume(module, array):
for volume in pgroup['volumes']:
if volume == module.params['restore']:
return volume
except:
except Exception:
return None
@ -134,7 +134,7 @@ def get_rpgsnapshot(module, array):
for snap in array.list_volumes(snap='true'):
if snap['name'] == snapname:
return snapname
except:
except Exception:
return None
@ -145,7 +145,7 @@ def get_pgsnapshot(module, array):
for snap in array.get_pgroup(module.params['name'], snap='true'):
if snap['name'] == snapname:
return snapname
except:
except Exception:
return None
@ -157,7 +157,7 @@ def create_pgsnapshot(module, array):
snap=True,
apply_retention=True)
changed = True
except:
except Exception:
changed = False
module.exit_json(changed=changed)
@ -168,7 +168,7 @@ def restore_pgsnapvolume(module, array):
try:
array.copy_volume(volume, module.params['target'], overwrite=module.params['overwrite'])
changed = True
except:
except Exception:
changed = False
module.exit_json(changed=changed)
@ -189,9 +189,9 @@ def delete_pgsnapshot(module, array):
try:
array.eradicate_pgroup(snapname)
changed = True
except:
except Exception:
changed = False
except:
except Exception:
changed = False
module.exit_json(changed=changed)

View file

@ -65,14 +65,14 @@ def enable_ra(module, array):
ra_facts['fa_ra'] = {'name': ra_data['name'],
'port': ra_data['port']}
changed = True
except:
except Exception:
module.fail_json(msg='Enabling Remote Assist failed')
else:
try:
ra_data = array.get_remote_assist_status()
ra_facts['fa_ra'] = {'name': ra_data['name'],
'port': ra_data['port']}
except:
except Exception:
module.fail_json(msg='Getting Remote Assist failed')
module.exit_json(changed=changed, ansible_facts=ra_facts)
@ -84,7 +84,7 @@ def disable_ra(module, array):
try:
array.disable_remote_assist()
changed = True
except:
except Exception:
module.fail_json(msg='Disabling Remote Assist failed')
module.exit_json(changed=changed)

View file

@ -107,7 +107,7 @@ def get_volume(module, array):
"""Return Volume or None"""
try:
return array.get_volume(module.params['name'])
except:
except Exception:
return None
@ -115,7 +115,7 @@ def get_target(module, array):
"""Return Volume or None"""
try:
return array.get_volume(module.params['target'])
except:
except Exception:
return None
@ -126,7 +126,7 @@ def get_snapshot(module, array):
for s in array.get_volume(module.params['name'], snap='true'):
if s['name'] == snapname:
return snapname
except:
except Exception:
return None
@ -136,7 +136,7 @@ def create_snapshot(module, array):
if not module.check_mode:
try:
array.create_snapshot(module.params['name'], suffix=module.params['suffix'])
except:
except Exception:
changed = False
module.exit_json(changed=changed)
@ -177,9 +177,9 @@ def delete_snapshot(module, array):
if module.params['eradicate']:
try:
array.eradicate_volume(snapname)
except:
except Exception:
changed = False
except:
except Exception:
changed = False
module.exit_json(changed=changed)

View file

@ -135,7 +135,7 @@ def get_volume(module, array):
"""Return Volume or None"""
try:
return array.get_volume(module.params['name'])
except:
except Exception:
return None
@ -146,7 +146,7 @@ def get_destroyed_volume(module, array):
return True
else:
return False
except:
except Exception:
return False
@ -154,7 +154,7 @@ def get_target(module, array):
"""Return Volume or None"""
try:
return array.get_volume(module.params['target'])
except:
except Exception:
return None
@ -167,7 +167,7 @@ def create_volume(module, array):
array.create_volume(module.params['name'], module.params['size'],
bandwidth_limit=module.params['qos'])
changed = True
except:
except Exception:
module.fail_json(msg='Volume {0} creation failed.'.format(module.params['name']))
else:
module.fail_json(msg='QoS value {0} out of range.'.format(module.params['qos']))
@ -175,7 +175,7 @@ def create_volume(module, array):
try:
array.create_volume(module.params['name'], module.params['size'])
changed = True
except:
except Exception:
module.fail_json(msg='Volume {0} creation failed.'.format(module.params['name']))
module.exit_json(changed=changed)
@ -192,7 +192,7 @@ def copy_from_volume(module, array):
array.copy_volume(module.params['name'],
module.params['target'])
changed = True
except:
except Exception:
module.fail_json(msg='Copy volume {0} to volume {1} failed.'.format(module.params['name'],
module.params['target']))
elif tgt is not None and module.params['overwrite']:
@ -201,7 +201,7 @@ def copy_from_volume(module, array):
module.params['target'],
overwrite=module.params['overwrite'])
changed = True
except:
except Exception:
module.fail_json(msg='Copy volume {0} to volume {1} failed.'.format(module.params['name'],
module.params['target']))
@ -221,7 +221,7 @@ def update_volume(module, array):
try:
array.extend_volume(module.params['name'], module.params['size'])
changed = True
except:
except Exception:
module.fail_json(msg='Volume {0} resize failed.'.format(module.params['name']))
if module.params['qos']:
if human_to_bytes(module.params['qos']) != vol_qos['bandwidth_limit']:
@ -230,7 +230,7 @@ def update_volume(module, array):
array.set_volume(module.params['name'],
bandwidth_limit=module.params['qos'])
changed = True
except:
except Exception:
module.fail_json(msg='Volume {0} QoS change failed.'.format(module.params['name']))
else:
module.fail_json(msg='QoS value {0} out of range. Check documentation.'.format(module.params['qos']))
@ -247,10 +247,10 @@ def delete_volume(module, array):
if module.params['eradicate']:
try:
array.eradicate_volume(module.params['name'])
except:
except Exception:
module.fail_json(msg='Eradicate volume {0} failed.'.format(module.params['name']))
changed = True
except:
except Exception:
module.fail_json(msg='Delete volume {0} failed.'.format(module.params['name']))
module.exit_json(changed=changed)
@ -261,7 +261,7 @@ def eradicate_volume(module, array):
try:
array.eradicate_volume(module.params['name'])
changed = True
except:
except Exception:
module.fail_json(msg='Eradication of volume {0} failed'.format(module.params['name']))
module.exit_json(changed=changed)

View file

@ -124,7 +124,7 @@ def create_bucket(module, blade):
attr.account = Reference(name=module.params['account'])
blade.buckets.create_buckets(names=[module.params['name']], account=attr)
changed = True
except:
except Exception:
module.fail_json(msg='Object Store Bucket {0}: Creation failed'.format(module.params['name']))
module.exit_json(changed=changed)
@ -140,9 +140,9 @@ def delete_bucket(module, blade):
try:
blade.buckets.delete_buckets(names=[module.params['name']])
changed = True
except:
except Exception:
module.fail_json(msg='Object Store Bucket {0}: Eradication failed'.format(module.params['name']))
except:
except Exception:
module.fail_json(msg='Object Store Bucket {0}: Deletion failed'.format(module.params['name']))
module.exit_json(changed=changed)
@ -154,7 +154,7 @@ def recover_bucket(module, blade):
blade.buckets.update_buckets(names=[module.params['name']],
destroyed=Bucket(destroyed=False))
changed = True
except:
except Exception:
module.fail_json(msg='Object Store Bucket {0}: Recovery failed'.format(module.params['name']))
module.exit_json(changed=changed)
@ -165,7 +165,7 @@ def eradicate_bucket(module, blade):
try:
blade.buckets.delete_buckets(names=[module.params['name']])
changed = True
except:
except Exception:
module.fail_json(msg='Object Store Bucket {0}: Eradication failed'.format(module.params['name']))
module.exit_json(changed=changed)

View file

@ -100,7 +100,7 @@ def update_role(module, blade):
blade.directory_services.update_directory_services_roles(names=[module.params['role']],
directory_service_role=role)
changed = True
except:
except Exception:
module.fail_json(msg='Update Directory Service Role {0} failed'.format(module.params['role']))
module.exit_json(changed=changed)
@ -114,7 +114,7 @@ def delete_role(module, blade):
blade.directory_services.update_directory_services_roles(names=[module.params['role']],
directory_service_role=role)
changed = True
except:
except Exception:
module.fail_json(msg='Delete Directory Service Role {0} failed'.format(module.params['role']))
module.exit_json(changed=changed)
@ -128,7 +128,7 @@ def create_role(module, blade):
blade.directory_services.update_directory_services_roles(names=[module.params['role']],
directory_service_role=role)
changed = True
except:
except Exception:
module.fail_json(msg='Create Directory Service Role {0} failed: Check configuration'.format(module.params['role']))
module.exit_json(changed=changed)

View file

@ -160,7 +160,7 @@ def get_fs(module, blade):
try:
res = blade.file_systems.list_file_systems(names=fs)
return res.items[0]
except:
except Exception:
return None
@ -196,7 +196,7 @@ def create_fs(module, blade):
)
blade.file_systems.create_file_systems(fs_obj)
changed = True
except:
except Exception:
changed = False
module.exit_json(changed=changed)
@ -257,7 +257,7 @@ def modify_fs(module, blade):
n_attr = FileSystem(**attr)
try:
blade.file_systems.update_file_systems(name=module.params['name'], attributes=n_attr)
except:
except Exception:
changed = False
module.exit_json(changed=changed)
@ -277,9 +277,9 @@ def delete_fs(module, blade):
try:
blade.file_systems.delete_file_systems(module.params['name'])
changed = True
except:
except Exception:
changed = False
except:
except Exception:
changed = False
module.exit_json(changed=changed)
@ -290,7 +290,7 @@ def eradicate_fs(module, blade):
try:
blade.file_systems.delete_file_systems(module.params['name'])
changed = True
except:
except Exception:
changed = False
module.exit_json(changed=changed)

View file

@ -102,7 +102,7 @@ def get_iface(module, blade):
try:
res = blade.network_interfaces.list_network_interfaces(names=iface)
return res.items[0]
except:
except Exception:
return None
@ -121,7 +121,7 @@ def create_iface(module, blade):
)
)
changed = True
except:
except Exception:
module.fail_json(msg='Interface creation failed. Check valid subnet exists for IP address {0}'.format(module.params['address']))
changed = False
module.exit_json(changed=changed)
@ -138,7 +138,7 @@ def modify_iface(module, blade):
blade.network_interfaces.update_network_interfaces(names=iface_new,
network_interface=NetworkInterface(address=module.params['address']))
changed = True
except:
except Exception:
changed = False
module.exit_json(changed=changed)
@ -150,7 +150,7 @@ def delete_iface(module, blade):
try:
blade.network_interfaces.delete_network_interfaces(names=iface)
changed = True
except:
except Exception:
changed = False
module.exit_json(changed=changed)

View file

@ -81,7 +81,7 @@ def create_s3acc(module, blade):
try:
blade.object_store_accounts.create_object_store_accounts(names=[module.params['name']])
changed = True
except:
except Exception:
module.fail_json(msg='Object Store Account {0}: Creation failed'.format(module.params['name']))
module.exit_json(changed=changed)
@ -96,7 +96,7 @@ def delete_s3acc(module, blade):
try:
blade.object_store_accounts.delete_object_store_accounts(names=[module.params['name']])
changed = True
except:
except Exception:
module.fail_json(msg='Object Store Account {0}: Deletion failed'.format(module.params['name']))
module.exit_json(changed=changed)

View file

@ -113,7 +113,7 @@ def update_s3user(module, blade):
s3user_facts['fb_s3user'] = {'user': user,
'access_key': result.items[0].secret_access_key,
'access_id': result.items[0].name}
except:
except Exception:
delete_s3user(module, blade)
module.fail_json(msg='Object Store User {0}: Creation failed'.format(user))
changed = True
@ -134,11 +134,11 @@ def create_s3user(module, blade):
s3user_facts['fb_s3user'] = {'user': user,
'access_key': result.items[0].secret_access_key,
'access_id': result.items[0].name}
except:
except Exception:
delete_s3user(module, blade)
module.fail_json(msg='Object Store User {0}: Creation failed'.format(user))
changed = True
except:
except Exception:
module.fail_json(msg='Object Store User {0}: Creation failed'.format(user))
module.exit_json(changed=changed, ansible_facts=s3user_facts)
@ -150,7 +150,7 @@ def delete_s3user(module, blade):
try:
blade.object_store_users.delete_object_store_users(names=[user])
changed = True
except:
except Exception:
module.fail_json(msg='Object Store Account {0}: Deletion failed'.format(module.params['name']))
module.exit_json(changed=changed)

View file

@ -99,7 +99,7 @@ def get_fs(module, blade):
try:
res = blade.file_systems.list_file_systems(names=fs)
return res.items[0]
except:
except Exception:
return None
@ -109,7 +109,7 @@ def get_fssnapshot(module, blade):
filt = 'source=\'' + module.params['name'] + '\' and suffix=\'' + module.params['suffix'] + '\''
res = blade.file_system_snapshots.list_file_system_snapshots(filter=filt)
return res.items[0]
except:
except Exception:
return None
@ -121,7 +121,7 @@ def create_snapshot(module, blade):
try:
blade.file_system_snapshots.create_file_system_snapshots(sources=source, suffix=SnapshotSuffix(module.params['suffix']))
changed = True
except:
except Exception:
changed = False
module.exit_json(changed=changed)
@ -134,7 +134,7 @@ def recover_snapshot(module, blade):
try:
blade.file_system_snapshots.update_file_system_snapshots(name=snapname, attributes=new_attr)
changed = True
except:
except Exception:
changed = False
module.exit_json(changed=changed)
@ -157,9 +157,9 @@ def delete_snapshot(module, blade):
try:
blade.file_system_snapshots.delete_file_system_snapshots(name=snapname)
changed = True
except:
except Exception:
changed = False
except:
except Exception:
changed = False
module.exit_json(changed=changed)
@ -171,7 +171,7 @@ def eradicate_snapshot(module, blade):
try:
blade.file_system_snapshots.delete_file_system_snapshots(name=snapname)
changed = True
except:
except Exception:
changed = False
module.exit_json(changed=changed)

View file

@ -118,7 +118,7 @@ def get_subnet(module, blade):
try:
res = blade.subnets.list_subnets(names=subnet)
return res.items[0]
except:
except Exception:
return None
@ -136,7 +136,7 @@ def create_subnet(module, blade):
)
)
changed = True
except:
except Exception:
module.fail_json(msg='Failed to create subnet {0}. Confirm supplied parameters'.format(module.params['name']))
module.exit_json(changed=changed)
@ -153,7 +153,7 @@ def modify_subnet(module, blade):
blade.subnets.update_subnets(names=subnet_new,
subnet=Subnet(prefix=module.params['prefix']))
changed = True
except:
except Exception:
module.fail_json(msg='Failed to change subnet {0} prefix to {1}'.format(module.params['name'],
module.params['prefix']))
if module.params['vlan']:
@ -162,7 +162,7 @@ def modify_subnet(module, blade):
blade.subnets.update_subnets(names=subnet_new,
subnet=Subnet(vlan=module.params['vlan']))
changed = True
except:
except Exception:
module.fail_json(msg='Failed to change subnet {0} VLAN to {1}'.format(module.params['name'],
module.params['vlan']))
if module.params['gateway']:
@ -171,7 +171,7 @@ def modify_subnet(module, blade):
blade.subnets.update_subnets(names=subnet_new,
subnet=Subnet(gateway=module.params['gateway']))
changed = True
except:
except Exception:
module.fail_json(msg='Failed to change subnet {0} gateway to {1}'.format(module.params['name'],
module.params['gateway']))
if module.params['mtu']:
@ -180,7 +180,7 @@ def modify_subnet(module, blade):
blade.subnets.update_subnets(names=subnet_new,
subnet=Subnet(mtu=module.params['mtu']))
changed = True
except:
except Exception:
module.fail_json(msg='Failed to change subnet {0} MTU to {1}'.format(module.params['name'],
module.params['mtu']))
module.exit_json(changed=changed)
@ -193,7 +193,7 @@ def delete_subnet(module, blade):
try:
blade.subnets.delete_subnets(names=subnet)
changed = True
except:
except Exception:
changed = False
module.exit_json(changed=changed)