示例#1
0
def get_kconnect_config():
    """
    return all config of kafka connect connectors
    vne::tbd:: validate auth token
    """
    try:
        if appconfig.get_app_module() != 'kconnect':
            #print 'Invalid Module'
            appconfig.get_app_logger().error('Invalid Module, %s, %s',
                                             appconfig.get_app_module(),
                                             request.url)
            return {"success": False, "error": "Invalid Request"}

        #print 'GET received', request, rbody
        appconfig.get_app_logger().info('GET received, %s', request)

        return {
            "success": True,
            "config": json.dumps(appconfig.get_kconnect_config())
        }
    except:
        appconfig.get_app_logger().exception(
            'Invalid Request. Some Exception, %s, %s',
            appconfig.get_app_module(), request.url)
        return {"success": False, "error": "Invalid Request. Some Exception"}
示例#2
0
def delete_kconnect_connector():
    """
    delete kafka connect connector 
    api/v1/internal/kconnect?authToken=<secret>&name=<connector name>
    use + in case of query params
    """
    try:
        if appconfig.get_app_module() != 'kconnect':
            #print 'Invalid Module'
            appconfig.get_app_logger().error('Invalid Module, %s, %s',
                                             appconfig.get_app_module(),
                                             request.url)
            return {"success": False, "error": "Invalid Request"}

        rbody = {}
        rbody['auth_token'] = request.query.auth_token or 'None'
        rbody['name'] = request.query.name or 'None'

        #Extract JSON payload
        #        rbody = json.load(request.body)
        #print 'POST received', request, rbody
        appconfig.get_app_logger().info('DELETE received, %s:%s', request,
                                        rbody)

        return process_delete_kconnect(rbody)
    except:
        appconfig.get_app_logger().exception(
            'Invalid Request. Some Exception, %s, %s',
            appconfig.get_app_module(), request.url)
        return {"success": False, "error": "Invalid Request. Some Exception"}
示例#3
0
def update_connection_config():
    """
    update MQTT connection appconfig if it already exists. 
    If it doesn't, return error 
    """

    if appconfig.get_app_module() != 'web':
        #print 'Invalid Module'
        appconfig.get_app_logger().error('Invalid Module, %s, %s',
                                         appconfig.get_app_module(),
                                         request.url)
        return {"success": False, "error": "Invalid Request"}

    try:
        #Extract JSON payload
        rbody = json.load(request.body)
        #print 'PUT received', request, rbody
        appconfig.get_app_logger().info('PUT received, %s:%s', request, rbody)

        return process_connection_config_v1(rbody)
    except:
        appconfig.get_app_logger().exception(
            'Invalid Request. Some Exception, %s, %s',
            appconfig.get_app_module(), request.url)
        return {"success": False, "error": "Invalid Request. Some Exception"}
示例#4
0
def main():
    
    global g_config
    if len (sys.argv) != 2:
        print "Usage: python main.py <web|mqtt|kconnect>"
        sys.exit(1)   
    
    config_file = 'config.json'
    init_config(config_file, sys.argv[1])
    if appconfig.get_app_module() == 'kconnect':
        appconfig.get_kconnect_sync_thrid().start()
    rest.start_rest_mod()
    
    if appconfig.get_app_module() == 'kconnect':
        appconfig.get_kconnect_sync_thrid().join() 
示例#5
0
def get_connection_config():
    """
    read MQTT current appconfig and send in HTTP response 
    """
    #print 'GET received'
    try:
        if appconfig.get_app_module() != 'web':
            appconfig.get_app_logger().error('Invalid Module, %s, %s',
                                             appconfig.get_app_module(),
                                             request.url)
            return {"success": False, "error": "Invalid Request"}

        return {"success": False, "error": "Not Implemented"}
    except:
        appconfig.get_app_logger().exception(
            'Invalid Request. Some Exception, %s, %s',
            appconfig.get_app_module(), request.url)
        return {"success": False, "error": "Invalid Request. Some Exception"}
示例#6
0
def get_vmq_config():
    """

    """
    #print 'GET received'

    try:
        if appconfig.get_app_module() != 'mqtt':
            #print 'Invalid Module'
            appconfig.get_app_logger().error('Invalid Module, %s, %s',
                                             appconfig.get_app_module(),
                                             request.url)
            return {"success": False, "error": "Invalid Request"}

        return {"success": False, "error": "Not Implemented"}
    except:
        appconfig.get_app_logger().exception(
            'Invalid Request. Some Exception, %s, %s',
            appconfig.get_app_module(), request.url)
        return {"success": False, "error": "Invalid Request. Some Exception"}
示例#7
0
def delete_connection_config():
    """
    Delete MQTT Connection appconfig it is already exists
    If it doesn't, return error 
    turn OFF the Nginx as well
    """
    #print 'DELETE received'
    try:
        if appconfig.get_app_module() != 'web':
            #print 'Invalid Module'
            appconfig.get_app_logger().error('Invalid Module, %s, %s',
                                             appconfig.get_app_module(),
                                             request.url)
            return {"success": False, "error": "Invalid Request"}

        #vne:: tbd: Stop Nginx server
        return {"success": False, "error": "Not Implemented"}
    except:
        appconfig.get_app_logger().exception(
            'Invalid Request. Some Exception, %s, %s',
            appconfig.get_app_module(), request.url)
        return {"success": False, "error": "Invalid Request. Some Exception"}
示例#8
0
def update_kconnect_connector():
    """
    Update an existing kafka connect connector 
    """
    try:
        if appconfig.get_app_module() != 'kconnect':
            #print 'Invalid Module'
            appconfig.get_app_logger().error('Invalid Module, %s, %s',
                                             appconfig.get_app_module(),
                                             request.url)
            return {"success": False, "error": "Invalid Request"}

        #Extract JSON payload
        rbody = json.load(request.body)
        #print 'PUT received', request, rbody
        appconfig.get_app_logger().info('PUT received, %s:%s', request, rbody)

        return process_update_kconnect(rbody)
    except:
        appconfig.get_app_logger().exception(
            'Invalid Request. Some Exception, %s, %s',
            appconfig.get_app_module(), request.url)
        return {"success": False, "error": "Invalid Request. Some Exception"}
示例#9
0
def create_vmq_config():
    """

    """
    try:
        if appconfig.get_app_module() != 'mqtt':
            #print 'Invalid Module'
            appconfig.get_app_logger().error('Invalid Module, %s, %s',
                                             appconfig.get_app_module(),
                                             request.url)
            return {"success": False, "error": "Invalid Request"}

        #Extract JSON payload
        rbody = json.load(request.body)
        #print 'POST received', request, rbody
        appconfig.get_app_logger().info('POST received, %s:%s', request, rbody)

        return process_vmq_config(rbody)
    except:
        appconfig.get_app_logger().exception(
            'Invalid Request. Some Exception, %s, %s',
            appconfig.get_app_module(), request.url)
        return {"success": False, "error": "Invalid Request. Some Exception"}