r1886 + extended search for RS pools and virtual services
authorDenis Ovsienko <infrastation@yandex.ru>
Mon, 14 Apr 2008 20:43:27 +0000 (20:43 +0000)
committerDenis Ovsienko <infrastation@yandex.ru>
Mon, 14 Apr 2008 20:43:27 +0000 (20:43 +0000)
inc/database.php
inc/functions.php
inc/interface.php

index c420a00..292733f 100644 (file)
@@ -1125,6 +1125,38 @@ function getIPv4AddressSearchResult ($terms)
        return $ret;
 }
 
+function getIPv4RSPoolSearchResult ($terms)
+{
+       $query = "select id as pool_id, name from IPRSPool where ";
+       $or = '';
+       foreach (explode (' ', $terms) as $term)
+       {
+               $query .= $or . "name like '%${term}%'";
+               $or = ' or ';
+       }
+       $result = useSelectBlade ($query);
+       $ret = array();
+       while ($row = $result->fetch (PDO::FETCH_ASSOC))
+               $ret[] = $row;
+       return $ret;
+}
+
+function getIPv4VServiceSearchResult ($terms)
+{
+       $query = "select id, inet_ntoa(vip) as vip, vport, proto, name from IPVirtualService where ";
+       $or = '';
+       foreach (explode (' ', $terms) as $term)
+       {
+               $query .= $or . "name like '%${term}%'";
+               $or = ' or ';
+       }
+       $result = useSelectBlade ($query);
+       $ret = array();
+       while ($row = $result->fetch (PDO::FETCH_ASSOC))
+               $ret[] = $row;
+       return $ret;
+}
+
 // This function returns either port ID or NULL for specified arguments.
 function getPortID ($object_id, $port_name)
 {
index 97a8213..78c338c 100644 (file)
@@ -1198,6 +1198,16 @@ function buildVServiceName ($vsinfo = NULL)
        return $vsinfo['vip'] . ':' . $vsinfo['vport'] . '/' . $vsinfo['proto'];
 }
 
+function buildRSPoolName ($rspool = NULL)
+{
+       if ($rspool == NULL)
+       {
+               showError ('NULL argument', __FUNCTION__);
+               return NULL;
+       }
+       return strlen ($rspool['name']) ? $rspool['name'] : 'ANONYMOUS pool';
+}
+
 // rackspace usage for a single rack
 // (T + W + U) / (height * 3 - A)
 function getRSUforRack ($data = NULL)
index 14d6f30..ce7f2ab 100644 (file)
@@ -2707,6 +2707,20 @@ function renderSearchResults ()
                        $lasthit = 'ipv4network';
                        $summary['ipv4network'] = $tmp;
                }
+               $tmp = getIPv4RSPoolSearchResult ($terms);
+               if (count ($tmp))
+               {
+                       $nhits += count ($tmp);
+                       $lasthit = 'ipv4rspool';
+                       $summary['ipv4rspool'] = $tmp;
+               }
+               $tmp = getIPv4VServiceSearchResult ($terms);
+               if (count ($tmp))
+               {
+                       $nhits += count ($tmp);
+                       $lasthit = 'ipv4vs';
+                       $summary['ipv4vs'] = $tmp;
+               }
        }
        if ($nhits == 0)
                echo "<center><h2>Nothing found for '${terms}'</h2></center>";
@@ -2738,6 +2752,12 @@ function renderSearchResults ()
                        case 'object':
                                echo "<script language='Javascript'>document.location='${root}?page=object&object_id=${record['id']}';//</script>";
                                break;
+                       case 'ipv4rspool':
+                               echo "<script language='Javascript'>document.location='${root}?page=rspool&pool_id=${record['pool_id']}';//</script>";
+                               break;
+                       case 'ipv4vs':
+                               echo "<script language='Javascript'>document.location='${root}?page=vservice&id=${record['id']}';//</script>";
+                               break;
                }
                return;
        }
@@ -2792,6 +2812,33 @@ function renderSearchResults ()
                                        echo '</table>';
                                        finishPortlet();
                                        break;
+                               case 'ipv4rspool':
+                                       startPortlet ('RS pools');
+                                       echo '<table border=0 cellpadding=5 cellspacing=0 align=center class=cooltable>';
+                                       foreach ($what as $rspool)
+                                       {
+                                               echo "<tr class=row_${order}><td class=tdleft><a href='${root}?page=rspool&pool_id=${rspool['pool_id']}'>";
+                                               echo buildRSPoolName ($rspool);
+                                               echo "</a></td></tr>";
+                                               $order = $nextorder[$order];
+                                       }
+                                       echo '</table>';
+                                       finishPortlet();
+                                       break;
+                               case 'ipv4vs':
+                                       startPortlet ('Virtual services');
+                                       echo '<table border=0 cellpadding=5 cellspacing=0 align=center class=cooltable>';
+                                       echo '<tr><th>VS</th><th>Descritpion</th></tr>';
+                                       foreach ($what as $vs)
+                                       {
+                                               echo "<tr class=row_${order}><td class=tdleft><a href='${root}?page=vservice&id=${vs['id']}'>";
+                                               echo buildVServiceName ($vs);
+                                               echo "</a></td><td>${vs['name']}</td></tr>";
+                                               $order = $nextorder[$order];
+                                       }
+                                       echo '</table>';
+                                       finishPortlet();
+                                       break;
                        }
        }
 }