state: cleanup and document the data model

Signed-off-by: John Crispin <john@phrozen.org>
This commit is contained in:
John Crispin
2023-02-09 09:11:31 +01:00
parent 6056d32a90
commit 94543eeb61
14 changed files with 206 additions and 43 deletions

16
state/gps.yml Normal file
View File

@@ -0,0 +1,16 @@
type: object
description:
This section describes the GPS location of the device.
properties:
latitude:
type: number
description:
The latitude in WGS84.
longitude:
type: number
description:
The longitude in WGS84.
elevation:
type: number
description:
The elevation above sea level in meters.

View File

@@ -2,29 +2,31 @@ type: array
items:
type: object
description:
An explanation about the purpose of this instance.
This section describes a network neighbour.
properties:
mac:
type: string
description:
The MAC address of the neighbour.
ipv4_addresses:
type: array
description:
An explanation about the purpose of this
The IPv4 addresses that the neighbour is known to use.
items:
type: string
ipv6_addresses:
type: array
description:
An explanation about the purpose of this
The IPv4 addresses that the neighbour is known to use.
items:
type: string
mac:
type: string
description:
An explanation about the purpose of this
ports:
type: array
description:
An explanation about the purpose of this
The physical network devices that that the neighbour has been seen on.
items:
description:
An explanation about the purpose
type: string
last_seen:
type: number
description:
How long along was traffic from this neighbour last seen.

View File

@@ -1,7 +1,6 @@
type: object
description:
This section contains the traffic counters of the logical interface. Entries
that have a value of 0 will not be included.
This section contains the traffic counters of the logical interface.
properties:
collisions:
type: number

View File

@@ -1,7 +0,0 @@
type: array
description:
The list of IPv4 addresses being used by this logical interface.
items:
type: string
description:
An IPv4 addreess.

21
state/interface.ipv4.yml Normal file
View File

@@ -0,0 +1,21 @@
type: object
properties:
addresses:
type: array
description:
The list of IPv4 addresses being used by this logical interface.
items:
type: string
description:
An IPv4 addreess.
leasetime:
type: number
description:
This is the leasetime if the IPv4 address of this logical interface was
acquired via DHCPv4.
dhcp_server:
type: string
description:
The IPv4 address of the DHCPv4 server that assigned the active lease.
leases:
$ref: "https://ucentral.io/state/v1/interface/ipv4-lease/"

View File

@@ -80,6 +80,12 @@ items:
type: number
chwidth:
type: number
he:
type: boolean
he_gi:
type: number
he_dcm:
type: number
tx_rate:
type: array
items:
@@ -96,6 +102,12 @@ items:
type: number
chwidth:
type: number
he:
type: boolean
he_gi:
type: number
he_dcm:
type: number
tid_stats:
type: array
items:

View File

@@ -9,10 +9,26 @@ items:
type: string
description:
The BSSID used by this BSS instance.
location:
type: string
description:
The json-schema path within the configuration where this logical interface is located.
phy:
type: string
description:
The unique path identifying the radio
band:
description:
The wireless band that the radio is currently operating on.
type: string
ssid:
type: string
description:
The SSID that we are broadcasting or connecting to.
iface:
type: string
description:
The physical network device used.
mode:
type: string
description:
@@ -30,5 +46,13 @@ items:
properties:
ref:
type: string
frequency:
description:
The list of all frequencies that the radio is currently operating on.
type: array
items:
type: number
associations:
$ref: "https://ucentral.io/state/v1/interface/ssid/association/"
counters:
$ref: "https://ucentral.io/state/v1/interface/counter/"

View File

@@ -1,9 +1,13 @@
type: array
description:
An array containing the runtime state of all logical interfaces.items:
An array containing the runtime state of all logical interfaces.items
items:
type: object
properties:
location:
type: string
description:
The json-schema path within the configuration where this logical interface is located.
uptime:
type: number
description:
@@ -17,11 +21,6 @@ items:
type: string
description:
The upstream NTP server being used by this interface.
ipv4_leasetime:
type: number
description:
This is the leasetime if the IPv4 address of this logical interface was
acquired via DHCPv4.
dns_servers:
type: array
description:
@@ -29,17 +28,16 @@ items:
domain name resolution.
items:
type: string
ipv4_addresses:
$ref: "https://ucentral.io/state/v1/interface/ipv4-address/"
ipv4_leases:
$ref: "https://ucentral.io/state/v1/interface/ipv4-lease/"
ipv4:
$ref: "https://ucentral.io/state/v1/interface/ipv4/"
ipv6_addresses:
$ref: "https://ucentral.io/state/v1/interface/ipv6-address/"
ipv6_leases:
$ref: "https://ucentral.io/state/v1/interface/ipv6-lease/"
clientss:
$ref: "https://ucentral.io/state/v1/interface/clients/"
counters:
$ref: "https://ucentral.io/state/v1/interface/counter/"
ssids:
$ref: "https://ucentral.io/state/v1/interface/ssid/"
lldp_neighbours:
$ref: "https://ucentral.io/state/v1/interface/lldp/"

21
state/link-state.yml Normal file
View File

@@ -0,0 +1,21 @@
type: object
description:
A list of all LLDP peers that this logical interface is connected to.
properties:
carrier:
type: boolean
description:
The physical interfaces carrier state.
speed:
type: number
description:
The speed of the physical link.
duplex:
type: string
description:
The physical links duplex mode.
enum:
- full
- half
counters:
$ref: "https://ucentral.io/state/v1/interface/counter/"

View File

@@ -14,7 +14,7 @@ items:
type: string
description:
The chassis description that our neighbour is announcing.
id:
mac:
type: string
description:
The chassis ID/MAC that our neighbour is announcing.

View File

@@ -5,6 +5,22 @@ description:
items:
type: object
properties:
channel:
description:
The primary channel that the radio is currently operating on.
type: number
channels:
description:
The list of all channels that the radio is currently operating on.
type: array
items:
type: number
frequency:
description:
The list of all frequencies that the radio is currently operating on.
type: array
items:
type: number
channel_width:
type: number
description:
@@ -15,14 +31,21 @@ items:
- 80
- 160
- 320
frequencies:
type: array
description:
The list of channels frquencies, that the unit is currently operating
on. Anything other than 20MHz will list several frequencies here.
items:
type: number
tx_power:
type: number
description:
The currently configure TX power of the radio in dBm.
phy:
type: string
description:
The unique path identifying the radio
band:
description:
The wireless band that the radio is currently operating on.
type: array
items:
type: string
temperature:
description:
The current temperature of the Wireless radio.
type: number

View File

@@ -3,9 +3,48 @@ $schema: http://json-schema.org/draft-07/schema#
description: OpenWrt uCentral state schema
type: object
properties:
version:
type: number
const: 1
uuid:
description:
The unique ID of the configuration. This is the unix timestamp of when the config was created.
type: integer
serial:
description:
The unique serial number of the device.
type: string
unit:
$ref: "https://ucentral.io/state/v1/unit/"
gps:
$ref: "https://ucentral.io/state/v1/gps/"
radios:
$ref: "https://ucentral.io/state/v1/radio/"
interfaces:
$ref: "https://ucentral.io/state/v1/interface/"
lldp-peers:
type: object
properties:
upstream:
type: object
patternProperties:
"^(eth|lan|wan)[0-9]*$":
$ref: "https://ucentral.io/state/v1/lldp-peers/"
downstream:
type: object
patternProperties:
"^(eth|lan|wan)[0-9]*$":
$ref: "https://ucentral.io/state/v1/lldp-peers/"
link-state:
type: object
properties:
upstream:
type: object
patternProperties:
"^(eth|lan|wan)[0-9]*$":
$ref: "https://ucentral.io/state/v1/link-state/"
downstream:
type: object
patternProperties:
"^(eth|lan|wan)[0-9]*$":
$ref: "https://ucentral.io/state/v1/link-state/"

View File

@@ -26,7 +26,22 @@ properties:
type: number
description:
The total amount of memory.
cached:
type: number
description:
The total amount of cached memory.
buffered:
type: number
description:
The total amount of buffered memory.
uptime:
type: number
description:
The number of seconds since the unit last booted..
The number of seconds since the unit last booted.
temperature:
description:
The average and maximum thermal reading from the CPU.
type: array
items:
type: number

View File

@@ -103,12 +103,12 @@ try {
if (length(chassis.name))
peer.name = chassis.name[0].value;
if (length(chassis.mgmt_ip)) {
if (length(chassis['mgmt-ip'])) {
let ipaddr = [];
for (let ip in chassis["mgmt-ip"])
push(ipaddr, ip.value);
peer.ips = ips;
peer.management_ips = ips;
}
if (length(chassis.capability)) {
@@ -180,7 +180,7 @@ for (let radio, data in wifistatus) {
radio.channel = vap.channel[0];
radio.channels = uniq(vap.channel);
radio.frequency = uniq(vap.frequency);
radio.channel_width = vap.ch_width;
radio.channel_width = +vap.ch_width;
radio.tx_power = vap.tx_power;
radio.survey = [];
for (let k, v in survey.survey)