Dockerize osdf simulators for csit 99/68899/6
authorvrvarma <vv8305@att.com>
Tue, 25 Sep 2018 15:28:01 +0000 (11:28 -0400)
committervrvarma <vv8305@att.com>
Tue, 2 Oct 2018 02:02:48 +0000 (22:02 -0400)
Dockerfile modifications
Adding intellectual property headers
Fixing simulators for policy, add policy name, etc.
Fix the hpa policy files based on the comments

Change-Id: I337e3200cc92fc1f205bb6e6151620968fc59c7e
Signed-off-by: vrvarma <vv8305@att.com>
Issue-ID: OPTFRA-286

test/functest/simulators/Dockerfile [new file with mode: 0644]
test/functest/simulators/build_sim_image.sh [new file with mode: 0755]
test/functest/simulators/oof_dependencies_simulators.py
test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/hpa_policy_vGMuxInfra_1.json
test/functest/simulators/policy/response-payloads/pdp-has-vcpe-good/hpa_policy_vG_1.json
test/policy-local-files/hpa_policy_vG_1.json

diff --git a/test/functest/simulators/Dockerfile b/test/functest/simulators/Dockerfile
new file mode 100644 (file)
index 0000000..7f6b49f
--- /dev/null
@@ -0,0 +1,34 @@
+#
+# -------------------------------------------------------------------------
+#   Copyright (c) 2018 AT&T Intellectual Property
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+#
+# -------------------------------------------------------------------------
+#
+
+FROM ubuntu:16.04
+
+RUN apt-get update -y \
+    && apt-get install -y vim unzip wget libmpfr-dev \
+    && apt-get install -y git libqt5printsupport5 build-essential \
+    && apt-get install -y python3 python3-setuptools python3-dev \
+    && easy_install3 pip \
+    && pip install --upgrade virtualenv pip wheel
+
+RUN ln -s /usr/bin/python3.5 /usr/bin/python
+ADD requirements.txt /requirements.txt
+RUN pip install -r requirements.txt
+ADD sim /sim
+
+CMD cd /sim && python oof_dependencies_simulators.py > simulator-logs 2>&1
\ No newline at end of file
diff --git a/test/functest/simulators/build_sim_image.sh b/test/functest/simulators/build_sim_image.sh
new file mode 100755 (executable)
index 0000000..c035e9a
--- /dev/null
@@ -0,0 +1,47 @@
+#!/bin/bash
+#
+# -------------------------------------------------------------------------
+#   Copyright (c) 2018 AT&T Intellectual Property
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#       http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+#
+# -------------------------------------------------------------------------
+#
+
+SCRIPTDIR=$(dirname $(readlink -f $0))
+FUNC_TEST_DIR=$(dirname $SCRIPTDIR)
+TEST_DIR=$(dirname $FUNC_TEST_DIR)
+SIMULATORS_DIR=$FUNC_TEST_DIR/simulators
+OSDF_DIR=$(dirname $TEST_DIR)
+DOCKER_DIR=$SIMULATORS_DIR/tmp_docker
+
+mkdir -p $DOCKER_DIR/sim/osdf/policy/response-payloads/pdp-has-vcpe-good
+
+cp $SIMULATORS_DIR/Dockerfile $DOCKER_DIR/.
+
+cp -r $OSDF_DIR/osdf $DOCKER_DIR/sim
+mkdir -p $DOCKER_DIR/sim/config/
+cp $SIMULATORS_DIR/simulated-config/*.yaml $DOCKER_DIR/sim/config/
+cp $SIMULATORS_DIR/simulated-config/*.config $DOCKER_DIR/sim/config/
+cp -r $SIMULATORS_DIR/configdb $DOCKER_DIR/sim
+cp -r $SIMULATORS_DIR/has-api $DOCKER_DIR/sim
+cp -r $SIMULATORS_DIR/policy $DOCKER_DIR/sim
+cp $TEST_DIR/policy-local-files/*.json $DOCKER_DIR/sim/policy/response-payloads/pdp-has-vcpe-good
+cp $SIMULATORS_DIR/oof_dependencies_simulators.py $DOCKER_DIR/sim/oof_dependencies_simulators.py
+cp $OSDF_DIR/requirements.txt $DOCKER_DIR
+
+cd $DOCKER_DIR
+
+docker build -t osdf_sim .
+
+rm -rf $DOCKER_DIR
index 9c20e79..b7e6cb5 100755 (executable)
@@ -20,6 +20,8 @@
 Simulators for dependencies of OSDF (e.g. HAS-API, Policy, SO-callback, etc.)
 """
 import glob
+import json
+import os
 from flask import Flask, jsonify, request
 
 from osdf.utils.interfaces import json_from_file
@@ -77,7 +79,18 @@ def get_policies(sub_component):
     """
     main_dir = "policy/response-payloads/" + sub_component
     files = glob.glob("{}/*.json".format(main_dir))
-    return jsonify([json_from_file(x) for x in files])
+    list_json = []
+    for x in files:
+        list_json.append({
+            "policyConfigMessage": "Config Retrieved! ",
+            "policyConfigStatus": "CONFIG_RETRIEVED",
+            "type": "JSON",
+            "config": json.dumps(json_from_file(x)),
+            "policyName": os.path.basename(x),
+            "policyType": "MicroService",
+            "policyVersion": "1"
+        })
+    return jsonify(list_json)
 
 
 @app.route("/simulated/configdb/getCellList", methods=["GET"])
@@ -98,4 +111,4 @@ def get_nbr_list():
 
 
 if __name__ == "__main__":
-    app.run(debug=True)
+    app.run(debug=True, host='0.0.0.0')
index 85b1e82..ce0b7e3 100644 (file)
@@ -67,7 +67,7 @@
               "hpa-feature" : "cpuInstructionSetExtensions",
               "mandatory" : "True",
               "architecture": "INTEL-64",
-              "directives":[],
+              "directives": [],
               "hpa-feature-attributes": [
                 {"hpa-attribute-key":"instructionSetExtensions", "hpa-attribute-value":["<CPUINST>", "<CPUINST>"], "operator": "ALL", "unit":""}
               ]
@@ -93,7 +93,7 @@
               "hpa-feature" : "cpuPinningy",
               "mandatory" : "True",
               "architecture": "generic",
-              "directives":[],
+              "directives": [],
               "hpa-feature-attributes": [
                 {"hpa-attribute-key":"logicalCpuThreadPinningPolicy", "hpa-attribute-value":"<CPUTHREADPOLICY>", "operator": "=", "unit":""},
                 {"hpa-attribute-key":"logicalCpuPinningPolicy", "hpa-attribute-value": "<CPUPOLICY>","operator": "=", "unit":""}
               "hpa-feature" : "basicCapabilities",
               "mandatory" : "True",
               "architecture": "generic",
-              "directives":[],
+              "directives": [],
               "hpa-feature-attributes": [
                 {"hpa-attribute-key": "numVirtualCpu", "hpa-attribute-value": "6", "operator": "=", "unit": ""},
                 {"hpa-attribute-key": "virtualMemSize", "hpa-attribute-value":"6", "operator": "=", "unit": "GB"}
               "mandatory" : "False",
               "score" : "5",
               "architecture": "generic",
-              "directives":[],
+              "directives": [],
               "hpa-feature-attributes": [
                 {"hpa-attribute-key": "diskSize", "hpa-attribute-value": "2", "operator": "=", "unit": "GB"},
                 {"hpa-attribute-key": "ephemeralDiskSize", "hpa-attribute-value": "2", "operator": "=", "unit": "GB"},
               "hpa-feature" : "pcie",
               "mandatory" : "True",
               "architecture": "generic",
-              "directives":[],
+              "directives": [],
               "hpa-feature-attributes": [
                 {"hpa-attribute-key": "pciCount", "hpa-attribute-value": "2", "operator": "=", "unit": ""},
                 {"hpa-attribute-key": "pciVendorId", "hpa-attribute-value":"8086", "operator": "=", "unit": ""},
               "mandatory" : "False",
               "score" : "5",
               "architecture": "generic",
-              "directives":[],
+              "directives": [],
               "hpa-feature-attributes": [
                 {"hpa-attribute-key": "numaNodes", "hpa-attribute-value": "2", "operator": "=", "unit": ""},
                 {"hpa-attribute-key": "numaCpu-0", "hpa-attribute-value":"2", "operator": "=", "unit": ""},
               "hpa-feature" : "basicCapabilities",
               "mandatory" : "True",
               "architecture": "generic",
-              "directives":[],
+              "directives": [],
               "hpa-feature-attributes": [
                 {"hpa-attribute-key": "numVirtualCpu", "hpa-attribute-value": "6", "operator": "=", "unit": ""},
                 {"hpa-attribute-key": "virtualMemSize", "hpa-attribute-value":"6", "operator": "=", "unit": "GB"}
               "mandatory" : "False",
               "score" : "7",
               "architecture": "generic",
-              "directives":[],
+              "directives": [],
               "hpa-feature-attributes": [
                  {"hpa-attribute-key": "memoryPageSize", "hpa-attribute-value": "<MEMORYPAGESIZE>", "operator": "=", "unit": ""}
               ]
index 262ffe7..5d2499f 100644 (file)
               ]
             },
             {
-              "hpa-feature" : "pcie",
+              "hpa-feature" : "pciePassthrough",
               "mandatory" : "True",
               "architecture": "generic",
-              "directives": [
-                {
-                  "type": "pcie_directives",
-                  "attributes": [
-                    {
-                      "attribute_name": "<pcie_label_name>",
-                      "attribute_value": "<value for pcie network>"
-                    }
-                  ]
-                }
-              ],
+              "directives": [],
               "hpa-feature-attributes": [
                 {"hpa-attribute-key": "pciCount", "hpa-attribute-value": "2", "operator": "=", "unit": ""},
                 {"hpa-attribute-key": "pciVendorId", "hpa-attribute-value":"8086", "operator": "=", "unit": ""},
-                {"hpa-attribute-key": "pciDeviceId", "hpa-attribute-value": "2", "operator": "=", "unit": ""},
-                {"hpa-attribute-key": "physicalNetwork", "hpa-attribute-value": "<PCITYPEVALUE>","operator": "=", "unit": ""}
+                {"hpa-attribute-key": "pciDeviceId", "hpa-attribute-value": "2", "operator": "=", "unit": ""}
               ]
             }
           ]
               "hpa-feature" : "numa",
               "mandatory" : "False",
               "score" : "5",
-              "directives": [],
               "architecture": "generic",
+              "directives": [],
               "hpa-feature-attributes": [
                 {"hpa-attribute-key": "numaNodes", "hpa-attribute-value": "2", "operator": "=", "unit": ""},
                 {"hpa-attribute-key": "numaCpu-0", "hpa-attribute-value":"2", "operator": "=", "unit": ""},
index 4dfb6ce..5d2499f 100644 (file)
               ]
             },
             {
-              "hpa-feature" : "pcie",
+              "hpa-feature" : "pciePassthrough",
               "mandatory" : "True",
               "architecture": "generic",
               "directives": [],
               "hpa-feature-attributes": [
                 {"hpa-attribute-key": "pciCount", "hpa-attribute-value": "2", "operator": "=", "unit": ""},
                 {"hpa-attribute-key": "pciVendorId", "hpa-attribute-value":"8086", "operator": "=", "unit": ""},
-                {"hpa-attribute-key": "pciDeviceId", "hpa-attribute-value": "2", "operator": "=", "unit": ""},
-                {"hpa-attribute-key": "functionType", "hpa-attribute-value": "<PCITYPEVALUE>","operator": "=", "unit": ""}
+                {"hpa-attribute-key": "pciDeviceId", "hpa-attribute-value": "2", "operator": "=", "unit": ""}
               ]
             }
           ]