Skip to content

Commit

Permalink
ucentral-schema: add initial version of the reworked data model
Browse files Browse the repository at this point in the history
Signed-off-by: John Crispin <john@phrozen.org>
  • Loading branch information
blogic committed Apr 15, 2021
1 parent b4d02b3 commit 43ed9dc
Show file tree
Hide file tree
Showing 29 changed files with 761 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
*.schema
docs/
new/ucentral.schema.json
new/ucentral.schema.pretty.json
new/docs/
new/central.schema.json
new/ucentral.schema.pretty.json
6 changes: 6 additions & 0 deletions new/config-raw.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
description:
This object allows passing raw uci commands, that get applied after all the
other configuration was ben generated.
type: array
items:
type: string
11 changes: 11 additions & 0 deletions new/definitions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
description:
This section is used to define templates that can be reference by a
configuration. This avoids duplication of data. A RADIUS server can be
defined here for example and then referenced by several SSIDs.
type: object
properties:
wireless-encryption:
description:
A wireless encryption template.
type: object
$ref: "#/interfaces/ssids/encryption"
5 changes: 5 additions & 0 deletions new/generate.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/sh

./merge-schema.py
mkdir -p docs
generate-schema-doc ucentral.schema.pretty.json docs/ucentral-schema.html
15 changes: 15 additions & 0 deletions new/globals.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
description:
A device has certain global properties that are used to derive parts of
the final configuration that gets applied.
type: object
properties:
ipv4-network:
description:
Define the IPv4 range that is delegatable to the downstream interfaces
This is described as a CIDR block. (192.168.0.0/16, 172.16.128/17)
type: string
ipv6-network:
description:
Define the IPv6 range that is delegatable to the downstream interfaces
This is described as a CIDR block. (fdca:1234:4567::/48)
type: string
40 changes: 40 additions & 0 deletions new/merge-schema.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/usr/bin/env python3

import yaml
import json

def schema_filename(list):
file = list.split("v1/")
file.pop(0)
return file[0].replace("/", ".") + "yml"

def schema_load(filename):
with open(filename) as stream:
try:
schema = yaml.safe_load(stream)
return schema
except yaml.YAMLError as exc:
print(exc)

def schema_compile(input, output, tiny):
for k in input:
if tiny and k == "description":
continue
if isinstance(input[k], dict):
if k not in output:
output[k] = {}
schema_compile(input[k], output[k], tiny)
elif k == "$ref" and input[k].startswith("https://"):
output.update(schema_compile(schema_load(schema_filename(input[k])), {}, tiny))
elif k == "$ref" and not tiny:
output["properties"] = {"reference": {"type": "string"}}
else:
output[k] = input[k]
return output

def schema_generate(filename, tiny):
with open(filename, 'w') as outfile:
json.dump(schema_compile(schema_load("ucentral.yml"), {}, tiny), outfile, ensure_ascii = tiny and False or True, indent = tiny and 0 or 4)

schema_generate('ucentral.schema.json', 1)
schema_generate('ucentral.schema.pretty.json', 0)
36 changes: 36 additions & 0 deletions new/metrics.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
description:
There are several types of mertics that shall be reported in certain
intervals. This section provides a granual configuration.
type: object
properties:
statistics:
description:
Statistics are traffic counters, neighbor tables, ...
type: object
properties:
interval:
description:
The reporting interval defined in seconds.
type: number
types:
description:
A list of names of subsystems that shall be reported periodically.
type: array
items:
types: string
health:
description:
Health check gets executed periodically and will report a health value
between 0-100 indicating how healthy the device thinks it is
type: object
properties:
interval:
description:
The reporting interval defined in seconds.
type: number
types:
description:
A list of names of subsystems that shall be reported periodically.
type: array
items:
types: string
16 changes: 16 additions & 0 deletions new/radio.he.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
description:
This section describes the HE specific configuration options of the BSS.
properties:
multiple-bssid:
description:
Enabling this option will make the PHY broadcast its BSSs using the multiple BSSID beacon IE.
type: boolean
ema:
description:
Enableing this option will make the PHY broadcast its multiple BSSID beacons using EMA.
type: boolean
bss-color:
description:
This enables BSS Coloring on the PHY. setting it to 0 disables the feature 1-63 sets the color
and 64 will make hostapd pick a random color.
type: boolean
102 changes: 102 additions & 0 deletions new/radio.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
description:
Describe a physical radio on the AP. A radio s be parent to several VAPs.
They all share the same physical properties.
type: array
items:
type: object
properties:
band:
type: string
enum:
- 2
- 5
- 5u
- 5l
- 6
bandwidth:
description:
Specifies a narrow channel width in MHz, possible values are: 5, 10, 20.
type: number
enum:
- 5
- 10
- 20
channel:
description:
Specifies the wireless channel to use. A value of 0 starts the ACS
algorithm.
type: number
maximum: 171
minimum: 0
country:
description:
Specifies the country code, affects the available channels and
transmission powers.
type: string
maxLength: 2
minLength: 2
channel-mode:
description:
Define the ideal channel mode that the radio shall use. This can be 802.11n, 802.11ac
or 802.11ax. This is just a hint for the AP. If the requested value is not supported
then the AP will use the highest common denominator.
type: string
enum:
- HT
- VHT
- HE
channel-width:
description:
The channel width that the radio shall use. This is just a hint for the AP. If the
requested value is not supported then the AP will use the highest common denominator.
type: string
enum:
- 20
- 40
- 80
- 160
- 8080
require-mode:
description:
Sations that do no fulfill these HT modes will be rejected.
type: array
items:
type: string
enum:
- HT
- VHT
- HE
mimo:
description:
This option allows configuring the antenna pairs that shall be used.
This is just a hint for the AP. If the requested value is not supported
then the AP will use the highest common denominator.
type: string
enum:
- 1x1
- 2x2
- 3x3
- 4x4
- 5x5
- 6x6
- 7x7
- 8x8
tx-power:
description:
This option specifies the transmission power in dBm
type: number
maximum: 30
minimum: 0
legacy-rates:
description:
Allow legacy 802.11b data rates.
type: boolean
default: false
he-settings:
$ref: "https://ucentral.io/schema/v1/radio/he/"
hostapd-iface-raw:
description:
This array allows passing raw hostapd.conf lines.
type: array
items:
type: string
10 changes: 10 additions & 0 deletions new/services.lldp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
type: object
properties:
describe:
description:
The LLDP description field. If set to "auto" it will be derived from unit.name.
type: string
location:
description:
The LLDP location field. If set to "auto" it will be derived from unit.location.
type: string
28 changes: 28 additions & 0 deletions new/services.log.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
description:
This section can be used to configure remote syslog support.
type: object
properties:
host:
description:
IP address of a syslog server to which the log messages should be
sent in addition to the local destination.
type: string
port:
description:
Port number of the remote syslog server specified with log_ip.
type: number
maximum: 65535
minimum: 100
proto:
description:
Sets the protocol to use for the connection, either tcp or udp.
type: string
enum:
- tcp
- udp
size:
description:
Size of the file based log buffer in KiB. This value is used as the fallback
value for log_buffer_size if the latter is not specified.
type: number
minimum: 32
9 changes: 9 additions & 0 deletions new/services.mdns.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
description:
This section can be used to configure the MDNS server.
type: object
properties:
enable:
description:
Enable this option if you would like to enable the MDNS server on the unit.
type: boolean
default: false
11 changes: 11 additions & 0 deletions new/services.ntp.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
type: object
description:
This section can be used to setup the upstream NTP servers.
properties:
servers:
description:
This is an array of URL/IP of the upstream NTP servers that the unit shall use to
acquire its current time.
type: array
items:
type: string
21 changes: 21 additions & 0 deletions new/services.rtty.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
description:
This section can be used to setup a SSH server on the AP.
type: object
properties:
enable:
description:
Shall the service be enabled.
type: boolean
host:
description:
The server that the AP shal to connect to.
type: string
port:
description:
This option defines the port that we connect to.
type: number
maximum: 65535
token:
description:
The security token that we use to authenticate with the server.
type: string
26 changes: 26 additions & 0 deletions new/services.ssh.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
description:
This section can be used to setup a SSH server on the AP.
type: object
properties:
enable:
description:
Enable this option if you would like to enable the SSH server on the unit.
type: boolean
default: false
port:
description:
This option defines which port the SSH server shall be available on.
type: number
maximum: 65535
authorized-keys:
description:
This allows the upload of public ssh keys. Keys need to be seperated by a
newline.
type: array
items:
type: string
password-authentication:
description:
This option defines if password authentication shall be enabled. If set
to false, only ssh key based authentication is possible.
type: boolean
8 changes: 8 additions & 0 deletions new/services.wifi-steering.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
description:
This section describes the band steering behaviour of the unit.
type: object
properties:
network:
description:
The network that shall be used to communicate with the other peers.
type: string
19 changes: 19 additions & 0 deletions new/services.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
description:
This section describes all of the services that may be present on the AP.
Each service is then referenced via its name inside an interface, ssid, ...
type: object
properties:
lldp:
$ref: "https://ucentral.io/schema/v1/services/lldp/"
ssh:
$ref: "https://ucentral.io/schema/v1/services/ssh/"
ntp:
$ref: "https://ucentral.io/schema/v1/services/ntp/"
mdns:
$ref: "https://ucentral.io/schema/v1/services/mdns/"
rtty:
$ref: "https://ucentral.io/schema/v1/services/rtty/"
log:
$ref: "https://ucentral.io/schema/v1/services/log/"
wifi-steering:
$ref: "https://ucentral.io/schema/v1/services/wifi-steering/"
Loading

0 comments on commit 43ed9dc

Please sign in to comment.