all: pip deb
prepare:
+ pip install setuptools
+ #pip install -r requirements.txt
mkdir -p build/
cp MANIFEST.in build/
cp requirements.txt build/
test:
./test/basictest.sh --force --insert-bashrc --install-openvim --init-openvim
+build-docker-from-source:
+ docker build -t osm/openmano -f docker/Dockerfile-local .
+
+run-docker:
+ docker-compose -f docker/openmano-compose.yml up
+
+stop-docker:
+ docker-compose -f docker/openmano-compose.yml down
+
clean:
rm -rf build
#find build -name '*.pyc' -delete
--- /dev/null
+from ubuntu:xenial
+
+MAINTAINER Gennadiy Dubina <gennadiy.dubina@dataat.com>
+
+# script uses it
+ENV USER=root
+
+#avoid extra information from packages
+RUN echo 'path-exclude /usr/share/doc/*\n\
+path-include /usr/share/doc/*/copyright\n\
+path-exclude /usr/share/man/*\n\
+path-exclude /usr/share/groff/*\n\
+path-exclude /usr/share/info/*\n\
+path-exclude /usr/share/lintian/*\n\
+path-exclude /usr/share/linda/*\n'\
+> /etc/dpkg/dpkg.cfg.d/01_nodoc && \
+ echo 'APT::Install-Recommends "false";\n\
+APT::AutoRemove::RecommendsImportant "false";\n\
+APT::AutoRemove::SuggestsImportant "false";\n'\
+> /etc/apt/apt.conf.d/99_norecommends
+
+#generate lsb_release stub
+RUN echo 'if [ "$1" == "-is" ]; then echo "Ubuntu"; else if [ "$1" == "-rs" ]; then echo "16.04"; fi fi' > /usr/bin/lsb_release && chmod +x /usr/bin/lsb_release
+
+COPY . /usr/local/src/openmano
+
+RUN apt update && \
+ DEBIAN_FRONTEND=noninteractive apt install -fqy software-properties-common make gcc git python python-dev python-pip sudo wget && \
+ pip install --upgrade pip && \
+ cd /usr/local/src/openmano && \
+ make build && \
+ cd build && \
+ ./scripts/install-openmano.sh -q --noclone --no-db && \
+ cd / && \
+ rm -rf /usr/local/src/openmano && \
+ rm -rf /usr/include/* && \
+ rm -rf /root/.cache && \
+ apt purge -y make gcc git curl wget python-dev python-pip && \
+ apt autoremove -y && \
+ apt clean && \
+ rm -rf /var/lib/apt/lists/*
+
+COPY docker/scripts/ /opt/openmano-docker
+
+VOLUME /opt/openmano/logs
+EXPOSE 9090
+
+env DB_USER='' DB_PSWD='' DB_HOST='' DB_PORT=3306 DB_NAME=mano_db
+
+CMD /opt/openmano-docker/start.sh
--- /dev/null
+version: '2'
+services:
+ osm-ro-db:
+ image: mysql
+ container_name: osm-ro-db
+ restart: always
+ environment:
+ - MYSQL_RANDOM_ROOT_PASSWORD=true
+ - MYSQL_DATABASE=mano_db
+ - MYSQL_USER=mano
+ - MYSQL_PASSWORD=manopw
+ osm-ro:
+ build:
+ context: ../
+ dockerfile: docker/Dockerfile-local
+ image: osm/openmano
+ container_name: osm-ro
+ restart: always
+ environment:
+ - DB_USER=mano
+ - DB_PSWD=manopw
+ - DB_NAME=mano_db
+ - DB_HOST=osm-ro-db
+ ports:
+ - "9090:9090"
+ volumes:
+ - /var/log/osm/openmano/logs:/opt/openmano/logs
+ depends_on:
+ - osm-ro-db
+ links:
+ - osm-ro-db
\ No newline at end of file
--- /dev/null
+#!/bin/bash
+
+#Database parameters
+#db_host: localhost
+#db_user: mano
+#db_passwd: manopw
+#db_name: mano_db
+
+sed -i "s/^db_host:.*/db_host: $DB_HOST/" /opt/openmano/openmanod.cfg
+sed -i "s/^db_user:.*/db_user: $DB_USER/" /opt/openmano/openmanod.cfg
+sed -i "s/^db_passwd:.*/db_passwd: $DB_PSWD/" /opt/openmano/openmanod.cfg
+sed -i "s/^db_name:.*/db_name: $DB_NAME/" /opt/openmano/openmanod.cfg
\ No newline at end of file
--- /dev/null
+#!/bin/bash
+
+function is_db_created() {
+ db_host=$1
+ db_port=$2
+ db_user=$3
+ db_pswd=$4
+ db_name=$5
+
+ RESULT=`mysqlshow -h"$db_host" -P"$db_port" -u"$db_user" -p"$db_pswd" | grep -v Wildcard | grep -o $db_name`
+ if [ "$RESULT" == "$db_name" ]; then
+
+ RESULT=`mysqlshow -h"$db_host" -P"$db_port" -u"$db_user" -p"$db_pswd" "$db_name" | grep -v Wildcard | grep schema_version`
+ #TODO validate version
+ if [ -n "$RESULT" ]; then
+ echo " DB $db_name exists and inited"
+ return 0
+ else
+ echo " DB $db_name exists BUT not inited"
+ return 1
+ fi
+ fi
+ echo " DB $db_name does not exist"
+ return 1
+}
+
+echo "1/4 Apply config"
+/opt/openmano-docker/configure.sh
+[ $? -ne 0 ] && exit 1
+echo "2/4 Wait for db"
+
+/opt/openmano-docker/wait_db.sh
+[ $? -ne 0 ] && exit 1
+
+echo "3/4 Init database" && \
+is_db_created "$DB_HOST" "$DB_PORT" "$DB_USER" "$DB_PSWD" "$DB_NAME"
+if [ $? -ne 0 ]; then
+ /opt/openmano/database_utils/init_mano_db.sh -u $DB_USER -p $DB_PSWD -h $DB_HOST -P $DB_PORT -d $DB_NAME
+ [ $? -ne 0 ] && exit 1
+else
+ echo " migrage database version"
+ /opt/openmano/database_utils/migrate_mano_db.sh -u $DB_USER -p $DB_PSWD -h $DB_HOST -P $DB_PORT -d $DB_NAME
+fi
+
+echo "4/4 Try to start"
+/opt/openmano/openmanod.py -c /opt/openmano/openmanod.cfg --log-file=/opt/openmano/logs/openmano.log
\ No newline at end of file
--- /dev/null
+#!/bin/bash
+
+attempt=0
+max_attempts=120
+while ! mysqladmin ping -h"$DB_HOST" -P"$DB_PORT" --silent; do
+ #wait 120 sec
+ if [ $attempt -ge $max_attempts ]; then
+ echo "Can not connect to database during $max_attempts sec"
+ exit 1
+ fi
+ attempt=$[$attempt+1]
+ echo "Wait for MySQL Server ${DB_HOST}:${DB_PORT} [attempt $attempt/$max_attempts]"
+ sleep 1
+done
\ No newline at end of file
---index-url https://pypi.python.org/simple/
-
PyYAML
bottle
MySQL-python