schema: add airtime-policies support

Signed-off-by: John Crispin <john@phrozen.org>
This commit is contained in:
John Crispin
2021-08-05 10:29:15 +02:00
parent d6c94d6468
commit 530cc5a0cb
4 changed files with 96 additions and 0 deletions

View File

@@ -0,0 +1,20 @@
description:
This section describes the airtime policies that are used to set the weight
of attached stations
type: object
properties:
dns-match:
description:
When a UE reolves one of these DNS entries, the resulting IP will get tracked
and traffic to that IP will be assigned a different weight.
type: array
items:
type: string
examples:
- "*.voice.example.com"
dns-weight:
description:
The airtime weight that shall be applied to a UE when it has open connections
to a server listed in "dns-match"
type: integer
default: 256

View File

@@ -31,3 +31,5 @@ properties:
$ref: "https://ucentral.io/schema/v1/service/data-plane/"
wifi-steering:
$ref: "https://ucentral.io/schema/v1/service/wifi-steering/"
airtime-policies:
$ref: "https://ucentral.io/schema/v1/service/airtime-policies/"

View File

@@ -4693,6 +4693,55 @@ function instantiateServiceWifiSteering(location, value, errors) {
return value;
}
function instantiateServiceAirtimePolicies(location, value, errors) {
if (type(value) == "object") {
let obj = {};
function parseDnsMatch(location, value, errors) {
if (type(value) == "array") {
function parseItem(location, value, errors) {
if (type(value) != "string")
push(errors, [ location, "must be of type string" ]);
return value;
}
return map(value, (item, i) => parseItem(location + "/" + i, item, errors));
}
if (type(value) != "array")
push(errors, [ location, "must be of type array" ]);
return value;
}
if (exists(value, "dns-match")) {
obj.dns_match = parseDnsMatch(location + "/dns-match", value["dns-match"], errors);
}
function parseDnsWeight(location, value, errors) {
if (type(value) != "int")
push(errors, [ location, "must be of type integer" ]);
return value;
}
if (exists(value, "dns-weight")) {
obj.dns_weight = parseDnsWeight(location + "/dns-weight", value["dns-weight"], errors);
}
else {
obj.dns_weight = 256;
}
return obj;
}
if (type(value) != "object")
push(errors, [ location, "must be of type object" ]);
return value;
}
function instantiateService(location, value, errors) {
if (type(value) == "object") {
let obj = {};
@@ -4753,6 +4802,10 @@ function instantiateService(location, value, errors) {
obj.wifi_steering = instantiateServiceWifiSteering(location + "/wifi-steering", value["wifi-steering"], errors);
}
if (exists(value, "airtime-policies")) {
obj.airtime_policies = instantiateServiceAirtimePolicies(location + "/airtime-policies", value["airtime-policies"], errors);
}
return obj;
}

View File

@@ -1783,6 +1783,24 @@
}
}
},
"service.airtime-policies": {
"type": "object",
"properties": {
"dns-match": {
"type": "array",
"items": {
"type": "string",
"examples": [
"*.voice.example.com"
]
}
},
"dns-weight": {
"type": "integer",
"default": 256
}
}
},
"service": {
"type": "object",
"properties": {
@@ -1827,6 +1845,9 @@
},
"wifi-steering": {
"$ref": "#/$defs/service.wifi-steering"
},
"airtime-policies": {
"$ref": "#/$defs/service.airtime-policies"
}
}
},