blob: ab9550a2ca62e54f856c4064e557811d5075e4b3 [file] [log] [blame]
Mike Marchetti94b645e2017-08-04 14:33:54 -04001# Copyright 2017 Sandvine
garciadeblase6ba40a2018-09-27 18:07:38 +02002# Copyright 2017-2018 Telefonica
Mike Marchetti94b645e2017-08-04 14:33:54 -04003# All Rights Reserved.
4#
5# Licensed under the Apache License, Version 2.0 (the "License"); you may
6# not use this file except in compliance with the License. You may obtain
7# a copy of the License at
8#
9# http://www.apache.org/licenses/LICENSE-2.0
10#
11# Unless required by applicable law or agreed to in writing, software
12# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
13# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
14# License for the specific language governing permissions and limitations
15# under the License.
16
17# NOTE: pyang and pyangbind are required for build
18
garciadeblas878dee42018-10-28 16:12:42 +010019.PHONY: all clean package trees deps yang-ietf openapi_schemas yang2swagger
garciadeblasd6e6ffb2019-04-09 15:12:05 +020020JAVA:=/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
Mike Marchetti94b645e2017-08-04 14:33:54 -040021PYANG:= pyang
Mike Marchettice4a73d2018-08-29 15:40:41 -040022PYBINDPLUGIN:=$(shell /usr/bin/env python3 -c \
23 'import pyangbind; import os; print("{}/plugin".format(os.path.dirname(pyangbind.__file__)))')
Mike Marchetti94b645e2017-08-04 14:33:54 -040024
jdelacruz27797532018-09-18 19:16:16 +020025YANG_DESC_MODELS := vnfd nsd nst nsi
garciadeblase4eafa82017-11-29 17:34:36 +010026YANG_RECORD_MODELS := vnfr nsr
27PYTHON_MODELS := $(addsuffix .py, $(YANG_DESC_MODELS))
garciadeblase4eafa82017-11-29 17:34:36 +010028YANG_DESC_TREES := $(addsuffix .tree.txt, $(YANG_DESC_MODELS))
29YANG_DESC_JSTREES := $(addsuffix .html, $(YANG_DESC_MODELS))
30YANG_RECORD_TREES := $(addsuffix .rec.tree.txt, $(YANG_RECORD_MODELS))
31YANG_RECORD_JSTREES := $(addsuffix .rec.html, $(YANG_RECORD_MODELS))
garciadeblas878dee42018-10-28 16:12:42 +010032OPENAPI_SCHEMAS := osm.yaml
Mike Marchetti94b645e2017-08-04 14:33:54 -040033
Tomás Villaseca1be3d082019-12-04 12:54:34 -030034SOL006_YANG_DESC_MODELS := etsi-nfv-vnfd etsi-nfv-nsd
35SOL006_PYTHON_MODELS := $(addsuffix .py, $(SOL006_YANG_DESC_MODELS))
36SOL006_YANG_DESC_TREES := $(addsuffix .tree.txt, $(SOL006_YANG_DESC_MODELS))
37SOL006_YANG_DESC_JSTREES := $(addsuffix .html, $(SOL006_YANG_DESC_MODELS))
38
Mike Marchetti94b645e2017-08-04 14:33:54 -040039OUT_DIR := osm_im
garciadeblase4eafa82017-11-29 17:34:36 +010040TREES_DIR := osm_im_trees
Mike Marchetti94b645e2017-08-04 14:33:54 -040041MODEL_DIR := models/yang
Tomás Villaseca1be3d082019-12-04 12:54:34 -030042SOL006_MODEL_DIR := sol006_model/src/yang
43
Mike Marchetti94b645e2017-08-04 14:33:54 -040044Q?=@
45
garciadeblas5a20e9b2017-08-29 12:25:24 +020046PYANG_OPTIONS := -Werror
Mike Marchetti94b645e2017-08-04 14:33:54 -040047
Tomás Villaseca1be3d082019-12-04 12:54:34 -030048all: sol006_deps $(PYTHON_MODELS) $(SOL006_PYTHON_MODELS) trees openapi_schemas
Mike Marchetti94b645e2017-08-04 14:33:54 -040049 $(MAKE) package
50
Tomás Villaseca1be3d082019-12-04 12:54:34 -030051trees: $(YANG_DESC_TREES) $(YANG_DESC_JSTREES) $(SOL006_YANG_DESC_TREES) $(SOL006_YANG_DESC_JSTREES)
garciadeblase4eafa82017-11-29 17:34:36 +010052
garciadeblas878dee42018-10-28 16:12:42 +010053openapi_schemas: $(OPENAPI_SCHEMAS)
54
garciadeblase4eafa82017-11-29 17:34:36 +010055$(TREES_DIR):
56 $(Q)mkdir -p $(TREES_DIR)
57
garciadeblas361145b2019-10-28 11:11:48 +010058%.py: yang-ietf
Mike Marchetti94b645e2017-08-04 14:33:54 -040059 $(Q)echo generating $@ from $*.yang
Tomás Villaseca1be3d082019-12-04 12:54:34 -030060 $(if $(findstring etsi,$@), $(eval DIR=$(SOL006_MODEL_DIR)),$(eval DIR = $(MODEL_DIR)))
61 $(Q)pyang $(PYANG_OPTIONS) --path $(DIR) --plugindir $(PYBINDPLUGIN) -f pybind -o $(OUT_DIR)/$@ $(DIR)/$*.yang
62
garciadeblasa1744192018-10-28 16:05:18 +010063%.tree.txt: $(TREES_DIR) yang-ietf
garciadeblase4eafa82017-11-29 17:34:36 +010064 $(Q)echo generating $@ from $*.yang
Tomás Villaseca1be3d082019-12-04 12:54:34 -030065 $(if $(findstring etsi,$@), $(eval DIR=$(SOL006_MODEL_DIR)),$(eval DIR = $(MODEL_DIR)))
66 $(Q)pyang $(PYANG_OPTIONS) --path $(DIR) -f tree -o $(TREES_DIR)/$@ $(DIR)/$*.yang
garciadeblase4eafa82017-11-29 17:34:36 +010067
garciadeblasa1744192018-10-28 16:05:18 +010068%.html: $(TREES_DIR) yang-ietf
garciadeblase4eafa82017-11-29 17:34:36 +010069 $(Q)echo generating $@ from $*.yang
Tomás Villaseca1be3d082019-12-04 12:54:34 -030070 $(if $(findstring etsi,$@), $(eval DIR=$(SOL006_MODEL_DIR)),$(eval DIR = $(MODEL_DIR)))
71 $(Q)pyang $(PYANG_OPTIONS) --path $(DIR) -f jstree -o $(TREES_DIR)/$@ $(DIR)/$*.yang
garciadeblase06b0aa2017-12-19 09:21:31 +010072 $(Q)sed -r -i 's|data\:image/gif\;base64,R0lGODlhS.*RCAA7|https://osm.etsi.org/images/OSM-logo.png\" width=\"175\" height=\"60|g' $(TREES_DIR)/$@
73 $(Q)sed -r -i 's|<a href=\"http://www.tail-f.com">|<a href="http://osm.etsi.org">|g' $(TREES_DIR)/$@
garciadeblase4eafa82017-11-29 17:34:36 +010074
garciadeblasa1744192018-10-28 16:05:18 +010075%.rec.tree.txt: $(TREES_DIR) yang-ietf
garciadeblase4eafa82017-11-29 17:34:36 +010076 $(Q)echo generating $@ from $*.yang
garciadeblasbc0dd142018-10-28 15:54:24 +010077 $(Q)pyang $(PYANG_OPTIONS) --path $(MODEL_DIR) -f tree -o $(TREES_DIR)/$@ $(MODEL_DIR)/$*.yang
garciadeblase4eafa82017-11-29 17:34:36 +010078 $(Q)mv $(TREES_DIR)/$@ $(TREES_DIR)/$*.tree.txt
79
garciadeblasa1744192018-10-28 16:05:18 +010080%.rec.html: $(TREES_DIR) yang-ietf
garciadeblase4eafa82017-11-29 17:34:36 +010081 $(Q)echo generating $@ from $*.yang
garciadeblasc038a8d2019-04-03 13:35:27 +020082 $(Q)pyang $(PYANG_OPTIONS) --path $(MODEL_DIR) -f jstree -o $(TREES_DIR)/$@ $(MODEL_DIR)/osm-project.yang $(MODEL_DIR)/$*.yang
garciadeblase06b0aa2017-12-19 09:21:31 +010083 $(Q)sed -r -i 's|data\:image/gif\;base64,R0lGODlhS.*RCAA7|https://osm.etsi.org/images/OSM-logo.png\" width=\"175\" height=\"60|g' $(TREES_DIR)/$@
84 $(Q)sed -r -i 's|<a href=\"http://www.tail-f.com">|<a href="http://osm.etsi.org">|g' $(TREES_DIR)/$@
garciadeblase4eafa82017-11-29 17:34:36 +010085 $(Q)mv $(TREES_DIR)/$@ $(TREES_DIR)/$*.html
86
garciadeblas361145b2019-10-28 11:11:48 +010087osm.yaml: yang-ietf yang2swagger
garciadeblas878dee42018-10-28 16:12:42 +010088 $(Q)echo generating $@
garciadeblasd6e6ffb2019-04-09 15:12:05 +020089 $(Q)$(JAVA) -jar ${HOME}/.m2/repository/com/mrv/yangtools/swagger-generator-cli/1.1.11/swagger-generator-cli-1.1.11-executable.jar -yang-dir $(MODEL_DIR) -output $(OUT_DIR)/$@
garciadeblas878dee42018-10-28 16:12:42 +010090
garciadeblasa1744192018-10-28 16:05:18 +010091yang-ietf:
Tomás Villaseca1be3d082019-12-04 12:54:34 -030092 $(Q)wget -q https://raw.githubusercontent.com/YangModels/yang/master/standard/ietf/RFC/ietf-yang-types%402013-07-15.yang -O $(MODEL_DIR)/ietf-yang-types.yang
93 $(Q)wget -q https://raw.githubusercontent.com/YangModels/yang/master/standard/ietf/RFC/ietf-inet-types%402013-07-15.yang -O $(MODEL_DIR)/ietf-inet-types.yang
94 $(Q)cp $(MODEL_DIR)/ietf-yang-types.yang $(SOL006_MODEL_DIR)/ietf-yang-types.yang
95 $(Q)cp $(MODEL_DIR)/ietf-inet-types.yang $(SOL006_MODEL_DIR)/ietf-inet-types.yang
garciadeblasa1744192018-10-28 16:05:18 +010096
garciadeblas878dee42018-10-28 16:12:42 +010097yang2swagger:
98 $(Q)mkdir -p ${HOME}/.m2
99 $(Q)wget -q -O ${HOME}/.m2/settings.xml https://raw.githubusercontent.com/opendaylight/odlparent/master/settings.xml
100 git clone https://github.com/bartoszm/yang2swagger.git
garciadeblasd6e6ffb2019-04-09 15:12:05 +0200101 git -C yang2swagger checkout tags/1.1.11
garciadeblas878dee42018-10-28 16:12:42 +0100102 mvn -f yang2swagger/pom.xml clean install
103
Mike Marchetti94b645e2017-08-04 14:33:54 -0400104package:
105 tox -e build
Mike Marchettice4a73d2018-08-29 15:40:41 -0400106 tox -e build3
Mike Marchetti09a27102018-09-24 15:05:51 -0400107 ./build-docs.sh
108
garciadeblas4cdeebb2018-10-28 16:00:37 +0100109deps:
110 $(Q)sudo apt-get -y install git make wget python python-pip debhelper dh-make tox python3 python3-pip maven
111 $(Q)sudo -H python3 -m pip install -U pip
112 $(Q)sudo -H python2 -m pip install -U pip
113 $(Q)sudo -H python3 -m pip install -U pyang pyangbind stdeb
114 $(Q)sudo -H python2 -m pip install -U pyang pyangbind stdeb
115 $(Q)mkdir -p ~/.m2
116 $(Q)cp -n ~/.m2/settings.xml{,.orig} ; wget -q -O - https://raw.githubusercontent.com/opendaylight/odlparent/master/settings.xml > ~/.m2/settings.xml
117
Tomás Villaseca1be3d082019-12-04 12:54:34 -0300118sol006_deps:
119 $(Q)git clone --single-branch --branch v2.6.1 https://forge.etsi.org/rep/nfv/SOL006.git sol006_model
120 $(Q)patch -p2 < patch/deref_warnings.patch
121 $(Q)patch -p2 < patch/nested_workaround.patch
122
Mike Marchetti94b645e2017-08-04 14:33:54 -0400123clean:
Tomás Villaseca1be3d082019-12-04 12:54:34 -0300124 $(Q)rm -rf dist sol006_model osm_im.egg-info deb deb_dist *.gz osm-imdocs* yang2swagger $(TREES_DIR)