本文整理汇总了Python中nova.api.ec2.ec2utils.id_to_ec2_vol_id函数的典型用法代码示例。如果您正苦于以下问题:Python id_to_ec2_vol_id函数的具体用法?Python id_to_ec2_vol_id怎么用?Python id_to_ec2_vol_id使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了id_to_ec2_vol_id函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: __call__
def __call__(self, req):
context = req.environ['nova.context']
api_request = req.environ['ec2.request']
result = None
try:
result = api_request.invoke(context)
except exception.InstanceNotFound as ex:
LOG.info(_('InstanceNotFound raised: %s'), unicode(ex),
context=context)
return self._error(req, context, type(ex).__name__, ex.message)
except exception.VolumeNotFound as ex:
LOG.info(_('VolumeNotFound raised: %s'), unicode(ex),
context=context)
ec2_id = ec2utils.id_to_ec2_vol_id(ex.volume_id)
message = _('Volume %s not found') % ec2_id
return self._error(req, context, type(ex).__name__, message)
except exception.SnapshotNotFound as ex:
LOG.info(_('SnapshotNotFound raised: %s'), unicode(ex),
context=context)
ec2_id = ec2utils.id_to_ec2_snap_id(ex.snapshot_id)
message = _('Snapshot %s not found') % ec2_id
return self._error(req, context, type(ex).__name__, message)
except exception.NotFound as ex:
LOG.info(_('NotFound raised: %s'), unicode(ex), context=context)
return self._error(req, context, type(ex).__name__, unicode(ex))
except exception.ApiError as ex:
LOG.exception(_('ApiError raised: %s'), unicode(ex),
context=context)
if ex.code:
return self._error(req, context, ex.code, unicode(ex))
else:
return self._error(req, context, type(ex).__name__,
unicode(ex))
except exception.KeyPairExists as ex:
LOG.debug(_('KeyPairExists raised: %s'), unicode(ex),
context=context)
return self._error(req, context, type(ex).__name__, unicode(ex))
except exception.InvalidParameterValue as ex:
LOG.debug(_('InvalidParameterValue raised: %s'), unicode(ex),
context=context)
return self._error(req, context, type(ex).__name__, unicode(ex))
except exception.InvalidPortRange as ex:
LOG.debug(_('InvalidPortRange raised: %s'), unicode(ex),
context=context)
return self._error(req, context, type(ex).__name__, unicode(ex))
except Exception as ex:
extra = {'environment': req.environ}
LOG.exception(_('Unexpected error raised: %s'), unicode(ex),
extra=extra, context=context)
return self._error(req,
context,
'UnknownError',
_('An unknown error has occurred. '
'Please try your request again.'))
else:
resp = webob.Response()
resp.status = 200
resp.headers['Content-Type'] = 'text/xml'
resp.body = str(result)
return resp
开发者ID:YouthSun,项目名称:nova,代码行数:60,代码来源:__init__.py
示例2: __call__
def __call__(self, req):
context = req.environ["nova.context"]
api_request = req.environ["ec2.request"]
try:
result = api_request.invoke(context)
except exception.InstanceNotFound as ex:
ec2_id = ec2utils.id_to_ec2_inst_id(ex.kwargs["instance_id"])
message = ex.msg_fmt % {"instance_id": ec2_id}
return ec2_error_ex(ex, req, message=message)
except exception.VolumeNotFound as ex:
ec2_id = ec2utils.id_to_ec2_vol_id(ex.kwargs["volume_id"])
message = ex.msg_fmt % {"volume_id": ec2_id}
return ec2_error_ex(ex, req, message=message)
except exception.SnapshotNotFound as ex:
ec2_id = ec2utils.id_to_ec2_snap_id(ex.kwargs["snapshot_id"])
message = ex.msg_fmt % {"snapshot_id": ec2_id}
return ec2_error_ex(ex, req, message=message)
except (
exception.CannotDisassociateAutoAssignedFloatingIP,
exception.FloatingIpAssociated,
exception.FloatingIpNotFound,
exception.FloatingIpBadRequest,
exception.ImageNotActive,
exception.InvalidInstanceIDMalformed,
exception.InvalidVolumeIDMalformed,
exception.InvalidKeypair,
exception.InvalidParameterValue,
exception.InvalidPortRange,
exception.InvalidVolume,
exception.KeyPairExists,
exception.KeypairNotFound,
exception.MissingParameter,
exception.NoFloatingIpInterface,
exception.NoMoreFixedIps,
exception.Forbidden,
exception.QuotaError,
exception.SecurityGroupExists,
exception.SecurityGroupLimitExceeded,
exception.SecurityGroupRuleExists,
exception.VolumeUnattached,
# Following aren't translated to valid EC2 errors.
exception.ImageNotFound,
exception.ImageNotFoundEC2,
exception.InvalidAttribute,
exception.InvalidRequest,
exception.NotFound,
) as ex:
return ec2_error_ex(ex, req)
except Exception as ex:
return ec2_error_ex(ex, req, unexpected=True)
else:
resp = webob.Response()
resp.status = 200
resp.headers["Content-Type"] = "text/xml"
resp.body = str(result)
return resp
开发者ID:dido18,项目名称:nova,代码行数:56,代码来源:__init__.py
示例3: __call__
def __call__(self, req):
context = req.environ['nova.context']
api_request = req.environ['ec2.request']
result = None
try:
result = api_request.invoke(context)
except exception.InstanceNotFound as ex:
ec2_id = ec2utils.id_to_ec2_inst_id(ex.kwargs['instance_id'])
message = ex.msg_fmt % {'instance_id': ec2_id}
return ec2_error_ex(ex, req, message=message)
except exception.VolumeNotFound as ex:
ec2_id = ec2utils.id_to_ec2_vol_id(ex.kwargs['volume_id'])
message = ex.msg_fmt % {'volume_id': ec2_id}
return ec2_error_ex(ex, req, message=message)
except exception.SnapshotNotFound as ex:
ec2_id = ec2utils.id_to_ec2_snap_id(ex.kwargs['snapshot_id'])
message = ex.msg_fmt % {'snapshot_id': ec2_id}
return ec2_error_ex(ex, req, message=message)
except exception.KeyPairExists as ex:
code = 'InvalidKeyPair.Duplicate'
return ec2_error_ex(ex, req, code=code)
except exception.InvalidKeypair as ex:
code = 'InvalidKeyPair.Format'
return ec2_error_ex(ex, req, code=code)
except (exception.EC2APIError,
exception.NotFound,
exception.KeypairNotFound,
exception.SecurityGroupExists,
exception.InvalidParameterValue,
exception.InvalidPortRange,
exception.NotAuthorized,
exception.InvalidRequest,
exception.InvalidAttribute,
exception.InvalidPortRange,
exception.QuotaError,
exception.MissingParameter,
exception.InvalidInstanceIDMalformedEC2) as ex:
return ec2_error_ex(ex, req)
except Exception as ex:
return ec2_error_ex(ex, req, unexpected=True)
else:
resp = webob.Response()
resp.status = 200
resp.headers['Content-Type'] = 'text/xml'
resp.body = str(result)
return resp
开发者ID:ainiaa,项目名称:nova,代码行数:46,代码来源:__init__.py
示例4: __call__
def __call__(self, req):
context = req.environ["nova.context"]
api_request = req.environ["ec2.request"]
result = None
try:
result = api_request.invoke(context)
except exception.InstanceNotFound as ex:
ec2_id = ec2utils.id_to_ec2_inst_id(ex.kwargs["instance_id"])
message = ex.msg_fmt % {"instance_id": ec2_id}
return ec2_error_ex(ex, req, message=message)
except exception.VolumeNotFound as ex:
ec2_id = ec2utils.id_to_ec2_vol_id(ex.kwargs["volume_id"])
message = ex.msg_fmt % {"volume_id": ec2_id}
return ec2_error_ex(ex, req, message=message)
except exception.SnapshotNotFound as ex:
ec2_id = ec2utils.id_to_ec2_snap_id(ex.kwargs["snapshot_id"])
message = ex.msg_fmt % {"snapshot_id": ec2_id}
return ec2_error_ex(ex, req, message=message)
except exception.KeyPairExists as ex:
code = "InvalidKeyPair.Duplicate"
return ec2_error_ex(ex, req, code=code)
except exception.InvalidKeypair as ex:
code = "InvalidKeyPair.Format"
return ec2_error_ex(ex, req, code=code)
except (
exception.EC2APIError,
exception.NotFound,
exception.InvalidParameterValue,
exception.InvalidPortRange,
exception.NotAuthorized,
exception.InvalidRequest,
exception.QuotaError,
exception.InvalidInstanceIDMalformed,
) as ex:
return ec2_error_ex(ex, req)
except Exception as ex:
return ec2_error_ex(ex, req, unexpected=True)
else:
resp = webob.Response()
resp.status = 200
resp.headers["Content-Type"] = "text/xml"
resp.body = str(result)
return resp
开发者ID:jziub,项目名称:nova,代码行数:43,代码来源:__init__.py
示例5: test_id_to_ec2_id
def test_id_to_ec2_id(self):
self.assertEqual(ec2utils.id_to_ec2_id(30), "i-0000001e")
self.assertEqual(ec2utils.id_to_ec2_id(29, "ami-%08x"), "ami-0000001d")
self.assertEqual(ec2utils.id_to_ec2_snap_id(28), "snap-0000001c")
self.assertEqual(ec2utils.id_to_ec2_vol_id(27), "vol-0000001b")
开发者ID:renuka-apte,项目名称:nova,代码行数:5,代码来源:test_api.py
示例6: __call__
def __call__(self, req):
context = req.environ['nova.context']
request_id = context.request_id
api_request = req.environ['ec2.request']
result = None
try:
result = api_request.invoke(context)
except exception.InstanceNotFound as ex:
LOG.info(_('InstanceNotFound raised: %s'), unicode(ex),
context=context)
ec2_id = ec2utils.id_to_ec2_inst_id(ex.kwargs['instance_id'])
message = ex.message % {'instance_id': ec2_id}
return ec2_error(req, request_id, type(ex).__name__, message)
except exception.VolumeNotFound as ex:
LOG.info(_('VolumeNotFound raised: %s'), unicode(ex),
context=context)
ec2_id = ec2utils.id_to_ec2_vol_id(ex.kwargs['volume_id'])
message = ex.message % {'volume_id': ec2_id}
return ec2_error(req, request_id, type(ex).__name__, message)
except exception.SnapshotNotFound as ex:
LOG.info(_('SnapshotNotFound raised: %s'), unicode(ex),
context=context)
ec2_id = ec2utils.id_to_ec2_snap_id(ex.kwargs['snapshot_id'])
message = ex.message % {'snapshot_id': ec2_id}
return ec2_error(req, request_id, type(ex).__name__, message)
except exception.NotFound as ex:
LOG.info(_('NotFound raised: %s'), unicode(ex), context=context)
return ec2_error(req, request_id, type(ex).__name__, unicode(ex))
except exception.EC2APIError as ex:
LOG.exception(_('EC2APIError raised: %s'), unicode(ex),
context=context)
if ex.code:
return ec2_error(req, request_id, ex.code, unicode(ex))
else:
return ec2_error(req, request_id, type(ex).__name__,
unicode(ex))
except exception.KeyPairExists as ex:
LOG.debug(_('KeyPairExists raised: %s'), unicode(ex),
context=context)
return ec2_error(req, request_id, type(ex).__name__, unicode(ex))
except exception.InvalidParameterValue as ex:
LOG.debug(_('InvalidParameterValue raised: %s'), unicode(ex),
context=context)
return ec2_error(req, request_id, type(ex).__name__, unicode(ex))
except exception.InvalidPortRange as ex:
LOG.debug(_('InvalidPortRange raised: %s'), unicode(ex),
context=context)
return ec2_error(req, request_id, type(ex).__name__, unicode(ex))
except exception.NotAuthorized as ex:
LOG.info(_('NotAuthorized raised: %s'), unicode(ex),
context=context)
return ec2_error(req, request_id, type(ex).__name__, unicode(ex))
except exception.InvalidRequest as ex:
LOG.debug(_('InvalidRequest raised: %s'), unicode(ex),
context=context)
return ec2_error(req, request_id, type(ex).__name__, unicode(ex))
except exception.QuotaError as ex:
LOG.debug(_('QuotaError raised: %s'), unicode(ex),
context=context)
return ec2_error(req, request_id, type(ex).__name__, unicode(ex))
except exception.InvalidInstanceIDMalformed as ex:
LOG.debug(_('Invalid id: bogus (expecting "i-..."): %s'),
unicode(ex), context=context)
return ec2_error(req, request_id, type(ex).__name__, unicode(ex))
except Exception as ex:
env = req.environ.copy()
for k in env.keys():
if not isinstance(env[k], basestring):
env.pop(k)
LOG.exception(_('Unexpected error raised: %s'), unicode(ex))
LOG.error(_('Environment: %s') % jsonutils.dumps(env))
return ec2_error(req, request_id, 'UnknownError',
_('An unknown error has occurred. '
'Please try your request again.'))
else:
resp = webob.Response()
resp.status = 200
resp.headers['Content-Type'] = 'text/xml'
resp.body = str(result)
return resp
开发者ID:isolosun,项目名称:nova,代码行数:81,代码来源:__init__.py
示例7: __call__
def __call__(self, req):
context = req.environ["nova.context"]
request_id = context.request_id
api_request = req.environ["ec2.request"]
result = None
try:
result = api_request.invoke(context)
except exception.InstanceNotFound as ex:
LOG.info(_("InstanceNotFound raised: %s"), unicode(ex), context=context)
ec2_id = ec2utils.id_to_ec2_inst_id(ex.kwargs["instance_id"])
message = ex.message % {"instance_id": ec2_id}
return ec2_error(req, request_id, type(ex).__name__, message)
except exception.VolumeNotFound as ex:
LOG.info(_("VolumeNotFound raised: %s"), unicode(ex), context=context)
ec2_id = ec2utils.id_to_ec2_vol_id(ex.kwargs["volume_id"])
message = ex.message % {"volume_id": ec2_id}
return ec2_error(req, request_id, type(ex).__name__, message)
except exception.SnapshotNotFound as ex:
LOG.info(_("SnapshotNotFound raised: %s"), unicode(ex), context=context)
ec2_id = ec2utils.id_to_ec2_snap_id(ex.kwargs["snapshot_id"])
message = ex.message % {"snapshot_id": ec2_id}
return ec2_error(req, request_id, type(ex).__name__, message)
except exception.NotFound as ex:
LOG.info(_("NotFound raised: %s"), unicode(ex), context=context)
return ec2_error(req, request_id, type(ex).__name__, unicode(ex))
except exception.EC2APIError as ex:
if ex.code:
return ec2_error(req, request_id, ex.code, unicode(ex))
else:
return ec2_error(req, request_id, type(ex).__name__, unicode(ex))
except exception.KeyPairExists as ex:
LOG.debug(_("KeyPairExists raised: %s"), unicode(ex), context=context)
code = "InvalidKeyPair.Duplicate"
return ec2_error(req, request_id, code, unicode(ex))
except exception.InvalidKeypair as ex:
LOG.debug(_("InvalidKeypair raised: %s"), unicode(ex), context)
code = "InvalidKeyPair.Format"
return ec2_error(req, request_id, code, unicode(ex))
except exception.InvalidParameterValue as ex:
LOG.debug(_("InvalidParameterValue raised: %s"), unicode(ex), context=context)
return ec2_error(req, request_id, type(ex).__name__, unicode(ex))
except exception.InvalidPortRange as ex:
LOG.debug(_("InvalidPortRange raised: %s"), unicode(ex), context=context)
return ec2_error(req, request_id, type(ex).__name__, unicode(ex))
except exception.NotAuthorized as ex:
LOG.info(_("NotAuthorized raised: %s"), unicode(ex), context=context)
return ec2_error(req, request_id, type(ex).__name__, unicode(ex))
except exception.InvalidRequest as ex:
LOG.debug(_("InvalidRequest raised: %s"), unicode(ex), context=context)
return ec2_error(req, request_id, type(ex).__name__, unicode(ex))
except exception.QuotaError as ex:
LOG.debug(_("QuotaError raised: %s"), unicode(ex), context=context)
return ec2_error(req, request_id, type(ex).__name__, unicode(ex))
except exception.InvalidInstanceIDMalformed as ex:
LOG.debug(_('Invalid id: bogus (expecting "i-..."): %s'), unicode(ex), context=context)
return ec2_error(req, request_id, type(ex).__name__, unicode(ex))
except Exception as ex:
env = req.environ.copy()
for k in env.keys():
if not isinstance(env[k], basestring):
env.pop(k)
LOG.exception(_("Unexpected error raised: %s"), unicode(ex))
LOG.error(_("Environment: %s") % jsonutils.dumps(env))
return ec2_error(
req, request_id, "UnknownError", _("An unknown error has occurred. " "Please try your request again.")
)
else:
resp = webob.Response()
resp.status = 200
resp.headers["Content-Type"] = "text/xml"
resp.body = str(result)
return resp
开发者ID:JacobMulero,项目名称:nova,代码行数:73,代码来源:__init__.py
注:本文中的nova.api.ec2.ec2utils.id_to_ec2_vol_id函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论