Example #1
0
def delete_user(request, user_id):
    if request.is_ajax() and request.method == 'POST':
        token = request.session.get('passToken')
        auth_url = request.session.get('auth_url')
        keystone = KeystoneRestAPI(auth_url, token)
        result = keystone.delete_user(user_id)
        return JsonResponse(result)
Example #2
0
def delete_user_for_soa(request):
    if request.method == 'POST':
        result, data = login_soa(request)
        if result.get("success"):
            token = request.session.get("passToken")
            auth_url = data.get("auth_url")
            user_list = json.loads(data.get("user"))

            response_data = {}
            for user_id in user_list:
                keystone = KeystoneRestAPI(auth_url, token)
                result = keystone.delete_user(user_id)
                if result.get("success"):
                    deleted_user = result["success"].get("user")

                    params = (auth_url, user_id)

                    try:
                        soa_conn = SOAControlDBConnector.getInstance()
                        soa_conn.delete(INSERT_SOAC_USER, params)
                    except Exception as e:
                        logger.debug("soac 사용자 삭제 실패(" +
                                     deleted_user.get("name") + ")" + str(e))
                        result = {
                            "error": {
                                "title": e.message,
                                "message": "soac db insert user error",
                                "code": 500
                            }
                        }
                        # end except
                    # end if
                response_data[user_id.get("name")] = result
                # end for
            result = response_data
            # end if

        return JsonResponse(result)