function renderEditVService($vsid) { $vsinfo = spotEntity('ipv4vs', $vsid); printOpFormIntro('updIPv4VS'); echo '<table border=0 align=center>'; echo "<tr><th class=tdright>VIP:</th><td class=tdleft><input type=text name=vip value='{$vsinfo['vip']}'></td></tr>\n"; echo "<tr><th class=tdright>Port:</th><td class=tdleft><input type=text name=vport value='{$vsinfo['vport']}'></td></tr>\n"; echo "<tr><th class=tdright>Proto:</th><td class=tdleft>"; global $vs_proto; printSelect($vs_proto, array('name' => 'proto'), $vsinfo['proto']); echo "</td></tr>\n"; echo "<tr><th class=tdright>Name:</th><td class=tdleft><input type=text name=name value='{$vsinfo['name']}'></td></tr>\n"; echo "<tr><th class=tdright>Tags:</th><td class=tdleft>"; printTagsPicker(); echo "</td></tr>\n"; echo "<tr><th class=tdright>VS config:</th><td class=tdleft><textarea name=vsconfig rows=20 cols=80>{$vsinfo['vsconfig']}</textarea></td></tr>\n"; echo "<tr><th class=tdright>RS config:</th><td class=tdleft><textarea name=rsconfig rows=20 cols=80>{$vsinfo['rsconfig']}</textarea></td></tr>\n"; echo "<tr><th class=submit colspan=2>"; printImageHREF('SAVE', 'Save changes', TRUE); echo "</td></tr>\n"; echo "</table></form>\n"; // delete link echo '<p class="centered">'; if ($vsinfo['refcnt'] > 0) { echo getOpLink(NULL, 'Delete virtual service', 'nodestroy', "Could not delete: there are {$vsinfo['refcnt']} LB links"); } else { echo getOpLink(array('op' => 'del', 'id' => $vsinfo['id']), 'Delete virtual service', 'destroy'); } }
function renderUserProperties($user_id) { printOpFormIntro('edit'); echo '<table border=0 align=center>'; echo "<tr><th class=tdright>Tags:</th><td class=tdleft>"; printTagsPicker(); echo "</td></tr>\n"; echo "<tr><th class=submit colspan=2>"; printImageHREF('SAVE', 'Save changes', TRUE, 102); echo '</th></tr></table></form>'; }
function renderNewVSGForm() { startPortlet('Add new VS group'); printOpFormIntro('add'); echo '<table border=0 cellpadding=5 cellspacing=0 align=center>'; echo '<tr valign=bottom><th>Name:</th><td class="tdleft">'; echo '<input type=text name=name></td></tr>'; echo '<tr><th>Tags:</th><td class="tdleft">'; printTagsPicker(); echo '</td></tr>'; echo '</table>'; printImageHREF('CREATE', 'create virtual service', TRUE); echo '</form>'; finishPortlet(); }
function renderEditUCSForm() { startPortlet('UCS Actions'); printOpFormIntro('autoPopulateUCS'); echo '<table cellspacing=0 cellpadding=5 align=center class=widetable>'; echo "<tr><th class=tdright><label for=ucs_login>Login:</label></th>"; echo "<td class=tdleft colspan=2><input type=text name=ucs_login id=ucs_login></td></tr>\n"; echo "<tr><th class=tdright><label for=ucs_password>Password:</label></th>"; echo "<td class=tdleft colspan=2><input type=password name=ucs_password id=ucs_password></td></tr>\n"; echo "<tr><th colspan=3><input type=checkbox name=use_terminal_settings id=use_terminal_settings>"; echo "<label for=use_terminal_settings>Use Credentials from terminal_settings()</label></th></tr>\n"; echo "<tr><th class=tdright>Actions:</th><td class=tdleft>"; printImageHREF('DQUEUE sync_ready', 'Auto-populate UCS', TRUE); echo '</td><td class=tdright>'; echo getOpLink(array('op' => 'cleanupUCS'), '', 'CLEAR', 'Clean-up UCS domain', 'need-confirmation'); echo "</td></tr></table></form>\n"; finishPortlet(); }
function renderEditUCSForm() { startPortlet('UCS Actions'); printOpFormIntro('autoPopulateUCS'); echo '<table cellspacing=0 cellpadding=5 align=center class=widetable>'; echo "<tr><th class=tdright><label for=ucs_login>Login:</label></th>"; echo "<td class=tdleft colspan=2><input type=text name=ucs_login id=ucs_login></td></tr>\n"; echo "<tr><th class=tdright><label for=ucs_password>Password:</label></th>"; echo "<td class=tdleft colspan=2><input type=password name=ucs_password id=ucs_password></td></tr>\n"; echo "<tr><th colspan=3><input type=checkbox name=use_terminal_settings id=use_terminal_settings>"; echo "<label for=use_terminal_settings>Use Credentials from terminal_settings()</label></th></tr>\n"; echo "<tr><th class=tdright>Actions:</th><td class=tdleft>"; printImageHREF('DQUEUE sync_ready', 'Auto-populate UCS', TRUE); echo '</td><td class=tdright>'; echo "<a href='" . makeHrefProcess(array('op' => 'cleanupUCS', 'object_id' => getBypassValue())) . "' onclick=\"javascript:return confirm('Are you sure you want to cleanup UCS Domain?')\">" . getImageHREF('CLEAR', 'Clean-up UCS domain') . "</a>"; echo "</td></tr></table></form>\n"; finishPortlet(); }
function renderNetCellForAlloc($cell, $needed_mask = NULL) { if (empty($cell['spare_ranges']) and $cell['kidc'] == 0 and $cell['mask'] < 31) { $cell['spare_ranges'][$cell['mask'] + 1][] = $cell['ip_bin']; $cell['spare_ranges'][$cell['mask'] + 1][] = ip_last($cell) & ip4_mask($cell['mask'] + 1); } $ranges = array_keys($cell['spare_ranges']); sort($ranges, SORT_NUMERIC); foreach ($ranges as &$range) { $suffix = count($cell['spare_ranges'][$range]) <= 1 ? '' : '<small> x ' . count($cell['spare_ranges'][$range]) . '</small>'; $range = '<a href="' . makeHref(array('page' => 'ipv4space', 'tab' => 'newrange', 'set-prefix' => ip_format($cell['spare_ranges'][$range][0]) . '/' . $range)) . '">/' . $range . '</a>' . $suffix; } $spare_cidr = NULL; if (isset($needed_mask)) { for ($i = $needed_mask; $i > 0; $i--) { if (!empty($cell['spare_ranges'][$i])) { $spare_cidr = ip_format($cell['spare_ranges'][$i][0]) . '/' . $needed_mask; break; } } } echo "<table class='slbcell vscell'><tr><td rowspan=3 width='5%'>"; printImageHREF('NET'); echo '</td>'; echo "<td><a href='index.php?page={$cell['realm']}&id={$cell['id']}'>{$cell['ip']}/{$cell['mask']}</a>"; echo getRenderedIPNetCapacity($cell); echo '</td></tr>'; echo "<tr><td>"; if (strlen($cell['name'])) { echo "<strong>" . niftyString($cell['name']) . "</strong>"; } else { echo "<span class=sparenetwork>no name</span>"; } // render VLAN echo '<div class="vlan">' . implode(', ', $ranges) . '</div>'; renderNetVLAN($cell); echo "</td></tr>"; echo '<tr><td>'; echo count($cell['etags']) ? "<small>" . serializeTags($cell['etags']) . "</small>" : ' '; if (isset($spare_cidr)) { echo "<div class='vlan'><a href=\"" . makeHref(array('page' => 'ipv4space', 'tab' => 'newrange', 'set-prefix' => $spare_cidr)) . "\">Allocate /{$needed_mask}</a></div>"; } echo "</td></tr></table>"; }
function renderNetworkEditAttrs() { global $pageno, $netobject_type_id; $network = spotEntity($pageno === 'ipv4net' ? 'ipv4net' : 'ipv6net', getBypassValue()); $values = getAttrValuesForNetwork($network); echo '<p>'; startPortlet("Attributes"); printOpFormIntro('updateAttrs'); // optional attributes echo '<table border=0 cellspacing=0 cellpadding=3 align=center>'; $suggest_records = array(); if (count($values) > 0) { $i = 0; foreach ($values as $record) { if (!permitted(NULL, NULL, NULL, array(array('tag' => '$attr_' . $record['id']), array('tag' => '$any_op')))) { continue; } echo "<input type=hidden name={$i}_attr_id value={$record['id']}>"; echo '<tr><td>'; if (strlen($record['value'])) { echo "<a href='" . makeHrefProcess(array('op' => 'clearSticker', 'id' => $network['id'], 'attr_id' => $record['id'])) . "'>"; printImageHREF('clear', 'Clear value'); echo '</a>'; } else { echo ' '; } echo '</td>'; echo "<th class=sticker>{$record['name']}:</th><td class=tdleft>"; switch ($record['type']) { case 'uint': case 'float': case 'string': echo "<input type=text name={$i}_value value='{$record['value']}'>"; break; case 'dict': $suggest_records = array(); $chapter = readChapter($record['chapter_id'], 'o'); foreach ($chapter as $id => $value) { $suggest_records[$id] = array("id" => $id, "tag" => $value); } printSuggestedInput($i . "_value", $suggest_records, array("id" => $record['key']), "macros"); enableTagsPicker(); break; case 'date': $date_value = $record['value'] ? date(getConfigVar('DATETIME_FORMAT'), $record['value']) : ''; echo "<input type=text name={$i}_value value='{$date_value}'>"; break; } $i++; echo '<input type=hidden name=num_attrs value=' . $i . ">\n"; } } echo '</table>'; printImageHREF('SAVE', 'Save changes', TRUE); echo '</form>'; finishPortlet(); }
function printunlinktr($linktype = 'front', $remote_port = NULL) { if ($this->port_id === NULL) { return; } $urlparams = array('tab' => 'linkmgmt', 'op' => 'unlinkPort', 'port_id' => $this->port_id, 'object_id' => $this->port['object_id'], 'linktype' => $linktype); $confirmmsg = "unlink port " . $this->port['name']; if ($remote_port !== NULL) { $urlparams['remote_id'] = $remote_port->port['id']; $confirmmsg .= ' -> ' . $remote_port->port['name']; } $confirmmsg .= " ({$linktype})"; // TODO cableid echo "<tr><td align=\"center\"><a href='" . makeHrefProcess($urlparams) . "' onclick=\"return confirm('{$confirmmsg}');\">"; printImageHREF('cut', 'Unlink this port'); echo "</a></td></tr>"; }
function renderNodePingChecks($object_id) { $accounts = getNodePingAccounts(); $account_options = array(); foreach ($accounts as $account) { $account_options[$account['id']] = $account['name']; } startPortlet('Add new check'); echo "<table cellspacing=0 cellpadding=5 align='center'>\n"; echo "<tr><th> </th><th>Account</th><th>Check ID</th><th></th><th> </th></tr>\n"; printOpFormIntro('add'); echo '<tr><td>'; printImageHREF('add', 'add check', TRUE); echo '</td><td>' . getSelect($account_options, array('name' => 'account_id')); echo '</td><td><input type=text size=25 name=np_check_id tabindex=101></td><td>'; printImageHREF('add', 'add check', TRUE); echo "</td></tr></form></table>\n"; finishPortlet(); $checks = getUnlinkedNodePingChecks($object_id); if (count($checks) > 0) { $check_options = array(); foreach ($checks as $check) { $check_options[$check['id']] = sprintf("%s - %s", $check['label'], $check['type']); } startPortlet('Link existing check (' . count($checks) . ')'); echo "<table cellspacing=0 cellpadding=5 align='center'>\n"; printOpFormIntro('link'); echo '<tr><td>' . getSelect($check_options, array('name' => 'check_id')); echo '</td><td class=tdleft>'; printImageHREF('ATTACH', 'Link check', TRUE); echo "</td></tr></form></table>\n"; finishPortlet(); } addJs(<<<END function toggleVisibility(tbodyId) { \t\$("#" + tbodyId).toggle(); } END , TRUE); $checks = getNodePingChecks($object_id); startPortlet('NodePing checks (' . count($checks) . ')'); if (count($checks)) { echo "<table cellspacing=0 cellpadding=5 align=center class=widetable>\n"; echo "<tr><th> </th><th>Type</th><th>Label</th><th>Interval</th><th>Reason</th><th>Result</th><th>Unlink</th><th> </th></tr>\n"; $token = ''; foreach ($checks as $check) { printOpFormIntro('upd', array('check_id' => $check['check_id'])); echo '<tr><td><a href="' . makeHrefProcess(array('op' => 'del', 'check_id' => $check['check_id'])) . '">'; echo getImageHREF('delete', 'Unlink and delete this check') . '</a></td>'; echo "<td><a href=\"#\" onclick=\"toggleVisibility('{$check['check_id']}');\">{$check['type']}</a></td>"; echo "<td>{$check['label']}</td>"; echo "<td>{$check['check_interval']}</td>"; // re-use a nodeping object if it already exists and is using the same token as this check if ($check['token'] != $token) { $nodeping = new NodePingClient(array('token' => $check['token'])); } $token = $check['token']; $np_result_raw = $nodeping->result->get(array('id' => $check['np_check_id'], 'limit' => 5, 'clean' => true)); if (isset($np_result_raw['error'])) { echo "<td colspan=5>Error: {$check_status_raw['error']}</td>"; } else { $np_result = $np_result_raw[0]; if ($np_result['su']) { $reason = ''; $result_str = 'PASS'; $result_class = 'msg_success'; } else { $reason = $np_result['sc']; $result_str = 'FAIL'; $result_class = 'msg_error'; } echo "<td>{$reason}</td>"; echo "<td><span class='{$result_class}'>{$result_str}</span></td>"; } echo '<td class=center><a href="' . makeHrefProcess(array('op' => 'unlink', 'link_id' => $check['link_id'])) . '">'; echo getImageHREF('cut', 'Unlink this check') . '</a></td>'; echo '<td class=tdleft>'; printImageHREF('save', 'Save changes', TRUE); echo "</td></tr>\n"; echo "<tbody id='{$check['check_id']}' style='display:none;'><tr><td colspan=8>"; echo '<table cellspacing=0 cellpadding=5 align=left>'; // override the td styling so it doesn't have a border echo '<tr><th>Account</th><td align=left style="border-top: 0px;">' . getSelect($account_options, array('name' => 'account_id'), $check['account_id']) . '</td></tr>'; echo '<tr><th>Check ID</th><td align=left style="border-top: 0px;"><input type=text size=25 name=np_check_id value="' . $check['np_check_id'] . '"></td></tr>'; echo "<tr><th>Target</th><td align=left style=\"border-top:0px; word-wrap:break-word; max-width:250px;\">{$check['target']}</td></tr>"; echo '</table></form>'; echo '<table cellspacing=0 cellpadding=5 align=right>'; echo '<tr><th colspan=5>Last 5 Results</th></tr>'; echo '<tr><th>Time</th><th>Loc</th><th>Run Time</th><th>Response</th><th>Result</th></tr>'; foreach ($np_result_raw as $np_row) { // time is reported in miliseconds, so trim off the last 3 digits printf('<tr><td>%s</td>', date('H:i:s A', substr($np_row['s'], 0, -3))); printf('<td>%s</td>', strtoupper($np_row['l'][$np_row['s']])); if ($np_row['su']) { $result_str = 'PASS'; $result_class = 'msg_success'; } else { $result_str = 'FAIL'; $result_class = 'msg_error'; } echo "<td>{$np_row['rt']}</td>"; echo "<td>{$np_row['sc']}</td>"; echo "<td><span class='{$result_class}'>{$result_str}</span></td></tr>"; } echo '</table>'; echo "</td></tr></tbody>\n"; } echo "</table>\n"; } finishPortlet(); }
function renderMuninServersEditor() { function printNewItemTR() { printOpFormIntro('add'); echo '<tr>'; echo '<td>' . getImageHREF('create', 'add a new server', TRUE) . '</td>'; echo '<td><input type=text size=48 name=base_url></td>'; echo '<td> </td>'; echo '<td>' . getImageHREF('create', 'add a new server', TRUE) . '</td>'; echo '</tr></form>'; } echo '<table cellspacing=0 cellpadding=5 align=center class=widetable>'; echo '<tr><th> </th><th>base URL</th><th>graph(s)</th><th> </th></tr>'; if (getConfigVar('ADDNEW_AT_TOP') == 'yes') { printNewItemTR(); } foreach (getMuninServers() as $server) { printOpFormIntro('upd', array('id' => $server['id'])); echo '<tr><td>'; if ($server['num_graphs']) { printImageHREF('nodestroy', 'cannot delete, graphs exist'); } else { echo getOpLink(array('op' => 'del', 'id' => $server['id']), '', 'destroy', 'delete this server'); } echo '</td>'; echo '<td><input type=text size=48 name=base_url value="' . htmlspecialchars($server['base_url'], ENT_QUOTES, 'UTF-8') . '"></td>'; echo "<td class=tdright>{$server['num_graphs']}</td>"; echo '<td>' . getImageHREF('save', 'update this server', TRUE) . '</td>'; echo '</tr></form>'; } if (getConfigVar('ADDNEW_AT_TOP') != 'yes') { printNewItemTR(); } echo '</table>'; }