Importing and Exporting

Importing and Exporting Flows

IN Tester provides console tools for bulk exporting and importing flows. These tools are available on the IN Tester server, in the directory:

/usr/share/n2int/bin

To access these tools, log into the IN Tester server using an SSH client such as Putty, or from another unix-type server:

ssh n2in@<IN Tester server>
cd /usr/share/n2int/bin

Exporting Flows

To export a set of flows, log in to the IN Tester server as a user who can execute command line processes and run:

    cd /usr/share/n2int/bin
    ./export_flows [options] <output directory>

Valid options for this tool are:

For example the following commands will export all flows from the database:

    mkdir /tmp/intester_flows 
    cd /usr/share/n2int/bin
    ./export_flows /tmp/intester_flows

The -l , -f and -g optional parameters can be used to limit the flows exported. The flows exported are the intersection of the flows that match the options provided.

For example, giving a group name and a folder name will cause the export to only export those flows that are both in the group and in the folder.

Simple pattern matching is also supported. Use % to match any string, and ? to match a single character of any value. For example:

    ./export_flows -l "%inter%" /tmp/

will output all flows in all folders whose name has “inter” within it. Matches are always case insensitive.

Flows are exported into a directory structure that represents the flows and folders in IN Tester. Within the output directory a directory for each folder with flows exported is created, and flows are then placed in the relevant directory.

Each flow is stored as a separate file.

File names are formatted such that both the flow ID and flow name are included. The format is:

<output directory>/<flow id>__<flow name>.json

Any / characters within the flow or folder name are converted to underscores when exporting flows.

Importing Flows

It is possible to import multiples flows through the bulk import tool:

    cd /usr/share/n2int/bin
    ./import_flows [options] <import source>

If is a dash (-), input is read from STDIN.

Valid options for this tool are:

If the import source given is a file, or STDIN, then either -l, or -i must be given to identify a specific flow. If -f is also given in addition to -l, then the flow name will be taken from the command line. Otherwise the flow name will be taken from the file name (if one is given).

If input is from STDIN, and no flow name is given (and no flow ID is given) then the flow name will be “Imported from STDIN”

If the import source is a directory, then:

  1. Any directories immediately under the given directory are assumed to be folders,
  2. Any files ending in .json, in directories immediately under the given source directory, will be import.
    The folder name is taken from the directory name. The file name can have one of two formats:

          <id>__<name>.json      
    

    or:

          <name>.<anything>      
    

    If the first format is matched, then the ID is used to identify the flow to import (and the name is ignored). In cases where the ID is not matched, the name is instead used.

  3. If -l is given on the command line, then only files in the are read (i.e. no subdirectories are looked at), and the above rules regarding flow file names are adhered too. Note that generally only active folders/flows will be updated. If a flow is imported for an inactive folder or flow, then instead a new folder/flow is created (unless the flow ID is explicitly given).

It is possible to import a previously set of exported flows. For example:

    mkdir /tmp/intester_flows 
    cd /usr/share/n2int/bin
    ./export_flows /tmp/intester_flows
    ./import_flows /tmp/intester_flows

Will export all flows then re-import them.