-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This change allows one model to be translated to another model. This is useful if multiple YANG models for the same type of data exist. In this case a back-end super YANG model is created which is a combination of the contributing models, and requests to the individual models are translated into a request of the super model and responses are translated back into the individual requesting models. In the Apteryx data store information only exists for the super model. The translation is controlled by a translating configuration file named {name}.xlat is that a single super mode
- Loading branch information
1 parent
8ea05c1
commit 6ea2295
Showing
5 changed files
with
925 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
xlat_data = {} | ||
|
||
xlat_data.translate_type = function(field, value, dir) | ||
local value1 = value | ||
if field == 'type' then | ||
value1 = tonumber (value) | ||
print("field " .. field) | ||
print("value1 " .. value1) | ||
print("dir " .. dir) | ||
if dir == 'out' then | ||
if value == '1' then | ||
value1 = '3' | ||
else | ||
value1 = '4' | ||
end | ||
print("value1 " .. value1) | ||
else | ||
if value == '3' then | ||
value1 = '1' | ||
else | ||
value1 = '2' | ||
end | ||
end | ||
end | ||
return value1 | ||
end | ||
|
||
return xlat_data | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
/xlat-test/xlat-animals /test/animals/animal | ||
/xlat-test/xlat-animals/xlat-animal /test/animals/animal | ||
/xlat-test/xlat-animals/xlat-animal/*/name /test/animals/animal/*/name | ||
/xlat-test/xlat-animals/xlat-animal/*/type /test/animals/animal/*/type xlat_data.translate_type | ||
/xlat-test/xlat-animals/xlat-animal/*/colour /test/animals/animal/*/colour | ||
/xlat-test/xlat-animals/xlat-animal/*/food /test/animals/animal/*/food | ||
/xlat-test/xlat-animals/xlat-animal/*/toys /test/animals/animal/*/toys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?xml version='1.0' encoding='UTF-8'?> | ||
<MODULE xmlns="http://test.com/ns/yang/xlat-testing" | ||
xmlns:xlat-test="http://test.com/ns/yang/xlat-testing" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="https://github.com/alliedtelesis/apteryx-xml https://github.com/alliedtelesis/apteryx-xml/releases/download/v1.2/apteryx.xsd" | ||
model="xlat-test" organization="Test Ltd" version="2023-01-01"> | ||
<NODE name="xlat-test" help="This is a test node"> | ||
<NODE name="xlat-animals"> | ||
<NODE name="xlat-animal" help="This is a list of animals"> | ||
<NODE name="*" help="The animal entry with key name"> | ||
<NODE name="name" mode="rw" help="This is the name of the animal" /> | ||
<NODE name="type" mode="rw" default="big" help="This is the type of the animal"> | ||
<VALUE name="fast" value="3" /> | ||
<VALUE name="slow" value="4" /> | ||
</NODE> | ||
<NODE name="colour" mode="rw" help="This is the colour of the animal" /> | ||
<NODE name="food"> | ||
<NODE name="*" help="This is a list of food"> | ||
<NODE name="name" mode="rw" help="Food name" /> | ||
<NODE name="type" mode="rw" help="Food type" /> | ||
</NODE> | ||
</NODE> | ||
<NODE name="toys"> | ||
<NODE name="toy" help="This is a leaf list of toys"> | ||
<NODE name="*" mode="rw" help="List of toys" /> | ||
</NODE> | ||
</NODE> | ||
</NODE> | ||
</NODE> | ||
</NODE> | ||
</NODE> | ||
</MODULE> |
Oops, something went wrong.