r1424 + first working version of renderLVSConfig() ever
authorDenis Ovsienko <infrastation@yandex.ru>
Mon, 24 Dec 2007 19:24:35 +0000 (19:24 +0000)
committerDenis Ovsienko <infrastation@yandex.ru>
Mon, 24 Dec 2007 19:24:35 +0000 (19:24 +0000)
inc/interface.php

index 1b771101140141dff59ee8506e85a6c5620adbeb..768eb20675ed54f71803d02cadc2eb0b50314dad 100644 (file)
@@ -3491,9 +3491,41 @@ Dictionary edit page in Configuration section.
 <?php
 }
 
-function renderLVSConfig ($object_id)
+function renderLVSConfig ($object_id = 0)
 {
-       dragon();
+       if ($object_id <= 0)
+       {
+               showError ('Invalid object_id in renderLVSConfig()');
+               return;
+       }
+       $natrules = getObjectForwards ($object_id);
+       $lvsconfig = array();
+       foreach ($natrules['out'] as $rule)
+       {
+               $lvsconfig [$rule['localip']] ['description'] = $rule['local_addr_name'];
+               $lvsconfig [$rule['localip']] [$rule['proto']] [$rule['localport']] ['rs'] [] = array
+               (
+                       'address' => $rule['remoteip'],
+                       'port' => $rule['remoteport'],
+                       'description' => $rule['remote_addr_name']
+               );
+       }
+       echo '<pre>';
+       foreach ($lvsconfig as $vip => $vipdata)
+               foreach (readChapter ('Protocols') as $proto)
+               {
+                       if (!isset ($vipdata[$proto]))
+                               continue;
+                       foreach ($vipdata[$proto] as $vport => $vportdata)
+                       {
+                               echo "# auto-VIP: ${vipdata['description']}\n";
+                               echo "virtual_server ${vip} ${vport}\n";
+                               foreach ($vportdata['rs'] as $rs)
+                                       echo "\treal_server ${rs['address']} ${rs['port']} {\n\t}\n";
+                               echo "}\n\n";
+                       }
+               }
+       echo '</pre>';
 }
 
 ?>