1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
'use strict';
'require view';
'require ui';
'require form';
'require uci';
return view.extend({
load: function() {
return Promise.all([
uci.load('keepalived'),
]);
},
renderTrackScript: function(m) {
var s, o;
var vrrp_scripts;
vrrp_scripts = uci.sections('keepalived', 'vrrp_script');
if (vrrp_scripts == '') {
ui.addNotification(null, E('p', _('VRRP Scripts must be configured for Track Scripts')));
}
s = m.section(form.GridSection, 'track_script', _('Track Script'),
_('Tracking scripts would be referenced from VRRP instances'));
s.anonymous = true;
s.addremove = true;
s.nodescriptions = true;
o = s.option(form.Value, 'name', _('Name'));
o.optional = false;
o.rmempty = false;
o = s.option(form.ListValue, 'value', _('VRRP Script'));
o.optional = false;
o.rmempty = false;
if (vrrp_scripts != '') {
for (i = 0; i < vrrp_scripts.length; i++) {
o.value(vrrp_scripts[i]['name']);
}
}
o = s.option(form.Value, 'weight', _('Weight'));
o.optional = true;
o.datatype = 'and(integer, range(-253, 253))';
o = s.option(form.ListValue, 'direction', _('Direction'));
o.optional = true;
o.default = '';
o.value('reverse', _('Reverse'));
o.value('noreverse', _('No Reverse'));
},
renderVRRPScript: function(m) {
var s, o;
s = m.section(form.GridSection, 'vrrp_script', _('VRRP Script'),
_('Adds a script to be executed periodically. Its exit code will be recorded for all VRRP instances and sync groups which are monitoring it'));
s.anonymous = true;
s.addremove = true;
s.nodescriptions = true;
o = s.option(form.Value, 'name', _('Name'));
o.optional = true;
o.placeholder = 'name';
o = s.option(form.FileUpload, 'script', _('Script'),
_('Path of the script to execute'));
o.root_directory = '/etc/keepalived/scripts';
o.enable_upload = true;
o.optional = true;
o.datatype = 'file';
o = s.option(form.Value, 'interval', _('Interval'),
_('Seconds between script invocations'));
o.optional = true;
o.datatype = 'uinteger';
o.default = 60;
o = s.option(form.Value, 'weight', _('Weight'),
_('Adjust script execution priority'));
o.optional = true;
o.datatype = 'and(integer, range(-253, 253))';
o = s.option(form.Value, 'rise', _('Rise'),
_('Required number of successes for OK transition'));
o.optional = true;
o.datatype = 'uinteger';
o = s.option(form.Value, 'fail', _('Fail'),
_('Required number of successes for KO transition'));
o.optional = true;
o.datatype = 'uinteger';
},
render: function() {
var m;
m = new form.Map('keepalived');
this.renderVRRPScript(m);
this.renderTrackScript(m);
return m.render();
}
});
|