From: Eduardo Sousa Date: Fri, 21 Sep 2018 10:37:49 +0000 (+0100) Subject: Adding Keystone environment variables to NBI X-Git-Tag: v5.0.0~95^2 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=e193dfd4b1e2f8c530eaf9be6423942a68aec07e;p=osm%2Fdevops.git Adding Keystone environment variables to NBI Adding the necessary environment variables to the NBI MDG Dockerfile in order for the Keystone authentication to work. Completing the docker-compose yaml, fixing renaming typo in keystone dockerfile and updating environment file creation. Change-Id: I4eb15119f4dba304494ef16fc90eea8d8c230927 Signed-off-by: Eduardo Sousa --- diff --git a/docker/Keystone/Dockerfile b/docker/Keystone/Dockerfile index 571e8873..91635626 100644 --- a/docker/Keystone/Dockerfile +++ b/docker/Keystone/Dockerfile @@ -42,4 +42,4 @@ ENV ADMIN_PASSWORD admin # NBI password ENV NBI_PASSWORD nbi -ENTRYPOINT ./install.sh \ No newline at end of file +ENTRYPOINT ./start.sh \ No newline at end of file diff --git a/docker/Keystone/scripts/start.sh b/docker/Keystone/scripts/start.sh index 15303873..4d95c609 100755 --- a/docker/Keystone/scripts/start.sh +++ b/docker/Keystone/scripts/start.sh @@ -37,8 +37,6 @@ function is_db_created() { fi } -KEYSTONE_IP=`ifconfig eth0 | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*'` - wait_db "$DB_HOST" "$DB_PORT" || exit 1 is_db_created "$DB_HOST" "$DB_PORT" "$ROOT_DB_USER" "$ROOT_DB_PASSWORD" "keystone" && DB_EXISTS="Y" @@ -67,19 +65,32 @@ keystone-manage credential_setup --keystone-user keystone --keystone-group keyst # Bootstrap Keystone service if [ -z $DB_EXISTS ]; then keystone-manage bootstrap --bootstrap-password "$ADMIN_PASSWORD" \ - --bootstrap-admin-url http://"$KEYSTONE_IP":5000/v3/ \ - --bootstrap-internal-url http://"$KEYSTONE_IP":5000/v3/ \ - --bootstrap-public-url http://"$KEYSTONE_IP":5000/v3/ \ + --bootstrap-admin-url http://keystone:5000/v3/ \ + --bootstrap-internal-url http://keystone:5000/v3/ \ + --bootstrap-public-url http://keystone:5000/v3/ \ --bootstrap-region-id RegionOne fi # Restart Apache Service service apache2 restart +cat << EOF >> setup_env +export OS_PROJECT_DOMAIN_NAME=default +export OS_USER_DOMAIN_NAME=default +export OS_PROJECT_NAME=admin +export OS_USERNAME=admin +export OS_PASSWORD=$ADMIN_PASSWORD +export OS_AUTH_URL=http://keystone:5000/v3 +export OS_IDENTITY_API_VERSION=3 +export OS_IMAGE_API_VERSION=2 +EOF + +source setup_env + # Create NBI User if [ -z $DB_EXISTS ]; then openstack user create --domain default --password "$NBI_PASSWORD" nbi - openstack project create --domain defaul --description "Service Project" service + openstack project create --domain default --description "Service Project" service openstack role add --project service --user nbi admin fi diff --git a/docker/NBI/Dockerfile b/docker/NBI/Dockerfile index 0531f3af..d2d0c361 100644 --- a/docker/NBI/Dockerfile +++ b/docker/NBI/Dockerfile @@ -5,9 +5,9 @@ FROM ubuntu:16.04 RUN apt-get update && apt-get -y install curl software-properties-common RUN apt-get update && apt-get install -y git python3 python3-jsonschema \ - python3-pymongo python3-yaml python3-pip \ + python3-pymongo python3-yaml python3-pip python3-keystoneclient \ && pip3 install pip==9.0.3 \ - && pip3 install aiokafka cherrypy pyangbind \ + && pip3 install aiokafka cherrypy==18.0.0 pyangbind keystoneauth1 \ && mkdir -p /app/storage/kafka && mkdir -p /app/log ARG REPOSITORY_BASE=http://osm-download.etsi.org/repository/osm/debian @@ -65,6 +65,16 @@ ENV OSMNBI_MESSAGE_PORT 9092 # logs ENV OSMNBI_LOG_FILE /app/log/nbi.log ENV OSMNBI_LOG_LEVEL DEBUG +# authentication +ENV OSMNBI_AUTHENTICATION_BACKEND internal +#ENV OSMNBI_AUTHENTICATION_BACKEND keystone +#ENV OSMNBI_AUTHENTICATION_AUTH_URL keystone +#ENV OSMNBI_AUTHENTICATION_AUTH_PORT 5000 +#ENV OSMNBI_AUTHENTICATION_USER_DOMAIN_NAME default +#ENV OSMNBI_AUTHENTICATION_PROJECT_DOMAIN_NAME default +#ENV OSMNBI_AUTHENTICATION_SERVICE_USERNAME nbi +#ENV OSMNBI_AUTHENTICATION_SERVICE_PASSWORD nbi +#ENV OSMNBI_AUTHENTICATION_SERVICE_PROJECT service HEALTHCHECK --interval=5s --timeout=2s --retries=12 \ CMD curl -k https://localhost:9999/osm/ | grep Welcome || exit 1 diff --git a/docker/mk/Makefile.include b/docker/mk/Makefile.include index 81529f34..54ef41a0 100644 --- a/docker/mk/Makefile.include +++ b/docker/mk/Makefile.include @@ -17,7 +17,7 @@ LOWER_MDG = $(shell echo $(MDG) | tr '[:upper:]' '[:lower:]') CMD_DOCKER_ARGS ?= -q DOCKER_ARGS = $(CMD_DOCKER_ARGS) -DEPS := MON IM LCM RO common osmclient devops NBI POL +DEPS := MON IM LCM RO common osmclient devops NBI POL Keystone DEPS_TARGETS = $(addprefix $(MKBUILD)/.dep_, $(DEPS)) diff --git a/installers/docker/__nbi__.env b/installers/docker/__nbi__.env new file mode 100644 index 00000000..34671e12 --- /dev/null +++ b/installers/docker/__nbi__.env @@ -0,0 +1 @@ +OSMNBI_AUTHENTICATION_SERVICE_PASSWORD=__NBI_PASSWORD__ \ No newline at end of file diff --git a/installers/docker/docker-compose.yaml b/installers/docker/docker-compose.yaml index 3917c9ee..38d322da 100644 --- a/installers/docker/docker-compose.yaml +++ b/installers/docker/docker-compose.yaml @@ -75,6 +75,8 @@ services: environment: OSMNBI_DATABASE_HOST: mongo OSMNBI_MESSAGE_HOST: kafka + env_file: + - ./nbi.env ports: - "${OSM_NBI_PORTS:-9999:9999}" #depends_on: diff --git a/installers/full_install_osm.sh b/installers/full_install_osm.sh index 02ed4278..66cb8484 100755 --- a/installers/full_install_osm.sh +++ b/installers/full_install_osm.sh @@ -726,9 +726,13 @@ function generate_docker_env_files() { fi if [ ! -f $OSM_DOCKER_WORK_DIR/keystone.env ]; then echo "ROOT_DB_PASSWORD=${MYSQL_ROOT_PASSWORD}" |$WORKDIR_SUDO tee $OSM_DOCKER_WORK_DIR/keystone.env - echo "KEYSTONE_DB_PASSWORD=${KEYSTONE_DB_PASSWORD}" |$WORKDIR_SUDO tee $OSM_DOCKER_WORK_DIR/keystone.env - #echo "ADMIN_PASSWORD=${ADMIN_PASSWORD}" |$WORKDIR_SUDO tee $OSM_DOCKER_WORK_DIR/keystone.env - echo "NBI_PASSWORD=${NBI_PASSWORD}" |$WORKDIR_SUDO tee $OSM_DOCKER_WORK_DIR/keystone.env + echo "KEYSTONE_DB_PASSWORD=${KEYSTONE_DB_PASSWORD}" |$WORKDIR_SUDO tee -a $OSM_DOCKER_WORK_DIR/keystone.env + #echo "ADMIN_PASSWORD=${ADMIN_PASSWORD}" |$WORKDIR_SUDO tee -a $OSM_DOCKER_WORK_DIR/keystone.env + echo "NBI_PASSWORD=${NBI_PASSWORD}" |$WORKDIR_SUDO tee -a $OSM_DOCKER_WORK_DIR/keystone.env + fi + + if [ ! -f $OSM_DOCKER_WORK_DIR/nbi.env ]; then + echo "OSMNBI_AUTHENTICATION_SERVICE_PASSWORD=${NBI_PASSWORD}" |$WORKDIR_SUDO tee $OSM_DOCKER_WORK_DIR/nbi.env fi echo "OS_NOTIFIER_URI=http://${DEFAULT_IP}:8662" |$WORKDIR_SUDO tee $OSM_DOCKER_WORK_DIR/mon.env