db.sm_flavor_create(context.get_admin_context(),
dict(label=label,
description=desc))
- except exception.DBError, e:
+ except exception.DBError as e:
_db_error(e)
@args('label', help='label of flavor to be deleted')
try:
db.sm_flavor_delete(context.get_admin_context(), label)
- except exception.DBError, e:
+ except exception.DBError as e:
_db_error(e)
def _splitfun(self, item):
sr_uuid = params['sr_uuid']
try:
backend = db.sm_backend_conf_get_by_sr(ctxt, sr_uuid)
- except exception.DBError, e:
+ except exception.DBError as e:
_db_error(e)
if backend:
flavor_id=flavors['id'],
sr_type=sr_type,
config_params=config_params))
- except exception.DBError, e:
+ except exception.DBError as e:
_db_error(e)
return
sr_uuid=sr_uuid,
sr_type=sr_type,
config_params=config_params))
- except exception.DBError, e:
+ except exception.DBError as e:
_db_error(e)
@args('backend_conf_id')
db.sm_backend_conf_delete(context.get_admin_context(),
backend_conf_id)
- except exception.DBError, e:
+ except exception.DBError as e:
_db_error(e)
try:
cinder.volume.utils.notify_usage_exists(admin_context,
volume_ref)
- except Exception, e:
+ except Exception as e:
print traceback.format_exc(e)
snapshots = db.snapshot_get_active_by_window(admin_context,
snapshot_ref,
'exists',
extra_info)
- except Exception, e:
+ except Exception as e:
print traceback.fromat_exc(e)
print _("Volume usage audit completed")
'update': update})
try:
self._update(context, id, update)
- except exception.NotFound, e:
+ except exception.NotFound as e:
raise exc.HTTPNotFound(e)
return webob.Response(status_int=202)
force = params.get('force', False)
try:
volume = self.volume_api.get(context, id)
- except exception.VolumeNotFound, error:
+ except exception.VolumeNotFound as error:
raise webob.exc.HTTPNotFound(explanation=unicode(error))
authorize(context, "upload_image")
image_metadata = {"container_format": params.get("container_format",
volume,
image_metadata,
force)
- except exception.InvalidVolume, error:
+ except exception.InvalidVolume as error:
raise webob.exc.HTTPBadRequest(explanation=unicode(error))
- except ValueError, error:
+ except ValueError as error:
raise webob.exc.HTTPBadRequest(explanation=unicode(error))
except rpc_common.RemoteError as error:
msg = "%(err_type)s: %(err_msg)s" % {'err_type': error.exc_type,
try:
msg_dict = dict(url=request.url, status=response.status_int)
msg = _("%(url)s returned with HTTP %(status)d") % msg_dict
- except AttributeError, e:
+ except AttributeError as e:
msg_dict = dict(url=request.url, e=e)
msg = _("%(url)s returned a fault: %(e)s") % msg_dict
volume_type_ref = models.VolumeTypes()
volume_type_ref.update(values)
volume_type_ref.save()
- except Exception, e:
+ except Exception as e:
raise db_exc.DBError(e)
return volume_type_ref
try:
spec_ref = volume_type_extra_specs_get_item(
context, volume_type_id, key, session)
- except exception.VolumeTypeExtraSpecsNotFound, e:
+ except exception.VolumeTypeExtraSpecsNotFound as e:
spec_ref = models.VolumeTypeExtraSpecs()
spec_ref.update({"key": key, "value": value,
"volume_type_id": volume_type_id,
"""Get the last modified datetime. Broken out for testing."""
try:
return os.path.getmtime(filename)
- except os.error, e:
+ except os.error as e:
LOG.exception(_("Could not stat scheduler options file "
"%(filename)s: '%(e)s'"), locals())
raise
"""Decode the JSON file. Broken out for testing."""
try:
return json.load(handle)
- except ValueError, e:
+ except ValueError as e:
LOG.exception(_("Could not decode scheduler options: "
"'%(e)s'") % locals())
return {}
'(PUT, /foo*, /foo.*, 10, hour);'
'(POST, /bar*, /bar.*, 5, second);'
'(Say, /derp*, /derp.*, 1, day)')
- except ValueError, e:
+ except ValueError as e:
assert False, str(e)
# Make sure the number of returned limits are correct
'(PUT, /foo*, /foo.*, 10, hour);'
'(POST, /bar*, /bar.*, 5, second);'
'(Say, /derp*, /derp.*, 1, day)')
- except ValueError, e:
+ except ValueError as e:
assert False, str(e)
# Make sure the number of returned limits are correct
for key, value in defaults.items():
self.test_databases[key] = value
self.snake_walk = cp.getboolean('walk_style', 'snake_walk')
- except ConfigParser.ParsingError, e:
+ except ConfigParser.ParsingError as e:
self.fail("Failed to read test_migrations.conf config "
"file. Got error: %s" % e)
else:
try:
out, err = execute(*args, **kwargs)
failed = False
- except exception.ProcessExecutionError, exn:
+ except exception.ProcessExecutionError as exn:
out, err = '', str(exn)
LOG.debug(err)
failed = True
if not self._running:
break
greenthread.sleep(interval)
- except LoopingCallDone, e:
+ except LoopingCallDone as e:
self.stop()
done.send(e.retvalue)
except Exception:
finally:
try:
shutil.rmtree(tmpdir)
- except OSError, e:
+ except OSError as e:
LOG.debug(_('Could not remove tmpdir: %s'), str(e))
% snapshot['id'])
try:
self.esm.create_snapshot(volume_name, snapshot_name)
- except Exception, e:
+ except Exception as e:
msg = _('Failed to Create Snapshot %(snapname)s')
LOG.debug(msg % dict(snapname=snapshot_name))
raise
try:
self._ensure_share_mounted(share)
self._mounted_shares.append(share)
- except Exception, exc:
+ except Exception as exc:
LOG.warning(_('Exception during mounting %s') % (exc,))
LOG.debug('Available shares %s' % str(self._mounted_shares))
try:
self._ensure_share_mounted(share)
self._mounted_shares.append(share)
- except Exception, exc:
+ except Exception as exc:
LOG.warning(_('Exception during mounting %s') % (exc,))
LOG.debug('Available shares %s' % str(self._mounted_shares))
data = response.read()
try:
data = json.loads(data)
- except (TypeError, ValueError), exc:
+ except (TypeError, ValueError) as exc:
connection.close()
msg = _("Call to json.loads() raised "
"an exception: %s") % exc
image_meta)
LOG.debug(_("Uploaded volume %(volume_id)s to "
"image (%(image_id)s) successfully") % locals())
- except Exception, error:
+ except Exception as error:
with excutils.save_and_reraise_exception():
payload['message'] = unicode(error)
finally:
ctxt = context.get_admin_context()
try:
vol_type = get_volume_type_by_name(ctxt, name)
- except exception.VolumeTypeNotFoundByName, e:
+ except exception.VolumeTypeNotFoundByName as e:
# Couldn't find volume type with the name in default_volume_type
# flag, record this issue and move on
#TODO(zhiteng) consider add notification to warn admin
if use_ssl:
sock = wrap_ssl(sock)
- except socket.error, err:
+ except socket.error as err:
if err.args[0] != errno.EADDRINUSE:
raise
eventlet.sleep(0.1)
mod_str = mod_str[:mod_str.rfind(".")]
try:
mod_obj = importutils.import_module(mod_str)
- except Exception, e:
+ except Exception as e:
sys.stderr.write("Failed to collect options from module %s: %s\n" % (
mod_str, str(e)))
return
opt_type = None
try:
opt_type = OPTION_REGEX.search(str(type(opt))).group(0)
- except (ValueError, AttributeError), err:
+ except (ValueError, AttributeError) as err:
sys.stderr.write("%s\n" % str(err))
sys.exit(1)
opt_help += ' (' + OPT_TYPES[opt_type] + ')'