From 94543eeb612a168281a70b2be09bd97782f47414 Mon Sep 17 00:00:00 2001 From: John Crispin Date: Thu, 9 Feb 2023 09:11:31 +0100 Subject: [PATCH] state: cleanup and document the data model Signed-off-by: John Crispin --- state/gps.yml | 16 ++++++++ state/interface.clients.yml | 22 ++++++----- state/interface.counter.yml | 3 +- state/interface.ipv4-address.yml | 7 ---- state/interface.ipv4.yml | 21 +++++++++++ state/interface.ssid.association.yml | 12 ++++++ state/interface.ssid.yml | 24 ++++++++++++ state/interface.yml | 22 +++++------ state/link-state.yml | 21 +++++++++++ state/{interface.lldp.yml => lldp-peers.yml} | 2 +- state/radio.yml | 37 +++++++++++++++---- state/state.yml | 39 ++++++++++++++++++++ state/unit.yml | 17 ++++++++- system/state.uc | 6 +-- 14 files changed, 206 insertions(+), 43 deletions(-) create mode 100644 state/gps.yml delete mode 100644 state/interface.ipv4-address.yml create mode 100644 state/interface.ipv4.yml create mode 100644 state/link-state.yml rename state/{interface.lldp.yml => lldp-peers.yml} (98%) diff --git a/state/gps.yml b/state/gps.yml new file mode 100644 index 0000000..017a02e --- /dev/null +++ b/state/gps.yml @@ -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. diff --git a/state/interface.clients.yml b/state/interface.clients.yml index b3fde41..3c1883e 100644 --- a/state/interface.clients.yml +++ b/state/interface.clients.yml @@ -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. diff --git a/state/interface.counter.yml b/state/interface.counter.yml index 01f94c4..5ef37b6 100644 --- a/state/interface.counter.yml +++ b/state/interface.counter.yml @@ -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 diff --git a/state/interface.ipv4-address.yml b/state/interface.ipv4-address.yml deleted file mode 100644 index 9f1727a..0000000 --- a/state/interface.ipv4-address.yml +++ /dev/null @@ -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. diff --git a/state/interface.ipv4.yml b/state/interface.ipv4.yml new file mode 100644 index 0000000..338289f --- /dev/null +++ b/state/interface.ipv4.yml @@ -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/" diff --git a/state/interface.ssid.association.yml b/state/interface.ssid.association.yml index 27da346..3702d5f 100644 --- a/state/interface.ssid.association.yml +++ b/state/interface.ssid.association.yml @@ -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: diff --git a/state/interface.ssid.yml b/state/interface.ssid.yml index 1e1e09a..7107c00 100644 --- a/state/interface.ssid.yml +++ b/state/interface.ssid.yml @@ -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/" diff --git a/state/interface.yml b/state/interface.yml index 67ee643..441215e 100644 --- a/state/interface.yml +++ b/state/interface.yml @@ -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/" + diff --git a/state/link-state.yml b/state/link-state.yml new file mode 100644 index 0000000..c27be88 --- /dev/null +++ b/state/link-state.yml @@ -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/" diff --git a/state/interface.lldp.yml b/state/lldp-peers.yml similarity index 98% rename from state/interface.lldp.yml rename to state/lldp-peers.yml index afd7db5..16ea476 100644 --- a/state/interface.lldp.yml +++ b/state/lldp-peers.yml @@ -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. diff --git a/state/radio.yml b/state/radio.yml index 369e9f7..e029aac 100644 --- a/state/radio.yml +++ b/state/radio.yml @@ -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 diff --git a/state/state.yml b/state/state.yml index e73936c..52d4209 100644 --- a/state/state.yml +++ b/state/state.yml @@ -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/" diff --git a/state/unit.yml b/state/unit.yml index 7516a54..8d93407 100644 --- a/state/unit.yml +++ b/state/unit.yml @@ -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 + diff --git a/system/state.uc b/system/state.uc index cc7dcad..69f11ca 100755 --- a/system/state.uc +++ b/system/state.uc @@ -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)