Adds generate_bindings.sh script which will 62/39062/15
authorAshish <ashishk.iiit@gmail.com>
Wed, 18 May 2016 18:20:43 +0000 (23:50 +0530)
committerLuis Gomez <ecelgp@gmail.com>
Tue, 26 Jul 2016 04:08:48 +0000 (04:08 +0000)
do the following for pyangbind project.

* Downloads YANG dependency files, from lispflowmapping
  into the odl-lispflowmapping-yang-files directory in
  the same directory i.e. odl-lispflowmapping-yang-bindings
  as the script;

* Generate the LISPFlowMappingYANGBindings.py into the
  same directory i.e. odl-lispflowmapping-yang-bindings
  so that in the later code for generating JSON dictionaries
  we can assume it is there.

* Adds bits.patch, Currently pyangbind doesn't support
  bits type so this patch would comment all those
  cases from yang files for pyangbind to generate the
  bindings file.

Change-Id: I6ec4af7060019b805f75d9a4b11bedf224fe6f77
Signed-off-by: Ashish <ashishk.iiit@gmail.com>
csit/scriptplans/lispflowmapping-pyangbind-generate-bindings.txt [new file with mode: 0644]
csit/suites/lispflowmapping/scripts/bits.patch [new file with mode: 0644]
csit/suites/lispflowmapping/scripts/generate_bindings.sh [new file with mode: 0755]

diff --git a/csit/scriptplans/lispflowmapping-pyangbind-generate-bindings.txt b/csit/scriptplans/lispflowmapping-pyangbind-generate-bindings.txt
new file mode 100644 (file)
index 0000000..fda7a9e
--- /dev/null
@@ -0,0 +1,2 @@
+# Place the scripts in run order:
+integration/test/csit/suites/lispflowmapping/scripts/generate_bindings.sh
diff --git a/csit/suites/lispflowmapping/scripts/bits.patch b/csit/suites/lispflowmapping/scripts/bits.patch
new file mode 100644 (file)
index 0000000..3b3cf5e
--- /dev/null
@@ -0,0 +1,104 @@
+*** ietf-lisp-address-types.yang       2016-05-29 00:36:20.843215496 +0530
+--- ietf-lisp-address-types-updated.yang       2016-05-29 00:37:35.135213297 +0530
+***************
+*** 449,455 ****
+          reference
+            "http://tools.ietf.org/html/draft-ietf-lisp-lcaf-10
+             #section-4.5";
+!         leaf latitude {
+            type bits {
+              bit N {
+                description
+--- 449,455 ----
+          reference
+            "http://tools.ietf.org/html/draft-ietf-lisp-lcaf-10
+             #section-4.5";
+!         /*leaf latitude {
+            type bits {
+              bit N {
+                description
+***************
+*** 458,464 ****
+            }
+            description
+              "Bit that selects between North and South latitude.";
+!         }
+          leaf latitude-degrees {
+            type uint8 {
+              range "0 .. 90";
+--- 458,464 ----
+            }
+            description
+              "Bit that selects between North and South latitude.";
+!         }*/
+          leaf latitude-degrees {
+            type uint8 {
+              range "0 .. 90";
+***************
+*** 480,486 ****
+            description
+              "Seconds of latitude.";
+          }
+!         leaf longitude {
+            type bits {
+              bit E {
+                description
+--- 480,486 ----
+            description
+              "Seconds of latitude.";
+          }
+!         /*leaf longitude {
+            type bits {
+              bit E {
+                description
+***************
+*** 489,495 ****
+            }
+            description
+              "Bit that selects between East and West longitude.";
+!         }
+          leaf longitude-degrees {
+            type uint16 {
+              range "0 .. 180";
+--- 489,495 ----
+            }
+            description
+              "Bit that selects between East and West longitude.";
+!         }*/
+          leaf longitude-degrees {
+            type uint16 {
+              range "0 .. 180";
+***************
+*** 588,594 ****
+              description
+                "AFI address.";
+            }
+!           leaf lrs-bits {
+              type bits{
+                bit lookup {
+                  description
+--- 588,594 ----
+              description
+                "AFI address.";
+            }
+!           /*leaf lrs-bits {
+              type bits{
+                bit lookup {
+                  description
+***************
+*** 605,611 ****
+              }
+              description
+                "Flag bits per hop.";
+!           }
+          }
+        }
+        container source-dest-key {
+--- 605,611 ----
+              }
+              description
+                "Flag bits per hop.";
+!           }*/
+          }
+        }
+        container source-dest-key {
diff --git a/csit/suites/lispflowmapping/scripts/generate_bindings.sh b/csit/suites/lispflowmapping/scripts/generate_bindings.sh
new file mode 100755 (executable)
index 0000000..e51952a
--- /dev/null
@@ -0,0 +1,45 @@
+#!/bin/bash
+echo "Downloading yang dependencies..."
+
+DIRECTORY="odl-lispflowmapping-yang-files"
+
+# odl-lispflowmapping-yang-files will contain all the yang files
+# odl-lispflowmapping-yang-files/LispFlowMappingYANGBindings will
+# contain all the binding files generated by pyangbind.
+mkdir -p ${WORKSPACE}/$DIRECTORY
+
+GITWEB_LISP="https://git.opendaylight.org/gerrit/gitweb?p=lispflowmapping.git;a=blob_plain"
+GITWEB_MDSAL="https://git.opendaylight.org/gerrit/gitweb?p=mdsal.git;a=blob_plain"
+GITWEB_CONTROLLER="https://git.opendaylight.org/gerrit/gitweb?p=controller.git;a=blob_plain"
+
+# Download yang-files in the VM on fly using curl before generating
+# binding files.
+curl "$GITWEB_LISP;f=mappingservice/lisp-proto/src/main/yang/ietf-lisp-address-types.yang" -o ${WORKSPACE}/$DIRECTORY/ietf-lisp-address-types.yang
+curl "$GITWEB_LISP;f=mappingservice/lisp-proto/src/main/yang/odl-lisp-proto.yang" -o ${WORKSPACE}/$DIRECTORY/odl-lisp-proto.yang
+curl "$GITWEB_LISP;f=mappingservice/lisp-proto/src/main/yang/odl-inet-binary-types.yang" -o ${WORKSPACE}/$DIRECTORY/odl-inet-binary-types.yang
+curl "$GITWEB_LISP;f=mappingservice/api/src/main/yang/odl-mappingservice.yang" -o ${WORKSPACE}/$DIRECTORY/odl-mappingservice.yang
+curl "$GITWEB_LISP;f=mappingservice/lisp-proto/src/main/yang/odl-lisp-address-types.yang" -o ${WORKSPACE}/$DIRECTORY/odl-lisp-address-types.yang
+curl "$GITWEB_MDSAL;f=model/ietf/ietf-yang-types-20130715/src/main/yang/ietf-yang-types@2013-07-15.yang" -o ${WORKSPACE}/$DIRECTORY/ietf-yang-types.yang
+curl "$GITWEB_MDSAL;f=model/ietf/ietf-inet-types-2013-07-15/src/main/yang/ietf-inet-types@2013-07-15.yang" -o ${WORKSPACE}/$DIRECTORY/ietf-inet-types.yang
+curl "$GITWEB_MDSAL;f=model/yang-ext/src/main/yang/yang-ext.yang" -o ${WORKSPACE}/$DIRECTORY/yang-ext.yang
+curl "$GITWEB_CONTROLLER;f=opendaylight/config/config-api/src/main/yang/config.yang" -o ${WORKSPACE}/$DIRECTORY/config.yang
+
+# Copy bits patch to yang file directory
+cp bits.patch ${WORKSPACE}/$DIRECTORY
+
+# Go to odl-lispflowmapping-yang-files directory
+cd ${WORKSPACE}/$DIRECTORY
+
+# Currently bits are not supported in pyangbind plugin so
+# We need to apply patch to generate pyangbind bindings
+# Successfully.
+patch -i bits.patch && echo 'Patch applied successfully!'
+
+# Generate binding files using pyangbind
+PYBINDPLUGIN=`/usr/bin/env python -c 'import pyangbind; import os; print "%s/plugin" % os.path.dirname(pyangbind.__file__)'`
+pyang --plugindir $PYBINDPLUGIN -f pybind --build-rpcs --split-class-dir ${WORKSPACE}/$DIRECTORY/LISPFlowMappingYANGBindings ./odl-mappingservice.yang
+
+# Go back the main direcory
+cd ../../
+
+echo "Yang Dependencies and bindings downloaded successfully in ${WORKSPACE}/$DIRECTORY"