"; renderTagFilterPortlet ($tagfilter, 'rack'); echo ''; echo ''; // generate thumb gallery $rackrowList = getRackspace ($tagfilter); global $root, $nextorder; $rackwidth = getConfigVar ('rtwidth_0') + getConfigVar ('rtwidth_1') + getConfigVar ('rtwidth_2'); $order = 'odd'; foreach ($rackrowList as $rackrow) { echo ""; $rackList = getRacksForRow ($rackrow['row_id'], $tagfilter); echo "\n"; $order = $nextorder[$order]; } echo "
"; echo ""; echo "${rackrow['row_name']}"; foreach ($rackList as $rack) { echo ""; } echo "
"; echo ""; echo "
${rack['name']}
\n"; echo "\n"; } function renderRow ($row_id) { if ($row_id == 0) { showError ('Invalid row_id', __FUNCTION__); return; } if (($rowInfo = getRackRowInfo ($row_id)) == NULL) { showError ('getRackRowInfo() failed', __FUNCTION__); return; } $tagfilter = getTagFilter(); $rackList = getRacksForRow ($row_id, $tagfilter); // Main layout starts. echo ""; // Left portlet with row information. echo ""; echo "
"; startPortlet ($rowInfo['dict_value']); echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
Racks:${rowInfo['count']}
Units:${rowInfo['sum']}
Utilization:"; renderProgressBar (getRSUforRackRow ($rackList)); echo "

\n"; finishPortlet(); echo "
"; global $root, $nextorder; $rackwidth = getConfigVar ('rtwidth_0') + getConfigVar ('rtwidth_1') + getConfigVar ('rtwidth_2'); $order = 'odd'; startPortlet ('Racks'); echo ""; foreach ($rackList as $rack) { echo ""; $order = $nextorder[$order]; } echo "
"; echo ""; echo "
${rack['name']}
\n"; finishPortlet(); echo "
"; renderTagFilterPortlet ($tagfilter, 'rack', 'row_id', $row_id); echo "
"; } function showError ($info = '', $funcname = 'N/A') { global $root; echo "
An error has occured in function [${funcname}]. "; if (empty ($info)) echo 'No additional information is available.'; else echo "Additional information:

\n

\n${info}\n

"; echo "Go back or try starting from index page.
\n"; } // This function renders rack as HTML table. function renderRack ($rack_id = 0, $hl_obj_id = 0) { if ($rack_id == 0) { showError ('Invalid rack_id', __FUNCTION__); return; } if (($rackData = getRackData ($rack_id)) == NULL) { showError ('getRackData() failed', __FUNCTION__); return; } global $root, $pageno, $tabno; markAllSpans ($rackData); if ($hl_obj_id > 0) highlightObject ($rackData, $hl_obj_id); markupObjectProblems ($rackData); $prev_id = getPrevIDforRack ($rackData['row_id'], $rack_id); $next_id = getNextIDforRack ($rackData['row_id'], $rack_id); echo "
"; echo ""; // FIXME: use 'bypass'? if ($prev_id != NULL) { echo ""; } echo ""; if ($next_id != NULL) { echo ""; } echo "

${rackData['row_name']} :

"; printImageHREF ('prev', 'previous rack'); echo "

${rackData['name']}

"; printImageHREF ('next', 'next rack'); echo "
\n"; if ($rackData['left_is_front'] == 'yes') $markup = array ('left' => 'Front', 'right' => 'Back'); else $markup = array ('left' => 'Back', 'right' => 'Front'); echo "\n"; echo ""; echo "\n"; for ($i = $rackData['height']; $i > 0; $i--) { echo ''; for ($locidx = 0; $locidx < 3; $locidx++) { if (isset ($rackData[$i][$locidx]['skipped'])) continue; $state = $rackData[$i][$locidx]['state']; echo "'; } echo "\n"; } echo "
 ${markup['left']}Interior${markup['right']}
' . ($rackData['bottom_is_unit1'] == 'yes' ? $i : $rackData['height'] - $i + 1) . '"; switch ($state) { case 'T': $objectData = getObjectInfo ($rackData[$i][$locidx]['object_id']); if (!empty ($objectData['asset_no'])) $prefix = "
"; else $suffix = "'>"; echo $prefix . $suffix; echo "${objectData['dname']}
"; break; case 'A': echo '
 
'; break; case 'F': echo '
 
'; break; case 'U': echo '
 
'; break; default: echo '
 
'; break; } echo '
\n"; } function renderNewObjectForm () { global $pageno, $tabno; // Look for current submit. if (isset ($_REQUEST['got_data'])) { $log = array(); assertUIntArg ('object_type_id', __FUNCTION__); assertStringArg ('object_name', __FUNCTION__, TRUE); assertStringArg ('object_label', __FUNCTION__, TRUE); assertStringArg ('object_barcode', __FUNCTION__, TRUE); assertStringArg ('object_asset_no', __FUNCTION__, TRUE); $type_id = $_REQUEST['object_type_id']; $name = $_REQUEST['object_name']; $label = $_REQUEST['object_label']; $asset_no = $_REQUEST['object_asset_no']; $barcode = $_REQUEST['object_barcode']; if (commitAddObject ($name, $label, $barcode, $type_id, $asset_no) === TRUE) $log[] = array ('code' => 'success', 'message' => "Added new object '${name}'"); else $log[] = array ('code' => 'error', 'message' => __FUNCTION__ . ': commitAddObject() failed'); printLog ($log); } // Render a form for the next. startPortlet ('Object attributes'); echo '
'; echo ""; echo ""; echo ''; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo '
Type:"; $typelist = getObjectTypeList(); $typelist[0] = 'select type...'; printSelect ($typelist, 'object_type_id', getConfigVar ('DEFAULT_OBJECT_TYPE')); echo "
Common name:
Visible label:
Asset tag:
Barcode:
'; finishPortlet(); } function renderNewRackForm ($row_id) { global $pageno, $tabno; // Look for current submit. if (isset ($_REQUEST['got_data'])) { $log = array(); assertStringArg ('rack_name', __FUNCTION__); assertUIntArg ('rack_height', __FUNCTION__); assertStringArg ('rack_comment', __FUNCTION__, TRUE); $name = $_REQUEST['rack_name']; $height = $_REQUEST['rack_height']; $comment = $_REQUEST['rack_comment']; if (commitAddRack ($name, $height, $row_id, $comment) === TRUE) $log[] = array ('code' => 'success', 'message' => "Added new rack '${name}'"); else $log[] = array ('code' => 'error', 'message' => __FUNCTION__ . 'commitAddRack() failed'); printLog ($log); } // Render a form for the next. startPortlet ('Rack attributes'); echo '
'; echo ""; echo ""; echo ""; echo ''; $defh = getConfigVar ('DEFAULT_RACK_HEIGHT'); if ($defh == 0) $defh = ''; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo '
Name (required):
Height in units (required):
Comment:
'; finishPortlet(); } function renderEditObjectForm ($object_id) { showMessageOrError(); // Handle submit. if (isset ($_REQUEST['got_data'])) { $log = array(); // object_id is already verified by page handler assertUIntArg ('object_type_id', __FUNCTION__); assertStringArg ('object_name', __FUNCTION__, TRUE); assertStringArg ('object_label', __FUNCTION__, TRUE); assertStringArg ('object_barcode', __FUNCTION__, TRUE); assertStringArg ('object_asset_no', __FUNCTION__, TRUE); $type_id = $_REQUEST['object_type_id']; if (isset ($_REQUEST['object_has_problems']) and $_REQUEST['object_has_problems'] == 'on') $has_problems = 'yes'; else $has_problems = 'no'; $name = $_REQUEST['object_name']; $label = $_REQUEST['object_label']; $barcode = $_REQUEST['object_barcode']; $asset_no = $_REQUEST['object_asset_no']; $comment = $_REQUEST['object_comment']; if (commitUpdateObject ($object_id, $name, $label, $barcode, $type_id, $has_problems, $asset_no, $comment) === TRUE) $log[] = array ('code' => 'success', 'message' => "Updated object '${name}'"); else $log[] = array ('code' => 'error', 'message' => __FUNCTION__ . ': commitUpdateObject() failed'); // Invalidate thumb cache of all racks objects could occupy. foreach (getResidentRacksData ($object_id, FALSE) as $rack_id) resetThumbCache ($rack_id); printLog ($log); } global $pageno, $tabno; $object = getObjectInfo ($object_id); if ($object == NULL) { showError ('getObjectInfo() failed', __FUNCTION__); return; } // Render a form for the next submit; echo ''; echo ''; // Optional attributes. echo ''; echo ''; echo ''; echo '
'; startPortlet ('Static attributes'); echo '
'; echo ""; echo ""; echo ""; echo ""; echo ''; echo "\n"; // Common attributes. echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo ""; echo "\n"; echo '
Type:"; printSelect (getObjectTypeList(), 'object_type_id', $object['objtype_id']); echo "
Common name:
Visible label:
Asset tag:
Barcode:
Has problems:
Comment:
"; printImageHREF ('SAVE', 'Save changes', TRUE); echo "

'; finishPortlet(); echo '
'; startPortlet ('Optional attributes'); $values = getAttrValues ($object_id); global $root; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo '"; echo ''; echo "\n"; $i++; } echo "\n"; echo ""; echo "
 AttributeValue 
'; if (!empty ($record['value'])) { echo ""; printImageHREF ('clear', 'Clear value'); echo ''; } else echo ' '; echo '${record['name']}:"; switch ($record['type']) { case 'uint': case 'float': case 'string': echo ""; break; case 'dict': $chapter = readChapter ($record['chapter_name']); $chapter[0] = '-- NOT SET --'; printSelect ($chapter, "${i}_value", $record['key']); break; } echo "
"; printImageHREF ('SAVE', 'Save changes', TRUE); echo "
\n"; finishPortlet(); echo '
'; startPortlet ('history'); renderHistory ($pageno, $object_id); finishPortlet(); echo '
'; } // This is a clone of renderEditObjectForm(). function renderEditRackForm ($rack_id) { // Handle submit. if (isset ($_REQUEST['got_data'])) { $log = array(); assertUIntArg ('rack_row_id', __FUNCTION__); assertUIntArg ('rack_height', __FUNCTION__); assertStringArg ('rack_name', __FUNCTION__); assertStringArg ('rack_comment', __FUNCTION__, TRUE); $row_id = $_REQUEST['rack_row_id']; $height = $_REQUEST['rack_height']; $name = $_REQUEST['rack_name']; $comment = $_REQUEST['rack_comment']; if (commitUpdateRack ($rack_id, $name, $height, $row_id, $comment) === TRUE) $log[] = array ('code' => 'success', 'message' => "Updated rack '${name}'"); else $log[] = array ('code' => 'error', 'message' => __FUNCTION__ . ': commitUpdateRack() failed'); resetThumbCache ($rack_id); printLog ($log); } global $pageno, $tabno; $rack = getRackData ($rack_id); if ($rack == NULL) { showError ('getRackData() failed', __FUNCTION__); return; } // Render a form for the next. startPortlet ('Rack attributes'); echo '
'; echo ""; echo ""; echo ""; echo ''; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo '
Rack row:"; printSelect (readChapter ('RackRow'), 'rack_row_id', $rack['row_id']); echo "
Name (required):
Height (required):
Comment:

'; finishPortlet(); startPortlet ('History'); renderHistory ($pageno, $rack_id); finishPortlet(); } // This is a helper for creators and editors. function printSelect ($rowList, $select_name, $selected_id = 1) { // First collect all data for OPTGROUPs, then ouput it and dump // the rest of records as is. $optgroup = array(); $other = array(); foreach ($rowList as $dict_key => $dict_value) { if (strpos ($dict_value, '%GSKIP%') !== FALSE) { $tmp = explode ('%GSKIP%', $dict_value, 2); $optgroup[$tmp[0]][$dict_key] = $tmp[1]; } elseif (strpos ($dict_value, '%GPASS%') !== FALSE) { $tmp = explode ('%GPASS%', $dict_value, 2); $optgroup[$tmp[0]][$dict_key] = $tmp[1]; } else $other[$dict_key] = $dict_value; } echo ""; } // used by renderGridForm() and renderRackPage() function renderRackInfoPortlet ($rackData) { startPortlet ('summary'); echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; printTagTRs ("${root}?page=rackspace&"); if (!empty ($rackData['comment'])) echo "\n"; echo '
Rack row:${rackData['row_name']}
Name:${rackData['name']}
Height:${rackData['height']}
Utilization:"; renderProgressBar (getRSUforRack ($rackData)); echo "
Objects:"; echo getObjectCount ($rackData); echo "
Comment:${rackData['comment']}
'; finishPortlet(); } // This is a universal editor of rack design/waste. function renderGridForm ($rack_id = 0, $filter, $header, $submit, $state1, $state2) { if ($rack_id == 0) { showError ('Invalid rack_id', __FUNCTION__); return; } if (($rackData = getRackData ($rack_id)) == NULL) { showError ('getRackData() failed', __FUNCTION__); return; } global $root, $pageno, $tabno; $filter ($rackData); markupObjectProblems ($rackData); // Process form submit. if (isset ($_REQUEST['do_update'])) { $log[] = processGridForm ($rackData, $state1, $state2); printLog ($log); $rackData = getRackData ($rack_id); $filter ($rackData); markupObjectProblems ($rackData); } // Render the result whatever it is. // Main layout. echo ""; echo "\n"; // Left column with information portlet. echo "\n"; echo "

${rackData['name']}

"; renderRackInfoPortlet ($rackData); echo ""; // Grid form. startPortlet ($header); echo "
\n"; echo "\n"; echo ""; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; markupAtomGrid ($rackData, $state2); renderAtomGrid ($rackData); echo "
 FrontInteriorBack
\n"; echo "


\n"; finishPortlet(); echo "
\n"; } function renderRackDesign ($rack_id) { renderGridForm ($rack_id, 'applyRackDesignMask', 'Rack design', 'Set rack design', 'A', 'F'); } function renderRackProblems ($rack_id = 0) { renderGridForm ($rack_id, 'applyRackProblemMask', 'Rack problems', 'Mark unusable atoms', 'F', 'U'); } function startPortlet ($title = '') { echo "

${title}

"; } function finishPortlet () { echo "
\n"; } function printRefsOfType ($refs, $type, $eq) { global $root; $gotone=0; foreach ($refs as $ref) { if ($eq($ref['type'], $type)) { if ($gotone) echo ', '; echo ""; if (!empty ($ref['name'])) echo $ref['name'] . '@'; echo "${ref['object_name']}"; $gotone=1; } } } function renderRackObject ($object_id = 0) { global $root; if ($object_id <= 0) { showError ('Invalid object_id', __FUNCTION__); return; } $info = getObjectInfo ($object_id); if ($info == NULL) { showError ('getObjectInfo() failed', __FUNCTION__); return; } // Main layout starts. echo ""; echo "\n"; // left column with uknown number of portlets echo "\n"; // After left column we have (surprise!) right column with rackspace portled only. echo ""; echo "

${info['dname']}

"; startPortlet ('Object information'); echo "\n"; if (!empty ($info['name'])) echo "\n"; elseif (in_array ($info['objtype_id'], explode (',', getConfigVar ('NAMEFUL_OBJTYPES')))) echo "\n"; echo ""; echo "\n"; if (!empty ($info['asset_no'])) echo "\n"; elseif (in_array ($info['objtype_id'], explode (',', getConfigVar ('REQUIRE_ASSET_TAG_FOR')))) echo "\n"; if (!empty ($info['label'])) echo "\n"; if (!empty ($info['barcode'])) echo "\n"; if ($info['has_problems'] == 'yes') echo "\n"; foreach (getAttrValues ($object_id, TRUE) as $record) if (!empty ($record['value'])) echo "\n"; printTagTRs ("${root}?page=objgroup&group_id=${info['objtype_id']}&"); echo "
Common name:${info['name']}
Common name is missing.
Object type:${info['objtype_name']}
Asset tag:${info['asset_no']}
Asset tag is missing.
Visible label:${info['label']}
Barcode:${info['barcode']}
Has problems
${record['name']}:${record['a_value']}

\n"; finishPortlet(); if (!empty ($info['comment'])) { startPortlet ('Comment'); echo '
' . string_insert_hrefs ($info['comment']) . '
'; finishPortlet (); } $ports = getObjectPortsAndLinks ($object_id); if (count ($ports)) { startPortlet ('Ports and links'); usort($ports, 'sortByName'); if ($ports) { $hl_port_id = 0; if (isset ($_REQUEST['hl_port_id'])) { assertUIntArg ('hl_port_id', __FUNCTION__); $hl_port_id = $_REQUEST['hl_port_id']; } echo "\n"; echo ""; echo "\n"; foreach ($ports as $port) { echo '"; echo ""; if ($port['remote_object_id']) { echo ""; echo ""; } elseif (!empty ($port['reservation_comment'])) { echo ""; echo ""; } else echo ''; echo "\n"; } echo "
Local nameVisible labelPort typeL2 addressRem. ObjectRem. port
${port['name']}${port['label']}${port['type']}${port['l2address']}${port['remote_object_name']}${port['remote_name']}Reserved;${port['reservation_comment']}  

\n"; } finishPortlet(); } $addresses = getObjectAddresses ($object_id); usort($addresses, 'sortAddresses'); if (count ($addresses)) { startPortlet ('IPv4 addresses'); echo "\n"; echo "\n"; foreach ($addresses as $addr) { if (strlen($addr['address_name'])>40) $address_name = substr($addr['address_name'],0,38).'...'; else $address_name = $addr['address_name']; $virtnum = countRefsOfType($addr['references'], 'virtual', 'eq'); $sharednum = countRefsOfType($addr['references'], 'shared', 'eq'); $regnum = countRefsOfType($addr['references'], 'regular', 'eq'); $notvirtnum = countRefsOfType($addr['references'], 'virtual', 'neq'); if ($addr['address_reserved']=='yes') $class='trerror'; elseif ($addr['type']!='virtual' && $regnum>0) $class='trerror'; elseif ($addr['type']=='regular' && $sharednum>0) $class='trerror'; else $class=''; echo "\n"; } echo "
Interface nameIP AddressDescriptionMisc
${addr['name']}${addr['ip']}$address_name\n"; if ($addr['address_reserved']=='yes') echo "Reserved; "; if ($addr['type'] == 'virtual') { echo "V"; if ($notvirtnum > 0) { echo " Owners: "; printRefsOfType($addr['references'], 'virtual', 'neq'); } } elseif ($addr['type'] == 'shared') { echo "S"; if ($sharednum > 0) { echo " Peers: "; printRefsOfType($addr['references'], 'shared', 'eq'); echo ";"; } if ($virtnum > 0) { echo " Virtuals: "; printRefsOfType($addr['references'], 'virtual', 'eq'); echo ";"; } if ($regnum > 0) { echo " Collisions: "; printRefsOfType($addr['references'], 'regular', 'eq'); } } else { if ($virtnum > 0) { echo " Virtuals: "; printRefsOfType($addr['references'], 'virtual', 'eq'); echo ";"; } if ($notvirtnum > 0) { echo " Collisions: "; printRefsOfType($addr['references'], 'virtual', 'neq'); } } echo "

\n"; finishPortlet(); } $forwards = getNATv4ForObject ($object_id); if (count($forwards['in']) or count($forwards['out'])) { startPortlet('NATv4'); if (count($forwards['out'])) { echo "

locally performed NAT

"; echo "\n"; echo "\n"; foreach ($forwards['out'] as $pf) { $class='trerrorg'; $name=''; foreach ($addresses as $addr) if ($addr['ip'] == $pf['localip']) { $class=''; $name=$addr['name']; break; } echo ""; echo ""; echo ""; $address=getIPAddress($pf['remoteip']); echo ""; echo ""; } echo "
ProtoMatch endpointTranslate toTarget objectRule comment
${pf['proto']}${name}: ${pf['localip']}:${pf['localport']}${pf['remoteip']}:${pf['remoteport']}"; if (count ($address['bonds'])) foreach($address['bonds'] as $bond) echo "${bond['object_name']}(${bond['name']}) "; elseif (!empty ($pf['remote_addr_name'])) echo '(' . $pf['remote_addr_name'] . ')'; echo "${pf['description']}


"; } if (count($forwards['in'])) { echo "

arriving NAT connections

"; echo "\n"; echo "\n"; foreach ($forwards['in'] as $pf) { echo ""; echo ""; echo ""; echo ""; } echo "
Matched endpointSource objectTranslated toRule comment
${pf['proto']}/${pf['localip']}:${pf['localport']}${pf['object_name']}"; echo "${pf['remoteip']}:${pf['remoteport']}${pf['description']}


"; } finishPortlet(); } $pools = getRSPoolsForObject ($object_id); if (count ($pools)) { startPortlet ('Real server pools'); echo "\n"; echo "\n"; foreach ($pools as $vs_id => $info) { echo "'; echo ""; echo ""; echo "\n"; } echo "
VSRS poolRSVS configRS config
"; echo buildVServiceName ($info); echo ''; if (!empty ($info['name'])) echo " (${info['name']})"; echo ""; echo (empty ($info['pool_name']) ? 'ANONYMOUS' : $info['pool_name']); echo '' . $info['rscount'] . '
${info['vsconfig']}
${info['rsconfig']}
\n"; finishPortlet(); } echo "
"; // rackspace portlet startPortlet ('Rackspace allocation'); // FIXME: now we call getRackData() twice $racks = getResidentRacksData ($object_id); foreach ($racks as $rackData) renderRack ($rackData['id'], $object_id); echo '
'; finishPortlet(); echo "
\n"; } function renderRackMultiSelect ($sname, $racks, $selected) { echo "\n"; } function showMessageOrError () { if (isset($_REQUEST['message'])) echo "
${_REQUEST['message']}
"; if (isset($_REQUEST['error'])) echo "
${_REQUEST['error']}
"; } // This function renders a form for port edition. function renderPortsForObject ($object_id = 0) { global $root, $pageno, $tabno; if ($object_id <= 0) { showError ('Invalid object_id', __FUNCTION__); return; } showMessageOrError(); startPortlet ('Ports and interfaces'); $ports = getObjectPortsAndLinks ($object_id); usort($ports, 'sortByName'); echo "\n"; echo ""; echo "\n"; foreach ($ports as $port) { echo ""; echo ""; echo "\n"; echo "\n"; echo ""; echo "\n"; echo "\n"; echo ""; echo ""; echo "\n"; echo "\n"; if ($port['remote_object_id']) { echo ""; echo ""; echo ""; } elseif (!empty ($port['reservation_comment'])) { echo ""; echo ""; echo ""; } else { echo ""; echo "\n"; } echo "\n"; } echo "\n"; echo ""; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo ""; echo "\n"; echo ""; echo "
 Local nameVisible labelPort typeL2 addressRem. objectRem. port(Un)link or (un)reserve 
"; printImageHREF ('delete', 'Unlink and Delete this port'); echo "${port['type']}${port['remote_object_name']}${port['remote_name']}"; printImageHREF ('unlink', 'Unlink this port'); echo "Reserved;"; printImageHREF ('useup', 'Use up this port'); echo "  "; echo ""; printImageHREF ('link', 'Link this port'); echo " "; echo ""; printImageHREF ('save', 'Save changes', TRUE); echo "
"; printImageHREF ('add', '', TRUE, 104); echo " 

\n"; finishPortlet(); startPortlet ('Add/update multiple ports'); echo "
"; echo "\n"; echo "\n"; echo "\n"; echo ""; echo 'Format: "; echo 'Default port type: '; echo ""; echo "
\n"; echo "
\n"; echo '
'; finishPortlet(); } function renderNetworkForObject ($object_id=0) { global $root, $pageno, $tabno; if ($object_id <= 0) { showError ('Invalid object_id', __FUNCTION__); return; } showMessageOrError(); startPortlet ('Network Addresses'); $addresses = getObjectAddresses ($object_id); usort($addresses, 'sortAddresses'); echo "\n"; echo "\n"; foreach ($addresses as $addr) { if (strlen($addr['address_name'])>40) $address_name = substr($addr['address_name'],0,38).'...'; else $address_name = $addr['address_name']; $virtnum = countRefsOfType($addr['references'], 'virtual', 'eq'); $sharednum = countRefsOfType($addr['references'], 'shared', 'eq'); $regnum = countRefsOfType($addr['references'], 'regular', 'eq'); $notvirtnum = countRefsOfType($addr['references'], 'virtual', 'neq'); if ($addr['address_reserved']=='yes') $class='trerror'; elseif ($addr['type']!='virtual' && $regnum>0) $class='trerror'; elseif ($addr['type']=='regular' && $sharednum>0) $class='trerror'; else $class=''; echo ""; echo "\n"; echo "\n"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "\n"; echo "\n"; } echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo ""; echo "
 Interface nameIP AddressDescriptionTypeMisc 
"; printImageHREF ('delete', 'Delete this IPv4 address'); echo "${addr['ip']}$address_name"; if ($addr['address_reserved']=='yes') echo "Reserved; "; if ($addr['type'] == 'virtual') { if ($notvirtnum > 0) { echo " Owners: "; printRefsOfType($addr['references'], 'virtual', 'neq'); } } elseif ($addr['type'] == 'shared') { if ($sharednum > 0) { echo " Peers: "; printRefsOfType($addr['references'], 'shared', 'eq'); echo ";"; } if ($virtnum > 0) { echo " Virtuals: "; printRefsOfType($addr['references'], 'virtual', 'eq'); echo ";"; } if ($regnum > 0) { echo " Collisions: "; printRefsOfType($addr['references'], 'regular', 'eq'); } } else { if ($virtnum > 0) { echo " Virtuals: "; printRefsOfType($addr['references'], 'virtual', 'eq'); echo ";"; } if ($notvirtnum > 0) { echo " Collisions: "; printRefsOfType($addr['references'], 'virtual', 'neq'); } } echo ""; printImageHREF ('save', 'Save changes', TRUE); echo "
"; printImageHREF ('add', 'Allocate new address', TRUE, 99); echo ""; echo "\n"; echo " "; echo " 

\n"; finishPortlet(); } function printLog ($log) { foreach ($log as $record) echo "
${record['message']}
"; } /* The following conditions must be followed: 1. We can mount onto free atoms only. This means: if any record for an atom already exists in RackSpace, it can't be used for mounting. 2. We can't unmount from 'W' atoms. Operator should review appropriate comments and either delete them before unmounting or refuse to unmount the object. */ // We extensively use $_REQUEST in the function. function renderRackSpaceForObject ($object_id = 0) { if ($object_id <= 0) { showError ('Invalid object_id', __FUNCTION__); return; } $is_submit = isset ($_REQUEST['got_atoms']); $is_update = isset ($_REQUEST['rackmulti'][0]); $info = getObjectInfo ($object_id); if ($info == NULL) { showError ('getObjectInfo() failed', __FUNCTION__); return; } // Always process occupied racks plus racks chosen by user. First get racks with // already allocated rackspace... $workingRacksData = getResidentRacksData ($object_id); if ($workingRacksData === NULL) { print_r ($workingRacksData); showError ('getResidentRacksData() failed', __FUNCTION__); return; } // ...and then add those chosen by user (if any). if ($is_update) foreach ($_REQUEST['rackmulti'] as $cand_id) { if (!isset ($workingRacksData[$cand_id])) { $rackData = getRackData ($cand_id); if ($rackData == NULL) { showError ('getRackData() failed', __FUNCTION__); return NULL; } $workingRacksData[$cand_id] = $rackData; } } // Do it only once... foreach ($workingRacksData as &$rackData) applyObjectMountMask ($rackData, $object_id); // Now we workaround an old caveat: http://bugs.php.net/bug.php?id=37410 unset ($rackData); // Here we process form submit by trying to save all submitted info to database. if ($is_submit) { $oldMolecule = getMoleculeForObject ($object_id); $worldchanged = FALSE; $log = array(); foreach ($workingRacksData as $rack_id => $rackData) { $logrecord = processGridForm ($rackData, 'F', 'T', $object_id); $log[] = $logrecord; if ($logrecord['code'] != 300) { $worldchanged = TRUE; // Reload our working copy after form processing. $rackData = getRackData ($rack_id); if ($rackData == NULL) $log[] = array ('code' => 500, 'message' => 'Working copy update failed in ', __FUNCTION__); applyObjectMountMask ($rackData, $object_id); $workingRacksData[$rack_id] = $rackData; } } if ($worldchanged) { // Log a record. $newMolecule = getMoleculeForObject ($object_id); $oc = count ($oldMolecule); $nc = count ($newMolecule); $omid = $oc ? createMolecule ($oldMolecule) : 'NULL'; $nmid = $nc ? createMolecule ($newMolecule) : 'NULL'; global $remote_username; $comment = empty ($_REQUEST['comment']) ? 'NULL' : "'${_REQUEST['comment']}'"; $query = "insert into MountOperation(object_id, old_molecule_id, new_molecule_id, user_name, comment) " . "values (${object_id}, ${omid}, ${nmid}, '${remote_username}', ${comment})"; global $dbxlink; $result = $dbxlink->query ($query); if ($result == NULL) $log[] = array ('code' => 'error', 'message' => 'SQL query failed during history logging.'); else $log[] = array ('code' => 'success', 'message' => 'History logged.'); } printLog ($log); } // This is the time for rendering. global $root, $pageno, $tabno; echo "
"; echo "\n"; echo "\n"; echo "\n"; // Main layout starts. echo ""; // Left portlet with rack list. echo ""; // Middle portlet with comment and submit. echo ""; // Right portlet with rendered racks. If this form submit is not final, we have to // reflect the former state of the grid in current form. echo "\n"; echo "\n"; echo "
"; startPortlet ('Racks'); $allRacksData = getRacksForRow(); if (count ($allRacksData) <= getConfigVar ('RACK_PRESELECT_THRESHOLD')) { foreach (array_keys ($allRacksData) as $rack_id) { $rackData = getRackData ($rack_id); if ($rackData == NULL) { showError ('getRackData() failed', __FUNCTION__); return NULL; } $workingRacksData[$rack_id] = $rackData; } foreach ($workingRacksData as &$rackData) applyObjectMountMask ($rackData, $object_id); unset ($rackData); } renderRackMultiSelect ('rackmulti[]', $allRacksData, array_keys ($workingRacksData)); echo "
"; echo "
"; finishPortlet(); echo "
"; startPortlet ('Comment'); echo "
\n"; echo "\n"; echo "
"; echo "
"; finishPortlet(); echo "
"; startPortlet ('Working copy'); echo ''; foreach ($workingRacksData as $rack_id => $rackData) { // Order is important here: only original allocation is highlighted. highlightObject ($rackData, $object_id); markupAtomGrid ($rackData, 'T'); // If we have a form processed, discard user input and show new database // contents. if (!$is_submit and $is_update) mergeGridFormToRack ($rackData); echo "'; } echo "
"; echo "
\n

${rackData['name']}

\n"; echo "\n"; echo ""; echo "\n"; renderAtomGrid ($rackData); echo ""; echo "\n"; echo "
 FrontInteriorBack
 FrontInteriorBack
\n"; echo '
"; finishPortlet(); echo "
\n"; } function renderMolecule ($mdata, $object_id) { // sort data out $rackpack = array(); global $loclist; foreach ($mdata as $rua) { $rack_id = $rua['rack_id']; $unit_no = $rua['unit_no']; $atom = $rua['atom']; if (!isset ($rackpack[$rack_id])) { $rackData = getRackData ($rack_id); for ($i = $rackData['height']; $i > 0; $i--) for ($locidx = 0; $locidx < 3; $locidx++) $rackData[$i][$locidx]['state'] = 'F'; $rackpack[$rack_id] = $rackData; } $rackpack[$rack_id][$unit_no][$loclist[$atom]]['state'] = 'T'; $rackpack[$rack_id][$unit_no][$loclist[$atom]]['object_id'] = $object_id; } // now we have some racks to render foreach ($rackpack as $rackData) { markAllSpans ($rackData); echo "\n"; echo "\n"; echo "\n"; for ($i = $rackData['height']; $i > 0; $i--) { echo ""; for ($locidx = 0; $locidx < 3; $locidx++) { $state = $rackData[$i][$locidx]['state']; echo "\n"; } echo "\n"; } echo "
${rackData['name']}
 FrontInteriorBack
$i 
\n"; } } function renderUnmountedObjectsPortlet () { startPortlet ('Unmounted objects'); $objs = getUnmountedObjects(); if ($objs === NULL) { showError ('getUnmountedObjects() failed', __FUNCTION__); return; } global $root, $nextorder; $order = 'odd'; echo '

'; echo ''; foreach ($objs as $obj) { echo ""; echo ""; echo ""; echo ""; $order = $nextorder[$order]; } echo "
Common nameVisible labelAsset numberBarcode
${obj['dname']}${obj['label']}${obj['asset_no']}${obj['barcode']}

\n"; finishPortlet(); } function renderProblematicObjectsPortlet () { startPortlet ('Problematic objects'); $objs = getProblematicObjects(); if ($objs === NULL) { showError ('getProblematicObjects() failed', __FUNCTION__); return; } global $root, $nextorder; $order = 'odd'; echo '

'; echo ''; foreach ($objs as $obj) { echo ""; echo ""; $order = $nextorder[$order]; } echo "
TypeCommon name
${obj['objtype_name']}${obj['dname']}

\n"; finishPortlet(); } function renderObjectSpace () { global $root, $taglist, $tagtree; echo "\n"; echo "
"; startPortlet ('View all by type'); $groupInfo = getObjectGroupInfo(); if ($groupInfo === NULL) { showError ('getObjectGroupInfo() failed', __FUNCTION__); return; } if (count ($groupInfo) == 0) echo "No objects exist in DB"; else { echo '
    '; foreach ($groupInfo as $gi) echo "
  • ${gi['name']} (${gi['count']})
  • "; echo '
'; } finishPortlet(); echo '
'; startPortlet ('View all by tag'); if (count ($taglist) == 0) echo "No tags exist in DB"; else renderTagCloud ('object'); finishPortlet(); echo "
\n"; } function renderObjectGroup () { global $root, $pageno, $tabno, $nextorder, $taglist, $tagtree; assertUIntArg ('group_id', __FUNCTION__, TRUE); $group_id = $_REQUEST['group_id']; $tagfilter = getTagFilter(); $tagfilter_str = getTagFilterStr ($tagfilter); echo "\n"; echo "
"; startPortlet ('change type'); $groupInfo = getObjectGroupInfo(); if ($groupInfo === NULL) { showError ('getObjectGroupInfo() failed', __FUNCTION__); return; } if (count ($groupInfo) == 0) echo "No objects exist in DB"; else { echo '
'; } finishPortlet(); echo '
'; startPortlet ('Objects'); $objects = getObjectList ($group_id, $tagfilter); if ($objects === NULL) { showError ('getObjectList() failed', __FUNCTION__); return; } echo '

'; echo ''; $order = 'odd'; foreach ($objects as $obj) { echo ""; echo ""; echo ""; echo ""; if ($obj['rack_id']) echo ""; else echo ''; echo ''; $order = $nextorder[$order]; } echo '
Common nameVisible labelAsset tagBarcodeRack
${obj['dname']}${obj['label']}${obj['asset_no']}${obj['barcode']}${obj['Rack_name']}Unmounted
'; finishPortlet(); echo "
"; renderTagFilterPortlet ($tagfilter, 'object', 'group_id', $group_id); echo "
\n"; } function renderEmptyPortsSelect ($port_id, $type_id) { $ports = getEmptyPortsOfType($type_id); usort($ports, 'sortEmptyPorts'); foreach ($ports as $port) { if ($port_id == $port['Port_id']) continue; echo "\n"; } } function renderObjectAddressesAndNames () { $addresses = getObjectAddressesAndNames(); usort($addresses, 'sortObjectAddressesAndNames'); foreach ($addresses as $address) { echo "\n"; } } // History viewer for history-enabled simple dictionaries. function renderHistory ($object_type, $object_id) { switch ($object_type) { case 'row': $query = "select ctime, user_name, name, deleted, comment from RackRowHistory where id = ${object_id} order by ctime"; $header = 'change timeauthorrack row nameis deleted?rack row comment'; $extra = 4; break; case 'rack': $query = "select ctime, user_name, rh.name, rh.deleted, d.dict_value as name, rh.height, rh.comment " . "from RackHistory as rh left join Dictionary as d on rh.row_id = d.dict_key " . "natural join Chapter " . "where chapter_name = 'RackRow' and rh.id = ${object_id} order by ctime"; $header = 'change timeauthorrack nameis deleted?rack row namerack heightrack comment'; $extra = 6; break; case 'object': $query = "select ctime, user_name, name, label, barcode, asset_no, deleted, has_problems, dict_value, comment " . "from RackObjectHistory inner join Dictionary on objtype_id = dict_key natural join Chapter " . "where chapter_name = 'RackObjectType' and id=${object_id} order by ctime"; $header = 'change timeauthorcommon namevisible labelbarcodeasset nois deleted?has problems?object typecomment'; $extra = 9; break; default: showError ("Uknown object type '${object_type}'", __FUNCTION__); return; } global $dbxlink; $result = $dbxlink->query ($query); if ($result == NULL) { showError ('SQL query failed', __FUNCTION__); return; } echo ''; $order = 'odd'; global $nextorder; echo $header; while ($row = $result->fetch (PDO::FETCH_NUM)) { echo ""; for ($i = 1; $i <= $extra; $i++) echo ""; echo "\n"; $order = $nextorder[$order]; } echo "
${row[0]}" . $row[$i] . "

\n"; } function renderRackspaceHistory () { global $root, $nextorder, $pageno, $tabno; $order = 'odd'; $history = getRackspaceHistory(); // Show the last operation by default. if (isset ($_REQUEST['op_id'])) $op_id = $_REQUEST['op_id']; elseif (isset ($history[0]['mo_id'])) $op_id = $history[0]['mo_id']; else $op_id = NULL; $omid = NULL; $nmid = NULL; $object_id = 1; if ($op_id) list ($omid, $nmid) = getOperationMolecules ($op_id); // Main layout starts. echo ""; // Left top portlet with old allocation. echo "
"; startPortlet ('Old allocation'); if ($omid) { $oldMolecule = getMolecule ($omid); renderMolecule ($oldMolecule, $object_id); } else echo "nothing"; finishPortlet(); echo ''; // Right top portlet with new allocation startPortlet ('New allocation'); if ($nmid) { $newMolecule = getMolecule ($nmid); renderMolecule ($newMolecule, $object_id); } else echo "nothing"; finishPortlet(); echo '
'; // Bottom portlet with list startPortlet ('Rackspace allocation history'); echo "\n"; echo "\n"; foreach ($history as $row) { if ($row['mo_id'] == $op_id) $class = 'hl'; else $class = "row_${order}"; echo ""; echo ""; echo "\n"; echo "\n"; $order = $nextorder[$order]; } echo "
timestampauthorrack object IDrack object typerack object namecomment
${row['ctime']}${row['user_name']}${row['ro_id']}${row['objtype_name']}${row['name']}${row['comment']}
\n"; finishPortlet(); echo '
'; } function renderAddressspace () { global $root, $page; echo "\n"; echo "
"; startPortlet ('Subnets'); echo "\n"; $tagfilter = getTagFilter(); $addrspaceList = getAddressspaceList ($tagfilter); echo ""; foreach ($addrspaceList as $iprange) { $range = getIPRange ($iprange['id']); $total = ($iprange['ip_bin'] | $iprange['mask_bin_inv']) - ($iprange['ip_bin'] & $iprange['mask_bin']) + 1; $used = count ($range['addrlist']); echo ""; echo ""; } echo "
SubnetNameUtilization
${iprange['ip']}/${iprange['mask']}${iprange['name']}"; renderProgressBar ($used/$total); echo " ${used}/${total}
\n"; finishPortlet(); echo '
'; renderTagFilterPortlet ($tagfilter, 'ipv4net'); echo "
\n"; } function renderIPv4SLB () { global $root, $page, $nextorder; startPortlet ('SLB configuration'); echo ""; foreach (array ('vservices', 'rspools', 'rservers', 'lbs') as $pno) echo ""; echo '

" . $page[$pno]['title'] . "

'; finishPortlet(); $summary = getSLBSummary(); startPortlet ('SLB tactical overview'); // A single id-keyed array isn't used here to preserve existing // order of LBs returned by getSLBSummary() $lblist = array(); $lbdname = array(); foreach ($summary as $vipdata) foreach (array_keys ($vipdata['lblist']) as $lb_object_id) if (!in_array ($lb_object_id, $lblist)) { $oi = getObjectInfo ($lb_object_id); $lbdname[$lb_object_id] = $oi['dname']; $lblist[] = $lb_object_id; } if (!count ($summary)) echo 'none configured'; else { $order = 'odd'; echo "\n"; echo ""; foreach ($lblist as $lb_object_id) echo ""; echo "\n"; foreach ($summary as $vsid => $vsdata) { echo ""; foreach ($lblist as $lb_object_id) { echo ''; } echo "\n"; $order = $nextorder[$order]; } echo "
VS ↓ LB →" . $lbdname[$lb_object_id] . "
"; echo buildVServiceName ($vsdata); echo ''; if (!empty ($vsdata['name'])) echo " (${vsdata['name']})"; echo "'; if (!isset ($vsdata['lblist'][$lb_object_id])) echo ' '; else { echo $vsdata['lblist'][$lb_object_id]['size']; echo " ("; echo $vsdata['lblist'][$lb_object_id]['name'] . ')'; } echo '
\n"; } finishPortlet (); } function renderAddNewRange () { global $root, $pageno, $tabno; showMessageOrError(); startPortlet ("Add New"); echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "
Address rangeNameconnected networkassign tags 
\n"; renderTagSelect(); echo "


\n"; finishPortlet(); startPortlet ("Manage Existing"); echo "\n"; $addrspaceList = getAddressspaceList(); echo ""; foreach ($addrspaceList as $iprange) { $range = getIPRange($iprange['id']); $usedips = count ($range['addrlist']); $totalips = ($iprange['ip_bin'] | $iprange['mask_bin_inv']) - ($iprange['ip_bin'] & $iprange['mask_bin']) + 1; echo "\n"; } echo "
 Address rangeNameUtilization
"; if ($usedips == 0) { echo ""; printImageHREF ('delete', 'Delete this IP range'); echo ""; } else printImageHREF ('nodelete', 'There are IP addresses allocated or reserved'); echo ""; echo "${iprange['ip']}/${iprange['mask']}${iprange['name']}"; echo ""; renderProgressBar ($usedips / $totalips); echo " ${usedips}/${totalips}"; echo "
"; finishPortlet(); } function renderIPRange ($id) { global $root, $pageno, $tabno; $netmaskbylen = array ( 32 => '255.255.255.255', 31 => '255.255.255.254', 30 => '255.255.255.252', 29 => '255.255.255.248', 28 => '255.255.255.240', 27 => '255.255.255.224', 26 => '255.255.255.192', 25 => '255.255.255.128', 24 => '255.255.255.0', 23 => '255.255.254.0', 22 => '255.255.252.0', 21 => '255.255.248.0', 20 => '255.255.240.0', 19 => '255.255.224.0', 18 => '255.255.192.0', 17 => '255.255.128.0', 16 => '255.255.0.0', 15 => '255.254.0.0', 14 => '255.252.0.0', 13 => '255.248.0.0', 12 => '255.240.0.0', 11 => '255.224.0.0', 10 => '255.192.0.0', 9 => '255.128.0.0', 8 => '255.0.0.0', 7 => '254.0.0.0', 6 => '252.0.0.0', 5 => '248.0.0.0', 4 => '240.0.0.0', 3 => '224.0.0.0', 2 => '192.0.0.0', 1 => '128.0.0.0' ); $wildcardbylen = array ( 32 => '0.0.0.0', 31 => '0.0.0.1', 30 => '0.0.0.3', 29 => '0.0.0.7', 28 => '0.0.0.15', 27 => '0.0.0.31', 26 => '0.0.0.63', 25 => '0.0.0.127', 24 => '0.0.0.255', 23 => '0.0.1.255', 22 => '0.0.3.255', 21 => '0.0.7.255', 20 => '0.0.15.255', 19 => '0.0.31.255', 18 => '0.0.63.255', 17 => '0.0.127.255', 16 => '0.0.255.25', 15 => '0.1.255.255', 14 => '0.3.255.255', 13 => '0.7.255.255', 12 => '0.15.255.255', 11 => '0.31.255.255', 10 => '0.63.255.255', 9 => '0.127.255.255', 8 => '0.255.255.255', 7 => '1.255.255.255', 6 => '3.255.255.255', 5 => '7.255.255.255', 4 => '15.255.255.255', 3 => '31.255.255.255', 2 => '63.255.255.255', 1 => '127.255.255.255' ); $maxperpage = getConfigVar ('IPV4_ADDRS_PER_PAGE'); if (isset($_REQUEST['pg'])) $page = $_REQUEST['pg']; else $page=0; $range = getIPRange($id); echo ""; echo "\n"; echo "\n"; echo "

${range['ip']}/${range['mask']}

${range['name']}

"; startPortlet ('summary'); $total = ($range['ip_bin'] | $range['mask_bin_inv']) - ($range['ip_bin'] & $range['mask_bin']) + 1; $used = count ($range['addrlist']); echo "\n"; echo "\n"; echo "\n"; echo "\n"; printTagTRs ("${root}?page=ipv4space&"); echo "
Utilization:"; renderProgressBar ($used/$total); echo " ${used}/${total}
Netmask:"; echo $netmaskbylen[$range['mask']]; echo "
Wildcard bits:"; echo $wildcardbylen[$range['mask']]; echo "

\n"; finishPortlet(); echo "
"; startPortlet ('details'); $startip = $range['ip_bin'] & $range['mask_bin']; $endip = $range['ip_bin'] | $range['mask_bin_inv']; $realstartip = $startip; $realendip = $endip; $numpages = 0; if($endip - $startip > $maxperpage) { $numpages = ($endip - $startip)/$maxperpage; $startip = $startip + $page * $maxperpage; $endip = $startip + $maxperpage-1; } echo "
"; if ($numpages) echo '

' . long2ip ($startip) . ' ~ ' . long2ip ($endip) . '

'; for ($i=0; $i<$numpages; $i++) { if ($i == $page) echo "$i "; else echo "$i "; } echo "
"; echo "\n"; echo "\n"; for($ip = $startip; $ip<=$endip; $ip++) { if (isset ($range['addrlist'][$ip])) { $numshared = countRefsOfType($range['addrlist'][$ip]['references'], 'shared', 'eq'); $numreg = countRefsOfType($range['addrlist'][$ip]['references'], 'regular', 'eq'); $numvirt = countRefsOfType($range['addrlist'][$ip]['references'], 'virtual', 'eq'); $numlb = count ($range['addrlist'][$ip]['lbrefs']); $numrs = count ($range['addrlist'][$ip]['rsrefs']); $addr = $range['addrlist'][$ip]; if ( ($numshared > 0 && $numreg > 0) || $numreg > 1 ) echo ""; elseif ( $addr['reserved'] == 'yes' and $numshared+$numreg+$numvirt+$numlb+$numrs > 0) echo ""; elseif ( $addr['reserved'] == 'yes') echo ""; elseif ( $numshared > 0 || $numreg > 0 || $numlb > 0 || $numrs > 0) echo ""; else echo ""; echo ""; echo "\n"; } else { echo "\n"; } } echo "
AddressNameAllocation
${addr['ip']}${addr['name']}"; $delim = ''; $prologue = ''; if ( $addr['reserved'] == 'yes') { echo "Reserved "; $delim = '; '; } foreach ($range['addrlist'][$ip]['references'] as $ref) { echo "${delim}"; echo $ref['name'] . (empty ($ref['name']) ? '' : '@'); echo "${ref['object_name']}"; $delim = '; '; } if ($delim != '') { $delim = ''; $prologue = '
'; } foreach ($range['addrlist'][$ip]['lbrefs'] as $ref) { echo $prologue; $prologue = ''; echo "${delim}"; echo "${ref['object_name']}:"; echo "${ref['vport']}/${ref['proto']}→"; $delim = '; '; } if ($delim != '') { $delim = ''; $prologue = '
'; } foreach ($range['addrlist'][$ip]['rsrefs'] as $ref) { echo $prologue; $prologue = ''; echo "${delim}→${ref['rsport']}@"; echo "${ref['rspool_name']}"; $delim = '; '; } echo "
".long2ip($ip)."  
"; finishPortlet(); echo "
\n"; } function renderIPRangeProperties ($id) { global $pageno, $tabno; showMessageOrError(); $range = getIPRange($id); echo "

${range['ip']}/${range['mask']}

\n"; echo "\n"; echo ""; echo "\n"; echo "\n"; echo ""; echo ""; echo "
Name:
\n"; } function renderIPAddress () { global $root; $ip = $_REQUEST['ip']; $address = getIPAddress($ip); echo "

$ip

"; if ($address['exists'] == 1) echo "

${address['name']}

"; echo "
\n"; // echo ""; // echo "
"; $numshared = countRefsOfType($address['bonds'], 'shared', 'eq'); $numreg = countRefsOfType($address['bonds'], 'regular', 'eq'); $numvirt = countRefsOfType($address['bonds'], 'virtual', 'eq'); if ($address['reserved'] == 'yes' or ($numshared + $numreg + $numvirt) > 0) { startPortlet ('Allocation'); echo "\n"; echo "\n"; if ( ($numshared > 0 && $numreg > 0) || $numreg > 1 ) $class='trerror'; elseif ( $address['reserved'] == 'yes' and $numshared+$numreg+$numvirt > 0) $class='trerror'; else $class=''; if ($address['reserved'] == 'yes') echo ""; foreach ($address['bonds'] as $bond) { echo "\n"; } echo "
Object nameInterface nameInterface type
RESERVED
${bond['object_name']}${bond['name']}"; switch ($bond['type']) { case 'virtual': echo "Virtual"; break; case 'shared': echo "Shared"; break; case 'regular': echo "Regular"; break; } echo "


"; finishPortlet(); } if (count ($address['vslist'])) { startPortlet ('Virtual services (' . count ($address['vslist']) . ')'); echo "\n"; echo "\n"; foreach ($address['vslist'] as $vsinfo) { echo "\n"; } echo "
VSname
"; echo buildVServiceName ($vsinfo) . ""; echo $vsinfo['name'] . "


"; finishPortlet(); } if (count ($address['rslist'])) { startPortlet ('Real servers (' . count ($address['rslist']) . ')'); echo "\n"; echo "\n"; foreach ($address['rslist'] as $rsinfo) { echo "\n"; } echo "
 portRS pool
"; if ($rsinfo['inservice'] == 'yes') printImageHREF ('inservice', 'in service'); else printImageHREF ('notinservice', 'NOT in service'); echo "${rsinfo['rsport']}"; echo $rsinfo['poolname'] . "


"; finishPortlet(); } // echo "
"; // echo "
"; } function renderIPAddressProperties () { global $pageno, $tabno; $ip = $_REQUEST['ip']; showMessageOrError(); $address = getIPAddress($ip); echo "

$ip

\n"; echo "\n"; echo ""; echo "\n"; echo "\n"; echo ""; echo ""; echo ""; echo ""; echo "
Name:
Reserved:
\n"; } function renderIPAddressAssignment () { global $pageno, $tabno, $root; $ip = $_REQUEST['ip']; $address = getIPAddress($ip); showMessageOrError(); echo "

$ip

\n"; echo "\n"; echo "\n"; $numshared = countRefsOfType($address['bonds'], 'shared', 'eq'); $numreg = countRefsOfType($address['bonds'], 'regular', 'eq'); $numvirt = countRefsOfType($address['bonds'], 'virtual', 'eq'); if ( ($numshared > 0 && $numreg > 0) || $numreg > 1 ) $class='trerror'; elseif ( $address['reserved'] == 'yes' and $numshared+$numreg+$numvirt > 0) $class='trerror'; else $class=''; if ($address['reserved'] == 'yes') echo ""; foreach ($address['bonds'] as $bond) { echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "\n"; } echo ""; echo "\n"; echo "\n"; echo ""; echo ""; echo ""; echo ""; echo "
 Object nameInterface nameInterface type 
RESERVED
"; printImageHREF ('delete', 'Unallocate address'); echo "${bond['object_name']}


"; } function renderNATv4ForObject ($object_id = 0) { global $pageno, $tabno, $root; $info = getObjectInfo ($object_id); $forwards = getNATv4ForObject ($object_id); $addresses = getObjectAddresses ($object_id); showMessageOrError(); echo "

locally performed NAT

"; echo "\n"; echo "\n"; foreach ($forwards['out'] as $pf) { $class='trerror'; $name=''; foreach ($addresses as $addr) if ($addr['ip'] == $pf['localip']) { $class=''; $name = $addr['name']; break; } echo ""; echo ""; echo ""; echo ""; $address=getIPAddress($pf['remoteip']); echo ""; echo ""; echo ""; echo ""; echo ""; } echo ""; echo ""; echo "\n"; echo "\n"; echo ""; echo ""; echo ""; echo ""; echo "
Match endpointTranslate toTarget objectComment 
"; printImageHREF ('delete', 'Delete NAT rule'); echo "${pf['proto']}/${name}: ${pf['localip']}:${pf['localport']}"; if (!empty ($pf['local_addr_name'])) echo ' (' . $pf['local_addr_name'] . ')'; echo "${pf['remoteip']}:${pf['remoteport']}"; if (count ($address['bonds'])) foreach($address['bonds'] as $bond) echo "${bond['object_name']}(${bond['name']}) "; elseif (!empty ($pf['remote_addr_name'])) echo '(' . $pf['remote_addr_name'] . ')'; echo "
"; echo ""; printImageHREF ('save', 'Save changes', TRUE); echo "
"; printImageHREF ('add', 'Add new NAT rule', TRUE); echo ''; printSelect (array ('TCP' => 'TCP', 'UDP' => 'UDP'), 'proto'); echo ":"; echo ""; printImageHREF ('find', 'Find object'); echo ""; echo ": 


"; echo "

arriving NAT connections

"; echo "\n"; echo "\n"; foreach ($forwards['in'] as $pf) { echo ""; echo ""; echo ""; echo ""; } echo "
SourceSource objectsTargetDescription
"; printImageHREF ('delete', 'Delete NAT rule'); echo "${pf['proto']}/${pf['localip']}:${pf['localport']}${pf['object_name']}"; echo "${pf['remoteip']}:${pf['remoteport']}${pf['description']}


"; } function renderAddMultipleObjectsForm () { global $root, $pageno, $tabno, $nextorder; $type_id = array(); $global_type_id = 0; $name = array(); $asset_no = array(); $keepvalues = FALSE; $log = array(); // Look for current submit. if (isset ($_REQUEST['got_fast_data'])) { $keepvalues = TRUE; $max = getConfigVar ('MASSCOUNT'); for ($i = 0; $i < $max; $i++) { if (!isset ($_REQUEST["${i}_object_type_id"])) { $log[] = array ('code' => 'error', 'message' => "Submitted form is invalid at line " . $i + 1); break; } assertUIntArg ("${i}_object_type_id", __FUNCTION__, TRUE); assertStringArg ("${i}_object_name", __FUNCTION__, TRUE); assertStringArg ("${i}_object_label", __FUNCTION__, TRUE); assertStringArg ("${i}_object_asset_no", __FUNCTION__, TRUE); assertStringArg ("${i}_object_barcode", __FUNCTION__, TRUE); $type_id[$i] = $_REQUEST["${i}_object_type_id"]; // Save user input for possible rendering. $name[$i] = $_REQUEST["${i}_object_name"]; $label[$i] = $_REQUEST["${i}_object_label"]; $asset_no[$i] = $_REQUEST["${i}_object_asset_no"]; $barcode[$i] = $_REQUEST["${i}_object_barcode"]; // It's better to skip silently than printing a notice. if ($type_id[$i] == 0) continue; if (commitAddObject ($name[$i], $label[$i], $barcode[$i], $type_id[$i], $asset_no[$i]) === TRUE) $log[] = array ('code' => 'success', 'message' => "Added new object '${name[$i]}'"); else $log[] = array ('code' => 'error', 'message' => __FUNCTION__ . ': commitAddObject() failed'); } } elseif (isset ($_REQUEST['got_very_fast_data'])) { $keepvalues = TRUE; assertUIntArg ('global_type_id', __FUNCTION__, TRUE); assertStringArg ('namelist', __FUNCTION__, TRUE); $global_type_id = $_REQUEST['global_type_id']; if ($global_type_id == 0) { if (!empty ($_REQUEST['namelist'])) $log[] = array ('code' => 'error', 'message' => 'Object type is not selected, check the form below'); else $log[] = array ('code' => 'error', 'message' => 'Empty form has been ignored. Cheers.'); } else { // The name extractor below was stolen from ophandlers.php:addMultiPorts() $names1 = explode ('\n', $_REQUEST['namelist']); $names2 = array(); foreach ($names1 as $line) { $parts = explode ('\r', $line); reset ($parts); if (empty ($parts[0])) continue; else $names2[] = rtrim ($parts[0]); } foreach ($names2 as $cname) if (commitAddObject ($cname, '', '', $global_type_id, '') === TRUE) $log[] = array ('code' => 'success', 'message' => "Added new object '${cname}'"); else $log[] = array ('code' => 'error', 'message' => "Could not add '${cname}'"); } } printLog ($log); // Render a form for the next. $typelist = getObjectTypeList(); $typelist[0] = 'select type...'; startPortlet ('Fast way'); echo "
"; echo ''; echo "\n"; // If a user forgot to select object type on input, we keep his // previous input in the form. $max = getConfigVar ('MASSCOUNT'); for ($i = 0; $i < $max; $i++) { echo ''; echo ""; echo ""; echo ""; echo ""; echo "\n"; } echo "\n"; echo "
Object typeCommon nameVisible labelAsset tagBarcode
'; // Don't employ DEFAULT_OBJECT_TYPE to avoid creating ghost records for pre-selected empty rows. printSelect ($typelist, "${i}_object_type_id", 0); echo '
\n"; finishPortlet(); startPortlet ('Very fast way'); echo "
"; echo 'For each line shown below create an object of type '; printSelect ($typelist, "global_type_id", getConfigVar ('DEFAULT_OBJECT_TYPE')); echo "
\n"; echo "
\n"; finishPortlet(); } function printGreeting () { global $remote_username, $accounts, $root; $account = $accounts[$remote_username]; echo "Hello, ${account['user_realname']}. This is RackTables " . CODE_VERSION . ". Click here to logout."; } function renderSearchResults () { global $remote_username, $root; $terms = trim ($_REQUEST['q']); if (empty ($terms)) { showError ('Search string cannot be empty.', __FUNCTION__); return; } if (!authorized ($remote_username, 'object', 'default')) { showError ('You are not authorized for viewing information about objects.', __FUNCTION__); return; } $nhits = 0; // If we search for L2 address, we can either find one or find none. if ( preg_match ('/^[0-9a-f][0-9a-f]?:[0-9a-f][0-9a-f]?:[0-9a-f][0-9a-f]?:[0-9a-f][0-9a-f]?:[0-9a-f][0-9a-f]?:[0-9a-f][0-9a-f]?$/i', $terms) or preg_match ('/^[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]$/i', $terms) or preg_match ('/^[0-9a-f][0-9a-f][0-9a-f][0-9a-f].[0-9a-f][0-9a-f][0-9a-f][0-9a-f].[0-9a-f][0-9a-f][0-9a-f][0-9a-f]$/i', $terms) or // STP bridge ID: bridge priotity + port MAC address. Cut off first 4 chars and look for MAC address. preg_match ('/^[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]$/i', $terms) ) // Search for L2 address. { $terms = substr ($terms, -12); $result = searchByl2address ($terms); if ($result !== NULL) { $nhits++; $lasthit = 'port'; $summary['port'][] = $result; } } elseif (preg_match ('/^[0-9][0-9]?[0-9]?\.[0-9]?[0-9]?[0-9]?\.[0-9][0-9]?[0-9]?\.[0-9]?[0-9]?[0-9]?$/i', $terms)) // Search for IP address. { $result = getRangeByIp ($terms); if ($result !== NULL) { $nhits++; $lasthit = 'ipv4address1'; $summary['ipv4address1'][] = $terms; } } else // Search for objects, addresses, networks, virtual services and RS pools by their description. { $tmp = getObjectSearchResults ($terms); if (count ($tmp)) { $nhits += count ($tmp); $lasthit = 'object'; $summary['object'] = $tmp; } $tmp = getIPv4AddressSearchResult ($terms); if (count ($tmp)) { $nhits += count ($tmp); $lasthit = 'ipv4address2'; $summary['ipv4address2'] = $tmp; } $tmp = getIPv4PrefixSearchResult ($terms); if (count ($tmp)) { $nhits += count ($tmp); $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 "

Nothing found for '${terms}'

"; elseif ($nhits == 1) { $record = current ($summary[$lasthit]); switch ($lasthit) { case 'port': echo ""; break; case 'ipv4address1': echo ""; break; case 'ipv4address2': echo ""; break; case 'ipv4network': echo ""; break; case 'object': echo ""; break; case 'ipv4rspool': echo ""; break; case 'ipv4vs': echo ""; break; } return; } else { global $nextorder; $order = 'odd'; echo "

${nhits} result(s) found for '${terms}'

"; foreach ($summary as $where => $what) switch ($where) { case 'object': startPortlet ("Objects"); echo ''; echo ''; foreach ($what as $obj) { echo ""; echo ""; echo ""; echo ""; $order = $nextorder[$order]; } echo '
Common nameVisible labelAsset tagbarcode
${obj['dname']}${obj['label']}${obj['asset_no']}${obj['barcode']}
'; finishPortlet(); break; case 'ipv4network': startPortlet ("IPv4 networks"); echo ''; echo ''; foreach ($what as $net) { echo "'; echo ""; $order = $nextorder[$order]; } echo '
NetworkDescritpion
${net['ip']}"; echo '/' . $net['mask'] . '${net['name']}
'; finishPortlet(); break; case 'ipv4address2': startPortlet ('IPv4 addresses'); echo ''; echo ''; foreach ($what as $addr) { echo ""; echo ""; $order = $nextorder[$order]; } echo '
AddressDescritpion
"; echo "${addr['ip']}${addr['name']}
'; finishPortlet(); break; case 'ipv4rspool': startPortlet ("RS pools"); echo ''; foreach ($what as $rspool) { echo ""; $order = $nextorder[$order]; } echo '
"; echo buildRSPoolName ($rspool); echo "
'; finishPortlet(); break; case 'ipv4vs': startPortlet ("Virtual services"); echo ''; echo ''; foreach ($what as $vs) { echo ""; $order = $nextorder[$order]; } echo '
VSDescritpion
"; echo buildVServiceName ($vs); echo "${vs['name']}
'; finishPortlet(); break; } } } // This function prints a table of checkboxes to aid the user in toggling mount atoms // from one state to another. The first argument is rack data as // produced by getRackData(), the second is the value used for the 'unckecked' state // and the third is the value used for 'checked' state. // Usage contexts: // for mounting an object: printAtomGrid ($data, 'F', 'T') // for changing rack design: printAtomGrid ($data, 'A', 'F') // for adding rack problem: printAtomGrid ($data, 'F', 'U') // for adding object problem: printAtomGrid ($data, 'T', 'W') function renderAtomGrid ($data) { $rack_id = $data['id']; for ($unit_no = $data['height']; $unit_no > 0; $unit_no--) { echo "${unit_no}"; for ($locidx = 0; $locidx < 3; $locidx++) { $state = $data[$unit_no][$locidx]['state']; echo ""; if (!($data[$unit_no][$locidx]['enabled'] === TRUE)) echo ''; else echo ""; echo ''; } echo "\n"; } } function renderPermissions () { startPortlet ('User permissions'); echo "\n"; echo ""; global $perms, $nextorder; $order = 'odd'; foreach ($perms as $username => $pages) foreach ($pages as $page => $tabs) foreach ($tabs as $tab => $access) { echo "\n"; $order = $nextorder[$order]; } echo "
UsernamePageTabAccess
$username$page$tab$access
\n"; finishPortlet(); } function renderAccounts () { global $nextorder, $accounts; startPortlet ('User accounts'); echo "\n"; echo ""; $order = 'odd'; foreach ($accounts as $user) { echo ""; echo ""; $order = $nextorder[$order]; } echo '
UsernameReal name
"; echo "${user['user_name']}
${user['user_realname']}
'; finishPortlet(); } function renderAccountsEditForm () { global $root, $pageno, $tabno, $accounts; startPortlet ('User accounts'); showMessageOrError(); echo "\n"; echo "\n"; foreach ($accounts as $account) { echo ""; echo ""; echo "\n"; echo "\n"; echo ""; echo ""; echo ""; echo ""; echo "\n"; } echo ""; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo ""; echo ""; echo "
opUsernameReal namePassword 
"; if ($account['user_enabled'] == 'yes' && $account['user_id'] != 1) { echo ""; printImageHREF ('blockuser', 'disable account'); echo "\n"; } if ($account['user_enabled'] == 'no' && $account['user_id'] != 1) { echo ""; printImageHREF ('unblockuser', 'enable account'); echo "\n"; } // Otherwise skip icon. echo ""; printImageHREF ('save', 'Save changes', TRUE); echo "
 "; printImageHREF ('create', 'Add new account', TRUE, 103); echo "

\n"; finishPortlet(); } function printChildrenAsOptions ($root, $depth = 0) { echo "\n"; foreach ($root['kids'] as $kid) printChildrenAsOptions ($kid, $depth + 1); } // 1. Find all parentless pages. // 2. For each of them recursively find all children. // 3. Output the tree with recursion tree display. function printPagesTree () { global $page; echo '
';
	foreach ($page as $ctitle => $cpage)
		if (!isset ($cpage['parent']))
		{
			$croot['title'] = $ctitle;
			$croot['kids'] = getAllChildPages ($ctitle);
			printChildrenAsOptions ($croot);
		}
	echo '
'; } function renderPermissionsEditForm () { global $root, $pageno, $tabno, $perms, $accounts; startPortlet ('User permissions'); showMessageOrError(); echo "\n"; echo "\n"; foreach ($perms as $username => $pages) foreach ($pages as $access_page => $tabs) foreach ($tabs as $access_tab => $access) { echo ""; echo ""; echo ""; echo ""; echo ""; echo "\n"; } echo ""; echo "\n"; echo "\n"; echo "\n"; // FIXME: border=0 doesn't work here for unknown reason echo ""; echo "\n"; echo ""; echo ""; echo ""; echo ""; echo "
 UsernamePageTabAccess
"; if ($username != '%') $userid = $accounts[$username]['user_id']; else $userid = 0; echo ""; printImageHREF ('revoke', 'Revoke permission'); echo "${username}${access_page}${access_tab}${access}
"; printImageHREF ('grant', '', TRUE, 103); echo "no yes

\n"; finishPortlet(); } function renderPortMapViewer () { renderPortMap (FALSE); } function renderPortMapEditor () { renderPortMap (TRUE); } function renderPortMap ($editable = FALSE) { global $nextorder, $root, $pageno, $tabno; showMessageOrError(); startPortlet ("Port compatibility map"); $ptlist = getPortTypes(); $pclist = getPortCompat(); $pctable = buildPortCompatMatrixFromList ($ptlist, $pclist); if ($editable) { echo "
"; echo ""; echo ""; echo ""; } echo "\n"; echo ""; foreach ($ptlist as $name2) echo ""; echo ""; // Make a copy to have an independent array pointer. $ptlistY = $ptlist; $order = 'odd'; foreach ($ptlistY as $type1 => $name1) { echo ""; foreach ($ptlist as $type2 => $name2) { echo ''; } echo "\n"; $order = $nextorder[$order]; } echo '
 to ${name2}
from $name1

'; if ($editable) { echo ""; echo "
"; } finishPortlet(); } function renderConfigMainpage () { global $pageno, $root; $children = getDirectChildPages ($pageno); echo ''; } function renderRackPage ($rack_id) { if ($rack_id == 0) { showError ('Invalid rack_id', __FUNCTION__); return; } if (($rackData = getRackData ($rack_id)) == NULL) { showError ('getRackData() failed', __FUNCTION__); return; } echo ""; // Left column with information. echo "'; // Right column with rendered rack. echo ''; echo '
"; renderRackInfoPortlet ($rackData); echo ''; startPortlet ('Rack diagram'); renderRack ($rack_id); finishPortlet(); echo '
'; } function renderDictionary () { global $nextorder; $dict = getDict (TRUE); echo "
\n"; foreach ($dict as $chapter_no => $chapter) { $order = 'odd'; echo "\n"; $wc = count ($chapter['word']); echo ""; if (!$wc) echo ""; else { $chap_start = TRUE; foreach ($chapter['word'] as $key => $value) { if (!$chap_start) echo ""; else $chap_start = FALSE; echo ''; echo "\n"; $order = $nextorder[$order]; } } } echo "
ChapterrefsWord
${chapter['name']} (${wc} records)
none
' . ($chapter['refcnt'][$key] ? $chapter['refcnt'][$key] : ' ') . '
${value}
\n
"; } function renderDictionaryEditor () { global $root, $pageno, $tabno, $nextorder; $dict = getDict(); showMessageOrError(); echo "
\n"; foreach ($dict as $chapter_no => $chapter) { $order = 'odd'; echo "\n"; $wc = count ($chapter['word']); // One extra span for the new record per each chapter block. echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ''; $order = $nextorder[$order]; foreach ($chapter['word'] as $key => $value) { echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "'; echo ""; echo ""; echo "\n"; $order = $nextorder[$order]; } // foreach ($chapter['word'] } // foreach ($dict echo "
Chapter Word 
${chapter['name']} (${wc} records)
 
"; // Prevent deleting words currently used somewhere. if ($chapter['refcnt'][$key]) printImageHREF ('nodelete', 'referenced ' . $chapter['refcnt'][$key] . ' time(s)'); else { echo ""; printImageHREF ('delete', 'Delete word'); echo ""; } echo '
\n"; } // We don't allow to rename/delete a sticky chapter and we don't allow // to delete a non-empty chapter. function renderChaptersEditor () { global $root, $pageno, $tabno; showMessageOrError(); $dict = getDict(); echo "\n"; echo ''; foreach ($dict as $chapter) { $wordcount = count ($chapter['word']); $sticky = $chapter['sticky']; echo ""; echo ""; echo ""; echo ""; echo ""; echo ''; echo ''; echo ""; echo "'; echo ''; } echo ""; echo ""; echo ""; echo ""; echo '"; echo ''; echo ''; echo "
 Chapter nameWords 
'; if ($sticky) printImageHREF ('nodelete', 'system chapter'); elseif ($wordcount > 0) printImageHREF ('nodelete', 'contains ' . $wordcount . ' word(s)'); else { echo ""; printImageHREF ('delete', 'Remove chapter'); echo ""; } echo '${wordcount}"; if ($sticky) echo ' '; else echo ""; echo '
'; printImageHREF ('add', '', TRUE); echo "
\n"; } function renderAttributes () { global $nextorder; $attrMap = getAttrMap(); startPortlet ('Optional attributes'); echo "\n"; echo ""; $order = 'odd'; foreach ($attrMap as $attr) { echo ""; echo ""; echo ""; echo ''; echo "\n"; $order = $nextorder[$order]; } echo "
Attribute nameAttribute typeApplies to
${attr['name']}${attr['type']}'; if (count ($attr['application']) == 0) echo ' '; else foreach ($attr['application'] as $app) if ($attr['type'] == 'dict') echo "${app['objtype_name']} (values from '${app['chapter_name']}')
"; else echo "${app['objtype_name']}
"; echo '

\n"; finishPortlet(); } function renderEditAttributesForm () { global $root, $pageno, $tabno; $attrMap = getAttrMap(); showMessageOrError(); startPortlet ('Optional attributes'); echo "\n"; echo ''; foreach ($attrMap as $attr) { echo ""; echo ""; echo ""; echo ""; echo ""; echo ''; echo "'; echo ""; echo ""; echo ""; echo ''; echo ''; } echo ""; echo ""; echo ""; echo ""; echo '"; echo ''; echo ''; echo ''; echo "
 NameType 
"; printImageHREF ('delete', 'Remove attribute'); echo '${attr['type']}
'; printImageHREF ('add', '', TRUE); echo "
\n"; finishPortlet(); } function renderEditAttrMapForm () { global $root, $pageno, $tabno; $attrMap = getAttrMap(); showMessageOrError(); startPortlet ('Attribute map'); echo "\n"; echo ''; foreach ($attrMap as $attr) { if (count ($attr['application']) == 0) continue; foreach ($attr['application'] as $app) { echo ''; echo ''; echo ""; echo ""; echo "\n"; } } echo ""; echo ""; echo ""; echo ""; echo '"; echo ''; $dict = getDict(); echo ''; echo ''; echo ''; echo "
 Attribute nameObject typeDictionary chapter
'; echo ""; printImageHREF ('delete', 'Remove mapping'); echo ""; echo '${attr['name']}${app['objtype_name']}"; if ($attr['type'] == 'dict') echo "${app['chapter_name']}"; else echo ' '; echo "
'; printImageHREF ('add', '', TRUE); echo "'; printSelect (getObjectTypeList(), 'objtype_id'); echo '
\n"; finishPortlet(); } function printImageHREF ($tag, $title = '', $do_input = FALSE, $tabindex = 0) { global $root; $image['error']['path'] = 'pix/error.png'; $image['error']['width'] = 76; $image['error']['height'] = 17; $image['logo']['path'] = 'pix/defaultlogo.png'; $image['logo']['width'] = 210; $image['logo']['height'] = 40; $image['rackspace']['path'] = 'pix/racks.png'; $image['rackspace']['width'] = 218; $image['rackspace']['height'] = 200; $image['objects']['path'] = 'pix/server.png'; $image['objects']['width'] = 218; $image['objects']['height'] = 200; $image['ipv4space']['path'] = 'pix/addressspace.png'; $image['ipv4space']['width'] = 218; $image['ipv4space']['height'] = 200; $image['ipv4slb']['path'] = 'pix/slb.png'; $image['ipv4slb']['width'] = 218; $image['ipv4slb']['height'] = 200; $image['config']['path'] = 'pix/configuration.png'; $image['config']['width'] = 218; $image['config']['height'] = 200; $image['reports']['path'] = 'pix/report.png'; $image['reports']['width'] = 218; $image['reports']['height'] = 200; $image['reserve']['path'] = 'pix/stop.png'; $image['reserve']['width'] = 16; $image['reserve']['height'] = 16; $image['useup']['path'] = 'pix/go.png'; $image['useup']['width'] = 16; $image['useup']['height'] = 16; $image['blockuser'] = $image['reserve']; $image['unblockuser'] = $image['useup']; $image['link']['path'] = 'pix/tango-network-wired.png'; $image['link']['width'] = 16; $image['link']['height'] = 16; $image['unlink']['path'] = 'pix/tango-edit-clear.png'; $image['unlink']['width'] = 16; $image['unlink']['height'] = 16; $image['add']['path'] = 'pix/tango-list-add.png'; $image['add']['width'] = 16; $image['add']['height'] = 16; $image['delete']['path'] = 'pix/tango-list-remove.png'; $image['delete']['width'] = 16; $image['delete']['height'] = 16; $image['nodelete']['path'] = 'pix/tango-list-remove-shadow.png'; $image['nodelete']['width'] = 16; $image['nodelete']['height'] = 16; $image['grant'] = $image['add']; $image['revoke'] = $image['delete']; $image['inservice']['path'] = 'pix/tango-emblem-system.png'; $image['inservice']['width'] = 16; $image['inservice']['height'] = 16; $image['notinservice']['path'] = 'pix/tango-dialog-error.png'; $image['notinservice']['width'] = 16; $image['notinservice']['height'] = 16; $image['find']['path'] = 'pix/tango-system-search.png'; $image['find']['width'] = 16; $image['find']['height'] = 16; $image['spacer']['path'] = 'pix/pixel.png'; $image['spacer']['width'] = 16; $image['spacer']['height'] = 16; $image['next']['path'] = 'pix/tango-go-next.png'; $image['next']['width'] = 32; $image['next']['height'] = 32; $image['prev']['path'] = 'pix/tango-go-previous.png'; $image['prev']['width'] = 32; $image['prev']['height'] = 32; $image['clear']['path'] = 'pix/tango-edit-clear.png'; $image['clear']['width'] = 16; $image['clear']['height'] = 16; $image['save']['path'] = 'pix/tango-document-save.png'; $image['save']['width'] = 16; $image['save']['height'] = 16; $image['SAVE']['path'] = 'pix/tango-document-save-big.png'; $image['SAVE']['width'] = 32; $image['SAVE']['height'] = 32; $image['create']['path'] = 'pix/tango-document-new.png'; $image['create']['width'] = 16; $image['create']['height'] = 16; if (!isset ($image[$tag])) $tag = 'error'; $img = $image[$tag]; if ($do_input == TRUE) echo ""; else echo ""; } // This function returns URL for favourite icon. function getFaviconURL () { global $root; return $root . 'pix/racktables.ico'; } function renderReportSummary () { echo "\n"; echo "\n"; echo "
\n"; startPortlet ("Dictionary/objects stats"); echo "\n"; foreach (getDictStats() as $header => $data) echo "\n"; echo "
${header}:${data}
\n"; finishPortlet(); startPortlet ('IPv4 stats'); echo "\n"; foreach (getIPv4Stats() as $header => $data) echo "\n"; echo "
${header}:${data}
\n"; finishPortlet(); startPortlet ('Rackspace stats'); echo "\n"; foreach (getRackspaceStats() as $header => $data) echo "\n"; echo "
${header}:${data}
\n"; finishPortlet(); echo "
\n"; startPortlet ("Tag popularity"); echo "\n"; foreach (getTagStats() as $header => $data) echo "\n"; echo "
${header}:${data}
\n"; finishPortlet(); echo "
\n"; } function dragon () { startPortlet ('Here be dragons'); ?>

                 \||/
                 |  @___oo  
       /\  /\   / (__,,,,|
      ) /^\) ^\/ _)
      )   /^\/   _) 
      )   _ /  / _)
  /\  )/\/ ||  | )_)    
 <  >      |(,,) )__)
  ||      /    \)___)\
  | \____(      )___) )___
   \______(_______;;; __;;;

'; echo 'OptionValue'; $order = 'odd'; foreach ($configCache as $v) { if ($v['is_hidden'] != 'no') continue; echo ""; echo "${v['description']}\n"; echo "${v['varvalue']}"; $order = $nextorder[$order]; } echo "\n"; finishPortlet(); } function renderUIConfigEditForm () { global $root, $pageno, $tabno, $configCache; showMessageOrError(); startPortlet ('Current configuration'); echo "\n"; echo ""; echo ""; echo ""; echo ""; echo "\n"; echo "\n"; $i = 0; foreach ($configCache as $v) { if ($v['is_hidden'] != 'no') continue; echo ""; echo ""; echo ""; echo "\n"; $i++; } echo "\n"; echo ""; echo ""; finishPortlet(); } // This function queries the gateway about current VLAN configuration and // renders a form suitable for submit. Ah, and it does submit processing as well. function renderVLANMembership ($object_id = 0) { global $root, $pageno, $tabno, $remote_username; if ($object_id <= 0) { showError ('Invalid object_id', __FUNCTION__); return; } // Handle probable pending submit. if (isset ($_REQUEST['portcount'])) { $data = getSwitchVLANs ($object_id); if ($data === NULL) { showError ('getSwitchVLANs() failed during submit processing', __FUNCTION__); return; } list ($vlanlist, $portlist) = $data; // Here we just build up 1 set command for the gateway with all of the ports // included. The gateway is expected to filter unnecessary changes silently // and to provide a list of responses with either error or success message // for each of the rest. assertUIntArg ('portcount', __FUNCTION__); $nports = $_REQUEST['portcount']; $prefix = 'set '; $log = array(); $setcmd = ''; for ($i = 0; $i < $nports; $i++) if ( !isset ($_REQUEST['portname_' . $i]) || !isset ($_REQUEST['vlanid_' . $i]) || $_REQUEST['portname_' . $i] != $portlist[$i]['portname'] ) $log[] = array ('code' => 'error', 'message' => "Ignoring malformed record #${i} in form submit"); elseif ( $_REQUEST['vlanid_' . $i] == $portlist[$i]['vlanid'] || $portlist[$i]['vlaind'] == 'TRUNK' ) continue; else { $setcmd .= $prefix . $_REQUEST['portname_' . $i] . '=' . $_REQUEST['vlanid_' . $i]; $prefix = ';'; } printLog ($log); // Feed the gateway and interpret its (non)response. if ($setcmd != '') printLog (setSwitchVLANs ($object_id, $setcmd)); } // Reload and render. $data = getSwitchVLANs ($object_id); if ($data === NULL) return; list ($vlanlist, $portlist, $maclist) = $data; echo '
OptionValue
${v['description']}
'; startPortlet ('Current status'); echo ""; echo ""; echo ""; echo ""; echo ""; $portcount = count ($portlist); echo "\n"; $portno = 0; $ports_per_row = getConfigVar ('PORTS_PER_ROW'); foreach ($portlist as $port) { // Don't let wide forms break our fancy pages. if ($portno % $ports_per_row == 0) { if ($portno > 0) echo "\n"; echo ""; } echo '"; } echo "
" . ($portno + 1) . "-" . ($portno + $ports_per_row > $portcount ? $portcount : $portno + $ports_per_row) . " $addrs) $maccount += count ($addrs); if ($maccount == 1) echo 'connected_single'; else echo 'connected_multi'; } echo '>' . $port['portname'] . '
'; echo ""; echo ""; } elseif ($port['vlanid'] == 'routed') { echo ""; echo ""; } else { echo ""; } $portno++; echo "
"; finishPortlet(); echo '
'; startPortlet ('VLAN table'); echo ''; echo ""; $order = 'even'; global $nextorder; foreach ($vlanlist as $id => $descr) { echo ""; $order = $nextorder[$order]; } echo '
IDDescription
${id}${descr}
'; finishPortlet(); echo '
'; startPortlet ('Color legend'); echo ''; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo '
port statecolor code
not connectedSAMPLE
disabledSAMPLE
unknownSAMPLE
connected with none MAC addresses activeSAMPLE
connected with 1 MAC addresses activeSAMPLE
connected with 1+ MAC addresses activeSAMPLE
'; finishPortlet(); echo '
'; if (count ($maclist)) { startPortlet ('MAC address table'); echo ''; echo "\n"; $order = 'even'; foreach ($maclist as $portname => $portdata) foreach ($portdata as $vlanid => $addrgroup) foreach ($addrgroup as $addr) { echo ""; echo "\n"; $order = $nextorder[$order]; } echo '
PortVLAN IDMAC address
$portname$vlanid$addr
'; finishPortlet(); } // End of main table. echo '
'; } // This snippet either renders a form inviting the user to start SNMP query // on the current device or displays the result of the scan. function renderSNMPPortFinder ($object_id = 0) { global $root, $pageno, $tabno, $remote_username; if ($object_id <= 0) { showError ('Invalid object_id', __FUNCTION__); return; } // FIXME: check if SNMP PHP extension is available! if (isset ($_REQUEST['do_scan'])) { $log = array(); // IDs: http://cisco.com/en/US/products/sw/cscowork/ps2064/products_device_support_table09186a0080803bb4.html // 2960: http://www.cisco.com/en/US/products/ps6406/prod_models_comparison.html // 2970: http://cisco.com/en/US/products/hw/switches/ps5206/products_qanda_item09186a00801b1750.shtml // 3500XL: http://cisco.com/en/US/products/hw/switches/ps637/products_eol_models.html // 3560: http://cisco.com/en/US/products/hw/switches/ps5528/products_data_sheet09186a00801f3d7f.html // 3750: http://cisco.com/en/US/products/hw/switches/ps5023/products_data_sheet09186a008016136f.html $ciscomodel[283] = 'WS-C6509-E (9-slot system)'; // FIXME: hwtype hardcoded value will become invalid after the Dictionary table transformation // in 0.14.7 version. Either the values will have to be adjusted as well or we have to switch // to value lookup (not reliable). $hwtype[283] = 148; # $ciscomodel[694] = 'WS-C2960-24TC-L (24 Ethernet 10/100 ports and 2 dual-purpose uplinks)'; # $ciscomodel[695] = 'WS-C2960-48TC-L (48 Ethernet 10/100 ports and 2 dual-purpose uplinks)'; $ciscomodel[696] = 'WS-C2960G-24TC-L (20 Ethernet 10/100/1000 ports and 4 dual-purpose uplinks)'; $hwtype[696] = 167; $ciscomodel[697] = 'WS-C2960G-48TC-L (44 Ethernet 10/100/1000 ports and 4 dual-purpose uplinks)'; $hwtype[697] = 166; # $ciscomodel[716] = 'WS-C2960-24TT-L (24 Ethernet 10/100 ports and 2 10/100/1000 uplinks)'; # $ciscomodel[717] = 'WS-C2960-48TT-L (48 Ethernet 10/100 ports and 2 10/100/1000 uplinks)'; $ciscomodel[527] = 'WS-C2970G-24T (24 Ethernet 10/100/1000 ports)'; $hwtype[527] = 210; $ciscomodel[561] = 'WS-C2970G-24TS (24 Ethernet 10/100/1000 ports and 4 10/100/1000 SFP uplinks)'; $hwtype[561] = 115; $ciscomodel[633] = 'WS-C3560-24TS (24 Ethernet 10/100 ports and 2 10/100/1000 SFP uplinks)'; $hwtype[633] = 169; $ciscomodel[634] = 'WS-C3560-48TS (48 Ethernet 10/100 ports and 4 10/100/1000 SFP uplinks)'; $hwtype[634] = 170; $ciscomodel[563] = 'WS-C3560-24PS (24 Ethernet 10/100 POE ports and 2 10/100/1000 SFP uplinks)'; $hwtype[563] = 171; $ciscomodel[564] = 'WS-C3560-48PS (48 Ethernet 10/100 POE ports and 4 10/100/1000 SFP uplinks)'; $hwtype[564] = 172; $ciscomodel[614] = 'WS-C3560G-24PS (24 Ethernet 10/100/1000 POE ports and 4 10/100/1000 SFP uplinks)'; $hwtype[614] = 175; $ciscomodel[615] = 'WS-C3560G-24TS (24 Ethernet 10/100/1000 ports and 4 10/100/1000 SFP uplinks)'; $hwtype[615] = 173; $ciscomodel[616] = 'WS-C3560G-48PS (48 Ethernet 10/100/1000 POE ports and 4 10/100/1000 SFP uplinks)'; $hwtype[616] = 176; $ciscomodel[617] = 'WS-C3560G-48TS (48 Ethernet 10/100/1000 ports and 4 10/100/1000 SFP uplinks)'; $hwtype[617] = 174; $ciscomodel[58] = 'WS-C4503 (3-slot system)'; $hwtype[58] = 145; $ciscomodel[503] = '4503 (3-slot system)'; $hwtype[503] = 145; $ciscomodel[59] = 'WS-C4506 (6-slot system)'; $hwtype[59] = 156; $ciscomodel[502] = '4506 (6-slot system)'; $hwtype[502] = 156; $ciscomodel[626] = 'WS-C4948 (48 Ethernet 10/100/1000 ports and 4 10/100/1000 SFP uplinks)'; $hwtype[626] = 147; $ciscomodel[659] = 'WS-C4948-10GE (48 Ethernet 10/100/1000 ports and 2 10Gb X2 uplinks)'; $hwtype[659] = 377; assertStringArg ('community', __FUNCTION__); $community = $_REQUEST['community']; $objectInfo = getObjectInfo ($object_id); $endpoints = findAllEndpoints ($object_id, $objectInfo['name']); $sysName = substr (snmpget ($endpoints[0], $community, 'sysName.0'), strlen ('STRING: ')); $sysDescr = snmpget ($endpoints[0], $community, 'sysDescr.0'); // Strip the object type, it's always string here. $sysDescr = substr ($sysDescr, strlen ('STRING: ')); if (strpos ($sysDescr, 'Cisco IOS Software') === 0 or strpos ($sysDescr, 'Cisco Internetwork Operating System Software') === 0) $log[] = array ('code' => 'success', 'message' => 'Seems to be a Cisco box'); else { $log[] = array ('code' => 'error', 'message' => 'No idea how to handle ' . $sysDescr); printLog ($log); return; } // It's a Cisco. Go on. $attrs = getAttrValues ($object_id); // Only fill in attribute values, if they are not set. // FIXME: this is hardcoded if (empty ($attrs[3]['value']) && !empty ($sysName)) // FQDN { $error = commitUpdateAttrValue ($object_id, 3, $sysName); if ($error == TRUE) $log[] = array ('code' => 'success', 'message' => 'FQDN set to ' . $sysName); else $log[] = array ('code' => 'error', 'message' => 'Failed settig FQDN: ' . $error); } if (empty ($attrs[5]['value'])) // SW version { $IOSversion = ereg_replace ('^.*, Version ([^ ]+), .*$', '\\1', $sysDescr); $error = commitUpdateAttrValue ($object_id, 5, $IOSversion); if ($error == TRUE) $log[] = array ('code' => 'success', 'message' => 'SW version set to ' . $IOSversion); else $log[] = array ('code' => 'error', 'message' => 'Failed settig SW version: ' . $error); } if (empty ($attrs[4]['value'])) // switch OS type switch (substr ($IOSversion, 0, 4)) { case '12.2': $error = commitUpdateAttrValue ($object_id, 4, 252); break; case '12.1': $error = commitUpdateAttrValue ($object_id, 4, 251); break; case '12.0': $error = commitUpdateAttrValue ($object_id, 4, 244); break; } if ($error == TRUE) $log[] = array ('code' => 'success', 'message' => 'Switch OS type set to Cisco IOS ' . substr ($IOSversion, 0, 4)); else $log[] = array ('code' => 'error', 'message' => 'Failed settig Switch OS type'); $sysObjectID = snmpget ($endpoints[0], $community, 'sysObjectID.0'); // Transform OID $sysObjectID = substr ($sysObjectID, strlen ('OID: SNMPv2-SMI::enterprises.9.1.')); if (!isset ($ciscomodel[$sysObjectID])) { $log[] = array ('code' => 'error', 'message' => 'Could not guess exact HW model!'); printLog ($log); return; } $log[] = array ('code' => 'success', 'message' => 'HW is ' . $ciscomodel[$sysObjectID]); if (empty ($attrs[2]['value']) and isset ($hwtype[$sysObjectID])) // switch HW type { $error = commitUpdateAttrValue ($object_id, 2, $hwtype[$sysObjectID]); if ($error == TRUE) $log[] = array ('code' => 'success', 'message' => 'HW type updated Ok'); else $log[] = array ('code' => 'error', 'message' => 'Failed settig HW type: ' . $error); } // Now fetch ifType, ifDescr and ifPhysAddr and let model-specific code sort the data out. $ifType = snmpwalkoid ($endpoints[0], $community, 'ifType'); $ifDescr = snmpwalkoid ($endpoints[0], $community, 'ifdescr'); $ifPhysAddress = snmpwalkoid ($endpoints[0], $community, 'ifPhysAddress'); // Combine 3 tables into 1... $ifList1 = array(); foreach ($ifType as $key => $val) { list ($dummy, $ifIndex) = explode ('.', $key); list ($dummy, $type) = explode (' ', $val); $ifList1[$ifIndex]['type'] = $type; } foreach ($ifDescr as $key => $val) { list ($dummy, $ifIndex) = explode ('.', $key); list ($dummy, $descr) = explode (' ', $val); $ifList1[$ifIndex]['descr'] = trim ($descr, '"'); } foreach ($ifPhysAddress as $key => $val) { list ($dummy, $ifIndex) = explode ('.', $key); list ($dummy, $addr) = explode (':', $val); $addr = str_replace (' ', '', $addr); $ifList1[$ifIndex]['phyad'] = $addr; } // ...and then reverse it inside out to make description the key. $ifList2 = array(); foreach ($ifList1 as $ifIndex => $data) { $ifList2[$data['descr']]['type'] = $data['type']; $ifList2[$data['descr']]['phyad'] = $data['phyad']; $ifList2[$data['descr']]['idx'] = $ifIndex; } $newports = 0; // Now we can directly pick necessary ports from the table accordingly // to our known hardware model. switch ($sysObjectID) { // FIXME: chassis edge switches often share a common naming scheme, so // the sequences below have to be generalized. Let's have some duplicated // code for the time being, as this is the first implementation ever. case '697': // WS-C2960G-48TC-L // 44 copper ports: 1X, 2X, 3X... // 4 combo ports: 45, 46, 47, 48. Don't list SFP connectors atm, as it's not // clear how to fit them into current Ports table structure. for ($i = 1; $i <= 48; $i++) { $label = ($i >= 45) ? "${i}" : "${i}X"; $error = commitAddPort ($object_id, 'gi0/' . $i, 24, $label, $ifList2["GigabitEthernet0/${i}"]['phyad']); if ($error == '') $newports++; else $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $label . ': ' . $error); } break; case '696': // WS-C2960G-24TC-L // Quite similar to the above. for ($i = 1; $i <= 24; $i++) { $label = ($i >= 21) ? "${i}" : "${i}X"; $error = commitAddPort ($object_id, 'gi0/' . $i, 24, $label, $ifList2["GigabitEthernet0/${i}"]['phyad']); if ($error == '') $newports++; else $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $label . ': ' . $error); } break; case '563': // WS-C3560-24PS case '633': // WS-C3560-24TS for ($i = 1; $i <= 24; $i++) { $label = "${i}X"; $error = commitAddPort ($object_id, 'fa0/' . $i, 19, $label, $ifList2["FastEthernet0/${i}"]['phyad']); if ($error == '') $newports++; else $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $label . ': ' . $error); } for ($i = 1; $i <= 2; $i++) { $label = "${i}"; $error = commitAddPort ($object_id, 'gi0/' . $i, 24, $label, $ifList2["GigabitEthernet0/${i}"]['phyad']); if ($error == '') $newports++; else $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $label . ': ' . $error); } break; case '564': // WS-C3560-48PS case '634': // WS-C3560-48TS for ($i = 1; $i <= 48; $i++) { $label = "${i}X"; $error = commitAddPort ($object_id, 'fa0/' . $i, 19, $label, $ifList2["FastEthernet0/${i}"]['phyad']); if ($error == '') $newports++; else $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $label . ': ' . $error); } for ($i = 1; $i <= 4; $i++) { $label = "${i}"; $error = commitAddPort ($object_id, 'gi0/' . $i, 24, $label, $ifList2["GigabitEthernet0/${i}"]['phyad']); if ($error == '') $newports++; else $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $label . ': ' . $error); } break; case '614': // WS-C3560G-24PS case '615': // WS-C3560G-24TS case '527': // WS-C2970G-24T case '561': // WS-C2970G-24TS for ($i = 1; $i <= 24; $i++) { $label = "${i}X"; $error = commitAddPort ($object_id, 'gi0/' . $i, 24, $label, $ifList2["GigabitEthernet0/${i}"]['phyad']); if ($error == '') $newports++; else $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $label . ': ' . $error); } break; case '616': // WS-C3560G-48PS case '617': // WS-C3560G-48TS for ($i = 1; $i <= 48; $i++) { $label = "${i}X"; $error = commitAddPort ($object_id, 'gi0/' . $i, 24, $label, $ifList2["GigabitEthernet0/${i}"]['phyad']); if ($error == '') $newports++; else $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $label . ': ' . $error); } break; case '626': // WS-C4948 case '659': // WS-C4948-10GE for ($i = 1; $i <= 48; $i++) { $label = "${i}X"; $error = commitAddPort ($object_id, 'gi1/' . $i, 24, $label, $ifList2["GigabitEthernet1/${i}"]['phyad']); if ($error == '') $newports++; else $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $label . ': ' . $error); } break; // For modular devices we don't iterate over all possible port names, // but use the first list to pick everything that looks legitimate // for this hardware. It would be correct to fetch the list of modules // installed to generate lists of ports, but who is going to implement // this? case '503': // 4503 case '58': // WS-C4503 case '502': // 4506 case '59': // WS-C4506 case '283': // WS-C6509-E foreach ($ifList1 as $port) { if ($port['type'] != 'ethernet-csmacd(6)') continue; // Copper Fa/Gi harvesting is relatively simple, while 10Gig ports can // have random samples of transciever units. if (strpos ($port['descr'], 'FastEthernet') === 0) // Fa { $prefix = 'fa'; $ptype = 19; // RJ-45/100Base-TX list ($slotno, $portno) = explode ('/', substr ($port['descr'], strlen ('FastEthernet'))); } elseif (strpos ($port['descr'], 'GigabitEthernet') === 0) // Gi { $prefix = 'gi'; $ptype = 24; // RJ-45/1000Base-T list ($slotno, $portno) = explode ('/', substr ($port['descr'], strlen ('GigabitEthernet'))); } else continue; $label = "slot ${slotno} port ${portno}"; $pname = "${prefix}${slotno}/${portno}"; $error = commitAddPort ($object_id, $pname, $ptype, $label, $port['phyad']); if ($error == '') $newports++; else $log[] = array ('code' => 'error', 'message' => 'Failed to add port ' . $pname . ': ' . $error); } break; default: showError ("Unexpected sysObjectID '${sysObjectID}'", __FUNCTION__); } $error = commitAddPort ($object_id, 'con0', 29, 'console', ''); if ($error == '') $newports++; else $log[] = array ('code' => 'error', 'message' => 'Failed to add console port : ' . $error); if ($newports > 0) $log[] = array ('code' => 'success', 'message' => "Added ${newports} new ports"); printLog ($log); return; } echo "
\n"; echo "\n"; echo "\n"; ?>

This switch has no ports listed, that's why you see this form. If you supply SNMP community, I can try atomatic data harvesting on the switch. As soon as at least one relevant port is found, this tab will not be seen any more. Good luck.

"; echo ""; echo ""; echo ""; echo "This button will reset user interface configuration to its defaults (except organization name and auth source): "; echo ""; echo "
"; } function renderFirstRowForm () { global $root, $pageno, $tabno; echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; ?>

Your rackspace seems to be empty, and this form will create your first rack row, just fill in the name. All the subsequent rack rows will have to be added from the Dictionary edit page in Configuration section.

$vsinfo) { $newconfig .= "########################################################\n" . "# VS (id == ${vs_id}): " . (empty ($vsinfo['vs_name']) ? 'NO NAME' : $vsinfo['vs_name']) . "\n" . "# RS pool (id == ${vsinfo['pool_id']}): " . (empty ($vsinfo['pool_name']) ? 'ANONYMOUS' : $vsinfo['pool_name']) . "\n" . "########################################################\n"; # The order of inheritance is: VS -> LB -> pool [ -> RS ] $macros = array ( '%VIP%' => $vsinfo['vip'], '%VPORT%' => $vsinfo['vport'], '%PROTO%' => $vsinfo['proto'], '%VNAME%' => $vsinfo['vs_name'], '%RSPOOLNAME%' => $vsinfo['pool_name'] ); $newconfig .= "virtual_server ${vsinfo['vip']} ${vsinfo['vport']} {\n"; $newconfig .= "\tprotocol ${vsinfo['proto']}\n"; $newconfig .= apply_macros ( $macros, lf_wrap ($vsinfo['vs_vsconfig']) . lf_wrap ($vsinfo['lb_vsconfig']) . lf_wrap ($vsinfo['pool_vsconfig']) ); foreach ($vsinfo['rslist'] as $rs) { $macros['%RSIP%'] = $rs['rsip']; $macros['%RSPORT%'] = $rs['rsport']; $newconfig .= "\treal_server ${rs['rsip']} ${rs['rsport']} {\n"; $newconfig .= apply_macros ( $macros, lf_wrap ($vsinfo['vs_rsconfig']) . lf_wrap ($vsinfo['lb_rsconfig']) . lf_wrap ($vsinfo['pool_rsconfig']) . lf_wrap ($rs['rs_rsconfig']) ); $newconfig .= "\t}\n"; } $newconfig .= "}\n\n\n"; } if (isset ($_REQUEST['do_activate'])) { printLog (activateSLBConfig ($object_id, html_entity_decode ($newconfig, ENT_QUOTES, 'UTF-8'))); } echo ""; echo ""; echo ""; echo ""; echo "
"; echo "
"; echo '
';
	echo $newconfig;
	echo '
'; } function renderVirtualService () { assertUIntArg ('id', __FUNCTION__); $vsid = $_REQUEST['id']; global $root, $nextorder; if ($vsid <= 0) { showError ('Invalid vsid', __FUNCTION__); return; } $vsinfo = getVServiceInfo ($vsid); echo ''; if (!empty ($vsinfo['name'])) echo "\n"; echo ''; echo ''; echo ''; echo '

${vsinfo['name']}

'; startPortlet ('Frontend'); echo "\n"; if (!empty ($vsinfo['name'])) echo "\n"; echo "\n"; echo "\n"; echo "\n"; printTagTRs ("${root}?page=vservices&"); if (!empty ($vsinfo['vsconfig'])) { echo "\n"; echo "\n"; } if (!empty ($vsinfo['rsconfig'])) { echo "\n"; echo "\n"; } echo "
Name:${vsinfo['name']}
Protocol:${vsinfo['proto']}
Virtual IP address:${vsinfo['vip']}
Virtual port:${vsinfo['vport']}
VS configuration: 
${vsinfo['vsconfig']}
RS configuration: 
${vsinfo['rsconfig']}
\n"; finishPortlet (); echo '
'; startPortlet ('Backend'); echo "\n"; echo "\n"; $order = 'odd'; foreach ($vsinfo['rspool'] as $pool_id => $poolInfo) { echo "\n"; $order = $nextorder[$order]; } echo "
real server poolload balancers
"; // Pool info echo ''; echo ""; if (!empty ($poolInfo['vsconfig'])) echo ""; if (!empty ($poolInfo['rsconfig'])) echo ""; echo '
"; if (!empty ($poolInfo['name'])) echo $poolInfo['name']; else echo 'ANONYMOUS'; echo "
VS config
${poolInfo['vsconfig']}
RS config
${poolInfo['rsconfig']}
'; echo '
'; // LB list if (!count ($poolInfo['lblist'])) echo 'none'; else { echo ''; foreach ($poolInfo['lblist'] as $object_id => $lbInfo) { // FIXME: dname should be cached $oi = getObjectInfo ($object_id); echo "'; if (!empty ($lbInfo['vsconfig'])) echo ""; if (!empty ($lbInfo['rsconfig'])) echo ""; } echo '
"; echo $oi['dname'] . '
VS config
${lbInfo['vsconfig']}
RS config
${lbInfo['rsconfig']}
'; } echo "
\n"; finishPortlet (); echo '
'; } function renderProgressBar ($percentage = 0) { global $root; $done = ((int) ($percentage * 100)); echo ""; } function renderRSPoolServerForm ($pool_id = 0) { global $root, $pageno, $tabno, $nextorder; if ($pool_id <= 0) { showError ('Invalid pool_id', __FUNCTION__); return; } showMessageOrError(); $poolInfo = getRSPoolInfo ($pool_id); if (($rsc = count ($poolInfo['rslist']))) { startPortlet ("Manage existing (${rsc})"); echo "
\n"; echo "\n"; $order = 'odd'; foreach ($poolInfo['rslist'] as $rsid => $rs) { echo ""; echo "\n"; echo "\n"; echo ""; echo ""; echo ""; echo ""; echo ""; echo "\n"; $order = $nextorder[$order]; } echo "
 AddressPortconfiguration 
"; printImageHREF ('delete', 'Delete this real server'); echo ""; printImageHREF ('save', 'Save changes', TRUE); echo "
\n"; finishPortlet(); } startPortlet ('Add one'); echo "\n"; echo "\n"; echo ""; echo "\n"; echo "\n"; echo ""; echo ""; echo ""; $default_port = getConfigVar ('DEFAULT_SLB_RS_PORT'); if ($default_port == 0) $default_port = ''; echo ""; echo ""; echo "
in serviceAddressPort 
"; if (getConfigVar ('DEFAULT_IPV4_RS_INSERVICE') == 'yes') printImageHREF ('inservice', 'in service'); else printImageHREF ('notinservice', 'NOT in service'); echo " "; echo ""; printImageHREF ('find', 'pick address'); echo ""; printImageHREF ('add', 'Add new', TRUE, 3); echo "
configuration
\n"; finishPortlet(); startPortlet ('Add many'); echo "
"; echo "\n"; echo "\n"; echo ""; echo ""; echo "\n\n"; echo "\n"; echo "
"; if (getConfigVar ('DEFAULT_IPV4_RS_INSERVICE') == 'yes') printImageHREF ('inservice', 'in service'); else printImageHREF ('notinservice', 'NOT in service'); echo "Format: "; $formats = array ( 'ipvs_2' => 'ipvsadm -l -n (address and port)', 'ipvs_3' => 'ipvsadm -l -n (address, port and weight)', 'ssv_2' => 'SSV: <IP address> <port>' ); printSelect ($formats, 'format'); echo "
\n"; finishPortlet(); } function renderRSPoolLBForm ($pool_id = 0) { global $root, $pageno, $tabno, $nextorder; showMessageOrError(); $poolInfo = getRSPoolInfo ($pool_id); $vs_list = array (); foreach (getVSList() as $vsid => $vsinfo) $vs_list[$vsid] = buildVServiceName ($vsinfo) . (empty ($vsinfo['name']) ? '' : " (${vsinfo['name']})"); if (count ($poolInfo['lblist'])) { startPortlet ('Manage existing (' . count ($poolInfo['lblist']) . ')'); echo "\n"; echo "\n"; $order = 'odd'; foreach ($poolInfo['lblist'] as $object_id => $vslist) foreach ($vslist as $vs_id => $configs) { $oi = getObjectInfo ($object_id); echo ""; echo "\n"; echo "\n"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "\n"; $order = $nextorder[$order]; } echo "
 LBVSVS configRS config 
"; printImageHREF ('delete', 'Unconfigure'); echo "${oi['dname']}"; $vsinfo = getVServiceInfo ($vs_id); echo buildVServiceName ($vsinfo) . ''; if (!empty ($vsinfo['name'])) echo " (${vsinfo['name']})"; echo ""; printImageHREF ('save', 'Save changes', TRUE); echo "
\n"; finishPortlet(); } startPortlet ('Add new'); echo "\n"; echo ""; echo "\n"; echo "\n"; echo ""; echo ""; echo "\n"; echo ""; echo ""; echo "
LB / VS "; printSelect ($vs_list, 'vs_id'); echo ""; printImageHREF ('add', 'Configure LB', TRUE, 2); echo "
VS config
RS config
\n"; finishPortlet(); } function renderRSPool ($pool_id = 0) { global $root; if ($pool_id <= 0) { showError ('Invalid pool_id', __FUNCTION__); return; } $poolInfo = getRSPoolInfo ($pool_id); if ($poolInfo == NULL) { showError ('getRSPoolInfo() returned NULL', __FUNCTION__); return; } echo ""; if (!empty ($poolInfo['name'])) echo ""; echo "

{$poolInfo['name']}

\n"; startPortlet ('Configuration'); echo "\n"; if (!empty ($poolInfo['name'])) echo "\n"; echo "\n"; echo "\n"; printTagTRs ("${root}?page=rspools&"); echo "
Pool name:${poolInfo['name']}
Real servers:" . count ($poolInfo['rslist']) . "
Load balancers:" . count ($poolInfo['lblist']) . "
"; finishPortlet(); startPortlet ('Load balancers (' . count ($poolInfo['lblist']) . ')'); echo "\n"; echo ""; foreach ($poolInfo['lblist'] as $object_id => $vslist) foreach ($vslist as $vs_id => $configs) { $oi = getObjectInfo ($object_id); $vi = getVServiceInfo ($vs_id); echo ""; echo ""; echo "\n"; } echo "
VSLBVS configRS config
"; echo buildVServiceName ($vi); echo "${oi['dname']}
${configs['vsconfig']}
${configs['rsconfig']}
\n"; finishPortlet(); echo "
\n"; startPortlet ('Real servers (' . count ($poolInfo['rslist']) . ')'); echo "\n"; echo ""; foreach ($poolInfo['rslist'] as $rs) { echo ""; echo "\n"; } echo "
in serviceaddressportRS configuration
"; if ($rs['inservice'] == 'yes') printImageHREF ('inservice', 'in service'); else printImageHREF ('notinservice', 'NOT in service'); echo "${rs['rsip']}${rs['rsport']}
${rs['rsconfig']}
\n"; finishPortlet(); echo "
\n"; } function renderVSList () { global $root, $nextorder; $tagfilter = getTagFilter(); $vslist = getVSList ($tagfilter); echo "\n"; echo "
"; startPortlet ('Virtual services'); echo "\n"; echo ""; $order = 'odd'; foreach ($vslist as $vsid => $vsinfo) { echo ""; echo ""; echo ""; echo ""; echo "\n"; $order = $nextorder[$order]; } echo "
endpointnameVS configurationRS configuration
" . buildVServiceName ($vsinfo); echo "${vsinfo['name']}
${vsinfo['vsconfig']}
${vsinfo['rsconfig']}
"; finishPortlet(); echo '
'; renderTagFilterPortlet ($tagfilter, 'ipv4vs'); echo '
'; } function renderVSListEditForm () { global $root, $pageno, $tabno, $nextorder; showMessageOrError(); startPortlet ('Manage existing'); echo "\n"; echo ""; echo ""; $protocols = array ('TCP' => 'TCP', 'UDP' => 'UDP'); $order = 'odd'; foreach (getVSList() as $vsid => $vsinfo) { echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo ""; echo "\n"; $order = $nextorder[$order]; } echo "
 VIPportprotonameVS configurationRS configuration
"; if ($vsinfo['poolcount']) printImageHREF ('nodelete', 'there are ' . $vsinfo['poolcount'] . ' RS pools configured'); else { echo ""; printImageHREF ('delete', 'delete virtual service'); echo ''; } echo ""; printSelect ($protocols, 'proto', $vsinfo['proto']); echo "
"; finishPortlet(); startPortlet ('Add new'); echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo ""; echo ""; echo ""; $default_port = getConfigVar ('DEFAULT_SLB_VS_PORT'); if ($default_port == 0) $default_port = ''; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
 VIPportprotoname 
 "; printSelect ($protocols, 'proto', 'TCP'); echo "
VS configuration
RS configuration
"; echo "
\n"; finishPortlet(); } function renderRSPoolList () { global $root, $nextorder; $tagfilter = getTagFilter(); $pool_list = getRSPoolList ($tagfilter); if ($pool_list === NULL) { showError ('getRSPoolList() failed', __FUNCTION__); return; } echo "\n"; echo "
"; startPortlet ('RS pools'); echo "\n"; echo ""; $order = 'odd'; foreach ($pool_list as $pool_id => $pool_info) { echo "'; echo "'; echo ""; echo ""; echo "\n"; $order = $nextorder[$order]; } echo "
refcntnameVS configurationRS configuration
" . ($pool_info['refcnt'] ? $pool_info['refcnt'] : ' ') . '"; echo (empty ($pool_info['name']) ? 'ANONYMOUS' : $pool_info['name']) . '
${pool_info['vsconfig']}
${pool_info['rsconfig']}
"; finishPortlet (); echo '
'; renderTagFilterPortlet ($tagfilter, 'ipv4rspool'); echo '
'; } function editRSPools () { global $root, $pageno, $tabno, $nextorder; showMessageOrError(); $pool_list = getRSPoolList(); startPortlet ('Manage existing'); echo "\n"; echo ""; $order='odd'; foreach ($pool_list as $pool_id => $pool_info) { echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo ""; echo ""; echo ""; echo ""; echo ""; echo "\n"; $order = $nextorder[$order]; } echo "
 nameVS configurationRS configuration 
"; if ($pool_info['refcnt']) printImageHREF ('nodelete', 'RS pool is used ' . $pool_info['refcnt'] . ' time(s)'); else { echo ""; printImageHREF ('delete', 'delete real server pool'); echo ''; } echo "
"; finishPortlet(); startPortlet ('Add new'); echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo ""; echo ""; echo ""; echo ""; echo ""; echo "
name
VS configuration
RS configuration
"; finishPortlet(); } function renderRealServerList () { global $root, $nextorder; $rslist = getRSList (); $pool_list = getRSPoolList (); echo "\n"; echo ""; $order = 'even'; $last_pool_id = 0; foreach ($rslist as $rsinfo) { if ($last_pool_id != $rsinfo['rspool_id']) { $order = $nextorder[$order]; $last_pool_id = $rsinfo['rspool_id']; } echo ""; echo ""; echo ""; echo "\n"; } echo "
RS poolin servicereal IP addressreal portRS configuration
"; echo empty ($pool_list[$rsinfo['rspool_id']]['name']) ? 'ANONYMOUS' : $pool_list[$rsinfo['rspool_id']]['name']; echo ''; if ($rsinfo['inservice'] == 'yes') printImageHREF ('inservice', 'in service'); else printImageHREF ('notinservice', 'NOT in service'); echo "${rsinfo['rsip']}${rsinfo['rsport']}
${rsinfo['rsconfig']}
"; } function renderLBList () { global $root, $nextorder; echo "\n"; echo ""; $oicache = array(); $order = 'odd'; foreach (getLBList() as $object_id => $poolcount) { if (!isset ($oicache[$object_id])) $oicache[$object_id] = getObjectInfo ($object_id); echo "'; echo ""; $order = $nextorder[$order]; } echo "
ObjectRS pools configured
"; echo $oicache[$object_id]['dname'] . '${poolcount}
"; } function renderRSPoolRSInServiceForm ($pool_id = 0) { global $root, $pageno, $tabno; if ($pool_id <= 0) { showError ('Invalid pool_id', __FUNCTION__); return; } showMessageOrError(); $poolInfo = getRSPoolInfo ($pool_id); $rscount = count ($poolInfo['rslist']); echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; $recno = 1; foreach ($poolInfo['rslist'] as $rs_id => $rsinfo) { echo "\n"; echo ""; echo ""; echo ""; $recno++; } echo "
RS addressRS portRS configurationin service
${rsinfo['rsip']}${rsinfo['rsport']}
${rsinfo['rsconfig']}
"; printImageHREF ('SAVE', 'Save changes', TRUE, $recno); echo "
\n
"; } function renderLivePTR ($id = 0) { if ($id == 0) { showError ("Invalid argument", __FUNCTION__); return; } showMessageOrError(); if (isset($_REQUEST['pg'])) $page = $_REQUEST['pg']; else $page=0; global $root, $pageno, $tabno; $maxperpage = getConfigVar ('IPV4_ADDRS_PER_PAGE'); $range = getIPRange ($id); echo "

${range['ip']}/${range['mask']}

${range['name']}

\n"; echo "\n"; $idx = 1; $cnt_match = $cnt_mismatch = $cnt_missing = 0; for ($ip = $startip; $ip <= $endip; $ip++) { // Find the (optional) DB name and the (optional) DNS record, then // compare values and produce a table row depending on the result. $addr = isset ($range['addrlist'][$ip]) ? $range['addrlist'][$ip] : array ('name' => '', 'reserved' => 'no'); $straddr = long2ip ($ip); $ptrname = gethostbyaddr ($straddr); if ($ptrname == $straddr) $ptrname = ''; echo "\n"; echo "\n"; echo "\n"; echo '"; echo "\n"; $idx++; } echo ""; echo "
"; startPortlet ('current records'); $startip = $range['ip_bin'] & $range['mask_bin']; $endip = $range['ip_bin'] | $range['mask_bin_inv']; $realstartip = $startip; $realendip = $endip; $numpages = 0; if ($endip - $startip > $maxperpage) { $numpages = ($endip - $startip) / $maxperpage; $startip = $startip + $page * $maxperpage; $endip = $startip + $maxperpage - 1; } echo "
"; if ($numpages) echo '

' . long2ip ($startip) . ' ~ ' . long2ip ($endip) . '

'; for ($i=0; $i<$numpages; $i++) if ($i == $page) echo "$i "; else echo "$i "; echo "
"; echo "
"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo '\n"; echo "
addresscurrent nameDNS dataimport
${straddr}${addr['name']}${ptrname}"; if ($print_cbox) echo ""; else echo ' '; echo "
"; echo ""; finishPortlet(); echo ""; startPortlet ('stats'); echo ""; echo "\n"; echo "\n"; echo "\n"; echo "
Exact matches:${cnt_match}
Missing from DB/DNS:${cnt_missing}
Mismatches:${cnt_mismatch}
\n"; finishPortlet(); echo "\n"; } function renderAutoPortsForm ($object_id = 0) { global $root, $pageno, $tabno; if ($object_id <= 0) { showError ('Invalid object_id', __FUNCTION__); return; } $info = getObjectInfo ($object_id); $ptlist = readChapter ('PortType'); echo "\n"; echo ""; echo ""; foreach (getAutoPorts ($info['objtype_id']) as $autoport) echo ""; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo ""; echo "
The following ports can be quickly added:
typename
" . $ptlist[$autoport['type']] . "${autoport['name']}
"; echo ""; echo "
"; } function renderTagRowForViewer ($taginfo, $level = 0) { echo ''; for ($i = 0; $i < $level; $i++) printImageHREF ('spacer'); echo $taginfo['tag']; echo "\n"; foreach ($taginfo['kids'] as $kid) renderTagRowForViewer ($kid, $level + 1); } function renderTagRowForCloud ($taginfo, $realm, $level = 0) { global $root; echo ''; for ($i = 0; $i < $level; $i++) printImageHREF ('spacer'); echo "
"; echo $taginfo['tag'] . ''; if (isset ($taginfo['refcnt'][$realm])) echo ' (' . $taginfo['refcnt'][$realm] . ')'; echo "\n"; foreach ($taginfo['kids'] as $kid) renderTagRowForCloud ($kid, $realm, $level + 1); } function renderTagRowForEditor ($taginfo, $level = 0) { global $root, $pageno, $tabno, $taglist; echo ''; $nrefs = 0; foreach ($taginfo['refcnt'] as $part) $nrefs += $part; if ($nrefs > 0 or count ($taginfo['kids']) > 0) printImageHREF ('nodelete', "${nrefs} references, " . count ($taginfo['kids']) . ' sub-tags'); else { echo ""; printImageHREF ('delete', 'Delete tag'); echo ""; } echo "\n"; echo ""; echo ""; printImageHREF ('save', 'Save changes', TRUE); echo "\n"; foreach ($taginfo['kids'] as $kid) renderTagRowForEditor ($kid, $level + 1); } function renderTagTree () { global $tagtree; echo '
'; foreach ($tagtree as $taginfo) { echo ''; renderTagRowForViewer ($taginfo); echo "\n"; } echo '
'; } function renderTagCloud ($realm = '') { global $taglist, $tagtree; echo ''; foreach (getObjectiveTagTree ($tagtree, $realm) as $taginfo) { echo ''; renderTagRowForCloud ($taginfo, $realm); echo "\n"; } echo '
'; } function renderTagTreeEditor () { global $root, $pageno, $tabno, $taglist, $tagtree; showMessageOrError(); echo "
"; startPortlet ('tag tree'); echo "\n"; echo "\n"; foreach ($tagtree as $taginfo) { renderTagRowForEditor ($taginfo, TRUE); } echo ""; echo ""; echo ""; echo ""; echo ""; echo "\n"; echo '
 tagparent 
"; printImageHREF ('grant', 'Create tag', TRUE, 102); echo ' 
'; finishPortlet(); echo "
"; startPortlet ('fallen leaves'); echo "\n"; echo "\n"; foreach (getOrphanedTags() as $taginfo) { echo '\n"; } echo '
tagparent 
'; echo "
"; echo ""; echo ""; echo "${taginfo['tag']}
"; printImageHREF ('save', 'Save changes', TRUE); echo "
'; finishPortlet(); echo "
"; } // Output a sequence of OPTION elements, selecting those, which are present on the // explicit tags list. function renderTagOption ($taginfo, $level = 0) { global $expl_tags; $selected = ''; foreach ($expl_tags as $etaginfo) if ($taginfo['id'] == $etaginfo['id']) { $selected = ' selected'; break; } echo '\n"; foreach ($taginfo['kids'] as $kid) renderTagOption ($kid, $level + 1); } // Idem, but select those, which are shown on the $_REQUEST['tagfiler'] array. // Ignore tag ids, which can't be found on the tree. function renderTagOptionForFilter ($taginfo, $tagfilter, $realm, $level = 0) { echo $level; $selected = ''; foreach ($tagfilter as $filter_id) if ($taginfo['id'] == $filter_id) { $selected = ' selected'; break; } echo '\n"; foreach ($taginfo['kids'] as $kid) renderTagOptionForFilter ($kid, $tagfilter, $realm, $level + 1); } function renderObjectTags ($id) { renderEntityTags ('object', 'object_id', $id); } function renderIPv4PrefixTags ($id) { renderEntityTags ('ipv4net', 'id', $id); } function renderRackTags ($id) { renderEntityTags ('rack', 'rack_id', $id); } function renderIPv4VSTags ($id) { renderEntityTags ('ip4vs', 'id', $id); } function renderIPv4RSPoolTags ($id) { renderEntityTags ('ip4rspool', 'pool_id', $id); } function renderEntityTags ($entity_realm = '', $bypass_name, $entity_id = 0) { global $tagtree; if ($entity_realm == '' or $entity_id <= 0) { showError ('Invalid or missing arguments', __FUNCTION__); return; } global $root, $pageno, $tabno; showMessageOrError(); startPortlet ('Tag list'); echo "
\n"; echo "\n"; echo "\n"; echo "\n"; echo "\n"; echo '
'; printImageHREF ('SAVE', 'Save changes', TRUE); echo "
\n"; finishPortlet(); } function printTagTRs ($baseurl = '') { global $expl_tags, $impl_tags, $auto_tags; if (getConfigVar ('SHOW_EXPLICIT_TAGS') == 'yes' and count ($expl_tags)) { echo "Explicit tags:"; echo serializeTags ($expl_tags, $baseurl) . "\n"; } if (getConfigVar ('SHOW_IMPLICIT_TAGS') == 'yes' and count ($impl_tags)) { echo "Implicit tags:"; echo serializeTags ($impl_tags, $baseurl) . "\n"; } if (getConfigVar ('SHOW_AUTOMATIC_TAGS') == 'yes' and count ($auto_tags)) { echo "Automatic tags:"; echo serializeTags ($auto_tags) . "\n"; } } // Output a portlet, with currently selected tags and prepare a form for update. function renderTagFilterPortlet ($tagfilter, $realm, $bypass_name = '', $bypass_value = '') { global $pageno, $tabno, $taglist, $tagtree; $objectivetags = getObjectiveTagTree ($tagtree, $realm); startPortlet ('Tag filter'); if (!count ($objectivetags)) { echo "None defined for current realm.
"; return; } echo "
\n"; echo "\n"; echo "\n"; if ($bypass_name != '') echo "\n"; echo '
'; echo "
\n"; finishPortlet(); } // Dump all tags in a single SELECT element. function renderTagSelect () { global $taglist, $tagtree; if (!count ($taglist)) { echo "No tags defined"; return; } echo '
'; } function renderTagRollerForRow () { dragon(); } function renderObjectSLB () { dragon(); } function renderEditRSPool () { dragon(); } function renderEditVService () { dragon(); } function renderEditLBsForVService () { dragon(); } function dump ($var) { echo '
';
	print_r ($var);
	echo '
'; } ?>