EOS; /* These are only needed for popup windows, so only need it for specific pages like dsh */ if ($stylesheets) { foreach ($stylesheets as $s) { echo "\n"; } } if ($javascripts) { foreach ($javascripts as $j) { echo "\n"; } } echo "
\n"; echo <<$str
\n"; } } // Take in a hostname or ip address and return the fully qualified primary hostname. If resolution fails, // it just returns what it was given. function resolveHost($host) { //------------------------------------ if (isIPAddr($host)) { // IP address $hostname = gethostbyaddr($host); return $hostname; } else { //todo: implement resolution of hostname to full primary hostname with just one call $ip = gethostbyname($host); if (!isIPAddr($ip)) { return $host; } $hostname = gethostbyaddr($ip); return $hostname; } } //------------------------------------ function isIPAddr ($host) { return preg_match('/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/', $host); } // Returns the URL for the requested documentation. This provides 1 level of indirection in case the location // of some of the documentation changes. function getDocURL($book, $section) { //------------------------------------ $web = array ( 'docs' => "http://xcat.org/doc", 'forum' => "http://xcat.org/mailman/listinfo/xcat-user", 'updates' => "http://www.alphaworks.ibm.com/tech/xCAT", 'opensrc' => "http://www-rcf.usc.edu/~garrick", 'wiki' => "http://www.asianlinux.org/xcat", ); $man = array (); $howto = array (); $rsctadmin = array ( 0 => "http://publib.boulder.ibm.com/infocenter/clresctr/vxrx/topic/com.ibm.cluster.rsct.doc/rsct_aix5l53", 1 => "$rsctadmin[0]/bl5adm1002.html", 'sqlExpressions' => "$rsctadmin[0]/bl5adm1042.html#ussexp", 'conditions' => "$rsctadmin[0]/bl5adm1041.html#cmrcond", 'responses' => "$rsctadmin[0]/bl5adm1041.html#cmrresp", 'resourceClasses' => "$rsctadmin[0]/bl5adm1039.html#lavrc", ); $rsctref = array ( 0 => "http://publib.boulder.ibm.com/infocenter/clresctr/vxrx/topic/com.ibm.cluster.rsct.doc/rsct_linux151", 1 => "$rsctref[0]/bl5trl1002.html", 'errm' => "$rsctref[0]/bl5trl1067.html#errmcmd", 'errmScripts' => "$rsctref[0]/bl5trl1081.html#errmscr", 'sensor' => "$rsctref[0]/bl5trl1088.html#srmcmd", 'auditlog' => "$rsctref[0]/bl5trl1095.html#audcmd", 'lscondresp' => "$rsctref[0]/bl5trl1071.html#lscondresp", 'startcondresp' => "$rsctref[0]/bl5trl1079.html#startcondresp", ); if ($book) { if (!$section) { $section = 1; } // link to whole book if no section specified $url = &$$book; return $url[$section]; } else { // produce html for a page that contains all the links above, for testing purposes return ''; //todo: } } // This returns important display info about each type of hardware, so we can easily add new hw types. function getHWTypeInfo($hwtype, $attr) { //------------------------------------ //todo: get the aliases to be keys in this hash too $hwhash = array ( 'x335' => array ( 'image'=>'330.gif', 'rackimage'=>'x335-front', 'u'=>1, 'aliases'=>'8676' ), 'x336' => array ( 'image'=>'330.gif', 'rackimage'=>'x335-front', 'u'=>1, 'aliases'=>'8837' ), 'x306' => array ( 'image'=>'330.gif', 'rackimage'=>'x335-front', 'u'=>1, 'aliases'=>'8836' ), 'x306m' => array ( 'image'=>'330.gif', 'rackimage'=>'x335-front', 'u'=>1, 'aliases'=>'8849,8491' ), 'x3550' => array ( 'image'=>'330.gif', 'rackimage'=>'x335-front', 'u'=>1, 'aliases'=>'7978' ), 'e325' => array ( 'image'=>'330.gif', 'rackimage'=>'x335-front', 'u'=>1, 'aliases'=>'8835' ), 'e326' => array ( 'image'=>'330.gif', 'rackimage'=>'x335-front', 'u'=>1, 'aliases'=>'8848' ), 'e326m' => array ( 'image'=>'330.gif', 'rackimage'=>'x335-front', 'u'=>1, 'aliases'=>'7969' ), 'e327' => array ( 'image'=>'330.gif', 'rackimage'=>'x335-front', 'u'=>1, 'aliases'=>'' ), 'x340' => array ( 'image'=>'342.gif', 'rackimage'=>'x345-front', 'u'=>2, 'aliases'=>'8656' ), 'x342' => array ( 'image'=>'342.gif', 'rackimage'=>'x345-front', 'u'=>2, 'aliases'=>'8669' ), 'x345' => array ( 'image'=>'342.gif', 'rackimage'=>'x345-front', 'u'=>2, 'aliases'=>'8670' ), 'x346' => array ( 'image'=>'342.gif', 'rackimage'=>'x345-front', 'u'=>2, 'aliases'=>'8840' ), 'x3650' => array ( 'image'=>'342.gif', 'rackimage'=>'x345-front', 'u'=>2, 'aliases'=>'7979' ), 'x360' => array ( 'image'=>'342.gif', 'rackimage'=>'x366-front', 'u'=>3, 'aliases'=>'8686' ), 'x365' => array ( 'image'=>'342.gif', 'rackimage'=>'x366-front', 'u'=>3, 'aliases'=>'8862' ), 'x366' => array ( 'image'=>'342.gif', 'rackimage'=>'x366-front', 'u'=>3, 'aliases'=>'8863' ), 'x3850' => array ( 'image'=>'342.gif', 'rackimage'=>'x366-front', 'u'=>3, 'aliases'=>'8863' ), 'x445' => array ( 'image'=>'342.gif', 'rackimage'=>'x366-front', 'u'=>3, 'aliases'=>'' ), 'x450' => array ( 'image'=>'342.gif', 'rackimage'=>'x366-front', 'u'=>3, 'aliases'=>'' ), 'x455' => array ( 'image'=>'342.gif', 'rackimage'=>'x366-front', 'u'=>3, 'aliases'=>'' ), 'x460' => array ( 'image'=>'342.gif', 'rackimage'=>'x366-front', 'u'=>3, 'aliases'=>'' ), 'x3950' => array ( 'image'=>'342.gif', 'rackimage'=>'x366-front', 'u'=>3, 'aliases'=>'' ), 'hs20' => array ( 'image'=>'blade.gif', 'rackimage'=>'blade-front', 'u'=>7, 'aliases'=>'8678,8843,7981' ), # removed 8832 because it is older and it made this entry to wide in the drop down boxes 'js20' => array ( 'image'=>'blade.gif', 'rackimage'=>'blade-front', 'u'=>7, 'aliases'=>'8842' ), 'js21' => array ( 'image'=>'blade.gif', 'rackimage'=>'blade-front', 'u'=>7, 'aliases'=>'8844' ), 'ls20' => array ( 'image'=>'blade.gif', 'rackimage'=>'blade-front', 'u'=>7, 'aliases'=>'8850' ), 'hs40' => array ( 'image'=>'blade2.gif', 'rackimage'=>'blade2-front', 'u'=>7, 'aliases'=>'8839' ), 'p5-505' => array ( 'image'=>'330.gif', 'rackimage'=>'x335-front', 'u'=>1, 'aliases'=>'9115' ), 'p5-505Q' => array ( 'image'=>'330.gif', 'rackimage'=>'x335-front', 'u'=>1, 'aliases'=>'9115' ), 'p5-510' => array ( 'image'=>'342.gif', 'rackimage'=>'x345-front', 'u'=>2, 'aliases'=>'9110' ), 'p5-510Q' => array ( 'image'=>'342.gif', 'rackimage'=>'x345-front', 'u'=>2, 'aliases'=>'9110' ), 'p5-575' => array ( 'image'=>'342.gif', 'rackimage'=>'x345-front', 'u'=>2, 'aliases'=>'9118' ), 'p5-520' => array ( 'image'=>'520.gif', 'rackimage'=>'p5-520-front', 'u'=>4, 'aliases'=>'9111' ), 'p5-520Q' => array ( 'image'=>'520.gif', 'rackimage'=>'p5-520-front', 'u'=>4, 'aliases'=>'9131' ), 'p5-550' => array ( 'image'=>'520.gif', 'rackimage'=>'p5-520-front', 'u'=>4, 'aliases'=>'9113' ), 'p5-550Q' => array ( 'image'=>'520.gif', 'rackimage'=>'p5-520-front', 'u'=>4, 'aliases'=>'9133' ), 'p5-560' => array ( 'image'=>'520.gif', 'rackimage'=>'p5-520-front', 'u'=>4, 'aliases'=>'9116' ), 'p5-560Q' => array ( 'image'=>'520.gif', 'rackimage'=>'p5-520-front', 'u'=>4, 'aliases'=>'9116' ), 'p5-570' => array ( 'image'=>'520.gif', 'rackimage'=>'p5-520-front', 'u'=>4, 'aliases'=>'9117' ), 'p5-590' => array ( 'image'=>'590.gif', 'rackimage'=>'p5-590-front', 'u'=>42, 'aliases'=>'9119' ), 'p5-595' => array ( 'image'=>'590.gif', 'rackimage'=>'p5-590-front', 'u'=>42, 'aliases'=>'9119' ), 'p710' => array ( 'image'=>'342.gif', 'rackimage'=>'x335-front', 'u'=>2, 'aliases'=>'9123' ), 'p720' => array ( 'image'=>'520.gif', 'rackimage'=>'x345-front', 'u'=>4, 'aliases'=>'9124' ), 'p610' => array ( 'image'=>'520.gif', 'rackimage'=>'x335-front', 'u'=>5, 'aliases'=>'7028' ), 'p615' => array ( 'image'=>'520.gif', 'rackimage'=>'x335-front', 'u'=>4, 'aliases'=>'7029' ), 'p630' => array ( 'image'=>'520.gif', 'rackimage'=>'x335-front', 'u'=>4, 'aliases'=>'7026' ), 'p640' => array ( 'image'=>'520.gif', 'rackimage'=>'x335-front', 'u'=>5, 'aliases'=>'7026' ), 'p650' => array ( 'image'=>'520.gif', 'rackimage'=>'x335-front', 'u'=>8, 'aliases'=>'7038' ), 'p655' => array ( 'image'=>'590.gif', 'rackimage'=>'x335-front', 'u'=>42, 'aliases'=>'7039' ), 'p670' => array ( 'image'=>'590.gif', 'rackimage'=>'x335-front', 'u'=>42, 'aliases'=>'7040' ), 'p690' => array ( 'image'=>'590.gif', 'rackimage'=>'x335-front', 'u'=>42, 'aliases'=>'7040' ), ); $info = $hwhash[strtolower($hwtype)]; if (isset($attr)) { return $info[$attr]; } else { return $info; } } // Returns the image that should be displayed for this type of hw. Gets this from getHWTypeInfo() function getHWTypeImage($hwtype, $powermethod) { //------------------------------------ # 1st try to match the hw type $info = getHWTypeInfo($hwtype, 'image'); if ($info) { return $info['image']; } # No matches yet. Use the power method to get a generic type. if (isset($powermethod)) { $powermethod = strtolower($powermethod); if ($powermethod == 'blade') { return getHWTypeInfo('hs20', 'image'); } elseif ($powermethod == 'hmc') { return getHWTypeInfo('p5-520', 'image'); } elseif ($powermethod == 'bmc') { return getHWTypeInfo('x335','image'); } elseif ($powermethod == 'xseries') { return getHWTypeInfo('x335', 'image'); } } # As a last resort, return the most common node image return getHWTypeInfo('x335', 'image'); } // Return the image that represents the status string passed in function getStatusImage($status) { global $TOPDIR; if ($status == 'good') { return "$TOPDIR/images/green-ball-m.gif"; } elseif ($status == 'warning') { return "$TOPDIR/images/yellow-ball-m.gif"; } elseif ($status == 'bad') { return "$TOPDIR/images/red-ball-m.gif"; } else { return "$TOPDIR/images/blue-ball-m.gif"; } } // Returns the specified user preference value. Not finished. function getPref($key) { //------------------------------------ if ($key == 'MaxNodesDisplayed') { return 50; } return ''; } // Returns a list of some or all of the nodes in the cluster. Pass in either a group name or node range, // or NULL for each to get all nodes. Not finished. function getNodes($group, $noderange) { //------------------------------------ //my ($hostname, $type, $osname, $distro, $version, $mode, $status, $conport, $hcp, $nodeid, $pmethod, $location, $comment) = split(/:\|:/, $na); for ($i = 1; $i <= 10; $i++) { $nodes[] = array('hostname'=>"node$i.cluster.com", 'type'=>'x3655', 'osname'=>'Linux', 'distro'=>'RedHat', 'version'=>'4.5', 'status'=>1, 'conport'=>$i, 'hcp'=>"node$i-bmc.cluster.com", 'nodeid'=>'', 'pmethod'=>'bmc', 'location'=>"frame=1 u=$", 'comment'=>''); } return $nodes; } // Returns the node groups defined in the cluster. function getGroups() { $groups = array(); $output = array(); runcmd("/bin/sudo listattr", 2, $output); foreach ($output as $grp) { $groups[] = $grp; } return $groups; } // Returns the aggregate status of each node group in the cluster. The return value is a // hash in which the key is the group name and the value is the status as returned by nodestat. function getGroupStatus() { $groups = array(); $output = array(); runcmd("/bin/sudo grpattr", 2, $output); foreach ($output as $line) { //echo "line=$line
"; $vals = preg_split('/: */', $line); if (count($vals) == 2) { $groups[$vals[0]] = $vals[1]; } } return $groups; } // Returns true if we are running on AIX ------------------------------------ function isAIX() { } //todo: implement // Returns true if we are running on Linux ------------------------------------ function isLinux() { } //todo: implement // Returns true if we are running on Windows ------------------------------------ function isWindows() { return array_key_exists('WINDIR', $_SERVER); } // Create file folder-like tabs. Tablist is an array of label/url pairs. function insertTabs ($tablist, $currentTabIndex) { //------------------------------------ echo ""; } if ($currentTabIndex == $key) { echo " | $tab[0] | "; } else { echo "$tab[0] | "; } } echo "||||
"; echo " | $button | "; } echo "
This page is not done yet.
\n"; } ?>