Web interface prototype ported to xcat 2. Now real development of it can start.
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@2236 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
cc909fa783
commit
bd63d8fc0b
@ -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;
|
||||
|
BIN
xCAT-web/images/top2.jpg
Normal file
BIN
xCAT-web/images/top2.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.8 KiB |
BIN
xCAT-web/images/topl2.jpg
Normal file
BIN
xCAT-web/images/topl2.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.8 KiB |
BIN
xCAT-web/images/topr2.jpg
Normal file
BIN
xCAT-web/images/topr2.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 5.4 KiB |
BIN
xCAT-web/images/toptop.gif
Normal file
BIN
xCAT-web/images/toptop.gif
Normal file
Binary file not shown.
After Width: | Height: | Size: 799 B |
@ -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 .= "<table id='$group' class=GroupNodeTable width='100%' cellpadding=0 cellspacing=1 border=0>\n";
|
||||
$html .= "<TR class=GroupNodeTableHeader><TD>Node Name</TD><TD>Arch</TD><TD>OS</TD><TD>Mode</TD><TD>Status</TD><TD>Power Method</TD><TD>Comment</TD></TR>\n";
|
||||
$html = "<table id='$group' class=GroupNodeTable width='100%' cellpadding=0 cellspacing=1 border=0>\n";
|
||||
$html .= "<TR class=GroupNodeTableHeader><TD>Node Name</TD><TD>Arch</TD><TD>OS</TD><TD>Profile</TD><TD>Status</TD><TD>Power Method</TD><TD>Comment</TD></TR>\n";
|
||||
|
||||
foreach($nodes as $nodeName => $attrs) {
|
||||
$html .= GroupNodeTable::getNodeTableRow($nodeName, $attrs);
|
||||
@ -103,16 +103,19 @@ function getNodeGroupSection($group, $nodes) {
|
||||
function getNodeTableRow($nodeName, $attrs) {
|
||||
$html = "<tr class=GroupNodeTableRow>\n" .
|
||||
"<td align=left><input type=checkbox name='node_$nodeName' >$nodeName</td>\n" .
|
||||
"<td>" . $attrs['arch'] . "</td>\n" .
|
||||
"<td>" . $attrs['osversion'] . "</td>\n" .
|
||||
"<td>" . $attrs['mode'] . "</td>\n";
|
||||
"<td>" . (array_key_exists('nodetype.arch',$attrs)?$attrs['nodetype.arch']:'') . "</td>\n" .
|
||||
"<td>" . (array_key_exists('nodetype.os',$attrs)?$attrs['nodetype.os']:'') . "</td>\n" .
|
||||
"<td>" . (array_key_exists('nodetype.profile',$attrs)?$attrs['nodetype.profile']:'') . "</td>\n";
|
||||
|
||||
$stat = 'unknown'; //todo: implement
|
||||
$stat = 'unknown'; //todo: implement when nodels <nr> nodelist.status works
|
||||
$img_string = '<img src="' . getStatusImage($stat) . '">';
|
||||
|
||||
$html .= "<td>" . $img_string . "</td>".
|
||||
"<td>" . $attrs['power'] . "</td>".
|
||||
"<td>" . $attrs['comment'] . "</td></tr>";
|
||||
$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 .= "<td align=center>" . $img_string . "</td>".
|
||||
"<td>" . $powerstr . "</td>".
|
||||
"<td>" . (array_key_exists('nodelist.comments',$attrs)?$attrs['nodelist.comments']:'') . "</td></tr>";
|
||||
|
||||
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"; }
|
||||
|
@ -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 "</head><body>\n";
|
||||
echo <<<EOS
|
||||
<table id=headingTable border=0 cellspacing=0 cellpadding=0>
|
||||
<tr valign=top>
|
||||
<td><img src='$TOPDIR/images/topl.jpg'></td>
|
||||
<td><img src='$TOPDIR/images/topl2.jpg'></td>
|
||||
<td class=TopMiddle><img id=xcatImage src='$TOPDIR/images/xCAT_icon-l.gif' height=40px></td>
|
||||
<td class=TopMiddle width='100%'>
|
||||
|
||||
@ -62,7 +64,7 @@ EOS;
|
||||
|
||||
insertMenus($currents);
|
||||
|
||||
echo "</td><td><img src='$TOPDIR/images/topr.jpg'></td></tr></table>\n";
|
||||
echo "</td><td><img src='$TOPDIR/images/topr2.jpg'></td></tr></table>\n";
|
||||
//echo "</div></div>\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 "</TR></TABLE>\n";
|
||||
//echo "</ul></div>\n";
|
||||
echo "</td></tr></ul>\n";
|
||||
echo "\n</ul></td></tr>\n";
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Inserts the html for each pages footer
|
||||
function insertFooter() {
|
||||
echo '<div class=PageFooter><p id=disclaimer>This interface is still under construction and not yet ready for use.</p></div></BODY></HTML>';
|
||||
}
|
||||
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// 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('<xcatrequest></xcatrequest>');
|
||||
$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 = '/<xcatresponse>\s*<serverdone>\s*<\/serverdone>\s*<\/xcatresponse>\s*$/';
|
||||
if(preg_match($pattern,$response)) { // transaction is done, pkg up the xml and return it
|
||||
#echo htmlentities($response);
|
||||
$response = '<xcat>' . preg_replace($pattern,'', $response) . '</xcat>'; // 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 "<p>xCAT Submit request Error: $errno - $errstr</p>\n";
|
||||
}
|
||||
if(! $cleanexit){
|
||||
if(!$skipVerify){
|
||||
echo "<p>Error: xCAT response ended prematurely.</p>";
|
||||
$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('<br>$_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 "<p class=Trace>$str</p>\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 "<p>nodels $noderange $a</p>\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 "<p> $attrname = $attrval </p>\n";
|
||||
//echo "<p>"; print_r($nodename); echo "</p>\n";
|
||||
//echo "<p>"; print_r($o); echo "</p>\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 "<p>$key=$value.</p>\n"; }
|
||||
//function awalk2($a) { foreach ($a as $key => $value) { if (is_array($value)) {$v='<array>';} else {$v=$value;} echo "<p>$key=$v.</p>\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 "<p>line=$line</p>";
|
||||
$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 "<TABLE cellpadding=4 cellspacing=0 width='100%' summary=Tabs><TBODY><TR>";
|
||||
foreach ($tablist as $key => $tab) {
|
||||
if ($key != 0) { echo "<TD width=2></TD>"; }
|
||||
@ -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 "<p class=NotDone>This page is not done yet.</p>\n"; }
|
||||
|
||||
?>
|
||||
|
@ -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;}
|
||||
|
@ -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 '</body></html>';
|
||||
|
||||
/* This was copied from the csm web interface and can be used as the beginning code
|
||||
for the frame view.
|
||||
<SCRIPT language="JavaScript">
|
||||
function _reloadMe(form)
|
||||
{
|
||||
@ -125,7 +128,6 @@ else { return form.selAllCheckbox.checked; } // non-rack display
|
||||
</SCRIPT>
|
||||
|
||||
<div id=content>
|
||||
<?php /* phpinfo(); */ ?>
|
||||
<P align="center"><IMG src="images/csmlogo.gif" border="0"></P>
|
||||
<H2>Node List on Management Server <?= $_SERVER["SERVER_NAME"] ?></H2>
|
||||
|
||||
@ -349,3 +351,4 @@ if ($AIXdisable) {
|
||||
</div>
|
||||
</body>
|
||||
</HTML>
|
||||
?>
|
||||
|
@ -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; }
|
||||
|
@ -68,17 +68,69 @@ foreach($groups as $group => $status) {
|
||||
|
||||
GroupNodeTable::insertGroupTableFooter();
|
||||
|
||||
echo <<<EOS
|
||||
<!-- <SCRIPT language="JavaScript"> XCATEvent.doExpandNodes(); </SCRIPT> -->
|
||||
</form>
|
||||
<table>
|
||||
<tr><td><img src="$TOPDIR/images/green-ball-m.gif"></td><td align=left>Node is good (Status is ready/pbs/sshd)</td></tr>
|
||||
<tr><td><img src="$TOPDIR/images/red-ball-m.gif"></td><td align=left>Node is bad (Status is 'noping')</td></tr>
|
||||
<tr><td><img src="$TOPDIR/images/yellow-ball-m.gif"></td><td align=left>Other status (unknown/node unavailable...)</td></tr>
|
||||
</table>
|
||||
<p id=disclaimer>This interface is still under construction and not yet ready for use.</p>
|
||||
</div>
|
||||
</BODY>
|
||||
</HTML>
|
||||
EOS;
|
||||
echo '<!-- <SCRIPT language="JavaScript"> XCATEvent.doExpandNodes(); </SCRIPT> --></form><table><tr>';
|
||||
|
||||
echo '<td><img src="' . getStatusImage('good') . '"> Good</td><td width=20></td>';
|
||||
echo '<td><img src="' . getStatusImage('warning') . '"> Possible problem</td><td width=20></td>';
|
||||
echo '<td><img src="' . getStatusImage('bad') . '"> Problem</td><td width=20></td>';
|
||||
echo '<td><img src="' . getStatusImage('unknown') . '"> Unknown</td>';
|
||||
|
||||
echo '</tr></table></div>';
|
||||
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 "<p>line=$line</p>";
|
||||
$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; }
|
||||
}
|
||||
|
||||
|
||||
?>
|
@ -1,11 +1,17 @@
|
||||
<?php
|
||||
|
||||
// Returns the nodes of a group expanded in the group/node table
|
||||
|
||||
$TOPDIR = '..';
|
||||
require_once("$TOPDIR/lib/GroupNodeTable.class.php");
|
||||
|
||||
$nodeGroupName = @$_REQUEST["nodeGroupName"];
|
||||
|
||||
// Get all the nodes with node information of the group
|
||||
$nodes = getNodes($nodeGroupName, array('type'));
|
||||
// Get all the nodes (with node information) of the group
|
||||
$nodes = getNodes($nodeGroupName, array('nodetype.os','nodetype.arch','nodetype.profile','nodehm.power','nodehm.mgt','nodelist.comments'));
|
||||
//$nodes = getNodes($nodeGroupName, 'nodetype.os');
|
||||
|
||||
// Display the rows in the table for these nodes
|
||||
echo GroupNodeTable::getNodeGroupSection($nodeGroupName, $nodes);
|
||||
|
||||
?>
|
||||
|
21
xCAT-web/machines/test.css
Normal file
21
xCAT-web/machines/test.css
Normal file
@ -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;
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ if (!isset($_REQUEST['noderange'])) {
|
||||
to /tmp on the nodes and executed from there.)</TD>
|
||||
</TR>
|
||||
<TR class=FormTable>
|
||||
<TD colspan="3" nowrap><INPUT type="checkbox" name="run_psh" id="pshChkBox" checked readonly>
|
||||
<TD colspan="3" nowrap><INPUT type="checkbox" name="run_psh" id="pshChkBox" disabled>
|
||||
Use parallel shell (psh) command instead of xdsh. Currently this option must be used, and the options below (associated with xdsh) are disabled.</TD>
|
||||
</TR>
|
||||
<TR class=FormTable>
|
||||
@ -79,17 +79,17 @@ if (!isset($_REQUEST['noderange'])) {
|
||||
</TR>
|
||||
<TR class=FormTable>
|
||||
<TD width="37"></TD>
|
||||
<TD width="210" valign="top" nowrap><INPUT type="checkbox" name="serial" id="serialChkBox" disabled>Streaming mode</TD>
|
||||
<TD width="210" valign="top" nowrap><INPUT type="checkbox" name="serial" id="serialChkBox">Streaming mode</TD>
|
||||
<TD width="500">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.</TD>
|
||||
</TR>
|
||||
<TR class=FormTable>
|
||||
<TD></TD>
|
||||
<TD valign="top" nowrap><INPUT type="checkbox" name="monitor" id="monitorChkBox" disabled>Monitor</TD>
|
||||
<TD valign="top" nowrap><INPUT type="checkbox" name="monitor" id="monitorChkBox">Monitor</TD>
|
||||
<TD>Prints starting and completion messages for each node. Useful with Streaming mode.</TD>
|
||||
</TR>
|
||||
<TR class=FormTable>
|
||||
<TD></TD>
|
||||
<TD valign="top" nowrap><INPUT type="checkbox" name="verify" id="verifyChkBox" disabled>Verify</TD>
|
||||
<TD valign="top" nowrap><INPUT type="checkbox" name="verify" id="verifyChkBox">Verify</TD>
|
||||
<TD>Verifies that nodes are responding before sending the command to them.</TD>
|
||||
</TR>
|
||||
<TR class=FormTable>
|
||||
@ -99,12 +99,12 @@ if (!isset($_REQUEST['noderange'])) {
|
||||
</TR>
|
||||
<TR class=FormTable>
|
||||
<TD></TD>
|
||||
<TD valign="top" nowrap>Fanout: <INPUT type="text" name="fanout" id="fanoutTxtBox" disabled></TD>
|
||||
<TD valign="top" nowrap>Fanout: <INPUT type="text" name="fanout" id="fanoutTxtBox"></TD>
|
||||
<TD>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).</TD>
|
||||
</TR>
|
||||
<TR class=FormTable>
|
||||
<TD></TD>
|
||||
<TD valign="top" nowrap>UserID: <INPUT type="text" name="userID" id="userIDTxtBox" disabled></TD>
|
||||
<TD valign="top" nowrap>UserID: <INPUT type="text" name="userID" id="userIDTxtBox"></TD>
|
||||
<TD>The user id to use to run the command on the nodes.</TD>
|
||||
</TR>
|
||||
<TR class=FormTable>
|
||||
@ -119,13 +119,13 @@ if (!isset($_REQUEST['noderange'])) {
|
||||
</TR>
|
||||
<TR class=FormTable>
|
||||
<TD></TD>
|
||||
<TD valign="top" nowrap><INPUT type="checkbox" name="ret_code" id="ret_codeChkBox" disabled>Return Code</TD>
|
||||
<TD valign="top" nowrap><INPUT type="checkbox" name="ret_code" id="ret_codeChkBox">Return Code</TD>
|
||||
<TD>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.</TD>
|
||||
</TR>
|
||||
<TR><TD colspan="3">
|
||||
<font class="BlueBack">Tips:</font>
|
||||
<UL>
|
||||
<LI>See the <A href="<?php echo $TOPDIR; ?>/support/doc.php?book=manpages&section=xdsh">xdsh man page</A> for more information about this command.</LI>
|
||||
<LI>See the <A href="<?php echo getDocURL('manpage','xdsh.1'); ?>">xdsh man page</A> for more information about this command.</LI>
|
||||
</UL>
|
||||
</TD></TR>
|
||||
</TBODY>
|
||||
|
@ -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 "<p>Command: ". $cmd ."</p>";
|
||||
|
||||
//$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 "<p><b>Command: $command_string</b></p>";
|
||||
//echo "<p><b>Command Ouput:</b></br></p>"; //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<br>"; }
|
||||
}
|
||||
//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<br>"; }
|
||||
}
|
||||
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 "<p><b>Command: $command $noderange " . implode(' ',$args) . "</b></p>";
|
||||
//echo "<p><b>Command Ouput:</b></br></p>"; //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 "<p>count=" . count($xml) . ", children=" . $xml->children() . "</p>";
|
||||
//echo "<p>"; print_r($xml); echo "</p>";
|
||||
//$output = $xml->xcatresponse->children();
|
||||
//echo "<p>"; print_r($output); echo "</p>";
|
||||
foreach ($xml->children() as $response) foreach ($response->children() as $line) { echo "$line<br>"; }
|
||||
|
||||
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user