當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。