mirror of
https://github.com/Telecominfraproject/ols-ucentral-schema.git
synced 2025-11-03 11:37:46 +00:00
@@ -1,11 +1,11 @@
|
|||||||
# usync-json-schema
|
# ucentral-json-schema
|
||||||
Collection of json schemas and utpl files used by usync for validating
|
Collection of json schemas and utpl files used by ucentral for validating
|
||||||
the datamodel and rendering incoming cfg json into uci batch sequences.
|
the datamodel and rendering incoming cfg json into uci batch sequences.
|
||||||
|
|
||||||
### Dependencies:
|
### Dependencies:
|
||||||
In order to run the test cases you will need the following tools
|
In order to run the test cases you will need the following tools
|
||||||
* utpl
|
* utpl
|
||||||
* usync-jsonschema
|
* ucentral-jsonschema
|
||||||
* jsonlint-php
|
* jsonlint-php
|
||||||
* pip3 install jsonschema2md
|
* pip3 install jsonschema2md
|
||||||
* pip3 install json-schema-for-humans
|
* pip3 install json-schema-for-humans
|
||||||
|
|||||||
@@ -65,7 +65,7 @@ for (key in cfg) {
|
|||||||
if (key in ["uuid", "ssid"])
|
if (key in ["uuid", "ssid"])
|
||||||
continue;
|
continue;
|
||||||
try {
|
try {
|
||||||
include(sprintf("cfg_%s.tpl", key));
|
include(sprintf("cfg_%s.uc", key));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
failed = true;
|
failed = true;
|
||||||
fails[key] = e;
|
fails[key] = e;
|
||||||
@@ -75,7 +75,7 @@ for (key in cfg) {
|
|||||||
|
|
||||||
if (failed) {
|
if (failed) {
|
||||||
ctx = ubus.connect();
|
ctx = ubus.connect();
|
||||||
ctx.call("usync", "log", {"error": "failed to apply config", "data": fails});
|
ctx.call("ucentral", "log", {"error": "failed to apply config", "data": fails});
|
||||||
ctx.disconnect();
|
ctx.disconnect();
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
{%
|
{%
|
||||||
if (!cmd.url) {
|
if (!cmd.url) {
|
||||||
warn("usync-upgrade: invalid FW URL\n");
|
warn("ucentral-upgrade: invalid FW URL\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
path = "/tmp/usync.upgrade";
|
path = "/tmp/ucentral.upgrade";
|
||||||
fs.popen(sprintf('wget %s -O %s', cmd.url, path), 'r').close();
|
fs.popen(sprintf('wget %s -O %s', cmd.url, path), 'r').close();
|
||||||
|
|
||||||
ctx = ubus.connect();
|
ctx = ubus.connect();
|
||||||
@@ -11,8 +11,8 @@
|
|||||||
|
|
||||||
if (!fw.valid) {
|
if (!fw.valid) {
|
||||||
ctx = ubus.connect();
|
ctx = ubus.connect();
|
||||||
ctx.call("usync", "log", {"error": "firmware file validation failed", "data": fw});
|
ctx.call("ucentral", "log", {"error": "firmware file validation failed", "data": fw});
|
||||||
warn("usync-upgrade: firmware file validation failed\n");
|
warn("ucentral-upgrade: firmware file validation failed\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
fs.popen(sprintf('/sbin/sysupgrade %s', path), 'r').close();
|
fs.popen(sprintf('/sbin/sysupgrade %s', path), 'r').close();
|
||||||
@@ -12,5 +12,5 @@ yaml2json schema/wifi-ssid.yml wifi-ssid.schema
|
|||||||
yaml2json schema/steer.yml steer.schema
|
yaml2json schema/steer.yml steer.schema
|
||||||
./merge-schema.py
|
./merge-schema.py
|
||||||
mkdir -p docs
|
mkdir -p docs
|
||||||
jsonschema2md usync.schema.json docs/usync-schema.md
|
jsonschema2md ucentral.schema.json docs/ucentral-schema.md
|
||||||
generate-schema-doc usync.schema.json docs/usync-schema.html
|
generate-schema-doc ucentral.schema.json docs/ucentral-schema.html
|
||||||
|
|||||||
@@ -3,9 +3,9 @@
|
|||||||
import json
|
import json
|
||||||
|
|
||||||
merge = {
|
merge = {
|
||||||
"$id": "https://openwrt.org/usync.schema.json",
|
"$id": "https://openwrt.org/ucentral.schema.json",
|
||||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||||
"description": "OpenWrt uSync schema",
|
"description": "OpenWrt uCentral schema",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"uuid": { "type": "integer" }
|
"uuid": { "type": "integer" }
|
||||||
@@ -23,10 +23,10 @@ def schema_merge(name, path):
|
|||||||
|
|
||||||
def schema_write():
|
def schema_write():
|
||||||
try:
|
try:
|
||||||
with open(f"usync.schema.json", 'w') as outfile:
|
with open(f"ucentral.schema.json", 'w') as outfile:
|
||||||
json.dump(merge, outfile, indent=True)
|
json.dump(merge, outfile, indent=True)
|
||||||
except:
|
except:
|
||||||
print("failed to write usync.schema.json")
|
print("failed to write ucentral.schema.json")
|
||||||
|
|
||||||
schema_merge("network", "network.schema")
|
schema_merge("network", "network.schema")
|
||||||
schema_merge("phy", "wifi-phy.schema")
|
schema_merge("phy", "wifi-phy.schema")
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"$id": "https://openwrt.org/usync.schema.json",
|
"$id": "https://openwrt.org/ucentral.schema.json",
|
||||||
"$schema": "http://json-schema.org/draft-07/schema#",
|
"$schema": "http://json-schema.org/draft-07/schema#",
|
||||||
"description": "OpenWrt uSync schema",
|
"description": "OpenWrt uCentral schema",
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
"uuid": {
|
"uuid": {
|
||||||
Reference in New Issue
Block a user