-
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.
- Loading branch information
1 parent
04adebc
commit c78b5b6
Showing
6 changed files
with
172 additions
and
13 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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
#<namespace> <root node> | ||
http://test.com/ns/yang/testing-2 /t2:test | ||
http://test.com/ns/yang/testing-3 /t3:test | ||
http://test.com/ns/yang/testing-3 /t3:test | ||
http://test.com/ns/yang/testing-4 /t4:test |
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,56 @@ | ||
local apteryx = require('apteryx') | ||
|
||
local function reboot(path, input) | ||
if input["language"] ~= nil then | ||
-- generate results for test cases | ||
if input["language"] ~= 'en-US' then | ||
if input["language"]:find("-") then | ||
return false, "do not support language " .. input["language"] | ||
elseif input["language"] == "" then | ||
return false, false, false | ||
else | ||
return false | ||
end | ||
end | ||
end | ||
apteryx.set_tree ("/system/reboot-info", { | ||
["reboot-time"] = input["delay"] or nil, | ||
["message"] = input["message"] or nil, | ||
["language"] = input["language"] or nil, | ||
}) | ||
return true | ||
end | ||
|
||
local function get_reboot_info(path, input) | ||
local info = apteryx.get_tree("/system/reboot-info") | ||
return { | ||
["reboot-time"] = info["reboot-time"] or nil, | ||
["message"] = info["message"] or nil, | ||
["language"] = info["language"] or nil, | ||
} | ||
end | ||
|
||
local function reset_state(path, input) | ||
local delay = input["delay"] | ||
apteryx.set("/t4:test/state/age", delay) | ||
return true | ||
end | ||
|
||
local function get_reset_time(path, input) | ||
return { ["last-reset"] = apteryx.get("/t4:test/state/age") } | ||
end | ||
|
||
local function set_age(path, input) | ||
local user = path:match('/t4:test/state/users/([^/]+)') | ||
local age = input["age"] | ||
apteryx.set("/t4:test/state/users/" .. user .. "/age", age) | ||
return true | ||
end | ||
|
||
return { | ||
["/operations/t4:reboot"] = reboot, | ||
["/operations/t4:get-reboot-info"] = get_reboot_info, | ||
["/t4:test/state/reset"] = reset_state, | ||
["/t4:test/state/get-last-reset-time"] = get_reset_time, | ||
["/t4:test/state/users/*/set-age"] = set_age, | ||
} |
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,50 @@ | ||
<?xml version='1.0' encoding='UTF-8'?> | ||
<MODULE xmlns="http://test.com/ns/yang/testing-4" | ||
xmlns:test="http://test.com/ns/yang/testing" | ||
xmlns:t4="http://test.com/ns/yang/testing-4" | ||
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="testing-4" organization="Test 4 Ltd" version="2024-02-01"> | ||
<NODE name="test" help="This is a test node in the testing-4 namespace"> | ||
<NODE name="state" help="State"> | ||
<NODE name="age" mode="r" help="a string"/> | ||
<NODE name="reset" mode="wx" help="Reset state"> | ||
<NODE name="input" help="Input parameters"> | ||
<NODE name="delay" mode="w" help="Number of seconds to wait before starting the reset" range="0..4294967295"/> | ||
</NODE> | ||
</NODE> | ||
<NODE name="get-last-reset-time" mode="rwx" help="Retrieve the last interface reset time"> | ||
<NODE name="output" help="Output parameters"> | ||
<NODE name="last-reset" mode="r" help="Time of the last reset" range="0..4294967295"/> | ||
</NODE> | ||
</NODE> | ||
<NODE name="users" help="This is a list of users"> | ||
<NODE name="*" help="The user entry with key name"> | ||
<NODE name="name" mode="rw" help="This is the name of the user"/> | ||
<NODE name="age" mode="rw" help="Age of the user" range="0..4294967295"/> | ||
<NODE name="set-age" mode="wx" help="Set the users age"> | ||
<NODE name="input" help="Input parameters"> | ||
<NODE name="age" mode="w" help="New age" range="0..4294967295"/> | ||
</NODE> | ||
</NODE> | ||
</NODE> | ||
</NODE> | ||
</NODE> | ||
</NODE> | ||
<test:NODE name="operations" help="Container for all operation resources."> | ||
<NODE name="reboot" mode="wx" help="Reboot operation."> | ||
<NODE name="input" help="Input parameters"> | ||
<NODE name="delay" mode="w" help="Number of seconds to wait before initiating the reboot operation." range="0..4294967295"/> | ||
<NODE name="message" mode="w" help="Log message to display when reboot is started."/> | ||
<NODE name="language" mode="w" help="Language identifier string."/> | ||
</NODE> | ||
</NODE> | ||
<NODE name="get-reboot-info" mode="rx" help="Retrieve parameters used in the last reboot operation."> | ||
<NODE name="output" help="Output parameters"> | ||
<NODE name="reboot-time" mode="r" help="The 'delay' parameter used in the last reboot operation." range="0..4294967295"/> | ||
<NODE name="message" mode="r" help="The 'message' parameter used in the last reboot operation."/> | ||
<NODE name="language" mode="r" help="The 'language' parameter used in the last reboot operation."/> | ||
</NODE> | ||
</NODE> | ||
</test:NODE> | ||
</MODULE> |
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