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


Python exceptions.NotFound方法代码示例

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


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

示例1: _cleanup_bogus_pool

# 需要导入模块: from neutronclient.common import exceptions [as 别名]
# 或者: from neutronclient.common.exceptions import NotFound [as 别名]
def _cleanup_bogus_pool(self, neutron, pool, lb_algorithm):
        # REVISIT(ivc): LBaaSv2 creates pool object despite raising an
        # exception. The created pool is not bound to listener, but
        # it is bound to loadbalancer and will cause an error on
        # 'release_loadbalancer'.
        pools = neutron.list_lbaas_pools(
            name=pool.name, project_id=pool.project_id,
            loadbalancer_id=pool.loadbalancer_id,
            protocol=pool.protocol, lb_algorithm=lb_algorithm)
        bogus_pool_ids = [p['id'] for p in pools.get('pools')
                          if not p['listeners']]
        for pool_id in bogus_pool_ids:
            try:
                LOG.debug("Removing bogus pool %(id)s %(pool)s", {
                    'id': pool_id, 'pool': pool})
                neutron.delete_lbaas_pool(pool_id)
            except (n_exc.NotFound, n_exc.StateInvalidClient):
                pass 
开发者ID:openstack,项目名称:kuryr-kubernetes,代码行数:20,代码来源:lbaasv2.py

示例2: delete_all_lbaas_pools

# 需要导入模块: from neutronclient.common import exceptions [as 别名]
# 或者: from neutronclient.common.exceptions import NotFound [as 别名]
def delete_all_lbaas_pools(self):
        for pool in super(NeutronClientPollingManager, self)\
                .list_lbaas_pools()['pools']:
            try:
                self.delete_lbaas_pool(pool['id'])
            except NotFound:
                continue
        attempts = 0
        while super(NeutronClientPollingManager, self)\
                .list_lbaas_pools()['pools']:
            time.sleep(self.interval)
            attempts = attempts + 1
            if attempts > self.max_attempts:
                raise MaximumNumberOfAttemptsExceeded
        return True

    # Begin member section 
开发者ID:F5Networks,项目名称:f5-openstack-test,代码行数:19,代码来源:polling_clients.py

示例3: _safe_get_floating_ips

# 需要导入模块: from neutronclient.common import exceptions [as 别名]
# 或者: from neutronclient.common.exceptions import NotFound [as 别名]
def _safe_get_floating_ips(self, client, **kwargs):
        """Get floating IP gracefully handling 404 from Neutron."""
        try:
            return client.list_floatingips(**kwargs)['floatingips']
        # If a neutron plugin does not implement the L3 API a 404 from
        # list_floatingips will be raised.
        except neutron_exceptions.NotFound:
            return []
        except neutron_exceptions.NeutronClientException as e:
            # bug/1513879 neutron client is currently using
            # NeutronClientException when there is no L3 API
            if e.status_code == 404:
                return []
            with excutils.save_and_reraise_exception():
                LOG.exception('Unable to access floating IP for %s',
                              ', '.join(['%s %s' % (k, v)
                                         for k, v in kwargs.items()])) 
开发者ID:openstack,项目名称:mogan,代码行数:19,代码来源:api.py

示例4: _safe_get_floating_ips

# 需要导入模块: from neutronclient.common import exceptions [as 别名]
# 或者: from neutronclient.common.exceptions import NotFound [as 别名]
def _safe_get_floating_ips(self, client, **kwargs):
        """Get floating IP gracefully handling 404 from Neutron."""
        try:
            return client.list_floatingips(**kwargs)['floatingips']
        # If a neutron plugin does not implement the L3 API a 404 from
        # list_floatingips will be raised.
        except neutron_client_exc.NotFound:
            return []
        except neutron_client_exc.NeutronClientException as e:
            # bug/1513879 neutron client is currently using
            # NeutronClientException when there is no L3 API
            if e.status_code == 404:
                return []
            with excutils.save_and_reraise_exception():
                LOG.exception(_LE('Unable to access floating IP for %s'),
                        ', '.join(['%s %s' % (k, v)
                                   for k, v in six.iteritems(kwargs)])) 
开发者ID:BU-NU-CLOUD-SP16,项目名称:Trusted-Platform-Module-nova,代码行数:19,代码来源:api.py

示例5: test_release_not_found

# 需要导入模块: from neutronclient.common import exceptions [as 别名]
# 或者: from neutronclient.common.exceptions import NotFound [as 别名]
def test_release_not_found(self):
        cls = d_lbaasv2.LBaaSv2Driver
        m_driver = mock.Mock(spec=d_lbaasv2.LBaaSv2Driver)
        loadbalancer = mock.sentinel.loadbalancer
        obj = mock.sentinel.obj
        m_delete = mock.Mock()
        timer = [mock.sentinel.t0, mock.sentinel.t1]
        m_driver._provisioning_timer.return_value = timer
        m_delete.side_effect = n_exc.NotFound

        cls._release(m_driver, loadbalancer, obj, m_delete)

        m_driver._wait_for_provisioning.assert_not_called()
        self.assertEqual(1, m_delete.call_count) 
开发者ID:openstack,项目名称:kuryr-kubernetes,代码行数:16,代码来源:test_lbaasv2.py

示例6: _release

# 需要导入模块: from neutronclient.common import exceptions [as 别名]
# 或者: from neutronclient.common.exceptions import NotFound [as 别名]
def _release(self, loadbalancer, obj, delete, *args, **kwargs):
        for remaining in self._provisioning_timer(_ACTIVATION_TIMEOUT):
            try:
                try:
                    delete(*args, **kwargs)
                    return
                except (n_exc.Conflict, n_exc.StateInvalidClient):
                    self._wait_for_provisioning(loadbalancer, remaining)
            except n_exc.NotFound:
                return

        raise k_exc.ResourceNotReady(obj) 
开发者ID:openstack,项目名称:kuryr-kubernetes,代码行数:14,代码来源:lbaasv2.py

示例7: handle_get

# 需要导入模块: from neutronclient.common import exceptions [as 别名]
# 或者: from neutronclient.common.exceptions import NotFound [as 别名]
def handle_get(self, cxt, resource, resource_id):
        try:
            client = self._get_client(cxt)
            return getattr(client, 'show_%s' % resource)(resource_id)[resource]
        except q_exceptions.ConnectionFailed:
            self.endpoint_url = None
            raise exceptions.EndpointNotAvailable(
                'neutron', client.httpclient.endpoint_url)
        except q_exceptions.NotFound:
            LOG.debug("%(resource)s %(resource_id)s not found",
                      {'resource': resource, 'resource_id': resource_id}) 
开发者ID:openstack,项目名称:trio2o,代码行数:13,代码来源:resource_handle.py

示例8: handle_delete

# 需要导入模块: from neutronclient.common import exceptions [as 别名]
# 或者: from neutronclient.common.exceptions import NotFound [as 别名]
def handle_delete(self, cxt, resource, resource_id):
        try:
            client = self._get_client(cxt)
            return getattr(client, 'delete_%s' % resource)(resource_id)
        except q_exceptions.ConnectionFailed:
            self.endpoint_url = None
            raise exceptions.EndpointNotAvailable(
                'neutron', client.httpclient.endpoint_url)
        except q_exceptions.NotFound:
            LOG.debug("Delete %(resource)s %(resource_id)s which not found",
                      {'resource': resource, 'resource_id': resource_id}) 
开发者ID:openstack,项目名称:trio2o,代码行数:13,代码来源:resource_handle.py

示例9: check_for_neutron_ext_support

# 需要导入模块: from neutronclient.common import exceptions [as 别名]
# 或者: from neutronclient.common.exceptions import NotFound [as 别名]
def check_for_neutron_ext_support():
    """Validates for mandatory extension support availability in neutron."""
    try:
        app.neutron.show_extension(MANDATORY_NEUTRON_EXTENSION)
    except n_exceptions.NeutronClientException as e:
        if e.status_code == n_exceptions.NotFound.status_code:
            raise exceptions.MandatoryApiMissing(
                "Neutron extension with alias '{0}' not found"
                            .format(MANDATORY_NEUTRON_EXTENSION)) 
开发者ID:openstack,项目名称:kuryr-libnetwork,代码行数:11,代码来源:controllers.py

示例10: check_for_neutron_tag_support

# 需要导入模块: from neutronclient.common import exceptions [as 别名]
# 或者: from neutronclient.common.exceptions import NotFound [as 别名]
def check_for_neutron_tag_support(ext_name):
    """Validates tag and tag-ext extension support availability in Neutron."""
    if ext_name == TAG_EXT_NEUTRON_EXTENSION:
        ext_rename = "tag_ext"
    else:
        ext_rename = ext_name
    setattr(app, ext_rename, True)
    try:
        app.neutron.show_extension(ext_name)
    except n_exceptions.NeutronClientException as e:
        setattr(app, ext_rename, False)
        if e.status_code == n_exceptions.NotFound.status_code:
            LOG.warning("Neutron extension %s not supported. "
                        "Continue without using them.", ext_name) 
开发者ID:openstack,项目名称:kuryr-libnetwork,代码行数:16,代码来源:controllers.py

示例11: _neutron_add_tag

# 需要导入模块: from neutronclient.common import exceptions [as 别名]
# 或者: from neutronclient.common.exceptions import NotFound [as 别名]
def _neutron_add_tag(resource_type, resource_id, tag):
    try:
        app.neutron.add_tag(resource_type, resource_id, tag)
    except n_exceptions.NotFound:
        LOG.warning("Neutron tags extension for given "
                    "resource type is not supported, "
                    "cannot add tag to %s.", resource_type) 
开发者ID:openstack,项目名称:kuryr-libnetwork,代码行数:9,代码来源:controllers.py

示例12: _lb_delete_helper

# 需要导入模块: from neutronclient.common import exceptions [as 别名]
# 或者: from neutronclient.common.exceptions import NotFound [as 别名]
def _lb_delete_helper(self, lbid):
        try:
            super(NeutronClientPollingManager, self)\
                .delete_loadbalancer(lbid)
        except NotFound:
            return True
        return False 
开发者ID:F5Networks,项目名称:f5-openstack-test,代码行数:9,代码来源:polling_clients.py

示例13: delete_all_lbaas_pool_members

# 需要导入模块: from neutronclient.common import exceptions [as 别名]
# 或者: from neutronclient.common.exceptions import NotFound [as 别名]
def delete_all_lbaas_pool_members(self, pool_id):
        for member in super(NeutronClientPollingManager, self)\
                .list_lbaas_members(pool_id)['members']:
            try:
                self.delete_lbaas_member(member['id'], pool_id)
            except NotFound:
                continue
        return True

    # Begin healthmonitor section 
开发者ID:F5Networks,项目名称:f5-openstack-test,代码行数:12,代码来源:polling_clients.py

示例14: delete_all_lbaas_healthmonitors

# 需要导入模块: from neutronclient.common import exceptions [as 别名]
# 或者: from neutronclient.common.exceptions import NotFound [as 别名]
def delete_all_lbaas_healthmonitors(self):
        for healthmonitor in\
                super(NeutronClientPollingManager, self)\
                .list_lbaas_healthmonitors()['healthmonitors']:
            try:
                self.delete_lbaas_healthmonitor(healthmonitor['id'])
            except NotFound:
                continue
        return True 
开发者ID:F5Networks,项目名称:f5-openstack-test,代码行数:11,代码来源:polling_clients.py

示例15: show

# 需要导入模块: from neutronclient.common import exceptions [as 别名]
# 或者: from neutronclient.common.exceptions import NotFound [as 别名]
def show(self, id_):
        try:
            return self._get_neutron_function(self.name, 'show')(id_)
        except n_err.NotFound as exc:
            raise error.NotFound(exc.message) 
开发者ID:openstack,项目名称:murano-plugin-networking-sfc,代码行数:7,代码来源:resource.py


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