Beispiel #1
0
    def post(self, project_name):
        # the
        #print "get vm_id"
        req_id = str(uuid.uuid4())
        data = request.get_json()
        #print data

        if data == None or "token" not in data:
            response = {
                'exe_result': False,
                'task_type': 'check',
                'req_id': req_id,
                'project_name': project_name,
                'error_msg': "data format illegal"
            }
            APILOG.info(
                "api.NetworkMonitorCheck.post - req-%s - project-%s request data format illegal"
                % (req_id, project_name))
            return response, 400

        msg = {
            'req_id': req_id,
            'project_name': project_name,
            'token': data['token']
        }

        print "api.NetworkMonitorCheck.post - req-%s - project-%s api get request:check project start" % (
            req_id, project_name)
        APILOG.info(
            "api.NetworkMonitorCheck.post - req-%s - project-%s api get request:check project start"
            % (req_id, project_name))

        # exception
        response = check_msg(msg)
        print "send task msg: %s" % (msg)

        if response['exe_result'] == False:
            APILOG.info(
                "api.NetworkMonitorCheck.post - req-%s - project-%s check project:fail info:%s"
                % (req_id, project_name, response['error_msg']))
            return response, 400
        else:
            print "api.NetworkMonitorCheck.post - req-%s - project-%s check project:success info:%s" % (
                req_id, project_name, response['result'])
            APILOG.info(
                "api.NetworkMonitorCheck.post - req-%s - project-%s check project:success info:%s"
                % (req_id, project_name, response['result']))
            return response, 200
Beispiel #2
0
    def post(self, project_name):
        # the vm resrource evalustion task post api
        #print "post vm_id"
        req_id = str(uuid.uuid4())
        data = request.get_json()

        if data == None or "token" not in data:
            response = {
                'exe_result': False,
                'task_type': 'get_status',
                'req_id': req_id,
                'project_name': project_name,
                'error_msg': "data format illegal"
            }
            APILOG.info(
                "api.NetworkMonitorStatus.post - req-%s - project-%s request data format illegal"
                % (req_id, project_name))
            return response, 400

        msg = {
            'req_id': req_id,
            'project_name': project_name,
            'token': data['token']
        }

        APILOG.info(
            "api.NetworkMonitorStatus.post - req-%s - project_name-%s api get request: get task status"
            % (req_id, project_name))

        # exception
        response = get_status(msg)

        if response['exe_result'] == False:
            APILOG.info(
                "api.ResourceEvaluate.post - req-%s - project_name-%s get status:fail info:%s"
                % (req_id, project_name, response['error_msg']))
            return response, 400
        else:
            APILOG.info(
                "api.ResourceEvaluate.post - req-%s - project_name-%s get status:success info:%s"
                % (req_id, project_name, response['result']))
            return response, 200
Beispiel #3
0
    def post(self, project_name):
        # write log
        req_id = str(uuid.uuid4())
        data = request.get_json()

        if data == None or "token" not in data:
            response = {
                'exe_result': False,
                'task_type': 'get_history',
                'req_id': req_id,
                'project_name': project_name,
                'error_msg': "data format illegal"
            }
            APILOG.info(
                "api.NetworkMonitorHistory.post - req-%s - project-%s request data format illegal"
                % (req_id, project_name))
            return response, 400

        msg = {
            "project_name": project_name,
            "req_id": req_id,
            "token": data["token"]
        }

        APILOG.info(
            "api.NetworkMonitorHistory.post - req-%s - project-%s api post request:get history"
            % (req_id, project_name))

        # exception
        response = get_history(msg)

        if response['exe_result']:
            APILOG.info(
                "api.NetworkMonitorHistory.post - req-%s - project-%s get history:success info:%s"
                % (req_id, project_name, response['result']))
            return response, 200
        else:
            APILOG.info(
                "api.NetworkMonitorHistory.post - req-%s - project-%s get history:fail info:%s"
                % (req_id, project_name, response['error_msg']))
            return response, 400
Beispiel #4
0
    def get(self, project_name):
        # write log
        req_id = str(uuid.uuid4())
        token = request.args.get("token")
        #project_name = request.args.get("project")

        if token == None or project_name == None:
            response = {
                'exe_result': False,
                'task_type': 'get_history',
                'req_id': req_id,
                'project_name': project_name,
                'error_msg': "url format illegal"
            }
            APILOG.info(
                "api.NetworkMonitorHistory.post - req-%s - project-%s request data format illegal"
                % (req_id, project_name))
            return response, 400

        msg = {"project_name": project_name, "req_id": req_id, "token": token}

        APILOG.info(
            "api.NetworkMonitorHistory.post - req-%s - project-%s api get request:get history"
            % (req_id, project_name))

        # exception
        response = get_history(msg)

        if response['exe_result']:
            APILOG.info(
                "api.NetworkMonitorHistory.post - req-%s - project-%s get history:success info:%s"
                % (req_id, project_name, response['result']))
            return response, 200
        else:
            APILOG.info(
                "api.NetworkMonitorHistory.post - req-%s - project-%s get history:fail info:%s"
                % (req_id, project_name, response['error_msg']))
            return response, 400
def handler(signum, frame):
    APILOG.info("sigterm")
    os.exit(0)