r5084 trivial CSS change
[racktables] / wwwroot / inc / slb-interface.php
CommitLineData
defd92d8
AA
1<?php
2
cddbb9fd
DO
3# This file is a part of RackTables, a datacenter and server room management
4# framework. See accompanying file "COPYING" for the full copyright and
5# licensing information.
6
defd92d8
AA
7function renderSLBDefConfig()
8{
9 $defaults = getSLBDefaults ();
10 startPortlet ('SLB default configs');
11 echo '<table cellspacing=0 cellpadding=5 align=center>';
12 printOpFormIntro ('save');
13 echo '<tr><th class=tdright>VS config</th><td colspan=2><textarea tabindex=103 name=vsconfig rows=10 cols=80>' . htmlspecialchars($defaults['vs']) . '</textarea></td>';
14 echo '<td rowspan=2>';
15 printImageHREF ('SAVE', 'Save changes', TRUE);
16 echo '</td></tr>';
17 echo '<tr><th class=tdright>RS config</th><td colspan=2><textarea tabindex=104 name=rsconfig rows=10 cols=80>' . htmlspecialchars($defaults['rs']) . '</textarea></td></tr>';
18 echo '</form></table>';
19 finishPortlet();
20}
21
22function renderSLBEntityCell ($cell, $highlighted = FALSE)
23{
24 $class = "slbcell realm-${cell['realm']} id-${cell['id']}";
5c717ce5 25 $a_class = $highlighted ? 'highlighted' : '';
defd92d8
AA
26
27 echo "<table class='$class'>";
28 switch ($cell['realm']) {
29 case 'object':
30 echo "<tr><td><a class='$a_class' href='index.php?page=object&object_id=${cell['id']}'>${cell['dname']}</a>";
31 echo "</td></tr><tr><td>";
32 printImageHREF ('LB');
33 echo "</td></tr>";
34 break;
35 case 'ipv4vs':
36 echo "<tr><td rowspan=3 width='5%'>";
37 printImageHREF ('VS');
38 echo "</td><td>";
39 echo "<a class='$a_class' href='index.php?page=ipv4vs&vs_id=${cell['id']}'>";
40 echo $cell['dname'] . "</a></td></tr><tr><td>";
41 echo $cell['name'] . '</td></tr>';
42 break;
43 case 'ipv4rspool':
44 echo "<tr><td>";
45 echo "<a class='$a_class' href='index.php?page=ipv4rspool&pool_id=${cell['id']}'>";
46 echo !strlen ($cell['name']) ? "ANONYMOUS pool [${cell['id']}]" : niftyString ($cell['name']);
47 echo "</a></td></tr><tr><td>";
48 printImageHREF ('RS pool');
49 if ($cell['rscount'])
50 echo ' <small>(' . $cell['rscount'] . ')</small>';
51 echo "</td></tr>";
52 break;
53 }
54 echo "<tr><td>";
55 echo count ($cell['etags']) ? ("<small>" . serializeTags ($cell['etags']) . "</small>") : '&nbsp;';
56 echo "</td></tr></table>";
57
58}
59
60function renderSLBEditTab ($entity_id)
61{
62 global $pageno;
63 renderSLBTripletsEdit (spotEntity ($pageno, $entity_id));
64}
65
66// called exclusively by renderSLBTripletsEdit. Renders form to add new SLB link.
67// realms 1 and 2 are realms to draw inputs for
68function renderNewSLBItemForm ($realm1, $realm2)
69{
70 function print_realm_select_input($realm)
71 {
72 switch ($realm)
73 {
74 case 'object':
75 echo "<tr valign=top><th class=tdright>Load balancer</th><td class=tdleft>";
76 printSelect (getNarrowObjectList ('IPV4LB_LISTSRC'), array ('name' => 'object_id', 'tabindex' => 100));
77 break;
78 case 'ipv4vs':
79 echo '</td></tr><tr><th class=tdright>Virtual service</th><td class=tdleft>';
80 printSelect (getIPv4VSOptions(), array ('name' => 'vs_id', 'tabindex' => 101));
81 break;
82 case 'ipv4rspool':
83 echo '</td></tr><tr><th class=tdright>RS pool</th><td class=tdleft>';
84 printSelect (getIPv4RSPoolOptions(), array ('name' => 'pool_id', 'tabindex' => 102));
85 break;
86 default:
87 throw new InvalidArgException('realm', $realm);
88 }
89 }
90
91 startPortlet ('Add new');
92 echo "<table cellspacing=0 cellpadding=5 align=center>";
93 printOpFormIntro ('addLB');
94 print_realm_select_input($realm1);
95 echo '</td><td class=tdcenter valign=middle rowspan=2>';
96 printImageHREF ('ADD', 'Configure LB', TRUE, 120);
97 print_realm_select_input($realm2);
98 echo "</td></tr>\n";
99 echo "<tr><th class=tdright>VS config</th><td colspan=2><textarea tabindex=110 name=vsconfig rows=10 cols=80></textarea></td></tr>";
100 echo "<tr><th class=tdright>RS config</th><td colspan=2><textarea tabindex=111 name=rsconfig rows=10 cols=80></textarea></td></tr>";
101 echo "<tr><th class=tdright>Priority</th><td class=tdleft colspan=2><input tabindex=112 name=prio size=10></td></tr>";
102 echo "</form></table>\n";
103 finishPortlet();
104}
105
106// supports object, ipv4vs, ipv4rspool, ipaddress cell types
107function renderSLBTriplets ($cell)
108{
71066ef1 109 $is_cell_ip = (isset ($cell['ip_bin']) && isset ($cell['vslist']));
defd92d8
AA
110 $additional_js_params = $is_cell_ip ? '' : ", {'" . $cell['realm'] . "': " . $cell['id'] . '}';
111 $triplets = SLBTriplet::getTriplets ($cell);
112 if (count ($triplets))
113 {
114 $cells = array();
115 foreach ($triplets[0]->display_cells as $field)
116 $cells[] = $triplets[0]->$field;
117
118 // render table header
119 startPortlet ('VS instances (' . count ($triplets) . ')');
120 echo "<table cellspacing=0 cellpadding=5 align=center class=widetable><tr>";
121 $headers = array
122 (
123 'object' => 'LB',
124 'ipv4vs' => 'VS',
125 'ipv4rspool' => 'RS pool',
126 );
127 foreach ($cells as $slb_cell)
128 echo '<th>' . $headers[$slb_cell['realm']] . '</th>';
129 foreach (array ('VS config', 'RS config', 'Prio') as $header)
130 echo "<th>$header</th>";
131 echo "</tr>";
132
133 // render table rows
134 global $nextorder;
135 $order = 'odd';
136 foreach ($triplets as $slb)
137 {
138 $cells = array();
139 foreach ($slb->display_cells as $field)
140 $cells[] = $slb->$field;
141 echo "<tr valign=top class='row_${order} triplet-row'>";
142 foreach ($cells as $slb_cell)
143 {
144 echo "<td class=tdleft>";
145 $highlighted = $is_cell_ip &&
146 (
71066ef1
AA
147 $slb_cell['realm'] == 'ipv4vs' && $slb->vs['vip_bin'] == $cell['ip_bin'] ||
148 $slb_cell['realm'] == 'ipv4rspool' && $slb->vs['vip_bin'] != $cell['ip_bin']
defd92d8
AA
149 );
150 renderSLBEntityCell ($slb_cell, $highlighted);
151 echo "</td>";
152 }
153 echo "<td class=slbconf>" . htmlspecialchars ($slb->slb['vsconfig']) . "</td>";
154 echo "<td class=slbconf>" . htmlspecialchars ($slb->slb['rsconfig']) . "</td>";
155 echo "<td class=slbconf>" . htmlspecialchars ($slb->slb['prio']) . "</td>";
156 echo "</tr>\n";
157 $order = $nextorder[$order];
158 }
159 echo "</table>\n";
160 finishPortlet();
defd92d8
AA
161 }
162}
163
164// renders a list of slb links. it is called from 3 different pages, wich compute their links lists differently.
165// each triplet in $triplets array contains balancer, pool, VS cells and config values for triplet: RS, VS configs and pair.
166function renderSLBTripletsEdit ($cell)
167{
168 list ($realm1, $realm2) = array_values (array_diff (array ('object', 'ipv4vs', 'ipv4rspool'), array ($cell['realm'])));
169 if (getConfigVar ('ADDNEW_AT_TOP') == 'yes')
170 renderNewSLBItemForm($realm1, $realm2);
171
172 $triplets = SLBTriplet::getTriplets ($cell);
173 if (count ($triplets))
174 {
175 $cells = array();
176 foreach ($triplets[0]->display_cells as $field)
177 $cells[] = $triplets[0]->$field;
178
179 startPortlet ('Manage existing (' . count ($triplets) . ')');
180 echo "<table cellspacing=0 cellpadding=5 align=center class=cooltable>\n";
181 global $nextorder;
182 $order = 'odd';
183 foreach ($triplets as $slb)
184 {
185 $cells = array();
186 foreach ($slb->display_cells as $field)
187 $cells[] = $slb->$field;
188 $ids = array
189 (
190 'object_id' => $slb->lb['id'],
191 'vs_id' => $slb->vs['id'],
192 'pool_id' => $slb->rs['id'],
193 );
194 $del_params = $ids;
195 $del_params['op'] = 'delLB';
196 printOpFormIntro ('updLB', $ids);
197 echo "<tr valign=top class=row_${order}><td rowspan=2 class=tdright valign=middle><a href='".makeHrefProcess($del_params)."'>";
198 printImageHREF ('DELETE', 'Unconfigure');
199 echo "</a></td><td class=tdleft valign=bottom>";
200 renderSLBEntityCell ($cells[0]);
201 echo "</td><td>VS config &darr;<br><textarea name=vsconfig rows=5 cols=70>" . htmlspecialchars ($slb->slb['vsconfig']) . "</textarea></td>";
202 echo '<td class=tdleft rowspan=2 valign=middle>';
203 printImageHREF ('SAVE', 'Save changes', TRUE);
204 echo "</td>";
205 echo "</tr><tr class=row_${order}><td class=tdleft valign=top>";
206 renderSLBEntityCell ($cells[1]);
207 echo '</td><td>';
208 echo "<textarea name=rsconfig rows=5 cols=70>" . htmlspecialchars ($slb->slb['rsconfig']) . "</textarea><br>RS config &uarr;";
209 echo "<div style='float:left; margin-top:10px'><label><input name=prio type=text size=10 value=\"" . htmlspecialchars ($slb->slb['prio']) . "\"> &larr; Priority</label></div>";
210 echo '</td></tr></form>';
211 $order = $nextorder[$order];
212 }
213 echo "</table>\n";
214 finishPortlet();
215 }
216
217 if (getConfigVar ('ADDNEW_AT_TOP') != 'yes')
218 renderNewSLBItemForm ($realm1, $realm2);
219}
220
221function renderLBList ()
222{
223 $cells = array();
0d9f88a9
AA
224 foreach (scanRealmByText('object', getConfigVar ('IPV4LB_LISTSRC')) as $object)
225 $cells[$object['id']] = $object;
defd92d8
AA
226 renderCellList ('object', 'items', FALSE, $cells);
227}
228
229function renderRSPool ($pool_id)
230{
231 $poolInfo = spotEntity ('ipv4rspool', $pool_id);
232
233 echo "<table border=0 class=objectview cellspacing=0 cellpadding=0>";
234 if (strlen ($poolInfo['name']))
235 echo "<tr><td colspan=2 align=center><h1>{$poolInfo['name']}</h1></td></tr>";
236 echo "<tr><td class=pcleft>\n";
237
238 $summary = array();
239 $summary['Pool name'] = $poolInfo['name'];
240 $summary['Real servers'] = $poolInfo['rscount'];
241 $summary['VS instances'] = $poolInfo['refcnt'];
242 $summary['tags'] = '';
243 $summary['VS configuration'] = '<div class="dashed slbconf">' . htmlspecialchars ($poolInfo['vsconfig']) . '</div>';
244 $summary['RS configuration'] = '<div class="dashed slbconf">' . htmlspecialchars ($poolInfo['rsconfig']) . '</div>';
245 renderEntitySummary ($poolInfo, 'Summary', $summary);
246
247 if ($poolInfo['rscount'])
248 {
4ed2310e 249 $rs_list = getRSListInPool ($pool_id);
87595d74
AA
250 $rs_table = callHook ('prepareRealServersTable', $rs_list);
251 startPortlet ("Real servers ({$poolInfo['rscount']})");
defd92d8 252 echo "<table cellspacing=0 cellpadding=5 align=center class=widetable>\n";
4ed2310e 253 echo "<tr>";
87595d74 254 foreach ($rs_table['columns'] as $title)
4ed2310e
AA
255 echo "<th>$title</th>";
256 echo "</tr>";
87595d74 257 foreach ($rs_table['rows'] as $rs)
defd92d8 258 {
4ed2310e 259 echo "<tr valign=top>";
87595d74 260 foreach (array_keys ($rs_table['columns']) as $field)
4ed2310e
AA
261 {
262 switch ($field)
263 {
264 case 'inservice':
265 echo "<td align=center>";
266 if ($rs['inservice'] == 'yes')
267 printImageHREF ('inservice', 'in service');
268 else
269 printImageHREF ('notinservice', 'NOT in service');
270 break;
271 case 'rsip':
272 echo "<td class=tdleft>";
273 echo "<a href='".makeHref(array('page'=>'ipaddress', 'ip'=>$rs[$field]))."'>${rs[$field]}</a>";
274 break;
275 case 'rsconfig':
276 echo "<td class=slbconf>";
277 echo $rs[$field];
278 break;
279 default:
280 echo "<td class=tdleft>";
281 echo $rs[$field];
282 break;
283 }
284 echo '</td>';
285 }
286 echo '</tr>';
defd92d8
AA
287 }
288 echo "</table>\n";
289 finishPortlet();
290 }
291
292 echo "</td><td class=pcright>\n";
293 renderSLBTriplets ($poolInfo);
294 echo "</td></tr><tr><td colspan=2>\n";
295 renderFilesPortlet ('ipv4rspool', $pool_id);
296 echo "</td></tr></table>\n";
297}
298
87595d74 299function prepareRealServersTable ($rs_list)
4ed2310e 300{
87595d74 301 $columns = array
4ed2310e
AA
302 (
303 'inservice' => '',
304 'rsip' => 'address',
305 'rsport' => 'port',
306 'rsconfig' => 'RS config',
307 'comment' => 'comment',
308 );
87595d74 309 $not_seen = $columns;
4ed2310e
AA
310 foreach ($rs_list as $rs)
311 foreach ($rs as $key => $value)
312 if (! empty ($value) and isset ($not_seen[$key]))
313 unset ($not_seen[$key]);
314 foreach (array_keys ($not_seen) as $key)
315 if ($key != 'rsip')
87595d74
AA
316 unset ($columns[$key]);
317 return array
318 (
319 'columns' => $columns,
320 'rows' => $rs_list,
321 );
4ed2310e
AA
322}
323
defd92d8
AA
324function renderRSPoolServerForm ($pool_id)
325{
326 global $nextorder;
327 $poolInfo = spotEntity ('ipv4rspool', $pool_id);
328
329 if ($poolInfo['rscount'])
330 {
4ed2310e 331 startPortlet ("Manage RS list (${poolInfo['rscount']})");
defd92d8 332 echo "<table cellspacing=0 cellpadding=5 align=center class=cooltable>\n";
4ed2310e
AA
333 echo "<tr><th>&nbsp;</th><th>Address</th><th>Port</th><th>Comment</th><th>in service</th><th>configuration</th><th>&nbsp;</th></tr>\n";
334 // new RS form
335 printOpFormIntro ('addRS');
336 echo "<tr class=row_odd valign=top><td>";
337 printImageHREF ('add', 'Add new real server');
338 echo "</td><td><input type=text name=rsip></td>";
339 $default_port = getConfigVar ('DEFAULT_SLB_RS_PORT');
340 if ($default_port == 0)
341 $default_port = '';
342 echo "<td><input type=text name=rsport size=5 value='$default_port'></td>";
343 echo "<td><input type=text name=comment size=15></td>";
344 $checked = (getConfigVar ('DEFAULT_IPV4_RS_INSERVICE') == 'yes') ? 'checked' : '';
345 echo "<td><input type=checkbox name=inservice $checked></td>";
346 echo "<td><textarea name=rsconfig></textarea></td><td>";
347 printImageHREF ('ADD', 'Add new real server', TRUE);
348 echo "</td></tr></form>\n";
349
350 $order = 'even';
defd92d8
AA
351 foreach (getRSListInPool ($pool_id) as $rsid => $rs)
352 {
353 printOpFormIntro ('updRS', array ('rs_id' => $rsid));
354 echo "<tr valign=top class=row_${order}><td><a href='".makeHrefProcess(array('op'=>'delRS', 'pool_id'=>$pool_id, 'id'=>$rsid))."'>";
355 printImageHREF ('delete', 'Delete this real server');
356 echo "</td><td><input type=text name=rsip value='${rs['rsip']}'></td>";
357 echo "<td><input type=text name=rsport size=5 value='${rs['rsport']}'></td>";
4ed2310e 358 echo "<td><input type=text name=comment size=15 value='${rs['comment']}'></td>";
defd92d8
AA
359 $checked = $rs['inservice'] == 'yes' ? 'checked' : '';
360 echo "<td><input type=checkbox name=inservice $checked></td>";
361 echo "<td><textarea name=rsconfig>${rs['rsconfig']}</textarea></td><td>";
362 printImageHREF ('SAVE', 'Save changes', TRUE);
363 echo "</td></tr></form>\n";
364 $order = $nextorder[$order];
365 }
366 echo "</table>\n";
367 finishPortlet();
368 }
369
defd92d8
AA
370 startPortlet ('Add many');
371 printOpFormIntro ('addMany');
372 echo "<table border=0 align=center>\n<tr><td>";
373 if (getConfigVar ('DEFAULT_IPV4_RS_INSERVICE') == 'yes')
374 printImageHREF ('inservice', 'in service');
375 else
376 printImageHREF ('notinservice', 'NOT in service');
377 echo "</td><td>Format: ";
ab8b6355
AA
378 $formats = callHook ('getBulkRealsFormats');
379 printSelect ($formats, array ('name' => 'format'));
380 echo "</td><td><input type=submit value=Parse></td></tr>\n";
381 echo "<tr><td colspan=3><textarea name=rawtext cols=100 rows=25></textarea></td></tr>\n";
382 echo "</table>\n";
383 finishPortlet();
384}
385
386function getBulkRealsFormats()
387{
388 return array
defd92d8
AA
389 (
390 'ssv_1' => 'SSV: &lt;IP address&gt;',
391 'ssv_2' => 'SSV: &lt;IP address&gt; &lt;port&gt;',
392 'ipvs_2' => 'ipvsadm -l -n (address and port)',
393 'ipvs_3' => 'ipvsadm -l -n (address, port and weight)',
394 );
defd92d8
AA
395}
396
397function renderRSPoolList ()
398{
399 renderCellList ('ipv4rspool', 'RS pools');
400}
401
402function renderRealServerList ()
403{
404 global $nextorder;
405 $rslist = getRSList ();
406 $pool_list = listCells ('ipv4rspool');
407 echo "<table class=widetable border=0 cellpadding=10 cellspacing=0 align=center>\n";
408 echo "<tr><th>RS pool</th><th>in service</th><th>real IP address</th><th>real port</th><th>RS configuration</th></tr>";
409 $order = 'even';
410 $last_pool_id = 0;
411 foreach ($rslist as $rsinfo)
412 {
413 if ($last_pool_id != $rsinfo['rspool_id'])
414 {
415 $order = $nextorder[$order];
416 $last_pool_id = $rsinfo['rspool_id'];
417 }
418 echo "<tr valign=top class=row_${order}><td><a href='".makeHref(array('page'=>'ipv4rspool', 'pool_id'=>$rsinfo['rspool_id']))."'>";
419 echo !strlen ($pool_list[$rsinfo['rspool_id']]['name']) ? 'ANONYMOUS' : $pool_list[$rsinfo['rspool_id']]['name'];
420 echo '</a></td><td align=center>';
421 if ($rsinfo['inservice'] == 'yes')
422 printImageHREF ('inservice', 'in service');
423 else
424 printImageHREF ('notinservice', 'NOT in service');
425 echo "</td><td><a href='".makeHref(array('page'=>'ipaddress', 'ip'=>$rsinfo['rsip']))."'>${rsinfo['rsip']}</a></td>";
426 echo "<td>${rsinfo['rsport']}</td>";
427 echo "<td><pre>${rsinfo['rsconfig']}</pre></td>";
428 echo "</tr>\n";
429 }
430 echo "</table>";
431}
432
433
71066ef1 434function renderNewRSPoolForm ()
defd92d8 435{
71066ef1
AA
436 startPortlet ('Add new RS pool');
437 printOpFormIntro ('add');
438 echo "<table border=0 cellpadding=10 cellspacing=0 align=center>";
439 echo "<tr><th class=tdright>Name</th>";
440 echo "<td class=tdleft><input type=text name=name tabindex=101></td><td>";
441 printImageHREF ('CREATE', 'create real server pool', TRUE, 104);
442 echo "</td><th>Assign tags</th></tr>";
443 echo "<tr><th class=tdright>VS config</th><td colspan=2><textarea name=vsconfig rows=10 cols=80 tabindex=102></textarea></td>";
444 echo "<td rowspan=2>";
445 renderNewEntityTags ('ipv4rspool');
446 echo "</td></tr>";
447 echo "<tr><th class=tdright>RS config</th><td colspan=2><textarea name=rsconfig rows=10 cols=80 tabindex=103></textarea></td></tr>";
448 echo "</table></form>";
449 finishPortlet();
defd92d8
AA
450}
451
452function renderVirtualService ($vsid)
453{
454 $vsinfo = spotEntity ('ipv4vs', $vsid);
455 echo '<table border=0 class=objectview cellspacing=0 cellpadding=0>';
456 if (strlen ($vsinfo['name']))
457 echo "<tr><td colspan=2 align=center><h1>${vsinfo['name']}</h1></td></tr>\n";
458 echo '<tr>';
459
460 echo '<td class=pcleft>';
461 $summary = array();
462 $summary['Name'] = $vsinfo['name'];
463 $summary['Protocol'] = $vsinfo['proto'];
464 $summary['Virtual IP address'] = "<a href='".makeHref(array('page'=>'ipaddress', 'tab'=>'default', 'ip'=>$vsinfo['vip']))."'>${vsinfo['vip']}</a>";
465 $summary['Virtual port'] = $vsinfo['vport'];
466 $summary['tags'] = '';
467 $summary['VS configuration'] = '<div class="dashed slbconf">' . $vsinfo['vsconfig'] . '</div>';
468 $summary['RS configuration'] = '<div class="dashed slbconf">' . $vsinfo['rsconfig'] . '</div>';
469 renderEntitySummary ($vsinfo, 'Summary', $summary);
470 echo '</td>';
471
472 echo '<td class=pcright>';
473 renderSLBTriplets ($vsinfo);
474 echo '</td></tr><tr><td colspan=2>';
475 renderFilesPortlet ('ipv4vs', $vsid);
476 echo '</tr><table>';
477}
478
479function renderVSList ()
480{
481 renderCellList ('ipv4vs', 'Virtual services');
482}
483
71066ef1 484function renderNewVSForm ()
defd92d8 485{
71066ef1
AA
486 startPortlet ('Add new virtual service');
487 printOpFormIntro ('add');
488 echo "<table border=0 cellpadding=10 cellspacing=0 align=center>\n";
489 echo "<tr valign=bottom><td>&nbsp;</td><th>VIP</th><th>port</th><th>proto</th><th>name</th><th>&nbsp;</th><th>Assign tags</th></tr>";
490 echo '<tr valign=top><td>&nbsp;</td>';
491 echo "<td><input type=text name=vip tabindex=101></td>";
492 $default_port = getConfigVar ('DEFAULT_SLB_VS_PORT');
493 if ($default_port == 0)
494 $default_port = '';
495 echo "<td><input type=text name=vport size=5 value='${default_port}' tabindex=102></td><td>";
496 global $vs_proto;
497 printSelect ($vs_proto, array ('name' => 'proto'), array_shift (array_keys ($vs_proto)));
498 echo '</td><td><input type=text name=name tabindex=104></td><td>';
499 printImageHREF ('CREATE', 'create virtual service', TRUE, 105);
500 echo "</td><td rowspan=3>";
501 renderNewEntityTags ('ipv4vs');
502 echo "</td></tr><tr><th>VS configuration</th><td colspan=5 class=tdleft><textarea name=vsconfig rows=10 cols=80></textarea></td>";
503 echo "<tr><th>RS configuration</th><td colspan=5 class=tdleft><textarea name=rsconfig rows=10 cols=80></textarea></td></tr>";
504 echo '</table></form>';
505 finishPortlet();
defd92d8
AA
506}
507
508function renderEditRSPool ($pool_id)
509{
510 $poolinfo = spotEntity ('ipv4rspool', $pool_id);
511 printOpFormIntro ('updIPv4RSP');
512 echo '<table border=0 align=center>';
513 echo "<tr><th class=tdright>name:</th><td class=tdleft><input type=text name=name value='${poolinfo['name']}'></td></tr>\n";
514 echo "<tr><th class=tdright>VS config:</th><td class=tdleft><textarea name=vsconfig rows=20 cols=80>${poolinfo['vsconfig']}</textarea></td></tr>\n";
515 echo "<tr><th class=tdright>RS config:</th><td class=tdleft><textarea name=rsconfig rows=20 cols=80>${poolinfo['rsconfig']}</textarea></td></tr>\n";
516 echo "<tr><th class=submit colspan=2>";
517 printImageHREF ('SAVE', 'Save changes', TRUE);
518 echo "</td></tr>\n";
519 echo "</table></form>\n";
d60c7760
AA
520
521 // clone link
522 echo '<p class="centered">';
523 echo getOpLink (array ('op' => 'cloneIPv4RSP', 'pool_id' => $poolinfo['id']), 'Clone RS pool', 'copy');
524 echo '</p>';
525
526 // delete link
527 echo '<p class="centered">';
528 if ($poolinfo['refcnt'] > 0)
529 echo getOpLink (NULL, 'Delete RS pool', 'nodestroy', "Could not delete: there are ${poolinfo['refcnt']} LB links");
530 else
531 echo getOpLink (array ('op' => 'del', 'id' => $poolinfo['id']), 'Delete RS pool', 'destroy');
532 echo '</p>';
defd92d8
AA
533}
534
535function renderEditVService ($vsid)
536{
537 $vsinfo = spotEntity ('ipv4vs', $vsid);
538 printOpFormIntro ('updIPv4VS');
539 echo '<table border=0 align=center>';
540 echo "<tr><th class=tdright>VIP:</th><td class=tdleft><input tabindex=1 type=text name=vip value='${vsinfo['vip']}'></td></tr>\n";
541 echo "<tr><th class=tdright>port:</th><td class=tdleft><input tabindex=2 type=text name=vport value='${vsinfo['vport']}'></td></tr>\n";
542 echo "<tr><th class=tdright>proto:</th><td class=tdleft>";
ed38c73c
AA
543 global $vs_proto;
544 printSelect ($vs_proto, array ('name' => 'proto'), $vsinfo['proto']);
defd92d8
AA
545 echo "</td></tr>\n";
546 echo "<tr><th class=tdright>name:</th><td class=tdleft><input tabindex=4 type=text name=name value='${vsinfo['name']}'></td></tr>\n";
547 echo "<tr><th class=tdright>VS config:</th><td class=tdleft><textarea tabindex=5 name=vsconfig rows=20 cols=80>${vsinfo['vsconfig']}</textarea></td></tr>\n";
548 echo "<tr><th class=tdright>RS config:</th><td class=tdleft><textarea tabindex=6 name=rsconfig rows=20 cols=80>${vsinfo['rsconfig']}</textarea></td></tr>\n";
549 echo "<tr><th class=submit colspan=2>";
550 printImageHREF ('SAVE', 'Save changes', TRUE, 7);
551 echo "</td></tr>\n";
552 echo "</table></form>\n";
71066ef1
AA
553
554 // delete link
555 echo '<p class="centered">';
556 if ($vsinfo['refcnt'] > 0)
557 echo getOpLink (NULL, 'Delete virtual service', 'nodestroy', "Could not delete: there are ${vsinfo['refcnt']} LB links");
558 else
559 echo getOpLink (array ('op' => 'del', 'id' => $vsinfo['id']), 'Delete virtual service', 'destroy');
defd92d8
AA
560}
561
562function renderLVSConfig ($object_id)
563{
6ef2215c
AA
564 printOpFormIntro ('submitSLBConfig');
565 echo "<center><input type=submit value='Submit for activation'></center>";
566 echo "</form>";
567 echo "<pre>" . buildLVSConfig ($object_id) . "</pre>";
defd92d8
AA
568}
569
570?>