r2730 - amplifyCell(): also operate on 'ipv4vs'
authorDenis Ovsienko <infrastation@yandex.ru>
Mon, 11 May 2009 20:01:54 +0000 (20:01 +0000)
committerDenis Ovsienko <infrastation@yandex.ru>
Mon, 11 May 2009 20:01:54 +0000 (20:01 +0000)
 - dynamic_title_decoder(): switch from getVServiceInfo() to spotEntity()
 - renderVSCell(): idem
 - renderVirtualService(): idem
 - renderVServiceLBForm(): idem
 - renderEditVService(): idem
 - getVServiceInfo(): sayonara

inc/database.php
inc/interface.php

index de6b1b3c59500797d082d21bb7b743dff00ab00e..8904d613e302825dcbe55b1f1e8449d94e733afd 100644 (file)
@@ -423,6 +423,7 @@ function amplifyCell (&$record, $dummy = NULL)
                                'vsconfig' => $row['vsconfig'],
                        );
                unset ($result);
+               $record['rslist'] = array();
                $query = "select id, inservice, inet_ntoa(rsip) as rsip, rsport, rsconfig from " .
                        "IPv4RS where rspool_id = ${record['id']} order by IPv4RS.rsip, rsport";
                $result = useSelectBlade ($query, __FUNCTION__);
@@ -435,6 +436,37 @@ function amplifyCell (&$record, $dummy = NULL)
                                'rsconfig' => $row['rsconfig'],
                        );
                unset ($result);
+               break;
+       case 'ipv4vs':
+               // Get the detailed composition of a particular virtual service, namely the list
+               // of all pools, each shown with the list of objects servicing it. VS/RS configs
+               // will be returned as well.
+               $record['rspool'] = array();
+               $query = "select pool.id, name, pool.vsconfig, pool.rsconfig, object_id, " .
+                       "lb.vsconfig as lb_vsconfig, lb.rsconfig as lb_rsconfig from " .
+                       "IPv4RSPool as pool left join IPv4LB as lb on pool.id = lb.rspool_id " .
+                       "where vs_id = ${record['id']} order by pool.name, object_id";
+               $result = useSelectBlade ($query, __FUNCTION__);
+               while ($row = $result->fetch (PDO::FETCH_ASSOC))
+               {
+                       if (!isset ($record['rspool'][$row['id']]))
+                               $record['rspool'][$row['id']] = array
+                               (
+                                       'name' => $row['name'],
+                                       'vsconfig' => $row['vsconfig'],
+                                       'rsconfig' => $row['rsconfig'],
+                                       'lblist' => array(),
+                               );
+                       if ($row['object_id'] == NULL)
+                               continue;
+                       $record['rspool'][$row['id']]['lblist'][$row['object_id']] = array
+                       (
+                               'vsconfig' => $row['lb_vsconfig'],
+                               'rsconfig' => $row['lb_rsconfig'],
+                       );
+               }
+               unset ($result);
+               break;
        default:
        }
 }
@@ -2480,49 +2512,6 @@ function getSLBSummary ()
        return $ret;
 }
 
-// Get the detailed composition of a particular virtual service, namely the list
-// of all pools, each shown with the list of objects servicing it. VS/RS configs
-// will be returned as well.
-function getVServiceInfo ($vsid = 0)
-{
-       $query1 = "select id, inet_ntoa(vip) as vip, vport, proto, name, vsconfig, rsconfig " .
-               "from IPv4VS where id = ${vsid}";
-       $result = useSelectBlade ($query1, __FUNCTION__);
-       $vsinfo = array ();
-       $row = $result->fetch (PDO::FETCH_ASSOC);
-       if (!$row)
-               return NULL;
-       foreach (array ('id', 'vip', 'vport', 'proto', 'name', 'vsconfig', 'rsconfig') as $cname)
-               $vsinfo[$cname] = $row[$cname];
-       $vsinfo['rspool'] = array();
-       $result->closeCursor();
-       unset ($result);
-       $query2 = "select pool.id, name, pool.vsconfig, pool.rsconfig, object_id, " .
-               "lb.vsconfig as lb_vsconfig, lb.rsconfig as lb_rsconfig from " .
-               "IPv4RSPool as pool left join IPv4LB as lb on pool.id = lb.rspool_id " .
-               "where vs_id = ${vsid} order by pool.name, object_id";
-       $result = useSelectBlade ($query2, __FUNCTION__);
-       while ($row = $result->fetch (PDO::FETCH_ASSOC))
-       {
-               if (!isset ($vsinfo['rspool'][$row['id']]))
-               {
-                       $vsinfo['rspool'][$row['id']]['name'] = $row['name'];
-                       $vsinfo['rspool'][$row['id']]['vsconfig'] = $row['vsconfig'];
-                       $vsinfo['rspool'][$row['id']]['rsconfig'] = $row['rsconfig'];
-                       $vsinfo['rspool'][$row['id']]['lblist'] = array();
-               }
-               if ($row['object_id'] == NULL)
-                       continue;
-               $vsinfo['rspool'][$row['id']]['lblist'][$row['object_id']] = array
-               (
-                       'vsconfig' => $row['lb_vsconfig'],
-                       'rsconfig' => $row['lb_rsconfig']
-               );
-       }
-       $result->closeCursor();
-       return $vsinfo;
-}
-
 function addRStoRSPool ($pool_id = 0, $rsip = '', $rsport = 0, $inservice = 'no', $rsconfig = '')
 {
        if ($pool_id <= 0)
@@ -3522,7 +3511,7 @@ function getFileLinks ($file_id = 0)
                        case 'ipv4vs':
                                $page = 'ipv4vs';
                                $id_name = 'vs_id';
-                               $parent = getVServiceInfo($row['entity_id']);
+                               $parent = spotEntity ($row['entity_type'], $row['entity_id']);
                                $name = $parent['name'];
                                break;
                        case 'object':
index ee733f49205090b00600dfc4bf5c8ba6552263cd..48b5fe6cdad60ee876468bf786b238fca11d57f1 100644 (file)
@@ -4015,7 +4015,8 @@ function renderVirtualService ($vsid)
                showError ('Invalid argument', __FUNCTION__);
                return;
        }
-       $vsinfo = getVServiceInfo ($vsid);
+       $vsinfo = spotEntity ('ipv4vs', $vsid);
+       amplifyCell ($vsinfo);
        echo '<table border=0 class=objectview cellspacing=0 cellpadding=0>';
        if (!empty ($vsinfo['name']))
                echo "<tr><td colspan=2 align=center><h1>${vsinfo['name']}</h1></td></tr>\n";
@@ -4224,7 +4225,8 @@ function renderRSPoolLBForm ($pool_id)
 function renderVServiceLBForm ($vs_id)
 {
        global $nextorder;
-       $vsinfo = getVServiceInfo ($vs_id);
+       $vsinfo = spotEntity ('ipv4vs', $vs_id);
+       amplifyCell ($vsinfo);
 
        if (count ($vsinfo['rspool']))
        {
@@ -5045,7 +5047,8 @@ function renderEditRSPool ($pool_id)
 
 function renderEditVService ($vsid)
 {
-       $vsinfo = getVServiceInfo ($vsid);
+       $vsinfo = spotEntity ('ipv4vs', $vsid);
+       amplifyCell ($vsinfo);
        printOpFormIntro ('updIPv4VS');
        echo '<table border=0 align=center>';
        echo "<tr><th class=tdright>VIP:</th><td class=tdleft><input tabindex=1 type=text name=vip value='${vsinfo['vip']}'></td></tr>\n";
@@ -5658,7 +5661,7 @@ function renderRSPoolCell ($pool_id, $pool_name)
 // FIXME: migrate to renderIPv4VSCell()
 function renderVSCell ($vs_id)
 {
-       renderIPv4VSCell (getVServiceInfo ($vs_id));
+       renderIPv4VSCell (spotEntity ('ipv4vs', $vs_id));
 }
 
 function renderIPv4VSCell ($vsinfo)
@@ -5924,9 +5927,10 @@ function dynamic_title_decoder ($path_position)
                );
        case 'ipv4vs':
                assertUIntArg ('vs_id', __FUNCTION__);
+               $tmp = spotEntity ('ipv4vs', $_REQUEST['vs_id']);
                return array
                (
-                       'name' => buildVServiceName (getVServiceInfo ($_REQUEST['vs_id'])),
+                       'name' => $tmp['dname'],
                        'params' => array ('vs_id' => $_REQUEST['vs_id'])
                );
        case 'object':