mirror of
https://github.com/Telecominfraproject/ols-ucentral-schema.git
synced 2025-10-29 17:22:23 +00:00
@@ -426,7 +426,8 @@ let ethernet = {
|
||||
|
||||
calculate_name: function(interface) {
|
||||
let vid = interface.vlan.id;
|
||||
|
||||
if (interface.admin_ui)
|
||||
return 'admin_ui';
|
||||
return (interface.role == 'upstream' ? 'up' : 'down') + interface.index + 'v' + vid;
|
||||
},
|
||||
|
||||
|
||||
40
renderer/templates/admin_ui.uc
Normal file
40
renderer/templates/admin_ui.uc
Normal file
@@ -0,0 +1,40 @@
|
||||
{%
|
||||
let admin_ui = state.services?.admin_ui;
|
||||
if (!admin_ui?.wifi_ssid)
|
||||
return;
|
||||
|
||||
let interface = {
|
||||
admin_ui: true,
|
||||
name: 'Admin-UI',
|
||||
role: 'downstream',
|
||||
auto_start: 0,
|
||||
services: [ 'ssh', 'http' ],
|
||||
ipv4: {
|
||||
addressing: 'static',
|
||||
subnet: '10.254.254.1/24',
|
||||
dhcp: {
|
||||
lease_first: 10,
|
||||
lease_count: 10,
|
||||
lease_time: '6h'
|
||||
}
|
||||
},
|
||||
ssids: [
|
||||
{
|
||||
name: admin_ui.wifi_ssid,
|
||||
wifi_bands: [ '2G', '5G' ],
|
||||
bss_mode: 'ap',
|
||||
encryption: {
|
||||
proto: 'none'
|
||||
}
|
||||
}
|
||||
],
|
||||
};
|
||||
|
||||
if (admin_ui.wifi_key) {
|
||||
interface.ssids[0].encryption.proto = 'psk2';
|
||||
interface.ssids[0].encryption.key = admin_ui.wifi_key;
|
||||
}
|
||||
push(state.interfaces, interface);
|
||||
%}
|
||||
|
||||
set state.ui.offline_trigger={{ admin_ui.offline_trigger }}
|
||||
@@ -15,6 +15,7 @@ set network.{{ afname }}.ifname={{ netdev }}
|
||||
set network.{{ afname }}.metric={{ interface.metric }}
|
||||
set network.{{ afname }}.mtu={{ interface.mtu }}
|
||||
set network.{{ afname }}.type={{ interface.type }}
|
||||
set network.{{ afname }}.auto={{ interface.auto_start }}
|
||||
{% if (ipv4_mode == 'static' || ipv6_mode == 'static'): %}
|
||||
set network.{{ afname }}.proto=static
|
||||
{% elif ((length(afnames) == 1 || afidx == 0) && ipv4_mode == 'dynamic'): %}
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
die('Configuration must contain a valid UUID. Rejecting whole file');
|
||||
}
|
||||
|
||||
include('admin_ui.uc');
|
||||
|
||||
// reject the config if there is no valid upstream configuration
|
||||
let upstream;
|
||||
for (let i, interface in state.interfaces) {
|
||||
|
||||
19
schema/service.admin-ui.yml
Normal file
19
schema/service.admin-ui.yml
Normal file
@@ -0,0 +1,19 @@
|
||||
type: object
|
||||
properties:
|
||||
wifi-ssid:
|
||||
description:
|
||||
The name of the admin ssid.
|
||||
type: string
|
||||
default: Maverick
|
||||
maxLength: 32
|
||||
minLength: 1
|
||||
wifi-key:
|
||||
description:
|
||||
The Pre Shared Key (PSK) that is used for encryption on the BSS.
|
||||
type: string
|
||||
maxLength: 63
|
||||
minLength: 8
|
||||
offline-trigger:
|
||||
description:
|
||||
The admin-ui will be spawned when this offline threshold was exceeded.
|
||||
type: number
|
||||
@@ -43,3 +43,5 @@ properties:
|
||||
$ref: 'https://ucentral.io/schema/v1/service/gps/'
|
||||
dhcp-relay:
|
||||
$ref: 'https://ucentral.io/schema/v1/service/dhcp-relay/'
|
||||
admin-ui:
|
||||
$ref: 'https://ucentral.io/schema/v1/service/admin-ui/'
|
||||
|
||||
@@ -8778,6 +8778,73 @@ function instantiateServiceDhcpRelay(location, value, errors) {
|
||||
return value;
|
||||
}
|
||||
|
||||
function instantiateServiceAdminUi(location, value, errors) {
|
||||
if (type(value) == "object") {
|
||||
let obj = {};
|
||||
|
||||
function parseWifiSsid(location, value, errors) {
|
||||
if (type(value) == "string") {
|
||||
if (length(value) > 32)
|
||||
push(errors, [ location, "must be at most 32 characters long" ]);
|
||||
|
||||
if (length(value) < 1)
|
||||
push(errors, [ location, "must be at least 1 characters long" ]);
|
||||
|
||||
}
|
||||
|
||||
if (type(value) != "string")
|
||||
push(errors, [ location, "must be of type string" ]);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
if (exists(value, "wifi-ssid")) {
|
||||
obj.wifi_ssid = parseWifiSsid(location + "/wifi-ssid", value["wifi-ssid"], errors);
|
||||
}
|
||||
else {
|
||||
obj.wifi_ssid = "Maverick";
|
||||
}
|
||||
|
||||
function parseWifiKey(location, value, errors) {
|
||||
if (type(value) == "string") {
|
||||
if (length(value) > 63)
|
||||
push(errors, [ location, "must be at most 63 characters long" ]);
|
||||
|
||||
if (length(value) < 8)
|
||||
push(errors, [ location, "must be at least 8 characters long" ]);
|
||||
|
||||
}
|
||||
|
||||
if (type(value) != "string")
|
||||
push(errors, [ location, "must be of type string" ]);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
if (exists(value, "wifi-key")) {
|
||||
obj.wifi_key = parseWifiKey(location + "/wifi-key", value["wifi-key"], errors);
|
||||
}
|
||||
|
||||
function parseOfflineTrigger(location, value, errors) {
|
||||
if (!(type(value) in [ "int", "double" ]))
|
||||
push(errors, [ location, "must be of type number" ]);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
if (exists(value, "offline-trigger")) {
|
||||
obj.offline_trigger = parseOfflineTrigger(location + "/offline-trigger", value["offline-trigger"], errors);
|
||||
}
|
||||
|
||||
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 = {};
|
||||
@@ -8862,6 +8929,10 @@ function instantiateService(location, value, errors) {
|
||||
obj.dhcp_relay = instantiateServiceDhcpRelay(location + "/dhcp-relay", value["dhcp-relay"], errors);
|
||||
}
|
||||
|
||||
if (exists(value, "admin-ui")) {
|
||||
obj.admin_ui = instantiateServiceAdminUi(location + "/admin-ui", value["admin-ui"], errors);
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
@@ -3131,6 +3131,25 @@
|
||||
}
|
||||
}
|
||||
},
|
||||
"service.admin-ui": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"wifi-ssid": {
|
||||
"type": "string",
|
||||
"default": "Maverick",
|
||||
"maxLength": 32,
|
||||
"minLength": 1
|
||||
},
|
||||
"wifi-key": {
|
||||
"type": "string",
|
||||
"maxLength": 63,
|
||||
"minLength": 8
|
||||
},
|
||||
"offline-trigger": {
|
||||
"type": "number"
|
||||
}
|
||||
}
|
||||
},
|
||||
"service": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
@@ -3193,6 +3212,9 @@
|
||||
},
|
||||
"dhcp-relay": {
|
||||
"$ref": "#/$defs/service.dhcp-relay"
|
||||
},
|
||||
"admin-ui": {
|
||||
"$ref": "#/$defs/service.admin-ui"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user