memcached container as sidecar 19/127919/5 1.5.7
authorBin Yang <bin.yang@windriver.com>
Mon, 21 Mar 2022 14:40:51 +0000 (22:40 +0800)
committerBin Yang <bin.yang@windriver.com>
Tue, 22 Mar 2022 06:31:13 +0000 (14:31 +0800)
To fix the dependency on memcached which depends on the GPLv3 licensed gdbm indirectly,
Use sidecar to integrate memcached from dockerhub

Add docker-composer scripts to support local test

Issue-ID: MULTICLOUD-1457

Signed-off-by: Bin Yang <bin.yang@windriver.com>
Change-Id: I55a156c0af158535dccfa87e7b9603e47be4d9c1

31 files changed:
docker-compose-fcaps.yml [new file with mode: 0644]
docker-compose-pike.yml [moved from fcaps/docker/docker-compose.yml with 66% similarity]
docker-compose-starlingx.yml [new file with mode: 0644]
docker-compose-windriver.yml [new file with mode: 0644]
fcaps/README.md
fcaps/docker/Dockerfile
fcaps/docker/Dockerfile4composer [new file with mode: 0644]
fcaps/fcaps/celery.py
fcaps/fcaps/settings.py
fcaps/run.sh
fcaps/stop.sh
pike/README.md
pike/docker/Dockerfile
pike/docker/Dockerfile4composer [new file with mode: 0644]
pike/pike/settings.py
pike/run.sh
pike/stop.sh
starlingx/README.md
starlingx/docker/Dockerfile
starlingx/docker/Dockerfile4composer [new file with mode: 0644]
starlingx/run.sh
starlingx/starlingx/pub/config/log.yml
starlingx/starlingx/settings.py
starlingx/stop.sh
windriver/README.md
windriver/docker/Dockerfile
windriver/docker/Dockerfile4composer [new file with mode: 0644]
windriver/run.sh
windriver/stop.sh
windriver/titanium_cloud/pub/config/log.yml
windriver/titanium_cloud/settings.py

diff --git a/docker-compose-fcaps.yml b/docker-compose-fcaps.yml
new file mode 100644 (file)
index 0000000..7ce0782
--- /dev/null
@@ -0,0 +1,45 @@
+# Copyright 2019 CMCC Corporation.
+# 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.
+
+# Only used for local test
+#First need to add broker('amqp://admin:mypass@rabbit:5672') to Celery
+
+version: '2'
+services:
+    rabbit:
+        hostname: rabbit
+        image: rabbitmq:alpine
+        environment:
+            - RABBITMQ_DEFAULT_USER=admin
+            - RABBITMQ_DEFAULT_PASS=mypass
+        ports:
+            - "5672:5672"
+            - "15672:15672"
+            - "15692:15692"
+    memcached:
+        hostname: memcached
+        image: memcached:alpine3.15
+        command: ["memcached", "-m", "2048", "-c", "1024", "-p", "11211", "-P", "/tmp/memcached1.pid", "-v"]
+        ports:
+        - "11211:11211"
+
+    worker:
+        build:
+            context: .
+            dockerfile: ./fcaps/docker/Dockerfile4composer
+        image: openstack-fcaps:test
+        environment:
+            - RABBITMQ_DEFAULT_USER=admin
+            - RABBITMQ_DEFAULT_PASS=mypass
+            - RABBITMQ_HOST=rabbit
+            - MEMCACHED_HOST=memcached
+        # volumes:
+        #     - .:/fcaps
similarity index 66%
rename from fcaps/docker/docker-compose.yml
rename to docker-compose-pike.yml
index 5a9c256..e4e8084 100644 (file)
 
 version: '2'
 services:
-    rabbit:
-        hostname: rabbit
-        image: rabbitmq:alpine
-        environment:
-            - RABBITMQ_DEFAULT_USER=admin
-            - RABBITMQ_DEFAULT_PASS=mypass
+    memcached:
+        hostname: memcached
+        image: memcached:alpine3.15
+        command: ["memcached", "-m", "2048", "-c", "1024", "-p", "11211", "-P", "/tmp/memcached1.pid", "-v"]
         ports:
-            - "15672:15672"
+        - "11211:11211"
 
     worker:
         build:
             context: .
-            dockerfile: Dockerfile
-        volumes:
-            - .:/fcaps
+            dockerfile: ./pike/docker/Dockerfile4composer
+        image: openstack-pike:test
+        environment:
+            - MEMCACHED_HOST=memcached
+        # volumes:
+        #     - .:/fcaps
diff --git a/docker-compose-starlingx.yml b/docker-compose-starlingx.yml
new file mode 100644 (file)
index 0000000..3efcac5
--- /dev/null
@@ -0,0 +1,32 @@
+# Copyright 2019 CMCC Corporation.
+# 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.
+
+# Only used for local test
+#First need to add broker('amqp://admin:mypass@rabbit:5672') to Celery
+
+version: '2'
+services:
+    memcached:
+        hostname: memcached
+        image: memcached:alpine3.15
+        command: ["memcached", "-m", "2048", "-c", "1024", "-p", "11211", "-P", "/tmp/memcached1.pid", "-v"]
+        ports:
+        - "11211:11211"
+
+    worker:
+        build:
+            context: .
+            dockerfile: ./starlingx/docker/Dockerfile4composer
+        image: openstack-starlingx:test
+        environment:
+            - MEMCACHED_HOST=memcached
+        # volumes:
+        #     - .:/fcaps
diff --git a/docker-compose-windriver.yml b/docker-compose-windriver.yml
new file mode 100644 (file)
index 0000000..34a269c
--- /dev/null
@@ -0,0 +1,32 @@
+# Copyright 2019 CMCC Corporation.
+# 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.
+
+# Only used for local test
+#First need to add broker('amqp://admin:mypass@rabbit:5672') to Celery
+
+version: '2'
+services:
+    memcached:
+        hostname: memcached
+        image: memcached:alpine3.15
+        command: ["memcached", "-m", "2048", "-c", "1024", "-p", "11211", "-P", "/tmp/memcached1.pid", "-v"]
+        ports:
+        - "11211:11211"
+
+    worker:
+        build:
+            context: .
+            dockerfile: ./windriver/docker/Dockerfile4composer
+        image: openstack-windriver:test
+        environment:
+            - MEMCACHED_HOST=memcached
+        # volumes:
+        #     - .:/fcaps
index 8005e17..b02e0d7 100644 (file)
 # limitations under the License.
 
 # Micro service of MultiCloud plugin for Wind River Titanium Cloud.
+
+### local test with docker-composer:
+
+docker-compose -f docker-compose-fcaps.yml build
+
+docker-compose -f docker-compose-fcaps.yml up -d
+
+docker ps
+
+### Test memcached
+docker exec -it openstack_worker_1 sh
+
+cat <<EOF>testmemcached.py
+import memcache
+mem = memcache.Client(['memcached:11211'], debug=1)
+mem.set("testkey1","testvalue1")
+value1 = mem.get("testkey1")
+print("memcached is working" if value1=="testvalue1" else "memcached is not working")
+EOF
+
+python testmemcached.py
+
+exit
+
+docker-compose -f docker-compose-fcaps.yml down
\ No newline at end of file
index 3de775a..f25e28a 100644 (file)
@@ -25,7 +25,7 @@ USER root
 COPY ./multicloud-openstack-fcaps-*.zip /opt/multicloud-openstack-fcaps.zip
 
 RUN apk update && \
-    apk add pcre pcre-dev uwsgi memcached wget unzip gcc make libc-dev libffi-dev openssl-dev && \
+    apk add pcre pcre-dev uwsgi wget unzip gcc make libc-dev libffi-dev openssl-dev && \
     cd /opt/ && \
     unzip -q -o -B multicloud-openstack-fcaps.zip && \
     chmod +x /opt/fcaps/*.sh && \
diff --git a/fcaps/docker/Dockerfile4composer b/fcaps/docker/Dockerfile4composer
new file mode 100644 (file)
index 0000000..0c5c165
--- /dev/null
@@ -0,0 +1,43 @@
+# FROM python:3.8-alpine
+FROM nexus3.onap.org:10001/onap/integration-python:9.1.0
+
+ARG HTTP_PROXY=${HTTP_PROXY}
+ARG HTTPS_PROXY=${HTTPS_PROXY}
+
+ENV http_proxy $HTTP_PROXY
+ENV https_proxy $HTTPS_PROXY
+
+ENV MSB_PROTO "http"
+ENV MSB_ADDR "127.0.0.1"
+ENV MSB_PORT "80"
+ENV AAI_ADDR "aai.api.simpledemo.openecomp.org"
+ENV AAI_PORT "8443"
+ENV AAI_SCHEMA_VERSION "v13"
+ENV AAI_USERNAME "AAI"
+ENV AAI_PASSWORD "AAI"
+
+EXPOSE 9011
+
+# RUN addgroup -S onap && adduser -S -G onap onap
+USER root
+
+COPY ./fcaps /opt/fcaps/
+COPY ./share /opt/fcaps/lib/share
+# COPY ./multicloud-openstack-fcaps-*.zip /opt/multicloud-openstack-fcaps.zip
+
+RUN apk update && \
+    apk add pcre pcre-dev uwsgi wget unzip gcc make libc-dev libffi-dev openssl-dev && \
+    cd /opt/ && \
+    chmod +x /opt/fcaps/*.sh && \
+    pip3 install --no-cache-dir -r /opt/fcaps/requirements.txt && \
+    pip3 install --no-cache-dir -r /opt/fcaps/uwsgi-requirements.txt && \
+    apk del wget unzip gcc make libc-dev libffi-dev openssl-dev pcre-dev && \
+    mkdir -p /var/log/onap/multicloud/fcaps && \
+    chown onap:onap /var/log/onap -R && \
+    chown onap:onap /opt/fcaps -R
+
+
+USER onap
+
+WORKDIR /opt/fcaps
+CMD /bin/sh -c /opt/fcaps/run.sh
index ca3b2e5..93ad698 100644 (file)
@@ -16,11 +16,14 @@ from __future__ import absolute_import, unicode_literals
 import os
 from celery import Celery
 import logging
+from django.conf import settings
+
 
 # set the default Django settings module for the 'celery' program.
 os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'fcaps.settings')
 
-app = Celery('fcaps')
+# app = Celery('fcaps', broker='amqp://guest:guest@localhost:5672//')
+app = Celery('fcaps', broker=settings.RABBITMQ_URL)
 
 # Using a string here means the worker doesn't have to serialize
 # the configuration object to child processes.
index 37021e0..5e663c6 100644 (file)
@@ -79,9 +79,12 @@ TIME_ZONE = 'UTC'
 
 STATIC_URL = '/static/'
 
-
 DEFAULT_MSB_ADDR = "127.0.0.1"
-DEFAULT_CACHE_BACKEND_LOCATION = '127.0.0.1:11211'
+# DEFAULT_CACHE_BACKEND_LOCATION = '127.0.0.1:11211'
+MEMCACHED_HOST = os.environ.get('MEMCACHED_HOST', '127.0.0.1')
+MEMCACHED_PORT = os.environ.get('MEMCACHED_PORT', '11211')
+DEFAULT_CACHE_BACKEND_LOCATION = "%s:%s" % (MEMCACHED_HOST, MEMCACHED_PORT)
+
 
 CACHES = {
     'default': {
@@ -90,6 +93,14 @@ CACHES = {
     }
 }
 
+# [RABBITMQ]
+RABBITMQ_DEFAULT_USER = os.environ.get('RABBITMQ_DEFAULT_USER', 'guest')
+RABBITMQ_DEFAULT_PASS = os.environ.get('RABBITMQ_DEFAULT_PASS', 'guest')
+RABBITMQ_HOST = os.environ.get('RABBITMQ_HOST', 'localhost')
+RABBITMQ_PORT = os.environ.get('RABBITMQ_PORT', '5672')
+RABBITMQ_URL = "amqp://%s:%s@%s:%s//" % (
+    RABBITMQ_DEFAULT_USER, RABBITMQ_DEFAULT_PASS, RABBITMQ_HOST, RABBITMQ_PORT)
+
 # [MSB]
 DEFAULT_MSB_PROTO = "http"
 MSB_SERVICE_PROTOCOL = os.environ.get('MSB_PROTO', DEFAULT_MSB_PROTO)
index e8b8209..864644c 100644 (file)
@@ -13,7 +13,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-memcached -d -m 2048 -c 1024 -p 11211 -P /tmp/memcached1.pid
+# memcached should be provided as sidecar to avoid GPLv3 license issue
+# memcached -d -m 2048 -c 1024 -p 11211 -P /tmp/memcached1.pid
 export PYTHONPATH=lib/share
 
 #service rabbitmq-server restart
@@ -36,5 +37,3 @@ while [ ! -f $logDir/fcaps.log ]; do
 done
 
 tail -F $logDir/fcaps.log
-
-
index d608abe..88c30b1 100644 (file)
@@ -15,4 +15,4 @@
 
 #ps auxww | grep 'manage.py runserver 0.0.0.0:9011' | awk '{print $2}' | xargs kill -9
 ps auxww |grep 'uwsgi --http :9011 --module fcaps.wsgi --master' |awk '{print $2}' |xargs kill -9
-ps auxww | grep 'memcached -d -m 2048 -c 1024 -p 11211 -P /tmp/memcached1.pid' | awk '{print $2}' | xargs kill -9
+ps auxww | grep 'memcached -d -m 2048 -c 1024 -p 11211 -P /tmp/memcached1.pid' | awk '{print $2}' | xargs kill -9
index e623122..a7f2761 100644 (file)
 # limitations under the License.
 
 # Micro service of MultiCloud plugin for pike.
+### local test with docker-composer:
+
+docker-compose -f docker-compose-pike.yml build
+
+docker-compose -f docker-compose-pike.yml up -d
+
+docker ps
+
+### Test memcached
+docker exec -it openstack_worker_1 sh
+
+cat <<EOF>testmemcached.py
+import memcache
+mem = memcache.Client(['memcached:11211'], debug=1)
+mem.set("testkey1","testvalue1")
+value1 = mem.get("testkey1")
+print("memcached is working" if value1=="testvalue1" else "memcached is not working")
+EOF
+
+python testmemcached.py
+
+exit
+
+docker-compose -f docker-compose-pike.yml down
\ No newline at end of file
index 7ce5402..ce239b2 100644 (file)
@@ -38,7 +38,7 @@ USER root
 
 COPY ./multicloud-openstack-pike-*.zip /opt/multicloud-openstack-pike.zip
 RUN apk update && \
-    apk add pcre pcre-dev uwsgi memcached wget unzip gcc make libc-dev libffi-dev openssl-dev && \
+    apk add pcre pcre-dev uwsgi wget unzip gcc make libc-dev libffi-dev openssl-dev && \
     cd /opt/ && \
     unzip -q -o -B /opt/multicloud-openstack-pike.zip -d /opt/ && \
     rm -f /opt/multicloud-openstack-pike.zip && \
diff --git a/pike/docker/Dockerfile4composer b/pike/docker/Dockerfile4composer
new file mode 100644 (file)
index 0000000..cbc5c8c
--- /dev/null
@@ -0,0 +1,56 @@
+# Copyright (c) 2018 Intel Corporation.
+#
+# 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 python:3.8-alpine
+FROM nexus3.onap.org:10001/onap/integration-python:9.1.0
+
+ARG HTTP_PROXY=${HTTP_PROXY}
+ARG HTTPS_PROXY=${HTTPS_PROXY}
+
+ENV http_proxy $HTTP_PROXY
+ENV https_proxy $HTTPS_PROXY
+
+ENV MSB_PROTO "http"
+ENV MSB_ADDR "127.0.0.1"
+ENV MSB_PORT "80"
+ENV AAI_ADDR "aai.api.simpledemo.openecomp.org"
+ENV AAI_PORT "8443"
+ENV AAI_SERVICE_URL ""
+ENV AAI_SCHEMA_VERSION "v13"
+ENV AAI_USERNAME "AAI"
+ENV AAI_PASSWORD "AAI"
+
+EXPOSE 9007
+
+# RUN addgroup -S onap && adduser -S -G onap onap
+USER root
+
+COPY ./pike /opt/pike/
+COPY ./share /opt/pike/lib/share
+# COPY ./multicloud-openstack-pike-*.zip /opt/multicloud-openstack-pike.zip
+RUN apk update && \
+    apk add pcre pcre-dev uwsgi wget unzip gcc make libc-dev libffi-dev openssl-dev && \
+    cd /opt/ && \
+    pip3 install --no-cache-dir -r /opt/pike/requirements.txt && \
+    pip3 install --no-cache-dir -r /opt/pike/uwsgi-requirements.txt && \
+    apk del wget unzip gcc make libc-dev libffi-dev openssl-dev pcre-dev && \
+    mkdir -p /var/log/onap/multicloud/openstack/pike && \
+    chown onap:onap /var/log/onap -R && \
+    chown onap:onap /opt/pike -R
+
+RUN mkdir -p /var/log/onap/multicloud/openstack/pike/
+
+USER onap
+WORKDIR /opt/pike
+CMD /bin/sh -c "/opt/pike/run.sh"
\ No newline at end of file
index 83c7415..d765ca3 100644 (file)
@@ -79,14 +79,25 @@ TIME_ZONE = 'UTC'
 # https://docs.djangoproject.com/en/1.6/howto/static-files/
 
 STATIC_URL = '/static/'
+MEMCACHED_HOST = os.environ.get('MEMCACHED_HOST', '127.0.0.1')
+MEMCACHED_PORT = os.environ.get('MEMCACHED_PORT', '11211')
+DEFAULT_CACHE_BACKEND_LOCATION = "%s:%s" % (MEMCACHED_HOST, MEMCACHED_PORT)
 
 CACHES = {
     'default': {
         'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
-        'LOCATION': '127.0.0.1:11211',
+        'LOCATION': DEFAULT_CACHE_BACKEND_LOCATION,
     }
 }
 
+# [RABBITMQ]
+RABBITMQ_DEFAULT_USER = os.environ.get('RABBITMQ_DEFAULT_USER', 'guest')
+RABBITMQ_DEFAULT_PASS = os.environ.get('RABBITMQ_DEFAULT_PASS', 'guest')
+RABBITMQ_HOST = os.environ.get('RABBITMQ_HOST', 'localhost')
+RABBITMQ_PORT = os.environ.get('RABBITMQ_PORT', '5672')
+RABBITMQ_URL = "amqp://%s:%s@%s:%s//" % (
+    RABBITMQ_DEFAULT_USER, RABBITMQ_DEFAULT_PASS, RABBITMQ_HOST, RABBITMQ_PORT)
+
 # [MSB]
 DEFAULT_MSB_PROTO = "http"
 MSB_SERVICE_PROTOCOL = os.environ.get('MSB_PROTO', DEFAULT_MSB_PROTO)
index c4ac483..fb81ee9 100755 (executable)
@@ -13,7 +13,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-memcached -d -m 2048 -c 1024 -p 11211 -P /tmp/memcached1.pid
+# memcached should be provided as sidecar to avoid GPLv3 license issue
+# memcached -d -m 2048 -c 1024 -p 11211 -P /tmp/memcached1.pid
 export PYTHONPATH=lib/share
 
 #nohup python manage.py runserver 0.0.0.0:9007 2>&1 &
index 6343dd1..77ee703 100755 (executable)
@@ -15,4 +15,4 @@
 
 #ps auxww | grep 'manage.py runserver 0.0.0.0:9007' | awk '{print $2}' | xargs kill -9
 ps auxww |grep 'uwsgi --http :9007 --module pike.wsgi --master' |awk '{print $2}' |xargs kill -9
-ps auxww | grep 'memcached -d -m 2048 -c 1024 -p 11211 -P /tmp/memcached1.pid' | awk '{print $2}' | xargs kill -9
+ps auxww | grep 'memcached -d -m 2048 -c 1024 -p 11211 -P /tmp/memcached1.pid' | awk '{print $2}' | xargs kill -9
index c8b300a..48c7be7 100644 (file)
 # limitations under the License.
 
 # Micro service of MultiCloud plugin for starlingx.
+
+
+docker-compose -f docker-compose-starlingx.yml build
+
+docker-compose -f docker-compose-starlingx.yml up -d
+
+docker ps
+
+### Test memcached
+docker exec -it openstack_worker_1 sh
+
+cat <<EOF>testmemcached.py
+import memcache
+mem = memcache.Client(['memcached:11211'], debug=1)
+mem.set("testkey1","testvalue1")
+value1 = mem.get("testkey1")
+print("memcached is working" if value1=="testvalue1" else "memcached is not working")
+EOF
+
+python testmemcached.py
+
+exit
+
+docker-compose -f docker-compose-starlingx.yml down
+
index 79b351d..d0cb914 100644 (file)
@@ -39,7 +39,7 @@ USER root
 # COPY ./ /opt/
 COPY ./multicloud-openstack-starlingx-*.zip /opt/multicloud-openstack-starlingx.zip
 RUN apk update && \
-    apk add pcre pcre-dev uwsgi memcached wget unzip gcc make libc-dev libffi-dev openssl-dev && \
+    apk add pcre pcre-dev uwsgi wget unzip gcc make libc-dev libffi-dev openssl-dev && \
     cd /opt/ && \
     unzip -q -o -B /opt/multicloud-openstack-starlingx.zip -d /opt/ && \
     rm -f /opt/multicloud-openstack-starlingx.zip && \
diff --git a/starlingx/docker/Dockerfile4composer b/starlingx/docker/Dockerfile4composer
new file mode 100644 (file)
index 0000000..e99dce8
--- /dev/null
@@ -0,0 +1,57 @@
+# Copyright (c) 2019 Intel Corporation.
+#
+# 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 python:3.8-alpine
+FROM nexus3.onap.org:10001/onap/integration-python:9.1.0
+
+ARG HTTP_PROXY=${HTTP_PROXY}
+ARG HTTPS_PROXY=${HTTPS_PROXY}
+
+ENV http_proxy $HTTP_PROXY
+ENV https_proxy $HTTPS_PROXY
+
+ENV MSB_PROTO "http"
+ENV MSB_ADDR "127.0.0.1"
+ENV MSB_PORT "80"
+ENV AAI_ADDR "aai.api.simpledemo.openecomp.org"
+ENV AAI_PORT "8443"
+ENV AAI_SERVICE_URL ""
+ENV AAI_SCHEMA_VERSION "v13"
+ENV AAI_USERNAME "AAI"
+ENV AAI_PASSWORD "AAI"
+
+EXPOSE 9009
+
+# RUN addgroup -S onap && adduser -S -G onap onap
+USER root
+
+COPY ./starlingx /opt/starlingx/
+COPY ./share /opt/starlingx/lib/share
+# COPY ./ /opt/
+# COPY ./multicloud-openstack-starlingx-*.zip /opt/multicloud-openstack-starlingx.zip
+RUN apk update && \
+    apk add pcre pcre-dev uwsgi wget unzip gcc make libc-dev libffi-dev openssl-dev && \
+    cd /opt/ && \
+    pip3 install --no-cache-dir -r /opt/starlingx/requirements.txt && \
+    pip3 install --no-cache-dir -r /opt/starlingx/uwsgi-requirements.txt && \
+    apk del wget unzip gcc make libc-dev libffi-dev openssl-dev pcre-dev && \
+    mkdir -p /var/log/onap/multicloud/openstack/starlingx && \
+    chown onap:onap /var/log/onap -R && \
+    chown onap:onap /opt/starlingx -R
+    
+RUN mkdir -p /var/log/onap/multicloud/openstack/starlingx/
+
+USER onap
+WORKDIR /opt/starlingx
+CMD /bin/sh -c "/opt/starlingx/run.sh"
index 66dd111..81d2df3 100755 (executable)
@@ -13,7 +13,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-memcached -d -m 2048 -c 1024 -p 11211 -P /tmp/memcached1.pid
+# memcached should be provided as sidecar to avoid GPLv3 license issue
+# memcached -d -m 2048 -c 1024 -p 11211 -P /tmp/memcached1.pid
 export PYTHONPATH=lib/share
 # uwsgi --http :9009 --module starlingx.wsgi --master --processes 4
 
index ef68a65..d819c23 100644 (file)
@@ -16,11 +16,11 @@ version: 1
 disable_existing_loggers: False
 
 loggers:
-    starlingx:
+    starlingx_base:
       handlers: [console_handler, file_handler]
       level: "DEBUG"
       propagate: False
-    starlingx_base:
+    starlingx:
       handlers: [console_handler, file_handler]
       level: "DEBUG"
       propagate: False
@@ -32,6 +32,7 @@ loggers:
       handlers: [console_handler, file_handler]
       level: "DEBUG"
       propagate: False
+
 handlers:
     console_handler:
         level: "DEBUG"
@@ -44,3 +45,7 @@ handlers:
         formatter: "standard"
         maxBytes: 52428800
         backupCount: 10
+
+formatters:
+    standard:
+        format: "%(asctime)s|||||%(name)s||%(thread)||%(funcName)s||%(levelname)s||%(message)s"
index d5362e4..c19e857 100644 (file)
@@ -80,14 +80,25 @@ TIME_ZONE = 'UTC'
 # https://docs.djangoproject.com/en/1.6/howto/static-files/
 
 STATIC_URL = '/static/'
+MEMCACHED_HOST = os.environ.get('MEMCACHED_HOST', '127.0.0.1')
+MEMCACHED_PORT = os.environ.get('MEMCACHED_PORT', '11211')
+DEFAULT_CACHE_BACKEND_LOCATION = "%s:%s" % (MEMCACHED_HOST, MEMCACHED_PORT)
 
 CACHES = {
     'default': {
         'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
-        'LOCATION': '127.0.0.1:11211',
+        'LOCATION': DEFAULT_CACHE_BACKEND_LOCATION,
     }
 }
 
+# [RABBITMQ]
+RABBITMQ_DEFAULT_USER = os.environ.get('RABBITMQ_DEFAULT_USER', 'guest')
+RABBITMQ_DEFAULT_PASS = os.environ.get('RABBITMQ_DEFAULT_PASS', 'guest')
+RABBITMQ_HOST = os.environ.get('RABBITMQ_HOST', 'localhost')
+RABBITMQ_PORT = os.environ.get('RABBITMQ_PORT', '5672')
+RABBITMQ_URL = "amqp://%s:%s@%s:%s//" % (
+    RABBITMQ_DEFAULT_USER, RABBITMQ_DEFAULT_PASS, RABBITMQ_HOST, RABBITMQ_PORT)
+
 # [MSB]
 DEFAULT_MSB_PROTO = "http"
 MSB_SERVICE_PROTOCOL = os.environ.get('MSB_PROTO', DEFAULT_MSB_PROTO)
index 3f7fd2a..8de97f9 100755 (executable)
@@ -15,4 +15,4 @@
 
 #ps auxww | grep 'manage.py runserver 0.0.0.0:9009' | awk '{print $2}' | xargs kill -9
 ps auxww |grep 'uwsgi --http :9009 --module starlingx.wsgi --master' |awk '{print $2}' |xargs kill -9
-ps auxww | grep 'memcached -d -m 2048 -c 1024 -p 11211 -P /tmp/memcached1.pid' | awk '{print $2}' | xargs kill -9
+ps auxww | grep 'memcached -d -m 2048 -c 1024 -p 11211 -P /tmp/memcached1.pid' | awk '{print $2}' | xargs kill -9
index d3bcc19..f6dcf8a 100644 (file)
 # limitations under the License.
 
 # Micro service of MultiCloud plugin for Wind River Titanium Cloud.
+
+docker-compose -f docker-compose-windriver.yml build
+
+docker-compose -f docker-compose-windriver.yml up -d
+
+docker ps
+
+### Test memcached
+docker exec -it openstack_worker_1 sh
+
+cat <<EOF>testmemcached.py
+import memcache
+mem = memcache.Client(['memcached:11211'], debug=1)
+mem.set("testkey1","testvalue1")
+value1 = mem.get("testkey1")
+print("memcached is working" if value1=="testvalue1" else "memcached is not working")
+EOF
+
+python testmemcached.py
+
+exit
+
+docker-compose -f docker-compose-windriver.yml down
index 0f26f13..4815c3b 100644 (file)
@@ -24,7 +24,7 @@ USER root
 # COPY ./ /opt/windriver/
 COPY ./multicloud-openstack-windriver-*.zip /opt/multicloud-openstack-windriver.zip
 RUN apk update && \
-    apk add pcre pcre-dev uwsgi memcached wget unzip gcc make libc-dev libffi-dev openssl-dev && \
+    apk add pcre pcre-dev uwsgi wget unzip gcc make libc-dev libffi-dev openssl-dev && \
     cd /opt/ && \
     unzip -q -o -B multicloud-openstack-windriver.zip && \
     chmod +x /opt/windriver/*.sh && \
diff --git a/windriver/docker/Dockerfile4composer b/windriver/docker/Dockerfile4composer
new file mode 100644 (file)
index 0000000..5d0dfc3
--- /dev/null
@@ -0,0 +1,42 @@
+# FROM python:3.8-alpine
+FROM nexus3.onap.org:10001/onap/integration-python:9.1.0
+
+ARG HTTP_PROXY=${HTTP_PROXY}
+ARG HTTPS_PROXY=${HTTPS_PROXY}
+
+ENV http_proxy $HTTP_PROXY
+ENV https_proxy $HTTPS_PROXY
+
+ENV MSB_PROTO "http"
+ENV MSB_ADDR "127.0.0.1"
+ENV MSB_PORT "80"
+ENV AAI_ADDR "aai.api.simpledemo.openecomp.org"
+ENV AAI_PORT "8443"
+ENV AAI_SCHEMA_VERSION "v13"
+ENV AAI_USERNAME "AAI"
+ENV AAI_PASSWORD "AAI"
+
+EXPOSE 9005
+
+# RUN addgroup -S onap && adduser -S -G onap onap
+USER root
+
+COPY ./windriver /opt/windriver/
+COPY ./share /opt/windriver/lib/share
+# COPY ./ /opt/windriver/
+# COPY ./multicloud-openstack-windriver-*.zip /opt/multicloud-openstack-windriver.zip
+RUN apk update && \
+    apk add pcre pcre-dev uwsgi wget unzip gcc make libc-dev libffi-dev openssl-dev && \
+    cd /opt/ && \
+    chmod +x /opt/windriver/*.sh && \
+    pip3 install --no-cache-dir -r /opt/windriver/requirements.txt && \
+    pip3 install --no-cache-dir -r /opt/windriver/uwsgi-requirements.txt && \
+    apk del wget unzip gcc make libc-dev libffi-dev openssl-dev pcre-dev && \
+    mkdir -p /var/log/onap/multicloud/openstack/windriver && \
+    chown onap:onap /var/log/onap -R && \
+    chown onap:onap /opt/windriver -R
+
+USER onap
+
+WORKDIR /opt/windriver
+CMD /bin/sh -c /opt/windriver/run.sh
index c65ecdf..32a0a5b 100644 (file)
@@ -13,7 +13,8 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-memcached -d -m 2048 -c 1024 -p 11211 -P /tmp/memcached1.pid
+# memcached should be provided as sidecar to avoid GPLv3 license issue
+# memcached -d -m 2048 -c 1024 -p 11211 -P /tmp/memcached1.pid
 export PYTHONPATH=lib/share
 
 #nohup python manage.py runserver 0.0.0.0:9005 2>&1 &
index 882fb74..5570eef 100644 (file)
@@ -15,4 +15,4 @@
 
 #ps auxww | grep 'manage.py runserver 0.0.0.0:9005' | awk '{print $2}' | xargs kill -9
 ps auxww |grep 'uwsgi --http :9005 --module titanium_cloud.wsgi --master' |awk '{print $2}' |xargs kill -9
-ps auxww | grep 'memcached -d -m 2048 -c 1024 -p 11211 -P /tmp/memcached1.pid' | awk '{print $2}' | xargs kill -9
+ps auxww | grep 'memcached -d -m 2048 -c 1024 -p 11211 -P /tmp/memcached1.pid' | awk '{print $2}' | xargs kill -9
index 280980d..cb61b52 100644 (file)
@@ -1,31 +1,38 @@
+
 version: 1
 disable_existing_loggers: False
 
 loggers:
-    titanium_cloud:
-      handlers: [titanium_cloud_handler]
+    starlingx_base:
+      handlers: [console_handler, file_handler]
       level: "DEBUG"
       propagate: False
-    newton_base:
-      handlers: [titanium_cloud_handler]
+    starlingx:
+      handlers: [console_handler, file_handler]
       level: "DEBUG"
       propagate: False
-    common:
-      handlers: [titanium_cloud_handler]
+    newton_base:
+      handlers: [console_handler, file_handler]
       level: "DEBUG"
       propagate: False
-    starlingx_base:
-      handlers: [titanium_cloud_handler]
+    common:
+      handlers: [console_handler, file_handler]
       level: "DEBUG"
       propagate: False
+
 handlers:
-    titanium_cloud_handler:
+    console_handler:
+        level: "DEBUG"
+        class: "logging.StreamHandler"
+        formatter: "standard"
+    file_handler:
         level: "DEBUG"
         class: "logging.handlers.RotatingFileHandler"
         filename: "/var/log/onap/multicloud/openstack/windriver/titanium_cloud.log"
         formatter: "standard"
         maxBytes: 52428800
         backupCount: 10
+
 formatters:
     standard:
         format: "%(asctime)s|||||%(name)s||%(thread)||%(funcName)s||%(levelname)s||%(message)s"
index eee2f1d..8a4be61 100644 (file)
@@ -80,7 +80,10 @@ STATIC_URL = '/static/'
 
 DEFAULT_MSB_PROTO = "http"
 DEFAULT_MSB_ADDR = "127.0.0.1"
-DEFAULT_CACHE_BACKEND_LOCATION = '127.0.0.1:11211'
+# DEFAULT_CACHE_BACKEND_LOCATION = '127.0.0.1:11211'
+MEMCACHED_HOST = os.environ.get('MEMCACHED_HOST', '127.0.0.1')
+MEMCACHED_PORT = os.environ.get('MEMCACHED_PORT', '11211')
+DEFAULT_CACHE_BACKEND_LOCATION = "%s:%s" % (MEMCACHED_HOST, MEMCACHED_PORT)
 
 CACHES = {
     'default': {
@@ -89,6 +92,14 @@ CACHES = {
     }
 }
 
+# [RABBITMQ]
+RABBITMQ_DEFAULT_USER = os.environ.get('RABBITMQ_DEFAULT_USER', 'guest')
+RABBITMQ_DEFAULT_PASS = os.environ.get('RABBITMQ_DEFAULT_PASS', 'guest')
+RABBITMQ_HOST = os.environ.get('RABBITMQ_HOST', 'localhost')
+RABBITMQ_PORT = os.environ.get('RABBITMQ_PORT', '5672')
+RABBITMQ_URL = "amqp://%s:%s@%s:%s//" % (
+    RABBITMQ_DEFAULT_USER, RABBITMQ_DEFAULT_PASS, RABBITMQ_HOST, RABBITMQ_PORT)
+
 # [MSB]
 MSB_SERVICE_PROTOCOL = os.environ.get('MSB_PROTO', DEFAULT_MSB_PROTO)
 MSB_SERVICE_ADDR = os.environ.get('MSB_ADDR', DEFAULT_MSB_ADDR)