diff --git a/schema/service.airtime-policies.yml b/schema/service.airtime-policies.yml new file mode 100644 index 0000000..dea9d0c --- /dev/null +++ b/schema/service.airtime-policies.yml @@ -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 diff --git a/schema/service.yml b/schema/service.yml index 8b3c430..1bc8a79 100644 --- a/schema/service.yml +++ b/schema/service.yml @@ -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/" diff --git a/schemareader.uc b/schemareader.uc index 20b8aa3..1618374 100644 --- a/schemareader.uc +++ b/schemareader.uc @@ -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; } diff --git a/ucentral.schema.json b/ucentral.schema.json index 9e2e808..35113ee 100644 --- a/ucentral.schema.json +++ b/ucentral.schema.json @@ -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" } } },