Initial commit to gerrit repo
Made non-functional change to trigger Jenkins
Add/update license headers
Dockerfile modification
Corrected Dockerfile faults
Dockerfile update
Yet another Dockerfile update
Support for placement without vld:s

Change-Id: I63c1733656f682233c96f6bcadeac1a2765ed085
Signed-off-by: magnussonl <lars-goran.magnusson@arctoslabs.com>
diff --git a/docker/Dockerfile b/docker/Dockerfile
new file mode 100755
index 0000000..1b4a01c
--- /dev/null
+++ b/docker/Dockerfile
@@ -0,0 +1,72 @@
+# Copyright 2020 ArctosLabs Scandinavia AB
+# *************************************************************
+
+# This file is part of OSM Placement module
+# All Rights Reserved to ArctosLabs Scandinavia AB
+
+# 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:18.04
+
+LABEL authors="Martin Björklund, Lars-Göran Magnusson"
+
+RUN apt-get --yes update \
+ && apt-get --yes install git python3 python3-pip libgl1-mesa-glx \ 
+ && pip3 install pip==9.0.3
+
+COPY requirements.txt /pla/requirements.txt
+
+RUN pip3 install -r /pla/requirements.txt
+
+ADD https://github.com/MiniZinc/MiniZincIDE/releases/download/2.3.1/MiniZincIDE-2.3.1-bundle-linux-x86_64.tgz /minizinc.tgz
+#COPY MiniZincIDE-2.3.1-bundle-linux-x86_64.tgz /minizinc.tgz
+
+RUN tar -zxf /minizinc.tgz && \
+    mv /MiniZincIDE-2.3.1-bundle-linux /minizinc
+
+RUN mkdir /entry_data \
+    && mkdir /entry_data/mzn-lib \
+    && ln -s /entry_data/mzn-lib /minizinc/share/minizinc/exec
+
+COPY . /pla
+
+RUN pip3 install /pla
+
+RUN mkdir /placement
+
+ENV OSMPLA_MESSAGE_DRIVER kafka
+ENV OSMPLA_MESSAGE_HOST kafka
+ENV OSMPLA_MESSAGE_PORT 9092
+
+ENV OSMPLA_DATABASE_DRIVER mongo
+ENV OSMPLA_DATABASE_URI mongodb://mongo:27017
+
+ENV OSMPLA_SQL_DATABASE_URI sqlite:///pla_sqlite.db
+ENV OSMPLA_GLOBAL_REQUEST_TIMEOUT 10
+ENV OSMPLA_GLOBAL_LOGLEVEL INFO
+ENV OSMPLA_VCA_HOST localhost
+ENV OSMPLA_VCA_SECRET secret
+ENV OSMPLA_VCA_USER admin
+ENV OSMPLA_DATABASE_COMMONKEY changeme
+
+ENV FZNEXEC "/entry_data/fzn-exec"
+ENV PATH "/minizinc/bin:${PATH}"
+ENV LD_LIBRARY_PATH "/minizinc/lib:${LD_LIBRARY_PATH}"
+
+EXPOSE 1234
+
+#HEALTHCHECK --interval=5s --timeout=2s --retries=12 \
+#  CMD osm-pla-healthcheck || exit 1
+
+CMD /bin/bash pla/docker/scripts/start.sh
+
+#WORKDIR /minizinc
diff --git a/docker/integrationtest.Dockerfile b/docker/integrationtest.Dockerfile
new file mode 100755
index 0000000..a4cedf6
--- /dev/null
+++ b/docker/integrationtest.Dockerfile
@@ -0,0 +1,74 @@
+# Copyright 2020 ArctosLabs Scandinavia AB
+# *************************************************************
+
+# This file is part of OSM Placement module
+# All Rights Reserved to ArctosLabs Scandinavia AB
+
+# 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:18.04
+
+LABEL authors="Martin Björklund, Lars-Göran Magnusson"
+
+RUN apt-get --yes update \
+ && apt-get --yes install git python3 python3-pip libgl1-mesa-glx \ 
+ && pip3 install pip==9.0.3
+
+COPY requirements.txt /pla/requirements.txt
+
+RUN pip3 install -r /pla/requirements.txt
+
+ADD https://github.com/MiniZinc/MiniZincIDE/releases/download/2.3.1/MiniZincIDE-2.3.1-bundle-linux-x86_64.tgz /minizinc.tgz
+#COPY MiniZincIDE-2.3.1-bundle-linux-x86_64.tgz /minizinc.tgz
+
+RUN tar -zxf /minizinc.tgz && \
+    mv /MiniZincIDE-2.3.1-bundle-linux /minizinc
+
+RUN mkdir /entry_data \
+    && mkdir /entry_data/mzn-lib \
+    && ln -s /entry_data/mzn-lib /minizinc/share/minizinc/exec
+
+COPY . /pla
+
+RUN pip3 install /pla
+
+RUN mkdir /placement
+COPY ./osm_pla/test/pil_price_list.yaml /placement/.
+COPY ./osm_pla/test/vnf_price_list.yaml /placement/.
+
+ENV OSMPLA_MESSAGE_DRIVER kafka
+ENV OSMPLA_MESSAGE_HOST kafka
+ENV OSMPLA_MESSAGE_PORT 9092
+
+ENV OSMPLA_DATABASE_DRIVER mongo
+ENV OSMPLA_DATABASE_URI mongodb://mongo:27017
+
+ENV OSMPLA_SQL_DATABASE_URI sqlite:///pla_sqlite.db
+ENV OSMPLA_GLOBAL_REQUEST_TIMEOUT 10
+ENV OSMPLA_GLOBAL_LOGLEVEL INFO
+ENV OSMPLA_VCA_HOST localhost
+ENV OSMPLA_VCA_SECRET secret
+ENV OSMPLA_VCA_USER admin
+ENV OSMPLA_DATABASE_COMMONKEY changeme
+
+ENV FZNEXEC "/entry_data/fzn-exec"
+ENV PATH "/minizinc/bin:${PATH}"
+ENV LD_LIBRARY_PATH "/minizinc/lib:${LD_LIBRARY_PATH}"
+
+EXPOSE 1234
+
+#HEALTHCHECK --interval=5s --timeout=2s --retries=12 \
+#  CMD osm-pla-healthcheck || exit 1
+
+CMD /bin/bash pla/docker/scripts/start.sh
+
+#WORKDIR /minizinc
diff --git a/docker/scripts/start.sh b/docker/scripts/start.sh
new file mode 100755
index 0000000..66b96c8
--- /dev/null
+++ b/docker/scripts/start.sh
@@ -0,0 +1,69 @@
+# Copyright 2020 ArctosLabs Scandinavia AB
+#
+# 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.
+DB_EXISTS=""
+
+max_attempts=120
+function wait_db(){
+    db_host=$1
+    db_port=$2
+    attempt=0
+    echo "Wait until $max_attempts seconds for MySQL mano Server ${db_host}:${db_port} "
+    while ! mysqladmin ping -h"$db_host" -P"$db_port" --silent; do
+        #wait 120 sec
+        if [ $attempt -ge $max_attempts ]; then
+            echo
+            echo "Can not connect to database ${db_host}:${db_port} during $max_attempts sec"
+            return 1
+        fi
+        attempt=$[$attempt+1]
+        echo -n "."
+        sleep 1
+    done
+    return 0
+}
+
+function is_db_created() {
+    db_host=$1
+    db_port=$2
+    db_user=$3
+    db_pswd=$4
+    db_name=$5
+
+    if mysqlshow -h"$db_host" -P"$db_port" -u"$db_user" -p"$db_pswd" | grep -v Wildcard | grep -q $db_name; then
+        echo "DB $db_name exists"
+        return 0
+    else
+        echo "DB $db_name does not exist"
+        return 1
+    fi
+}
+
+if [[ $OSMPLA_SQL_DATABASE_URI == *'mysql'* ]]; then
+    DB_HOST=$(echo $OSMPLA_SQL_DATABASE_URI | sed -r 's|^.+://.+:.+@(.+):.*$|\1|')
+    DB_PORT=$(echo $OSMPLA_SQL_DATABASE_URI | sed -r 's|^.+://.*:([0-9]+).*$|\1|')
+    DB_USER=$(echo $OSMPLA_SQL_DATABASE_URI | sed -r 's|^.+://(.+):.+@.+$|\1|')
+    DB_PASSWORD=$(echo $OSMPLA_SQL_DATABASE_URI | sed -r 's|^.+://.+:(.+)@.*$|\1|')
+    DB_NAME=$(echo $OSMPLA_SQL_DATABASE_URI | sed -r 's|^.+://.+:.+@.+:.*/(\w+)(\?.*)?$|\1|')
+    
+    wait_db "$DB_HOST" "$DB_PORT" || exit 1
+
+    is_db_created "$DB_HOST" "$DB_PORT" "$DB_USER" "$DB_PASSWORD" "$DB_NAME" && DB_EXISTS="Y"
+
+    if [ -z $DB_EXISTS ]; then
+        mysql -h"$DB_HOST" -P"$DB_PORT" -u"$DB_USER" -p"$DB_PASSWORD" --default_character_set utf8 -e "CREATE DATABASE $DB_NAME"
+    fi
+fi
+
+osm-pla-server