r2124 - split builting and local reports
authorDenis Ovsienko <infrastation@yandex.ru>
Mon, 11 Aug 2008 20:32:06 +0000 (20:32 +0000)
committerDenis Ovsienko <infrastation@yandex.ru>
Mon, 11 Aug 2008 20:32:06 +0000 (20:32 +0000)
 - add messages for IPv4 network mgmt funcs (not used atm though)
 - fix ChangeLog items

ChangeLog
inc/interface.php
inc/navigation.php
inc/triggers.php

index 789dc56c0fe5b3a91ff783df84a5fd326e1d5c12..a17137df074da1a9a16487fd074e2e90c1718549 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -2,7 +2,8 @@
        bugfix: IP address picker was broken
        bugfix: more message processing fixes
        new feature: "router" addresses allocations
-       new feature: router configuration exporter
+       new feature: support for local extensions
+       new feature: IPv4 networks hierarchy
        update: 3 more switches in SNMP code by Walery Wysotsky
 0.16.1 2008-07-30
        new feature: pre-assigned tags for new VS and RS pools records
index 2f86118909359bf897b40da32b878ac24009e391..72fdc756a085e3de9333421bd6147bb03f51b753 100644 (file)
@@ -118,6 +118,10 @@ $image['DENIED']['path'] = 'pix/tango-dialog-error-big.png';
 $image['DENIED']['width'] = 32;
 $image['DENIED']['height'] = 32;
 
+// This may be populated later onsite, report rendering function will use it.
+// See the $systemreport for structure.
+$localreports = array();
+
 // Main menu.
 function renderIndex ()
 {
@@ -1317,6 +1321,10 @@ function printLog ($log)
                                170 => array ('code' => 'error', 'format' => 'There is no network for IP address "%s"'),
                                171 => array ('code' => 'error', 'format' => "Failed creating rack '%s'. Already exists in this row?"),
                                172 => array ('code' => 'error', 'format' => 'Malformed request'),
+                               173 => array ('code' => 'error', 'format' => "Invalid IPv4 prefix '%s'"),
+                               174 => array ('code' => 'error', 'format' => 'Bad IPv4 address'),
+                               175 => array ('code' => 'error', 'format' => 'Invalid netmask'),
+                               176 => array ('code' => 'error', 'format' => 'This network already exists'),
 
                                200 => array ('code' => 'warning', 'format' => 'generic warning: %s'),
                                201 => array ('code' => 'warning', 'format' => 'nothing happened...'),
@@ -3448,44 +3456,72 @@ function getFaviconURL ()
 }
 
 // FIXME: stack the report sections somehow, so they can register themselves.
-function renderReportSummary ()
+function renderSystemReports ()
 {
-       echo "<table width='100%'>\n";
-       echo "<tr><td class=pcleft>\n";
-       startPortlet ("Dictionary/objects");
-       echo "<table>\n";
-       foreach (getDictStats() as $header => $data)
-               echo "<tr><th class=tdright>${header}:</th><td class=tdleft>${data}</td></tr>\n";
-       echo "</table>\n";
-       finishPortlet();
-       startPortlet ('IPv4');
-       echo "<table>\n";
-       foreach (getIPv4Stats() as $header => $data)
-               echo "<tr><th class=tdright>${header}:</th><td class=tdleft>${data}</td></tr>\n";
-       echo "</table>\n";
-       finishPortlet();
-       startPortlet ('Rackspace');
-       echo "<table>\n";
-       foreach (getRackspaceStats() as $header => $data)
-               echo "<tr><th class=tdright>${header}:</th><td class=tdleft>${data}</td></tr>\n";
-       echo "</table>\n";
-       finishPortlet();
-       startPortlet ('RackCode');
-       echo "<table>\n";
-       foreach (getRackCodeStats() as $header => $data)
-               echo "<tr><th class=tdright>${header}:</th><td class=tdleft>${data}</td></tr>\n";
-       echo "</table>\n";
-       finishPortlet();
+       $systemreports = array
+       (
+               array
+               (
+                       'title' => 'Dictionary/objects',
+                       'type' => 'counters',
+                       'func' => 'getDictStats'
+               ),
+               array
+               (
+                       'title' => 'IPv4',
+                       'type' => 'counters',
+                       'func' => 'getIPv4Stats'
+               ),
+               array
+               (
+                       'title' => 'Rackspace',
+                       'type' => 'counters',
+                       'func' => 'getRackspaceStats'
+               ),
+               array
+               (
+                       'title' => 'RackCode',
+                       'type' => 'counters',
+                       'func' => 'getRackCodeStats'
+               ),
+               array
+               (
+                       'title' => 'Tag popularity',
+                       'type' => 'counters',
+                       'func' => 'getTagStats'
+               ),
+       );
+       renderReports ($systemreports);
+}
 
-       echo "</td><td class=pcright>\n";
+function renderLocalReports ()
+{
+       global $localreports;
+       renderReport ($localreports);
+}
 
-       startPortlet ("Tag popularity");
-       echo "<table>\n";
-       foreach (getTagStats() as $header => $data)
-               echo "<tr><th class=tdright>${header}:</th><td class=tdleft>${data}</td></tr>\n";
-       echo "</table>\n";
-       finishPortlet();
-       echo "</td></tr>\n";
+function renderReports ($what)
+{
+       if (!count ($what))
+               return;
+       echo "<table align=center>\n";
+       foreach ($what as $item)
+       {
+               echo "<tr><th colspan=2><h3>${item['title']}</h3></th></tr>\n";
+               switch ($item['type'])
+               {
+                       case 'counters':
+                               foreach ($item['func'] () as $header => $data)
+                                       echo "<tr><td class=tdright>${header}:</td><td class=tdleft>${data}</td></tr>\n";
+                               break;
+                       case 'custom':
+                               $item['func'] ();
+                               break;
+                       default:
+                               showError ('Internal data error', __FUNCTION__);
+               }
+               echo "<tr><td colspan=2><hr></td></tr>\n";
+       }
        echo "</table>\n";
 }
 
index 861705bd715d0a939a08dd1160e8c43ccb8e76e6..34a18fb68130a260fa8ff1236deb14b94fe522ca 100644 (file)
@@ -210,6 +210,10 @@ $ophandler['ipv4space']['newrange']['delIPv4Prefix'] = 'delIPv4Prefix';
 $ophandler['ipv4space']['newrange']['updIPv4Prefix'] = 'updIPv4Prefix';
 $msgcode['ipv4space']['newrange']['addIPv4Prefix']['OK'] = 23;
 $msgcode['ipv4space']['newrange']['addIPv4Prefix']['ERR'] = 100;
+$msgcode['ipv4space']['newrange']['addIPv4Prefix']['ERR1'] = 173;
+$msgcode['ipv4space']['newrange']['addIPv4Prefix']['ERR2'] = 174;
+$msgcode['ipv4space']['newrange']['addIPv4Prefix']['ERR3'] = 175;
+$msgcode['ipv4space']['newrange']['addIPv4Prefix']['ERR4'] = 176;
 $msgcode['ipv4space']['newrange']['delIPv4Prefix']['OK'] = 24;
 $msgcode['ipv4space']['newrange']['delIPv4Prefix']['ERR'] = 100;
 
@@ -532,7 +536,11 @@ $msgcode['myaccount']['mypassword']['changeMyPassword']['ERR4'] = 153;
 
 $page['reports']['title'] = 'Reports';
 $page['reports']['parent'] = 'index';
-$page['reports']['handler'] = 'renderReportSummary';
+$tab['reports']['default'] = 'System';
+$tab['reports']['local'] = 'Local';
+$trigger['reports']['local'] = 'trigger_localreports';
+$tabhandler['reports']['default'] = 'renderSystemReports';
+$tabhandler['reports']['local'] = 'renderLocalReports';
 
 // This function returns array if page numbers leading to the target page
 // plus page number of target page itself. The first element is the target
index 10c71264c7d9de0c4ab34213b33ba0fd6e25f783..074dffef16d5d76c1228458b0f77b5ee7d90b370 100644 (file)
@@ -106,4 +106,10 @@ function trigger_passwdchange ()
        return getConfigVar ('USER_AUTH_SRC') == 'database';
 }
 
+function trigger_localreports ()
+{
+       global $localreports;
+       return count ($localreports) > 0;
+}
+
 ?>