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


Python exceptions.EndpointNotFound方法代码示例

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


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

示例1: _get_prom_url

# 需要导入模块: from keystoneauth1 import exceptions [as 别名]
# 或者: from keystoneauth1.exceptions import EndpointNotFound [as 别名]
def _get_prom_url(self):
        # Get promenade url from Keystone session object

        ks_session = self._get_ks_session()

        try:
            prom_endpoint = ks_session.get_endpoint(
                interface='internal', service_type='kubernetesprovisioner')
        except exc.EndpointNotFound:
            self.logger.error("Could not find an internal interface"
                              " defined in Keystone for Promenade")

            raise errors.DriverError("Could not find an internal interface"
                                     " defined in Keystone for Promenade")

        prom_url = urlparse(prom_endpoint)

        return prom_url 
开发者ID:airshipit,项目名称:drydock,代码行数:20,代码来源:promenade_client.py

示例2: get_endpoint

# 需要导入模块: from keystoneauth1 import exceptions [as 别名]
# 或者: from keystoneauth1.exceptions import EndpointNotFound [as 别名]
def get_endpoint(endpoint):
    """
    Wraps calls to keystone for lookup of an endpoint by service type
    :param Endpoints endpoint: The endpoint to look up
    :returns: The url string of the endpoint
    :rtype: str
    :raises AppError: if the endpoint cannot be resolved
    """
    service_type = _get_service_type(endpoint)
    try:
        return _get_ks_session().get_endpoint(
            interface='internal',
            service_type=service_type)
    except exc.EndpointNotFound:
        LOG.error('Could not find an internal interface for %s',
                  endpoint.name)
        raise AppError(
            title='Can not access service endpoint',
            description=(
                'Keystone catalog has no internal endpoint for service type: '
                '{}'.format(service_type)
            ),
            status=falcon.HTTP_500,
            retry=False) 
开发者ID:airshipit,项目名称:shipyard,代码行数:26,代码来源:service_endpoints.py

示例3: test_ensure_resource_provider_create_no_placement

# 需要导入模块: from keystoneauth1 import exceptions [as 别名]
# 或者: from keystoneauth1.exceptions import EndpointNotFound [as 别名]
def test_ensure_resource_provider_create_no_placement(
            self, get_rpt_mock, refresh_mock, create_rp_mock):
        create_rp_mock.side_effect = ks_exc.EndpointNotFound('test')
        # No resource provider exists in the client's cache, and
        # _create_resource_provider raise because
        # Placement isn't running yet. Ensure we don't populate the resource
        # provider cache.
        get_rpt_mock.return_value = []

        self.assertRaises(
            exception.ResourceProviderCreationFailed,
            self.client._ensure_resource_provider, self.context,
            uuids.compute_node)

        get_rpt_mock.assert_called_once_with(self.context, uuids.compute_node)
        create_rp_mock.assert_called_once_with(
            self.context, uuids.compute_node, uuids.compute_node,
            parent_provider_uuid=None)
        self.assertFalse(self.client._provider_tree.exists(uuids.compute_node))
        refresh_mock.assert_not_called()
        self.assertRaises(
            ValueError,
            self.client._provider_tree.in_aggregates, uuids.compute_node, [])
        self.assertRaises(
            ValueError,
            self.client._provider_tree.has_traits, uuids.compute_node, []) 
开发者ID:openstack,项目名称:zun,代码行数:28,代码来源:test_report.py

示例4: test_get_providers_in_tree_ksa_exc

# 需要导入模块: from keystoneauth1 import exceptions [as 别名]
# 或者: from keystoneauth1.exceptions import EndpointNotFound [as 别名]
def test_get_providers_in_tree_ksa_exc(self):
        self.ks_adap_mock.get.side_effect = ks_exc.EndpointNotFound()
        self.assertRaises(
            ks_exc.ClientException,
            self.client.get_providers_in_tree, self.context, uuids.whatever) 
开发者ID:openstack,项目名称:zun,代码行数:7,代码来源:test_report.py

示例5: test_get_provider_traits_placement_comm_error

# 需要导入模块: from keystoneauth1 import exceptions [as 别名]
# 或者: from keystoneauth1.exceptions import EndpointNotFound [as 别名]
def test_get_provider_traits_placement_comm_error(self):
        """ksa ClientException raises through."""
        uuid = uuids.compute_node
        self.ks_adap_mock.get.side_effect = ks_exc.EndpointNotFound()
        self.assertRaises(ks_exc.ClientException,
                          self.client.get_provider_traits, self.context, uuid)
        expected_url = '/resource_providers/' + uuid + '/traits'
        self.ks_adap_mock.get.assert_called_once_with(
            expected_url,
            endpoint_filter=mock.ANY,
            logger=mock.ANY,
            headers={'X-Openstack-Request-Id': self.context.global_id},
            **self.trait_api_kwargs) 
开发者ID:openstack,项目名称:zun,代码行数:15,代码来源:test_report.py

示例6: test_remove_res_from_alloc_failed_to_get_alloc

# 需要导入模块: from keystoneauth1 import exceptions [as 别名]
# 或者: from keystoneauth1.exceptions import EndpointNotFound [as 别名]
def test_remove_res_from_alloc_failed_to_get_alloc(
            self, mock_get):
        mock_get.side_effect = ks_exc.EndpointNotFound()
        resources_to_remove = {
            uuids.rp1: {
                'NET_BW_EGR_KILOBIT_PER_SEC': 200,
                'NET_BW_IGR_KILOBIT_PER_SEC': 200,
            }
        }

        self.assertRaises(
            ks_exc.ClientException,
            self.client.remove_resources_from_container_allocation,
            self.context, uuids.consumer_uuid, resources_to_remove) 
开发者ID:openstack,项目名称:zun,代码行数:16,代码来源:test_report.py

示例7: _get_alarm_client

# 需要导入模块: from keystoneauth1 import exceptions [as 别名]
# 或者: from keystoneauth1.exceptions import EndpointNotFound [as 别名]
def _get_alarm_client(**ceilo_kwargs):
        """Get client for alarm manager that redirect to aodh."""
        # NOTE(sileht): the auth_plugin/keystone session cannot be copied
        # because they rely on threading module.
        auth_plugin = ceilo_kwargs.pop('auth_plugin', None)
        session = ceilo_kwargs.pop('session', None)

        kwargs = copy.deepcopy(ceilo_kwargs)
        kwargs["service_type"] = "alarming"
        aodh_endpoint = ceilo_kwargs.get('aodh_endpoint')

        if session:
            # keystone session can be shared between client
            ceilo_kwargs['session'] = kwargs['session'] = session
            if aodh_endpoint:
                kwargs['endpoint_override'] = aodh_endpoint
        elif auth_plugin and kwargs.get('auth_url'):
            ceilo_kwargs['auth_plugin'] = auth_plugin
            kwargs.pop('endpoint', None)
            kwargs['auth_plugin'] = monitoringclient.get_auth_plugin(
                aodh_endpoint, **kwargs)
        else:
            # Users may just provide ceilometer endpoint and token, and no
            # auth_url, in this case, we need 'aodh_endpoint' also to be
            # provided, otherwise we cannot get aodh endpoint from
            # keystone, and assume aodh is unavailable.
            return None

        try:
            # NOTE(sileht): try to use aodh

            c = monitoringclient._construct_http_client(**kwargs)
            c.get("/")
            return c
        except ka_exc.EndpointNotFound:
            return None
        except requests.exceptions.ConnectionError:
            return None 
开发者ID:nttcom,项目名称:eclcli,代码行数:40,代码来源:client.py

示例8: assert_client_cannot_get_endpoint

# 需要导入模块: from keystoneauth1 import exceptions [as 别名]
# 或者: from keystoneauth1.exceptions import EndpointNotFound [as 别名]
def assert_client_cannot_get_endpoint(self, client):
        self.assertRaises(ks_exceptions.EndpointNotFound,
                          client.containers.list)
        self.assertRaises(ks_exceptions.EndpointNotFound,
                          client.orders.list)
        self.assertRaises(ks_exceptions.EndpointNotFound,
                          client.secrets.list) 
开发者ID:openstack,项目名称:python-barbicanclient,代码行数:9,代码来源:test_client_connectivity.py

示例9: select_destinations

# 需要导入模块: from keystoneauth1 import exceptions [as 别名]
# 或者: from keystoneauth1.exceptions import EndpointNotFound [as 别名]
def select_destinations(self, context, containers, extra_specs):
        LOG.debug("Starting to schedule for containers: %s",
                  [c.uuid for c in containers])

        if not self.traits_ensured:
            self.placement_client._ensure_traits(context, consts.CUSTOM_TRAITS)
            self.traits_ensured = True

        alloc_reqs_by_rp_uuid, provider_summaries, allocation_request_version \
            = None, None, None
        request_filter.process_reqspec(context, extra_specs)
        resources = utils.resources_from_request_spec(
            context, containers[0], extra_specs)

        try:
            res = self.placement_client.get_allocation_candidates(context,
                                                                  resources)
            (alloc_reqs, provider_summaries, allocation_request_version) = res
        except (ks_exc.EndpointNotFound,
                ks_exc.MissingAuthPlugin,
                ks_exc.Unauthorized,
                ks_exc.DiscoveryFailure,
                ks_exc.ConnectFailure):
            # We have to handle the case that we failed to connect to the
            # Placement service.
            alloc_reqs, provider_summaries, allocation_request_version = (
                None, None, None)
        if not alloc_reqs:
            LOG.info("Got no allocation candidates from the Placement "
                     "API. This could be due to insufficient resources "
                     "or a temporary occurrence as compute nodes start "
                     "up.")
            raise exception.NoValidHost(reason="")
        else:
            # Build a dict of lists of allocation requests, keyed by
            # provider UUID, so that when we attempt to claim resources for
            # a host, we can grab an allocation request easily
            alloc_reqs_by_rp_uuid = collections.defaultdict(list)
            for ar in alloc_reqs:
                for rp_uuid in ar['allocations']:
                    alloc_reqs_by_rp_uuid[rp_uuid].append(ar)

        selections = self.driver.select_destinations(
            context, containers, extra_specs, alloc_reqs_by_rp_uuid,
            provider_summaries, allocation_request_version)
        return selections 
开发者ID:openstack,项目名称:zun,代码行数:48,代码来源:query.py

示例10: verify_project_id

# 需要导入模块: from keystoneauth1 import exceptions [as 别名]
# 或者: from keystoneauth1.exceptions import EndpointNotFound [as 别名]
def verify_project_id(context, project_id):
    """verify that a project_id exists.

    This attempts to verify that a project id exists. If it does not,
    an HTTPBadRequest is emitted.

    """
    session = ksa_loading.load_session_from_conf_options(
        CONF, 'keystone', auth=context.get_auth_plugin())
    adap = ksa_loading.load_adapter_from_conf_options(
        CONF, 'keystone',
        session=session, min_version=(3, 0), max_version=(3, 'latest'))
    try:
        resp = adap.get('/projects/%s' % project_id, raise_exc=False)
    except kse.EndpointNotFound:
        LOG.error(
            "Keystone identity service version 3.0 was not found. This might "
            "be because your endpoint points to the v2.0 versioned endpoint "
            "which is not supported. Please fix this.")
        raise exceptions.KeystoneCommunicationFailure(
            _("KeystoneV3 endpoint not found"))
    except kse.ClientException:
        # something is wrong, like there isn't a keystone v3 endpoint,
        # or nova isn't configured for the interface to talk to it;
        # we'll take the pass and default to everything being ok.
        LOG.info("Unable to contact keystone to verify project_id")
        return True

    if resp:
        # All is good with this 20x status
        return True
    elif resp.status_code == 404:
        # we got access, and we know this project is not there
        raise exceptions.InvalidProject(
            _("%s is not a valid project ID.") % project_id)

    elif resp.status_code == 403:
        # we don't have enough permission to verify this, so default
        # to "it's ok".
        LOG.info(
            "Insufficient permissions for user %(user)s to verify "
            "existence of project_id %(pid)s",
            {"user": context.user_id, "pid": project_id})
        return True
    else:
        LOG.warning(
            "Unexpected response from keystone trying to "
            "verify project_id %(pid)s - resp: %(code)s %(content)s",
            {"pid": project_id,
             "code": resp.status_code,
             "content": resp.content})
        # realize we did something wrong, but move on with a warning
        return True 
开发者ID:openstack,项目名称:designate,代码行数:55,代码来源:keystone.py

示例11: get_cinderclient

# 需要导入模块: from keystoneauth1 import exceptions [as 别名]
# 或者: from keystoneauth1.exceptions import EndpointNotFound [as 别名]
def get_cinderclient(self, context=None):
        if self.backend_group:
            glance_store = getattr(self.conf, self.backend_group)
        else:
            glance_store = self.conf.glance_store

        user_overriden = self.is_user_overriden()
        if user_overriden:
            username = glance_store.cinder_store_user_name
            password = glance_store.cinder_store_password
            project = glance_store.cinder_store_project_name
            url = glance_store.cinder_store_auth_address
        else:
            username = context.user
            password = context.auth_token
            project = context.tenant

            if glance_store.cinder_endpoint_template:
                url = glance_store.cinder_endpoint_template % context.to_dict()
            else:
                info = glance_store.cinder_catalog_info
                service_type, service_name, interface = info.split(':')
                try:
                    catalog = keystone_sc.ServiceCatalogV2(
                        context.service_catalog)
                    url = catalog.url_for(
                        region_name=glance_store.cinder_os_region_name,
                        service_type=service_type,
                        service_name=service_name,
                        interface=interface)
                except keystone_exc.EndpointNotFound:
                    reason = _("Failed to find Cinder from a service catalog.")
                    raise exceptions.BadStoreConfiguration(store_name="cinder",
                                                           reason=reason)

        c = cinderclient.Client(
            username, password, project, auth_url=url,
            region_name=glance_store.cinder_os_region_name,
            insecure=glance_store.cinder_api_insecure,
            retries=glance_store.cinder_http_retries,
            cacert=glance_store.cinder_ca_certificates_file)

        LOG.debug(
            'Cinderclient connection created for user %(user)s using URL: '
            '%(url)s.', {'user': username, 'url': url})

        # noauth extracts user_id:project_id from auth_token
        if not user_overriden:
            c.client.auth_token = context.auth_token or '%s:%s' % (username,
                                                                   project)
        c.client.management_url = url
        return c 
开发者ID:openstack,项目名称:glance_store,代码行数:54,代码来源:cinder.py

示例12: get_endpoint

# 需要导入模块: from keystoneauth1 import exceptions [as 别名]
# 或者: from keystoneauth1.exceptions import EndpointNotFound [as 别名]
def get_endpoint(ksa_adapter):
    """Get the endpoint URL represented by a keystoneauth1 Adapter.

    This method is equivalent to what

        ksa_adapter.get_endpoint()

    should do, if it weren't for a panoply of bugs.

    :param ksa_adapter: keystoneauth1.adapter.Adapter, appropriately set up
                        with an endpoint_override; or service_type, interface
                        (list) and auth/service_catalog.
    :return: String endpoint URL.
    :raise EndpointNotFound: If endpoint discovery fails.
    """
    # TODO(efried): This will be unnecessary once bug #1707993 is fixed.
    # (At least for the non-image case, until 1707995 is fixed.)
    if ksa_adapter.endpoint_override:
        return ksa_adapter.endpoint_override
    # TODO(efried): Remove this once bug #1707995 is fixed.
    if ksa_adapter.service_type == 'image':
        try:
            # LOG.warning(ksa_adapter.__dict__)
            return ksa_adapter.get_endpoint_data().catalog_url
        except AttributeError:
            # ksa_adapter.auth is a _ContextAuthPlugin, which doesn't have
            # get_endpoint_data.  Fall through to using get_endpoint().
            pass
    # TODO(efried): The remainder of this method reduces to
    # TODO(efried):     return ksa_adapter.get_endpoint()
    # TODO(efried): once bug #1709118 is fixed.
    # NOTE(efried): Id9bd19cca68206fc64d23b0eaa95aa3e5b01b676 may also do the
    #               trick, once it's in a ksa release.
    # The EndpointNotFound exception happens when _ContextAuthPlugin is in play
    # because its get_endpoint() method isn't yet set up to handle interface as
    # a list.  (It could also happen with a real auth if the endpoint isn't
    # there; but that's covered below.)
    try:
        return ksa_adapter.get_endpoint()
    except ks_exc.EndpointNotFound:
        pass

    interfaces = list(ksa_adapter.interface)
    for interface in interfaces:
        ksa_adapter.interface = interface
        try:
            return ksa_adapter.get_endpoint()
        except ks_exc.EndpointNotFound:
            pass
    raise ks_exc.EndpointNotFound(
        "Could not find requested endpoint for any of the following "
        "interfaces: %s" % interfaces) 
开发者ID:openstack,项目名称:cyborg,代码行数:54,代码来源:utils.py


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