| tierno | 63056c5 | 2018-11-14 12:46:21 +0100 | [diff] [blame] | 1 | # 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 | |
| garciadeblas | cf92004 | 2017-09-14 16:17:39 +0200 | [diff] [blame] | 16 | .PHONY: all test clean |
| 17 | |
| garciadeblas | 9453a8a | 2017-03-09 16:21:24 +0100 | [diff] [blame] | 18 | SHELL := /bin/bash |
| garciadeblas | 9453a8a | 2017-03-09 16:21:24 +0100 | [diff] [blame] | 19 | |
| garciadeblas | cf92004 | 2017-09-14 16:17:39 +0200 | [diff] [blame] | 20 | BRANCH ?= master |
| garciadeblas | d40e551 | 2017-04-21 15:09:26 +0200 | [diff] [blame] | 21 | |
| tierno | 63056c5 | 2018-11-14 12:46:21 +0100 | [diff] [blame] | 22 | all: # lib-openvim # osm-im |
| garciadeblas | cf92004 | 2017-09-14 16:17:39 +0200 | [diff] [blame] | 23 | $(MAKE) clean_build build |
| 24 | $(MAKE) clean_build package |
| 25 | |
| 26 | clean: clean_build |
| 27 | rm -rf .build openvim IM |
| 28 | |
| 29 | clean_build: |
| garciadeblas | d40e551 | 2017-04-21 15:09:26 +0200 | [diff] [blame] | 30 | rm -rf build |
| 31 | find osm_ro -name '*.pyc' -delete |
| 32 | find osm_ro -name '*.pyo' -delete |
| garciadeblas | cf92004 | 2017-09-14 16:17:39 +0200 | [diff] [blame] | 33 | |
| garciadeblas | 9453a8a | 2017-03-09 16:21:24 +0100 | [diff] [blame] | 34 | prepare: |
| garciadeblas | cf92004 | 2017-09-14 16:17:39 +0200 | [diff] [blame] | 35 | # ip install --user --upgrade setuptools |
| garciadeblas | 2c290ca | 2017-04-06 03:12:51 +0200 | [diff] [blame] | 36 | mkdir -p build/ |
| garciadeblas | cf92004 | 2017-09-14 16:17:39 +0200 | [diff] [blame] | 37 | # 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/ |
| garciadeblas | 2c290ca | 2017-04-06 03:12:51 +0200 | [diff] [blame] | 42 | cp MANIFEST.in build/ |
| garciadeblas | 06e6c39 | 2017-03-28 15:42:20 +0200 | [diff] [blame] | 43 | cp requirements.txt build/ |
| 44 | cp README.rst build/ |
| garciadeblas | 2c290ca | 2017-04-06 03:12:51 +0200 | [diff] [blame] | 45 | cp setup.py build/ |
| garciadeblas | e5ef517 | 2017-04-20 14:46:29 +0200 | [diff] [blame] | 46 | cp stdeb.cfg build/ |
| garciadeblas | 2c290ca | 2017-04-06 03:12:51 +0200 | [diff] [blame] | 47 | cp -r osm_ro build/ |
| 48 | cp openmano build/ |
| garciadeblas | cf1826b | 2017-04-18 10:03:17 +0200 | [diff] [blame] | 49 | cp openmanod build/ |
| garciadeblas | 2c290ca | 2017-04-06 03:12:51 +0200 | [diff] [blame] | 50 | 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 |
| garciadeblas | 8285539 | 2017-09-20 17:34:16 +0200 | [diff] [blame] | 55 | cp LICENSE build/osm_ro |
| garciadeblas | 9453a8a | 2017-03-09 16:21:24 +0100 | [diff] [blame] | 56 | |
| garciadeblas | 06e6c39 | 2017-03-28 15:42:20 +0200 | [diff] [blame] | 57 | connectors: prepare |
| 58 | # python-novaclient is required for that |
| garciadeblas | 2c290ca | 2017-04-06 03:12:51 +0200 | [diff] [blame] | 59 | 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 |
| tierno | 3cb8dc3 | 2017-10-24 18:13:19 +0200 | [diff] [blame] | 61 | python build/osm_ro/openmanolinkervimconn.py 2>&1 |
| garciadeblas | 2c290ca | 2017-04-06 03:12:51 +0200 | [diff] [blame] | 62 | rm -f build/osm_ro/openmanolinkervimconn.py |
| garciadeblas | 9453a8a | 2017-03-09 16:21:24 +0100 | [diff] [blame] | 63 | |
| garciadeblas | cf92004 | 2017-09-14 16:17:39 +0200 | [diff] [blame] | 64 | build: connectors prepare |
| garciadeblas | 2c290ca | 2017-04-06 03:12:51 +0200 | [diff] [blame] | 65 | python -m py_compile build/osm_ro/*.py |
| garciadeblas | cf92004 | 2017-09-14 16:17:39 +0200 | [diff] [blame] | 66 | # cd build && tox -e flake8 |
| garciadeblas | 9453a8a | 2017-03-09 16:21:24 +0100 | [diff] [blame] | 67 | |
| garciadeblas | cf92004 | 2017-09-14 16:17:39 +0200 | [diff] [blame] | 68 | lib-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 |
| garciadeblas | 06e6c39 | 2017-03-28 15:42:20 +0200 | [diff] [blame] | 76 | |
| garciadeblas | cf92004 | 2017-09-14 16:17:39 +0200 | [diff] [blame] | 77 | osm-im: |
| 78 | $(shell git clone https://osm.etsi.org/gerrit/osm/IM) |
| 79 | make -C IM clean all |
| 80 | |
| 81 | package: prepare |
| 82 | # apt-get install -y python-stdeb |
| garciadeblas | e5ef517 | 2017-04-20 14:46:29 +0200 | [diff] [blame] | 83 | 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 |
| garciadeblas | d40e551 | 2017-04-21 15:09:26 +0200 | [diff] [blame] | 86 | mkdir -p .build |
| garciadeblas | a64b262 | 2017-04-24 11:50:03 +0200 | [diff] [blame] | 87 | cp build/deb_dist/python-*.deb .build/ |
| garciadeblas | 06e6c39 | 2017-03-28 15:42:20 +0200 | [diff] [blame] | 88 | |
| garciadeblas | cf1826b | 2017-04-18 10:03:17 +0200 | [diff] [blame] | 89 | snap: |
| garciadeblas | 06e6c39 | 2017-03-28 15:42:20 +0200 | [diff] [blame] | 90 | echo "Nothing to be done yet" |
| 91 | |
| tierno | 63056c5 | 2018-11-14 12:46:21 +0100 | [diff] [blame] | 92 | install: lib-openvim osm-im |
| garciadeblas | cf92004 | 2017-09-14 16:17:39 +0200 | [diff] [blame] | 93 | 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 |
| garciadeblas | cf1826b | 2017-04-18 10:03:17 +0200 | [diff] [blame] | 102 | |
| 103 | develop: prepare |
| garciadeblas | cf92004 | 2017-09-14 16:17:39 +0200 | [diff] [blame] | 104 | # pip install -r requirements.txt |
| garciadeblas | cf1826b | 2017-04-18 10:03:17 +0200 | [diff] [blame] | 105 | cd build && ./setup.py develop |
| 106 | |
| garciadeblas | 06e6c39 | 2017-03-28 15:42:20 +0200 | [diff] [blame] | 107 | test: |
| garciadeblas | cf92004 | 2017-09-14 16:17:39 +0200 | [diff] [blame] | 108 | . ./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 |
| garciadeblas | 06e6c39 | 2017-03-28 15:42:20 +0200 | [diff] [blame] | 112 | |
| Gennadiy Dubina | 311ea74 | 2017-04-03 20:46:16 +0300 | [diff] [blame] | 113 | build-docker-from-source: |
| 114 | docker build -t osm/openmano -f docker/Dockerfile-local . |
| 115 | |
| 116 | run-docker: |
| 117 | docker-compose -f docker/openmano-compose.yml up |
| 118 | |
| 119 | stop-docker: |
| 120 | docker-compose -f docker/openmano-compose.yml down |
| 121 | |
| garciadeblas | 9453a8a | 2017-03-09 16:21:24 +0100 | [diff] [blame] | 122 | |