if [ -n "$PORT" ]; then
PARAMS+=" --port $PORT"
fi
- if [ -n "$OPENRC" ]; then
- if [ -f "$OPENRC" ]; then
- PARAMS+=" -c \"openrc_file: $OPENRC\""
- else
- echo "Aborting... Openrc config file cannot be found in the given path: $OPENRC"
- exit 1
+ if [ -n "$CONFIG_FILE" ]; then
+ if [ -f "$CONFIG_FILE" ]; then
+ PARAMS+=" -c $CONFIG_FILE"
fi
- else
- echo "Aborting... Openrc config path is absent"
- exit 1
fi
eval "nfvbench $PARAMS"
fi
\ No newline at end of file
| | /tmp/nfvbench director in the container but any |
| | other similar mapping can work as well |
+------------------------------------------------------+------------------------------------------------------+
-| --net=host | (optional) needed if you run the NFVbench ok |
+| --net=host | (optional) needed if you run the NFVbench ok |
| | server in the container (or use any appropriate |
| | docker network mode other than "host") |
+------------------------------------------------------+------------------------------------------------------+
| --privileged | (optional) required if SELinux is enabled on the host|
+------------------------------------------------------+------------------------------------------------------+
-| --e HOST="127.0.0.1" | (optional) required if REST server is enabled |
+| -e HOST="127.0.0.1" | (optional) required if REST server is enabled |
+------------------------------------------------------+------------------------------------------------------+
-| --e PORT=7556 | (optional) required if REST server is enabled |
+| -e PORT=7556 | (optional) required if REST server is enabled |
++------------------------------------------------------+------------------------------------------------------+
+| -e CONFIG_FILE="/root/nfvbenchconfig.json | (optional) required if REST server is enabled |
+------------------------------------------------------+------------------------------------------------------+
-
It can be convenient to write a shell script (or an alias) to automatically insert the necessary options.
+The minimal configuration file required must specify the openrc file to use (using in-container path), the PCI addresses of the 2 NIC ports to use
+for generating traffic and the line rate (in each direction) of each of these 2 interfaces.
+
+Here is an example of mimimal configuration where:
+the openrc file is located on the host current directory which is mapped under /tmp/nfvbench in the container (this is achieved using -v $PWD:/tmp/nfvbench)
+the 2 NIC ports to use for generating traffic have the PCI addresses "04:00.0" and "04:00.1"
+
+.. code-block:: bash
+ {
+ "openrc_file": "/tmp/nfvbench/openrc",
+ "traffic_generator": {
+ "generator_profile": [
+ {
+ "interfaces": [
+ {
+ "pci": "04:00.0",
+ "port": 0,
+ },
+ {
+ "pci": "04:00.1",
+ "port": 1,
+ }
+ ],
+ "intf_speed": "10Gbps",
+ "ip": "127.0.0.1",
+ "name": "trex-local",
+ "tool": "TRex"
+ }
+ ]
+ }
+ }
+
+The other options in the minimal configuration must be present and must have the same values as above.
+
3. Start the Docker container
-----------------------------
As for any Docker container, you can execute NFVbench measurement sessions using a temporary container ("docker run" - which exits after each NFVbench run)
docker run --detach --net=host --privileged -v $PWD:/tmp/nfvbench -v /dev:/dev -v /lib/modules/$(uname -r):/lib/modules/$(uname -r) --name nfvbench opnfv/nfvbench
-To run NFVBench enabling REST server
+To run NFVBench enabling REST server (mount the configuration json and the path for openrc)
.. code-block:: bash
- docker run --detach --net=host --privileged -e HOST="127.0.0.1" -e PORT=7556 -v $PWD:/tmp/nfvbench -v /dev:/dev -v /lib/modules/$(uname -r):/lib/modules/$(uname -r) --name nfvbench opnfv/nfvbench start_rest_server
+ docker run --detach --net=host --privileged -e HOST="127.0.0.1" -e PORT=7556 --e CONFIG_FILE="/tmp/nfvbench/nfvbenchconfig.json -v $PWD:/tmp/nfvbench -v /dev:/dev -v /lib/modules/$(uname -r):/lib/modules/$(uname -r) --name nfvbench opnfv/nfvbench start_rest_server
The create an alias to make it easy to execute nfvbench commands directly from the host shell prompt:
app.root_path = root_path
socketio = SocketIO(app, async_mode='threading')
busy_json = result_json(STATUS_ERROR, 'there is already an NFVbench request running')
- config_is_null_json = result_json(STATUS_ERROR, 'configuration is missing')
not_busy_json = result_json(STATUS_ERROR, 'no pending NFVbench run')
not_found_msg = 'results not found'
pending_msg = 'NFVbench run still pending'
@app.route('/start_run', methods=['POST'])
def start_run():
config = load_json(request.json)
- if config:
- if Ctx.is_busy():
- return jsonify(busy_json)
- else:
- request_id = get_uuid()
- Ctx.enqueue(config, request_id)
- return jsonify(result_json(STATUS_PENDING, pending_msg, request_id))
- else:
- return jsonify(config_is_null_json)
+ if not config:
+ config = {}
+ if Ctx.is_busy():
+ return jsonify(busy_json)
+ request_id = get_uuid()
+ Ctx.enqueue(config, request_id)
+ return jsonify(result_json(STATUS_PENDING, pending_msg, request_id))
@app.route('/status', defaults={'request_id': None}, methods=['GET'])
@app.route('/status/<request_id>', methods=['GET'])