function renderVirtualService($vsid)
{
    $vsinfo = spotEntity('ipv4vs', $vsid);
    echo '<table border=0 class=objectview cellspacing=0 cellpadding=0>';
    if (strlen($vsinfo['name'])) {
        echo "<tr><td colspan=2 align=center><h1>{$vsinfo['name']}</h1></td></tr>\n";
    }
    echo '<tr>';
    echo '<td class=pcleft>';
    $summary = array();
    $summary['Name'] = $vsinfo['name'];
    $summary['Protocol'] = $vsinfo['proto'];
    $summary['Virtual IP address'] = mkA($vsinfo['vip'], 'ipaddress', $vsinfo['vip']);
    $summary['Virtual port'] = $vsinfo['vport'];
    $summary['tags'] = '';
    $summary['VS configuration'] = '<div class="dashed slbconf">' . $vsinfo['vsconfig'] . '</div>';
    $summary['RS configuration'] = '<div class="dashed slbconf">' . $vsinfo['rsconfig'] . '</div>';
    renderEntitySummary($vsinfo, 'Summary', $summary);
    echo '</td>';
    echo '<td class=pcright>';
    renderSLBTriplets($vsinfo);
    echo '</td></tr><tr><td colspan=2>';
    renderFilesPortlet('ipv4vs', $vsid);
    echo '</tr><table>';
}
Beispiel #2
0
function renderIPAddress($ip_bin)
{
    global $aat, $nextorder;
    $address = getIPAddress($ip_bin);
    echo "<table border=0 class=objectview cellspacing=0 cellpadding=0>";
    echo "<tr><td colspan=2 align=center><h1>{$address['ip']}</h1></td></tr>\n";
    echo "<tr><td class=pcleft>";
    $summary = array();
    if (strlen($address['name'])) {
        $summary['Name'] = $address['name'];
    }
    if (strlen($address['comment'])) {
        $summary['Comment'] = $address['comment'];
    }
    $summary['Reserved'] = $address['reserved'];
    $summary['Allocations'] = count($address['allocs']);
    if (isset($address['outpf'])) {
        $summary['Originated NAT connections'] = count($address['outpf']);
    }
    if (isset($address['inpf'])) {
        $summary['Arriving NAT connections'] = count($address['inpf']);
    }
    renderEntitySummary($address, 'summary', $summary);
    // render SLB portlet
    if (!empty($address['vslist']) or !empty($address['vsglist']) or !empty($address['rsplist'])) {
        startPortlet("");
        if (!empty($address['vsglist'])) {
            printf("<h2>virtual service groups (%d):</h2>", count($address['vsglist']));
            foreach ($address['vsglist'] as $vsg_id) {
                renderSLBEntityCell(spotEntity('ipvs', $vsg_id));
            }
        }
        if (!empty($address['vslist'])) {
            printf("<h2>virtual services (%d):</h2>", count($address['vslist']));
            foreach ($address['vslist'] as $vs_id) {
                renderSLBEntityCell(spotEntity('ipv4vs', $vs_id));
            }
        }
        if (!empty($address['rsplist'])) {
            printf("<h2>RS pools (%d):</h2>", count($address['rsplist']));
            foreach ($address['rsplist'] as $rsp_id) {
                renderSLBEntityCell(spotEntity('ipv4rspool', $rsp_id));
            }
        }
        finishPortlet();
    }
    echo "</td>\n";
    echo "<td class=pcright>";
    if (isset($address['class']) and !empty($address['allocs'])) {
        startPortlet('allocations');
        echo "<table class='widetable' cellpadding=5 cellspacing=0 border=0 align='center' width='100%'>\n";
        echo "<tr><th>object</th><th>OS interface</th><th>allocation type</th></tr>\n";
        // render all allocation records for this address the same way
        foreach ($address['allocs'] as $bond) {
            $tr_class = "{$address['class']} tdleft";
            if (isset($_REQUEST['hl_object_id']) and $_REQUEST['hl_object_id'] == $bond['object_id']) {
                $tr_class .= ' highlight';
            }
            echo "<tr class='{$tr_class}'>" . "<td>" . makeIPAllocLink($ip_bin, $bond) . "</td>" . "<td>{$bond['name']}</td>" . "<td><strong>" . $aat[$bond['type']] . "</strong></td>" . "</tr>\n";
        }
        echo "</table><br><br>";
        finishPortlet();
    }
    if (!empty($address['rsplist'])) {
        startPortlet("RS pools:");
        foreach ($address['rsplist'] as $rsp_id) {
            renderSLBEntityCell(spotEntity('ipv4rspool', $rsp_id));
            echo '<br>';
        }
        finishPortlet();
    }
    if (!empty($address['vsglist'])) {
        foreach ($address['vsglist'] as $vsg_id) {
            renderSLBTriplets2(spotEntity('ipvs', $vsg_id), FALSE, $ip_bin);
        }
    }
    if (!empty($address['vslist'])) {
        renderSLBTriplets($address);
    }
    foreach (array('outpf' => 'departing NAT rules', 'inpf' => 'arriving NAT rules') as $key => $title) {
        if (!empty($address[$key])) {
            startPortlet($title);
            echo "<table class='widetable' cellpadding=5 cellspacing=0 border=0 align='center' width='100%'>\n";
            echo "<tr><th>proto</th><th>from</th><th>to</th><th>comment</th></tr>\n";
            foreach ($address[$key] as $rule) {
                echo "<tr>";
                echo "<td>" . $rule['proto'] . "</td>";
                echo "<td>" . getRenderedIPPortPair($rule['localip'], $rule['localport']) . "</td>";
                echo "<td>" . getRenderedIPPortPair($rule['remoteip'], $rule['remoteport']) . "</td>";
                echo "<td>" . $rule['description'] . "</td></tr>";
                echo "</tr>";
            }
            echo "</table>";
            finishPortlet();
        }
    }
    echo "</td></tr>";
    echo "</table>\n";
}