From f38ce7749257b3a11f40790607713ab16142865e Mon Sep 17 00:00:00 2001 From: Johannes Erdfelt Date: Tue, 25 Sep 2012 16:16:39 +0000 Subject: LOG.exception() should only be used in exception handler When used outside of an exception handler it will print the message and then 'None', which isn't useful at all. Change-Id: I797dbb0f6f0c5012859c02689907aa286c218808 --- nova/db/sqlalchemy/migrate_repo/versions/082_essex.py | 2 +- nova/virt/powervm/operator.py | 16 ++++++++-------- nova/virt/vmwareapi/network_utils.py | 8 ++++---- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/nova/db/sqlalchemy/migrate_repo/versions/082_essex.py b/nova/db/sqlalchemy/migrate_repo/versions/082_essex.py index 4e2a1a70d..13dc02e9c 100644 --- a/nova/db/sqlalchemy/migrate_repo/versions/082_essex.py +++ b/nova/db/sqlalchemy/migrate_repo/versions/082_essex.py @@ -993,4 +993,4 @@ def upgrade(migrate_engine): def downgrade(migrate_engine): - LOG.exception('Downgrade from Essex is unsupported.') + raise Exception('Downgrade from Essex is unsupported.') diff --git a/nova/virt/powervm/operator.py b/nova/virt/powervm/operator.py index 9097c6962..8b411c055 100644 --- a/nova/virt/powervm/operator.py +++ b/nova/virt/powervm/operator.py @@ -88,7 +88,7 @@ class PowerVMOperator(object): lpar_instance = self._operator.get_lpar(instance_name) if lpar_instance is None: - LOG.exception(_("LPAR instance '%s' not found") % instance_name) + LOG.error(_("LPAR instance '%s' not found") % instance_name) raise exception.PowerVMLPARInstanceNotFound( instance_name=instance_name) return lpar_instance @@ -176,7 +176,7 @@ class PowerVMOperator(object): # Memory mem = instance['memory_mb'] if mem > host_stats['host_memory_free']: - LOG.exception(_('Not enough free memory in the host')) + LOG.error(_('Not enough free memory in the host')) raise exception.PowerVMInsufficientFreeMemory( instance_name=instance['name']) mem_min = min(mem, constants.POWERVM_MIN_MEM) @@ -186,7 +186,7 @@ class PowerVMOperator(object): cpus = instance['vcpus'] avail_cpus = host_stats['vcpus'] - host_stats['vcpus_used'] if cpus > avail_cpus: - LOG.exception(_('Insufficient available CPU on PowerVM')) + LOG.error(_('Insufficient available CPU on PowerVM')) raise exception.PowerVMInsufficientCPU( instance_name=instance['name']) cpus_min = min(cpus, constants.POWERVM_MIN_CPUS) @@ -480,8 +480,8 @@ class BaseOperator(object): break if not found_vg: - LOG.exception(_('Could not create logical volume. ' - 'No space left on any volume group.')) + LOG.error(_('Could not create logical volume. ' + 'No space left on any volume group.')) raise exception.PowerVMNoSpaceLeftOnVolumeGroup() cmd = self.command.mklv('%s %sB' % (found_vg, size / 512)) @@ -539,10 +539,10 @@ class BaseOperator(object): "/usr/bin/awk '{print $1}'" % comp_path) output = self.run_command_as_root(cmd) if not len(output): - LOG.exception("Unable to get checksum") + LOG.error(_("Unable to get checksum")) raise exception.PowerVMFileTransferFailed() if source_cksum != output[0]: - LOG.exception("Image checksums do not match") + LOG.error(_("Image checksums do not match")) raise exception.PowerVMFileTransferFailed() # Unzip the image @@ -567,7 +567,7 @@ class BaseOperator(object): if len(output): size = int(output[0]) else: - LOG.exception("Uncompressed image file not found") + LOG.error(_("Uncompressed image file not found")) raise exception.PowerVMFileTransferFailed() if (size % 512 != 0): size = (int(size / 512) + 1) * 512 diff --git a/nova/virt/vmwareapi/network_utils.py b/nova/virt/vmwareapi/network_utils.py index 97d9d6c26..a3b20137d 100644 --- a/nova/virt/vmwareapi/network_utils.py +++ b/nova/virt/vmwareapi/network_utils.py @@ -125,10 +125,10 @@ def get_vlanid_and_vswitch_for_portgroup(session, pg_name): "get_dynamic_property", host_mor, "HostSystem", "config.network.portgroup") if not port_grps_on_host_ret: - excep = _("ESX SOAP server returned an empty port group " - "for the host system in its response") - LOG.exception(excep) - raise exception.NovaException(excep) + msg = _("ESX SOAP server returned an empty port group " + "for the host system in its response") + LOG.error(msg) + raise exception.NovaException(msg) port_grps_on_host = port_grps_on_host_ret.HostPortGroup for p_gp in port_grps_on_host: if p_gp.spec.name == pg_name: -- cgit