Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Various fixes to generate TAPI v2.x Yang files #15

Open
wants to merge 1 commit into
base: Tapi_v2x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
*~
UmlYangTools/xmi2yang/node_modules/**
11 changes: 11 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>EAGLE-UML2YANG</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>
</projectDescription>
35 changes: 19 additions & 16 deletions UmlYangTools/.project
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>UmlYangTools</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.eclipsesource.jshint.ui.builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
</natures>
</projectDescription>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>UmlYangTools</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.eclipsesource.jshint.ui.builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.nodeclipse.ui.NodeNature</nature>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
<nature>tern.eclipse.ide.core.ternnature</nature>
</natures>
</projectDescription>
5 changes: 3 additions & 2 deletions UmlYangTools/xmi2yang/model/yang/augment.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,15 @@ Augment.prototype.writeNode = function (layer){
break;
}
}
uses = PRE + "\tuses " + this.client + ";\r\n";
uses = PRE + "\tcontainer " + this.client + " {\r\n uses " + this.client + ";\r\n";
}

uses=PRE +"\tuses "+this.client+ ";\r\n";
uses=PRE + "\tcontainer " + this.client + " {\r\n uses "+this.client+ ";\r\n";

var s;
s = PRE + name + " {\r\n" +
Util.yangifyName(uses) +
"\t" +description + " }\r\n" +
description + "\t}\r\n";
return s;
};
Expand Down
2 changes: 1 addition & 1 deletion UmlYangTools/xmi2yang/model/yang/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ function Module(name, namespace, imp, pref, org, contact, revis, descrp, fileNam
this.organization = org;
this.contact = contact;
this.revision = revis;
this.description = descrp;
this.description = descrp + "\r\n - The TAPI YANG models included in this TAPI release are a *normative* part of the TAPI SDK.\r\n- The YANG specifications have been generated from the corresponding UML model using the [ONF EAGLE UML2YANG mapping tool]\r\n <https://github.com/OpenNetworkingFoundation/EagleUmlYang>\r\n and further edited manually to comply with the [ONF IISOMI UML2YANG mapping guidelines]\r\n <https://wiki.opennetworking.org/display/OIMT/UML+-+YANG+Guidelines>\r\n - Status of YANG model artifacts can be determined by referring to the corresponding UML artifacts.\r\n As described in the UML models, some artifacts are considered *experimental*, and thus the corresponding YANG artifacts.\r\n - The ONF TAPI release process does not guarantee backward compatibility of YANG models across major versions of TAPI releases.\r\n The YANG model backward compatibility criteria are outlined in section 11 of <https://tools.ietf.org/html/rfc7950>.\r\n YANG models included in this release may not be backward compatible with previous TAPI releases.";
this.fileName = fileName;
this.children = [];

Expand Down
2 changes: 1 addition & 1 deletion UmlYangTools/xmi2yang/model/yang/node.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ Node.prototype.writeNode = function (layer) {
var name = this.nodeType + " " + Util.yangifyName(this.name);
}else if(this.nodeType == "base" ){
// this.name+="-id";
var name = this.nodeType + " " + Util.typeifyName(this.name);
var name = this.nodeType + " " + Util.identityfyName(this.name);
}else{
//this.name = this.name.replace(/\_+/g,'-');
//keep literal names as they are in UML file
Expand Down
4 changes: 2 additions & 2 deletions UmlYangTools/xmi2yang/model/yang/package.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ Package.prototype.writeNode = function (layer) {
}

//var name = "container " + this.name;
var name = "/***********************\r\n* package " + this.name + "\r\n**********************/";
var name = "/**************************\r\n* package " + this.name + "\r\n**************************/";
name = name.replace(/\r\n/g, '\r\n' + PRE);
var descript;
if(!this.description){
Expand All @@ -62,7 +62,7 @@ Package.prototype.writeNode = function (layer) {

}
this.children.map(function(child) {
children += child.writeNode(layer + 1);
children += child.writeNode(layer);
});
}
var uses = "";
Expand Down
11 changes: 9 additions & 2 deletions UmlYangTools/xmi2yang/model/yang/type.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,16 +85,23 @@ type.prototype.writeNode = function (layer) {
var p = /int[0-9]/;
if(p.test(this.name)){
var name = "type " + this.name;
}else{
}
else if (this.name === 'real') {
var name = "type decimal64";
}
else {
var name = "type " + Util.typeifyName(this.name);
}
/* if (this.name !== "enumeration") {
name += ";";
}*/
var s = "";
if(this.path || this.range || this.length || this.children.length){
if(this.path || this.range || this.length || this.children.length || this.name === 'real'){
s = " {\r\n";
var regex = /[^0-9/./*]/;
if(this.name === 'real') {
s += PRE + " fraction-digits 7;\r\n";
}
if(this.range){
/*if(regex.test(this.range) == true){
if(this.range.indexOf('*') !== -1){
Expand Down
6 changes: 6 additions & 0 deletions UmlYangTools/xmi2yang/model/yang/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,10 @@ Util.typeifyName = function(str) {
.replace( /([0-9])\.-([0-9])/g, '$1.$2');
};

Util.identityfyName = function(str) {
return Util.typeifyName(str)
.replace(/-/g,"_")
.toUpperCase();
};

module.exports = Util;
Loading