blob: 33deb4e96b10c768cf4c6b5680defca488195961 [file] [log] [blame]
tierno59bc1ce2018-11-13 15:06:45 +00001# Copyright 2018 Telefonica S.A.
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
12# implied.
13# See the License for the specific language governing permissions and
14# limitations under the License.
15
garciadeblascf920042017-09-14 16:17:39 +020016.PHONY: all test clean
17
garciadeblas9453a8a2017-03-09 16:21:24 +010018SHELL := /bin/bash
garciadeblas9453a8a2017-03-09 16:21:24 +010019
garciadeblascf920042017-09-14 16:17:39 +020020BRANCH ?= master
garciadeblasd40e5512017-04-21 15:09:26 +020021
tierno59bc1ce2018-11-13 15:06:45 +000022all: # lib-openvim # osm-im
garciadeblascf920042017-09-14 16:17:39 +020023 $(MAKE) clean_build build
24 $(MAKE) clean_build package
25
26clean: clean_build
27 rm -rf .build openvim IM
28
29clean_build:
garciadeblasd40e5512017-04-21 15:09:26 +020030 rm -rf build
31 find osm_ro -name '*.pyc' -delete
32 find osm_ro -name '*.pyo' -delete
garciadeblascf920042017-09-14 16:17:39 +020033
garciadeblas9453a8a2017-03-09 16:21:24 +010034prepare:
garciadeblascf920042017-09-14 16:17:39 +020035# ip install --user --upgrade setuptools
garciadeblas2c290ca2017-04-06 03:12:51 +020036 mkdir -p build/
garciadeblascf920042017-09-14 16:17:39 +020037# VER1=$(shell git describe | sed -e 's/^v//' |cut -d- -f1); \
38# VER2=$(shell git describe | cut -d- -f2); \
39# VER3=$(shell git describe | cut -d- -f3); \
40# echo "$$VER1.dev$$VER2+$$VER3" > build/RO_VERSION
41 cp tox.ini build/
garciadeblas2c290ca2017-04-06 03:12:51 +020042 cp MANIFEST.in build/
garciadeblas06e6c392017-03-28 15:42:20 +020043 cp requirements.txt build/
44 cp README.rst build/
garciadeblas2c290ca2017-04-06 03:12:51 +020045 cp setup.py build/
garciadeblase5ef5172017-04-20 14:46:29 +020046 cp stdeb.cfg build/
garciadeblas2c290ca2017-04-06 03:12:51 +020047 cp -r osm_ro build/
48 cp openmano build/
garciadeblascf1826b2017-04-18 10:03:17 +020049 cp openmanod build/
garciadeblas2c290ca2017-04-06 03:12:51 +020050 cp -r vnfs build/osm_ro
51 cp -r scenarios build/osm_ro
52 cp -r instance-scenarios build/osm_ro
53 cp -r scripts build/osm_ro
54 cp -r database_utils build/osm_ro
garciadeblas82855392017-09-20 17:34:16 +020055 cp LICENSE build/osm_ro
garciadeblas9453a8a2017-03-09 16:21:24 +010056
garciadeblas06e6c392017-03-28 15:42:20 +020057connectors: prepare
58 # python-novaclient is required for that
garciadeblas2c290ca2017-04-06 03:12:51 +020059 rm -f build/osm_ro/openmanolinkervimconn.py
60 cd build/osm_ro; for i in `ls vimconn_*.py |sed "s/\.py//"` ; do echo "import $$i" >> openmanolinkervimconn.py; done
tierno3cb8dc32017-10-24 18:13:19 +020061 python build/osm_ro/openmanolinkervimconn.py 2>&1
garciadeblas2c290ca2017-04-06 03:12:51 +020062 rm -f build/osm_ro/openmanolinkervimconn.py
garciadeblas9453a8a2017-03-09 16:21:24 +010063
garciadeblascf920042017-09-14 16:17:39 +020064build: connectors prepare
garciadeblas2c290ca2017-04-06 03:12:51 +020065 python -m py_compile build/osm_ro/*.py
garciadeblascf920042017-09-14 16:17:39 +020066# cd build && tox -e flake8
garciadeblas9453a8a2017-03-09 16:21:24 +010067
garciadeblascf920042017-09-14 16:17:39 +020068lib-openvim:
69 $(shell git clone https://osm.etsi.org/gerrit/osm/openvim)
70 LIB_BRANCH=$(shell git -C openvim branch -a|grep -oP 'remotes/origin/\K$(BRANCH)'); \
71 [ -z "$$LIB_BRANCH" ] && LIB_BRANCH='master'; \
72 echo "BRANCH: $(BRANCH)"; \
73 echo "LIB_OPENVIM_BRANCH: $$LIB_BRANCH"; \
74 git -C openvim checkout $$LIB_BRANCH
75 make -C openvim clean lite
garciadeblas06e6c392017-03-28 15:42:20 +020076
garciadeblascf920042017-09-14 16:17:39 +020077osm-im:
78 $(shell git clone https://osm.etsi.org/gerrit/osm/IM)
79 make -C IM clean all
80
81package: prepare
82# apt-get install -y python-stdeb
garciadeblase5ef5172017-04-20 14:46:29 +020083 cd build && python setup.py --command-packages=stdeb.command sdist_dsc --with-python2=True
84 cd build && cp osm_ro/scripts/python-osm-ro.postinst deb_dist/osm-ro*/debian/
85 cd build/deb_dist/osm-ro* && dpkg-buildpackage -rfakeroot -uc -us
garciadeblasd40e5512017-04-21 15:09:26 +020086 mkdir -p .build
garciadeblasa64b2622017-04-24 11:50:03 +020087 cp build/deb_dist/python-*.deb .build/
garciadeblas06e6c392017-03-28 15:42:20 +020088
garciadeblascf1826b2017-04-18 10:03:17 +020089snap:
garciadeblas06e6c392017-03-28 15:42:20 +020090 echo "Nothing to be done yet"
91
tierno59bc1ce2018-11-13 15:06:45 +000092install: lib-openvim osm-im
garciadeblascf920042017-09-14 16:17:39 +020093 dpkg -i IM/deb_dist/python-osm-im*.deb
94 dpkg -i openvim/.build/python-lib-osm-openvim*.deb
95 dpkg -i .build/python-osm-ro*.deb
96 cd .. && \
97 OSMLIBOVIM_PATH=`python -c 'import lib_osm_openvim; print lib_osm_openvim.__path__[0]'` || FATAL "lib-osm-openvim was not properly installed" && \
98 OSMRO_PATH=`python -c 'import osm_ro; print osm_ro.__path__[0]'` || FATAL "osm-ro was not properly installed" && \
99 USER=root DEBIAN_FRONTEND=noninteractive $$OSMRO_PATH/database_utils/install-db-server.sh --updatedb || FATAL "osm-ro db installation failed" && \
100 USER=root DEBIAN_FRONTEND=noninteractive $$OSMLIBOVIM_PATH/database_utils/install-db-server.sh -u mano -p manopw -d mano_vim_db --updatedb || FATAL "lib-osm-openvim db installation failed"
101 service osm-ro restart
garciadeblascf1826b2017-04-18 10:03:17 +0200102
103develop: prepare
garciadeblascf920042017-09-14 16:17:39 +0200104# pip install -r requirements.txt
garciadeblascf1826b2017-04-18 10:03:17 +0200105 cd build && ./setup.py develop
106
garciadeblas06e6c392017-03-28 15:42:20 +0200107test:
garciadeblascf920042017-09-14 16:17:39 +0200108 . ./test/basictest.sh -f --insert-bashrc --install-openvim --init-openvim
109 . ./test/basictest.sh -f reset add-openvim
110 ./test/test_RO.py deploy -n mgmt -t osm -i cirros034 -d local-openvim --timeout=30 --failfast
111 ./test/test_RO.py vim -t osm -d local-openvim --timeout=30 --failfast
garciadeblas06e6c392017-03-28 15:42:20 +0200112
Gennadiy Dubina311ea742017-04-03 20:46:16 +0300113build-docker-from-source:
114 docker build -t osm/openmano -f docker/Dockerfile-local .
115
116run-docker:
117 docker-compose -f docker/openmano-compose.yml up
118
119stop-docker:
120 docker-compose -f docker/openmano-compose.yml down
121
garciadeblas9453a8a2017-03-09 16:21:24 +0100122