Skip to content

Commit

Permalink
First working toolchain.
Browse files Browse the repository at this point in the history
Signed-off-by: peusterm <[email protected]>
  • Loading branch information
peusterm committed Feb 28, 2019
1 parent a1cdd12 commit 906f83d
Show file tree
Hide file tree
Showing 11 changed files with 153 additions and 56 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
models/model.py
# generated stuff
results/

Expand Down
21 changes: 15 additions & 6 deletions models/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,27 @@
# the Horizon 2020 and 5G-PPP programmes. The authors would like to
# acknowledge the contributions of their colleagues of the SONATA
# partner consortium (www.5gtango.eu).
.DEFAULT_GOAL := all

DOC_DIR="doc"

ped:
validate:
# generate doc
pyang ped.yang -f tree -o "$(DOC_DIR)/ped.tree"
pyang ped.yang -f jstree -o "$(DOC_DIR)/ped.html"
pyang ped.yang -f uml -o "$(DOC_DIR)/ped.uml"
pyang ietf-ped.yang -f tree -o "$(DOC_DIR)/ietf-ped.tree"
pyang ietf-ped.yang -f jstree -o "$(DOC_DIR)/ietf-ped.html"
pyang ietf-ped.yang -f uml -o "$(DOC_DIR)/ietf-ped.uml"
# finally validate
pyang ped.yang --ietf
pyang ietf-ped.yang --ietf

all: ped
bind:
# generate / compile python model
PYBINDPLUGIN=$(shell python -c 'import pyangbind; import os; print("{}/plugin".format(os.path.dirname(pyangbind.__file__)))')
pyang --plugindir $(PYBINDPLUGIN) -f pybind -o model.py ietf-ped.yang

test:
python test.py

all: validate bind

clean:
rm doc/*
10 changes: 9 additions & 1 deletion models/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# tng-sdk-benchmark models

YANG based models for PED files etc.
YANG based models for PED files etc.

## Build

```sh
make
```

This will create HTML, tree, and UML documentation in `doc/`.
48 changes: 38 additions & 10 deletions models/doc/ped.html → models/doc/ietf-ped.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<head><title> ped
<head><title> ietf-ped
</title>
<style type="text/css" media="all">

Expand Down Expand Up @@ -153,9 +153,9 @@
</a>
<div class="app">
<div style="background: #eee; border: dashed 1px #000;">
<h1> Module: <font color=blue>ped</font>, Namespace:
<font color=blue>https://github.com/sonata-nfv/tng-sdk-benchmark/models/ped</font>, Prefix:
<font color=blue>ped</font></h1>
<h1> Module: <font color=blue>ietf-ped</font>, Namespace:
<font color=blue>urn:ietf:params:xml:ns:yang:ietf-ped</font>, Prefix:
<font color=blue>pe</font></h1>

<table width="100%">

Expand All @@ -181,7 +181,7 @@ <h1> Module: <font color=blue>ped</font>, Namespace:
onclick="toggleRows(this);return false;"
class="folder">&nbsp;
</a>
<font color=blue>ped</font>
<font color=blue>ietf-ped</font>
</div>
</td>
<td>module</td><td></td><td></td><td></td><td>
Expand All @@ -193,21 +193,21 @@ <h1> Module: <font color=blue>ped</font>, Namespace:
onclick="toggleRows(this);return false"
class="folder">&nbsp;
</a>
<abbr title="Performance Experiment Descriptor (PED)">ped-catalog</abbr>
<abbr title="Performance Experiment Descriptor (PED)">ped</abbr>
</div>
</td>
<td nowrap>container</td>
<td nowrap></td>
<td nowrap>config</td>
<td></td>
<td>current</td>
<td nowrap>/ped:ped-catalog</td>
<td nowrap>/pe:ped</td>
</tr>
<tr id="1-1-1" class="a">
<td nowrap>
<div id=9999 class=tier3>
<a class="leaf">&nbsp;</a>
<abbr title="Schema version for the PED. Uses v1.0 if not specified."> <em> schema-version </em></abbr>
<abbr title="Pointer to this data model."> <em> descriptor-schema </em></abbr>
</div>
</td>
<td>leaf</td>
Expand All @@ -216,8 +216,22 @@ <h1> Module: <font color=blue>ped</font>, Namespace:
<td nowrap>config</td>
<td>?</td>
<td>current</td>
<td nowrap>/ped:ped-catalog/ped:schema-version</td</tr>
<td nowrap>/pe:ped/pe:descriptor-schema</td</tr>
<tr id="1-1-2" class="a">
<td nowrap>
<div id=9999 class=tier3>
<a class="leaf">&nbsp;</a>
<abbr title="Vendor of the described experiments."> <em> vendor </em></abbr>
</div>
</td>
<td>leaf</td>
<td nowrap><abbr title="string
">string</abbr></td>
<td nowrap>config</td>
<td>?</td>
<td>current</td>
<td nowrap>/pe:ped/pe:vendor</td</tr>
<tr id="1-1-3" class="a">
<td nowrap>
<div id=9999 class=tier3>
<a class="leaf">&nbsp;</a>
Expand All @@ -230,7 +244,21 @@ <h1> Module: <font color=blue>ped</font>, Namespace:
<td nowrap>config</td>
<td>?</td>
<td>current</td>
<td nowrap>/ped:ped-catalog/ped:name</td</tr>
<td nowrap>/pe:ped/pe:name</td</tr>
<tr id="1-1-4" class="a">
<td nowrap>
<div id=9999 class=tier3>
<a class="leaf">&nbsp;</a>
<abbr title="Version of the described experiments."> <em> version </em></abbr>
</div>
</td>
<td>leaf</td>
<td nowrap><abbr title="string
">string</abbr></td>
<td nowrap>config</td>
<td>?</td>
<td>current</td>
<td nowrap>/pe:ped/pe:version</td</tr>

</table>
</div>
Expand Down
6 changes: 6 additions & 0 deletions models/doc/ietf-ped.tree
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
module: ietf-ped
+--rw ped
+--rw descriptor-schema? string
+--rw vendor? string
+--rw name? string
+--rw version? string
29 changes: 29 additions & 0 deletions models/doc/ietf-ped.uml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
'Download plantuml from http://plantuml.sourceforge.net/
'Generate png with java -jar plantuml.jar <file>
'Output in img/<module>.png
'If Java spits out memory error increase heap size with java -Xmx1024m -jar plantuml.jar <file>
@startuml img/ietf-ped.png
hide empty fields
hide empty methods
hide <<case>> circle
hide <<augment>> circle
hide <<choice>> circle
hide <<leafref>> stereotype
hide <<leafref>> circle
page 1x1
Title ietf-ped
note top of pe_ietf_ped : <b>Namespace: </b> urn:ietf:params:xml:ns:yang:ietf-ped \n<b>Prefix: </b> pe \n<b>Organization : </b>\n \n<b>Contact : </b>\n \n<b>Revision : </b> 2019-02-21 \n
package "pe:ietf-ped" as pe_ietf_ped {
class "ietf-ped" as ietf_ped << (M, #33CCFF) module>>
class "ped" as ietf_ped_I_ped <<container>>
ietf_ped *-- "1" ietf_ped_I_ped
ietf_ped_I_ped : descriptor-schema : string = https://github.com/mpeuster/tng-sdk-benchmark/raw/feature-73/models/ped.yang
ietf_ped_I_ped : vendor : string
ietf_ped_I_ped : name : string
ietf_ped_I_ped : version : string
}

center footer
<size:20> UML Generated : 2019-02-28 22:37 </size>
endfooter
@enduml
4 changes: 0 additions & 4 deletions models/doc/ped.tree

This file was deleted.

27 changes: 0 additions & 27 deletions models/doc/ped.uml

This file was deleted.

6 changes: 6 additions & 0 deletions models/example-instance.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
ped:
descriptor-schema: "blaa"
vendor: "com.vendor"
name: "my_example"
version: "0.1"
29 changes: 21 additions & 8 deletions models/ped.yang → models/ietf-ped.yang
Original file line number Diff line number Diff line change
Expand Up @@ -26,30 +26,43 @@
* acknowledge the contributions of their colleagues of the SONATA
* partner consortium (www.5gtango.eu).
*/

module ped
module ietf-ped
{
namespace "https://github.com/sonata-nfv/tng-sdk-benchmark/models/ped";
prefix "ped";
namespace "urn:ietf:params:xml:ns:yang:ietf-ped";
prefix "pe";
organization "";
contact "";
description "";

revision 2019-02-21 {
description
"Initial revision. This YANG file defines
the Performance Experiment Descriptor (PED)";
reference "";
}
container ped-catalog {
container ped {
description
"Performance Experiment Descriptor (PED)";

leaf schema-version {
description "Schema version for the PED. Uses v1.0 if not specified.";
leaf descriptor-schema {
type string;
default "https://github.com/mpeuster/tng-sdk-benchmark/raw/feature-73/models/ped.yang"; // update this
description "Pointer to this data model.";
}

leaf vendor {
type string;
default "v1.0";
description "Vendor of the described experiments.";
}

leaf name {
type string;
description "Name of the described experiments.";
}

leaf version {
type string;
description "Version of the described experiments.";
}
}
}
28 changes: 28 additions & 0 deletions models/test.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import model
from model import ietf_ped
from pyangbind.lib.serialise import pybindJSONDecoder
import pyangbind.lib.pybindJSON as pybindJSON
import yaml
import json

#
# re-generate the model
# pyang --plugindir $PYBINDPLUGIN -f pybind -o model.py ietf-ped.yang
#

#m = ietf_ped()
#print(ietf_ped)
#print(pybindJSON.dumps(m))

#
#pybindJSONDecoder.load_ietf_json(data, None, None, obj=m.ped())

# json version
#m2 = pybindJSON.load("example-instance.json", model, "ietf_ped")
#print(m2.ped.vendor)

# yaml version
data = yaml.load(open("example-instance.yml", "r"))
print(data)
m3 = pybindJSON.loads(data, model, "ietf_ped")
print(m3.ped.vendor)

0 comments on commit 906f83d

Please sign in to comment.