servers.js 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. 'use strict';
  2. 'require view';
  3. 'require form';
  4. 'require uci';
  5. return view.extend({
  6. load: function() {
  7. return Promise.all([
  8. uci.load('keepalived'),
  9. ]);
  10. },
  11. renderVirtualServer: function(m) {
  12. var s, o;
  13. var real_servers;
  14. s = m.section(form.GridSection, 'virtual_server', _('Virtual Server'),
  15. _('A virtual server is a service configured to listen on a specific virtual IP.') + '<br/>' +
  16. _('A VIP address migrates from one LVS router to the other during a failover,') +
  17. _('thus maintaining a presence at that IP address'));
  18. s.anonymous = true;
  19. s.addremove = true;
  20. s.nodescriptions = true;
  21. s.tab('general', _('General'));
  22. s.tab('advanced', _('Advanced'));
  23. o = s.taboption('general', form.Flag, 'enabled', _('Enable'));
  24. o.optional = true;
  25. o.placeholder = 'name';
  26. o = s.taboption('general', form.Value, 'ipaddr', _('Address'),
  27. _('Address of the Server'));
  28. o.datatype = 'ipaddr';
  29. o = s.taboption('general', form.ListValue, 'protocol', _('Protocol'));
  30. o.value('TCP');
  31. o.value('UDP');
  32. o.default = 'TCP';
  33. o.modalonly = true;
  34. o = s.taboption('general', form.Value, 'port', _('Port'),
  35. _('Server Port'));
  36. o.rmempty = false;
  37. o.optional = false;
  38. o.datatype = 'port';
  39. o = s.taboption('general', form.Value, 'fwmark', _('Mark'),
  40. _('Firewall fwmark. Use Virtual server from FWMARK'));
  41. o.datatype = 'hexstring';
  42. real_servers = uci.sections('keepalived', 'real_server');
  43. o = s.taboption('general', form.DynamicList, 'real_server', _('Real Server'));
  44. if (real_servers != '') {
  45. for (i = 0; i < real_servers.length; i++) {
  46. o.value(real_servers[i]['name']);
  47. }
  48. }
  49. o.optional = false;
  50. o = s.taboption('general', form.Value, 'virtualhost', _('Virtual Host'),
  51. _('HTTP virtualhost to use for HTTP_GET | SSL_GET'));
  52. o.datatype = 'hostname';
  53. o.modalonly = true;
  54. o = s.taboption('general', form.ListValue, 'lb_kind', _('Forwarding Method'));
  55. o.value('NAT');
  56. o.value('DR');
  57. o.value('TUN');
  58. o.default = 'NAT';
  59. o = s.taboption('advanced', form.Value, 'delay_loop', _('Delay Loop'),
  60. _('Interval between checks in seconds'));
  61. o.optional = false;
  62. o.datatype = 'uinteger';
  63. o.modalonly = true;
  64. o = s.taboption('advanced', form.ListValue, 'lb_algo', _('Scheduler Algorigthm'));
  65. o.value('rr', _('Round-Robin'));
  66. o.value('wrr', _('Weighted Round-Robin'));
  67. o.value('lc', _('Least-Connection'));
  68. o.value('wlc', _('Weighted Least-Connection'));
  69. o.default = 'rr';
  70. o = s.taboption('advanced', form.Value, 'persistence_timeout', _('Persist Timeout'),
  71. _('Timeout value for persistent connections'));
  72. o.datatype = 'uinteger';
  73. o.default = 50;
  74. o.modalonly = true;
  75. o = s.taboption('advanced', form.Value, 'persistence_granularity', _('Persist Granularity'),
  76. _('Granularity mask for persistent connections'));
  77. o.datatype = 'ipaddr';
  78. o.modalonly = true;
  79. o = s.taboption('advanced', form.Value, 'sorry_server_ip', _('Sorry Server Address'),
  80. _('Server to be added to the pool if all real servers are down'));
  81. o.optional = false;
  82. o.datatype = 'ipaddr';
  83. o.modalonly = true;
  84. o = s.taboption('advanced', form.Value, 'sorry_server_port', _('Sorry Server Port'));
  85. o.optional = false;
  86. o.datatype = 'port';
  87. o.modalonly = true;
  88. o = s.taboption('advanced', form.Value, 'rise', _('Rise'),
  89. _('Required number of successes for OK transition'));
  90. o.optional = true;
  91. o.datatype = 'uinteger';
  92. o.modalonly = true;
  93. o = s.taboption('advanced', form.Value, 'fail', _('Fail'),
  94. _('Required number of successes for KO transition'));
  95. o.optional = true;
  96. o.datatype = 'uinteger';
  97. o.modalonly = true;
  98. },
  99. renderRealServer: function(m) {
  100. var s, o;
  101. var urls;
  102. s = m.section(form.GridSection, 'real_server', _('Real Servers'),
  103. _('Real Server to redirect all request'));
  104. s.anonymous = true;
  105. s.addremove = true;
  106. s.nodescriptions = true;
  107. o = s.option(form.Value, 'name', _('Name'));
  108. o.rmempty = false;
  109. o.optional = false;
  110. o.placeholder = 'name';
  111. o = s.option(form.Flag, 'enabled', _('Enabled'));
  112. o.default = true;
  113. o = s.option(form.Value, 'ipaddr', _('Address'),
  114. _('Address of the Server'));
  115. o.rmempty = false;
  116. o.optional = false;
  117. o.datatype = 'ipaddr';
  118. o = s.option(form.Value, 'port', _('Port'),
  119. _('Server Port'));
  120. o.rmempty = false;
  121. o.optional = false;
  122. o.datatype = 'port';
  123. o = s.option(form.Value, 'weight', _('Weight'),
  124. _('Relative weight to use'));
  125. o.rmempty = false;
  126. o.optional = false;
  127. o.placeholder = 1;
  128. o.datatype = 'uinteger';
  129. o = s.option(form.ListValue, 'check', _('Check'),
  130. _('Healthcheckers. Can be multiple of each type'));
  131. o.value('HTTP_GET');
  132. o.value('SSL_GET');
  133. o.value('TCP_CHECK');
  134. o.value('MISC_CHECK');
  135. o = s.option(form.Value, 'connect_timeout', _('Connect Timeout'));
  136. o.datatype = 'uinteger';
  137. o.depends('check', 'TCP_CHECK');
  138. o = s.option(form.Value, 'connect_port', _('Port'),
  139. _('Port to connect to'));
  140. o.datatype = 'port';
  141. o.depends('check', 'TCP_CHECK');
  142. o = s.option(form.Value, 'misc_path', _('User Check Script'));
  143. o.datatype = 'file';
  144. o.depends('check', 'MISC_CHECK');
  145. urls = uci.sections('keepalived', 'url');
  146. o = s.option(form.DynamicList, 'url', _('URLs'));
  147. if (urls != '') {
  148. for (var i = 0; i < urls.length; i++) {
  149. o.value(urls[i].name);
  150. }
  151. }
  152. o.depends('check', 'HTTP_GET');
  153. o.depends('check', 'SSL_GET');
  154. o = s.option(form.Value, 'retry', _('Retry'));
  155. o.datatype = 'uinteger';
  156. o = s.option(form.Value, 'delay_before_retry', _('Delay Before Retry'));
  157. o.datatype = 'uinteger';
  158. },
  159. render: function() {
  160. var m;
  161. m = new form.Map('keepalived');
  162. this.renderVirtualServer(m);
  163. this.renderRealServer(m);
  164. return m.render();
  165. }
  166. });