diff --git a/xCAT-web/cmds/grpattr b/xCAT-web/cmds/grpattr index 3eb0c593c..d8959b38c 100644 --- a/xCAT-web/cmds/grpattr +++ b/xCAT-web/cmds/grpattr @@ -1,5 +1,7 @@ #!/usr/bin/perl +# NOTE: this cmd is not ported to xCAT 2.0 and is not used any more!!!!!! + # Display some aggregate information about each group, gathered from the db and its nodes use strict; diff --git a/xCAT-web/images/top2.jpg b/xCAT-web/images/top2.jpg new file mode 100644 index 000000000..7e1f7a21d Binary files /dev/null and b/xCAT-web/images/top2.jpg differ diff --git a/xCAT-web/images/topl2.jpg b/xCAT-web/images/topl2.jpg new file mode 100644 index 000000000..ec1351dac Binary files /dev/null and b/xCAT-web/images/topl2.jpg differ diff --git a/xCAT-web/images/topr2.jpg b/xCAT-web/images/topr2.jpg new file mode 100644 index 000000000..fb0107d1f Binary files /dev/null and b/xCAT-web/images/topr2.jpg differ diff --git a/xCAT-web/images/toptop.gif b/xCAT-web/images/toptop.gif new file mode 100644 index 000000000..5194ba2f7 Binary files /dev/null and b/xCAT-web/images/toptop.gif differ diff --git a/xCAT-web/lib/GroupNodeTable.class.php b/xCAT-web/lib/GroupNodeTable.class.php index 94308de7d..cbdb694f6 100644 --- a/xCAT-web/lib/GroupNodeTable.class.php +++ b/xCAT-web/lib/GroupNodeTable.class.php @@ -84,8 +84,8 @@ function getNodeGroupSection($group, $nodes) { $right_arrow_gif = $imagedir . "/grey_arrow_r.gif"; $left_arrow_gif = $imagedir . "/grey_arrow_l.gif"; - $html .= "\n"; - $html .= "\n"; + $html = "
Node NameArchOSModeStatusPower MethodComment
\n"; + $html .= "\n"; foreach($nodes as $nodeName => $attrs) { $html .= GroupNodeTable::getNodeTableRow($nodeName, $attrs); @@ -103,16 +103,19 @@ function getNodeGroupSection($group, $nodes) { function getNodeTableRow($nodeName, $attrs) { $html = "\n" . "\n" . - "\n" . - "\n" . - "\n"; + "\n" . + "\n" . + "\n"; - $stat = 'unknown'; //todo: implement + $stat = 'unknown'; //todo: implement when nodels nodelist.status works $img_string = ''; - $html .= "". - "". - ""; + $powerstr = array_key_exists('nodehm.power',$attrs) ? $attrs['nodehm.power'] : NULL; + if (empty($powerstr)) { $powerstr = array_key_exists('nodehm.mgt',$attrs)?$attrs['nodehm.mgt']:''; } + + $html .= "". + "". + ""; return $html; } @@ -123,7 +126,7 @@ function getNodeTableRow($nodeName, $attrs) { */ function determineStatus($statStr) { $status = NULL; - if ($statStr == "ready" || $statStr == "pbs" || $statStr == "sshd") { $status = "good"; } + if ($statStr == "alive" || $statStr == "ready" || $statStr == "pbs" || $statStr == "sshd") { $status = "good"; } else if ($statStr == "noping") { $status = "bad"; } else if ($statStr == "ping") { $status = "warning"; } else { $status = "unknown"; } diff --git a/xCAT-web/lib/functions.php b/xCAT-web/lib/functions.php index 7fcd2c3cf..c9882dffd 100644 --- a/xCAT-web/lib/functions.php +++ b/xCAT-web/lib/functions.php @@ -7,10 +7,12 @@ session_start(); // retain session variables across page requests if (!isset($TOPDIR)) { $TOPDIR = '..'; } // The settings below display error on the screen, instead of giving blank pages. -error_reporting(E_ALL ^ E_NOTICE); +//error_reporting(E_ALL ^ E_NOTICE); +error_reporting(E_ALL); ini_set('display_errors', true); +//----------------------------------------------------------------------------- /** * Inserts the header part of the HTML and the top part of the page, including the menu. * Also includes some common css and js files and the css and js files specified. @@ -53,7 +55,7 @@ echo "\n"; echo << - +
Node NameArchOSProfileStatusPower MethodComment
$nodeName" . $attrs['arch'] . "" . $attrs['osversion'] . "" . $attrs['mode'] . "" . (array_key_exists('nodetype.arch',$attrs)?$attrs['nodetype.arch']:'') . "" . (array_key_exists('nodetype.os',$attrs)?$attrs['nodetype.os']:'') . "" . (array_key_exists('nodetype.profile',$attrs)?$attrs['nodetype.profile']:'') . "" . $img_string . "" . $attrs['power'] . "" . $attrs['comment'] . "
" . $img_string . "" . $powerstr . "" . (array_key_exists('nodelist.comments',$attrs)?$attrs['nodelist.comments']:'') . "
@@ -62,7 +64,7 @@ EOS; insertMenus($currents); -echo "
\n"; +echo "\n"; //echo "\n"; // end the top div } // end insertHeader @@ -126,10 +128,10 @@ $MENU = array( 'list' => array( 'diagnose' => array('label' => 'Diagnose', 'url' => "$TOPDIR/support/diagnose.php"), 'update' => array('label' => 'Update', 'url' => "$TOPDIR/support/update.php"), - 'howtos' => array('label' => 'HowTos', 'url' => "$TOPDIR/support/howtos.php"), - 'manpages' => array('label' => 'Man Pages', 'url' => "$TOPDIR/support/manpages.php"), - 'maillist' => array('label' => 'Mail List', 'url' => "http://xcat.org/mailman/listinfo/xcat-user"), - 'wiki' => array('label' => 'Wiki', 'url' => "http://xcat.wiki.sourceforge.net/"), + 'howtos' => array('label' => 'HowTos', 'url' => getDocURL('howto')), + 'manpages' => array('label' => 'Man Pages', 'url' => getDocURL('manpage')), + 'maillist' => array('label' => 'Mail List', 'url' => getDocURL('web','mailinglist')), + 'wiki' => array('label' => 'Wiki', 'url' => getDocURL('web','wiki')), 'suggest' => array('label' => 'Suggestions', 'url' => "$TOPDIR/support/suggest.php"), 'about' => array('label' => 'About', 'url' => "$TOPDIR/support/about.php"), ) @@ -137,6 +139,7 @@ $MENU = array( ); +//----------------------------------------------------------------------------- // Insert the menus at the top of the page // $currents is an array of the current menu choice tree function insertMenus($currents) { @@ -152,6 +155,7 @@ function insertMenus($currents) { } +//----------------------------------------------------------------------------- // Insert one set of choices under a main choice. function insertMenuRow($current, $isTop, $items) { global $TOPDIR; @@ -182,10 +186,82 @@ function insertMenuRow($current, $isTop, $items) { //echo "\n"; //echo "\n"; - echo "\n"; + echo "\n\n"; } +//----------------------------------------------------------------------------- +// Inserts the html for each pages footer +function insertFooter() { +echo ''; +} + + +//----------------------------------------------------------------------------- +// Run a cmd via the xcat client/server protocol +// args is an array of arguments to the cmd +// Returns a tree of SimpleXML objects. See perl-xCAT/xCAT/Client.pm for the format. +function docmd($cmd, $nr, $args){ + $request = simplexml_load_string(''); + $request->addChild('command',$cmd); + foreach ($args as $a) { + $request->addChild('arg',$a); + } + if(!empty($nr)){ + $request->addChild('noderange',$nr); + } + #echo $request->asXML(); + $xml = submit_request($request,0); + return $xml; +} + + +//----------------------------------------------------------------------------- +// Used by docmd() +// req is a tree of SimpleXML objects +// Returns a tree of SimpleXML objects. See perl-xCAT/xCAT/Client.pm for the format. +function submit_request($req, $skipVerify){ + #global $cert,$port,$xcathost; + $apachehome = '/var/www'; #todo: for sles this should be /var/lib/wwwrun + $cert = "$apachehome/.xcat/client-cred.pem"; + $xcathost = "localhost"; + $port = "3001"; + $rsp = 0; + $response = ''; + $cleanexit=0; + + // Open a socket to xcatd + $context = stream_context_create(array('ssl'=>array('local_cert' => $cert))); + if($fp = stream_socket_client('ssl://'.$xcathost.':'.$port,$errno,$errstr,30, + STREAM_CLIENT_CONNECT,$context)){ + fwrite($fp,$req->asXML()); // send the xml to xcatd + while(!feof($fp)){ // and then read until there is no more + $response .= preg_replace('/\n/','', stream_get_contents($fp)); // remove newlines and add it to the response + + // Look for the serverdone response + $pattern = '/\s*\s*<\/serverdone>\s*<\/xcatresponse>\s*$/'; + if(preg_match($pattern,$response)) { // transaction is done, pkg up the xml and return it + #echo htmlentities($response); + $response = '' . preg_replace($pattern,'', $response) . ''; // remove the serverdone response and put an xcat tag around the rest + $rsp = simplexml_load_string($response,'SimpleXMLElement', LIBXML_NOCDATA); + $cleanexit = 1; + } + } + fclose($fp); + }else{ + echo "

xCAT Submit request Error: $errno - $errstr

\n"; + } + if(! $cleanexit){ + if(!$skipVerify){ + echo "

Error: xCAT response ended prematurely.

"; + $rsp = 0; + } + } + return $rsp; +} + + + /** ---------------------------------------------------------------------------------------------- Function to run the commands on the remote nodes. Four arguments: 1. The command @@ -238,8 +314,9 @@ function runcmd ($cmd, $mode, &$output, $options=NULL){ } +//----------------------------------------------------------------------------- // Send the keys and values in the primary global arrays -function dumpGlobals() { //------------------------------------ +function dumpGlobals() { trace('$_SERVER:'); foreach ($_SERVER as $key => $val) { trace("$key = $val"); } trace('
$_ENV:'); @@ -253,8 +330,12 @@ function dumpGlobals() { //------------------------------------ } } + +//----------------------------------------------------------------------------- function getXcatRoot() { return isset($_ENV['XCATROOT']) ? $_ENV['XCATROOT'] : '/opt/xcat'; } + +//----------------------------------------------------------------------------- # Returns true if the given rpm file is already installed at this version or higher. function isInstalled($rpmfile) { $aixrpmopt = isAIX() ? '--ignoreos' : ''; @@ -271,6 +352,7 @@ function isInstalled($rpmfile) { $isSupportedHash = array(); +//----------------------------------------------------------------------------- # Returns true if the specified feature is supported. This is normally determined by some fast # method like checking for the existence of a file. The answer is also cached for next time. function isSupported($feature) { @@ -297,9 +379,10 @@ define("TRACE", "1"); function trace($str) { if (TRACE) { 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) { //------------------------------------ +function resolveHost($host) { if (isIPAddr($host)) { // IP address $hostname = gethostbyaddr($host); return $hostname; @@ -312,23 +395,41 @@ function resolveHost($host) { //------------------------------------ } } -//------------------------------------ +//----------------------------------------------------------------------------- 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) { //------------------------------------ +//----------------------------------------------------------------------------- +// Returns the URL for the requested documentation. This provides 1 level of indirection in case +// the location of some of the documentation changes. +// book is the name (minus the dollar sign) of one of the arrays below. +// section is the book/website/table name, or in the case of manpage: cmd.section# +function getDocURL($book, $section = NULL) { + global $TOPDIR; $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", + 'docs' => "http://xcat.svn.sourceforge.net/svnroot/xcat/xcat-core/trunk/xCAT-client/share/doc", + 'mailinglist' => "http://xcat.org/mailman/listinfo/xcat-user", + 'updates' => "http://xcat.sourceforge.net/yum", + 'opensrc' => "http://xcat.sourceforge.net/yum", + 'wiki' => "http://xcat.wiki.sourceforge.net", ); - $man = array (); - $howto = array (); - $rsctadmin = array ( + $manpage = array( + 0 => "$TOPDIR/../xcat-doc", + 1 => "$TOPDIR/../xcat-doc/man1/xcat.1.html", + ); + $dbtable = array( + 0 => "$TOPDIR/../xcat-doc/man5", + 1 => "$TOPDIR/../xcat-doc/man5/xcatdb.5.html", + ); + $howto = array( + 0 => "$TOPDIR/../xcat-doc", + 1 => "$TOPDIR/../xcat-doc/index.html", + 'linuxCookbook' => "$TOPDIR/../xcat-doc/xCAT2.pdf", + 'idataplexCookbook' => "$TOPDIR/../xcat-doc/xCAT-iDpx.pdf", + 'aixCookbook' => "$TOPDIR/../xcat-doc/xCAT2onAIX.pdf", + ); + /* + $rsctadmin = array ( //todo: update this 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", @@ -336,8 +437,7 @@ function getDocURL($book, $section) { //------------------------------------ 'responses' => "$rsctadmin[0]/bl5adm1041.html#cmrresp", 'resourceClasses' => "$rsctadmin[0]/bl5adm1039.html#lavrc", ); - - $rsctref = array ( + $rsctref = array ( //todo: update this 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", @@ -347,11 +447,23 @@ function getDocURL($book, $section) { //------------------------------------ '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]; + //$url = &$$book; + if ($book=='web') $url = & $web; + elseif ($book=='manpage') $url = & $manpage; + elseif ($book=='dbtable') $url = & $dbtable; + elseif ($book=='howto') $url = & $howto; + else return NULL; + + if (!$section) { return $url[1]; } // link to whole book if no section specified + if ($book=='manpage') { + $m = explode('.',$section); // 1st part is cmd name, 2nd part is man section + return "$url[0]/man$m[1]/$m[0].$m[1].html"; + } + elseif ($book=='dbtable') { return "$url[0]/$section.5.html"; } + else return $url[$section]; } else { // produce html for a page that contains all the links above, for testing purposes return ''; //todo: @@ -359,8 +471,9 @@ function getDocURL($book, $section) { //------------------------------------ } +//----------------------------------------------------------------------------- // This returns important display info about each type of hardware, so we can easily add new hw types. -function getHWTypeInfo($hwtype, $attr) { //------------------------------------ +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' ), @@ -431,8 +544,9 @@ function getHWTypeInfo($hwtype, $attr) { //------------------------------------ } +//----------------------------------------------------------------------------- // Returns the image that should be displayed for this type of hw. Gets this from getHWTypeInfo() -function getHWTypeImage($hwtype, $powermethod) { //------------------------------------ +function getHWTypeImage($hwtype, $powermethod) { # 1st try to match the hw type $info = getHWTypeInfo($hwtype, 'image'); if ($info) { return $info['image']; } @@ -451,6 +565,7 @@ function getHWTypeImage($hwtype, $powermethod) { //----------------------------- } +//----------------------------------------------------------------------------- // Return the image that represents the status string passed in function getStatusImage($status) { global $TOPDIR; @@ -461,6 +576,7 @@ function getStatusImage($status) { } +//----------------------------------------------------------------------------- // Returns the specified user preference value, or the default. (The preferences are stored in cookies.) // If no key is specified, it will return the list of preference names. function getPref($key) { @@ -474,69 +590,76 @@ function getPref($key) { } +//----------------------------------------------------------------------------- // Returns a list of some or all of the nodes in the cluster and some of their attributes. // Pass in a node range (or NULL to get all nodes) and an array of attribute names (or NULL for none). // Returns an array where each key is the node name and each value is an array of attr/value pairs. +// attrs is an array of attributes that should be returned. function getNodes($noderange, $attrs) { //my ($hostname, $type, $osname, $distro, $version, $mode, $status, $conport, $hcp, $nodeid, $pmethod, $location, $comment) = split(/:\|:/, $na); //$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'=>''); $nodes = array(); - foreach ($attrs as $a) { - $output = array(); - //echo "

nodels $noderange $a

\n"; - runcmd("nodels $noderange $a", 2, $output); - foreach ($output as $line) { - $vals = preg_split('/: */', $line); // vals[0] will be the node name - if (!$nodes[$vals[0]]) { $nodes[$vals[0]] = array(); } - $attributes = & $nodes[$vals[0]]; - if ($a == 'type') { - $types = preg_split('/-/', $vals[1]); - $attributes['osversion'] = $types[0]; - $attributes['arch'] = $types[1]; - $attributes['type'] = $types[2]; - } - } + //$xml = docmd('nodels',$noderange,implode(' ',$attrs)); + $xml = docmd('nodels',$noderange,$attrs); + $output = $xml->xcatresponse->children(); // technically, we should iterate over the xcatresponses, because there can be more than one + foreach ($output as $o) { + $nodename = (string)$o->name; + $data = $o->data; + $attrval = (string)$data->contents; + $attrname = (string)$data->desc; + //echo "

$attrname = $attrval

\n"; + //echo "

"; print_r($nodename); echo "

\n"; + //echo "

"; print_r($o); echo "

\n"; + //$nodes[$nodename] = array('osversion' => $attr); + if (!array_key_exists($nodename,$nodes)) { $nodes[$nodename] = array(); } + $attributes = & $nodes[$nodename]; + $attributes[$attrname] = $attrval; } return $nodes; } +//function awalk($value, $key) { echo "

$key=$value.

\n"; } +//function awalk2($a) { foreach ($a as $key => $value) { if (is_array($value)) {$v='';} else {$v=$value;} echo "

$key=$v.

\n"; } } + +//----------------------------------------------------------------------------- // Returns the node groups defined in the cluster. function getGroups() { $groups = array(); - $output = array(); - runcmd("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("grpattr", 2, $output); + $xml = docmd('tabdump','',array('nodelist')); + $output = $xml->xcatresponse->children(); + #$output = $xml->children(); // technically, we should iterate over the xcatresponses, because there can be more than one foreach ($output as $line) { //echo "

line=$line

"; - $vals = preg_split('/: */', $line); - if (count($vals) == 2) { $groups[$vals[0]] = $vals[1]; } + $vals = array(); + preg_match('/^"([^"]*)","([^"]*)"/', $line, $vals); //todo: create function to parse tabdump output better + if (count($vals) > 2) { + //$node = $vals[1]; + $grplist = preg_split('/,/', $vals[2]); + foreach ($grplist as $g) { $groups[$g] = 1; } + } } - return $groups; + $grplist = array_keys($groups); + sort($grplist); + return $grplist; } -// Returns true if we are running on AIX ------------------------------------ +//----------------------------------------------------------------------------- +// Returns true if we are running on AIX function isAIX() { } //todo: implement -// Returns true if we are running on Linux ------------------------------------ +//----------------------------------------------------------------------------- +// Returns true if we are running on Linux function isLinux() { } //todo: implement -// Returns true if we are running on Windows ------------------------------------ +//----------------------------------------------------------------------------- +// 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) { //------------------------------------ +function insertTabs ($tablist, $currentTabIndex) { echo ""; foreach ($tablist as $key => $tab) { if ($key != 0) { echo ""; } @@ -551,6 +674,7 @@ function insertTabs ($tablist, $currentTabIndex) { //--------------------------- } +//----------------------------------------------------------------------------- // Create the Action buttons in a table. Each argument passed in is a button, which is an array of attribute strings. // If your onclick attribute contains javascript code that uses quotes, use double quotes instead of single quotes. // Note: if only 1 button is passed in, the button is not put in a table. @@ -568,6 +692,7 @@ function insertButtons () { } +//----------------------------------------------------------------------------- // Display messages in the html. If severity is W or E, it will attempt to use the Error class // from the style sheet. function msg($severity, $msg) @@ -580,6 +705,7 @@ function msg($severity, $msg) } +//----------------------------------------------------------------------------- function insertNotDoneYet() { echo "

This page is not done yet.

\n"; } ?> diff --git a/xCAT-web/lib/style.css b/xCAT-web/lib/style.css index 6b213864b..62d1f7ee4 100644 --- a/xCAT-web/lib/style.css +++ b/xCAT-web/lib/style.css @@ -3,7 +3,8 @@ /* background-color: #002432; */ } -.TopMiddle { background: #FFF url(../images/top.jpg) repeat-x top; } +.TopTop { background: #FFF url(../images/toptop.jpg) repeat-x top; } +.TopMiddle { background: #FFF url(../images/top2.jpg) repeat-x top; padding-top: 1px; } /* #top { @@ -38,7 +39,7 @@ border-right: 2px solid white; } -#mainNav { /* the UL the contains the LIs of one row of menu items */ +#mainNav { /* the UL that contains the LIs of one row of menu items */ /* position: absolute; float: left; */ list-style: none; @@ -63,7 +64,7 @@ display: block; padding: 0 2em; /*2em;*/ margin: 0px; - background: #09334b; + background: #0B4360; /* #09334b; */ color: #fafafa; } @@ -95,7 +96,7 @@ } */ #mainNav a:hover { - background: #09334b; + background: #0B4360; /* #09334b; */ color: #fafafa; } @@ -123,6 +124,21 @@ div#content { .ContentForm { margin: 10px 2px 15px 2px; } +.PageFooter { + background-color : #e8e8e8; + margin: 10px; + padding: 5px; +} + +#disclaimer { + font-weight: bold; + font-size: 8pt; + font-style: italic; + color: red; + text-align: center; + margin: 5px; +} + BODY { margin: 0; padding: 10px; @@ -138,6 +154,7 @@ BODY { */ } +IMG { vertical-align: middle; } INPUT {vertical-align : middle; font-size : 8pt; font-family : sans-serif; font-weight : bold;} SELECT {vertical-align : middle; font-size : 8pt; font-family : sans-serif; font-weight : bold;} TEXTAREA {vertical-align : middle; font-size : 8pt; font-family : sans-serif; font-weight : bold;} diff --git a/xCAT-web/machines/frames.php b/xCAT-web/machines/frames.php index 38b55002c..ff4888994 100644 --- a/xCAT-web/machines/frames.php +++ b/xCAT-web/machines/frames.php @@ -4,8 +4,11 @@ $TOPDIR = '..'; require_once "$TOPDIR/lib/functions.php"; insertHeader('xCAT Frame Node List', NULL, NULL, array('machines','frames')); if (isAIX()) { $aixDisabled = 'disabled'; } -?> +insertNotDoneYet(); +echo ''; +/* This was copied from the csm web interface and can be used as the beginning code + for the frame view.
-

Node List on Management Server

@@ -349,3 +351,4 @@ if ($AIXdisable) {
+?> diff --git a/xCAT-web/machines/groups.css b/xCAT-web/machines/groups.css index bd41296dd..716968631 100644 --- a/xCAT-web/machines/groups.css +++ b/xCAT-web/machines/groups.css @@ -1,13 +1,7 @@ + /* Styles specific to the groups.php page */ -#disclaimer { - font-weight: bold; - font-size: 9pt; - color: red; - text-align: center; - margin: 5px; -} - .GroupNodeTable { margin-left: 10px; } +.GroupNodeTable TD { padding-left: 0.2em; padding-right: 0.2em; } .GroupNodeTableHeader { color: black; background-color : #FFFF66; font-weight : bold; white-space: nowrap; } .GroupNodeTableRow { color: black; background-color : #FFFF66; white-space: nowrap; } diff --git a/xCAT-web/machines/groups.php b/xCAT-web/machines/groups.php index b4a818f6e..45ace52eb 100644 --- a/xCAT-web/machines/groups.php +++ b/xCAT-web/machines/groups.php @@ -68,17 +68,69 @@ foreach($groups as $group => $status) { GroupNodeTable::insertGroupTableFooter(); -echo << XCATEvent.doExpandNodes(); --> - -
- - - -
Node is good (Status is ready/pbs/sshd)
Node is bad (Status is 'noping')
Other status (unknown/node unavailable...)
-

This interface is still under construction and not yet ready for use.

- - - -EOS; +echo ''; + +echo ''; +echo ''; +echo ''; +echo ''; + +echo '
Good Possible problem Problem Unknown
'; +insertFooter(); + + + +//----------------------------------------------------------------------------- +// 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 nodelist.status. +function getGroupStatus() { + $groups = array(); + $xml = docmd('tabdump','',array('nodelist')); + $output = $xml->xcatresponse->children(); + #$output = $xml->children(); // technically, we should iterate over the xcatresponses, because there can be more than one + foreach ($output as $line) { + //echo "

line=$line

"; + $vals = array(); + preg_match('/^"([^"]*)","([^"]*)",(.*)$/', $line, $vals); //todo: create function to parse tabdump output better + if (count($vals) > 3) { + //$node = $vals[1]; + $grplist = preg_split('/,/', $vals[2]); + $rest = $vals[3]; + $status = array(); + preg_match('/^"([^"]*)"/', $rest, $status); + if (count($status) < 2) { $status[1] = 'unknown'; } + foreach ($grplist as $g) { + if (array_key_exists($g,$groups)) { $groups[$g] = minstat($groups[$g], $status[1]); } + else { $groups[$g] = $status[1]; } + } + } + } + return $groups; +} + + +//----------------------------------------------------------------------------- +// For 2 status strings from nodestat or nodelist.status, return the "lowest". +function minstat($s1, $s2) { + $statnum = array( 'unknown' => 0, + 'noping' => 1, + 'ping' => 2, + 'snmp' => 3, + 'sshd' => 4, + 'pbs' => 5, + 'ready' => 6, + ); + + // if either value is empty, just return the other one + if (!isset($s1)) { return $s2; } + if (!isset($s2)) { return $s1; } + + // if either value does not map into the hash, then return unknown + if (!isset($statnum[$s1]) || !isset($statnum[$s2])) { return 'unknown'; } + + if ($statnum[$s1] < $statnum[$s2]) { return $s1; } + else { return $s2; } +} + + ?> \ No newline at end of file diff --git a/xCAT-web/machines/nodes_by_group.php b/xCAT-web/machines/nodes_by_group.php index be561565b..027bda3c1 100644 --- a/xCAT-web/machines/nodes_by_group.php +++ b/xCAT-web/machines/nodes_by_group.php @@ -1,11 +1,17 @@ diff --git a/xCAT-web/machines/test.css b/xCAT-web/machines/test.css new file mode 100644 index 000000000..c58705b1f --- /dev/null +++ b/xCAT-web/machines/test.css @@ -0,0 +1,21 @@ + +#disclaimer { + font-weight: bold; + font-size: 9pt; + color: red; + text-align: center; + margin: 5px; +} + +.GroupNodeTable { margin-left: 10px; } + +.myTableHeader { + color: black; + background-color: #FFFF66; +} + +.myTableRow { + color: black; + background-color: #FFFF66; +} + diff --git a/xCAT-web/manage/dsh.php b/xCAT-web/manage/dsh.php index 41e9704da..76b93800c 100644 --- a/xCAT-web/manage/dsh.php +++ b/xCAT-web/manage/dsh.php @@ -71,7 +71,7 @@ if (!isset($_REQUEST['noderange'])) { to /tmp on the nodes and executed from there.) - + Use parallel shell (psh) command instead of xdsh. Currently this option must be used, and the options below (associated with xdsh) are disabled. @@ -79,17 +79,17 @@ if (!isset($_REQUEST['noderange'])) { - Streaming mode + Streaming mode Specifies that output is returned as it becomes available from each target, instead of waiting for the command to be completed on a target before returning output from that target. - Monitor + Monitor Prints starting and completion messages for each node. Useful with Streaming mode. - Verify + Verify Verifies that nodes are responding before sending the command to them. @@ -99,12 +99,12 @@ if (!isset($_REQUEST['noderange'])) { - Fanout: + Fanout: The maximum number of nodes the command should be run on concurrently. When the command finishes on 1 of the nodes, it will be started on an additional node (the default is 64). - UserID: + UserID: The user id to use to run the command on the nodes. @@ -119,13 +119,13 @@ if (!isset($_REQUEST['noderange'])) { - Return Code + Return Code Prints the return code of the (last) command that was run remotely on each node. The return code is appended at the end of the output for each node. Tips:
    -
  • See the xdsh man page for more information about this command.
  • +
  • See the xdsh man page for more information about this command.
diff --git a/xCAT-web/manage/dsh_action.php b/xCAT-web/manage/dsh_action.php index 58ab62e52..bb836cbce 100644 --- a/xCAT-web/manage/dsh_action.php +++ b/xCAT-web/manage/dsh_action.php @@ -46,81 +46,54 @@ if (isset($_COOKIE['history']) && array_search($_REQUEST['command'], $_COOKIE['h $ret_code = @$_REQUEST["ret_code"]; - //if ($group == "") $nodegrps = "blade7"; // For now, use blade7 as test node + if (!empty($group)) $noderange = $group; + else $noderange = $node; - if ($psh == "off"){ //using dsh - $command = "xdsh "; - $copy_cmd = "xdcp "; - if ($group == "") $node_group = /* "-n " . */ $node; - else $node_group = /* "-N " . */ $group; + if ($serial == "on") $args[] = "-s"; //streaming mode + if (!empty($fanout)) { $args[] = "-f"; $args[] = $fanout; } + if (!empty($userID)) { $args[] = "-l"; $args[] = $userID; } + if ($verify == "on") $args[] = "-v"; + if ($monitor == "on") $args[] = "-m"; + if ($copy == "on") $args[] = "-e"; + if ($ret_code == "on") $args[] = "-z"; - }else{ - $command = "psh "; - $copy_cmd = "pscp "; - if ($group == "") $node_group = $node; - else $node_group = $group; - } + //$exp_cmd = "export DSH_CONTEXT=XCAT XCATROOT=/opt/xcat; "; - if ($serial == "on") $options = "-s "; //serial mode/streaming mode - if ($fanout == "") $options .= "-f 64 "; else $options .= "-f " . $fanout; - if ($userID != "") $options .= "-l " . $userID; - if ($verify == "on") $options .= "-v "; - if ($monitor == "on") $options .= "-m "; +/* + if ($copy == "on"){ //using dcp/prcp - //echo "

Command: ". $cmd ."

"; - - //$exp_cmd = "export DSH_CONTEXT=XCAT XCATROOT=/opt/xcat; "; - - if ($copy == "on"){ //using dcp/prcp - - //extract the script name from the command - $script = strtok($cmd,' '); - - //copy the command to the remote node - $source = "/opt/xcat/bin/" . $script; //copy from - $target = "/tmp"; //copy to - if ($psh == "off"){ - $copy_cmd = $exp_cmd . $copy_cmd . $node_group . " " . $source . " " . $target; - }else{ - $copy_cmd = $copy_cmd . $source . " " . $node_group . ":" . $target; - } - runcmd($copy_cmd,1, $outp); - - if ($psh != "on"){ - $command_string = $exp_cmd . $command. $node_group . " /tmp/" . $cmd; - }else{ - $command_string = $command . $node_group . " /tmp/" . $cmd; - } - - } - else{ - if ($psh != "on"){ - $command_string = $exp_cmd . $command. $node_group . " " . $cmd; - }else{ - $command_string = $command . $node_group . " " . $cmd; - } - } - - if ($collapse == "on") $command_string .= " | dshbak -c"; - - echo "

Command: $command_string

"; - //echo "

Command Ouput:

"; //output will be returned from the runcmd function call - - //run the script - $output = array(); - if ($ret_code == "on"){ - $rc = runcmd($command_string, 0, $output); //mode 0 - if ($rc == 0){ - foreach ($output as $line){ echo "$line
"; } - } + //extract the script name from the command + $script = strtok($cmd,' '); + //copy the command to the remote node + $source = $script; + $target = "/tmp"; + if (empty($psh) || $psh!="on"){ + $xml = docmd('xdcp',$noderange,array($source, $target)); + //todo: check if copy succeeded }else{ - //$rc = runcmd($command_string,1, $outp); //streaming mode - DOES NOT WORK YET - $rc = runcmd($command_string, 0, $output); //mode 0 - if ($rc == 0){ - foreach ($output as $line){ echo "$line
"; } - } + runcmd("pscp $source $noderange:$target",1,$outp); } + $cmd = "/tmp/$cmd"; + } +*/ + + if (empty($psh) || $psh!="on") $command = "xdsh"; + else $command = "psh"; + + //if ($collapse == "on") $command_string .= " | dshbak -c"; + + // Run the script + $args[] = $cmd; + echo "

Command: $command $noderange " . implode(' ',$args) . "

"; + //echo "

Command Ouput:

"; //output will be returned from the runcmd function call + //$rc = runcmd($command_string,1, $outp); //streaming mode - DOES NOT WORK YET + $xml = docmd($command, $noderange, $args); + //echo "

count=" . count($xml) . ", children=" . $xml->children() . "

"; + //echo "

"; print_r($xml); echo "

"; + //$output = $xml->xcatresponse->children(); + //echo "

"; print_r($output); echo "

"; + foreach ($xml->children() as $response) foreach ($response->children() as $line) { echo "$line
"; } diff --git a/xCAT-web/xCAT-web.spec b/xCAT-web/xCAT-web.spec index c9d414a87..1721ad605 100644 --- a/xCAT-web/xCAT-web.spec +++ b/xCAT-web/xCAT-web.spec @@ -52,10 +52,10 @@ then apachedaemon='httpd' apacheuser='apache' - # todo: change this when switch to xcat 2 - echo "Updating apache userid to allow logins..." - cp /etc/passwd /etc/passwd.orig - perl -e 'while (<>) { s,^apache:(.*):/sbin/nologin$,apache:$1:/bin/bash,; print $_; }' /etc/passwd.orig >/etc/passwd + # Note: this was for sudo with xcat 1.3 + #echo "Updating apache userid to allow logins..." + #cp /etc/passwd /etc/passwd.orig + #perl -e 'while (<>) { s,^apache:(.*):/sbin/nologin$,apache:$1:/bin/bash,; print $_; }' /etc/passwd.orig >/etc/passwd else # SuSE apachedaemon='apache2' apacheuser='wwwrun' @@ -67,19 +67,20 @@ then /bin/ln -s %{prefix}/web/etc/apache2/conf.d/xcat-web.conf /etc/$apachedaemon/conf.d/xcat-web.conf /etc/init.d/$apachedaemon reload - # Link to the grpattr cmd. Todo: remove this when it is in base xcat - /bin/rm -f %{prefix}/bin/grpattr - mkdir -p %{prefix}/bin - /bin/ln -s %{prefix}/web/cmds/grpattr %{prefix}/bin/grpattr + # Link to the grpattr cmd. Note: this was for xcat 1.3. Do not use this anymore. + #/bin/rm -f %{prefix}/bin/grpattr + #mkdir -p %{prefix}/bin + #/bin/ln -s %{prefix}/web/cmds/grpattr %{prefix}/bin/grpattr + + # Config sudo. Note: this was for xcat 1.3. Do not use this anymore. + #if ! egrep -q "^$apacheuser ALL=\(ALL\) NOPASSWD:ALL" /etc/sudoers; then + #echo "Configuring sudo for $apacheuser..." + #echo "$apacheuser ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers + #fi - # Config sudo. Todo: change this when switch to xcat 2 - if ! egrep -q "^$apacheuser ALL=\(ALL\) NOPASSWD:ALL" /etc/sudoers; then - echo "Configuring sudo for $apacheuser..." - echo "$apacheuser ALL=(ALL) NOPASSWD:ALL" >> /etc/sudoers - fi # Authorize the apacheuser to xcatd - # echo -e "y\ny\ny" | %{prefix}/share/xcat/scripts/setup-local-client.sh $apacheuser - # XCATROOT=%{prefix} %{prefix}/sbin/chtab priority=5 policy.name=$apacheuser policy.rule=allow + echo -e "y\ny\ny" | %{prefix}/share/xcat/scripts/setup-local-client.sh $apacheuser + XCATROOT=%{prefix} %{prefix}/sbin/chtab priority=5 policy.name=$apacheuser policy.rule=allow fi @@ -98,9 +99,9 @@ then apacheuser='apache' # Undo change we made to passwd file. Todo: change this when switch to xcat 2 - echo "Undoing apache userid login..." - cp /etc/passwd /etc/passwd.tmp - perl -e 'while (<>) { s,^apache:(.*):/bin/bash$,apache:$1:/sbin/nologin,; print $_; }' /etc/passwd.tmp >/etc/passwd + #echo "Undoing apache userid login..." + #cp /etc/passwd /etc/passwd.tmp + #perl -e 'while (<>) { s,^apache:(.*):/bin/bash$,apache:$1:/sbin/nologin,; print $_; }' /etc/passwd.tmp >/etc/passwd else # SuSE apachedaemon='apache2' apacheuser='wwwrun' @@ -110,15 +111,15 @@ then echo "Undoing $apachedaemon configuration for xCAT..." /bin/rm -f /etc/$apachedaemon/conf.d/xcat-web.conf /etc/init.d/$apachedaemon reload - /bin/rm -f %{prefix}/bin/grpattr + #/bin/rm -f %{prefix}/bin/grpattr # Remove change we made to sudoers config. Todo: remove this when switch to xcat 2 - if egrep -q "^$apacheuser ALL=\(ALL\) NOPASSWD:ALL" /etc/sudoers; then - echo "Undoing sudo configuration for $apacheuser..." - cp -f /etc/sudoers /etc/sudoers.tmp - egrep -v "^$apacheuser ALL=\(ALL\) NOPASSWD:ALL" /etc/sudoers.tmp > /etc/sudoers - rm -f /etc/sudoers.tmp - fi + #if egrep -q "^$apacheuser ALL=\(ALL\) NOPASSWD:ALL" /etc/sudoers; then + #echo "Undoing sudo configuration for $apacheuser..." + #cp -f /etc/sudoers /etc/sudoers.tmp + #egrep -v "^$apacheuser ALL=\(ALL\) NOPASSWD:ALL" /etc/sudoers.tmp > /etc/sudoers + #rm -f /etc/sudoers.tmp + #fi fi