diff options
author | Bin Yang <bin.yang@windriver.com> | 2022-03-21 22:40:51 +0800 |
---|---|---|
committer | Bin Yang <bin.yang@windriver.com> | 2022-03-22 14:31:13 +0800 |
commit | de7df2bb51ecd068d3eae6cf314b20c744e96927 (patch) | |
tree | b55034272a7d683dba1a95c504c6594d970645d3 /fcaps | |
parent | 3bd3e44e2c9533b96f6f6664f9d6ed2150515955 (diff) |
memcached container as sidecar1.5.7
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
Diffstat (limited to 'fcaps')
-rw-r--r-- | fcaps/README.md | 25 | ||||
-rw-r--r-- | fcaps/docker/Dockerfile | 2 | ||||
-rw-r--r-- | fcaps/docker/Dockerfile4composer | 43 | ||||
-rw-r--r-- | fcaps/docker/docker-compose.yml | 31 | ||||
-rw-r--r-- | fcaps/fcaps/celery.py | 5 | ||||
-rw-r--r-- | fcaps/fcaps/settings.py | 15 | ||||
-rw-r--r-- | fcaps/run.sh | 5 | ||||
-rw-r--r-- | fcaps/stop.sh | 2 |
8 files changed, 89 insertions, 39 deletions
diff --git a/fcaps/README.md b/fcaps/README.md index 8005e176..b02e0d72 100644 --- a/fcaps/README.md +++ b/fcaps/README.md @@ -13,3 +13,28 @@ # 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 diff --git a/fcaps/docker/Dockerfile b/fcaps/docker/Dockerfile index 3de775a7..f25e28ac 100644 --- a/fcaps/docker/Dockerfile +++ b/fcaps/docker/Dockerfile @@ -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 index 00000000..0c5c1657 --- /dev/null +++ b/fcaps/docker/Dockerfile4composer @@ -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 diff --git a/fcaps/docker/docker-compose.yml b/fcaps/docker/docker-compose.yml deleted file mode 100644 index 5a9c2569..00000000 --- a/fcaps/docker/docker-compose.yml +++ /dev/null @@ -1,31 +0,0 @@ -# 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: - - "15672:15672" - - worker: - build: - context: . - dockerfile: Dockerfile - volumes: - - .:/fcaps diff --git a/fcaps/fcaps/celery.py b/fcaps/fcaps/celery.py index ca3b2e56..93ad6982 100644 --- a/fcaps/fcaps/celery.py +++ b/fcaps/fcaps/celery.py @@ -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. diff --git a/fcaps/fcaps/settings.py b/fcaps/fcaps/settings.py index 37021e05..5e663c61 100644 --- a/fcaps/fcaps/settings.py +++ b/fcaps/fcaps/settings.py @@ -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) diff --git a/fcaps/run.sh b/fcaps/run.sh index e8b82097..864644c5 100644 --- a/fcaps/run.sh +++ b/fcaps/run.sh @@ -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 - - diff --git a/fcaps/stop.sh b/fcaps/stop.sh index d608abed..88c30b10 100644 --- a/fcaps/stop.sh +++ b/fcaps/stop.sh @@ -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 |