X-Git-Url: https://osm.etsi.org/gitweb/?a=blobdiff_plain;ds=inline;f=Makefile;h=90cd86a13f223583a0a6648cc8600cc50862274d;hb=40deefbbeba19ca0ee7be0868062280bcf851ca3;hp=22df56d6566b318270c6c551762449a57f798a98;hpb=e6ba40aa913089e6fd057dce5ad34879ee4303ce;p=osm%2FIM.git
diff --git a/Makefile b/Makefile
index 22df56d..90cd86a 100644
--- a/Makefile
+++ b/Makefile
@@ -1,13 +1,13 @@
# Copyright 2017 Sandvine
# Copyright 2017-2018 Telefonica
# All Rights Reserved.
-#
+#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
-#
+#
# http://www.apache.org/licenses/LICENSE-2.0
-#
+#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
@@ -16,80 +16,117 @@
# NOTE: pyang and pyangbind are required for build
-PYANG:= pyang
-PYBINDPLUGIN:=$(shell /usr/bin/env python3 -c \
- 'import pyangbind; import os; print("{}/plugin".format(os.path.dirname(pyangbind.__file__)))')
-
-YANG_DESC_MODELS := vnfd nsd
+.PHONY: all clean package trees deps yang-ietf openapi_schemas yang2swagger
+JAVA := /usr/lib/jvm/java-8-openjdk-amd64/jre/bin/java
+PYANG := pyang
+ifeq ($(OS),Windows_NT) # is Windows_NT on XP, 2000, 7, Vista, 10...
+ PYTHON_INTERPRETER := python
+else
+ PYTHON_INTERPRETER := python3
+endif
+PYBINDPLUGIN := $(shell $(PYTHON_INTERPRETER) -c \
+ 'import pyangbind; import os; print(os.path.join(f"{os.path.dirname(pyangbind.__file__)}", "plugin"))')
+
+YANG_DESC_MODELS := vnfd nsd nst nsi etsi-nfv-vnfd etsi-nfv-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))
+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
+SOL006_MODEL_DIR := sol006_model/src/yang
+SOL006_AUGMENTS_DIR := models/augments/*
+
Q?=@
PYANG_OPTIONS := -Werror
-all: $(PYTHON_MODELS) trees
+all: models trees openapi_schemas
$(MAKE) package
-trees: $(YANG_DESC_TREES) $(YANG_DESC_JSTREES) $(YANG_RECORD_TREES) $(YANG_RECORD_JSTREES)
+models: sol006_deps $(PYTHON_MODELS) rename_etsi_nfv_py
+
+trees: $(YANG_DESC_TREES) $(YANG_DESC_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)
- $(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
-
-%.jsonschema: $(OUT_DIR) $(RW_PB_EXT) pyang-json-schema-plugin
+%.py: 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
+ $(if $(findstring etsi,$@), $(eval DIR=$(SOL006_MODEL_DIR)),$(eval DIR=$(MODEL_DIR)))
+ $(if $(findstring etsi,$@), $(eval AUGMENTS_DIR=$(SOL006_AUGMENTS_DIR)),$(eval AUGMENTS_DIR=))
+ $(Q)pyang $(PYANG_OPTIONS) --path $(DIR) --plugindir "$(PYBINDPLUGIN)" -f pybind -o $(OUT_DIR)/$@ $(AUGMENTS_DIR) $(DIR)/$*.yang
-%.tree.txt: $(TREES_DIR)
+%.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
+ $(if $(findstring etsi,$@), $(eval DIR=$(SOL006_MODEL_DIR)),$(eval DIR = $(MODEL_DIR)))
+ $(if $(findstring etsi,$@), $(eval AUGMENTS_DIR=$(SOL006_AUGMENTS_DIR)),$(eval AUGMENTS_DIR=))
+ $(Q)pyang $(PYANG_OPTIONS) --path $(DIR) -f tree -o $(TREES_DIR)/$@ $(DIR)/$*.yang $(AUGMENTS_DIR)
-%.html: $(TREES_DIR)
+%.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)/$*.yang
+ $(if $(findstring etsi,$@), $(eval DIR=$(SOL006_MODEL_DIR)),$(eval DIR = $(MODEL_DIR)))
+ $(if $(findstring etsi,$@), $(eval AUGMENTS_DIR=$(SOL006_AUGMENTS_DIR)),$(eval AUGMENTS_DIR=))
+ $(Q)pyang $(PYANG_OPTIONS) --path $(DIR) -f jstree -o $(TREES_DIR)/$@ $(DIR)/$*.yang $(AUGMENTS_DIR)
$(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
+ $(if $(findstring etsi,$@), $(eval DIR=$(SOL006_MODEL_DIR)),$(eval DIR=$(MODEL_DIR)))
+ $(Q)pyang $(PYANG_OPTIONS) --path $(DIR) -f tree -o $(TREES_DIR)/$@ $(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
+ $(if $(findstring etsi,$@), $(eval DIR=$(SOL006_MODEL_DIR)),$(eval DIR=$(MODEL_DIR)))
+ $(Q)pyang $(PYANG_OPTIONS) --path $(DIR) -f jstree -o $(TREES_DIR)/$@ $(DIR)/osm-project.yang $(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.14/swagger-generator-cli-1.1.14-executable.jar -yang-dir $(MODEL_DIR) -output $(OUT_DIR)/$@
+
+yang-ietf:
+ $(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
+ $(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
+ $(Q)cp $(MODEL_DIR)/ietf-yang-types.yang $(SOL006_MODEL_DIR)/ietf-yang-types.yang
+ $(Q)cp $(MODEL_DIR)/ietf-inet-types.yang $(SOL006_MODEL_DIR)/ietf-inet-types.yang
+
+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.14
+ mvn -f yang2swagger/pom.xml clean install
package:
- tox -e build
- tox -e build3
./build-docs.sh
-pyang-json-schema-plugin:
- git clone https://github.com/cmoberg/pyang-json-schema-plugin
+deps:
+ $(Q)mkdir -p ${HOME}/.m2
+ $(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
+
+sol006_deps:
+ $(Q)git clone --single-branch --branch v2.6.1 https://forge.etsi.org/rep/nfv/SOL006.git sol006_model
+ $(Q)patch -p2 < patch/deref_warnings.patch
+ $(Q)patch -p2 < patch/nested_workaround.patch
+
+rename_etsi_nfv_py:
+ mv osm_im/etsi-nfv-nsd.py osm_im/etsi_nfv_nsd.py
+ mv osm_im/etsi-nfv-vnfd.py osm_im/etsi_nfv_vnfd.py
clean:
- $(Q)rm -rf build dist osm_im.egg-info deb deb_dist *.gz pyang-json-schema-plugin $(OUT_DIR) $(TREES_DIR)
+ $(Q)rm -rf dist sol006_model osm_im.egg-info deb deb_dist *.gz osm-imdocs* yang2swagger $(TREES_DIR)
+ $(Q)rm -rf debian/osm-imdocs.install
+ $(Q)rm -rf osm_im/etsi_nfv_nsd.py osm_im/etsi_nfv_vnfd.py
+ $(Q)rm -rf osm_im/nsd.py osm_im/nsi.py osm_im/nst.py osm_im/osm.yaml osm_im/vnfd.py