X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;ds=inline;f=Makefile;h=e4e8fef3da44c1863a9cf23834d9f57ad2c6bc0e;hb=refs%2Ftags%2Fv7.1.0rc6;hp=2d824180f9d9c668b0b8ebeaf05098d97e8240e9;hpb=241bd466dff92bbe997af447fbb10121af4a5aa4;p=osm%2FIM.git
diff --git a/Makefile b/Makefile
index 2d82418..e4e8fef 100644
--- a/Makefile
+++ b/Makefile
@@ -1,4 +1,5 @@
# Copyright 2017 Sandvine
+# Copyright 2017-2018 Telefonica
# All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
@@ -15,90 +16,92 @@
# NOTE: pyang and pyangbind are required for build
+.PHONY: all clean package trees deps yang-ietf openapi_schemas yang2swagger
+JAVA:=/usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
PYANG:= pyang
-PYBINDPLUGIN:=$(shell /usr/bin/env python -c \
- 'import pyangbind; import os; print "%s/plugin" % os.path.dirname(pyangbind.__file__)')
+PYBINDPLUGIN:=$(shell /usr/bin/env python3 -c \
+ 'import pyangbind; import os; print("{}/plugin".format(os.path.dirname(pyangbind.__file__)))')
-YANG_DESC_MODELS := vnfd nsd
+YANG_DESC_MODELS := vnfd nsd nst nsi
YANG_RECORD_MODELS := vnfr nsr
PYTHON_MODELS := $(addsuffix .py, $(YANG_DESC_MODELS))
-PYTHON_JSONSCHEMAS := $(addsuffix .jsonschema, $(YANG_DESC_MODELS))
YANG_DESC_TREES := $(addsuffix .tree.txt, $(YANG_DESC_MODELS))
YANG_DESC_JSTREES := $(addsuffix .html, $(YANG_DESC_MODELS))
YANG_RECORD_TREES := $(addsuffix .rec.tree.txt, $(YANG_RECORD_MODELS))
YANG_RECORD_JSTREES := $(addsuffix .rec.html, $(YANG_RECORD_MODELS))
+OPENAPI_SCHEMAS := osm.yaml
OUT_DIR := osm_im
TREES_DIR := osm_im_trees
MODEL_DIR := models/yang
-RW_PB_EXT := build/yang/rw-pb-ext.yang
Q?=@
PYANG_OPTIONS := -Werror
-all: $(PYTHON_MODELS) pyangbind trees
+all: $(PYTHON_MODELS) trees openapi_schemas
$(MAKE) package
trees: $(YANG_DESC_TREES) $(YANG_DESC_JSTREES) $(YANG_RECORD_TREES) $(YANG_RECORD_JSTREES)
-$(OUT_DIR):
- $(Q)mkdir -p $(OUT_DIR)
- $(Q)touch $(OUT_DIR)/__init__.py
+openapi_schemas: $(OPENAPI_SCHEMAS)
$(TREES_DIR):
$(Q)mkdir -p $(TREES_DIR)
-%.py: $(OUT_DIR) $(RW_PB_EXT)
+%.py: yang-ietf
$(Q)echo generating $@ from $*.yang
- $(Q)pyang $(PYANG_OPTIONS) --path build/yang --path $(MODEL_DIR) --plugindir $(PYBINDPLUGIN) -f pybind -o $(OUT_DIR)/$@ $(MODEL_DIR)/$*.yang
+ $(Q)pyang $(PYANG_OPTIONS) --path $(MODEL_DIR) --plugindir $(PYBINDPLUGIN) -f pybind -o $(OUT_DIR)/$@ $(MODEL_DIR)/$*.yang
-%.jsonschema: $(OUT_DIR) $(RW_PB_EXT) pyang-json-schema-plugin
+%.tree.txt: $(TREES_DIR) yang-ietf
$(Q)echo generating $@ from $*.yang
- $(Q)pyang $(PYANG_OPTIONS) --path build/yang --path $(MODEL_DIR) --plugindir pyang-json-schema-plugin -f json-schema -o $(OUT_DIR)/$@ $(MODEL_DIR)/$*.yang
+ $(Q)pyang $(PYANG_OPTIONS) --path $(MODEL_DIR) -f tree -o $(TREES_DIR)/$@ $(MODEL_DIR)/$*.yang
-%.tree.txt: $(TREES_DIR)
+%.html: $(TREES_DIR) yang-ietf
$(Q)echo generating $@ from $*.yang
- $(Q)pyang $(PYANG_OPTIONS) --path build/yang --path $(MODEL_DIR) -f tree -o $(TREES_DIR)/$@ $(MODEL_DIR)/$*.yang
-
-%.html: $(TREES_DIR)
- $(Q)echo generating $@ from $*.yang
- $(Q)pyang $(PYANG_OPTIONS) --path build/yang --path $(MODEL_DIR) -f jstree -o $(TREES_DIR)/$@ $(MODEL_DIR)/$*.yang
+ $(Q)pyang $(PYANG_OPTIONS) --path $(MODEL_DIR) -f jstree -o $(TREES_DIR)/$@ $(MODEL_DIR)/$*.yang
$(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)/$@
$(Q)sed -r -i 's|||g' $(TREES_DIR)/$@
-%.rec.tree.txt: $(TREES_DIR)
+%.rec.tree.txt: $(TREES_DIR) yang-ietf
$(Q)echo generating $@ from $*.yang
- $(Q)pyang $(PYANG_OPTIONS) --path build/yang --path $(MODEL_DIR) -f tree -o $(TREES_DIR)/$@ $(MODEL_DIR)/$*.yang
+ $(Q)pyang $(PYANG_OPTIONS) --path $(MODEL_DIR) -f tree -o $(TREES_DIR)/$@ $(MODEL_DIR)/$*.yang
$(Q)mv $(TREES_DIR)/$@ $(TREES_DIR)/$*.tree.txt
-%.rec.html: $(TREES_DIR)
+%.rec.html: $(TREES_DIR) yang-ietf
$(Q)echo generating $@ from $*.yang
- $(Q)pyang $(PYANG_OPTIONS) --path build/yang --path $(MODEL_DIR) -f jstree -o $(TREES_DIR)/$@ $(MODEL_DIR)/rw-project.yang $(MODEL_DIR)/$*.yang
+ $(Q)pyang $(PYANG_OPTIONS) --path $(MODEL_DIR) -f jstree -o $(TREES_DIR)/$@ $(MODEL_DIR)/osm-project.yang $(MODEL_DIR)/$*.yang
$(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)/$@
$(Q)sed -r -i 's|||g' $(TREES_DIR)/$@
$(Q)mv $(TREES_DIR)/$@ $(TREES_DIR)/$*.html
-$(RW_PB_EXT):
- $(Q)mkdir -p $$(dirname $@)
- $(Q)wget -q https://raw.githubusercontent.com/RIFTIO/RIFT.ware/RIFT.ware-4.4.1/modules/core/util/yangtools/yang/rw-pb-ext.yang -O $@
+osm.yaml: yang-ietf yang2swagger
+ $(Q)echo generating $@
+ $(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)/$@
-package:
- tox -e build
+yang-ietf:
+ $(Q)wget -q https://raw.githubusercontent.com/YangModels/yang/master/standard/ietf/RFC/ietf-yang-types%402013-07-15.yang -O models/yang/ietf-yang-types.yang
+ $(Q)wget -q https://raw.githubusercontent.com/YangModels/yang/master/standard/ietf/RFC/ietf-inet-types%402013-07-15.yang -O models/yang/ietf-inet-types.yang
-pyangbind: pyang
- git clone https://github.com/alf-tierno/pyangbind
- cd pyangbind; git checkout issue151; python setup.py --command-packages=stdeb.command bdist_deb; cd ..
- mkdir -p deb_dist
- cp pyangbind/deb_dist/*.deb deb_dist
+yang2swagger:
+ $(Q)mkdir -p ${HOME}/.m2
+ $(Q)wget -q -O ${HOME}/.m2/settings.xml https://raw.githubusercontent.com/opendaylight/odlparent/master/settings.xml
+ git clone https://github.com/bartoszm/yang2swagger.git
+ git -C yang2swagger checkout tags/1.1.11
+ mvn -f yang2swagger/pom.xml clean install
-pyang:
- git clone https://github.com/mbj4668/pyang
- cd pyang; python setup.py --command-packages=stdeb.command bdist_deb; cd ..
- mkdir -p deb_dist
- cp pyang/deb_dist/*.deb deb_dist
-
-pyang-json-schema-plugin:
- git clone https://github.com/cmoberg/pyang-json-schema-plugin
+package:
+ tox -e build
+ tox -e build3
+ ./build-docs.sh
+
+deps:
+ $(Q)sudo apt-get -y install git make wget python python-pip debhelper dh-make tox python3 python3-pip maven
+ $(Q)sudo -H python3 -m pip install -U pip
+ $(Q)sudo -H python2 -m pip install -U pip
+ $(Q)sudo -H python3 -m pip install -U pyang pyangbind stdeb
+ $(Q)sudo -H python2 -m pip install -U pyang pyangbind stdeb
+ $(Q)mkdir -p ~/.m2
+ $(Q)cp -n ~/.m2/settings.xml{,.orig} ; wget -q -O - https://raw.githubusercontent.com/opendaylight/odlparent/master/settings.xml > ~/.m2/settings.xml
clean:
- $(Q)rm -rf build dist osm_im.egg-info deb deb_dist *.gz pyang pyangbind pyang-json-schema-plugin $(OUT_DIR) $(TREES_DIR)
+ $(Q)rm -rf dist osm_im.egg-info deb deb_dist *.gz osm-imdocs* yang2swagger $(TREES_DIR)