From 38509f1fbad27de70eef1e81eaa2c5084765ca8f Mon Sep 17 00:00:00 2001 From: Michael DÜrre Date: Thu, 27 Jan 2022 13:43:37 +0100 Subject: improve sdnc-web for external apps MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit add package manager for more flexibility Issue-ID: SDNC-1658 Signed-off-by: Michael DÜrre Change-Id: I30f4aaa24cf05fce212282b06d5e08437dbcfa8b Signed-off-by: Michael DÜrre Former-commit-id: f41f011ff2e18befd77dd63ab828ea14aafac2a7 --- installation/sdnc-web/src/main/docker/Dockerfile | 21 +- .../sdnc-web/src/main/resources/favicon.ico | Bin 0 -> 268322 bytes .../sdnc-web/src/main/resources/http_site.conf | 33 +- .../sdnc-web/src/main/resources/https_site.conf | 34 +-- .../sdnc-web/src/main/resources/location.rules | 46 +++ .../src/main/resources/odlux.application.list | 9 + .../sdnc-web/src/main/scripts/configure.py | 34 +++ .../sdnc-web/src/main/scripts/configure.sh | 106 ------- installation/sdnc-web/src/main/scripts/core.py | 333 +++++++++++++++++++++ installation/sdnc-web/src/main/scripts/opm.py | 126 ++++++++ installation/sdnc-web/src/main/scripts/run.sh | 11 +- 11 files changed, 573 insertions(+), 180 deletions(-) create mode 100644 installation/sdnc-web/src/main/resources/favicon.ico create mode 100644 installation/sdnc-web/src/main/resources/location.rules create mode 100644 installation/sdnc-web/src/main/resources/odlux.application.list create mode 100644 installation/sdnc-web/src/main/scripts/configure.py delete mode 100644 installation/sdnc-web/src/main/scripts/configure.sh create mode 100644 installation/sdnc-web/src/main/scripts/core.py create mode 100755 installation/sdnc-web/src/main/scripts/opm.py (limited to 'installation/sdnc-web/src') diff --git a/installation/sdnc-web/src/main/docker/Dockerfile b/installation/sdnc-web/src/main/docker/Dockerfile index a552137f..9f3f6870 100644 --- a/installation/sdnc-web/src/main/docker/Dockerfile +++ b/installation/sdnc-web/src/main/docker/Dockerfile @@ -22,12 +22,14 @@ # Base bitnami nginx image FROM ${base.image.repo} LABEL maintainer="CCSDK Team (onap-ccsdk@lists.onap.org)" - +USER root +RUN apt-get update && apt-get install python3-minimal python3-urllib3 unzip openssl -y +USER 1001 # copy ODLUX files to nginx COPY html /opt/bitnami/nginx/html # copy site conf files -COPY *.conf /opt/bitnami/nginx/conf/server_blocks/ +COPY conf/* /opt/bitnami/nginx/conf/server_blocks/ # setup environment variables ENV WEBPROTOCOL="HTTP" \ @@ -38,20 +40,25 @@ ENV WEBPROTOCOL="HTTP" \ TRPCEURL="" \ TOPOURL="" \ TILEURL="" \ - DNS_RESOLVER="1.1.1.1" \ + SITEDOCURL="" \ + DNS_RESOLVER="1.1.1.1 ipv6=off" \ + DNS_INTERNAL_RESOLVER="127.0.0.11" \ SSL_CERT_DIR="/app/cert" \ SSL_CERTIFICATE="cert.pem" \ SSL_CERTIFICATE_KEY="cert.key" # Check if /app can be used. If so, create "custom" directory and copy the files there. -COPY bin/*.sh /opt/bitnami/nginx/sbin/ +COPY bin/* /opt/bitnami/nginx/sbin/ USER root -RUN chmod +x /opt/bitnami/nginx/sbin/configure.sh /opt/bitnami/nginx/sbin/run.sh +RUN chmod +x /opt/bitnami/nginx/sbin/run.sh /opt/bitnami/nginx/sbin/opm.py # By default, docker copies files with the permissions of the build user. To avoid cases where build user # has 644 which can result in failure of certain commands -RUN chmod -R g+w /opt/bitnami/nginx/html/odlux - +RUN chmod -R g+w /opt/bitnami/nginx/html/odlux && mkdir /app/init.d +RUN chmod 666 /opt/bitnami/nginx/conf/server_blocks/*.rules +#RUN chown 1001:1001 /app/odlux.application.list && chmod 777 /app/odlux.application.list +RUN chown -R 1001:1001 /app +RUN ln -s /opt/bitnami/nginx/sbin/opm.py /usr/local/bin/opm USER 1001 CMD [ "/opt/bitnami/nginx/sbin/run.sh" ] diff --git a/installation/sdnc-web/src/main/resources/favicon.ico b/installation/sdnc-web/src/main/resources/favicon.ico new file mode 100644 index 00000000..650067eb Binary files /dev/null and b/installation/sdnc-web/src/main/resources/favicon.ico differ diff --git a/installation/sdnc-web/src/main/resources/http_site.conf b/installation/sdnc-web/src/main/resources/http_site.conf index ea6c33be..3d9ade13 100644 --- a/installation/sdnc-web/src/main/resources/http_site.conf +++ b/installation/sdnc-web/src/main/resources/http_site.conf @@ -49,36 +49,5 @@ server { server_name _; - location ~ ^/$ { - return 301 /odlux/index.html; - } - location ~ ^/help/$ { - try_files /help/$args.json $uri; - } - location ~ ^/transportpce { - if ($request_uri ~* "/transportpce/(.*)") { - proxy_pass TRPCEURL/$1; - } - } - location ~ ^/topology { - proxy_pass TOPOURL; - } - location ~ ^/tiles/ { - resolver DNS_RESOLVER; - if ($request_uri ~* "/tiles/(.*)") { - proxy_pass TILEURL/$1; - } - } - location / { - try_files $uri $uri/ @backend; - } - location /websocket { - proxy_pass SDNRPROTOCOL://SDNRHOST:SDNRPORT/websocket; - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; - } - location @backend { - proxy_pass SDNRPROTOCOL://SDNRHOST:SDNRPORT; - } + include server_blocks/location.rules; } diff --git a/installation/sdnc-web/src/main/resources/https_site.conf b/installation/sdnc-web/src/main/resources/https_site.conf index 5e61fece..6dcfb790 100644 --- a/installation/sdnc-web/src/main/resources/https_site.conf +++ b/installation/sdnc-web/src/main/resources/https_site.conf @@ -68,36 +68,6 @@ server { server_name _; - location ~ ^/$ { - return 301 /odlux/index.html; - } - location ~ ^/help/$ { - try_files /help/$args.json $uri; - } - location ~ ^/transportpce { - if ($request_uri ~* "/transportpce/(.*)") { - proxy_pass TRPCEURL/$1; - } - } - location ~ ^/topology { - proxy_pass TOPOURL; - } - location ~ ^/tiles/ { - resolver DNS_RESOLVER; - if ($request_uri ~* "/tiles/(.*)") { - proxy_pass TILEURL/$1; - } - } - location / { - try_files $uri $uri/ @backend; - } - location /websocket { - proxy_pass SDNRPROTOCOL://SDNRHOST:SDNRPORT/websocket; - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; - } - location @backend { - proxy_pass SDNRPROTOCOL://SDNRHOST:SDNRPORT; - } + include server_blocks/location.rules; + } diff --git a/installation/sdnc-web/src/main/resources/location.rules b/installation/sdnc-web/src/main/resources/location.rules new file mode 100644 index 00000000..83120d60 --- /dev/null +++ b/installation/sdnc-web/src/main/resources/location.rules @@ -0,0 +1,46 @@ +location ~ ^/$ { + return 301 " /odlux/index.html"; +} +location ~ ^/help/$ { + try_files /help/$args.json $uri; +} +location ~ ^/transportpce { + resolver DNS_INTERNAL_RESOLVER; + if ($request_uri ~* "/transportpce/(.*)") { + proxy_pass TRPCEURL/$1; + } +} +location ~ ^/topology/ { + resolver DNS_INTERNAL_RESOLVER; + proxy_pass TOPOURL; +} +location ~ ^/sitedoc/ { + resolver DNS_INTERNAL_RESOLVER; + if ($request_uri ~* "/sitedoc/(.*)") { + proxy_pass SITEDOCURL/topology/stadok/$1; + } +} +location ~ ^/tiles/ { + resolver DNS_RESOLVER; + if ($request_uri ~* "/tiles/(.*)") { + proxy_pass TILEURL/$1; + } +} +location ~ ^/terrain/ { + resolver DNS_INTERNAL_RESOLVER; + if ($request_uri ~* "/terrain/(.*)") { + proxy_pass TERRAINURL/$1; + } +} +location / { + try_files $uri $uri/ @backend; +} +location /websocket { + proxy_pass SDNRPROTOCOL://SDNRHOST:SDNRPORT/websocket; + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; +} +location @backend { + proxy_pass SDNRPROTOCOL://SDNRHOST:SDNRPORT; +} \ No newline at end of file diff --git a/installation/sdnc-web/src/main/resources/odlux.application.list b/installation/sdnc-web/src/main/resources/odlux.application.list new file mode 100644 index 00000000..9176aae6 --- /dev/null +++ b/installation/sdnc-web/src/main/resources/odlux.application.list @@ -0,0 +1,9 @@ +1 connectApp +10 faultApp +20 maintenanceApp +30 configurationApp +55 performanceHistoryApp +70 inventoryApp +75 eventLogApp +90 mediatorApp +200 helpApp diff --git a/installation/sdnc-web/src/main/scripts/configure.py b/installation/sdnc-web/src/main/scripts/configure.py new file mode 100644 index 00000000..255cbcd5 --- /dev/null +++ b/installation/sdnc-web/src/main/scripts/configure.py @@ -0,0 +1,34 @@ +#!/bin/bash + +### +# ============LICENSE_START======================================================= +# ONAP : ccsdk distribution web +# ================================================================================ +# Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. +# All rights reserved. +# ================================================================================ +# 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. +# ============LICENSE_END========================================================= +### + +# load core methods to call +from core import * + +# Comment listening on 8080 in nginx.conf as we don't want nginx to listen on any port other than SDNR +sedInFile('listen','\#listen', '/opt/bitnami/nginx/conf/nginx.conf') +initial_load() +update_index_html() + +check_for_rule_template() + +update_nginx_site_conf() diff --git a/installation/sdnc-web/src/main/scripts/configure.sh b/installation/sdnc-web/src/main/scripts/configure.sh deleted file mode 100644 index a257e6e1..00000000 --- a/installation/sdnc-web/src/main/scripts/configure.sh +++ /dev/null @@ -1,106 +0,0 @@ -#!/bin/bash - -### -# ============LICENSE_START======================================================= -# ONAP : ccsdk distribution web -# ================================================================================ -# Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. -# All rights reserved. -# ================================================================================ -# 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. -# ============LICENSE_END========================================================= -### - -# Comment listening on 8080 in nginx.conf as we don't want nginx to listen on any port other than SDNR -sed -i 's/listen/\#listen/g' /opt/bitnami/nginx/conf/nginx.conf - -update_index_html() { - - # Backup the index.html file - cp /opt/bitnami/nginx/html/odlux/index.html /opt/bitnami/nginx/html/odlux/index.html.backup - #default values - ODLUX_AUTH_METHOD="basic" - ENABLE_ODLUX_RBAC=${ENABLE_ODLUX_RBAC:-false} - - if [ "$ENABLE_OAUTH" == "true" ]; then - ODLUX_AUTH_METHOD="oauth" - fi - echo "authentication is $ODLUX_AUTH_METHOD" - echo "rbac access is enabled: $ENABLE_ODLUX_RBAC" - ODLUX_CONFIG='{"authentication":"'$ODLUX_AUTH_METHOD'","enablePolicy":'$ENABLE_ODLUX_RBAC'}' -# sed -z 's/