mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-05-07 22:02:50 +00:00
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:
@@ -330,11 +330,11 @@ def get_instance_info(inst):
|
||||
|
||||
try:
|
||||
netname = inst.extra['networkInterfaces'][0]['network'].split('/')[-1]
|
||||
except:
|
||||
except Exception:
|
||||
netname = None
|
||||
try:
|
||||
subnetname = inst.extra['networkInterfaces'][0]['subnetwork'].split('/')[-1]
|
||||
except:
|
||||
except Exception:
|
||||
subnetname = None
|
||||
if 'disks' in inst.extra:
|
||||
disk_names = [disk_info['source'].split('/')[-1]
|
||||
|
||||
@@ -239,7 +239,7 @@ def main():
|
||||
zone, node_name = node.split('/')
|
||||
nodes.append(gce.ex_get_node(node_name, zone))
|
||||
output_nodes.append(node)
|
||||
except:
|
||||
except Exception:
|
||||
# skip nodes that are badly formatted or don't exist
|
||||
pass
|
||||
try:
|
||||
|
||||
@@ -188,7 +188,7 @@ def main():
|
||||
is_attached = True
|
||||
json_output['attached_mode'] = d['mode']
|
||||
json_output['attached_to_instance'] = inst.name
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# find disk if it already exists
|
||||
@@ -210,7 +210,7 @@ def main():
|
||||
size_gb = int(round(float(size_gb)))
|
||||
if size_gb < 1:
|
||||
raise Exception
|
||||
except:
|
||||
except Exception:
|
||||
module.fail_json(msg="Must supply a size_gb larger than 1 GB",
|
||||
changed=False)
|
||||
|
||||
|
||||
@@ -203,7 +203,7 @@ def _validate_params(params):
|
||||
try:
|
||||
check_params(params, fields)
|
||||
_validate_backend_params(params['backends'])
|
||||
except:
|
||||
except Exception:
|
||||
raise
|
||||
|
||||
return (True, '')
|
||||
@@ -233,7 +233,7 @@ def _validate_backend_params(backends):
|
||||
for backend in backends:
|
||||
try:
|
||||
check_params(backend, fields)
|
||||
except:
|
||||
except Exception:
|
||||
raise
|
||||
|
||||
if 'max_rate' in backend and 'max_rate_per_instance' in backend:
|
||||
|
||||
@@ -178,7 +178,7 @@ def get_global_forwarding_rule(client, name, project_id=None):
|
||||
req = client.globalForwardingRules().get(
|
||||
project=project_id, forwardingRule=name)
|
||||
return GCPUtils.execute_api_client_req(req, raise_404=False)
|
||||
except:
|
||||
except Exception:
|
||||
raise
|
||||
|
||||
|
||||
@@ -204,7 +204,7 @@ def create_global_forwarding_rule(client, params, project_id):
|
||||
name=params['forwarding_rule_name'],
|
||||
project_id=project_id)
|
||||
return (True, return_data)
|
||||
except:
|
||||
except Exception:
|
||||
raise
|
||||
|
||||
|
||||
@@ -229,7 +229,7 @@ def delete_global_forwarding_rule(client, name, project_id):
|
||||
project=project_id, forwardingRule=name)
|
||||
return_data = GCPUtils.execute_api_client_req(req, client)
|
||||
return (True, return_data)
|
||||
except:
|
||||
except Exception:
|
||||
raise
|
||||
|
||||
|
||||
@@ -270,7 +270,7 @@ def update_global_forwarding_rule(client, forwarding_rule, params, name, project
|
||||
return_data = GCPUtils.execute_api_client_req(
|
||||
req, client=client, raw=False)
|
||||
return (True, return_data)
|
||||
except:
|
||||
except Exception:
|
||||
raise
|
||||
|
||||
|
||||
|
||||
@@ -261,7 +261,7 @@ def get_healthcheck(client, name, project_id=None, resource_type='HTTP'):
|
||||
args = {'project': project_id, entity_name: name}
|
||||
req = resource.get(**args)
|
||||
return GCPUtils.execute_api_client_req(req, raise_404=False)
|
||||
except:
|
||||
except Exception:
|
||||
raise
|
||||
|
||||
|
||||
@@ -289,7 +289,7 @@ def create_healthcheck(client, params, project_id, resource_type='HTTP'):
|
||||
name=params['healthcheck_name'],
|
||||
project_id=project_id)
|
||||
return (True, return_data)
|
||||
except:
|
||||
except Exception:
|
||||
raise
|
||||
|
||||
|
||||
@@ -315,7 +315,7 @@ def delete_healthcheck(client, name, project_id, resource_type='HTTP'):
|
||||
req = resource.delete(**args)
|
||||
return_data = GCPUtils.execute_api_client_req(req, client)
|
||||
return (True, return_data)
|
||||
except:
|
||||
except Exception:
|
||||
raise
|
||||
|
||||
|
||||
@@ -356,7 +356,7 @@ def update_healthcheck(client, healthcheck, params, name, project_id,
|
||||
return_data = GCPUtils.execute_api_client_req(
|
||||
req, client=client, raw=False)
|
||||
return (True, return_data)
|
||||
except:
|
||||
except Exception:
|
||||
raise
|
||||
|
||||
|
||||
|
||||
@@ -161,7 +161,7 @@ def create_target_http_proxy(client, params, project_id):
|
||||
name=params['target_proxy_name'],
|
||||
project_id=project_id)
|
||||
return (True, return_data)
|
||||
except:
|
||||
except Exception:
|
||||
raise
|
||||
|
||||
|
||||
@@ -186,7 +186,7 @@ def delete_target_http_proxy(client, name, project_id):
|
||||
project=project_id, targetHttpProxy=name)
|
||||
return_data = GCPUtils.execute_api_client_req(req, client)
|
||||
return (True, return_data)
|
||||
except:
|
||||
except Exception:
|
||||
raise
|
||||
|
||||
|
||||
@@ -227,7 +227,7 @@ def update_target_http_proxy(client, target_proxy, params, name, project_id):
|
||||
return_data = GCPUtils.execute_api_client_req(
|
||||
req, client=client, raw=False)
|
||||
return (True, return_data)
|
||||
except:
|
||||
except Exception:
|
||||
raise
|
||||
|
||||
|
||||
|
||||
@@ -178,7 +178,7 @@ def _validate_params(params):
|
||||
_validate_path_matcher_params(params['path_matchers'])
|
||||
if 'host_rules' in params and params['host_rules'] is not None:
|
||||
_validate_host_rules_params(params['host_rules'])
|
||||
except:
|
||||
except Exception:
|
||||
raise
|
||||
|
||||
return (True, '')
|
||||
@@ -220,7 +220,7 @@ def _validate_path_matcher_params(path_matchers):
|
||||
if not path.startswith('/'):
|
||||
raise ValueError("path for %s must start with /" % (
|
||||
pm['name']))
|
||||
except:
|
||||
except Exception:
|
||||
raise
|
||||
|
||||
return (True, '')
|
||||
@@ -259,7 +259,7 @@ def _validate_host_rules_params(host_rules):
|
||||
raise ValueError("wildcard be followed by a '.' or '-', %s" % (
|
||||
host))
|
||||
|
||||
except:
|
||||
except Exception:
|
||||
raise
|
||||
|
||||
return (True, '')
|
||||
@@ -341,7 +341,7 @@ def get_url_map(client, name, project_id=None):
|
||||
try:
|
||||
req = client.urlMaps().get(project=project_id, urlMap=name)
|
||||
return GCPUtils.execute_api_client_req(req, raise_404=False)
|
||||
except:
|
||||
except Exception:
|
||||
raise
|
||||
|
||||
|
||||
@@ -367,7 +367,7 @@ def create_url_map(client, params, project_id):
|
||||
name=params['url_map_name'],
|
||||
project_id=project_id)
|
||||
return (True, return_data)
|
||||
except:
|
||||
except Exception:
|
||||
raise
|
||||
|
||||
|
||||
@@ -391,7 +391,7 @@ def delete_url_map(client, name, project_id):
|
||||
req = client.urlMaps().delete(project=project_id, urlMap=name)
|
||||
return_data = GCPUtils.execute_api_client_req(req, client)
|
||||
return (True, return_data)
|
||||
except:
|
||||
except Exception:
|
||||
raise
|
||||
|
||||
|
||||
@@ -431,7 +431,7 @@ def update_url_map(client, url_map, params, name, project_id):
|
||||
urlMap=name, body=gcp_dict)
|
||||
return_data = GCPUtils.execute_api_client_req(req, client=client, raw=False)
|
||||
return (True, return_data)
|
||||
except:
|
||||
except Exception:
|
||||
raise
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user