service_registry.py 文件源码

python
阅读 17 收藏 0 点赞 0 评论 0

项目:FogLAMP 作者: foglamp 项目源码 文件源码
def unregister(request):
    """ Deregister a service

    :Example: curl -X DELETE  http://localhost:8082/foglamp/service/dc9bfc01-066a-4cc0-b068-9c35486db87f
    """

    try:
        service_id = request.match_info.get('service_id', None)

        if not service_id:
            raise web.HTTPBadRequest(reason='Service id is required')

        try:
            Service.Instances.get(idx=service_id)
        except Service.DoesNotExist:
            raise web.HTTPBadRequest(reason='Service with {} does not exist'.format(service_id))

        Service.Instances.unregister(service_id)

        _resp = {'id': str(service_id), 'message': 'Service unregistered'}

        return web.json_response(_resp)
    except ValueError as ex:
        raise web.HTTPNotFound(reason=str(ex))
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号