Fix bug 1731: backwards compatibility of relations
[osm/IM.git] / Makefile
1 # Copyright 2017 Sandvine
2 # Copyright 2017-2018 Telefonica
3 # 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
19 .PHONY: all clean package trees deps yang-ietf openapi_schemas yang2swagger
20 JAVA:=/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
21 PYANG:= pyang
22 PYBINDPLUGIN:=$(shell /usr/bin/env python3 -c \
23 'import pyangbind; import os; print("{}/plugin".format(os.path.dirname(pyangbind.__file__)))')
24
25 YANG_DESC_MODELS := vnfd nsd nst nsi etsi-nfv-vnfd etsi-nfv-nsd
26 YANG_RECORD_MODELS := vnfr nsr
27 PYTHON_MODELS := $(addsuffix .py, $(YANG_DESC_MODELS))
28 YANG_DESC_TREES := $(addsuffix .tree.txt, $(YANG_DESC_MODELS))
29 YANG_DESC_JSTREES := $(addsuffix .html, $(YANG_DESC_MODELS))
30 YANG_RECORD_TREES := $(addsuffix .rec.tree.txt, $(YANG_RECORD_MODELS))
31 YANG_RECORD_JSTREES := $(addsuffix .rec.html, $(YANG_RECORD_MODELS))
32 OPENAPI_SCHEMAS := osm.yaml
33
34 OUT_DIR := osm_im
35 TREES_DIR := osm_im_trees
36 MODEL_DIR := models/yang
37 SOL006_MODEL_DIR := sol006_model/src/yang
38 SOL006_AUGMENTS_DIR := models/augments/*
39
40 Q?=@
41
42 PYANG_OPTIONS := -Werror
43
44 all: models trees openapi_schemas
45 $(MAKE) package
46
47 models: sol006_deps $(PYTHON_MODELS) rename_etsi_nfv_py
48
49 trees: $(YANG_DESC_TREES) $(YANG_DESC_JSTREES) $(YANG_RECORD_TREES) $(YANG_RECORD_JSTREES)
50
51 openapi_schemas: $(OPENAPI_SCHEMAS)
52
53 $(TREES_DIR):
54 $(Q)mkdir -p $(TREES_DIR)
55
56 %.py: yang-ietf
57 $(Q)echo generating $@ from $*.yang
58 $(if $(findstring etsi,$@), $(eval DIR=$(SOL006_MODEL_DIR)),$(eval DIR=$(MODEL_DIR)))
59 $(if $(findstring etsi,$@), $(eval AUGMENTS_DIR=$(SOL006_AUGMENTS_DIR)),$(eval AUGMENTS_DIR=))
60 $(Q)pyang $(PYANG_OPTIONS) --path $(DIR) --plugindir $(PYBINDPLUGIN) -f pybind -o $(OUT_DIR)/$@ $(AUGMENTS_DIR) $(DIR)/$*.yang
61
62 %.tree.txt: $(TREES_DIR) yang-ietf
63 $(Q)echo generating $@ from $*.yang
64 $(if $(findstring etsi,$@), $(eval DIR=$(SOL006_MODEL_DIR)),$(eval DIR = $(MODEL_DIR)))
65 $(if $(findstring etsi,$@), $(eval AUGMENTS_DIR=$(SOL006_AUGMENTS_DIR)),$(eval AUGMENTS_DIR=))
66 $(Q)pyang $(PYANG_OPTIONS) --path $(DIR) -f tree -o $(TREES_DIR)/$@ $(DIR)/$*.yang $(AUGMENTS_DIR)
67
68 %.html: $(TREES_DIR) yang-ietf
69 $(Q)echo generating $@ from $*.yang
70 $(if $(findstring etsi,$@), $(eval DIR=$(SOL006_MODEL_DIR)),$(eval DIR = $(MODEL_DIR)))
71 $(if $(findstring etsi,$@), $(eval AUGMENTS_DIR=$(SOL006_AUGMENTS_DIR)),$(eval AUGMENTS_DIR=))
72 $(Q)pyang $(PYANG_OPTIONS) --path $(DIR) -f jstree -o $(TREES_DIR)/$@ $(DIR)/$*.yang $(AUGMENTS_DIR)
73 $(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)/$@
74 $(Q)sed -r -i 's|<a href=\"http://www.tail-f.com">|<a href="http://osm.etsi.org">|g' $(TREES_DIR)/$@
75
76 %.rec.tree.txt: $(TREES_DIR) yang-ietf
77 $(Q)echo generating $@ from $*.yang
78 $(if $(findstring etsi,$@), $(eval DIR=$(SOL006_MODEL_DIR)),$(eval DIR=$(MODEL_DIR)))
79 $(Q)pyang $(PYANG_OPTIONS) --path $(DIR) -f tree -o $(TREES_DIR)/$@ $(DIR)/$*.yang
80 $(Q)mv $(TREES_DIR)/$@ $(TREES_DIR)/$*.tree.txt
81
82 %.rec.html: $(TREES_DIR) yang-ietf
83 $(Q)echo generating $@ from $*.yang
84 $(if $(findstring etsi,$@), $(eval DIR=$(SOL006_MODEL_DIR)),$(eval DIR=$(MODEL_DIR)))
85 $(Q)pyang $(PYANG_OPTIONS) --path $(DIR) -f jstree -o $(TREES_DIR)/$@ $(DIR)/osm-project.yang $(DIR)/$*.yang
86 $(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)/$@
87 $(Q)sed -r -i 's|<a href=\"http://www.tail-f.com">|<a href="http://osm.etsi.org">|g' $(TREES_DIR)/$@
88 $(Q)mv $(TREES_DIR)/$@ $(TREES_DIR)/$*.html
89
90 osm.yaml: yang-ietf yang2swagger
91 $(Q)echo generating $@
92 $(Q)$(JAVA) -jar ${HOME}/.m2/repository/com/mrv/yangtools/swagger-generator-cli/1.1.14/swagger-generator-cli-1.1.14-executable.jar -yang-dir $(MODEL_DIR) -output $(OUT_DIR)/$@
93
94 yang-ietf:
95 $(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
96 $(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
97 $(Q)cp $(MODEL_DIR)/ietf-yang-types.yang $(SOL006_MODEL_DIR)/ietf-yang-types.yang
98 $(Q)cp $(MODEL_DIR)/ietf-inet-types.yang $(SOL006_MODEL_DIR)/ietf-inet-types.yang
99
100 yang2swagger:
101 $(Q)mkdir -p ${HOME}/.m2
102 $(Q)wget -q -O ${HOME}/.m2/settings.xml https://raw.githubusercontent.com/opendaylight/odlparent/master/settings.xml
103 git clone https://github.com/bartoszm/yang2swagger.git
104 git -C yang2swagger checkout tags/1.1.14
105 mvn -f yang2swagger/pom.xml clean install
106
107 package:
108 ./build-docs.sh
109
110 deps:
111 $(Q)mkdir -p ${HOME}/.m2
112 $(Q)cp -n ${HOME}/.m2/settings.xml ${HOME}/.m2/settings.xml.orig ; wget -q -O - https://raw.githubusercontent.com/opendaylight/odlparent/master/settings.xml > ${HOME}/.m2/settings.xml
113
114 sol006_deps:
115 $(Q)git clone --single-branch --branch v2.6.1 https://forge.etsi.org/rep/nfv/SOL006.git sol006_model
116 $(Q)patch -p2 < patch/deref_warnings.patch
117 $(Q)patch -p2 < patch/nested_workaround.patch
118
119 rename_etsi_nfv_py:
120 mv osm_im/etsi-nfv-nsd.py osm_im/etsi_nfv_nsd.py
121 mv osm_im/etsi-nfv-vnfd.py osm_im/etsi_nfv_vnfd.py
122
123 clean:
124 $(Q)rm -rf dist sol006_model osm_im.egg-info deb deb_dist *.gz osm-imdocs* yang2swagger $(TREES_DIR)
125 $(Q)rm -rf debian/osm-imdocs.install osm_im/etsi_nfv_nsd.py osm_im/etsi_nfv_vnfd.py osm_im/nsd.py
126 $(Q)rm -rf osm_im/nsi.py osm_im/nst.py osm_im/osm.yaml osm_im/vnfd.py