NFVBENCH-34 Pass configuration file to entrypoint script 21/43221/4
authorKerim Gokarslan <kgokarsl@cisco.com>
Tue, 26 Sep 2017 19:15:30 +0000 (12:15 -0700)
committerKerim Gokarslan <kgokarsl@cisco.com>
Wed, 27 Sep 2017 17:51:44 +0000 (10:51 -0700)
Change-Id: If44d5d9fb2db58b3e1a3ebd1c8d94c1452f84409
Signed-off-by: Kerim Gokarslan <kgokarsl@cisco.com>
docker/nfvbench-entrypoint.sh
docs/testing/user/userguide/quickstart_docker.rst
docs/testing/user/userguide/server.rst
nfvbench/nfvbenchd.py

index 9d6d3ae..ed98ced 100755 (executable)
@@ -24,16 +24,10 @@ else
         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
index ccb629b..0ab657c 100644 (file)
@@ -38,19 +38,54 @@ The NFVbench container requires the following Docker options to operate properly
 |                                                      | /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)
@@ -67,11 +102,11 @@ To run NFVBench without server mode
 
     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:
index e08f663..1c1e052 100644 (file)
@@ -84,7 +84,7 @@ Example of return when the run completes:
 <http-url>/start_run (POST)
 ^^^^^^^^^^^^^^^^^^^^^
 
-This request starts an NFVBench run with passed configurations.
+This request starts an NFVBench run with passed configurations. If no configuration is passed, a run with default configurations will be executed.
 
 Example request: curl -XPOST 'localhost:7556/start_run' -H "Content-Type: application/json" -d @nfvbenchconfig.json
 
index 3ab30de..4657504 100644 (file)
@@ -137,7 +137,6 @@ def setup_flask(root_path):
     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'
@@ -169,15 +168,13 @@ def setup_flask(root_path):
     @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'])