Modify Makefile to use SOL006 YANG models 22/8322/3
authorTomás Villaseca <tvillaseca@whitestack.com>
Wed, 4 Dec 2019 15:54:34 +0000 (12:54 -0300)
committerTomás Villaseca <tvillaseca@whitestack.com>
Thu, 19 Dec 2019 20:55:52 +0000 (17:55 -0300)
Change-Id: I4a23d31a7de694d70f701430ce3f5e0cbf338f90
Signed-off-by: Tomás Villaseca <tvillaseca@whitestack.com>
.gitignore
Makefile
patch/deref_warnings.patch [new file with mode: 0644]
patch/nested_workaround.patch [new file with mode: 0644]

index 893f025..f1e4221 100644 (file)
@@ -35,6 +35,8 @@ osm_im/vnfd.py
 osm_im/nst.py
 osm_im/nsi.py
 osm_im/osm.yaml
+osm_im/etsi-nfv-nsd.py
+osm_im/etsi-nfv-vnfd.py
 
 #Pyang and other tools' folders
 pyangbind
index e4e8fef..ab9550a 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -31,17 +31,24 @@ YANG_RECORD_TREES := $(addsuffix .rec.tree.txt, $(YANG_RECORD_MODELS))
 YANG_RECORD_JSTREES := $(addsuffix .rec.html, $(YANG_RECORD_MODELS))
 OPENAPI_SCHEMAS := osm.yaml
 
+SOL006_YANG_DESC_MODELS := etsi-nfv-vnfd etsi-nfv-nsd
+SOL006_PYTHON_MODELS := $(addsuffix .py, $(SOL006_YANG_DESC_MODELS))
+SOL006_YANG_DESC_TREES := $(addsuffix .tree.txt, $(SOL006_YANG_DESC_MODELS))
+SOL006_YANG_DESC_JSTREES := $(addsuffix .html, $(SOL006_YANG_DESC_MODELS))
+
 OUT_DIR := osm_im
 TREES_DIR := osm_im_trees
 MODEL_DIR := models/yang
+SOL006_MODEL_DIR := sol006_model/src/yang
+
 Q?=@
 
 PYANG_OPTIONS := -Werror
 
-all: $(PYTHON_MODELS) trees openapi_schemas
+all: sol006_deps $(PYTHON_MODELS) $(SOL006_PYTHON_MODELS) trees openapi_schemas
        $(MAKE) package
 
-trees: $(YANG_DESC_TREES) $(YANG_DESC_JSTREES) $(YANG_RECORD_TREES) $(YANG_RECORD_JSTREES)
+trees: $(YANG_DESC_TREES) $(YANG_DESC_JSTREES) $(SOL006_YANG_DESC_TREES) $(SOL006_YANG_DESC_JSTREES)
 
 openapi_schemas: $(OPENAPI_SCHEMAS)
 
@@ -50,15 +57,18 @@ $(TREES_DIR):
 
 %.py: yang-ietf
        $(Q)echo generating $@ from $*.yang
-       $(Q)pyang $(PYANG_OPTIONS) --path $(MODEL_DIR) --plugindir $(PYBINDPLUGIN) -f pybind -o $(OUT_DIR)/$@ $(MODEL_DIR)/$*.yang
-
+       $(if $(findstring etsi,$@), $(eval DIR=$(SOL006_MODEL_DIR)),$(eval DIR = $(MODEL_DIR)))
+       $(Q)pyang $(PYANG_OPTIONS) --path $(DIR) --plugindir $(PYBINDPLUGIN) -f pybind -o $(OUT_DIR)/$@ $(DIR)/$*.yang
+               
 %.tree.txt: $(TREES_DIR) yang-ietf
        $(Q)echo generating $@ from $*.yang
-       $(Q)pyang $(PYANG_OPTIONS) --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
 
 %.html: $(TREES_DIR) yang-ietf
        $(Q)echo generating $@ from $*.yang
-       $(Q)pyang $(PYANG_OPTIONS) --path $(MODEL_DIR) -f jstree -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 jstree -o $(TREES_DIR)/$@ $(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|<a href=\"http://www.tail-f.com">|<a href="http://osm.etsi.org">|g' $(TREES_DIR)/$@
 
@@ -79,8 +89,10 @@ osm.yaml: yang-ietf yang2swagger
        $(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)/$@
 
 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
+       $(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
@@ -103,5 +115,10 @@ deps:
        $(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
 
+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
+
 clean:
-       $(Q)rm -rf dist osm_im.egg-info deb deb_dist *.gz osm-imdocs* yang2swagger $(TREES_DIR)
+       $(Q)rm -rf dist sol006_model osm_im.egg-info deb deb_dist *.gz osm-imdocs* yang2swagger $(TREES_DIR)
diff --git a/patch/deref_warnings.patch b/patch/deref_warnings.patch
new file mode 100644 (file)
index 0000000..457b73a
--- /dev/null
@@ -0,0 +1,86 @@
+#
+# Copyright 2019 Whitestack LLC
+#
+# 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 License for the specific language governing permissions and
+# limitations under the License.
+
+--- /tmp/sol006_model/src/yang/etsi-nfv-ns.yang        2019-12-04 13:56:05.510072421 +0000
++++ /tmp/sol006_model/src/yang/etsi-nfv-ns_new.yang    2019-12-04 13:59:32.675856579 +0000
+@@ -434,8 +434,8 @@
+           mandatory "true";
+           container vnf-profile {
+             leaf vnf-profile-id {
+-              must ". = deref(../../vnfd-profile-id)" {
+-              }
++              // must ". = deref(../../vnfd-profile-id)" {
++              // }
+               type leafref {
+                 path "../../../../../nsd/df/vnf-profile/id";
+               }
+@@ -443,8 +443,8 @@
+           }
+           container pnf-profile {
+             leaf pnf-profile-id {
+-              must ". = deref(../../pnfd-profile-id)" {
+-              }
++              // must ". = deref(../../pnfd-profile-id)" {
++              // }
+               type leafref {
+                 path "../../../../../nsd/df/pnf-profile/id";
+               }
+@@ -452,8 +452,8 @@
+           }
+           container ns-profile {
+             leaf ns-profile-id {
+-              must ". = deref(../../ns-profile-id)" {
+-              }
++              // must ". = deref(../../ns-profile-id)" {
++              // }
+               type leafref {
+                 path "../../../../../nsd/df/ns-profile/id";
+               }
+@@ -469,8 +469,8 @@
+         choice constituent-cpd-id {
+           container vnf {
+             leaf vnfd-id {
+-              must ". = deref(../../vnfd-profile-id)/../vnfd-id" {
+-              }
++              // must ". = deref(../../vnfd-profile-id)/../vnfd-id" {
++              // }
+               type leafref {
+                 path "../../../../../vnfd/id";
+               }
+@@ -483,8 +483,8 @@
+           }
+           container pnf {
+             leaf pnfd-id {
+-              must ". = deref(../../pnfd-profile-id)/../pnfd-id" {
+-              }
++              // must ". = deref(../../pnfd-profile-id)/../pnfd-id" {
++              // }
+               type leafref {
+                 path "../../../../../pnfd/id";
+               }
+@@ -497,9 +497,9 @@
+           }
+           container ns {
+             leaf nsd-id {
+-              must ". = deref(../../nested-ns-profile-id)/" +
+-                   "../nsd-id" {
+-              }
++              // must ". = deref(../../nested-ns-profile-id)/" +
++              //      "../nsd-id" {
++              // }
+               type leafref {
+                 path "../../../../../nsd/id";
diff --git a/patch/nested_workaround.patch b/patch/nested_workaround.patch
new file mode 100644 (file)
index 0000000..68f3fb1
--- /dev/null
@@ -0,0 +1,36 @@
+#
+# Copyright 2019 Whitestack LLC
+#
+# 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 License for the specific language governing permissions and
+# limitations under the License.
+
+--- /tmp/sol006_model/src/yang/etsi-nfv-ns.yang        2019-12-04 14:26:39.453144459 +0000
++++ /tmp/sol006_model/src/yang/etsi-nfv-ns_new.yang    2019-12-04 14:28:34.659419362 +0000
+@@ -159,7 +159,7 @@
+             "GS NFV IFA014: Section 6.2.3.2 Sapd information element";
+         }
+-        choice associated-cpd-id {
++        //choice associated-cpd-id {
+           container vnf {
+             leaf vnfd-id {
+               mandatory true;
+@@ -209,7 +209,7 @@
+               }
+             }
+           }
+-        }
++        //}
+       }
+     }