f9293d6c2073752e0f800bd22d1d5ce24b734af9
6 'require tools.widgets as widgets';
12 uci
.load('keepalived'),
16 renderGeneralTab: function(s
) {
19 o
= s
.taboption('general',form
.Value
, 'name', _('Name'));
23 o
= s
.taboption('general', form
.ListValue
, 'state', _('State'),
24 _('Initial State. As soon as the other machine(s) come up,') +
25 _('an election will be held and the machine with the highest "priority" will become MASTER.'));
26 o
.value('MASTER', _('Master'));
27 o
.value('BACKUP', _('Backup'));
31 o
= s
.taboption('general', widgets
.DeviceSelect
, 'interface', _('Interface'),
32 _('Interface for inside_network, bound by VRRP'));
38 o
= s
.taboption('general', form
.Value
, 'virtual_router_id', _('Virtual Router Id'),
39 _('Differentiate multiple instances of vrrpd, running on the same NIC'));
40 o
.datatype
= 'range(1-255)';
44 o
= s
.taboption('general', form
.Value
, 'priority', _('Priority'),
45 _('A server with a higher priority becomes a MASTER'));
46 o
.datatype
= 'uinteger';
50 o
= s
.taboption('general', form
.ListValue
, 'advert_int', _('Interval'),
51 _('VRRP Advert interval in seconds'));
63 o
= s
.taboption('general', form
.Flag
, 'nopreempt', _('Disable Preempt'),
64 _('Allows the lower priority machine to maintain the master role,') +
65 _('even when a higher priority machine comes back online.') + ' ' +
66 _('For this to work, the initial state of this entry must be BACKUP.'));
70 ipaddress
= uci
.sections('keepalived', 'ipaddress');
71 o
= s
.taboption('general', form
.DynamicList
, 'virtual_ipaddress', _('Virtual IP Address'),
72 _('Addresses add|del on change to MASTER, to BACKUP.') + ' ' +
73 _('With the same entries on other machines, the opposite transition will be occurring.'));
74 if (ipaddress
!= '') {
75 for (var i
= 0; i
< ipaddress
.length
; i
++) {
76 o
.value(ipaddress
[i
]['name']);
83 renderPeerTab: function(s
, netDevs
) {
86 o
= s
.taboption('peer', form
.ListValue
, 'unicast_src_ip', _('Unicast Source IP'),
87 _('Default IP for binding vrrpd is the primary IP on interface'));
88 o
.datatype
= 'ipaddr';
91 for (var i
= 0; i
< netDevs
.length
; i
++) {
92 var addrs
= netDevs
[i
].getIPAddrs();
93 for (var j
= 0; j
< addrs
.length
; j
++) {
94 o
.value(addrs
[j
].split('/')[0]);
98 var peers
= uci
.sections('keepalived', 'peer');
99 o
= s
.taboption('peer', form
.DynamicList
, 'unicast_peer', _('Peer'),
100 _('Do not send VRRP adverts over VRRP multicast group.') + ' ' +
101 _('Instead it sends adverts to the following list of ip addresses using unicast design fashion'));
103 for (var i
= 0; i
< peers
.length
; i
++) {
104 o
.value(peers
[i
]['name']);
108 o
= s
.taboption('peer', form
.Value
, 'mcast_src_ip', _('Multicast Source IP'),
109 _('If you want to hide location of vrrpd, use this IP for multicast vrrp packets'));
110 o
.datatype
= 'ipaddr';
113 o
.depends({ 'unicast_peer' : '' });
115 o
= s
.taboption('peer', form
.ListValue
, 'auth_type', _('HA Authentication Type'));
116 o
.value('PASS', _('Simple Password'));
117 o
.value('AH', _('IPSec'));
119 o
= s
.taboption('peer', form
.Value
, 'auth_pass', _('Password'),
120 _('Password for accessing vrrpd, should be the same on all machines'));
121 o
.datatype
= 'maxlength(8)';
124 o
.depends({ 'auth_type' : 'PASS' });
127 renderGARPTab: function(s
) {
130 o
= s
.taboption('garp', form
.ListValue
, 'garp_master_delay', _('GARP Delay'),
131 _('Gratuitous Master Delay in seconds'));
132 o
.datatype
= 'uinteger';
141 o
= s
.taboption('garp', form
.ListValue
, 'garp_master_repeat', _('GARP Repeat'),
142 _('Gratuitous Master Repeat in seconds'));
143 o
.datatype
= 'uinteger';
152 o
= s
.taboption('garp', form
.ListValue
, 'garp_master_refresh', _('GARP Refresh'),
153 _('Gratuitous Master Refresh in seconds'));
154 o
.datatype
= 'uinteger';
163 o
= s
.taboption('garp', form
.ListValue
, 'garp_master_refresh_repeat', _('GARP Refresh Repeat'),
164 _('Gratuitous Master Refresh Repeat in seconds'));
165 o
.datatype
= 'uinteger';
175 renderAdvancedTab: function(s
) {
178 o
= s
.taboption('advanced', form
.Value
, 'use_vmac', _('Use VMAC'),
179 _('Use VRRP Virtual MAC'));
181 o
.placeholder
= '[<VMAC_INTERFACE_NAME>] [MAC_ADDRESS]';
184 o
= s
.taboption('advanced', form
.Flag
, 'vmac_xmit_base', _('Use VMAC Base'),
185 _('Send/Recv VRRP messages from base interface instead of VMAC interfac'));
190 o
= s
.taboption('advanced', form
.Flag
, 'native_ipv6', _('Use IPV6'),
191 _('Force instance to use IPv6'));
196 o
= s
.taboption('advanced', form
.Flag
, 'dont_track_primary', _('Disable Primary Tracking'),
197 _('Ignore VRRP interface faults'));
202 o
= s
.taboption('advanced', form
.ListValue
, 'version', _('Version'),
203 _('VRRP version to run on interface'));
204 o
.value('', _('None'));
205 o
.value('2', _('2'));
206 o
.value('3', _('3'));
210 o
= s
.taboption('advanced', form
.Flag
, 'accept', _('Accept'),
211 _('Accept packets to non address-owner'));
215 o
= s
.taboption('advanced', form
.Value
, 'preempt_delay', _('Preempt Delay'),
216 _('Time in seconds to delay preempting compared'));
217 o
.datatype
= 'float';
218 o
.placeholder
= '300';
221 o
= s
.taboption('advanced', form
.ListValue
, 'preempt_delay', _('Debug'),
231 o
= s
.taboption('advanced', form
.Flag
, 'smtp_alert', _('Email Alert'),
232 _('Send SMTP alerts'));
237 renderTrackingTab: function(s
) {
239 var ipaddress
, routes
, interfaces
, scripts
;
241 ipaddress
= uci
.sections('keepalived', 'ipaddress');
242 routes
= uci
.sections('keepalived', 'route');
243 interfaces
= uci
.sections('keepalived', 'track_interface');
244 scripts
= uci
.sections('keepalived', 'track_script');
246 o
= s
.taboption('tracking', form
.DynamicList
, 'virtual_ipaddress_excluded', _('Exclude Virtual IP Address'),
247 _('VRRP IP excluded from VRRP. For cases with large numbers (eg 200) of IPs on the same interface.') + ' ' +
248 _('To decrease the number of packets sent in adverts, you can exclude most IPs from adverts.'));
250 if (ipaddress
!= '') {
251 for (var i
= 0; i
< ipaddress
.length
; i
++) {
252 o
.value(ipaddress
[i
]['name']);
256 o
= s
.taboption('tracking', form
.DynamicList
, 'virtual_routes', _('Virtual Routes'),
257 _('Routes add|del when changing to MASTER, to BACKUP'));
260 for (var i
= 0; i
< routes
.length
; i
++) {
261 o
.value(routes
[i
]['name']);
265 o
= s
.taboption('tracking', form
.DynamicList
, 'track_interface', _('Track Interfaces'),
266 _('Go to FAULT state if any of these go down'));
268 if (interfaces
!= '') {
269 for (var i
= 0; i
< interfaces
.length
; i
++) {
270 o
.value(interfaces
[i
]['name']);
274 o
= s
.taboption('tracking', form
.DynamicList
, 'track_script', _('Track Script'),
275 _('Go to FAULT state if any of these go down, if unweighted'));
278 for (var i
= 0; i
< scripts
.length
; i
++) {
279 o
.value(scripts
[i
]['name']);
284 render: function(data
) {
285 var netDevs
= data
[0];
288 m
= new form
.Map('keepalived');
290 s
= m
.section(form
.GridSection
, 'vrrp_instance', _('VRRP Instance'),
291 _('Define an individual instance of the VRRP protocol running on an interface'));
294 s
.nodescriptions
= true;
296 o
= s
.tab('general', _('General'));
297 o
= s
.tab('peer', _('Peer'));
298 o
= s
.tab('tracking', _('Tracking'));
299 o
= s
.tab('garp', _('GARP'));
300 o
= s
.tab('advanced', _('Advanced'));
302 this.renderGeneralTab(s
);
303 this.renderPeerTab(s
, netDevs
);
304 this.renderTrackingTab(s
);
305 this.renderGARPTab(s
);
306 this.renderAdvancedTab(s
);