From: garciadeblas Date: Wed, 29 Nov 2017 16:34:36 +0000 (+0100) Subject: Generation of text and html trees with pyang to navigate through the IM X-Git-Tag: v3.0.3~6^2~1 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F43%2F5743%2F1;p=osm%2FIM.git Generation of text and html trees with pyang to navigate through the IM Change-Id: I8770e13e69f50adb948494ca6bbc9edce0c4e56c Signed-off-by: garciadeblas --- diff --git a/.gitignore b/.gitignore index 0025eee..66f7158 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,7 @@ dist *egg-info *.gz osm_im +osm_im_trees pyangbind pyang dists diff --git a/Makefile b/Makefile index 706bab4..5f3b235 100644 --- a/Makefile +++ b/Makefile @@ -19,11 +19,17 @@ PYANG:= pyang PYBINDPLUGIN:=$(shell /usr/bin/env python -c \ 'import pyangbind; import os; print "%s/plugin" % os.path.dirname(pyangbind.__file__)') -YANG_MODELS := vnfd nsd -PYTHON_MODELS := $(addsuffix .py, $(YANG_MODELS)) -PYTHON_JSONSCHEMAS := $(addsuffix .jsonschema, $(YANG_MODELS)) +YANG_DESC_MODELS := vnfd nsd +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)) OUT_DIR := osm_im +TREES_DIR := osm_im_trees MODEL_DIR := models/yang RW_PB_EXT := build/yang/rw-pb-ext.yang Q?=@ @@ -33,10 +39,15 @@ PYANG_OPTIONS := -Werror all: $(PYTHON_MODELS) pyangbind $(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 +$(TREES_DIR): + $(Q)mkdir -p $(TREES_DIR) + %.py: $(OUT_DIR) $(RW_PB_EXT) $(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 @@ -45,6 +56,24 @@ $(OUT_DIR): $(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 +%.tree.txt: $(TREES_DIR) + $(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 + +%.rec.tree.txt: $(TREES_DIR) + $(Q)echo generating $@ from $*.yang + $(Q)pyang $(PYANG_OPTIONS) --path build/yang --path $(MODEL_DIR) -f tree -o $(TREES_DIR)/$@ $(MODEL_DIR)/$*.yang + $(Q)mv $(TREES_DIR)/$@ $(TREES_DIR)/$*.tree.txt + +%.rec.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)/rw-project.yang $(MODEL_DIR)/$*.yang + $(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 $@ @@ -68,4 +97,4 @@ pyang-json-schema-plugin: git clone https://github.com/cmoberg/pyang-json-schema-plugin clean: - $(Q)rm -rf build dist osm_im.egg-info deb deb_dist *.gz pyang pyangbind pyang-json-schema-plugin $(OUT_DIR) + $(Q)rm -rf build dist osm_im.egg-info deb deb_dist *.gz pyang pyangbind pyang-json-schema-plugin $(OUT_DIR) $(TREES_DIR)