Prepare Web Portal for ONAP integration 83/65583/10
authorStamatis Katsaounis <mokats@intracom-telecom.com>
Wed, 5 Dec 2018 10:40:42 +0000 (12:40 +0200)
committerStamatis Katsaounis <mokats@intracom-telecom.com>
Fri, 8 Mar 2019 09:08:27 +0000 (09:08 +0000)
This patch applies all the required changes in order to support a
second web portal container with the onap web portal content.

Change-Id: I2f59776313bf2067dbdfb04445620b5241716ebb
Signed-off-by: Stamatis Katsaounis <mokats@intracom-telecom.com>
docker/.gitignore
docker/Dockerfile.api
docker/Dockerfile.web
docker/config.env.sample
docker/docker-compose.yml
docker/nginx/sites-available/default-onap [new file with mode: 0644]
docker/nginx/sites-available/default-opnfv [moved from docker/nginx/sites-available/default with 82% similarity]
docker/prepare-env.sh
docker/start-nginx.sh
opnfv_testapi/ui/root.py [deleted file]

index af398fe..5ef677d 100644 (file)
@@ -1,2 +1,3 @@
 config.env
-vhost.env
+vhost-opnfv.env
+vhost-onap.env
index d40562a..b414dd3 100644 (file)
@@ -49,9 +49,10 @@ RUN apt-get update && apt-get install -y \
 
 RUN pip install -U setuptools
 
-RUN git clone https://gerrit.opnfv.org/gerrit/dovetail-webportal $HOME/testapi && \
-    cd $HOME/testapi && \
-    git checkout -f $BRANCH && \
+RUN git init $HOME/testapi && \
+    (cd $HOME/testapi && \
+        git fetch --tags https://gerrit.opnfv.org/gerrit/dovetail-webportal $BRANCH && \
+        git checkout FETCH_HEAD) && \
     mkdir -p $HOME/testapi/logs/api && \
     mkdir -p $HOME/testapi/media/companies
 
index 853e0f8..e5c39a1 100644 (file)
@@ -10,6 +10,8 @@ MAINTAINER Leo Wang <grakiss.wanglei@huawei.com>
 LABEL version="v2" description="OVP nginx"
 
 ARG BRANCH=master
+ARG GUI=testapi-ui
+ARG CONTAINER=opnfv
 
 ENV HOME /home
 WORKDIR $HOME
@@ -22,16 +24,17 @@ RUN apt-get update && apt-get install -y \
     npm \
  && rm -rf /var/lib/apt/lists/*
 
-RUN git clone https://gerrit.opnfv.org/gerrit/dovetail-webportal $HOME/testapi && \
-    cd $HOME/testapi && \
-    git checkout -f $BRANCH && \
-    cd $HOME/testapi/3rd_party/static/testapi-ui && \
+RUN git init $HOME/testapi && \
+    (cd $HOME/testapi && \
+        git fetch --tags https://gerrit.opnfv.org/gerrit/dovetail-webportal $BRANCH && \
+        git checkout FETCH_HEAD) && \
+    cd $HOME/testapi/3rd_party/static/$GUI && \
     npm install && \
-    mkdir /www && \
-    cp -r $HOME/testapi/3rd_party/static /www/
+    mkdir -p /www/static && \
+    cp -r $HOME/testapi/3rd_party/static/$GUI /www/static
 
 ADD nginx/nginx.conf /etc/nginx/nginx.conf
-ADD nginx/sites-available/default /etc/nginx/sites-available/default
+ADD nginx/sites-available/default-$CONTAINER /etc/nginx/sites-available/default
 ADD supervisor/conf.d/nginx.conf /etc/supervisor/conf.d/nginx.conf
 ADD start-nginx.sh $HOME/start-nginx.sh
 
index 003d92f..f824c22 100644 (file)
@@ -1,3 +1,4 @@
 mongodb_url=mongodb://mongodb:27017/
 base_url=http://ovp.localhost
-testapi_url=cvpapi:8010
+testapi_url=lfnapi:8010
+PYTHONUNBUFFERED=True
index 4edf4cc..15e28f7 100644 (file)
@@ -3,47 +3,62 @@ version: '3'
 services:
     mongodb:
         image: mongo:3.2.1
-        container_name: cvp-db
+        container_name: lfn-db
         volumes:
-            - cvp-db:/data/db
+            - lfn-db:/data/db
         expose:
             - "27017"
-    web:
+    webopnfv:
         image: opnfv/dovetail-webportal-web:latest
-        container_name: cvp-web
+        container_name: web-opnfv
         restart: always
         env_file:
             - config.env
-            - vhost.env
+            - vhost-opnfv.env
         volumes:
-            - cvp-testapi-logs:/home/testapi/logs
+            - lfn-testapi-logs:/home/testapi/logs
         links:
             - mongodb
-            - cvpapi
+            - lfnapi
         ports:
             - "8000:8000"
-    cvpapi:
+    webonap:
+        image: opnfv/dovetail-webportal-web-onap:latest
+        container_name: web-onap
+        restart: always
+        env_file:
+            - config.env
+            - vhost-onap.env
+        volumes:
+            - lfn-testapi-logs:/home/testapi/logs
+        links:
+            - mongodb
+            - lfnapi
+        ports:
+            - "8001:8000"
+    lfnapi:
         image: opnfv/dovetail-webportal-api:latest
-        container_name: cvp-cvpapi
+        container_name: lfn-api
         env_file:
             - config.env
         volumes:
-            - cvp-testapi-logs:/home/testapi/logs
-            - cvp-company-logos:/home/testapi/media/companies
+            - lfn-testapi-logs:/home/testapi/logs
+            - lfn-company-logos:/home/testapi/media/companies
         ports:
             - "8010:8010"
     nginx:
         image: jwilder/nginx-proxy
-        container_name: cvp-nginx
+        container_name: lfn-nginx
         volumes:
             - /var/run/docker.sock:/tmp/docker.sock:ro
             - ./nginx-proxy/custom_proxy_settings.conf:/etc/nginx/conf.d/custom_proxy_settings.conf
         depends_on:
-            - web
+            - webopnfv
+            - webonap
         ports:
             - "80:80"
 
 volumes:
-    cvp-db:
-    cvp-company-logos:
-    cvp-testapi-logs:
+    lfn-db:
+    lfn-company-logos:
+    lfn-testapi-logs:
diff --git a/docker/nginx/sites-available/default-onap b/docker/nginx/sites-available/default-onap
new file mode 100644 (file)
index 0000000..e6aecb1
--- /dev/null
@@ -0,0 +1,64 @@
+upstream lfnapi {
+    server lfnapi:8010;
+}
+
+server {
+    listen 8000 default_server;
+    listen [::]:8000 default_server ipv6only=on;
+
+    root /usr/share/nginx/html;
+    index index.html index.htm;
+
+    server_name localhost;
+
+    location ~* /onap-ui/ {
+        root /www/static;
+        expires 1d;
+    }
+
+    location ~* /logs/.*\.(log|out|yaml|yml|txt|conf|json|sh|)$ {
+        root /home/testapi;
+        add_header Content-Type text/plain;
+    }
+
+    location ~* /logs/.*/results {
+        root /home/testapi;
+        expires 1d;
+        autoindex on;
+        autoindex_exact_size off;
+        autoindex_localtime on;
+    }
+
+    location ~* /logs/api {
+        root /home/testapi;
+        expires 1d;
+        autoindex on;
+        autoindex_exact_size on;
+        autoindex_localtime on;
+    }
+
+    location = /api/v1/onap/results/upload {
+        client_max_body_size 20m;
+        proxy_pass http://lfnapi/api/v1/onap/results/upload;
+        proxy_set_header X-Real_IP $remote_addr;
+        proxy_set_header Host $host;
+    }
+
+    location /api/v1/ {
+        proxy_pass http://lfnapi/api/v1/;
+        proxy_set_header X-Real-IP $remote_addr;
+        proxy_set_header Host $host;
+    }
+
+    location / {
+        root /www/static/onap-ui;
+        expires 1d;
+    }
+
+    error_page 413 =200 /413.json;
+
+    location /413.json {
+        return 200 '{"msg": "Please upload a file less than 20MB.", "code": 413}';
+    }
+
+}
similarity index 82%
rename from docker/nginx/sites-available/default
rename to docker/nginx/sites-available/default-opnfv
index 7652eb1..f271fb4 100644 (file)
@@ -1,5 +1,5 @@
-upstream cvpapi {
-    server cvpapi:8010;
+upstream lfnapi {
+    server lfnapi:8010;
 }
 
 server {
@@ -38,50 +38,50 @@ server {
     }
 
     location /api/v1/cvp {
-        proxy_pass http://cvpapi/api/v1/cvp;
+        proxy_pass http://lfnapi/api/v1/cvp;
         proxy_set_header X-Real-IP $remote_addr;
         proxy_set_header Host $host;
     }
 
     location /api/v1/auth {
-        proxy_pass http://cvpapi/api/v1/auth;
+        proxy_pass http://lfnapi/api/v1/auth;
         proxy_set_header X-Real-IP $remote_addr;
         proxy_set_header Host $host;
     }
 
     location /api/v1/profile {
-        proxy_pass http://cvpapi/api/v1/profile;
+        proxy_pass http://lfnapi/api/v1/profile;
         proxy_set_header X-Real-IP $remote_addr;
         proxy_set_header Host $host;
     }
 
     location /api/v1/test {
-        proxy_pass http://cvpapi/api/v1/test;
+        proxy_pass http://lfnapi/api/v1/test;
         proxy_set_header X-Real-IP $remote_addr;
         proxy_set_header Host $host;
     }
 
     location = /api/v1/results {
-        proxy_pass http://cvpapi/api/v1/results;
+        proxy_pass http://lfnapi/api/v1/results;
         proxy_set_header X-Real-IP $remote_addr;
         proxy_set_header Host $host;
     }
 
     location ~* /api/v1/results/([a-zA-Z0-9]+) {
         client_max_body_size 20m;
-        proxy_pass http://cvpapi/api/v1/results/$1;
+        proxy_pass http://lfnapi/api/v1/results/$1;
         proxy_set_header X-Real_IP $remote_addr;
         proxy_set_header Host $host;
     }
 
     location ~* /api/v1/suts/hardware/([a-zA-Z0-9\-]+) {
-        proxy_pass http://cvpapi/api/v1/suts/hardware/$1;
+        proxy_pass http://lfnapi/api/v1/suts/hardware/$1;
         proxy_set_header X-Real-IP $remote_addr;
         proxy_set_header Host $host;
     }
 
     location /api/v1/ {
-        proxy_pass http://cvpapi/api/v1/;
+        proxy_pass http://lfnapi/api/v1/;
         proxy_set_header X-Real-IP $remote_addr;
         proxy_set_header Host $host;
     }
index 61ff233..762e741 100755 (executable)
@@ -11,5 +11,4 @@ if [ "$base_url" != "" ]; then
     sudo crudini --set --existing $FILE swagger base_url $base_url
     sudo crudini --set --existing $FILE ui url $base_url
     sudo crudini --set --existing $FILE jira OAUTH_CALLBACK_URL $base_url/api/v1/auth/signin_return_jira
-    sudo crudini --set --existing $FILE lfid return_url $base_url/api/v1/auth/signin_return_cas
 fi
index c9949be..5f33847 100755 (executable)
@@ -1,8 +1,8 @@
 #!/bin/bash
-FILE=/etc/nginx/sites-enabled/default
+NGINX_CONF=/etc/nginx/sites-enabled/default
 
 if [ "$testapi_url" != "" ]; then
-    sed -i "s/server localhost:8010/server $testapi_url/" $FILE
+    sed -i "s/server lfnapi:8010/server $testapi_url/" $NGINX_CONF
 fi
 
 service supervisor start
diff --git a/opnfv_testapi/ui/root.py b/opnfv_testapi/ui/root.py
deleted file mode 100644 (file)
index 7f970b2..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-from opnfv_testapi.resources.handlers import GenericApiHandler
-from opnfv_testapi.common.config import CONF
-
-
-class RootHandler(GenericApiHandler):
-    def get_template_path(self):
-        return CONF.ui_static_path
-
-    def get(self):
-        self.render('testapi-ui/index.html')