当前位置: 首页>>代码示例>>Python>>正文


Python excutils.save_and_reraise_exception方法代码示例

本文整理汇总了Python中oslo_utils.excutils.save_and_reraise_exception方法的典型用法代码示例。如果您正苦于以下问题:Python excutils.save_and_reraise_exception方法的具体用法?Python excutils.save_and_reraise_exception怎么用?Python excutils.save_and_reraise_exception使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在oslo_utils.excutils的用法示例。


在下文中一共展示了excutils.save_and_reraise_exception方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _do_container_create

# 需要导入模块: from oslo_utils import excutils [as 别名]
# 或者: from oslo_utils.excutils import save_and_reraise_exception [as 别名]
def _do_container_create(self, context, container, requested_networks,
                             requested_volumes, pci_requests=None,
                             limits=None):
        LOG.debug('Creating container: %s', container.uuid)

        try:
            rt = self._get_resource_tracker()
            with rt.container_claim(context, container, pci_requests, limits):
                created_container = self._do_container_create_base(
                    context, container, requested_networks, requested_volumes,
                    limits)
                return created_container
        except exception.ResourcesUnavailable as e:
            with excutils.save_and_reraise_exception():
                LOG.exception("Container resource claim failed: %s",
                              str(e))
                self._fail_container(context, container, str(e),
                                     unset_host=True)
                self.reportclient.delete_allocation_for_container(
                    context, container.uuid) 
开发者ID:openstack,项目名称:zun,代码行数:22,代码来源:manager.py

示例2: _attach_volume

# 需要导入模块: from oslo_utils import excutils [as 别名]
# 或者: from oslo_utils.excutils import save_and_reraise_exception [as 别名]
def _attach_volume(self, context, container, volmap):
        driver = self._get_driver(container)
        context = context.elevated()
        LOG.info('Attaching volume %(volume_id)s to %(host)s',
                 {'volume_id': volmap.cinder_volume_id,
                  'host': CONF.host})
        try:
            driver.attach_volume(context, volmap)
        except Exception:
            with excutils.save_and_reraise_exception():
                LOG.error("Failed to attach volume %(volume_id)s to "
                          "container %(container_id)s",
                          {'volume_id': volmap.cinder_volume_id,
                           'container_id': volmap.container_uuid})
                if volmap.auto_remove:
                    try:
                        driver.delete_volume(context, volmap)
                    except Exception:
                        LOG.exception("Failed to delete volume %s.",
                                      volmap.cinder_volume_id)
                volmap.destroy() 
开发者ID:openstack,项目名称:zun,代码行数:23,代码来源:manager.py

示例3: _do_container_start

# 需要导入模块: from oslo_utils import excutils [as 别名]
# 或者: from oslo_utils.excutils import save_and_reraise_exception [as 别名]
def _do_container_start(self, context, container):
        LOG.debug('Starting container: %s', container.uuid)
        with self._update_task_state(context, container,
                                     consts.CONTAINER_STARTING):
            try:
                # NOTE(hongbin): capsule shouldn't reach here
                container = self.driver.start(context, container)
                container.started_at = timeutils.utcnow()
                container.save(context)
                return container
            except exception.DockerError as e:
                with excutils.save_and_reraise_exception():
                    LOG.error("Error occurred while calling Docker start "
                              "API: %s", str(e))
                    self._fail_container(context, container, str(e))
            except Exception as e:
                with excutils.save_and_reraise_exception():
                    LOG.exception("Unexpected exception: %s",
                                  str(e))
                    self._fail_container(context, container, str(e)) 
开发者ID:openstack,项目名称:zun,代码行数:22,代码来源:manager.py

示例4: detach_volume

# 需要导入模块: from oslo_utils import excutils [as 别名]
# 或者: from oslo_utils.excutils import save_and_reraise_exception [as 别名]
def detach_volume(self, context, volmap):
        volume_id = volmap.cinder_volume_id
        try:
            self.cinder_api.begin_detaching(volume_id)
        except cinder_exception.BadRequest as e:
            raise exception.Invalid(_("Invalid volume: %s") %
                                    str(e))

        conn_info = jsonutils.loads(volmap.connection_info)
        if not self._volume_connection_keep(context, volume_id):
            try:
                self._disconnect_volume(conn_info)
            except Exception:
                with excutils.save_and_reraise_exception():
                    LOG.exception('Failed to disconnect volume %(volume_id)s',
                                  {'volume_id': volume_id})
                    self.cinder_api.roll_detaching(volume_id)

            self.cinder_api.terminate_connection(
                volume_id, get_volume_connector_properties())
        self.cinder_api.detach(volmap) 
开发者ID:openstack,项目名称:zun,代码行数:23,代码来源:cinder_workflow.py

示例5: do_mount

# 需要导入模块: from oslo_utils import excutils [as 别名]
# 或者: from oslo_utils.excutils import save_and_reraise_exception [as 别名]
def do_mount(devpath, mountpoint, fstype):
    """Execute device mount operation.

    :param devpath: The path of mount device.
    :param mountpoint: The path of mount point.
    :param fstype: The file system type.
    """
    if check_already_mounted(mountpoint):
        return

    mounter = Mounter()
    try:
        mounter.mount(devpath, mountpoint, fstype)
    except exception.MountException:
        try:
            mounter.make_filesystem(devpath, fstype)
            mounter.mount(devpath, mountpoint, fstype)
        except exception.ZunException as e:
            with excutils.save_and_reraise_exception():
                LOG.error(e.message) 
开发者ID:openstack,项目名称:zun,代码行数:22,代码来源:mount.py

示例6: create_port_chain

# 需要导入模块: from oslo_utils import excutils [as 别名]
# 或者: from oslo_utils.excutils import save_and_reraise_exception [as 别名]
def create_port_chain(self, context, port_chain):
        with db_api.CONTEXT_WRITER.using(context):
            port_chain_db = super(SfcPlugin, self).create_port_chain(
                context, port_chain)
            portchain_db_context = sfc_ctx.PortChainContext(
                self, context, port_chain_db)
            self.driver_manager.create_port_chain_precommit(
                portchain_db_context)
        try:
            self.driver_manager.create_port_chain_postcommit(
                portchain_db_context)
        except sfc_exc.SfcDriverError as e:
            LOG.exception(e)
            with excutils.save_and_reraise_exception():
                LOG.error("Create port chain failed, "
                          "deleting port_chain '%s'",
                          port_chain_db['id'])
                self.delete_port_chain(context, port_chain_db['id'])

        return port_chain_db 
开发者ID:openstack,项目名称:networking-sfc,代码行数:22,代码来源:plugin.py

示例7: update_port_chain

# 需要导入模块: from oslo_utils import excutils [as 别名]
# 或者: from oslo_utils.excutils import save_and_reraise_exception [as 别名]
def update_port_chain(self, context, portchain_id, port_chain):
        with db_api.CONTEXT_WRITER.using(context):
            original_portchain = self.get_port_chain(context, portchain_id)
            updated_portchain = super(SfcPlugin, self).update_port_chain(
                context, portchain_id, port_chain)
            portchain_db_context = sfc_ctx.PortChainContext(
                self, context, updated_portchain,
                original_portchain=original_portchain)
            self.driver_manager.update_port_chain_precommit(
                portchain_db_context)

        try:
            self.driver_manager.update_port_chain_postcommit(
                portchain_db_context)
        except sfc_exc.SfcDriverError as e:
            LOG.exception(e)
            with excutils.save_and_reraise_exception():
                LOG.error("Update port chain failed, port_chain '%s'",
                          updated_portchain['id'])

        # TODO(qijing): should we rollback the database update here?
        return updated_portchain 
开发者ID:openstack,项目名称:networking-sfc,代码行数:24,代码来源:plugin.py

示例8: delete_port_chain

# 需要导入模块: from oslo_utils import excutils [as 别名]
# 或者: from oslo_utils.excutils import save_and_reraise_exception [as 别名]
def delete_port_chain(self, context, portchain_id):
        pc = self.get_port_chain(context, portchain_id)
        pc_context = sfc_ctx.PortChainContext(self, context, pc)
        try:
            self.driver_manager.delete_port_chain(pc_context)
        except sfc_exc.SfcDriverError as e:
            LOG.exception(e)
            with excutils.save_and_reraise_exception():
                LOG.error("Delete port chain failed, portchain '%s'",
                          portchain_id)

        # TODO(qijing): unsync in case deleted in driver but fail in database
        with db_api.CONTEXT_WRITER.using(context):
            pc = self.get_port_chain(context, portchain_id)
            pc_context = sfc_ctx.PortChainContext(self, context, pc)
            super(SfcPlugin, self).delete_port_chain(context, portchain_id)
            self.driver_manager.delete_port_chain_precommit(pc_context)
        self.driver_manager.delete_port_chain_postcommit(pc_context) 
开发者ID:openstack,项目名称:networking-sfc,代码行数:20,代码来源:plugin.py

示例9: create_port_pair

# 需要导入模块: from oslo_utils import excutils [as 别名]
# 或者: from oslo_utils.excutils import save_and_reraise_exception [as 别名]
def create_port_pair(self, context, port_pair):
        with db_api.CONTEXT_WRITER.using(context):
            portpair_db = super(SfcPlugin, self).create_port_pair(
                context, port_pair)
            portpair_context = sfc_ctx.PortPairContext(
                self, context, portpair_db)
            self.driver_manager.create_port_pair_precommit(portpair_context)

        try:
            self.driver_manager.create_port_pair_postcommit(portpair_context)
        except sfc_exc.SfcDriverError as e:
            LOG.exception(e)
            with excutils.save_and_reraise_exception():
                LOG.error("Create port pair failed, "
                          "deleting port_pair '%s'",
                          portpair_db['id'])
                self.delete_port_pair(context, portpair_db['id'])

        return portpair_db 
开发者ID:openstack,项目名称:networking-sfc,代码行数:21,代码来源:plugin.py

示例10: update_port_pair

# 需要导入模块: from oslo_utils import excutils [as 别名]
# 或者: from oslo_utils.excutils import save_and_reraise_exception [as 别名]
def update_port_pair(self, context, portpair_id, port_pair):
        with db_api.CONTEXT_WRITER.using(context):
            original_portpair = self.get_port_pair(context, portpair_id)
            updated_portpair = super(SfcPlugin, self).update_port_pair(
                context, portpair_id, port_pair)
            portpair_context = sfc_ctx.PortPairContext(
                self, context, updated_portpair,
                original_portpair=original_portpair)
            self.driver_manager.update_port_pair_precommit(portpair_context)
        try:
            self.driver_manager.update_port_pair_postcommit(portpair_context)
        except sfc_exc.SfcDriverError as e:
            LOG.exception(e)
            with excutils.save_and_reraise_exception():
                LOG.error("Update port pair failed, port_pair '%s'",
                          updated_portpair['id'])

        return updated_portpair 
开发者ID:openstack,项目名称:networking-sfc,代码行数:20,代码来源:plugin.py

示例11: create_port_pair_group

# 需要导入模块: from oslo_utils import excutils [as 别名]
# 或者: from oslo_utils.excutils import save_and_reraise_exception [as 别名]
def create_port_pair_group(self, context, port_pair_group):
        with db_api.CONTEXT_WRITER.using(context):
            portpairgroup_db = super(SfcPlugin, self).create_port_pair_group(
                context, port_pair_group)
            portpairgroup_context = sfc_ctx.PortPairGroupContext(
                self, context, portpairgroup_db)
            self.driver_manager.create_port_pair_group_precommit(
                portpairgroup_context)
        try:
            self.driver_manager.create_port_pair_group_postcommit(
                portpairgroup_context)
        except sfc_exc.SfcDriverError as e:
            LOG.exception(e)
            with excutils.save_and_reraise_exception():
                LOG.error("Create port pair group failed, "
                          "deleting port_pair_group '%s'",
                          portpairgroup_db['id'])
                self.delete_port_pair_group(context, portpairgroup_db['id'])

        return portpairgroup_db 
开发者ID:openstack,项目名称:networking-sfc,代码行数:22,代码来源:plugin.py

示例12: update_port_pair_group

# 需要导入模块: from oslo_utils import excutils [as 别名]
# 或者: from oslo_utils.excutils import save_and_reraise_exception [as 别名]
def update_port_pair_group(
        self, context, portpairgroup_id, port_pair_group
    ):
        with db_api.CONTEXT_WRITER.using(context):
            original_portpairgroup = self.get_port_pair_group(
                context, portpairgroup_id)
            updated_portpairgroup = super(
                SfcPlugin, self).update_port_pair_group(
                context, portpairgroup_id, port_pair_group)
            portpairgroup_context = sfc_ctx.PortPairGroupContext(
                self, context, updated_portpairgroup,
                original_portpairgroup=original_portpairgroup)
            self.driver_manager.update_port_pair_group_precommit(
                portpairgroup_context)
        try:
            self.driver_manager.update_port_pair_group_postcommit(
                portpairgroup_context)
        except sfc_exc.SfcDriverError as e:
            LOG.exception(e)
            with excutils.save_and_reraise_exception():
                LOG.error("Update port pair group failed, "
                          "port_pair_group '%s'",
                          updated_portpairgroup['id'])

        return updated_portpairgroup 
开发者ID:openstack,项目名称:networking-sfc,代码行数:27,代码来源:plugin.py

示例13: delete_port_pair_group

# 需要导入模块: from oslo_utils import excutils [as 别名]
# 或者: from oslo_utils.excutils import save_and_reraise_exception [as 别名]
def delete_port_pair_group(self, context, portpairgroup_id):
        portpairgroup = self.get_port_pair_group(context, portpairgroup_id)
        portpairgroup_context = sfc_ctx.PortPairGroupContext(
            self, context, portpairgroup)
        try:
            self.driver_manager.delete_port_pair_group(portpairgroup_context)
        except sfc_exc.SfcDriverError as e:
            LOG.exception(e)
            with excutils.save_and_reraise_exception():
                LOG.error("Delete port pair group failed, "
                          "port_pair_group '%s'",
                          portpairgroup_id)

        with db_api.CONTEXT_WRITER.using(context):
            portpairgroup = self.get_port_pair_group(context, portpairgroup_id)
            portpairgroup_context = sfc_ctx.PortPairGroupContext(
                self, context, portpairgroup)
            super(SfcPlugin, self).delete_port_pair_group(context,
                                                          portpairgroup_id)
            self.driver_manager.delete_port_pair_group_precommit(
                portpairgroup_context)
        self.driver_manager.delete_port_pair_group_postcommit(
            portpairgroup_context) 
开发者ID:openstack,项目名称:networking-sfc,代码行数:25,代码来源:plugin.py

示例14: create_service_graph

# 需要导入模块: from oslo_utils import excutils [as 别名]
# 或者: from oslo_utils.excutils import save_and_reraise_exception [as 别名]
def create_service_graph(self, context, service_graph):
        with db_api.CONTEXT_WRITER.using(context):
            service_graph_db = super(SfcPlugin, self).create_service_graph(
                context, service_graph)
            service_graph_db_context = sfc_ctx.ServiceGraphContext(
                self, context, service_graph_db)
            self.driver_manager.create_service_graph_precommit(
                service_graph_db_context)
        try:
            self.driver_manager.create_service_graph_postcommit(
                service_graph_db_context)
        except sfc_exc.SfcDriverError as e:
            LOG.exception(e)
            with excutils.save_and_reraise_exception():
                LOG.error("Create Service Graph failed, "
                          "deleting Service Graph '%s'",
                          service_graph_db['id'])
                self.delete_service_graph(context, service_graph_db['id'])

        return service_graph_db 
开发者ID:openstack,项目名称:networking-sfc,代码行数:22,代码来源:plugin.py

示例15: update_service_graph

# 需要导入模块: from oslo_utils import excutils [as 别名]
# 或者: from oslo_utils.excutils import save_and_reraise_exception [as 别名]
def update_service_graph(self, context, id, service_graph):
        with db_api.CONTEXT_WRITER.using(context):
            original_graph = self.get_service_graph(context, id)
            updated_graph = super(SfcPlugin, self).update_service_graph(
                context, id, service_graph)
            service_graph_db_context = sfc_ctx.ServiceGraphContext(
                self, context, updated_graph,
                original_graph=original_graph)
            self.driver_manager.update_service_graph_precommit(
                service_graph_db_context)
        try:
            self.driver_manager.update_service_graph_postcommit(
                service_graph_db_context)
        except sfc_exc.SfcDriverError:
            with excutils.save_and_reraise_exception():
                LOG.error("Update failed, service_graph '%s'",
                          updated_graph['id'])
        return updated_graph 
开发者ID:openstack,项目名称:networking-sfc,代码行数:20,代码来源:plugin.py


注:本文中的oslo_utils.excutils.save_and_reraise_exception方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。