def default():
    try:
        return_message = 'The Data Flow has been created'
        if request.method == 'POST':
            access = security.get_service_access_status('nifi', True)
            if access.access_status.status == 'UNKNOWN':
                error = None
                return render_template('login.html', error=error)

            raw_data = json.loads(json.loads(request.data)["process_group"])
            parent_group = adapter.to_process_group(
                json_process_group=raw_data)

            processor_config = raw_data["config"]
            flow_components = raw_data["flow_components"]
            group_name = raw_data["group_name"]
            group_location = raw_data["group_location"]

            create_flow(flow_components, parent_group, group_name,
                        group_location, processor_config)

    except Exception as e:
        return_message = str(e)

    return return_message
Beispiel #2
0
def template1():
    try:
        return_message = 'OK'
        if request.method == 'POST':
            access = security.get_service_access_status('nifi', True)
            if access.access_status.status == 'UNKNOWN':
                error = None
                return render_template('login.html', error=error)

            raw_data = json.loads(request.form['process_group'])
            parent_group = adapter.to_process_group(
                json_process_group=raw_data)
            processor_config = raw_data["config"]
            group_name = raw_data["group_name"]

            new_process_group = CreateProcessGroup(parent_group, group_name,
                                                   (200.0, 300.0))
            new_process_group.create()

            put_hdfs = CreateProcessorPutHDFS(new_process_group,
                                              "InsereArquivoNOHDFS",
                                              (100.0, 900.0), processor_config)
            put_hdfs.create()

            get_ftp = CreateProcessorGetSFTP(new_process_group, "test1",
                                             (400.0, 900.0), processor_config)
            get_ftp.create()

            connection = CreateConnection(new_process_group, "connection",
                                          put_hdfs, get_ftp, ['sucesss'])
            connection.create()
    except Exception as e:
        return_message = str(e)

    return return_message
def mroi():
    try:
        return_message = 'OK'
        if request.method == 'POST':
            access = security.get_service_access_status('nifi', True)
            if access.access_status.status == 'UNKNOWN':
                error = None
                return render_template('login.html', error=error)

            raw_data = json.loads(request.form['process_group'])
            parent_group = adapter.to_process_group(json_process_group=raw_data)
            processor_config = raw_data["config"]
            group_name = raw_data["group_name"]

            new_process_group = CreateProcessGroup(
                parent_group, group_name, (700.00, 700.0)).create()

            create_mroi_data_flow(new_process_group, processor_config)
    except Exception as e:
        return_message = str(e)

    return return_message
def example():
    try:
        return_message = 'OK'
        if request.method == 'POST':
            access = security.get_service_access_status('nifi', True)
            if access.access_status.status == 'UNKNOWN':
                error = None
                return render_template('login.html', error=error)

            raw_data = json.loads(request.form['process_group'])
            parent_group = adapter.to_process_group(json_process_group=raw_data)
            processor_config = raw_data["config"]

            new_process_group = CreateProcessGroup(
                parent_group, raw_data["group_name"], (700.00,400.0)).create()

            buscar_arquivo_ftp = CreateProcessorGetSFTP(
                new_process_group, "BuscarArquivoSftp", (500.0, 400.0), processor_config)
            buscar_arquivo_ftp.create()

            retirar_header = CreateProcessorRouteText(
                new_process_group, "RetirarHeaderDoCsv", (1000.0, 400.0), processor_config)
            retirar_header.create()

            CreateConnection(
                new_process_group, "buscar_arquivo_ftp_retirar_header", buscar_arquivo_ftp, retirar_header, ["success"]
            ).create()

            retirar_header_test = CreateProcessorRouteText(
                new_process_group, "RetirarHeaderDoCsvtest", (1000.0, 800.0), processor_config)
            retirar_header_test.create()

            create_sub_group_example1(new_process_group, retirar_header, retirar_header_test, processor_config)

    except Exception as e:
        return_message = str(e)

    return return_message
def example2():
    try:
        return_message = 'OK'
        if request.method == 'POST':
            access = security.get_service_access_status('nifi', True)
            if access.access_status.status == 'UNKNOWN':
                error = None
                return render_template('login.html', error=error)

            raw_data = json.loads(request.form['process_group'])
            parent_group = adapter.to_process_group(json_process_group=raw_data)
            processor_config = raw_data["config"]
            group_location = raw_data["group_location"]

            component_location = CreateLocation(x=0.0, y=0.0, type=LocationType.ZIGZAG).create

            new_process_group = CreateProcessGroup(
                parent_group, raw_data["group_name"], (group_location["x"],group_location["y"])).create()

            test_update_attribute = CreateProcessorUpdateAttribute(
                new_process_group, "TestUpdateAttribute", component_location(), processor_config)
            test_update_attribute.create()

            create_sub_group_example2(new_process_group, None, test_update_attribute, processor_config, component_location)

            test_update_attribute2 = CreateProcessorUpdateAttribute(
                new_process_group, "TestUpdateAttribute2", component_location(), processor_config)
            test_update_attribute2.create()

            CreateConnection(
                new_process_group, "connection_test", test_update_attribute, test_update_attribute2, ["success"]
            ).create()            

    except Exception as e:
        return_message = str(e)

    return return_message