Fix tox pep8 errors of type E722 in sysinv

Remove the skip clause for E722.
Fix the offending errors. This should not affect the logic of the code.

E722: "Do not use bare except".

The aim here is to be as specific as possible with the exceptions
while still catching all the exceptions we would previously expect.

Story: 2002888
Task: 23161

Change-Id: I41bc36a74f997fc25dd2192e85b8867e26011c96
Signed-off-by: Mathieu Robinson <mathieu.robinson@windriver.com>
This commit is contained in:
Mathieu Robinson 2018-08-10 14:51:50 -04:00
parent 7a57ad711a
commit 0682193eb9
24 changed files with 116 additions and 116 deletions

View File

@ -227,7 +227,7 @@ class AgentManager(service.PeriodicService):
topic=conductor_rpcapi.MANAGER_TOPIC)
try:
ttys_dcd = rpcapi.get_host_ttys_dcd(context, host_id)
except:
except exception.SysinvException:
LOG.exception("Sysinv Agent exception getting host ttys_dcd.")
pass
if ttys_dcd is not None:
@ -399,7 +399,7 @@ class AgentManager(service.PeriodicService):
rpcapi.lldp_neighbour_update_by_host(context,
host_uuid,
neighbour_dict_array)
except:
except exception.SysinvException:
LOG.exception("Sysinv Agent exception updating lldp neighbours.")
self._lldp_operator.lldp_neighbours_clear()
pass
@ -433,7 +433,7 @@ class AgentManager(service.PeriodicService):
rpcapi.lldp_agent_update_by_host(context,
host_uuid,
agent_dict_array)
except:
except exception.SysinvException:
LOG.exception("Sysinv Agent exception updating lldp agents.")
self._lldp_operator.lldp_agents_clear()
pass
@ -503,7 +503,7 @@ class AgentManager(service.PeriodicService):
if os.path.exists(FIRST_BOOT_FLAG):
os.remove(FIRST_BOOT_FLAG)
LOG.info("Removed %s" % FIRST_BOOT_FLAG)
except:
except exception.SysinvException:
# For compatibility with 15.12
LOG.warn("platform_update_by_host exception host_uuid=%s msg_dict=%s." %
(host_uuid, msg_dict))
@ -664,7 +664,7 @@ class AgentManager(service.PeriodicService):
# of the agent for the rest of inventory calls
try:
rpcapi.load_update_by_host(icontext, ihost['uuid'], tsc.SW_VERSION)
except:
except exception.SysinvException:
LOG.exception("Sysinv Agent exception updating load conductor.")
pass
@ -674,7 +674,7 @@ class AgentManager(service.PeriodicService):
rpcapi.subfunctions_update_by_ihost(icontext,
ihost['uuid'],
subfunctions)
except:
except exception.SysinvException:
LOG.exception("Sysinv Agent exception updating subfunctions "
"conductor.")
pass
@ -714,7 +714,7 @@ class AgentManager(service.PeriodicService):
LOG.error("iport_update_by_ihost RemoteError exc_type=%s" %
e.exc_type)
self._report_to_conductor = False
except:
except exception.SysinvException:
LOG.exception("Sysinv Agent exception updating iport conductor.")
pass
@ -722,7 +722,7 @@ class AgentManager(service.PeriodicService):
rpcapi.subfunctions_update_by_ihost(icontext,
ihost['uuid'],
subfunctions)
except:
except exception.SysinvException:
LOG.exception("Sysinv Agent exception updating subfunctions "
"conductor.")
pass
@ -756,7 +756,7 @@ class AgentManager(service.PeriodicService):
rpcapi.pci_device_update_by_host(icontext,
ihost['uuid'],
pci_device_dict_array)
except:
except exception.SysinvException:
LOG.exception("Sysinv Agent exception updating iport conductor.")
pass
@ -777,7 +777,7 @@ class AgentManager(service.PeriodicService):
LOG.exception("Sysinv Agent exception updating inuma e=%s." % e)
self._report_to_conductor = True
pass
except:
except exception.SysinvException:
LOG.exception("Sysinv Agent uncaught exception updating inuma.")
pass
@ -797,7 +797,7 @@ class AgentManager(service.PeriodicService):
LOG.exception("Sysinv Agent exception updating icpus e=%s." % e)
self._report_to_conductor = True
pass
except:
except exception.SysinvException:
LOG.exception("Sysinv Agent uncaught exception updating icpus conductor.")
pass
@ -813,7 +813,7 @@ class AgentManager(service.PeriodicService):
e.exc_type)
# Allow the audit to update
pass
except:
except exception.SysinvException:
LOG.exception("Sysinv Agent exception updating imemory "
"conductor.")
pass
@ -831,7 +831,7 @@ class AgentManager(service.PeriodicService):
"Upgrade in progress?")
else:
LOG.exception("Sysinv Agent exception updating idisk conductor.")
except:
except exception.SysinvException:
LOG.exception("Sysinv Agent exception updating idisk conductor.")
pass
@ -844,7 +844,7 @@ class AgentManager(service.PeriodicService):
# safe to ignore during upgrades
LOG.warn("Skip updating ipartition conductor. "
"Upgrade in progress?")
except:
except exception.SysinvException:
LOG.exception("Sysinv Agent exception updating ipartition"
" conductor.")
pass
@ -854,7 +854,7 @@ class AgentManager(service.PeriodicService):
rpcapi.ipv_update_by_ihost(icontext,
ihost['uuid'],
ipv)
except:
except exception.SysinvException:
LOG.exception("Sysinv Agent exception updating ipv conductor.")
pass
@ -863,7 +863,7 @@ class AgentManager(service.PeriodicService):
rpcapi.ilvg_update_by_ihost(icontext,
ihost['uuid'],
ilvg)
except:
except exception.SysinvException:
LOG.exception("Sysinv Agent exception updating ilvg conductor.")
pass
@ -873,7 +873,7 @@ class AgentManager(service.PeriodicService):
try:
platform_interfaces = rpcapi.get_platform_interfaces(icontext,
ihost['id'])
except:
except exception.SysinvException:
LOG.exception("Sysinv Agent exception getting platform interfaces.")
pass
self._update_interface_irq_affinity(self, platform_interfaces)
@ -1061,7 +1061,7 @@ class AgentManager(service.PeriodicService):
else:
LOG.exception("Sysinv Agent exception updating idisk "
"conductor.")
except:
except exception.SysinvException:
LOG.exception("Sysinv Agent exception updating idisk "
"conductor.")
pass
@ -1169,7 +1169,7 @@ class AgentManager(service.PeriodicService):
else:
LOG.exception("Sysinv Agent exception updating idisk "
"conductor.")
except:
except exception.SysinvException:
LOG.exception("Sysinv Agent exception updating idisk"
"conductor.")
self._prev_disk = None
@ -1188,7 +1188,7 @@ class AgentManager(service.PeriodicService):
# safe to ignore during upgrades
LOG.warn("Skip updating ipartition conductor. "
"Upgrade in progress?")
except:
except exception.SysinvException:
LOG.exception("Sysinv Agent exception updating "
"ipartition conductor.")
self._prev_partition = None
@ -1203,7 +1203,7 @@ class AgentManager(service.PeriodicService):
rpcapi.ipv_update_by_ihost(icontext,
self._ihost_uuid,
ipv)
except:
except exception.SysinvException:
LOG.exception("Sysinv Agent exception updating ipv"
"conductor.")
self._prev_pv = None
@ -1218,7 +1218,7 @@ class AgentManager(service.PeriodicService):
rpcapi.ilvg_update_by_ihost(icontext,
self._ihost_uuid,
ilvg)
except:
except exception.SysinvException:
LOG.exception("Sysinv Agent exception updating ilvg"
"conductor.")
self._prev_lvg = None
@ -1567,7 +1567,7 @@ class AgentManager(service.PeriodicService):
response_dict = {'is_configured': False} # guilty until proven innocent
try:
tpmconfig = rpcapi.get_system_tpmconfig(context)
except:
except exception.SysinvException:
pass
finally:
if not tpmconfig:
@ -1583,7 +1583,7 @@ class AgentManager(service.PeriodicService):
# that flag (originally set in apply_tpm_config())
# would be cleared on Sysinv agent restarts/swacts
self._tpmconfig_host_first_apply = True
except:
except exception.SysinvException:
# it could be that a TPM configuration was attempted before
# this controller was provisioned in which case we will
# raise a failure. However it could also be that the agent

View File

@ -186,7 +186,7 @@ class PCIOperator(object):
with open(fnuma_node, 'r') as f:
numa_node = f.readline().strip()
LOG.debug("ATTR numa_node: %s " % numa_node)
except:
except Exception:
LOG.debug("ATTR numa_node unknown for: %s " % pciaddr)
numa_node = None
return numa_node
@ -198,7 +198,7 @@ class PCIOperator(object):
sriov_totalvfs = f.readline()
LOG.debug("ATTR sriov_totalvfs: %s " % sriov_totalvfs)
f.close()
except:
except Exception:
LOG.debug("ATTR sriov_totalvfs unknown for: %s " % pciaddr)
sriov_totalvfs = None
pass
@ -211,7 +211,7 @@ class PCIOperator(object):
sriov_numvfs = f.readline()
LOG.debug("ATTR sriov_numvfs: %s " % sriov_numvfs)
f.close()
except:
except Exception:
LOG.debug("ATTR sriov_numvfs unknown for: %s " % pciaddr)
sriov_numvfs = 0
pass
@ -226,7 +226,7 @@ class PCIOperator(object):
lvf = dirpcidev + '/virtfn' + str(i)
try:
sriov_vfs_pci_address.append(os.path.basename(os.readlink(lvf)))
except:
except Exception:
LOG.warning("virtfn link %s non-existent (sriov_numvfs=%s)"
% (lvf, sriov_numvfs))
pass
@ -242,7 +242,7 @@ class PCIOperator(object):
]
driver = str(','.join(str(d) for d in drivers))
except:
except Exception:
LOG.debug("ATTR driver unknown for: %s " % pciaddr)
driver = None
pass
@ -343,21 +343,21 @@ class PCIOperator(object):
try:
with open(fvendor, 'r') as f:
pvendor_id = f.readline().strip('0x').strip()
except:
except Exception:
LOG.debug("ATTR vendor unknown for: %s " % a)
pvendor_id = None
try:
with open(fdevice, 'r') as f:
pdevice_id = f.readline().replace('0x', '').strip()
except:
except Exception:
LOG.debug("ATTR device unknown for: %s " % a)
pdevice_id = None
try:
with open(fclass, 'r') as f:
pclass_id = f.readline().replace('0x', '').strip()
except:
except Exception:
LOG.debug("ATTR class unknown for: %s " % a)
pclass_id = None
@ -404,7 +404,7 @@ class PCIOperator(object):
with open(fflags, 'r') as f:
hex_str = f.readline().rstrip()
flags = int(hex_str, 16)
except:
except Exception:
flags = None
return flags
@ -452,14 +452,14 @@ class PCIOperator(object):
try:
with open(fvendor, 'r') as f:
vendor = f.readline().strip()
except:
except Exception:
LOG.debug("ATTR vendor unknown for: %s " % a)
vendor = None
try:
with open(fdevice, 'r') as f:
device = f.readline().strip()
except:
except Exception:
LOG.debug("ATTR device unknown for: %s " % a)
device = None
@ -517,7 +517,7 @@ class PCIOperator(object):
if not mac:
LOG.info("ATTR mac could not be determined "
"for slave interface %s" % n)
except:
except Exception:
LOG.info("ATTR mac could not be determined, "
"could not open %s" % procnetbonding)
else:
@ -525,14 +525,14 @@ class PCIOperator(object):
with open(fmac, 'r') as f:
mac = f.readline().rstrip()
mac = utils.validate_and_normalize_mac(mac)
except:
except Exception:
LOG.info("ATTR mac unknown for: %s " % n)
fmtu = dirpcinet + n + '/' + "mtu"
try:
with open(fmtu, 'r') as f:
mtu = f.readline().rstrip()
except:
except Exception:
LOG.debug("ATTR mtu unknown for: %s " % n)
mtu = None
@ -554,7 +554,7 @@ class PCIOperator(object):
LOG.error("Invalid port speed = %s for %s " %
(speed, n))
speed = None
except:
except Exception:
LOG.warning("ATTR speed unknown for: %s (flags: %s)" % (n, hex(flags)))
speed = None
# If the administrative state was down, take it back down
@ -568,7 +568,7 @@ class PCIOperator(object):
try:
with open(flink_mode, 'r') as f:
link_mode = f.readline().rstrip()
except:
except Exception:
LOG.debug("ATTR link_mode unknown for: %s " % n)
link_mode = None
@ -576,7 +576,7 @@ class PCIOperator(object):
try:
with open(fdevport, 'r') as f:
dev_port = int(f.readline().rstrip(), 0)
except:
except Exception:
LOG.debug("ATTR dev_port unknown for: %s " % n)
# Kernel versions older than 3.15 used dev_id
# (incorrectly) to identify the network devices,
@ -586,7 +586,7 @@ class PCIOperator(object):
fdevid = dirpcinet + n + '/' + "dev_id"
with open(fdevid, 'r') as f:
dev_port = int(f.readline().rstrip(), 0)
except:
except Exception:
LOG.debug("ATTR dev_id unknown for: %s " % n)
dev_port = 0

View File

@ -389,7 +389,7 @@ class CPUController(rest.RestController):
inode = objects.node.get_by_uuid(
pecan.request.context, p['value'])
p['value'] = inode.id
except:
except exception.SysinvException:
p['value'] = None
if p['path'] == '/allocated_function':

View File

@ -389,7 +389,7 @@ class EthernetPortController(rest.RestController):
interface = objects.interface.get_by_uuid(
pecan.request.context, p['value'])
p['value'] = interface.id
except:
except exception.SysinvException:
p['value'] = None
try:

View File

@ -151,7 +151,7 @@ class HelmChartsController(rest.RestController):
# Extract the info we want.
values = output.split('USER-SUPPLIED VALUES:\n')[1].split(
'\nCOMPUTED VALUES:')[0]
except:
except exception.SysinvException:
raise
finally:
os.remove(chartfile)

View File

@ -1535,7 +1535,7 @@ class HostController(rest.RestController):
contents = fileitem.file.read()
# Generate an array of hosts' attributes to be used in creation
root = ET.fromstring(contents)
except:
except Exception:
return dict(
success="",
error="No hosts have been added, invalid XML document"
@ -2212,7 +2212,7 @@ class HostController(rest.RestController):
ihost.uuid,
ihost.hostname,
constants.VIM_DELETE_TIMEOUT_IN_SECS)
except:
except Exception:
LOG.warn(_("No response from vim_api %s " % ihost['uuid']))
raise wsme.exc.ClientSideError(_("System rejected delete "
"request. Please retry and if problem persists then "

View File

@ -346,7 +346,7 @@ class InterfaceController(rest.RestController):
try:
host = pecan.request.dbapi.ihost_get(ihost)
ihost_id = host.uuid
except:
except exception.SysinvException:
raise wsme.exc.ClientSideError(_("Invalid ihost %s" % ihost))
return self._get_interfaces_collection(ihost_id, marker, limit,

View File

@ -438,7 +438,7 @@ class MemoryController(rest.RestController):
inode = objects.node.get_by_uuid(
pecan.request.context, p['value'])
p['value'] = inode.id
except:
except exception.SysinvException:
p['value'] = None
try:

View File

@ -72,8 +72,8 @@ def host_modify(token, address, port, ihost_mtce, timeout, max_retries=1):
# Note: Even there is a timeout but neither of these "except" got it.
LOG.warn("WARNING rest_api_request Timeout Error e=%s" % (e))
raise si_exception.SysInvSignalTimeout
except:
LOG.warn("WARNING rest_api_request Unexpected Error")
except si_exception.SysinvException as e:
LOG.warn("WARNING rest_api_request Unexpected Error e=%s" % (e))
return response

View File

@ -2595,7 +2595,7 @@ def ifprofile_apply_to_host(host, profile):
data = {'interface_id': None}
try:
pecan.request.dbapi.ethernet_port_update(p.uuid, data)
except:
except dbException.DBError:
raise wsme.exc.ClientSideError(_("Failed to unlink port from interface."))
# Delete all Host's interfaces in reverse order (VLANs, AEs, ethernet, etc)
@ -2643,13 +2643,13 @@ def ifprofile_apply_to_host(host, profile):
data = {'interface_id': None}
try:
pecan.request.dbapi.ethernet_port_update(p.uuid, data)
except:
except dbException.DBError:
LOG.debug(_("Failed to unlink port from interface."))
for i in host.interfaces:
try:
interface_api._delete(i.as_dict(), from_profile=True)
except:
except exception.SysinvException:
LOG.debug(_("Can not delete host interface: %s" % i.uuid))
# Restore the previous interfaces
@ -2845,7 +2845,7 @@ def storprofile_apply_to_host(host, profile):
pdata = {'foristorid': storPairs[pdisk.foristorid]}
try:
pecan.request.dbapi.idisk_update(hdisk.uuid, pdata)
except:
except dbException.DBError:
raise wsme.exc.ClientSideError(_("Failed to link storage to disk"))
@ -3156,7 +3156,7 @@ def localstorageprofile_apply_to_host(host, profile):
pdata = {'foripvid': ipvPairs[pdisk.foripvid]}
try:
device_update_function(disk_or_part_uuid, pdata)
except:
except dbException.DBError:
raise wsme.exc.ClientSideError(_(
"Failed to link storage to device %s" % disk_or_part_uuid))

View File

@ -279,7 +279,7 @@ class EthInterface(Interface):
sec2 = int(section_list1[1], 16)
sec3 = int(section_list2[0], 16)
sec4 = int(section_list2[1], 16)
except:
except (TypeError, ValueError):
raise InvalidProfileData(_('pciAddress is not well formatted.'))
result = '{0:04x}:{1:02x}:{2:02x}.{3:01x}'.format(sec1, sec2, sec3, sec4)

View File

@ -459,7 +459,7 @@ class SensorController(rest.RestController):
p['value'] = sensorgroup.id
LOG.info("sensorgroup_uuid=%s id=%s" % (p['value'],
sensorgroup.id))
except:
except exception.SysinvException:
p['value'] = None
try:

View File

@ -261,7 +261,7 @@ def get_tpm_config():
tpmconfig = None
try:
tpmconfig = pecan.request.dbapi.tpmconfig_get_one()
except:
except exception.SysinvException:
pass
return tpmconfig
@ -283,7 +283,7 @@ def get_sdn_l3_mode_enabled():
allowed_vals = constants.SERVICE_PLUGINS_SDN
return (any(sp in allowed_vals
for sp in sdn_l3_mode.value.split(',')))
except:
except exception.SysinvException:
return False
@ -606,7 +606,7 @@ class SBApiHelper(object):
backend_enable_function(pecan.request.context)
LOG.info("Configuration of storage %s backend initialized, "
"continuing in background." % sb.backend.title())
except:
except exception.SysinvException:
LOG.exception("Manifests failed!")
# Set lvm backend to error so that it can be recreated
values = {'state': constants.SB_STATE_CONFIG_ERR, 'task': None}

View File

@ -134,5 +134,5 @@ class ClusterServices(object):
self.__cluster_data = xml.CLUSTER_DATA
self.__loaded = True
except:
except Exception:
LOG.error("error:", sys.exc_info()[0])

View File

@ -89,7 +89,7 @@ class Pacemaker(object):
os.remove(pacemaker_xml_filename)
except:
except Exception:
if os.path.exists(pacemaker_xml_filename):
os.remove(pacemaker_xml_filename)
@ -199,7 +199,7 @@ class Pacemaker(object):
os.system("/usr/sbin/crm node %s %s" % (action, node_name))
return True
except:
except Exception:
LOG.error("error:", sys.exc_info()[0])
return False
@ -216,7 +216,7 @@ class Pacemaker(object):
% (resource_name, node_name, lifetime))
return True
except:
except Exception:
os.system("/usr/sbin/crm resource unmigrate %s" % resource_name)
LOG.error("error:", sys.exc_info()[0])
return False

View File

@ -680,7 +680,7 @@ class CephApiOperator(object):
if num_inv_monitors >= required_monitors:
try:
quorum_names = self._osd_quorum_names()
except:
except Exception:
# if the cluster is not responding to requests
# we set the quorum_names to an empty list , indicating a problem
quorum_names = []

View File

@ -198,7 +198,7 @@ class Retrying(object):
while True:
try:
attempt = Attempt(fn(*args, **kwargs), attempt_number, False)
except:
except Exception:
tb = sys.exc_info()
attempt = Attempt(tb, attempt_number, True)

View File

@ -89,7 +89,7 @@ class StorageBackendConfig(object):
backends = []
try:
backend_list = api.storage_backend_get_list()
except:
except Exception:
backend_list = []
for backend in backend_list:

View File

@ -829,7 +829,7 @@ def notify_mtc_and_recv(mtc_address, mtc_port, idict):
try:
mtc_response_dict = json.loads(mtc_response)
LOG.warning("Mtc Response: %s" % mtc_response_dict)
except:
except Exception:
LOG.exception("Mtc Response Error: %s" % mtc_response)
pass

View File

@ -1692,7 +1692,7 @@ class ConductorManager(service.PeriodicService):
try:
hostname = socket.gethostname()
except:
except socket.error:
LOG.exception("Failed to get local hostname")
hostname = None
@ -1825,7 +1825,7 @@ class ConductorManager(service.PeriodicService):
{'interface_id': new_interface['id'],
'bootp': bootp
})
except:
except Exception:
LOG.exception("Failed to create new interface %s" %
inic['mac'])
pass # at least create the port
@ -1849,7 +1849,7 @@ class ConductorManager(service.PeriodicService):
new_interface = self.dbapi.iinterface_create(
ihost['id'], interface_dict
)
except:
except Exception:
LOG.exception(
"Failed to create new vlan interface %s" %
inic['mac'])
@ -1881,11 +1881,11 @@ class ConductorManager(service.PeriodicService):
# change. This will update the db to reflect that
if port['name'] != inic['pname']:
self._update_port_name(port, inic['pname'])
except:
except Exception:
LOG.exception("Failed to update port %s" % inic['mac'])
pass
except:
except Exception:
# adjust for field naming differences between the NIC
# dictionary returned by the agent and the Port model
port_dict = inic_dict.copy()
@ -1902,7 +1902,7 @@ class ConductorManager(service.PeriodicService):
"Invalid ihost_uuid: host not found: %s") %
ihost_uuid)
except: # this info may have been posted previously, update ?
except Exception: # this info may have been posted previously, update ?
pass
# Set interface ID for management address
@ -2309,7 +2309,7 @@ class ConductorManager(service.PeriodicService):
"%s on host %s" % (pci_dev_dict, host['id']))
dev = self.dbapi.pci_device_create(host['id'],
pci_dev_dict)
except:
except Exception:
LOG.info("Attempting to create new device "
"%s on host %s" % (pci_dev_dict, host['id']))
dev = self.dbapi.pci_device_create(host['id'],
@ -2333,7 +2333,7 @@ class ConductorManager(service.PeriodicService):
'driver': pci_dev['driver']}
LOG.info("attr: %s" % attr)
dev = self.dbapi.pci_device_update(dev['uuid'], attr)
except:
except Exception:
LOG.exception("Failed to update port %s" %
dev['pciaddr'])
pass
@ -2342,7 +2342,7 @@ class ConductorManager(service.PeriodicService):
raise exception.SysinvException(_(
"Invalid host_uuid: host not found: %s") %
host_uuid)
except:
except Exception:
pass
def inumas_update_by_ihost(self, context,
@ -2402,7 +2402,7 @@ class ConductorManager(service.PeriodicService):
raise exception.SysinvException(_(
"Invalid ihost_uuid: host not found: %s") %
ihost_uuid)
except: # this info may have been posted previously, update ?
except Exception: # this info may have been posted previously, update ?
pass
def _get_default_platform_cpu_count(self, ihost, node,
@ -2660,7 +2660,7 @@ class ConductorManager(service.PeriodicService):
raise exception.SysinvException(_(
"Invalid ihost_uuid: host not found: %s") %
ihost_uuid)
except:
except Exception:
# info may have already been posted
pass
@ -2753,7 +2753,7 @@ class ConductorManager(service.PeriodicService):
mem_dict['memavail_mib'] += vm_4K_mib
self.dbapi.imemory_update(imem['uuid'],
mem_dict)
except:
except Exception:
# Set the amount of memory reserved for platform use.
mem_dict.update(self._get_platform_reserved_memory(
ihost, i['numa_node']))
@ -3124,7 +3124,7 @@ class ConductorManager(service.PeriodicService):
lvg_dict.update({'vg_state': constants.PROVISIONED})
try:
self.dbapi.ilvg_create(forihostid, lvg_dict)
except:
except Exception:
LOG.exception("Local Volume Group Creation failed")
# Purge the database records for volume groups that have been
@ -3141,7 +3141,7 @@ class ConductorManager(service.PeriodicService):
if not found:
try:
self.dbapi.ilvg_destroy(ilvg.id)
except:
except Exception:
LOG.exception("Local Volume Group removal failed")
return
@ -3172,7 +3172,7 @@ class ConductorManager(service.PeriodicService):
try:
self.dbapi.partition_update(db_part.uuid, values)
except:
except Exception:
LOG.exception("Updating partition (%s) with values %s failed." %
(db_part.uuid, str(values)))
@ -3377,7 +3377,7 @@ class ConductorManager(service.PeriodicService):
try:
self._prepare_for_ipv_removal(ipv)
self.dbapi.ipv_destroy(ipv.id)
except:
except Exception:
LOG.exception("Remove ipv for missing %s failed" % storage)
def update_partition_config(self, context, partition):
@ -3680,7 +3680,7 @@ class ConductorManager(service.PeriodicService):
if ipv_update_needed:
try:
self.dbapi.ipv_update(ipv['uuid'], pv_dict)
except:
except Exception:
LOG.exception("Update ipv for changed idisk "
"details failed.")
break
@ -3717,7 +3717,7 @@ class ConductorManager(service.PeriodicService):
try:
self.dbapi.ipv_update(ipv['uuid'], pv_dict)
except:
except Exception:
LOG.exception("Update ipv for changed partition "
"details failed.")
@ -3786,7 +3786,7 @@ class ConductorManager(service.PeriodicService):
self.dbapi.partition_update(
ipv['disk_or_part_uuid'],
{'status': constants.PARTITION_IN_USE_STATUS})
except:
except Exception:
LOG.exception("Update ipv with latest info failed")
if ipv['pv_type'] == constants.PV_TYPE_PARTITION:
@ -3808,7 +3808,7 @@ class ConductorManager(service.PeriodicService):
pv_dict.update({'disk_or_part_uuid': d.uuid})
try:
self.dbapi.ipv_update(ipv['uuid'], pv_dict)
except:
except Exception:
LOG.exception("Update ipv for changed "
"idisk uuid failed")
break
@ -3905,7 +3905,7 @@ class ConductorManager(service.PeriodicService):
pv = None
try:
pv = self.dbapi.ipv_create(forihostid, pv_dict)
except:
except Exception:
LOG.exception("PV Volume Creation failed")
if pv.get('pv_type') == constants.PV_TYPE_PARTITION:
@ -3914,7 +3914,7 @@ class ConductorManager(service.PeriodicService):
pv.disk_or_part_uuid,
{'foripvid': pv.id,
'status': constants.PARTITION_IN_USE_STATUS})
except:
except Exception:
LOG.exception("Updating partition (%s) for ipv id "
"failed (%s)" % (pv.disk_or_part_uuid,
pv.uuid))
@ -3922,7 +3922,7 @@ class ConductorManager(service.PeriodicService):
try:
self.dbapi.idisk_update(pv.disk_or_part_uuid,
{'foripvid': pv.id})
except:
except Exception:
LOG.exception("Updating idisk (%s) for ipv id "
"failed (%s)" % (pv.disk_or_part_uuid,
pv.uuid))
@ -3965,7 +3965,7 @@ class ConductorManager(service.PeriodicService):
# # PV before removal.
self._prepare_for_ipv_removal(ipv)
self.dbapi.ipv_destroy(ipv.id)
except:
except Exception:
LOG.exception("Physical Volume removal failed")
else:
if ipv.pv_state == constants.PROVISIONED:
@ -3985,7 +3985,7 @@ class ConductorManager(service.PeriodicService):
if update:
try:
self.dbapi.ipv_update(ipv['uuid'], update)
except:
except Exception:
LOG.exception("Updating ipv id %s "
"failed" % ipv['uuid'])
@ -4288,7 +4288,7 @@ class ConductorManager(service.PeriodicService):
self._openstack.create_neutron_host(context,
ihost_uuid,
ihost['hostname'])
except: # TODO: DPENNEY: Needs better exception
except Exception: # TODO: DPENNEY: Needs better exception
LOG.exception("Failed in neutron stuff")
ihost_val = {'subfunctions': subfunctions}
@ -4311,7 +4311,7 @@ class ConductorManager(service.PeriodicService):
try:
mac = mac.rstrip()
mac = cutils.validate_and_normalize_mac(mac)
except:
except Exception:
LOG.warn("get_ihost_by_macs invalid mac: %s" % mac)
continue
@ -4583,7 +4583,7 @@ class ConductorManager(service.PeriodicService):
constants.CONTROLLER_0_HOSTNAME)
if not utils.is_host_active_controller(controller_0):
vim_api.set_vim_upgrade_state(controller_0, False)
except:
except Exception:
LOG.exception("Unable to set VIM upgrade state to False")
def _audit_install_states(self, hosts):
@ -7934,7 +7934,7 @@ class ConductorManager(service.PeriodicService):
try:
if ihost.get('hostname'):
self._generate_dnsmasq_hosts_file()
except:
except Exception:
LOG.warning("Failed to remove mgmt ip from dnsmasq.hosts")
if mgmt_ip is None:
@ -8004,7 +8004,7 @@ class ConductorManager(service.PeriodicService):
try:
if ihost.get('hostname'):
self._generate_dnsmasq_hosts_file()
except:
except Exception:
LOG.warning("Failed to remove infra ip from dnsmasq.hosts")
if infra_ip is None:
@ -8291,7 +8291,7 @@ class ConductorManager(service.PeriodicService):
root = ElementTree.fromstring(metadata_file.read())
metadata_file.close()
except:
except Exception:
raise exception.SysinvException(_(
"Unable to read metadata file"))
@ -8617,7 +8617,7 @@ class ConductorManager(service.PeriodicService):
from_version, to_version, i_system)
LOG.info("Finished upgrade preparation")
except:
except Exception:
LOG.exception("Upgrade preparation failed")
with excutils.save_and_reraise_exception():
if tsc.system_mode != constants.SYSTEM_MODE_SIMPLEX:
@ -8670,7 +8670,7 @@ class ConductorManager(service.PeriodicService):
upgrades_management.activate_upgrade(from_version,
to_version, i_system)
LOG.info("Finished upgrade activation")
except:
except Exception:
LOG.exception("Upgrade activation failed")
with excutils.save_and_reraise_exception():
# mark the activation as failed. The intention
@ -8759,7 +8759,7 @@ class ConductorManager(service.PeriodicService):
try:
vim_api.set_vim_upgrade_state(controller_0, False)
except:
except Exception:
LOG.exception()
raise exception.SysinvException(_(
"upgrade-abort rejected: unable to reset VIM upgrade "
@ -9448,7 +9448,7 @@ class ConductorManager(service.PeriodicService):
tpmdevice_dict.update({'host_uuid': tpm_host['uuid']})
tpmdevice = self.dbapi.tpmdevice_create(tpm_host['id'],
tpmdevice_dict)
except:
except Exception:
LOG.exception("Cannot create TPM device for host %s" % host_uuid)
return

View File

@ -271,7 +271,7 @@ class OpenStackOperator(object):
if not aggregates:
try:
aggregates = self._get_novaclient().aggregates.list()
except:
except Exception:
self.nova_client = None # password may have updated
aggregates = self._get_novaclient().aggregates.list()
@ -480,12 +480,12 @@ class OpenStackOperator(object):
providernet)
ihost_providernets = list(ihost_aggset_provider)
except:
except Exception:
LOG.exception("AGG iinterfaces_get failed for %s." % ihost_uuid)
try:
aggregates = self._get_novaclient().aggregates.list()
except:
except Exception:
self.nova_client = None # password may have updated
aggregates = self._get_novaclient().aggregates.list()
pass
@ -507,7 +507,7 @@ class OpenStackOperator(object):
aggregates.append(aggregate)
LOG.debug("AGG6 aggregate= %s. aggregates= %s" % (aggregate,
aggregates))
except:
except Exception:
# do not continue i, redo as potential race condition
LOG.error("AGG6 EXCEPTION aggregate i=%s, aggregates=%s" %
(i, aggregates))
@ -530,7 +530,7 @@ class OpenStackOperator(object):
LOG.debug("AGG8 aggregate metadata = %s." % metadata)
aggregate = self._get_novaclient().aggregates.set_metadata(
aggregate.id, metadata)
except:
except Exception:
LOG.error("AGG8 EXCEPTION aggregate")
pass
@ -555,7 +555,7 @@ class OpenStackOperator(object):
try:
metadata = self._get_novaclient().aggregates.add_host(
i.id, ihost.hostname)
except:
except Exception:
LOG.warn("AGG10 EXCEPTION aggregate id = %s ihost= %s."
% (i.id, ihost.hostname))
return False

View File

@ -1319,8 +1319,8 @@ class Connection(api.Connection):
try:
mgmt_mac = mgmt_mac.rstrip()
mgmt_mac = utils.validate_and_normalize_mac(mgmt_mac)
except:
raise exception.NodeNotFound(node=mgmt_mac)
except exception.SysinvException:
raise exception.HostNotFound(node=mgmt_mac)
query = model_query(models.ihost)
query = add_host_options(query)
@ -4034,7 +4034,7 @@ class Connection(api.Connection):
try:
result = _paginate_query(models.StorageBackend, limit, marker,
sort_key, sort_dir, query)
except:
except (db_exc.InvalidSortKey, ValueError):
result = []
return result
@ -4065,7 +4065,7 @@ class Connection(api.Connection):
try:
result = _paginate_query(models.StorageBackend, limit, marker,
sort_key, sort_dir, query)
except:
except exception.SysinvException:
result = []
return result

View File

@ -391,5 +391,5 @@ class KeystonePuppet(openstack.OpenstackBasePuppet):
msg = ("section '%s' contains no configuration options" % section)
raise Exception(msg)
return dict(rules)
except:
except Exception:
raise Exception("Failed to extract password rules from file")

View File

@ -81,7 +81,7 @@ commands =
# H231..H238 are python3 compatability
# H401,H403,H404,H405 are docstring and not important
[flake8]
ignore = E501,E127,E128,E402,E126,E722,H101,H102,H104,H105,H231,H232,H233,H234,H235,H236,H237,H238,H401,H403,H404,H405
ignore = E501,E127,E128,E402,E126,H101,H102,H104,H105,H231,H232,H233,H234,H235,H236,H237,H238,H401,H403,H404,H405
builtins = _
[testenv:flake8]