mirror of
https://github.com/xcat2/xcat-core.git
synced 2026-05-19 18:10:24 +00:00
Merge pull request #18 from chuckbrazie/ZVM_XCAT_DEV_AprilUpdates
zVM changes up till April 21
This commit is contained in:
@@ -279,6 +279,7 @@ sub getNetworkNames {
|
||||
|
||||
# Get network names
|
||||
my $out;
|
||||
my $outmsg;
|
||||
my $names;
|
||||
my $count;
|
||||
my @parms;
|
||||
@@ -369,11 +370,12 @@ sub getNetworkNames {
|
||||
# use vmcp q lan if this is not the zhcp node
|
||||
} else {
|
||||
#$out = `ssh -o ConnectTimeout=5 $user\@$node "$sudo /sbin/vmcp q lan | egrep 'LAN|VSWITCH'"`;
|
||||
my $cmd = $sudo . ' /sbin/vmcp q lan | egrep "LAN|VSWITCH"';
|
||||
my $cmd = $sudo . ' /sbin/vmcp q lan';
|
||||
$out = xCAT::zvmUtils->execcmdonVM($user, $node, $cmd); # caller sets $user to $::SUDOER
|
||||
if (xCAT::zvmUtils->checkOutput($out) == -1) {
|
||||
return $out;
|
||||
}
|
||||
$out = `echo "$out" | egrep -a -i 'LAN|VSWITCH'`;
|
||||
@lines = split( '\n', $out );
|
||||
|
||||
foreach (@lines) {
|
||||
@@ -431,11 +433,12 @@ sub getNetworkNamesArray {
|
||||
|
||||
# Get the networks used by the node
|
||||
#my $out = `ssh $user\@$node "$sudo /sbin/vmcp q v nic" | egrep -i "VSWITCH|LAN"`;
|
||||
my $cmd = $sudo . ' /sbin/vmcp q v nic | egrep -i "VSWITCH|LAN"';
|
||||
my $cmd = $sudo . ' /sbin/vmcp q v nic';
|
||||
my $out = xCAT::zvmUtils->execcmdonVM($user, $node, $cmd); # caller sets $user to $::SUDOER
|
||||
if (xCAT::zvmUtils->checkOutput($out) == -1) {
|
||||
return $out;
|
||||
}
|
||||
$out = `echo "$out" | egrep -a -i 'VSWITCH|LAN'`;
|
||||
my @lines = split( '\n', $out );
|
||||
|
||||
# Loop through each line
|
||||
@@ -549,7 +552,7 @@ sub getNetwork {
|
||||
xCAT::zvmUtils->printSyslog("ssh $user\@$hcp $sudo $dir/smcli Virtual_Network_LAN_Query -T $hcpUserId -n $netNameQuery -o '*'");
|
||||
$out = `ssh $user\@$hcp "$sudo $dir/smcli Virtual_Network_LAN_Query -T $hcpUserId -n $netNameQuery -o '*' "`;
|
||||
$rc = $? >> 8;
|
||||
if ($rc) {
|
||||
if ($rc == 255) {
|
||||
$retStr = "(Error) unable to communicate with the zhcp system: $hcpUserId";
|
||||
xCAT::zvmUtils->printSyslog($retStr);
|
||||
return $retStr;
|
||||
@@ -674,11 +677,12 @@ sub getVswitchId {
|
||||
|
||||
# Get VSwitch
|
||||
#my $out = `ssh -o ConnectTimeout=5 $user\@$node "$sudo /sbin/vmcp q v nic" | grep "VSWITCH"`;
|
||||
my $cmd = $sudo . ' /sbin/vmcp q v nic | grep "VSWITCH"';
|
||||
my $cmd = $sudo . ' /sbin/vmcp q v nic';
|
||||
my $out = xCAT::zvmUtils->execcmdonVM($user, $node, $cmd); # caller sets $user to $::SUDOER
|
||||
if (xCAT::zvmUtils->checkOutput($out) == -1) {
|
||||
return $out;
|
||||
}
|
||||
$out = `echo "$out" | egrep -a -i 'VSWITCH'`;
|
||||
my @lines = split( '\n', $out );
|
||||
my @parms;
|
||||
my @vswitch;
|
||||
@@ -731,8 +735,9 @@ sub grantVSwitch {
|
||||
# Use SMAPI EXEC, use new extended SMAPI vs old one
|
||||
# my $out = `ssh $user\@$hcp "$sudo $dir/smcli Virtual_Network_Vswitch_Set -T SYSTEM -n $vswitchId -I $userId -u 2"`;
|
||||
# xCAT::zvmUtils->printSyslog("grantVSwitch- ssh $user\@$hcp $sudo $dir/smcli Virtual_Network_Vswitch_Set -T SYSTEM -n $vswitchId -I $userId -u 2");
|
||||
xCAT::zvmUtils->printSyslog( "grantVSwitch- ssh $user\@$hcp $sudo $dir/smcli Virtual_Network_Vswitch_Set_Extended -T SYSTEM -k 'switch_name='$vswitchId -k 'grant_userid='$userId -k 'persist=YES '$lanidparm" );
|
||||
my $out = `ssh $user\@$hcp "$sudo $dir/smcli Virtual_Network_Vswitch_Set_Extended -T SYSTEM -k 'switch_name='$vswitchId -k 'grant_userid='$userId -k 'persist=YES' $lanidparm"`;
|
||||
xCAT::zvmUtils->printSyslog("grantVSwitch- ssh $user\@$hcp $sudo $dir/smcli Virtual_Network_Vswitch_Set_Extended -T SYSTEM -k 'switch_name='$vswitchId -k 'grant_userid='$userId -k 'persist=YES '$lanidparm");
|
||||
|
||||
$out = xCAT::zvmUtils->trimStr($out);
|
||||
|
||||
# If return string contains 'Done' - Operation was successful
|
||||
@@ -915,8 +920,9 @@ sub smapiFlashCopy {
|
||||
SPOOL file class to be assigned to the punched file
|
||||
"" means that the current class is to be used
|
||||
anything else is the class to set on the punched file
|
||||
Returns : Operation results (Done/Failed)
|
||||
Example : my $rc = xCAT::zvmCPUtils->punch2Reader($hcp, $userId, $srcFile, $tgtFile, $options, $spoolClass );
|
||||
Returns : Operation results ("Done" or "Failed" with additional info)
|
||||
Example : my $response = xCAT::zvmCPUtils->punch2Reader( $user, $hcp, $userId, $srcFile,
|
||||
$tgtFile, $options, $spoolClass );
|
||||
|
||||
=cut
|
||||
|
||||
@@ -950,29 +956,32 @@ sub punch2Reader {
|
||||
$vmur = "/usr/sbin/vmur";
|
||||
}
|
||||
|
||||
my $done = 0;
|
||||
|
||||
# Punch the file. A loop is done in case the punch is currently in use.
|
||||
until ( $done ) {
|
||||
my $done = 0;
|
||||
my $maxTries = 12; # 12 attempts with 15 second waits for punch to become available
|
||||
my $maxTime = $maxTries / 4; # Total time: 3 minutes
|
||||
for ( my $i=0; ( $i < $maxTries and !$done ); $i++ ) {
|
||||
$out = `ssh -o ConnectTimeout=5 $user\@$hcp "$sudo $vmur punch $options $punchTarget -r $srcFile -N $tgtFile" 2>&1`;
|
||||
$rc = $? >> 8;
|
||||
if ( $rc == 255 ) {
|
||||
xCAT::zvmUtils->printSyslog( "(Error) In punch2Reader(), SSH communication with $hcp failed for command: $vmur punch" );
|
||||
$subResp = "Failed to communicate with the zHCP system: $hcp";
|
||||
$done = 1;
|
||||
} elsif ( $out =~ m/A concurrent instance of vmur is already active/i ) {
|
||||
# Recoverable error: retry the command after a delay
|
||||
xCAT::zvmUtils->printSyslog( "punch2Reader() Punch in use on $hcp, retrying in 15 seconds" );
|
||||
$subResp = "Failed, Punch in use on $hcp for over $maxTime minutes."; # Assume it will never become available
|
||||
sleep( 15 );
|
||||
} elsif ( $rc == 0 ) {
|
||||
# Punch appears successful
|
||||
$subResp = '';
|
||||
$punched = 1;
|
||||
$done = 1;
|
||||
} else {
|
||||
# Punch appears successful -- Look for the completion string
|
||||
my $searchStr = "created";
|
||||
if ( $out =~ m/$searchStr/i ) {
|
||||
$punched = 1;
|
||||
} else {
|
||||
chomp( $out );
|
||||
$subResp = "Failed, punch info: '$out'";
|
||||
xCAT::zvmUtils->printSyslog( "punch2Reader() Failed punching $srcFile to $userId from $hcp, rc: $rc, out: '$out'" );
|
||||
}
|
||||
# Punch failed for other than currently in use.
|
||||
chomp( $out );
|
||||
$subResp = "Failed, punch info: '$out'";
|
||||
xCAT::zvmUtils->printSyslog( "punch2Reader() Failed punching $srcFile to $userId from $hcp, rc: $rc, out: '$out'" );
|
||||
$done = 1;
|
||||
}
|
||||
}
|
||||
@@ -996,6 +1005,7 @@ sub punch2Reader {
|
||||
$rc = $? >> 8;
|
||||
if ( $rc == 255 ) {
|
||||
# SSH failure to communicate with zHCP. Nothing to do, file remains in zHCP's reader.
|
||||
xCAT::zvmUtils->printSyslog( "(Error) In punch2Reader(), SSH communication with $hcp failed for command: vmcp change rdr $spoolId class $spoolClass" );
|
||||
$subResp = "Failed to communicate with the zHCP system to change the reader file $spoolId to class $spoolClass: $hcp";
|
||||
} elsif ( $rc != 0 ) {
|
||||
# Generic failure of transfer command.
|
||||
@@ -1013,6 +1023,7 @@ sub punch2Reader {
|
||||
$subResp = "Done";
|
||||
} elsif ( $rc == 255 ) {
|
||||
# SSH failure to communicate with zHCP. Nothing to do, file remains in zHCP's reader.
|
||||
xCAT::zvmUtils->printSyslog( "(Error) In punch2Reader(), SSH communication with $hcp failed for command: vmcp transfer rdr $spoolId to $userId" );
|
||||
$subResp = "Failed to communicate with the zHCP system to transfer reader file $spoolId: $hcp";
|
||||
} else {
|
||||
# Generic failure of transfer command.
|
||||
@@ -1028,6 +1039,7 @@ sub punch2Reader {
|
||||
$rc = $? >> 8;
|
||||
if ( $rc == 255 ) {
|
||||
# SSH failure to communicate with zHCP. Nothing to do, file remains in zHCP's reader.
|
||||
xCAT::zvmUtils->printSyslog( "(Error) In punch2Reader(), SSH communication with $hcp failed for command: vmcp purge reader $spoolId" );
|
||||
$subResp = $subResp. "\nFailed to communicate with the zHCP system to purge reader file $spoolId: $hcp";
|
||||
} elsif ( $rc != 0 ) {
|
||||
# Any failure is bad and unrecoverable.
|
||||
@@ -1194,7 +1206,7 @@ sub getNetworkLayer {
|
||||
Arguments : User (root or non-root)
|
||||
zHCP
|
||||
Name of network
|
||||
Returns : Network type (VSWITCH/HIPERS/QDIO)
|
||||
Returns : Network type (VSWITCH/HIPERS/QDIO) or string containing (Error)...
|
||||
Example : my $netType = xCAT::zvmCPUtils->getNetworkType($hcp, $netName);
|
||||
|
||||
=cut
|
||||
@@ -1209,7 +1221,15 @@ sub getNetworkType {
|
||||
}
|
||||
|
||||
# Get network details
|
||||
my $out = `ssh -o ConnectTimeout=5 $user\@$hcp "$sudo /sbin/vmcp q lan $netName" | grep "Type"`;
|
||||
my $outmsg;
|
||||
my $rc;
|
||||
my $out = `ssh -o ConnectTimeout=5 $user\@$hcp "$sudo /sbin/vmcp q lan $netName"`;
|
||||
($rc, $outmsg) = xCAT::zvmUtils->checkSSH_Rc( $?, "ssh -o ConnectTimeout=5 $user\@$hcp \"$sudo /sbin/vmcp q lan $netName\"", $hcp, "getNetworkType", $out );
|
||||
if ($rc != 0) {
|
||||
return $outmsg;
|
||||
}
|
||||
|
||||
$out = `echo "$out" | egrep -a 'Type'`;
|
||||
|
||||
# Go through each line and determine network type
|
||||
my @lines = split( '\n', $out );
|
||||
|
||||
+349
-132
File diff suppressed because it is too large
Load Diff
+557
-550
File diff suppressed because it is too large
Load Diff
@@ -4,43 +4,43 @@
|
||||
function loadFilesPage() {
|
||||
var tabId = 'filesTab';
|
||||
$('#' + tabId).empty();
|
||||
|
||||
|
||||
// Set padding for page
|
||||
$('#' + tabId).css('padding', '10px 30px');
|
||||
|
||||
|
||||
// Create info bar
|
||||
var info = $('#' + tabId).find('.ui-state-highlight');
|
||||
// If there is no info bar
|
||||
if (!info.length) {
|
||||
var infoBar = createInfoBar('Below is a listing of the xCAT repository. ' +
|
||||
'Upload any file or package into the repository using the Upload button. ' +
|
||||
'Go into any subdirectories by specifying the directory path and clicking on Go.');
|
||||
|
||||
'Upload any file or package into the repository using the Upload button. ' +
|
||||
'Go into any subdirectories by specifying the directory path and clicking on Go.');
|
||||
|
||||
var directoryFS = $('<fieldset></fieldset>');
|
||||
var dirLegend = $('<legend>Directory</legend>');
|
||||
directoryFS.append(dirLegend);
|
||||
|
||||
|
||||
// Division to hold directory actions
|
||||
var actions = $('<div></div>');
|
||||
directoryFS.append(actions);
|
||||
|
||||
|
||||
// Create button to create a directory
|
||||
var folderBtn = createButton('New folder');
|
||||
folderBtn.click(function() {
|
||||
var deleteFolderBtn = $('<span class="ui-icon ui-icon-close" style="margin-left:10px; margin-right:10px;"></span>');
|
||||
var createFolderBtn = createButton('Create');
|
||||
|
||||
|
||||
// Create a new directory
|
||||
var newFolder = $('<li><span class="ui-icon ui-icon-folder-collapsed" style="margin-right: 10px;"></span><input type="text" name="new_folder"/></li>');
|
||||
newFolder.prepend(deleteFolderBtn);
|
||||
newFolder.append(createFolderBtn);
|
||||
$('#repo_content ul').append(newFolder);
|
||||
|
||||
|
||||
// Delete new folder on-click
|
||||
deleteFolderBtn.click(function() {
|
||||
$(this).parents('li').remove();
|
||||
});
|
||||
|
||||
|
||||
// Create folder on-click
|
||||
createFolderBtn.click(function() {
|
||||
var directory = $('#' + tabId + ' input[name="repo_directory"]');
|
||||
@@ -55,26 +55,27 @@ function loadFilesPage() {
|
||||
args : 'createfolder;' + directory.val() + '/' + newFolderPath,
|
||||
msg : ''
|
||||
},
|
||||
|
||||
|
||||
success:function(data) {
|
||||
data = decodeRsp(data);
|
||||
openDialog('info', data.rsp[0]);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$(this).parents('li').remove();
|
||||
} else {
|
||||
openDialog('warn', 'You must specify the folder name');
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// Create button to upload files
|
||||
var uploadBtn = createButton('Upload');
|
||||
uploadBtn.click(function() {
|
||||
var directory = $('#' + tabId + ' input[name="repo_directory"]');
|
||||
openUploadDialog(directory.val());
|
||||
});
|
||||
|
||||
|
||||
// Create button to go into a directory path
|
||||
var dirPath = $('<input type="text" name="repo_directory" style="width:400px;"/>');
|
||||
var goBtn = createButton('Go');
|
||||
@@ -83,18 +84,18 @@ function loadFilesPage() {
|
||||
loadPath(directory.val());
|
||||
});
|
||||
goBtn.attr('id', 'go_to_path');
|
||||
|
||||
|
||||
var space = $('<div id="repo_space"></div>');
|
||||
var content = $('<div id="repo_content" class="form"></div>');
|
||||
var content = $('<div id="repo_content" class="form"></div>');
|
||||
actions.append(folderBtn, uploadBtn, dirPath, goBtn);
|
||||
directoryFS.append(space, content);
|
||||
|
||||
|
||||
$('#' + tabId).append(infoBar, directoryFS);
|
||||
}
|
||||
|
||||
// Retrieve repository space
|
||||
|
||||
// Retrieve repository space
|
||||
getRepositorySpace();
|
||||
|
||||
|
||||
// Retrieve files from /install
|
||||
loadPath('/install');
|
||||
}
|
||||
@@ -115,8 +116,9 @@ function getRepositorySpace() {
|
||||
msg : ''
|
||||
},
|
||||
success: function(data) {
|
||||
data = decodeRsp(data);
|
||||
$('#repo_space').children().remove();
|
||||
|
||||
|
||||
// Data returned is: size, used, available, used %, mount
|
||||
// Data could be in a different format in CMO, where it puts the directory on the line
|
||||
// "rsp":["\/data\/xcat\/install 28G 6.0G 20G 24% \/install"],"msg":null}
|
||||
@@ -134,7 +136,7 @@ function getRepositorySpace() {
|
||||
|
||||
/**
|
||||
* Open a dialog to upload files into the repository
|
||||
*
|
||||
*
|
||||
* @param destDirectory The destination directory
|
||||
*/
|
||||
function openUploadDialog(destDirectory) {
|
||||
@@ -142,15 +144,15 @@ function openUploadDialog(destDirectory) {
|
||||
var info = createInfoBar('Select a file to upload onto ' + destDirectory + '.');
|
||||
var dialog = $('<div id="upload_file_dg"></div>');
|
||||
dialog.append(info);
|
||||
|
||||
|
||||
// Upload file
|
||||
var upload = $('<form id="upload_file" enctype="multipart/form-data"></form>');
|
||||
var label = $('<label style="margin-right: 10px;">Remote file:</label>');
|
||||
var file = $('<input type="file" name="file" id="file"/>');
|
||||
var subBtn = createButton('Upload');
|
||||
var subBtn = createButton('Upload');
|
||||
upload.append(label, file, subBtn);
|
||||
dialog.append(upload);
|
||||
|
||||
|
||||
upload.submit(function() {
|
||||
// Create status bar, hide on load
|
||||
var statBarId = 'uploadStatusBar';
|
||||
@@ -158,8 +160,8 @@ function openUploadDialog(destDirectory) {
|
||||
var loader = createLoader('');
|
||||
statBar.find('div').append('Do not close this dialog while the file is being uploaded ');
|
||||
statBar.find('div').append(loader);
|
||||
statBar.prependTo($('#upload_file_dg'));
|
||||
|
||||
statBar.prependTo($('#upload_file_dg'));
|
||||
|
||||
var data = new FormData($('#upload_file')[0]);
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
@@ -168,8 +170,8 @@ function openUploadDialog(destDirectory) {
|
||||
success: function(data) {
|
||||
$('#uploadStatusBar').find('img').hide();
|
||||
$('#uploadStatusBar').find('div').empty();
|
||||
$('#uploadStatusBar').find('div').append(data);
|
||||
|
||||
$('#uploadStatusBar').find('div').append(data);
|
||||
|
||||
// Refresh directory contents
|
||||
$('#go_to_path').click();
|
||||
getRepositorySpace();
|
||||
@@ -178,11 +180,11 @@ function openUploadDialog(destDirectory) {
|
||||
contentType: false,
|
||||
processData: false
|
||||
});
|
||||
|
||||
|
||||
return false;
|
||||
});
|
||||
|
||||
// Create dialog
|
||||
|
||||
// Create dialog
|
||||
dialog.dialog({
|
||||
modal: true,
|
||||
title: 'Upload',
|
||||
@@ -193,7 +195,7 @@ function openUploadDialog(destDirectory) {
|
||||
|
||||
/**
|
||||
* Load the directory path structure
|
||||
*
|
||||
*
|
||||
* @path The directory path
|
||||
*/
|
||||
function loadPath(path) {
|
||||
@@ -202,17 +204,17 @@ function loadPath(path) {
|
||||
openDialog('warn', 'You are not authorized to browse outside the repository');
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var tabId = 'filesTab';
|
||||
var directory = $('#' + tabId + ' input[name="repo_directory"]');
|
||||
directory.val(path);
|
||||
|
||||
|
||||
// Un-ordered list containing directories and files
|
||||
var contentId = 'repo_content';
|
||||
$('#' + contentId).empty();
|
||||
var itemsList = $('<ul></ul>');
|
||||
$('#' + contentId).append(itemsList);
|
||||
|
||||
|
||||
// Back button to go up a directory
|
||||
var item = $('<li><span class="ui-icon ui-icon-folder-collapsed" style="margin-right: 10px;"></span>..</li>');
|
||||
itemsList.append(item);
|
||||
@@ -221,7 +223,7 @@ function loadPath(path) {
|
||||
path = path.substring(0, path.lastIndexOf('/'));
|
||||
loadPath(path);
|
||||
});
|
||||
|
||||
|
||||
$.ajax({
|
||||
type: 'POST',
|
||||
url : 'lib/getpath.php',
|
||||
@@ -238,21 +240,21 @@ function loadPath(path) {
|
||||
$.each(files, function(index, file) {
|
||||
if (!file.path || file.path.indexOf("undefined"))
|
||||
file.path = "";
|
||||
|
||||
|
||||
var fullPath = file.path + "/" + file.name;
|
||||
|
||||
|
||||
// Create a list showing the directories and files
|
||||
var item;
|
||||
if (file.isFolder) {
|
||||
var deleteFolderBtn = $('<span class="ui-icon ui-icon-close" style="margin-left:10px; margin-right:10px;"></span>');
|
||||
|
||||
|
||||
item = $('<li><span class="ui-icon ui-icon-folder-collapsed" style="margin-right: 10px;"></span>' + file.name + '</li>');
|
||||
item.prepend(deleteFolderBtn);
|
||||
item.prepend(deleteFolderBtn);
|
||||
itemsList.append(item);
|
||||
item.dblclick(function() {
|
||||
loadPath(directory.val() + fullPath);
|
||||
});
|
||||
|
||||
|
||||
// Delete file on click
|
||||
deleteFolderBtn.click(function() {
|
||||
deleteFile($(this).parents('li'), directory.val() + fullPath);
|
||||
@@ -260,25 +262,25 @@ function loadPath(path) {
|
||||
} else {
|
||||
var icon = $('<span class="ui-icon ui-icon-document" style="margin-right: 10px;"></span>');
|
||||
var deleteFileBtn = $('<span class="ui-icon ui-icon-close" style="margin-left:10px; margin-right:10px;"></span>');
|
||||
|
||||
|
||||
item = $('<li><a href="' + directory.val() + fullPath + '">' + file.name + '</a></li>');
|
||||
item.append(deleteFileBtn, icon);
|
||||
|
||||
|
||||
// Delete file on click
|
||||
deleteFileBtn.click(function() {
|
||||
deleteFile($(this).parents('li'), directory.val() + fullPath);
|
||||
});
|
||||
|
||||
|
||||
itemsList.append(item);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Prompt user to confirm deletion of file
|
||||
*
|
||||
* Prompt user to confirm deletion of file
|
||||
*
|
||||
* @param container The element container
|
||||
* @param file The file name to delete
|
||||
*/
|
||||
@@ -296,14 +298,14 @@ function deleteFile(container, file) {
|
||||
"Ok": function() {
|
||||
var loader = createLoader('').css({'margin': '5px'});
|
||||
$(this).append(loader);
|
||||
|
||||
|
||||
// Change dialog buttons
|
||||
$(this).dialog('option', 'buttons', {
|
||||
'Close':function() {
|
||||
$(this).dialog('destroy').remove();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
$.ajax({
|
||||
url : 'lib/cmd.php',
|
||||
dataType : 'json',
|
||||
@@ -315,13 +317,14 @@ function deleteFile(container, file) {
|
||||
msg : ''
|
||||
},
|
||||
success: function(data) {
|
||||
data = decodeRsp(data);
|
||||
$('#confirm_delete').children().remove();
|
||||
var info = createInfoBar(data.rsp[0]);
|
||||
$('#confirm_delete').append(info);
|
||||
getRepositorySpace();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// Delete folder from the list
|
||||
container.remove();
|
||||
},
|
||||
|
||||
+1313
-1279
File diff suppressed because it is too large
Load Diff
+321
-309
@@ -1,310 +1,322 @@
|
||||
/**
|
||||
* Load update page
|
||||
*/
|
||||
function loadUpdatePage() {
|
||||
var repositoryDiv = $('<div id="repository"></div>');
|
||||
var rpmDiv = $('<div id="rpm"></div>');
|
||||
var statusDiv = createStatusBar("update");
|
||||
statusDiv.hide();
|
||||
|
||||
$('#updateTab').append(statusDiv);
|
||||
$('#updateTab').append(repositoryDiv);
|
||||
$('#updateTab').append(rpmDiv);
|
||||
|
||||
var infoBar = createInfoBar('Select the repository to use and the RPMs to update, then click Update.');
|
||||
repositoryDiv.append(infoBar);
|
||||
|
||||
repositoryDiv.append("<fieldset><legend>Repository</legend></fieldset>");
|
||||
$.ajax( {
|
||||
url : 'lib/systemcmd.php',
|
||||
dataType : 'json',
|
||||
data : {
|
||||
cmd : 'ostype'
|
||||
},
|
||||
|
||||
success : showRepository
|
||||
});
|
||||
|
||||
rpmDiv.append("<fieldset></fieldset>");
|
||||
$.ajax( {
|
||||
url : 'lib/systemcmd.php',
|
||||
dataType : 'json',
|
||||
data : {
|
||||
cmd : 'rpm -q xCAT-client perl-xCAT xCAT-server xCAT xCAT-rmc xCAT-UI'
|
||||
},
|
||||
|
||||
success : showRpmInfo
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the RPM repository (it can use the user's last choice and input)
|
||||
*
|
||||
* @param data Data returned from HTTP request
|
||||
*/
|
||||
function showRepository(data) {
|
||||
var develRepository = "";
|
||||
var stableRepository = "";
|
||||
var show = "";
|
||||
|
||||
// Get the corresponding repository by OS Type
|
||||
if (data.rsp == "aix") {
|
||||
// No repository exists for AIX on Sourceforge!
|
||||
develRepository = "http://xcat.sourceforge.net/aix/devel/xcat-core/";
|
||||
stableRepository = "http://xcat.sourceforge.net/aix/xcat-core/";
|
||||
} else {
|
||||
develRepository = "http://sourceforge.net/projects/xcat/files/yum/devel/xcat-core/";
|
||||
stableRepository = "http://sourceforge.net/projects/xcat/files/yum/stable/xcat-core/";
|
||||
}
|
||||
|
||||
var repoList = $('<ol></ol>');
|
||||
|
||||
// Display the Devel Repository, remember user's last selection
|
||||
show = show + "<li><input type='radio' ";
|
||||
if ($.cookie('xcat_repository') == 1) {
|
||||
show = show + "checked='true'";
|
||||
}
|
||||
show = show + "name='reporadio' value='" + develRepository + "'>";
|
||||
show = show + "<strong>Development</strong>: " + develRepository + "</li>";
|
||||
repoList.append(show);
|
||||
|
||||
// Display the Stable Repository, remember user's last selection
|
||||
show = "<li><input type='radio' ";
|
||||
if ($.cookie('xcat_repository') == 2) {
|
||||
show = show + "checked='true'";
|
||||
}
|
||||
show = show + "name='reporadio' value='" + stableRepository + "' checked='true'>";
|
||||
show = show + "<strong>Stable</strong>: " + stableRepository + "</li>";
|
||||
repoList.append(show);
|
||||
|
||||
// Display the Input Repository, remember user's last selection
|
||||
if (($.cookie('xcat_repository')) && ($.cookie('xcat_repository') != 1)
|
||||
&& ($.cookie('xcat_repository') != 2)) {
|
||||
show = "<li><input type='radio' checked='true' name='reporadio' value=''>Other: ";
|
||||
show += "<input style='width: 500px' id='repositoryaddr' value='"
|
||||
+ $.cookie('xcat_repository') + "'</li>";
|
||||
} else {
|
||||
show = "<li><input type='radio' name='reporadio' value=''>Other: ";
|
||||
show += "<input style='width: 500px' id='repositoryaddr' value=''</li>";
|
||||
}
|
||||
repoList.append(show);
|
||||
|
||||
$('#repository fieldset').append(repoList);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show all xCAT RPMs
|
||||
*
|
||||
* @param data Data returned from HTTP request
|
||||
*/
|
||||
function showRpmInfo(data) {
|
||||
var rpms = null;
|
||||
var show = "";
|
||||
var rpmNames = new Array("xCAT-client", "perl-xCAT", "xCAT-server", "xCAT", "xCAT-rmc",
|
||||
"xCAT-UI");
|
||||
var temp = 0;
|
||||
if (null == data.rsp) {
|
||||
$('#rpm fieldset').append("Error getting RPMs!");
|
||||
return;
|
||||
}
|
||||
|
||||
rpms = data.rsp.split(/\n/);
|
||||
|
||||
// No rpm installed, return
|
||||
if (1 > rpms.length) {
|
||||
$('#rpm fieldset').append("No RPMs installed!");
|
||||
return;
|
||||
}
|
||||
|
||||
// Clear the old data
|
||||
$('#rpm fieldset').children().remove();
|
||||
$('#rpm fieldset').append("<legend>xCAT RPMs</legend>");
|
||||
show = "<table id=rpmtable >";
|
||||
show += "<thead class='ui-widget-header'><tr>";
|
||||
show += "<th><input type='checkbox' id='selectall' value='' onclick='updateSelectAll()'></th>";
|
||||
show += "<th><b>Package Name</b></th><th><b>Version</b></th>";
|
||||
show += "</tr></thead>";
|
||||
for (temp = 0; temp < rpms.length; temp++) {
|
||||
// Empty line continue
|
||||
if (!rpms[temp]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// The RPM is not installed, continue
|
||||
if (rpms[temp].indexOf("not") != -1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Show the version in table
|
||||
show += "<tr>";
|
||||
show += "<td><input type='checkbox' value='" + rpmNames[temp] + "'></td>";
|
||||
show += "<td>" + rpmNames[temp] + "</td><td>"
|
||||
+ rpms[temp].substr(rpmNames[temp].length + 1) + "</td>";
|
||||
show += "</tr>";
|
||||
}
|
||||
show += "</table>";
|
||||
show += "<br\>";
|
||||
$('#rpm fieldset').append(show);
|
||||
|
||||
// Add the update button
|
||||
var updateButton = createButton('Update');
|
||||
$('#rpm fieldset').append(updateButton);
|
||||
updateButton.bind('click', function() {
|
||||
updateRpm();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Select all checkboxes
|
||||
*/
|
||||
function updateSelectAll() {
|
||||
var check_status = $('#selectall').attr('checked');
|
||||
$('input:checkbox').attr('checked', check_status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update selected xCAT RPMs
|
||||
*/
|
||||
function updateRpm() {
|
||||
// Remove any warning messages
|
||||
$('#updateTab').find('.ui-state-error').remove();
|
||||
|
||||
var rpmPath = $('input[type=radio]:checked').val();
|
||||
var rpmPathType = "0";
|
||||
var rpms = "";
|
||||
var temp = "";
|
||||
|
||||
if (undefined == rpmPath) {
|
||||
rpmPath = "";
|
||||
}
|
||||
|
||||
// Select other and we should use the value in the input
|
||||
if ("" == rpmPath) {
|
||||
// Store repo in a cookie
|
||||
rpmPath = $('#repositoryaddr').val();
|
||||
rpmPathType = rpmPath;
|
||||
} else {
|
||||
if (-1 == rpmPath.toLowerCase().indexOf("devel")) {
|
||||
rpmPathType = "2";
|
||||
} else {
|
||||
rpmPathType = "1";
|
||||
}
|
||||
}
|
||||
|
||||
$("input[type=checkbox]:checked").each(function() {
|
||||
temp = $(this).val();
|
||||
if ("" == temp) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var pattern = new RegExp("^" + temp + ",|," + temp + ",");
|
||||
if (pattern.test(rpms)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
rpms = rpms + temp + ",";
|
||||
});
|
||||
|
||||
if (0 < rpms.length) {
|
||||
rpms = rpms.slice(0, -1);
|
||||
}
|
||||
|
||||
// Check RPM and repository
|
||||
var errMsg = '';
|
||||
if (!rpms) {
|
||||
errMsg = "Please select an RPM!<br>";
|
||||
}
|
||||
|
||||
if (!rpmPath) {
|
||||
errMsg += "Please select or specify a repository!";
|
||||
}
|
||||
|
||||
if (!rpms || !rpmPath) {
|
||||
// Show warning message
|
||||
var warn = createWarnBar(errMsg);
|
||||
warn.prependTo($('#updateTab'));
|
||||
return;
|
||||
}
|
||||
|
||||
// Remember users' choice and input
|
||||
$.cookie('xcat_repository', rpmPathType, {
|
||||
path : '/xcat',
|
||||
secure : true,
|
||||
expires : 10
|
||||
});
|
||||
|
||||
$('#update').show();
|
||||
$('#update div').empty();
|
||||
$('#update div').append("<p>Updating <b>" + rpms + "</b> from <b>" + rpmPath + "</b></p>");
|
||||
$('#update div').append("<img id='loadingpic' src='images/loader.gif'>");
|
||||
$('#rpm button').attr('disabled', 'true');
|
||||
|
||||
// Send the update command to server
|
||||
$.ajax( {
|
||||
url : 'lib/cmd.php',
|
||||
dataType : 'json',
|
||||
data : {
|
||||
cmd : 'webrun',
|
||||
tgt : '',
|
||||
args : 'update;' + rpms + ";" + rpmPath,
|
||||
msg : ''
|
||||
},
|
||||
|
||||
success : showUpdateResult
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the results of the RPM update
|
||||
*
|
||||
* @param data Data returned from HTTP request
|
||||
*/
|
||||
function showUpdateResult(data) {
|
||||
var temp = 0;
|
||||
$('#loadingpic').remove();
|
||||
|
||||
var resArray = data.rsp[0].split(/\n/);
|
||||
if (0 < resArray.length) {
|
||||
// Show last lines
|
||||
if (('' == resArray[resArray.length - 1]) && (resArray.length > 1)) {
|
||||
$('#update div').append('<pre>' + resArray[resArray.length - 2] + '</pre>');
|
||||
} else {
|
||||
$('#update div').append('<pre>' + resArray[resArray.length - 1] + '</pre>');
|
||||
}
|
||||
|
||||
// Create link to show details
|
||||
$('#update div').append('<br/><a>Show details</a>');
|
||||
$('#update div a').css( {
|
||||
'color' : '#0000FF',
|
||||
'cursor' : 'pointer'
|
||||
}).bind('click', function() {
|
||||
// Toggle details and change text
|
||||
$('#resDetail').toggle();
|
||||
if ($('#update div a').text() == 'Show details') {
|
||||
$('#update div a').text('Hide details');
|
||||
} else {
|
||||
$('#update div a').text('Show details');
|
||||
}
|
||||
});
|
||||
|
||||
var resDetail = $('<pre id="resDetail"></pre>');
|
||||
resDetail.hide();
|
||||
$('#update div').append(resDetail);
|
||||
for (temp = 0; temp < resArray.length; temp++) {
|
||||
resDetail.append(resArray[temp] + '<br/>');
|
||||
}
|
||||
}
|
||||
|
||||
// Update the rpm info
|
||||
$.ajax( {
|
||||
url : 'lib/systemcmd.php',
|
||||
dataType : 'json',
|
||||
data : {
|
||||
cmd : 'rpm -q xCAT-client perl-xCAT xCAT-server xCAT xCAT-rmc xCAT-UI'
|
||||
},
|
||||
|
||||
success : showRpmInfo
|
||||
});
|
||||
|
||||
$('#rpm button').attr('disabled', '');
|
||||
/**
|
||||
* Load update page
|
||||
*/
|
||||
function loadUpdatePage() {
|
||||
var repositoryDiv = $('<div id="repository"></div>');
|
||||
var rpmDiv = $('<div id="rpm"></div>');
|
||||
var statusDiv = createStatusBar("update");
|
||||
statusDiv.hide();
|
||||
|
||||
$('#updateTab').append(statusDiv);
|
||||
$('#updateTab').append(repositoryDiv);
|
||||
$('#updateTab').append(rpmDiv);
|
||||
|
||||
var infoBar = createInfoBar('Select the repository to use and the RPMs to update, then click Update.');
|
||||
repositoryDiv.append(infoBar);
|
||||
|
||||
repositoryDiv.append("<fieldset><legend>Repository</legend></fieldset>");
|
||||
$.ajax( {
|
||||
url : 'lib/systemcmd.php',
|
||||
dataType : 'json',
|
||||
data : {
|
||||
cmd : 'ostype'
|
||||
},
|
||||
|
||||
success : function(data) {
|
||||
data = decodeRsp(data);
|
||||
showRepository(data);
|
||||
}
|
||||
});
|
||||
|
||||
rpmDiv.append("<fieldset></fieldset>");
|
||||
$.ajax( {
|
||||
url : 'lib/systemcmd.php',
|
||||
dataType : 'json',
|
||||
data : {
|
||||
cmd : 'rpm -q xCAT-client perl-xCAT xCAT-server xCAT xCAT-rmc xCAT-UI'
|
||||
},
|
||||
|
||||
success : function(data) {
|
||||
data = decodeRsp(data);
|
||||
showRpmInfo(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the RPM repository (it can use the user's last choice and input)
|
||||
*
|
||||
* @param data Data returned from HTTP request
|
||||
*/
|
||||
function showRepository(data) {
|
||||
var develRepository = "";
|
||||
var stableRepository = "";
|
||||
var show = "";
|
||||
|
||||
// Get the corresponding repository by OS Type
|
||||
if (data.rsp == "aix") {
|
||||
// No repository exists for AIX on Sourceforge!
|
||||
develRepository = "http://xcat.sourceforge.net/aix/devel/xcat-core/";
|
||||
stableRepository = "http://xcat.sourceforge.net/aix/xcat-core/";
|
||||
} else {
|
||||
develRepository = "http://sourceforge.net/projects/xcat/files/yum/devel/xcat-core/";
|
||||
stableRepository = "http://sourceforge.net/projects/xcat/files/yum/stable/xcat-core/";
|
||||
}
|
||||
|
||||
var repoList = $('<ol></ol>');
|
||||
|
||||
// Display the Devel Repository, remember user's last selection
|
||||
show = show + "<li><input type='radio' ";
|
||||
if ($.cookie('xcat_repository') == 1) {
|
||||
show = show + "checked='true'";
|
||||
}
|
||||
show = show + "name='reporadio' value='" + develRepository + "'>";
|
||||
show = show + "<strong>Development</strong>: " + develRepository + "</li>";
|
||||
repoList.append(show);
|
||||
|
||||
// Display the Stable Repository, remember user's last selection
|
||||
show = "<li><input type='radio' ";
|
||||
if ($.cookie('xcat_repository') == 2) {
|
||||
show = show + "checked='true'";
|
||||
}
|
||||
show = show + "name='reporadio' value='" + stableRepository + "' checked='true'>";
|
||||
show = show + "<strong>Stable</strong>: " + stableRepository + "</li>";
|
||||
repoList.append(show);
|
||||
|
||||
// Display the Input Repository, remember user's last selection
|
||||
if (($.cookie('xcat_repository')) && ($.cookie('xcat_repository') != 1)
|
||||
&& ($.cookie('xcat_repository') != 2)) {
|
||||
show = "<li><input type='radio' checked='true' name='reporadio' value=''>Other: ";
|
||||
show += "<input style='width: 500px' id='repositoryaddr' value='"
|
||||
+ $.cookie('xcat_repository') + "'</li>";
|
||||
} else {
|
||||
show = "<li><input type='radio' name='reporadio' value=''>Other: ";
|
||||
show += "<input style='width: 500px' id='repositoryaddr' value=''</li>";
|
||||
}
|
||||
repoList.append(show);
|
||||
|
||||
$('#repository fieldset').append(repoList);
|
||||
}
|
||||
|
||||
/**
|
||||
* Show all xCAT RPMs
|
||||
*
|
||||
* @param data Data returned from HTTP request
|
||||
*/
|
||||
function showRpmInfo(data) {
|
||||
var rpms = null;
|
||||
var show = "";
|
||||
var rpmNames = new Array("xCAT-client", "perl-xCAT", "xCAT-server", "xCAT", "xCAT-rmc",
|
||||
"xCAT-UI");
|
||||
var temp = 0;
|
||||
if (null == data.rsp) {
|
||||
$('#rpm fieldset').append("Error getting RPMs!");
|
||||
return;
|
||||
}
|
||||
|
||||
rpms = data.rsp.split(/\n/);
|
||||
|
||||
// No rpm installed, return
|
||||
if (1 > rpms.length) {
|
||||
$('#rpm fieldset').append("No RPMs installed!");
|
||||
return;
|
||||
}
|
||||
|
||||
// Clear the old data
|
||||
$('#rpm fieldset').children().remove();
|
||||
$('#rpm fieldset').append("<legend>xCAT RPMs</legend>");
|
||||
show = "<table id=rpmtable >";
|
||||
show += "<thead class='ui-widget-header'><tr>";
|
||||
show += "<th><input type='checkbox' id='selectall' value='' onclick='updateSelectAll()'></th>";
|
||||
show += "<th><b>Package Name</b></th><th><b>Version</b></th>";
|
||||
show += "</tr></thead>";
|
||||
for (temp = 0; temp < rpms.length; temp++) {
|
||||
// Empty line continue
|
||||
if (!rpms[temp]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// The RPM is not installed, continue
|
||||
if (rpms[temp].indexOf("not") != -1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Show the version in table
|
||||
show += "<tr>";
|
||||
show += "<td><input type='checkbox' value='" + rpmNames[temp] + "'></td>";
|
||||
show += "<td>" + rpmNames[temp] + "</td><td>"
|
||||
+ rpms[temp].substr(rpmNames[temp].length + 1) + "</td>";
|
||||
show += "</tr>";
|
||||
}
|
||||
show += "</table>";
|
||||
show += "<br\>";
|
||||
$('#rpm fieldset').append(show);
|
||||
|
||||
// Add the update button
|
||||
var updateButton = createButton('Update');
|
||||
$('#rpm fieldset').append(updateButton);
|
||||
updateButton.bind('click', function() {
|
||||
updateRpm();
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Select all checkboxes
|
||||
*/
|
||||
function updateSelectAll() {
|
||||
var check_status = $('#selectall').attr('checked');
|
||||
$('input:checkbox').attr('checked', check_status);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update selected xCAT RPMs
|
||||
*/
|
||||
function updateRpm() {
|
||||
// Remove any warning messages
|
||||
$('#updateTab').find('.ui-state-error').remove();
|
||||
|
||||
var rpmPath = $('input[type=radio]:checked').val();
|
||||
var rpmPathType = "0";
|
||||
var rpms = "";
|
||||
var temp = "";
|
||||
|
||||
if (undefined == rpmPath) {
|
||||
rpmPath = "";
|
||||
}
|
||||
|
||||
// Select other and we should use the value in the input
|
||||
if ("" == rpmPath) {
|
||||
// Store repo in a cookie
|
||||
rpmPath = $('#repositoryaddr').val();
|
||||
rpmPathType = rpmPath;
|
||||
} else {
|
||||
if (-1 == rpmPath.toLowerCase().indexOf("devel")) {
|
||||
rpmPathType = "2";
|
||||
} else {
|
||||
rpmPathType = "1";
|
||||
}
|
||||
}
|
||||
|
||||
$("input[type=checkbox]:checked").each(function() {
|
||||
temp = $(this).val();
|
||||
if ("" == temp) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var pattern = new RegExp("^" + temp + ",|," + temp + ",");
|
||||
if (pattern.test(rpms)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
rpms = rpms + temp + ",";
|
||||
});
|
||||
|
||||
if (0 < rpms.length) {
|
||||
rpms = rpms.slice(0, -1);
|
||||
}
|
||||
|
||||
// Check RPM and repository
|
||||
var errMsg = '';
|
||||
if (!rpms) {
|
||||
errMsg = "Please select an RPM!<br>";
|
||||
}
|
||||
|
||||
if (!rpmPath) {
|
||||
errMsg += "Please select or specify a repository!";
|
||||
}
|
||||
|
||||
if (!rpms || !rpmPath) {
|
||||
// Show warning message
|
||||
var warn = createWarnBar(errMsg);
|
||||
warn.prependTo($('#updateTab'));
|
||||
return;
|
||||
}
|
||||
|
||||
// Remember users' choice and input
|
||||
$.cookie('xcat_repository', rpmPathType, {
|
||||
path : '/xcat',
|
||||
secure : true,
|
||||
expires : 10
|
||||
});
|
||||
|
||||
$('#update').show();
|
||||
$('#update div').empty();
|
||||
$('#update div').append("<p>Updating <b>" + rpms + "</b> from <b>" + rpmPath + "</b></p>");
|
||||
$('#update div').append("<img id='loadingpic' src='images/loader.gif'>");
|
||||
$('#rpm button').attr('disabled', 'true');
|
||||
|
||||
// Send the update command to server
|
||||
$.ajax( {
|
||||
url : 'lib/cmd.php',
|
||||
dataType : 'json',
|
||||
data : {
|
||||
cmd : 'webrun',
|
||||
tgt : '',
|
||||
args : 'update;' + rpms + ";" + rpmPath,
|
||||
msg : ''
|
||||
},
|
||||
|
||||
success : function(data) {
|
||||
data = decodeRsp(data);
|
||||
showUpdateResult(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Show the results of the RPM update
|
||||
*
|
||||
* @param data Data returned from HTTP request
|
||||
*/
|
||||
function showUpdateResult(data) {
|
||||
var temp = 0;
|
||||
$('#loadingpic').remove();
|
||||
|
||||
var resArray = data.rsp[0].split(/\n/);
|
||||
if (0 < resArray.length) {
|
||||
// Show last lines
|
||||
if (('' == resArray[resArray.length - 1]) && (resArray.length > 1)) {
|
||||
$('#update div').append('<pre>' + resArray[resArray.length - 2] + '</pre>');
|
||||
} else {
|
||||
$('#update div').append('<pre>' + resArray[resArray.length - 1] + '</pre>');
|
||||
}
|
||||
|
||||
// Create link to show details
|
||||
$('#update div').append('<br/><a>Show details</a>');
|
||||
$('#update div a').css( {
|
||||
'color' : '#0000FF',
|
||||
'cursor' : 'pointer'
|
||||
}).bind('click', function() {
|
||||
// Toggle details and change text
|
||||
$('#resDetail').toggle();
|
||||
if ($('#update div a').text() == 'Show details') {
|
||||
$('#update div a').text('Hide details');
|
||||
} else {
|
||||
$('#update div a').text('Show details');
|
||||
}
|
||||
});
|
||||
|
||||
var resDetail = $('<pre id="resDetail"></pre>');
|
||||
resDetail.hide();
|
||||
$('#update div').append(resDetail);
|
||||
for (temp = 0; temp < resArray.length; temp++) {
|
||||
resDetail.append(resArray[temp] + '<br/>');
|
||||
}
|
||||
}
|
||||
|
||||
// Update the rpm info
|
||||
$.ajax( {
|
||||
url : 'lib/systemcmd.php',
|
||||
dataType : 'json',
|
||||
data : {
|
||||
cmd : 'rpm -q xCAT-client perl-xCAT xCAT-server xCAT xCAT-rmc xCAT-UI'
|
||||
},
|
||||
|
||||
success : function(data) {
|
||||
data = decodeRsp(data);
|
||||
showRpmInfo(data);
|
||||
}
|
||||
});
|
||||
|
||||
$('#rpm button').attr('disabled', '');
|
||||
}
|
||||
+548
-536
File diff suppressed because it is too large
Load Diff
+798
-794
File diff suppressed because it is too large
Load Diff
+2815
-2785
File diff suppressed because it is too large
Load Diff
+8345
-8140
File diff suppressed because it is too large
Load Diff
+927
-924
File diff suppressed because it is too large
Load Diff
+1057
-1045
File diff suppressed because it is too large
Load Diff
+280
-275
@@ -1,276 +1,281 @@
|
||||
/**
|
||||
* Global variables
|
||||
*/
|
||||
var monitorTabs; // Monitor tabs
|
||||
|
||||
/**
|
||||
* Set the monitor tab
|
||||
*
|
||||
* @param o
|
||||
* Tab object
|
||||
* @return Nothing
|
||||
*/
|
||||
function setMonitorTab(o) {
|
||||
monitorTabs = o;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the monitor tab
|
||||
*
|
||||
* @return Tab object
|
||||
*/
|
||||
function getMonitorTab() {
|
||||
return monitorTabs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the monitor page
|
||||
*/
|
||||
function loadMonitorPage() {
|
||||
// If the page is already loaded
|
||||
if ($('#monitor_page').children().length) {
|
||||
// Do not reload the monitor page
|
||||
return;
|
||||
}
|
||||
|
||||
// Create monitor tab
|
||||
var tab = new Tab();
|
||||
setMonitorTab(tab);
|
||||
tab.init();
|
||||
$('#content').append(tab.object());
|
||||
|
||||
var monitorForm = $('<div class="form"></div>');
|
||||
monitorForm.append('Getting monitoring status ').append(createLoader());
|
||||
tab.add('monitorTab', 'Monitor', monitorForm, false);
|
||||
|
||||
// Get monitoring status of each tool
|
||||
$.ajax( {
|
||||
url : 'lib/cmd.php',
|
||||
dataType : 'json',
|
||||
data : {
|
||||
cmd : 'webrun',
|
||||
tgt : '',
|
||||
args : 'monls',
|
||||
msg : ''
|
||||
},
|
||||
|
||||
/**
|
||||
* Load monitoring status
|
||||
*
|
||||
* @param data Data returned from HTTP request
|
||||
*/
|
||||
success : function(data){
|
||||
// Initialize status for each tool
|
||||
var statusHash = new Object();
|
||||
statusHash['xcatmon'] = 'Off';
|
||||
statusHash['rmcmon'] = 'Off';
|
||||
statusHash['rmcevent'] = 'Off';
|
||||
statusHash['gangliamon'] = 'Off';
|
||||
if (data.rsp[0]) {
|
||||
var tempArray = data.rsp[0].split(';');
|
||||
var position = 0;
|
||||
var name = '';
|
||||
var status = '';
|
||||
for ( var i in tempArray) {
|
||||
position = tempArray[i].indexOf(':');
|
||||
if (position == -1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
name = tempArray[i].substr(0, position);
|
||||
status = tempArray[i].substr(position + 1);
|
||||
statusHash[name] = status;
|
||||
}
|
||||
}
|
||||
|
||||
// Create a status buttonset for each monitoring tool
|
||||
var statusButtonHash = new Object();
|
||||
for ( var name in statusHash) {
|
||||
var statusButton = $('<div></div>').css({
|
||||
'width': '100px',
|
||||
'text-align': 'center'
|
||||
});
|
||||
statusButtonHash[name] = statusButton;
|
||||
|
||||
// Set button to correct status
|
||||
if (statusHash[name] == 'On') {
|
||||
statusButton.append($('<input type="radio" id="' + name + 'On" name="' + name + '" value="On" checked="checked"/><label for="' + name + 'On">On</label>'));
|
||||
statusButton.append($('<input type="radio" id="' + name + 'Off" name="' + name + '" value="Off"/><label for="' + name + 'Off">Off</label>'));
|
||||
} else {
|
||||
statusButton.append($('<input type="radio" id="' + name + 'On" name="' + name + '" value="On"/><label for="' + name + 'On">On</label>'));
|
||||
statusButton.append($('<input type="radio" id="' + name + 'Off" name="' + name + '" value="Off" checked="checked"/><label for="' + name + 'Off">Off</label>'));
|
||||
}
|
||||
|
||||
statusButton.find('label').css({
|
||||
'margin': '0px',
|
||||
'padding': '0px',
|
||||
'font-size': '10px',
|
||||
'width': 'auto'
|
||||
});
|
||||
statusButton.buttonset();
|
||||
|
||||
// Turn on or off monitoring tool when clicked
|
||||
statusButton.find('input["' + name + '"]:radio').change(toggleMonitor);
|
||||
}
|
||||
|
||||
var monTable = $('<table></table>');
|
||||
monTable.append($('<thead class="ui-widget-header"><tr><th><b>Tool</b></th><th><b>Status</b></th><th><b>Description</b></th></tr></thead>'));
|
||||
|
||||
var monTableBody = $('<tbody></tbody>');
|
||||
monTable.append(monTableBody);
|
||||
|
||||
var xcatMon = $('<tr></tr>');
|
||||
xcatMon.append($('<td><a href="#" name="xcatmon">xCAT</a></td>'));
|
||||
xcatMon.append($('<td></td>').append(statusButtonHash['xcatmon']));
|
||||
xcatMon.append($('<td>xCAT provides node status monitoring using fping on AIX and nmapon Linux. It also provides application status monitoring. The status and the appstatus columns of the nodelist table will be updated periodically with the latest status values for the nodes.</td>'));
|
||||
monTableBody.append(xcatMon);
|
||||
|
||||
var rmcMon = $('<tr></tr>');
|
||||
rmcMon.append($('<td><a href="#" name="rmcmon">RMC</a></td>'));
|
||||
rmcMon.append($('<td></td>').append(statusButtonHash['rmcmon']));
|
||||
rmcMon.append($('<td>Resource Monitoring and Control (RMC) is a generalized framework for managing, monitoring and manipulating resources, such as physical or logical system entities. RMC is utilized as a communication mechanism for reporting service events to the Hardware Management Console (HMC).</td>'));
|
||||
monTableBody.append(rmcMon);
|
||||
|
||||
var rmcEvent = $('<tr></tr>');
|
||||
rmcEvent.append($('<td><a href="#" name="rmcevent">RMC Event</a></td>'));
|
||||
rmcEvent.append($('<td></td>').append(statusButtonHash['rmcevent']));
|
||||
rmcEvent.append($('<td>Shows a list of events recorded by the RSCT Event Response resource manager in the audit log.</td>'));
|
||||
monTableBody.append(rmcEvent);
|
||||
|
||||
var gangliaMon = $('<tr></tr>');
|
||||
gangliaMon.append($('<td><a href="#" name="gangliamon">Ganglia</a></td>'));
|
||||
gangliaMon.append($('<td></td>').append(statusButtonHash['gangliamon']));
|
||||
gangliaMon.append($('<td>Ganglia is a scalable distributed monitoring system for high-performance computing systems such as clusters and Grids.</td>'));
|
||||
monTableBody.append(gangliaMon);
|
||||
|
||||
// Do not word wrap
|
||||
monTableBody.find('td:nth-child(1)').css('white-space', 'nowrap');
|
||||
monTableBody.find('td:nth-child(3)').css({
|
||||
'white-space': 'normal',
|
||||
'text-align': 'left'
|
||||
});
|
||||
|
||||
// Append info bar
|
||||
$('#monitorTab div').empty().append(createInfoBar('Select a monitoring tool to use'));
|
||||
$('#monitorTab .form').append(monTable);
|
||||
|
||||
// Open monitoring tool onclick
|
||||
$('#monitorTab .form a').bind('click', function() {
|
||||
loadMonitorTab($(this).attr('name'));
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Load monitoring tool in a new tab
|
||||
*
|
||||
* @param name Name of monitoring tool
|
||||
*/
|
||||
function loadMonitorTab(name) {
|
||||
// If the tab exist, then we only need to select it
|
||||
var tab = getMonitorTab();
|
||||
if ($("#" + name).length) {
|
||||
tab.select(name);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (name) {
|
||||
case 'xcatmon':
|
||||
tab.add(name, 'xCAT', '', true);
|
||||
loadXcatMon();
|
||||
break;
|
||||
case 'rmcmon':
|
||||
tab.add(name, 'RMC Monitor', '', true);
|
||||
loadRmcMon();
|
||||
break;
|
||||
case 'gangliamon':
|
||||
tab.add(name, 'Ganglia', '', true);
|
||||
loadGangliaMon();
|
||||
break;
|
||||
case 'rmcevent':
|
||||
tab.add(name, 'RMC Event', '', true);
|
||||
loadRmcEvent();
|
||||
break;
|
||||
}
|
||||
|
||||
tab.select(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load tab showing 'Under contruction'
|
||||
*
|
||||
* @param monitorName Name of monitoring tool
|
||||
* @param tab Tab area
|
||||
*/
|
||||
function loadUnfinish(monitorName, tab) {
|
||||
var unfinishPage = $('<div></div>');
|
||||
unfinishPage.append(createInfoBar('Not yet supported'));
|
||||
tab.add(monitorName, 'Unfinished', unfinishPage, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn on or off monitoring tool
|
||||
*
|
||||
* @return Nothing
|
||||
*/
|
||||
function toggleMonitor() {
|
||||
// Get the name of the monitoring tool
|
||||
var name = $(this).attr('name');
|
||||
// Get the status to toggle to, either on or off
|
||||
var status = $(this).val();
|
||||
|
||||
// Start or stop monitoring plugin
|
||||
var command = 'monstart';
|
||||
if (status == 'Off') {
|
||||
command = 'monstop' ;
|
||||
}
|
||||
|
||||
// Start or stop monitoring on xCAT
|
||||
$.ajax({
|
||||
url : 'lib/cmd.php',
|
||||
dataType : 'json',
|
||||
data : {
|
||||
cmd : command,
|
||||
tgt : '',
|
||||
args : name + '',
|
||||
msg : ''
|
||||
},
|
||||
success : function(data) {
|
||||
// Start or stop monitoring on remote nodes
|
||||
$.ajax({
|
||||
url : 'lib/cmd.php',
|
||||
dataType : 'json',
|
||||
data : {
|
||||
cmd : command,
|
||||
tgt : '',
|
||||
args : name + ';-r',
|
||||
msg : name + ' switched ' + status
|
||||
},
|
||||
success : updateMonStatus
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the monitoring status on Monitor tab
|
||||
*
|
||||
* @param data Data returned from HTTP request
|
||||
*/
|
||||
function updateMonStatus(data) {
|
||||
var rsp = data.rsp[data.rsp.length-1];
|
||||
var msg = data.msg;
|
||||
|
||||
// Create appropriate info or warning bar
|
||||
var bar = '';
|
||||
if (rsp.indexOf('started') > -1 || rsp.indexOf('stopped') > -1) {
|
||||
bar = createInfoBar(msg);
|
||||
} else {
|
||||
bar = createWarnBar('Failed to ' + msg + '. ' + rsp);
|
||||
}
|
||||
|
||||
// Prepend info or warning bar to tab
|
||||
bar.prependTo($('#monitorTab .form'));
|
||||
bar.delay(4000).slideUp();
|
||||
/**
|
||||
* Global variables
|
||||
*/
|
||||
var monitorTabs; // Monitor tabs
|
||||
|
||||
/**
|
||||
* Set the monitor tab
|
||||
*
|
||||
* @param o
|
||||
* Tab object
|
||||
* @return Nothing
|
||||
*/
|
||||
function setMonitorTab(o) {
|
||||
monitorTabs = o;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the monitor tab
|
||||
*
|
||||
* @return Tab object
|
||||
*/
|
||||
function getMonitorTab() {
|
||||
return monitorTabs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load the monitor page
|
||||
*/
|
||||
function loadMonitorPage() {
|
||||
// If the page is already loaded
|
||||
if ($('#monitor_page').children().length) {
|
||||
// Do not reload the monitor page
|
||||
return;
|
||||
}
|
||||
|
||||
// Create monitor tab
|
||||
var tab = new Tab();
|
||||
setMonitorTab(tab);
|
||||
tab.init();
|
||||
$('#content').append(tab.object());
|
||||
|
||||
var monitorForm = $('<div class="form"></div>');
|
||||
monitorForm.append('Getting monitoring status ').append(createLoader());
|
||||
tab.add('monitorTab', 'Monitor', monitorForm, false);
|
||||
|
||||
// Get monitoring status of each tool
|
||||
$.ajax( {
|
||||
url : 'lib/cmd.php',
|
||||
dataType : 'json',
|
||||
data : {
|
||||
cmd : 'webrun',
|
||||
tgt : '',
|
||||
args : 'monls',
|
||||
msg : ''
|
||||
},
|
||||
|
||||
/**
|
||||
* Load monitoring status
|
||||
*
|
||||
* @param data Data returned from HTTP request
|
||||
*/
|
||||
success : function(data){
|
||||
data = decodeRsp(data);
|
||||
// Initialize status for each tool
|
||||
var statusHash = new Object();
|
||||
statusHash['xcatmon'] = 'Off';
|
||||
statusHash['rmcmon'] = 'Off';
|
||||
statusHash['rmcevent'] = 'Off';
|
||||
statusHash['gangliamon'] = 'Off';
|
||||
if (data.rsp[0]) {
|
||||
var tempArray = data.rsp[0].split(';');
|
||||
var position = 0;
|
||||
var name = '';
|
||||
var status = '';
|
||||
for ( var i in tempArray) {
|
||||
position = tempArray[i].indexOf(':');
|
||||
if (position == -1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
name = tempArray[i].substr(0, position);
|
||||
status = tempArray[i].substr(position + 1);
|
||||
statusHash[name] = status;
|
||||
}
|
||||
}
|
||||
|
||||
// Create a status buttonset for each monitoring tool
|
||||
var statusButtonHash = new Object();
|
||||
for ( var name in statusHash) {
|
||||
var statusButton = $('<div></div>').css({
|
||||
'width': '100px',
|
||||
'text-align': 'center'
|
||||
});
|
||||
statusButtonHash[name] = statusButton;
|
||||
|
||||
// Set button to correct status
|
||||
if (statusHash[name] == 'On') {
|
||||
statusButton.append($('<input type="radio" id="' + name + 'On" name="' + name + '" value="On" checked="checked"/><label for="' + name + 'On">On</label>'));
|
||||
statusButton.append($('<input type="radio" id="' + name + 'Off" name="' + name + '" value="Off"/><label for="' + name + 'Off">Off</label>'));
|
||||
} else {
|
||||
statusButton.append($('<input type="radio" id="' + name + 'On" name="' + name + '" value="On"/><label for="' + name + 'On">On</label>'));
|
||||
statusButton.append($('<input type="radio" id="' + name + 'Off" name="' + name + '" value="Off" checked="checked"/><label for="' + name + 'Off">Off</label>'));
|
||||
}
|
||||
|
||||
statusButton.find('label').css({
|
||||
'margin': '0px',
|
||||
'padding': '0px',
|
||||
'font-size': '10px',
|
||||
'width': 'auto'
|
||||
});
|
||||
statusButton.buttonset();
|
||||
|
||||
// Turn on or off monitoring tool when clicked
|
||||
statusButton.find('input["' + name + '"]:radio').change(toggleMonitor);
|
||||
}
|
||||
|
||||
var monTable = $('<table></table>');
|
||||
monTable.append($('<thead class="ui-widget-header"><tr><th><b>Tool</b></th><th><b>Status</b></th><th><b>Description</b></th></tr></thead>'));
|
||||
|
||||
var monTableBody = $('<tbody></tbody>');
|
||||
monTable.append(monTableBody);
|
||||
|
||||
var xcatMon = $('<tr></tr>');
|
||||
xcatMon.append($('<td><a href="#" name="xcatmon">xCAT</a></td>'));
|
||||
xcatMon.append($('<td></td>').append(statusButtonHash['xcatmon']));
|
||||
xcatMon.append($('<td>xCAT provides node status monitoring using fping on AIX and nmapon Linux. It also provides application status monitoring. The status and the appstatus columns of the nodelist table will be updated periodically with the latest status values for the nodes.</td>'));
|
||||
monTableBody.append(xcatMon);
|
||||
|
||||
var rmcMon = $('<tr></tr>');
|
||||
rmcMon.append($('<td><a href="#" name="rmcmon">RMC</a></td>'));
|
||||
rmcMon.append($('<td></td>').append(statusButtonHash['rmcmon']));
|
||||
rmcMon.append($('<td>Resource Monitoring and Control (RMC) is a generalized framework for managing, monitoring and manipulating resources, such as physical or logical system entities. RMC is utilized as a communication mechanism for reporting service events to the Hardware Management Console (HMC).</td>'));
|
||||
monTableBody.append(rmcMon);
|
||||
|
||||
var rmcEvent = $('<tr></tr>');
|
||||
rmcEvent.append($('<td><a href="#" name="rmcevent">RMC Event</a></td>'));
|
||||
rmcEvent.append($('<td></td>').append(statusButtonHash['rmcevent']));
|
||||
rmcEvent.append($('<td>Shows a list of events recorded by the RSCT Event Response resource manager in the audit log.</td>'));
|
||||
monTableBody.append(rmcEvent);
|
||||
|
||||
var gangliaMon = $('<tr></tr>');
|
||||
gangliaMon.append($('<td><a href="#" name="gangliamon">Ganglia</a></td>'));
|
||||
gangliaMon.append($('<td></td>').append(statusButtonHash['gangliamon']));
|
||||
gangliaMon.append($('<td>Ganglia is a scalable distributed monitoring system for high-performance computing systems such as clusters and Grids.</td>'));
|
||||
monTableBody.append(gangliaMon);
|
||||
|
||||
// Do not word wrap
|
||||
monTableBody.find('td:nth-child(1)').css('white-space', 'nowrap');
|
||||
monTableBody.find('td:nth-child(3)').css({
|
||||
'white-space': 'normal',
|
||||
'text-align': 'left'
|
||||
});
|
||||
|
||||
// Append info bar
|
||||
$('#monitorTab div').empty().append(createInfoBar('Select a monitoring tool to use'));
|
||||
$('#monitorTab .form').append(monTable);
|
||||
|
||||
// Open monitoring tool onclick
|
||||
$('#monitorTab .form a').bind('click', function() {
|
||||
loadMonitorTab($(this).attr('name'));
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Load monitoring tool in a new tab
|
||||
*
|
||||
* @param name Name of monitoring tool
|
||||
*/
|
||||
function loadMonitorTab(name) {
|
||||
// If the tab exist, then we only need to select it
|
||||
var tab = getMonitorTab();
|
||||
if ($("#" + name).length) {
|
||||
tab.select(name);
|
||||
return;
|
||||
}
|
||||
|
||||
switch (name) {
|
||||
case 'xcatmon':
|
||||
tab.add(name, 'xCAT', '', true);
|
||||
loadXcatMon();
|
||||
break;
|
||||
case 'rmcmon':
|
||||
tab.add(name, 'RMC Monitor', '', true);
|
||||
loadRmcMon();
|
||||
break;
|
||||
case 'gangliamon':
|
||||
tab.add(name, 'Ganglia', '', true);
|
||||
loadGangliaMon();
|
||||
break;
|
||||
case 'rmcevent':
|
||||
tab.add(name, 'RMC Event', '', true);
|
||||
loadRmcEvent();
|
||||
break;
|
||||
}
|
||||
|
||||
tab.select(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load tab showing 'Under contruction'
|
||||
*
|
||||
* @param monitorName Name of monitoring tool
|
||||
* @param tab Tab area
|
||||
*/
|
||||
function loadUnfinish(monitorName, tab) {
|
||||
var unfinishPage = $('<div></div>');
|
||||
unfinishPage.append(createInfoBar('Not yet supported'));
|
||||
tab.add(monitorName, 'Unfinished', unfinishPage, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* Turn on or off monitoring tool
|
||||
*
|
||||
* @return Nothing
|
||||
*/
|
||||
function toggleMonitor() {
|
||||
// Get the name of the monitoring tool
|
||||
var name = $(this).attr('name');
|
||||
// Get the status to toggle to, either on or off
|
||||
var status = $(this).val();
|
||||
|
||||
// Start or stop monitoring plugin
|
||||
var command = 'monstart';
|
||||
if (status == 'Off') {
|
||||
command = 'monstop' ;
|
||||
}
|
||||
|
||||
// Start or stop monitoring on xCAT
|
||||
$.ajax({
|
||||
url : 'lib/cmd.php',
|
||||
dataType : 'json',
|
||||
data : {
|
||||
cmd : command,
|
||||
tgt : '',
|
||||
args : name + '',
|
||||
msg : ''
|
||||
},
|
||||
success : function(data) {
|
||||
data = decodeRsp(data);
|
||||
// Start or stop monitoring on remote nodes
|
||||
$.ajax({
|
||||
url : 'lib/cmd.php',
|
||||
dataType : 'json',
|
||||
data : {
|
||||
cmd : command,
|
||||
tgt : '',
|
||||
args : name + ';-r',
|
||||
msg : name + ' switched ' + status
|
||||
},
|
||||
success : function(data) {
|
||||
data = decodeRsp(data);
|
||||
updateMonStatus(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the monitoring status on Monitor tab
|
||||
*
|
||||
* @param data Data returned from HTTP request
|
||||
*/
|
||||
function updateMonStatus(data) {
|
||||
var rsp = data.rsp[data.rsp.length-1];
|
||||
var msg = data.msg;
|
||||
|
||||
// Create appropriate info or warning bar
|
||||
var bar = '';
|
||||
if (rsp.indexOf('started') > -1 || rsp.indexOf('stopped') > -1) {
|
||||
bar = createInfoBar(msg);
|
||||
} else {
|
||||
bar = createWarnBar('Failed to ' + msg + '. ' + rsp);
|
||||
}
|
||||
|
||||
// Prepend info or warning bar to tab
|
||||
bar.prependTo($('#monitorTab .form'));
|
||||
bar.delay(4000).slideUp();
|
||||
}
|
||||
+1211
-1188
File diff suppressed because it is too large
Load Diff
+422
-418
@@ -1,419 +1,423 @@
|
||||
/**
|
||||
* Global variables
|
||||
*/
|
||||
var xcatMonTableId = "xcatMonSettingTable";
|
||||
|
||||
/**
|
||||
* Load xCAT monitoring
|
||||
*/
|
||||
function loadXcatMon() {
|
||||
// Find xCAT monitoring tab
|
||||
var xcatMonTab = $('#xcatmon');
|
||||
xcatMonTab.append("<div id= xcatmonTable></div>");
|
||||
|
||||
// Show content of monsetting table
|
||||
$.ajax({
|
||||
url : 'lib/cmd.php',
|
||||
dataType : 'json',
|
||||
data : {
|
||||
cmd : 'tabdump',
|
||||
tgt : '',
|
||||
args : 'monsetting',
|
||||
msg : ''
|
||||
},
|
||||
success : loadXcatMonSetting
|
||||
});
|
||||
}
|
||||
|
||||
function loadXcatMonSetting(data) {
|
||||
var apps = ""; // Contains the xcatmon config
|
||||
var rsp = data.rsp;
|
||||
if (!rsp.length)
|
||||
return;
|
||||
|
||||
var apps_flag = 0;
|
||||
var ping; // xcatmon ping interval
|
||||
var ping_flag = 0;
|
||||
|
||||
// Create an info bar
|
||||
var infoBar = createInfoBar('Click on a cell to edit. Click outside the table to write to the cell. Once you are finished configuring the xCAT monitor, click on Apply.');
|
||||
$('#xcatmonTable').append(infoBar);
|
||||
|
||||
// Create xcatmon table
|
||||
var xcatmonTable = new DataTable(xcatMonTableId);
|
||||
|
||||
// Create datatable
|
||||
var dTable;
|
||||
|
||||
// Create table header
|
||||
var header = rsp[0].split(",");
|
||||
header.splice(3, 2);
|
||||
header.splice(0, 1);
|
||||
header[0] = "App Name";
|
||||
header[1] = "Configure";
|
||||
header.push('<input type="checkbox" onclick="selectAllCheckbox(event,$(this))">');
|
||||
header.unshift('');
|
||||
xcatmonTable.init(header);
|
||||
|
||||
// Create container for original table contents
|
||||
var origCont = new Array();
|
||||
origCont[0] = header; // Table headers
|
||||
|
||||
// Create container for new contents to use later updating monsetting table
|
||||
var newCont = new Object();
|
||||
newCont[0] = rsp[0].split(","); // Table headers
|
||||
|
||||
// Create container for other monsetting lines
|
||||
var otherCont = new Array();
|
||||
|
||||
$('#xcatmonTable').append(xcatmonTable.object());
|
||||
var m = 1; // Count for origCont
|
||||
var n = 0;
|
||||
for ( var i = 1; i < rsp.length; i++) {
|
||||
var pos = rsp[i].indexOf("xcatmon"); // Only check xcatmon setting
|
||||
if (pos == 1) {
|
||||
if ((rsp[i].indexOf("apps") == -1) && (rsp[i].indexOf("ping") == -1)) {
|
||||
var cols = rsp[i].split(',');
|
||||
for ( var j = 0; j < cols.length; j++) {
|
||||
if (cols[j].count('"') % 2 == 1) {
|
||||
while (cols[j].count('"') % 2 == 1) {
|
||||
cols[j] = cols[j] + "," + cols[j + 1];
|
||||
cols.splice(j + 1, 1);
|
||||
}
|
||||
}
|
||||
cols[j] = cols[j].replace(new RegExp('"', 'g'), '');
|
||||
}
|
||||
|
||||
cols.splice(3, 2);
|
||||
cols.splice(0, 1);
|
||||
cols.push('<input type="checkbox" name="' + cols[0] + '" title="Checking this box will add/remove the app from the configured app value"/>');
|
||||
cols.unshift('<span class="ui-icon ui-icon-close" onclick="deleteXcatMonRow(this)"></span>');
|
||||
|
||||
// Add column to table
|
||||
xcatmonTable.add(cols);
|
||||
origCont[m++] = cols;
|
||||
} else {
|
||||
if (!apps_flag) { // Check the apps setting
|
||||
if (rsp[i].indexOf("apps") > -1) {
|
||||
apps = rsp[i].split(',');
|
||||
|
||||
for ( var j = 0; j < apps.length; j++) {
|
||||
if (apps[j].count('"') % 2 == 1) {
|
||||
while (apps[j].count('"') % 2 == 1) {
|
||||
apps[j] = apps[j] + "," + apps[j + 1];
|
||||
apps.splice(j + 1, 1);
|
||||
}
|
||||
}
|
||||
apps[j] = apps[j].replace(new RegExp('"', 'g'), '');
|
||||
}
|
||||
|
||||
apps_flag = 1; // Set the flag to 1 to avoid this subroute
|
||||
}
|
||||
}
|
||||
|
||||
// Get into the ping settings
|
||||
if (!ping_flag) {
|
||||
// Check the ping interval
|
||||
if (rsp[i].indexOf("ping-interval") > -1) {
|
||||
ping = rsp[i].split(',');
|
||||
for ( var j = 0; j < ping.length; j++) {
|
||||
if (ping[j].count('"') % 2 == 1) {
|
||||
while (ping[j].count('"') % 2 == 1) {
|
||||
ping[j] = ping[j] + "," + ping[j + 1];
|
||||
ping.splice(j + 1, 1);
|
||||
}
|
||||
}
|
||||
ping[j] = ping[j].replace((new RegExp('"', 'g')),
|
||||
'');
|
||||
}
|
||||
ping_flag = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (pos != 1) {
|
||||
// The other monitor in the monsetting table
|
||||
var otherCols = rsp[i].split(',');
|
||||
for ( var k = 0; k < otherCols.length; k++) {
|
||||
if (otherCols[k].count('"') % 2 == 1) {
|
||||
while (otherCols[k].count('"') % 2 == 1) {
|
||||
otherCols[k] = otherCols[k] + "," + otherCols[k + 1];
|
||||
otherCols.splice(k + 1, 1);
|
||||
}
|
||||
}
|
||||
otherCols[k] = otherCols[k].replace(new RegExp('"', 'g'), '');
|
||||
}
|
||||
|
||||
otherCont[n++] = otherCols;
|
||||
|
||||
}
|
||||
}
|
||||
// If app is not in the monsetting table, then create default apps row
|
||||
if (!apps_flag) {
|
||||
apps = rsp[0].split(',');
|
||||
apps[0] = "xcatmon";
|
||||
apps[1] = "apps";
|
||||
apps[2] = "";
|
||||
apps[3] = "";
|
||||
apps[4] = "";
|
||||
}
|
||||
|
||||
// If the ping interval is not in the monsetting table, then create the
|
||||
// default ping-interval
|
||||
if (!ping_flag) {
|
||||
ping = rsp[0].split(',');
|
||||
ping[0] = "xcatmon";
|
||||
ping[1] = "ping-interval";
|
||||
|
||||
// Set default ping-interval setting to 5
|
||||
ping[2] = "5";
|
||||
ping[3] = "";
|
||||
ping[4] = "";
|
||||
}
|
||||
|
||||
// Set checkbox to be true
|
||||
var checked = apps[2].split(',');
|
||||
for ( var i = 0; i < checked.length; i++) {
|
||||
$("input:checkbox[name=" + checked[i] + "]").attr('checked', true);
|
||||
for ( var j = 0; j < origCont.length; j++) {
|
||||
if (origCont[j][1] == checked[i]) {
|
||||
origCont[j].splice(3, 1);
|
||||
origCont[j].push('<input type="checkbox" name="' + origCont[j][1] + '" title="Check this checkbox to add/remove the app from the configured app value." checked=true/>');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
$(":checkbox").tooltip();
|
||||
|
||||
// Make the table editable
|
||||
$('#' + xcatMonTableId + ' td:not(td:nth-child(1),td:last-child)').editable(function(value, settings) {
|
||||
var colPos = this.cellIndex;
|
||||
var rowPos = dTable.fnGetPosition(this.parentNode);
|
||||
dTable.fnUpdate(value, rowPos, colPos);
|
||||
return (value);
|
||||
}, {
|
||||
onblur : 'submit',
|
||||
type : 'textarea',
|
||||
placeholder : ' ',
|
||||
height : '30px'
|
||||
});
|
||||
|
||||
// Save datatable
|
||||
dTable = $('#' + xcatMonTableId).dataTable({
|
||||
'iDisplayLength': 50,
|
||||
'bLengthChange': false,
|
||||
"bScrollCollapse": true,
|
||||
"sScrollY": "400px",
|
||||
"sScrollX": "110%",
|
||||
"bAutoWidth": true,
|
||||
"oLanguage": {
|
||||
"oPaginate": {
|
||||
"sNext": "",
|
||||
"sPrevious": ""
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Create action bar
|
||||
var actionBar = $('<div class="actionBar"></div>');
|
||||
var addRowLnk = $('<a>Add row</a>');
|
||||
addRowLnk.bind('click', function(event) {
|
||||
// Create container for new row
|
||||
var row = new Array();
|
||||
|
||||
// Add delete button to row
|
||||
row.push('<span class="ui-icon ui-icon-close" onclick="deleteXcatMonRow(this)"></span>');
|
||||
for ( var i = 0; i < header.length - 2; i++)
|
||||
row.push('');
|
||||
|
||||
// Add checkbox
|
||||
row.push('<input type="checkbox" name="' + row[2] + '" title="Checking this checkbox will add/remove the app from the configured apps value"/>');
|
||||
// Get the datatable of the table
|
||||
var dTable = $('#' + xcatMonTableId).dataTable();
|
||||
// Add the new row to the datatable
|
||||
dTable.fnAddData(row);
|
||||
|
||||
// make the datatable editable
|
||||
$(":checkbox[title]").tooltip();
|
||||
$('#' + xcatMonTableId + ' td:not(td:nth-child(1),td:last-child)').editable(function(value, settings) {
|
||||
var colPos = this.cellIndex;
|
||||
var rowPos = dTable
|
||||
.fnGetPosition(this.parentNode);
|
||||
dTable.fnUpdate(value, rowPos,
|
||||
colPos);
|
||||
return (value);
|
||||
}, {
|
||||
onblur : 'submit',
|
||||
type : 'textarea',
|
||||
placeholder : ' ',
|
||||
height : '30px'
|
||||
});
|
||||
});
|
||||
|
||||
// Create apply button to store the contents of the table to the monsetting table
|
||||
var applyLnk = $('<a>Apply</a>');
|
||||
applyLnk.bind('click', function(event) {
|
||||
// Get the datatable
|
||||
var dTable = $('#' + xcatMonTableId).dataTable();
|
||||
// Get datatable rows
|
||||
var dRows = dTable.fnGetNodes();
|
||||
var count = 0;
|
||||
|
||||
// Create a new container for the apps value
|
||||
var appValue = '';
|
||||
var tableName = 'monsetting';
|
||||
var closeBtn = createButton('close');
|
||||
|
||||
// Get the row contents
|
||||
for ( var i = 0; i < dRows.length; i++) {
|
||||
if (dRows[i]) {
|
||||
// Get the row columns
|
||||
var cols = dRows[i].childNodes;
|
||||
// Create a container for the new columns
|
||||
var vals = new Array();
|
||||
|
||||
for ( var j = 1; j < cols.length - 1; j++) {
|
||||
var val = cols.item(j).firstChild.nodeValue;
|
||||
if (val == ' ')
|
||||
vals[j - 1] = '';
|
||||
else
|
||||
vals[j - 1] = val;
|
||||
}
|
||||
|
||||
var vals_orig = new Array();
|
||||
// Copy data from vals to vals_orig
|
||||
for ( var p = 0; p < 2; p++) {
|
||||
var val = vals[p];
|
||||
vals_orig[p] = val;
|
||||
}
|
||||
|
||||
vals.push('');
|
||||
vals.push('');
|
||||
vals.unshift('xcatmon');
|
||||
|
||||
// Stored new column to newCont
|
||||
newCont[i + 1] = vals;
|
||||
|
||||
if (cols.item(cols.length - 1).firstChild.checked) {
|
||||
vals_orig.push('<input type="checkbox" name="' + vals_orig[0] + '" title="Checking this checkbox will add/remove the app from the configured apps value" checked=true/>');
|
||||
} else {
|
||||
vals_orig.push('<input type="checkbox" name="' + vals_orig[0] + '" title="Checking this checkbox will add/remove the app from the configured apps value"/>');
|
||||
}
|
||||
|
||||
// Add delete button to row
|
||||
vals_orig.unshift('<span class="ui-icon ui-icon-close" onclick="deleteXcatMonRow(this)"></span>');
|
||||
// Add row to origCont
|
||||
origCont[i + 1] = vals_orig;
|
||||
count = i + 1;
|
||||
|
||||
// Check checkbox for every row when merging the app name with the apps values
|
||||
if (cols.item(cols.length - 1).firstChild.checked)
|
||||
appValue = appValue.concat(cols.item(2).firstChild.nodeValue + ",");
|
||||
}
|
||||
}
|
||||
|
||||
count++;
|
||||
|
||||
// Delete the last comma of the apps value
|
||||
appValue = appValue.substring(0, (appValue.length - 1));
|
||||
apps[2] = appValue;
|
||||
|
||||
newCont[count++] = apps;
|
||||
newCont[count++] = ping;
|
||||
|
||||
// Add to other monitor settings
|
||||
for ( var j = 0; j < otherCont.length; j++) {
|
||||
newCont[count++] = otherCont[j];
|
||||
}
|
||||
|
||||
// Create save dialog
|
||||
var dialogSave = $('<div id="saveDialog" align="center">Saving configuration</div>');
|
||||
dialogSave.append(createLoader());
|
||||
|
||||
$('#xcatmon').append(dialogSave);
|
||||
$("#saveDialog").dialog({
|
||||
modal : true
|
||||
});
|
||||
|
||||
$('.ui-dialog-titlebar-close').hide();
|
||||
$.ajax({
|
||||
type : 'POST',
|
||||
url : 'lib/tabRestore.php',
|
||||
dataType : 'json',
|
||||
data : {
|
||||
table : tableName,
|
||||
cont : newCont
|
||||
},
|
||||
success : function(data) {
|
||||
// empty the dialog.add the close button
|
||||
$("#saveDialog").empty().append('<p>Configuration saved!</p>');
|
||||
$("#saveDialog").append(closeBtn);
|
||||
}
|
||||
});
|
||||
|
||||
// Close button
|
||||
closeBtn.bind('click', function(event) {
|
||||
$("#saveDialog").dialog("destroy");
|
||||
$("#saveDialog").remove();
|
||||
});
|
||||
|
||||
// Clear the newCont
|
||||
newCont = null;
|
||||
newCont = new Object();
|
||||
newCont[0] = rsp[0].split(",");
|
||||
});
|
||||
|
||||
var cancelLnk = $('<a>Cancel</a>');
|
||||
cancelLnk.bind('click', function(event) {
|
||||
// Get the datatable for the page
|
||||
var dTable = $('#' + xcatMonTableId).dataTable();
|
||||
|
||||
// Clear the datatable
|
||||
dTable.fnClearTable();
|
||||
|
||||
// Add the contents of origCont to the datatable
|
||||
for ( var i = 1; i < origCont.length; i++)
|
||||
dTable.fnAddData(origCont[i], true);
|
||||
|
||||
$(":checkbox[title]").tooltip();
|
||||
$('#' + xcatMonTableId + ' td:not(td:nth-child(1),td:last-child)').editable(function(value, settings) {
|
||||
var colPos = this.cellIndex;
|
||||
var rowPos = dTable.fnGetPosition(this.parentNode);
|
||||
dTable.fnUpdate(value, rowPos, colPos);
|
||||
return (value);
|
||||
}, {
|
||||
onblur : 'submit',
|
||||
type : 'textarea',
|
||||
placeholder : ' ',
|
||||
height : '30px'
|
||||
});
|
||||
});
|
||||
|
||||
// Create actions menu
|
||||
var actionsLnk = '<a>Actions</a>';
|
||||
var actsMenu = createMenu([ addRowLnk, applyLnk, cancelLnk ]);
|
||||
var actionsMenu = createMenu([ [ actionsLnk, actsMenu ] ]);
|
||||
actionsMenu.superfish();
|
||||
actionsMenu.css('display', 'inline-block');
|
||||
actionBar.append(actionsMenu);
|
||||
|
||||
// Create a division to hold actions menu
|
||||
var menuDiv = $('<div id="' + xcatMonTableId + '_menuDiv" class="menuDiv"></div>');
|
||||
$('#' + xcatMonTableId + '_wrapper').prepend(menuDiv);
|
||||
menuDiv.append(actionBar);
|
||||
$('#' + xcatMonTableId + '_filter').appendTo(menuDiv);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a row from the table
|
||||
*/
|
||||
function deleteXcatMonRow(obj) {
|
||||
var dTable = $('#' + xcatMonTableId).dataTable();
|
||||
var rows = dTable.fnGetNodes();
|
||||
var tgtRow = $(obj).parent().parent().get(0);
|
||||
for ( var i in rows) {
|
||||
if (rows[i] == tgtRow) {
|
||||
dTable.fnDeleteRow(i, null, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Global variables
|
||||
*/
|
||||
var xcatMonTableId = "xcatMonSettingTable";
|
||||
|
||||
/**
|
||||
* Load xCAT monitoring
|
||||
*/
|
||||
function loadXcatMon() {
|
||||
// Find xCAT monitoring tab
|
||||
var xcatMonTab = $('#xcatmon');
|
||||
xcatMonTab.append("<div id= xcatmonTable></div>");
|
||||
|
||||
// Show content of monsetting table
|
||||
$.ajax({
|
||||
url : 'lib/cmd.php',
|
||||
dataType : 'json',
|
||||
data : {
|
||||
cmd : 'tabdump',
|
||||
tgt : '',
|
||||
args : 'monsetting',
|
||||
msg : ''
|
||||
},
|
||||
success : function(data) {
|
||||
data = decodeRsp(data);
|
||||
loadXcatMonSetting(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function loadXcatMonSetting(data) {
|
||||
var apps = ""; // Contains the xcatmon config
|
||||
var rsp = data.rsp;
|
||||
if (!rsp.length)
|
||||
return;
|
||||
|
||||
var apps_flag = 0;
|
||||
var ping; // xcatmon ping interval
|
||||
var ping_flag = 0;
|
||||
|
||||
// Create an info bar
|
||||
var infoBar = createInfoBar('Click on a cell to edit. Click outside the table to write to the cell. Once you are finished configuring the xCAT monitor, click on Apply.');
|
||||
$('#xcatmonTable').append(infoBar);
|
||||
|
||||
// Create xcatmon table
|
||||
var xcatmonTable = new DataTable(xcatMonTableId);
|
||||
|
||||
// Create datatable
|
||||
var dTable;
|
||||
|
||||
// Create table header
|
||||
var header = rsp[0].split(",");
|
||||
header.splice(3, 2);
|
||||
header.splice(0, 1);
|
||||
header[0] = "App Name";
|
||||
header[1] = "Configure";
|
||||
header.push('<input type="checkbox" onclick="selectAllCheckbox(event,$(this))">');
|
||||
header.unshift('');
|
||||
xcatmonTable.init(header);
|
||||
|
||||
// Create container for original table contents
|
||||
var origCont = new Array();
|
||||
origCont[0] = header; // Table headers
|
||||
|
||||
// Create container for new contents to use later updating monsetting table
|
||||
var newCont = new Object();
|
||||
newCont[0] = rsp[0].split(","); // Table headers
|
||||
|
||||
// Create container for other monsetting lines
|
||||
var otherCont = new Array();
|
||||
|
||||
$('#xcatmonTable').append(xcatmonTable.object());
|
||||
var m = 1; // Count for origCont
|
||||
var n = 0;
|
||||
for ( var i = 1; i < rsp.length; i++) {
|
||||
var pos = rsp[i].indexOf("xcatmon"); // Only check xcatmon setting
|
||||
if (pos == 1) {
|
||||
if ((rsp[i].indexOf("apps") == -1) && (rsp[i].indexOf("ping") == -1)) {
|
||||
var cols = rsp[i].split(',');
|
||||
for ( var j = 0; j < cols.length; j++) {
|
||||
if (cols[j].count('"') % 2 == 1) {
|
||||
while (cols[j].count('"') % 2 == 1) {
|
||||
cols[j] = cols[j] + "," + cols[j + 1];
|
||||
cols.splice(j + 1, 1);
|
||||
}
|
||||
}
|
||||
cols[j] = cols[j].replace(new RegExp('"', 'g'), '');
|
||||
}
|
||||
|
||||
cols.splice(3, 2);
|
||||
cols.splice(0, 1);
|
||||
cols.push('<input type="checkbox" name="' + cols[0] + '" title="Checking this box will add/remove the app from the configured app value"/>');
|
||||
cols.unshift('<span class="ui-icon ui-icon-close" onclick="deleteXcatMonRow(this)"></span>');
|
||||
|
||||
// Add column to table
|
||||
xcatmonTable.add(cols);
|
||||
origCont[m++] = cols;
|
||||
} else {
|
||||
if (!apps_flag) { // Check the apps setting
|
||||
if (rsp[i].indexOf("apps") > -1) {
|
||||
apps = rsp[i].split(',');
|
||||
|
||||
for ( var j = 0; j < apps.length; j++) {
|
||||
if (apps[j].count('"') % 2 == 1) {
|
||||
while (apps[j].count('"') % 2 == 1) {
|
||||
apps[j] = apps[j] + "," + apps[j + 1];
|
||||
apps.splice(j + 1, 1);
|
||||
}
|
||||
}
|
||||
apps[j] = apps[j].replace(new RegExp('"', 'g'), '');
|
||||
}
|
||||
|
||||
apps_flag = 1; // Set the flag to 1 to avoid this subroute
|
||||
}
|
||||
}
|
||||
|
||||
// Get into the ping settings
|
||||
if (!ping_flag) {
|
||||
// Check the ping interval
|
||||
if (rsp[i].indexOf("ping-interval") > -1) {
|
||||
ping = rsp[i].split(',');
|
||||
for ( var j = 0; j < ping.length; j++) {
|
||||
if (ping[j].count('"') % 2 == 1) {
|
||||
while (ping[j].count('"') % 2 == 1) {
|
||||
ping[j] = ping[j] + "," + ping[j + 1];
|
||||
ping.splice(j + 1, 1);
|
||||
}
|
||||
}
|
||||
ping[j] = ping[j].replace((new RegExp('"', 'g')),
|
||||
'');
|
||||
}
|
||||
ping_flag = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if (pos != 1) {
|
||||
// The other monitor in the monsetting table
|
||||
var otherCols = rsp[i].split(',');
|
||||
for ( var k = 0; k < otherCols.length; k++) {
|
||||
if (otherCols[k].count('"') % 2 == 1) {
|
||||
while (otherCols[k].count('"') % 2 == 1) {
|
||||
otherCols[k] = otherCols[k] + "," + otherCols[k + 1];
|
||||
otherCols.splice(k + 1, 1);
|
||||
}
|
||||
}
|
||||
otherCols[k] = otherCols[k].replace(new RegExp('"', 'g'), '');
|
||||
}
|
||||
|
||||
otherCont[n++] = otherCols;
|
||||
|
||||
}
|
||||
}
|
||||
// If app is not in the monsetting table, then create default apps row
|
||||
if (!apps_flag) {
|
||||
apps = rsp[0].split(',');
|
||||
apps[0] = "xcatmon";
|
||||
apps[1] = "apps";
|
||||
apps[2] = "";
|
||||
apps[3] = "";
|
||||
apps[4] = "";
|
||||
}
|
||||
|
||||
// If the ping interval is not in the monsetting table, then create the
|
||||
// default ping-interval
|
||||
if (!ping_flag) {
|
||||
ping = rsp[0].split(',');
|
||||
ping[0] = "xcatmon";
|
||||
ping[1] = "ping-interval";
|
||||
|
||||
// Set default ping-interval setting to 5
|
||||
ping[2] = "5";
|
||||
ping[3] = "";
|
||||
ping[4] = "";
|
||||
}
|
||||
|
||||
// Set checkbox to be true
|
||||
var checked = apps[2].split(',');
|
||||
for ( var i = 0; i < checked.length; i++) {
|
||||
$("input:checkbox[name=" + checked[i] + "]").attr('checked', true);
|
||||
for ( var j = 0; j < origCont.length; j++) {
|
||||
if (origCont[j][1] == checked[i]) {
|
||||
origCont[j].splice(3, 1);
|
||||
origCont[j].push('<input type="checkbox" name="' + origCont[j][1] + '" title="Check this checkbox to add/remove the app from the configured app value." checked=true/>');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
$(":checkbox").tooltip();
|
||||
|
||||
// Make the table editable
|
||||
$('#' + xcatMonTableId + ' td:not(td:nth-child(1),td:last-child)').editable(function(value, settings) {
|
||||
var colPos = this.cellIndex;
|
||||
var rowPos = dTable.fnGetPosition(this.parentNode);
|
||||
dTable.fnUpdate(value, rowPos, colPos);
|
||||
return (value);
|
||||
}, {
|
||||
onblur : 'submit',
|
||||
type : 'textarea',
|
||||
placeholder : ' ',
|
||||
height : '30px'
|
||||
});
|
||||
|
||||
// Save datatable
|
||||
dTable = $('#' + xcatMonTableId).dataTable({
|
||||
'iDisplayLength': 50,
|
||||
'bLengthChange': false,
|
||||
"bScrollCollapse": true,
|
||||
"sScrollY": "400px",
|
||||
"sScrollX": "110%",
|
||||
"bAutoWidth": true,
|
||||
"oLanguage": {
|
||||
"oPaginate": {
|
||||
"sNext": "",
|
||||
"sPrevious": ""
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Create action bar
|
||||
var actionBar = $('<div class="actionBar"></div>');
|
||||
var addRowLnk = $('<a>Add row</a>');
|
||||
addRowLnk.bind('click', function(event) {
|
||||
// Create container for new row
|
||||
var row = new Array();
|
||||
|
||||
// Add delete button to row
|
||||
row.push('<span class="ui-icon ui-icon-close" onclick="deleteXcatMonRow(this)"></span>');
|
||||
for ( var i = 0; i < header.length - 2; i++)
|
||||
row.push('');
|
||||
|
||||
// Add checkbox
|
||||
row.push('<input type="checkbox" name="' + row[2] + '" title="Checking this checkbox will add/remove the app from the configured apps value"/>');
|
||||
// Get the datatable of the table
|
||||
var dTable = $('#' + xcatMonTableId).dataTable();
|
||||
// Add the new row to the datatable
|
||||
dTable.fnAddData(row);
|
||||
|
||||
// make the datatable editable
|
||||
$(":checkbox[title]").tooltip();
|
||||
$('#' + xcatMonTableId + ' td:not(td:nth-child(1),td:last-child)').editable(function(value, settings) {
|
||||
var colPos = this.cellIndex;
|
||||
var rowPos = dTable
|
||||
.fnGetPosition(this.parentNode);
|
||||
dTable.fnUpdate(value, rowPos,
|
||||
colPos);
|
||||
return (value);
|
||||
}, {
|
||||
onblur : 'submit',
|
||||
type : 'textarea',
|
||||
placeholder : ' ',
|
||||
height : '30px'
|
||||
});
|
||||
});
|
||||
|
||||
// Create apply button to store the contents of the table to the monsetting table
|
||||
var applyLnk = $('<a>Apply</a>');
|
||||
applyLnk.bind('click', function(event) {
|
||||
// Get the datatable
|
||||
var dTable = $('#' + xcatMonTableId).dataTable();
|
||||
// Get datatable rows
|
||||
var dRows = dTable.fnGetNodes();
|
||||
var count = 0;
|
||||
|
||||
// Create a new container for the apps value
|
||||
var appValue = '';
|
||||
var tableName = 'monsetting';
|
||||
var closeBtn = createButton('close');
|
||||
|
||||
// Get the row contents
|
||||
for ( var i = 0; i < dRows.length; i++) {
|
||||
if (dRows[i]) {
|
||||
// Get the row columns
|
||||
var cols = dRows[i].childNodes;
|
||||
// Create a container for the new columns
|
||||
var vals = new Array();
|
||||
|
||||
for ( var j = 1; j < cols.length - 1; j++) {
|
||||
var val = cols.item(j).firstChild.nodeValue;
|
||||
if (val == ' ')
|
||||
vals[j - 1] = '';
|
||||
else
|
||||
vals[j - 1] = val;
|
||||
}
|
||||
|
||||
var vals_orig = new Array();
|
||||
// Copy data from vals to vals_orig
|
||||
for ( var p = 0; p < 2; p++) {
|
||||
var val = vals[p];
|
||||
vals_orig[p] = val;
|
||||
}
|
||||
|
||||
vals.push('');
|
||||
vals.push('');
|
||||
vals.unshift('xcatmon');
|
||||
|
||||
// Stored new column to newCont
|
||||
newCont[i + 1] = vals;
|
||||
|
||||
if (cols.item(cols.length - 1).firstChild.checked) {
|
||||
vals_orig.push('<input type="checkbox" name="' + vals_orig[0] + '" title="Checking this checkbox will add/remove the app from the configured apps value" checked=true/>');
|
||||
} else {
|
||||
vals_orig.push('<input type="checkbox" name="' + vals_orig[0] + '" title="Checking this checkbox will add/remove the app from the configured apps value"/>');
|
||||
}
|
||||
|
||||
// Add delete button to row
|
||||
vals_orig.unshift('<span class="ui-icon ui-icon-close" onclick="deleteXcatMonRow(this)"></span>');
|
||||
// Add row to origCont
|
||||
origCont[i + 1] = vals_orig;
|
||||
count = i + 1;
|
||||
|
||||
// Check checkbox for every row when merging the app name with the apps values
|
||||
if (cols.item(cols.length - 1).firstChild.checked)
|
||||
appValue = appValue.concat(cols.item(2).firstChild.nodeValue + ",");
|
||||
}
|
||||
}
|
||||
|
||||
count++;
|
||||
|
||||
// Delete the last comma of the apps value
|
||||
appValue = appValue.substring(0, (appValue.length - 1));
|
||||
apps[2] = appValue;
|
||||
|
||||
newCont[count++] = apps;
|
||||
newCont[count++] = ping;
|
||||
|
||||
// Add to other monitor settings
|
||||
for ( var j = 0; j < otherCont.length; j++) {
|
||||
newCont[count++] = otherCont[j];
|
||||
}
|
||||
|
||||
// Create save dialog
|
||||
var dialogSave = $('<div id="saveDialog" align="center">Saving configuration</div>');
|
||||
dialogSave.append(createLoader());
|
||||
|
||||
$('#xcatmon').append(dialogSave);
|
||||
$("#saveDialog").dialog({
|
||||
modal : true
|
||||
});
|
||||
|
||||
$('.ui-dialog-titlebar-close').hide();
|
||||
$.ajax({
|
||||
type : 'POST',
|
||||
url : 'lib/tabRestore.php',
|
||||
dataType : 'json',
|
||||
data : {
|
||||
table : tableName,
|
||||
cont : newCont
|
||||
},
|
||||
success : function(data) {
|
||||
// do not put in until tabRestore.php has been updated: data = decodeRsp(data);
|
||||
// empty the dialog.add the close button
|
||||
$("#saveDialog").empty().append('<p>Configuration saved!</p>');
|
||||
$("#saveDialog").append(closeBtn);
|
||||
}
|
||||
});
|
||||
|
||||
// Close button
|
||||
closeBtn.bind('click', function(event) {
|
||||
$("#saveDialog").dialog("destroy");
|
||||
$("#saveDialog").remove();
|
||||
});
|
||||
|
||||
// Clear the newCont
|
||||
newCont = null;
|
||||
newCont = new Object();
|
||||
newCont[0] = rsp[0].split(",");
|
||||
});
|
||||
|
||||
var cancelLnk = $('<a>Cancel</a>');
|
||||
cancelLnk.bind('click', function(event) {
|
||||
// Get the datatable for the page
|
||||
var dTable = $('#' + xcatMonTableId).dataTable();
|
||||
|
||||
// Clear the datatable
|
||||
dTable.fnClearTable();
|
||||
|
||||
// Add the contents of origCont to the datatable
|
||||
for ( var i = 1; i < origCont.length; i++)
|
||||
dTable.fnAddData(origCont[i], true);
|
||||
|
||||
$(":checkbox[title]").tooltip();
|
||||
$('#' + xcatMonTableId + ' td:not(td:nth-child(1),td:last-child)').editable(function(value, settings) {
|
||||
var colPos = this.cellIndex;
|
||||
var rowPos = dTable.fnGetPosition(this.parentNode);
|
||||
dTable.fnUpdate(value, rowPos, colPos);
|
||||
return (value);
|
||||
}, {
|
||||
onblur : 'submit',
|
||||
type : 'textarea',
|
||||
placeholder : ' ',
|
||||
height : '30px'
|
||||
});
|
||||
});
|
||||
|
||||
// Create actions menu
|
||||
var actionsLnk = '<a>Actions</a>';
|
||||
var actsMenu = createMenu([ addRowLnk, applyLnk, cancelLnk ]);
|
||||
var actionsMenu = createMenu([ [ actionsLnk, actsMenu ] ]);
|
||||
actionsMenu.superfish();
|
||||
actionsMenu.css('display', 'inline-block');
|
||||
actionBar.append(actionsMenu);
|
||||
|
||||
// Create a division to hold actions menu
|
||||
var menuDiv = $('<div id="' + xcatMonTableId + '_menuDiv" class="menuDiv"></div>');
|
||||
$('#' + xcatMonTableId + '_wrapper').prepend(menuDiv);
|
||||
menuDiv.append(actionBar);
|
||||
$('#' + xcatMonTableId + '_filter').appendTo(menuDiv);
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a row from the table
|
||||
*/
|
||||
function deleteXcatMonRow(obj) {
|
||||
var dTable = $('#' + xcatMonTableId).dataTable();
|
||||
var rows = dTable.fnGetNodes();
|
||||
var tgtRow = $(obj).parent().parent().get(0);
|
||||
for ( var i in rows) {
|
||||
if (rows[i] == tgtRow) {
|
||||
dTable.fnDeleteRow(i, null, true);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
+4419
-4329
File diff suppressed because it is too large
Load Diff
+307
-295
@@ -1,296 +1,308 @@
|
||||
/**
|
||||
* Load nodeset page
|
||||
*
|
||||
* @param tgtNodes Targets to run nodeset against
|
||||
*/
|
||||
function loadNodesetPage(tgtNodes) {
|
||||
// Get OS images
|
||||
$.ajax( {
|
||||
url : 'lib/cmd.php',
|
||||
dataType : 'json',
|
||||
data : {
|
||||
cmd : 'tabdump',
|
||||
tgt : '',
|
||||
args : 'osimage',
|
||||
msg : ''
|
||||
},
|
||||
|
||||
success : setOSImageCookies
|
||||
});
|
||||
|
||||
// Get nodes tab
|
||||
var tab = getNodesTab();
|
||||
|
||||
// Generate new tab ID
|
||||
var inst = 0;
|
||||
var tabId = 'nodesetTab' + inst;
|
||||
while ($('#' + tabId).length) {
|
||||
// If one already exists, generate another one
|
||||
inst = inst + 1;
|
||||
tabId = 'nodesetTab' + inst;
|
||||
}
|
||||
|
||||
// Create nodeset form
|
||||
var nodesetForm = $('<div class="form"></div>');
|
||||
|
||||
// Create status bar
|
||||
var statBarId = 'nodesetStatusBar' + inst;
|
||||
var statBar = createStatusBar(statBarId).hide();
|
||||
|
||||
// Create loader
|
||||
var loader = createLoader('nodesetLoader');
|
||||
statBar.find('div').append(loader);
|
||||
|
||||
// Create info bar
|
||||
var infoBar = createInfoBar('Set the boot state for a node range');
|
||||
nodesetForm.append(statBar, infoBar);
|
||||
|
||||
// Create VM fieldset
|
||||
var vmFS = $('<fieldset></fieldset>');
|
||||
var vmLegend = $('<legend>Virtual Machine</legend>');
|
||||
vmFS.append(vmLegend);
|
||||
nodesetForm.append(vmFS);
|
||||
|
||||
var vmAttr = $('<div style="display: inline-table; vertical-align: middle;"></div>');
|
||||
vmFS.append($('<div style="display: inline-table; vertical-align: middle;"><img src="images/provision/computer.png"></img></div>'));
|
||||
vmFS.append(vmAttr);
|
||||
|
||||
// Create options fieldset
|
||||
var imageFS = $('<fieldset></fieldset>');
|
||||
var imageLegend = $('<legend>Image</legend>');
|
||||
imageFS.append(imageLegend);
|
||||
nodesetForm.append(imageFS);
|
||||
|
||||
var imageAttr = $('<div style="display: inline-table; vertical-align: middle;"></div>');
|
||||
imageFS.append($('<div style="display: inline-table; vertical-align: middle;"><img src="images/provision/setting.png" style="width: 70px;"></img></div>'));
|
||||
imageFS.append(imageAttr);
|
||||
|
||||
// Create target node or group
|
||||
var tgt = $('<div><label>Target node range:</label><input type="text" name="target" value="' + tgtNodes + '" title="The node or node range to set the boot state for"/></div>');
|
||||
vmAttr.append(tgt);
|
||||
|
||||
// Create boot type drop down
|
||||
var type = $('<div></div>');
|
||||
var typeLabel = $('<label>Boot type:</label>');
|
||||
var typeSelect = $('<select id="bootType" name="bootType" title="The type of network booting to use for this node"></select>');
|
||||
typeSelect.append('<option value="zvm">zvm</option>'
|
||||
+ '<option value="install">pxe</option>'
|
||||
+ '<option value="iscsiboot">yaboot</option>'
|
||||
);
|
||||
type.append(typeLabel);
|
||||
type.append(typeSelect);
|
||||
imageAttr.append(type);
|
||||
|
||||
// Create operating system image input
|
||||
var os = $('<div></div>');
|
||||
var osLabel = $('<label>Operating system image:</label>');
|
||||
var osSelect = $('<select name="os" title="The operating system image to be installed on this node"></select>');
|
||||
osSelect.append($('<option value=""></option>'));
|
||||
|
||||
var imageNames = $.cookie('xcat_imagenames').split(',');
|
||||
if (imageNames) {
|
||||
imageNames.sort();
|
||||
for (var i in imageNames) {
|
||||
osSelect.append($('<option value="' + imageNames[i] + '">' + imageNames[i] + '</option>'));
|
||||
}
|
||||
}
|
||||
os.append(osLabel);
|
||||
os.append(osSelect);
|
||||
imageAttr.append(os);
|
||||
|
||||
// Generate tooltips
|
||||
nodesetForm.find('div input[title],select').tooltip({
|
||||
position: "center right",
|
||||
offset: [-2, 10],
|
||||
effect: "fade",
|
||||
opacity: 0.7,
|
||||
predelay: 800,
|
||||
events : {
|
||||
def : "mouseover,mouseout",
|
||||
input : "mouseover,mouseout",
|
||||
widget : "focus mouseover,blur mouseout",
|
||||
tooltip : "mouseover,mouseout"
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Ok
|
||||
*/
|
||||
var okBtn = createButton('Ok');
|
||||
okBtn.css({
|
||||
'width': '80px',
|
||||
'display': 'block'
|
||||
});
|
||||
okBtn.bind('click', function(event) {
|
||||
// Remove any warning messages
|
||||
$(this).parents('.ui-tabs-panel').find('.ui-state-error').remove();
|
||||
|
||||
// Check state, OS, arch, and profile
|
||||
var ready = true;
|
||||
var inputs = $('#' + tabId + ' input');
|
||||
for ( var i = 0; i < inputs.length; i++) {
|
||||
if (!inputs.eq(i).val() && inputs.eq(i).attr('name') != 'diskPw') {
|
||||
inputs.eq(i).css('border', 'solid #FF0000 1px');
|
||||
ready = false;
|
||||
} else {
|
||||
inputs.eq(i).css('border', 'solid #BDBDBD 1px');
|
||||
}
|
||||
}
|
||||
|
||||
if (ready) {
|
||||
// Get nodes
|
||||
var tgts = $('#' + tabId + ' input[name=target]').val();
|
||||
// Get boot type
|
||||
var type = $('#' + tabId + ' select[id=bootType]').val();
|
||||
// Get operating system image
|
||||
var os = $('#' + tabId + ' select[name=os]').val();
|
||||
|
||||
// Disable all inputs, selects, and Ok button
|
||||
inputs.attr('disabled', 'disabled');
|
||||
$('#' + tabId + ' select').attr('disabled', 'disabled');
|
||||
$(this).attr('disabled', 'true');
|
||||
|
||||
/**
|
||||
* (1) Set the OS, arch, and profile
|
||||
*/
|
||||
$.ajax( {
|
||||
url : 'lib/cmd.php',
|
||||
dataType : 'json',
|
||||
data : {
|
||||
cmd : 'nodeadd',
|
||||
tgt : '',
|
||||
args : tgts + ';noderes.netboot=' + type,
|
||||
msg : 'cmd=nodeadd;inst=' + inst
|
||||
},
|
||||
|
||||
success : updateNodesetStatus
|
||||
});
|
||||
|
||||
// Show status bar
|
||||
statBar.show();
|
||||
} else {
|
||||
// Show warning message
|
||||
var warn = createWarnBar('You are missing some values!');
|
||||
warn.prependTo($(this).parents('.ui-tabs-panel'));
|
||||
}
|
||||
});
|
||||
nodesetForm.append(okBtn);
|
||||
|
||||
// Append to discover tab
|
||||
tab.add(tabId, 'Nodeset', nodesetForm, true);
|
||||
|
||||
// Select new tab
|
||||
tab.select(tabId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update nodeset status
|
||||
*
|
||||
* @param data Data returned from HTTP request
|
||||
*/
|
||||
function updateNodesetStatus(data) {
|
||||
// Get ajax response
|
||||
var rsp = data.rsp;
|
||||
var args = data.msg.split(';');
|
||||
var cmd = args[0].replace('cmd=', '');
|
||||
|
||||
// Get nodeset instance
|
||||
var inst = args[1].replace('inst=', '');
|
||||
// Get status bar ID
|
||||
var statBarId = 'nodesetStatusBar' + inst;
|
||||
// Get tab ID
|
||||
var tabId = 'nodesetTab' + inst;
|
||||
|
||||
// Get nodes
|
||||
var tgts = $('#' + tabId + ' input[name=target]').val();
|
||||
// Get operating system image
|
||||
var os = $('#' + tabId + ' select[name=os]').val();
|
||||
|
||||
/**
|
||||
* (2) Update /etc/hosts
|
||||
*/
|
||||
if (cmd == 'nodeadd') {
|
||||
if (rsp.length) {
|
||||
$('#' + statBarId).find('img').hide();
|
||||
$('#' + statBarId).find('div').append('<pre>(Error) Failed to create node definition</pre>');
|
||||
} else {
|
||||
// Create target nodes string
|
||||
var tgtNodesStr = '';
|
||||
var nodes = tgts.split(',');
|
||||
|
||||
// Loop through each node
|
||||
for ( var i in nodes) {
|
||||
// If it is the 1st and only node
|
||||
if (i == 0 && i == nodes.length - 1) {
|
||||
tgtNodesStr += nodes[i];
|
||||
}
|
||||
// If it is the 1st node of many nodes
|
||||
else if (i == 0 && i != nodes.length - 1) {
|
||||
// Append a comma to the string
|
||||
tgtNodesStr += nodes[i] + ', ';
|
||||
} else {
|
||||
// If it is the last node
|
||||
if (i == nodes.length - 1) {
|
||||
// Append nothing to the string
|
||||
tgtNodesStr += nodes[i];
|
||||
} else {
|
||||
// Append a comma to the string
|
||||
tgtNodesStr += nodes[i] + ', ';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$('#' + statBarId).find('div').append('<pre>Node definition created for ' + tgtNodesStr + '</pre>');
|
||||
$.ajax( {
|
||||
url : 'lib/cmd.php',
|
||||
dataType : 'json',
|
||||
data : {
|
||||
cmd : 'makehosts',
|
||||
tgt : '',
|
||||
args : '',
|
||||
msg : 'cmd=makehosts;inst=' + inst
|
||||
},
|
||||
|
||||
success : updateNodesetStatus
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* (4) Update DNS
|
||||
*/
|
||||
else if (cmd == 'makehosts') {
|
||||
// If no output, no errors occurred
|
||||
if (rsp.length) {
|
||||
$('#' + statBarId).find('div').append('<pre>(Error) Failed to update /etc/hosts</pre>');
|
||||
} else {
|
||||
$('#' + statBarId).find('div').append('<pre>/etc/hosts updated</pre>');
|
||||
}
|
||||
|
||||
// Go straight to prepare node for boot
|
||||
$.ajax( {
|
||||
url : 'lib/cmd.php',
|
||||
dataType : 'json',
|
||||
data : {
|
||||
cmd : 'nodeset',
|
||||
tgt : tgts,
|
||||
args : 'osimage=' + os,
|
||||
msg : 'cmd=nodeset;inst=' + inst
|
||||
},
|
||||
|
||||
success : updateNodesetStatus
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* (5) Boot node from network
|
||||
*/
|
||||
else if (cmd == 'nodeset') {
|
||||
// Write ajax response to status bar
|
||||
var prg = writeRsp(rsp, '');
|
||||
$('#' + statBarId).find('div').append(prg);
|
||||
|
||||
// Hide loader
|
||||
$('#' + statBarId).find('img').hide();
|
||||
}
|
||||
/**
|
||||
* Load nodeset page
|
||||
*
|
||||
* @param tgtNodes Targets to run nodeset against
|
||||
*/
|
||||
function loadNodesetPage(tgtNodes) {
|
||||
// Get OS images
|
||||
$.ajax( {
|
||||
url : 'lib/cmd.php',
|
||||
dataType : 'json',
|
||||
data : {
|
||||
cmd : 'tabdump',
|
||||
tgt : '',
|
||||
args : 'osimage',
|
||||
msg : ''
|
||||
},
|
||||
|
||||
success : function(data) {
|
||||
data = decodeRsp(data);
|
||||
setOSImageCookies(data);
|
||||
}
|
||||
});
|
||||
|
||||
// Get nodes tab
|
||||
var tab = getNodesTab();
|
||||
|
||||
// Generate new tab ID
|
||||
var inst = 0;
|
||||
var tabId = 'nodesetTab' + inst;
|
||||
while ($('#' + tabId).length) {
|
||||
// If one already exists, generate another one
|
||||
inst = inst + 1;
|
||||
tabId = 'nodesetTab' + inst;
|
||||
}
|
||||
|
||||
// Create nodeset form
|
||||
var nodesetForm = $('<div class="form"></div>');
|
||||
|
||||
// Create status bar
|
||||
var statBarId = 'nodesetStatusBar' + inst;
|
||||
var statBar = createStatusBar(statBarId).hide();
|
||||
|
||||
// Create loader
|
||||
var loader = createLoader('nodesetLoader');
|
||||
statBar.find('div').append(loader);
|
||||
|
||||
// Create info bar
|
||||
var infoBar = createInfoBar('Set the boot state for a node range');
|
||||
nodesetForm.append(statBar, infoBar);
|
||||
|
||||
// Create VM fieldset
|
||||
var vmFS = $('<fieldset></fieldset>');
|
||||
var vmLegend = $('<legend>Virtual Machine</legend>');
|
||||
vmFS.append(vmLegend);
|
||||
nodesetForm.append(vmFS);
|
||||
|
||||
var vmAttr = $('<div style="display: inline-table; vertical-align: middle;"></div>');
|
||||
vmFS.append($('<div style="display: inline-table; vertical-align: middle;"><img src="images/provision/computer.png"></img></div>'));
|
||||
vmFS.append(vmAttr);
|
||||
|
||||
// Create options fieldset
|
||||
var imageFS = $('<fieldset></fieldset>');
|
||||
var imageLegend = $('<legend>Image</legend>');
|
||||
imageFS.append(imageLegend);
|
||||
nodesetForm.append(imageFS);
|
||||
|
||||
var imageAttr = $('<div style="display: inline-table; vertical-align: middle;"></div>');
|
||||
imageFS.append($('<div style="display: inline-table; vertical-align: middle;"><img src="images/provision/setting.png" style="width: 70px;"></img></div>'));
|
||||
imageFS.append(imageAttr);
|
||||
|
||||
// Create target node or group
|
||||
var tgt = $('<div><label>Target node range:</label><input type="text" name="target" value="' + tgtNodes + '" title="The node or node range to set the boot state for"/></div>');
|
||||
vmAttr.append(tgt);
|
||||
|
||||
// Create boot type drop down
|
||||
var type = $('<div></div>');
|
||||
var typeLabel = $('<label>Boot type:</label>');
|
||||
var typeSelect = $('<select id="bootType" name="bootType" title="The type of network booting to use for this node"></select>');
|
||||
typeSelect.append('<option value="zvm">zvm</option>'
|
||||
+ '<option value="install">pxe</option>'
|
||||
+ '<option value="iscsiboot">yaboot</option>'
|
||||
);
|
||||
type.append(typeLabel);
|
||||
type.append(typeSelect);
|
||||
imageAttr.append(type);
|
||||
|
||||
// Create operating system image input
|
||||
var os = $('<div></div>');
|
||||
var osLabel = $('<label>Operating system image:</label>');
|
||||
var osSelect = $('<select name="os" title="The operating system image to be installed on this node"></select>');
|
||||
osSelect.append($('<option value=""></option>'));
|
||||
|
||||
var imageNames = $.cookie('xcat_imagenames').split(',');
|
||||
if (imageNames) {
|
||||
imageNames.sort();
|
||||
for (var i in imageNames) {
|
||||
osSelect.append($('<option value="' + imageNames[i] + '">' + imageNames[i] + '</option>'));
|
||||
}
|
||||
}
|
||||
os.append(osLabel);
|
||||
os.append(osSelect);
|
||||
imageAttr.append(os);
|
||||
|
||||
// Generate tooltips
|
||||
nodesetForm.find('div input[title],select').tooltip({
|
||||
position: "center right",
|
||||
offset: [-2, 10],
|
||||
effect: "fade",
|
||||
opacity: 0.7,
|
||||
predelay: 800,
|
||||
events : {
|
||||
def : "mouseover,mouseout",
|
||||
input : "mouseover,mouseout",
|
||||
widget : "focus mouseover,blur mouseout",
|
||||
tooltip : "mouseover,mouseout"
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Ok
|
||||
*/
|
||||
var okBtn = createButton('Ok');
|
||||
okBtn.css({
|
||||
'width': '80px',
|
||||
'display': 'block'
|
||||
});
|
||||
okBtn.bind('click', function(event) {
|
||||
// Remove any warning messages
|
||||
$(this).parents('.ui-tabs-panel').find('.ui-state-error').remove();
|
||||
|
||||
// Check state, OS, arch, and profile
|
||||
var ready = true;
|
||||
var inputs = $('#' + tabId + ' input');
|
||||
for ( var i = 0; i < inputs.length; i++) {
|
||||
if (!inputs.eq(i).val() && inputs.eq(i).attr('name') != 'diskPw') {
|
||||
inputs.eq(i).css('border', 'solid #FF0000 1px');
|
||||
ready = false;
|
||||
} else {
|
||||
inputs.eq(i).css('border', 'solid #BDBDBD 1px');
|
||||
}
|
||||
}
|
||||
|
||||
if (ready) {
|
||||
// Get nodes
|
||||
var tgts = $('#' + tabId + ' input[name=target]').val();
|
||||
// Get boot type
|
||||
var type = $('#' + tabId + ' select[id=bootType]').val();
|
||||
// Get operating system image
|
||||
var os = $('#' + tabId + ' select[name=os]').val();
|
||||
|
||||
// Disable all inputs, selects, and Ok button
|
||||
inputs.attr('disabled', 'disabled');
|
||||
$('#' + tabId + ' select').attr('disabled', 'disabled');
|
||||
$(this).attr('disabled', 'true');
|
||||
|
||||
/**
|
||||
* (1) Set the OS, arch, and profile
|
||||
*/
|
||||
$.ajax( {
|
||||
url : 'lib/cmd.php',
|
||||
dataType : 'json',
|
||||
data : {
|
||||
cmd : 'nodeadd',
|
||||
tgt : '',
|
||||
args : tgts + ';noderes.netboot=' + type,
|
||||
msg : 'cmd=nodeadd;inst=' + inst
|
||||
},
|
||||
|
||||
success : function(data) {
|
||||
data = decodeRsp(data);
|
||||
updateNodesetStatus(data);
|
||||
}
|
||||
});
|
||||
|
||||
// Show status bar
|
||||
statBar.show();
|
||||
} else {
|
||||
// Show warning message
|
||||
var warn = createWarnBar('You are missing some values!');
|
||||
warn.prependTo($(this).parents('.ui-tabs-panel'));
|
||||
}
|
||||
});
|
||||
nodesetForm.append(okBtn);
|
||||
|
||||
// Append to discover tab
|
||||
tab.add(tabId, 'Nodeset', nodesetForm, true);
|
||||
|
||||
// Select new tab
|
||||
tab.select(tabId);
|
||||
}
|
||||
|
||||
/**
|
||||
* Update nodeset status
|
||||
*
|
||||
* @param data Data returned from HTTP request
|
||||
*/
|
||||
function updateNodesetStatus(data) {
|
||||
// Get ajax response
|
||||
var rsp = data.rsp;
|
||||
var args = data.msg.split(';');
|
||||
var cmd = args[0].replace('cmd=', '');
|
||||
|
||||
// Get nodeset instance
|
||||
var inst = args[1].replace('inst=', '');
|
||||
// Get status bar ID
|
||||
var statBarId = 'nodesetStatusBar' + inst;
|
||||
// Get tab ID
|
||||
var tabId = 'nodesetTab' + inst;
|
||||
|
||||
// Get nodes
|
||||
var tgts = $('#' + tabId + ' input[name=target]').val();
|
||||
// Get operating system image
|
||||
var os = $('#' + tabId + ' select[name=os]').val();
|
||||
|
||||
/**
|
||||
* (2) Update /etc/hosts
|
||||
*/
|
||||
if (cmd == 'nodeadd') {
|
||||
if (rsp.length) {
|
||||
$('#' + statBarId).find('img').hide();
|
||||
$('#' + statBarId).find('div').append('<pre>(Error) Failed to create node definition</pre>');
|
||||
} else {
|
||||
// Create target nodes string
|
||||
var tgtNodesStr = '';
|
||||
var nodes = tgts.split(',');
|
||||
|
||||
// Loop through each node
|
||||
for ( var i in nodes) {
|
||||
// If it is the 1st and only node
|
||||
if (i == 0 && i == nodes.length - 1) {
|
||||
tgtNodesStr += nodes[i];
|
||||
}
|
||||
// If it is the 1st node of many nodes
|
||||
else if (i == 0 && i != nodes.length - 1) {
|
||||
// Append a comma to the string
|
||||
tgtNodesStr += nodes[i] + ', ';
|
||||
} else {
|
||||
// If it is the last node
|
||||
if (i == nodes.length - 1) {
|
||||
// Append nothing to the string
|
||||
tgtNodesStr += nodes[i];
|
||||
} else {
|
||||
// Append a comma to the string
|
||||
tgtNodesStr += nodes[i] + ', ';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$('#' + statBarId).find('div').append('<pre>Node definition created for ' + tgtNodesStr + '</pre>');
|
||||
$.ajax( {
|
||||
url : 'lib/cmd.php',
|
||||
dataType : 'json',
|
||||
data : {
|
||||
cmd : 'makehosts',
|
||||
tgt : '',
|
||||
args : '',
|
||||
msg : 'cmd=makehosts;inst=' + inst
|
||||
},
|
||||
|
||||
success : function(data) {
|
||||
data = decodeRsp(data);
|
||||
updateNodesetStatus(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* (4) Update DNS
|
||||
*/
|
||||
else if (cmd == 'makehosts') {
|
||||
// If no output, no errors occurred
|
||||
if (rsp.length) {
|
||||
$('#' + statBarId).find('div').append('<pre>(Error) Failed to update /etc/hosts</pre>');
|
||||
} else {
|
||||
$('#' + statBarId).find('div').append('<pre>/etc/hosts updated</pre>');
|
||||
}
|
||||
|
||||
// Go straight to prepare node for boot
|
||||
$.ajax( {
|
||||
url : 'lib/cmd.php',
|
||||
dataType : 'json',
|
||||
data : {
|
||||
cmd : 'nodeset',
|
||||
tgt : tgts,
|
||||
args : 'osimage=' + os,
|
||||
msg : 'cmd=nodeset;inst=' + inst
|
||||
},
|
||||
|
||||
success : function(data) {
|
||||
data = decodeRsp(data);
|
||||
updateNodesetStatus(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* (5) Boot node from network
|
||||
*/
|
||||
else if (cmd == 'nodeset') {
|
||||
// Write ajax response to status bar
|
||||
var prg = writeRsp(rsp, '');
|
||||
$('#' + statBarId).find('div').append(prg);
|
||||
|
||||
// Hide loader
|
||||
$('#' + statBarId).find('img').hide();
|
||||
}
|
||||
}
|
||||
+934
-932
File diff suppressed because it is too large
Load Diff
+222
-219
@@ -1,220 +1,223 @@
|
||||
/**
|
||||
* Load netboot page
|
||||
*
|
||||
* @param tgtNodes Targets to run rnetboot against
|
||||
*/
|
||||
function loadNetbootPage(tgtNodes) {
|
||||
// Get node OS
|
||||
var osHash = new Object();
|
||||
var nodes = tgtNodes.split(',');
|
||||
for (var i in nodes) {
|
||||
var os = getNodeAttr(nodes[i], 'os');
|
||||
var osBase = os.match(/[a-zA-Z]+/);
|
||||
if (osBase) {
|
||||
nodes[osBase] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Get nodes tab
|
||||
var tab = getNodesTab();
|
||||
|
||||
// Generate new tab ID
|
||||
var inst = 0;
|
||||
var newTabId = 'netbootTab' + inst;
|
||||
while ($('#' + newTabId).length) {
|
||||
// If one already exists, generate another one
|
||||
inst = inst + 1;
|
||||
newTabId = 'netbootTab' + inst;
|
||||
}
|
||||
|
||||
// Create netboot form
|
||||
var netbootForm = $('<div class="form"></div>');
|
||||
|
||||
// Create status bar
|
||||
var statBarId = 'netbootStatusBar' + inst;
|
||||
var statusBar = createStatusBar(statBarId).hide();
|
||||
|
||||
// Create loader
|
||||
var loader = createLoader('netbootLoader');
|
||||
statusBar.find('div').append(loader);
|
||||
|
||||
// Create info bar
|
||||
var infoBar = createInfoBar('Cause the range of nodes to boot to network');
|
||||
netbootForm.append(statusBar, infoBar);
|
||||
|
||||
// Create VM fieldset
|
||||
var vmFS = $('<fieldset></fieldset>');
|
||||
var vmLegend = $('<legend>Virtual Machine</legend>');
|
||||
vmFS.append(vmLegend);
|
||||
netbootForm.append(vmFS);
|
||||
|
||||
var vmAttr = $('<div style="display: inline-table; vertical-align: middle;"></div>');
|
||||
vmFS.append($('<div style="display: inline-table; vertical-align: middle;"><img src="images/provision/computer.png"></img></div>'));
|
||||
vmFS.append(vmAttr);
|
||||
|
||||
// Create options fieldset
|
||||
var optionsFS = $('<fieldset></fieldset>');
|
||||
var optionsLegend = $('<legend>Options</legend>');
|
||||
optionsFS.append(optionsLegend);
|
||||
netbootForm.append(optionsFS);
|
||||
|
||||
var optionsAttr = $('<div style="display: inline-table; vertical-align: middle;"></div>');
|
||||
optionsFS.append($('<div style="display: inline-table; vertical-align: middle;"><img src="images/provision/setting.png" style="width: 70px;"></img></div>'));
|
||||
optionsFS.append(optionsAttr);
|
||||
|
||||
// Create target node or group input
|
||||
var target = $('<div><label>Target node range:</label><input type="text" name="target" value="' + tgtNodes + '" title="The node or node range to boot to network"/></div>');
|
||||
vmAttr.append(target);
|
||||
|
||||
// Create options
|
||||
var optsLabel = $('<label>Options:</label>');
|
||||
var optsList = $('<ul></ul>');
|
||||
optionsAttr.append(optsList);
|
||||
|
||||
// Create boot order checkbox
|
||||
var opt = $('<li></li>');
|
||||
var bootOrderChkBox = $('<input type="checkbox" id="s" name="s"/>');
|
||||
opt.append(bootOrderChkBox);
|
||||
opt.append('Set the boot device order');
|
||||
optsList.append(opt);
|
||||
// Create boot order input
|
||||
var bootOrder = $('<li><label>Boot order:</label><input type="text" name="bootOrder"/></li>');
|
||||
bootOrder.hide();
|
||||
optsList.append(bootOrder);
|
||||
|
||||
// Create force reboot checkbox
|
||||
optsList.append('<li><input type="checkbox" id="F" name="F"/>Force reboot</li>');
|
||||
// Create force shutdown checkbox
|
||||
optsList.append('<li><input type="checkbox" id="f" name="f"/>Force immediate shutdown of the partition</li>');
|
||||
if (osHash['AIX']) {
|
||||
// Create iscsi dump checkbox
|
||||
optsList.append('<li><input type="checkbox" id="I" name="I"/>Do a iscsi dump on AIX</li>');
|
||||
}
|
||||
|
||||
// Show boot order when checkbox is checked
|
||||
bootOrderChkBox.bind('click', function(event) {
|
||||
if ($(this).is(':checked')) {
|
||||
bootOrder.show();
|
||||
} else {
|
||||
bootOrder.hide();
|
||||
}
|
||||
});
|
||||
|
||||
// Determine plugin
|
||||
var tmp = tgtNodes.split(',');
|
||||
for ( var i = 0; i < tmp.length; i++) {
|
||||
var mgt = getNodeAttr(tmp[i], 'mgt');
|
||||
// If it is zvm
|
||||
if (mgt == 'zvm') {
|
||||
// Add IPL input
|
||||
optsList.append('<div><label style="width: 40px;">IPL:</label><input type="text" name="ipl" title="The virtual address to IPL"/></div>');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Generate tooltips
|
||||
netbootForm.find('div input[title]').tooltip({
|
||||
position: "center right",
|
||||
offset: [-2, 10],
|
||||
effect: "fade",
|
||||
opacity: 0.7,
|
||||
predelay: 800,
|
||||
events : {
|
||||
def : "mouseover,mouseout",
|
||||
input : "mouseover,mouseout",
|
||||
widget : "focus mouseover,blur mouseout",
|
||||
tooltip : "mouseover,mouseout"
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Ok
|
||||
*/
|
||||
var okBtn = createButton('Ok');
|
||||
okBtn.css({
|
||||
'width': '80px',
|
||||
'display': 'block'
|
||||
});
|
||||
okBtn.bind('click', function(event) {
|
||||
// Remove any warning messages
|
||||
$(this).parents('.ui-tabs-panel').find('.ui-state-error').remove();
|
||||
|
||||
// Check inputs
|
||||
var ready = true;
|
||||
var inputs = $("#" + newTabId + " input[type='text']:visible");
|
||||
for ( var i = 0; i < inputs.length; i++) {
|
||||
if (!inputs.eq(i).val()) {
|
||||
inputs.eq(i).css('border', 'solid #FF0000 1px');
|
||||
ready = false;
|
||||
} else {
|
||||
inputs.eq(i).css('border', 'solid #BDBDBD 1px');
|
||||
}
|
||||
}
|
||||
|
||||
// Generate arguments
|
||||
var chkBoxes = $("#" + newTabId + " input[type='checkbox']:checked");
|
||||
var optStr = '';
|
||||
var opt;
|
||||
for ( var i = 0; i < chkBoxes.length; i++) {
|
||||
opt = chkBoxes.eq(i).attr('name');
|
||||
optStr += '-' + opt;
|
||||
|
||||
// If it is the boot order
|
||||
if (opt == 's') {
|
||||
// Get the boot order
|
||||
optStr += ';' + $('#' + newTabId + ' input[name=bootOrder]').val();
|
||||
}
|
||||
|
||||
// Append ; to end of string
|
||||
if (i < (chkBoxes.length - 1)) {
|
||||
optStr += ';';
|
||||
}
|
||||
}
|
||||
|
||||
// If no inputs are empty
|
||||
if (ready) {
|
||||
// Get nodes
|
||||
var tgts = $('#' + newTabId + ' input[name=target]').val();
|
||||
|
||||
// Get IPL address
|
||||
var ipl = $('#' + newTabId + ' input[name=ipl]');
|
||||
if (ipl) {
|
||||
optStr += 'ipl=' + ipl.val();
|
||||
}
|
||||
|
||||
// Disable all inputs and Ok button
|
||||
$('#' + newTabId + ' input').attr('disabled', 'disabled');
|
||||
$(this).attr('disabled', 'true');
|
||||
|
||||
/**
|
||||
* (1) Boot to network
|
||||
*/
|
||||
$.ajax( {
|
||||
url : 'lib/cmd.php',
|
||||
dataType : 'json',
|
||||
data : {
|
||||
cmd : 'rnetboot',
|
||||
tgt : tgts,
|
||||
args : optStr,
|
||||
msg : 'out=' + statBarId + ';cmd=rnetboot;tgt=' + tgts
|
||||
},
|
||||
|
||||
success : updateStatusBar
|
||||
});
|
||||
|
||||
// Show status bar
|
||||
statusBar.show();
|
||||
} else {
|
||||
// Show warning message
|
||||
var warn = createWarnBar('Please provide a value for each missing field.');
|
||||
warn.prependTo($(this).parents('.ui-tabs-panel'));
|
||||
}
|
||||
});
|
||||
netbootForm.append(okBtn);
|
||||
|
||||
// Append to discover tab
|
||||
tab.add(newTabId, 'Boot', netbootForm, true);
|
||||
|
||||
// Select new tab
|
||||
tab.select(newTabId);
|
||||
/**
|
||||
* Load netboot page
|
||||
*
|
||||
* @param tgtNodes Targets to run rnetboot against
|
||||
*/
|
||||
function loadNetbootPage(tgtNodes) {
|
||||
// Get node OS
|
||||
var osHash = new Object();
|
||||
var nodes = tgtNodes.split(',');
|
||||
for (var i in nodes) {
|
||||
var os = getNodeAttr(nodes[i], 'os');
|
||||
var osBase = os.match(/[a-zA-Z]+/);
|
||||
if (osBase) {
|
||||
nodes[osBase] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Get nodes tab
|
||||
var tab = getNodesTab();
|
||||
|
||||
// Generate new tab ID
|
||||
var inst = 0;
|
||||
var newTabId = 'netbootTab' + inst;
|
||||
while ($('#' + newTabId).length) {
|
||||
// If one already exists, generate another one
|
||||
inst = inst + 1;
|
||||
newTabId = 'netbootTab' + inst;
|
||||
}
|
||||
|
||||
// Create netboot form
|
||||
var netbootForm = $('<div class="form"></div>');
|
||||
|
||||
// Create status bar
|
||||
var statBarId = 'netbootStatusBar' + inst;
|
||||
var statusBar = createStatusBar(statBarId).hide();
|
||||
|
||||
// Create loader
|
||||
var loader = createLoader('netbootLoader');
|
||||
statusBar.find('div').append(loader);
|
||||
|
||||
// Create info bar
|
||||
var infoBar = createInfoBar('Cause the range of nodes to boot to network');
|
||||
netbootForm.append(statusBar, infoBar);
|
||||
|
||||
// Create VM fieldset
|
||||
var vmFS = $('<fieldset></fieldset>');
|
||||
var vmLegend = $('<legend>Virtual Machine</legend>');
|
||||
vmFS.append(vmLegend);
|
||||
netbootForm.append(vmFS);
|
||||
|
||||
var vmAttr = $('<div style="display: inline-table; vertical-align: middle;"></div>');
|
||||
vmFS.append($('<div style="display: inline-table; vertical-align: middle;"><img src="images/provision/computer.png"></img></div>'));
|
||||
vmFS.append(vmAttr);
|
||||
|
||||
// Create options fieldset
|
||||
var optionsFS = $('<fieldset></fieldset>');
|
||||
var optionsLegend = $('<legend>Options</legend>');
|
||||
optionsFS.append(optionsLegend);
|
||||
netbootForm.append(optionsFS);
|
||||
|
||||
var optionsAttr = $('<div style="display: inline-table; vertical-align: middle;"></div>');
|
||||
optionsFS.append($('<div style="display: inline-table; vertical-align: middle;"><img src="images/provision/setting.png" style="width: 70px;"></img></div>'));
|
||||
optionsFS.append(optionsAttr);
|
||||
|
||||
// Create target node or group input
|
||||
var target = $('<div><label>Target node range:</label><input type="text" name="target" value="' + tgtNodes + '" title="The node or node range to boot to network"/></div>');
|
||||
vmAttr.append(target);
|
||||
|
||||
// Create options
|
||||
var optsLabel = $('<label>Options:</label>');
|
||||
var optsList = $('<ul></ul>');
|
||||
optionsAttr.append(optsList);
|
||||
|
||||
// Create boot order checkbox
|
||||
var opt = $('<li></li>');
|
||||
var bootOrderChkBox = $('<input type="checkbox" id="s" name="s"/>');
|
||||
opt.append(bootOrderChkBox);
|
||||
opt.append('Set the boot device order');
|
||||
optsList.append(opt);
|
||||
// Create boot order input
|
||||
var bootOrder = $('<li><label>Boot order:</label><input type="text" name="bootOrder"/></li>');
|
||||
bootOrder.hide();
|
||||
optsList.append(bootOrder);
|
||||
|
||||
// Create force reboot checkbox
|
||||
optsList.append('<li><input type="checkbox" id="F" name="F"/>Force reboot</li>');
|
||||
// Create force shutdown checkbox
|
||||
optsList.append('<li><input type="checkbox" id="f" name="f"/>Force immediate shutdown of the partition</li>');
|
||||
if (osHash['AIX']) {
|
||||
// Create iscsi dump checkbox
|
||||
optsList.append('<li><input type="checkbox" id="I" name="I"/>Do a iscsi dump on AIX</li>');
|
||||
}
|
||||
|
||||
// Show boot order when checkbox is checked
|
||||
bootOrderChkBox.bind('click', function(event) {
|
||||
if ($(this).is(':checked')) {
|
||||
bootOrder.show();
|
||||
} else {
|
||||
bootOrder.hide();
|
||||
}
|
||||
});
|
||||
|
||||
// Determine plugin
|
||||
var tmp = tgtNodes.split(',');
|
||||
for ( var i = 0; i < tmp.length; i++) {
|
||||
var mgt = getNodeAttr(tmp[i], 'mgt');
|
||||
// If it is zvm
|
||||
if (mgt == 'zvm') {
|
||||
// Add IPL input
|
||||
optsList.append('<div><label style="width: 40px;">IPL:</label><input type="text" name="ipl" title="The virtual address to IPL"/></div>');
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Generate tooltips
|
||||
netbootForm.find('div input[title]').tooltip({
|
||||
position: "center right",
|
||||
offset: [-2, 10],
|
||||
effect: "fade",
|
||||
opacity: 0.7,
|
||||
predelay: 800,
|
||||
events : {
|
||||
def : "mouseover,mouseout",
|
||||
input : "mouseover,mouseout",
|
||||
widget : "focus mouseover,blur mouseout",
|
||||
tooltip : "mouseover,mouseout"
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Ok
|
||||
*/
|
||||
var okBtn = createButton('Ok');
|
||||
okBtn.css({
|
||||
'width': '80px',
|
||||
'display': 'block'
|
||||
});
|
||||
okBtn.bind('click', function(event) {
|
||||
// Remove any warning messages
|
||||
$(this).parents('.ui-tabs-panel').find('.ui-state-error').remove();
|
||||
|
||||
// Check inputs
|
||||
var ready = true;
|
||||
var inputs = $("#" + newTabId + " input[type='text']:visible");
|
||||
for ( var i = 0; i < inputs.length; i++) {
|
||||
if (!inputs.eq(i).val()) {
|
||||
inputs.eq(i).css('border', 'solid #FF0000 1px');
|
||||
ready = false;
|
||||
} else {
|
||||
inputs.eq(i).css('border', 'solid #BDBDBD 1px');
|
||||
}
|
||||
}
|
||||
|
||||
// Generate arguments
|
||||
var chkBoxes = $("#" + newTabId + " input[type='checkbox']:checked");
|
||||
var optStr = '';
|
||||
var opt;
|
||||
for ( var i = 0; i < chkBoxes.length; i++) {
|
||||
opt = chkBoxes.eq(i).attr('name');
|
||||
optStr += '-' + opt;
|
||||
|
||||
// If it is the boot order
|
||||
if (opt == 's') {
|
||||
// Get the boot order
|
||||
optStr += ';' + $('#' + newTabId + ' input[name=bootOrder]').val();
|
||||
}
|
||||
|
||||
// Append ; to end of string
|
||||
if (i < (chkBoxes.length - 1)) {
|
||||
optStr += ';';
|
||||
}
|
||||
}
|
||||
|
||||
// If no inputs are empty
|
||||
if (ready) {
|
||||
// Get nodes
|
||||
var tgts = $('#' + newTabId + ' input[name=target]').val();
|
||||
|
||||
// Get IPL address
|
||||
var ipl = $('#' + newTabId + ' input[name=ipl]');
|
||||
if (ipl) {
|
||||
optStr += 'ipl=' + ipl.val();
|
||||
}
|
||||
|
||||
// Disable all inputs and Ok button
|
||||
$('#' + newTabId + ' input').attr('disabled', 'disabled');
|
||||
$(this).attr('disabled', 'true');
|
||||
|
||||
/**
|
||||
* (1) Boot to network
|
||||
*/
|
||||
$.ajax( {
|
||||
url : 'lib/cmd.php',
|
||||
dataType : 'json',
|
||||
data : {
|
||||
cmd : 'rnetboot',
|
||||
tgt : tgts,
|
||||
args : optStr,
|
||||
msg : 'out=' + statBarId + ';cmd=rnetboot;tgt=' + tgts
|
||||
},
|
||||
|
||||
success : function(data) {
|
||||
data = decodeRsp(data);
|
||||
updateStatusBar(data);
|
||||
}
|
||||
});
|
||||
|
||||
// Show status bar
|
||||
statusBar.show();
|
||||
} else {
|
||||
// Show warning message
|
||||
var warn = createWarnBar('Please provide a value for each missing field.');
|
||||
warn.prependTo($(this).parents('.ui-tabs-panel'));
|
||||
}
|
||||
});
|
||||
netbootForm.append(okBtn);
|
||||
|
||||
// Append to discover tab
|
||||
tab.add(newTabId, 'Boot', netbootForm, true);
|
||||
|
||||
// Select new tab
|
||||
tab.select(newTabId);
|
||||
}
|
||||
+173
-170
@@ -1,171 +1,174 @@
|
||||
/**
|
||||
* Load rscan page
|
||||
*
|
||||
* @param tgtNodes Targets to run rscan against
|
||||
*/
|
||||
function loadRscanPage(tgtNodes) {
|
||||
// Get node OS
|
||||
var osHash = new Object();
|
||||
var nodes = tgtNodes.split(',');
|
||||
for (var i in nodes) {
|
||||
var os = getNodeAttr(nodes[i], 'os');
|
||||
var osBase = os.match(/[a-zA-Z]+/);
|
||||
if (osBase) {
|
||||
nodes[osBase] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Get nodes tab
|
||||
var tab = getNodesTab();
|
||||
|
||||
// Generate new tab ID
|
||||
var inst = 0;
|
||||
var newTabId = 'rscanTab' + inst;
|
||||
while ($('#' + newTabId).length) {
|
||||
// If one already exists, generate another one
|
||||
inst = inst + 1;
|
||||
newTabId = 'rscanTab' + inst;
|
||||
}
|
||||
|
||||
// Create rscan form
|
||||
var rscanForm = $('<div class="form"></div>');
|
||||
|
||||
// Create status bar
|
||||
var statBarId = 'rscanStatusBar' + inst;
|
||||
var statBar = createStatusBar(statBarId).hide();
|
||||
|
||||
// Create loader
|
||||
var loader = createLoader('rscanLoader');
|
||||
statBar.find('div').append(loader);
|
||||
|
||||
// Create info bar
|
||||
var infoBar = createInfoBar('Collects node information from one or more hardware control points');
|
||||
rscanForm.append(statBar, infoBar);
|
||||
|
||||
// Create VM fieldset
|
||||
var vmFS = $('<fieldset></fieldset>');
|
||||
var vmLegend = $('<legend>Virtual Machine</legend>');
|
||||
vmFS.append(vmLegend);
|
||||
rscanForm.append(vmFS);
|
||||
|
||||
var vmAttr = $('<div style="display: inline-table; vertical-align: middle;"></div>');
|
||||
vmFS.append($('<div style="display: inline-table; vertical-align: middle;"><img src="images/provision/computer.png"></img></div>'));
|
||||
vmFS.append(vmAttr);
|
||||
|
||||
// Create options fieldset
|
||||
var optionsFS = $('<fieldset></fieldset>');
|
||||
var optionsLegend = $('<legend>Options</legend>');
|
||||
optionsFS.append(optionsLegend);
|
||||
rscanForm.append(optionsFS);
|
||||
|
||||
var optionsAttr = $('<div style="display: inline-table; vertical-align: middle;"></div>');
|
||||
optionsFS.append($('<div style="display: inline-table; vertical-align: middle;"><img src="images/provision/setting.png" style="width: 70px;"></img></div>'));
|
||||
optionsFS.append(optionsAttr);
|
||||
|
||||
// Create target node or group input
|
||||
var target = $('<div><label>Target node range:</label><input type="text" name="target" value="' + tgtNodes + '" title="The node or node range to scan"/></div>');
|
||||
vmAttr.append(target);
|
||||
|
||||
// Create options
|
||||
var optsList = $('<ul></ul>');
|
||||
optionsAttr.append(optsList);
|
||||
|
||||
optsList.append('<li><input type="checkbox" name="u"/>Updates and then prints out node definitions in the xCAT database for CEC/BPA</li>');
|
||||
optsList.append('<li><input type="checkbox" name="w"/>Writes output to xCAT database</li>');
|
||||
optsList.append('<li><input type="checkbox" name="x"/>XML format</li>');
|
||||
optsList.append('<li><input type="checkbox" name="z"/>Stanza formated output</li>');
|
||||
|
||||
// Generate tooltips
|
||||
rscanForm.find('div input[title]').tooltip({
|
||||
position: "center right",
|
||||
offset: [-2, 10],
|
||||
effect: "fade",
|
||||
opacity: 0.7,
|
||||
predelay: 800,
|
||||
events : {
|
||||
def : "mouseover,mouseout",
|
||||
input : "mouseover,mouseout",
|
||||
widget : "focus mouseover,blur mouseout",
|
||||
tooltip : "mouseover,mouseout"
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Ok
|
||||
*/
|
||||
var okBtn = createButton('Ok');
|
||||
okBtn.css({
|
||||
'width': '80px',
|
||||
'display': 'block'
|
||||
});
|
||||
okBtn.bind('click', function(event) {
|
||||
// Remove any warning messages
|
||||
$(this).parents('.ui-tabs-panel').find('.ui-state-error').remove();
|
||||
|
||||
// Check inputs
|
||||
var ready = true;
|
||||
var inputs = $("#" + newTabId + " input[type='text']");
|
||||
for ( var i = 0; i < inputs.length; i++) {
|
||||
if (!inputs.eq(i).val()) {
|
||||
inputs.eq(i).css('border', 'solid #FF0000 1px');
|
||||
ready = false;
|
||||
} else {
|
||||
inputs.eq(i).css('border', 'solid #BDBDBD 1px');
|
||||
}
|
||||
}
|
||||
|
||||
// Generate arguments
|
||||
var chkBoxes = $("#" + newTabId + " input[type='checkbox']:checked");
|
||||
var optStr = '';
|
||||
var opt;
|
||||
for ( var i = 0; i < chkBoxes.length; i++) {
|
||||
opt = chkBoxes.eq(i).attr('name');
|
||||
optStr += '-' + opt;
|
||||
|
||||
// Append ; to end of string
|
||||
if (i < (chkBoxes.length - 1)) {
|
||||
optStr += ';';
|
||||
}
|
||||
}
|
||||
|
||||
// If no inputs are empty
|
||||
if (ready) {
|
||||
// Get nodes
|
||||
var tgts = $('#' + newTabId + ' input[name=target]').val();
|
||||
|
||||
// Disable all inputs and Ok button
|
||||
$('#' + newTabId + ' input').attr('disabled', 'disabled');
|
||||
$(this).attr('disabled', 'true');
|
||||
|
||||
/**
|
||||
* (1) Scan
|
||||
*/
|
||||
$.ajax( {
|
||||
url : 'lib/cmd.php',
|
||||
dataType : 'json',
|
||||
data : {
|
||||
cmd : 'rscan',
|
||||
tgt : tgts,
|
||||
args : optStr,
|
||||
msg : 'out=' + statBarId + ';cmd=rscan;tgt=' + tgts
|
||||
},
|
||||
|
||||
success : updateStatusBar
|
||||
});
|
||||
|
||||
// Show status bar
|
||||
statBar.show();
|
||||
} else {
|
||||
// Show warning message
|
||||
var warn = createWarnBar('Please provide a value for each missing field.');
|
||||
warn.prependTo($(this).parents('.ui-tabs-panel'));
|
||||
}
|
||||
});
|
||||
rscanForm.append(okBtn);
|
||||
|
||||
// Append to discover tab
|
||||
tab.add(newTabId, 'Scan', rscanForm, true);
|
||||
|
||||
// Select new tab
|
||||
tab.select(newTabId);
|
||||
/**
|
||||
* Load rscan page
|
||||
*
|
||||
* @param tgtNodes Targets to run rscan against
|
||||
*/
|
||||
function loadRscanPage(tgtNodes) {
|
||||
// Get node OS
|
||||
var osHash = new Object();
|
||||
var nodes = tgtNodes.split(',');
|
||||
for (var i in nodes) {
|
||||
var os = getNodeAttr(nodes[i], 'os');
|
||||
var osBase = os.match(/[a-zA-Z]+/);
|
||||
if (osBase) {
|
||||
nodes[osBase] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Get nodes tab
|
||||
var tab = getNodesTab();
|
||||
|
||||
// Generate new tab ID
|
||||
var inst = 0;
|
||||
var newTabId = 'rscanTab' + inst;
|
||||
while ($('#' + newTabId).length) {
|
||||
// If one already exists, generate another one
|
||||
inst = inst + 1;
|
||||
newTabId = 'rscanTab' + inst;
|
||||
}
|
||||
|
||||
// Create rscan form
|
||||
var rscanForm = $('<div class="form"></div>');
|
||||
|
||||
// Create status bar
|
||||
var statBarId = 'rscanStatusBar' + inst;
|
||||
var statBar = createStatusBar(statBarId).hide();
|
||||
|
||||
// Create loader
|
||||
var loader = createLoader('rscanLoader');
|
||||
statBar.find('div').append(loader);
|
||||
|
||||
// Create info bar
|
||||
var infoBar = createInfoBar('Collects node information from one or more hardware control points');
|
||||
rscanForm.append(statBar, infoBar);
|
||||
|
||||
// Create VM fieldset
|
||||
var vmFS = $('<fieldset></fieldset>');
|
||||
var vmLegend = $('<legend>Virtual Machine</legend>');
|
||||
vmFS.append(vmLegend);
|
||||
rscanForm.append(vmFS);
|
||||
|
||||
var vmAttr = $('<div style="display: inline-table; vertical-align: middle;"></div>');
|
||||
vmFS.append($('<div style="display: inline-table; vertical-align: middle;"><img src="images/provision/computer.png"></img></div>'));
|
||||
vmFS.append(vmAttr);
|
||||
|
||||
// Create options fieldset
|
||||
var optionsFS = $('<fieldset></fieldset>');
|
||||
var optionsLegend = $('<legend>Options</legend>');
|
||||
optionsFS.append(optionsLegend);
|
||||
rscanForm.append(optionsFS);
|
||||
|
||||
var optionsAttr = $('<div style="display: inline-table; vertical-align: middle;"></div>');
|
||||
optionsFS.append($('<div style="display: inline-table; vertical-align: middle;"><img src="images/provision/setting.png" style="width: 70px;"></img></div>'));
|
||||
optionsFS.append(optionsAttr);
|
||||
|
||||
// Create target node or group input
|
||||
var target = $('<div><label>Target node range:</label><input type="text" name="target" value="' + tgtNodes + '" title="The node or node range to scan"/></div>');
|
||||
vmAttr.append(target);
|
||||
|
||||
// Create options
|
||||
var optsList = $('<ul></ul>');
|
||||
optionsAttr.append(optsList);
|
||||
|
||||
optsList.append('<li><input type="checkbox" name="u"/>Updates and then prints out node definitions in the xCAT database for CEC/BPA</li>');
|
||||
optsList.append('<li><input type="checkbox" name="w"/>Writes output to xCAT database</li>');
|
||||
optsList.append('<li><input type="checkbox" name="x"/>XML format</li>');
|
||||
optsList.append('<li><input type="checkbox" name="z"/>Stanza formated output</li>');
|
||||
|
||||
// Generate tooltips
|
||||
rscanForm.find('div input[title]').tooltip({
|
||||
position: "center right",
|
||||
offset: [-2, 10],
|
||||
effect: "fade",
|
||||
opacity: 0.7,
|
||||
predelay: 800,
|
||||
events : {
|
||||
def : "mouseover,mouseout",
|
||||
input : "mouseover,mouseout",
|
||||
widget : "focus mouseover,blur mouseout",
|
||||
tooltip : "mouseover,mouseout"
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Ok
|
||||
*/
|
||||
var okBtn = createButton('Ok');
|
||||
okBtn.css({
|
||||
'width': '80px',
|
||||
'display': 'block'
|
||||
});
|
||||
okBtn.bind('click', function(event) {
|
||||
// Remove any warning messages
|
||||
$(this).parents('.ui-tabs-panel').find('.ui-state-error').remove();
|
||||
|
||||
// Check inputs
|
||||
var ready = true;
|
||||
var inputs = $("#" + newTabId + " input[type='text']");
|
||||
for ( var i = 0; i < inputs.length; i++) {
|
||||
if (!inputs.eq(i).val()) {
|
||||
inputs.eq(i).css('border', 'solid #FF0000 1px');
|
||||
ready = false;
|
||||
} else {
|
||||
inputs.eq(i).css('border', 'solid #BDBDBD 1px');
|
||||
}
|
||||
}
|
||||
|
||||
// Generate arguments
|
||||
var chkBoxes = $("#" + newTabId + " input[type='checkbox']:checked");
|
||||
var optStr = '';
|
||||
var opt;
|
||||
for ( var i = 0; i < chkBoxes.length; i++) {
|
||||
opt = chkBoxes.eq(i).attr('name');
|
||||
optStr += '-' + opt;
|
||||
|
||||
// Append ; to end of string
|
||||
if (i < (chkBoxes.length - 1)) {
|
||||
optStr += ';';
|
||||
}
|
||||
}
|
||||
|
||||
// If no inputs are empty
|
||||
if (ready) {
|
||||
// Get nodes
|
||||
var tgts = $('#' + newTabId + ' input[name=target]').val();
|
||||
|
||||
// Disable all inputs and Ok button
|
||||
$('#' + newTabId + ' input').attr('disabled', 'disabled');
|
||||
$(this).attr('disabled', 'true');
|
||||
|
||||
/**
|
||||
* (1) Scan
|
||||
*/
|
||||
$.ajax( {
|
||||
url : 'lib/cmd.php',
|
||||
dataType : 'json',
|
||||
data : {
|
||||
cmd : 'rscan',
|
||||
tgt : tgts,
|
||||
args : optStr,
|
||||
msg : 'out=' + statBarId + ';cmd=rscan;tgt=' + tgts
|
||||
},
|
||||
|
||||
success : function(data) {
|
||||
data = decodeRsp(data);
|
||||
updateStatusBar(data);
|
||||
}
|
||||
});
|
||||
|
||||
// Show status bar
|
||||
statBar.show();
|
||||
} else {
|
||||
// Show warning message
|
||||
var warn = createWarnBar('Please provide a value for each missing field.');
|
||||
warn.prependTo($(this).parents('.ui-tabs-panel'));
|
||||
}
|
||||
});
|
||||
rscanForm.append(okBtn);
|
||||
|
||||
// Append to discover tab
|
||||
tab.add(newTabId, 'Scan', rscanForm, true);
|
||||
|
||||
// Select new tab
|
||||
tab.select(newTabId);
|
||||
}
|
||||
+408
-402
@@ -1,403 +1,409 @@
|
||||
/**
|
||||
* Load updatenode page
|
||||
*
|
||||
* @param tgtNodes Targets to run updatenode against
|
||||
*/
|
||||
function loadUpdatenodePage(tgtNodes) {
|
||||
// Get OS images
|
||||
$.ajax({
|
||||
url : 'lib/cmd.php',
|
||||
dataType : 'json',
|
||||
data : {
|
||||
cmd : 'tabdump',
|
||||
tgt : '',
|
||||
args : 'osimage',
|
||||
msg : ''
|
||||
},
|
||||
|
||||
success : setOSImageCookies
|
||||
});
|
||||
|
||||
// Get node OS
|
||||
var osHash = new Object();
|
||||
var nodes = tgtNodes.split(',');
|
||||
for (var i in nodes) {
|
||||
var os = getNodeAttr(nodes[i], 'os');
|
||||
var osBase = os.match(/[a-zA-Z]+/);
|
||||
if (osBase) {
|
||||
nodes[osBase] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Get nodes tab
|
||||
var tab = getNodesTab();
|
||||
|
||||
// Generate new tab ID
|
||||
var inst = 0;
|
||||
var newTabId = 'updatenodeTab' + inst;
|
||||
while ($('#' + newTabId).length) {
|
||||
// If one already exists, generate another one
|
||||
inst = inst + 1;
|
||||
newTabId = 'updatenodeTab' + inst;
|
||||
}
|
||||
|
||||
// Create rscan form
|
||||
var updatenodeForm = $('<div class="form"></div>');
|
||||
|
||||
// Create status bar
|
||||
var statBarId = 'updatenodeStatusBar' + inst;
|
||||
var statusBar = createStatusBar(statBarId).hide();
|
||||
|
||||
// Create loader
|
||||
var loader = createLoader('updatenodeLoader');
|
||||
statusBar.find('div').append(loader);
|
||||
|
||||
// Create info bar
|
||||
var infoBar = createInfoBar('Update nodes in an xCAT environment');
|
||||
updatenodeForm.append(statusBar, infoBar);
|
||||
|
||||
// Create VM fieldset
|
||||
var vmFS = $('<fieldset></fieldset>');
|
||||
var vmLegend = $('<legend>Virtual Machine</legend>');
|
||||
vmFS.append(vmLegend);
|
||||
updatenodeForm.append(vmFS);
|
||||
|
||||
var vmAttr = $('<div style="display: inline-table; vertical-align: middle;"></div>');
|
||||
vmFS.append($('<div style="display: inline-table; vertical-align: middle;"><img src="images/provision/computer.png"></img></div>'));
|
||||
vmFS.append(vmAttr);
|
||||
|
||||
// Create options fieldset
|
||||
var optionsFS = $('<fieldset></fieldset>');
|
||||
var optionsLegend = $('<legend>Options</legend>');
|
||||
optionsFS.append(optionsLegend);
|
||||
updatenodeForm.append(optionsFS);
|
||||
|
||||
var optionsAttr = $('<div style="display: inline-table; vertical-align: middle;"></div>');
|
||||
optionsFS.append($('<div style="display: inline-table; vertical-align: middle;"><img src="images/provision/setting.png" style="width: 70px;"></img></div>'));
|
||||
optionsFS.append(optionsAttr);
|
||||
|
||||
// Create target node or group input
|
||||
var tgt = $('<div><label>Target node range:</label><input type="text" name="target" value="' + tgtNodes + '" title="The node or node range to update"/></div>');
|
||||
vmAttr.append(tgt);
|
||||
|
||||
// Create options
|
||||
var optionsList = $('<ul></ul>');
|
||||
optionsAttr.append(optionsList);
|
||||
|
||||
// Create update all software checkbox (only AIX)
|
||||
if (osHash['AIX']) {
|
||||
var updateAllOption = $('<li></li>');
|
||||
var updateAllChkBox = $('<input type="checkbox" id="A" name="A"/>');
|
||||
updateAllOption.append(updateAllChkBox);
|
||||
optionsList.append(updateAllOption);
|
||||
updateAllOption.append('Install or update all software contained in the source directory');
|
||||
|
||||
// Create source directory input
|
||||
var allSwScrDirectory = $('<li><label style="vertical-align: middle">Source directory:</label><input type="text" id="allSwSrcDirectory" name="allSwSrcDirectory"/></li>');
|
||||
// Browse server directory and files
|
||||
var allSWSrcDirBrowse = createButton('Browse');
|
||||
allSWSrcDirBrowse.serverBrowser({
|
||||
onSelect : function(path) {
|
||||
$('#allSwSrcDirectory').val(path);
|
||||
},
|
||||
onLoad : function() {
|
||||
return $('#allSwSrcDirectory').val();
|
||||
},
|
||||
knownExt : [ 'exe', 'js', 'txt' ],
|
||||
knownPaths : [ {
|
||||
text : 'Install',
|
||||
image : 'desktop.png',
|
||||
path : '/install'
|
||||
} ],
|
||||
imageUrl : 'images/serverbrowser/',
|
||||
systemImageUrl : 'images/serverbrowser/',
|
||||
handlerUrl : 'lib/getpath.php',
|
||||
title : 'Browse',
|
||||
requestMethod : 'POST',
|
||||
width : '500',
|
||||
height : '300',
|
||||
basePath : '/install' // Limit user to only install directory
|
||||
});
|
||||
allSwScrDirectory.append(allSWSrcDirBrowse);
|
||||
allSwScrDirectory.hide();
|
||||
optionsList.append(allSwScrDirectory);
|
||||
|
||||
// Show source directory when checked
|
||||
updateAllChkBox.bind('click', function(event) {
|
||||
if ($(this).is(':checked')) {
|
||||
allSwScrDirectory.show();
|
||||
} else {
|
||||
allSwScrDirectory.hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Create update software checkbox
|
||||
var updateOption = $('<li></li>');
|
||||
var updateChkBox = $('<input type="checkbox" id="S" name="S"/>');
|
||||
optionsList.append(updateOption);
|
||||
updateOption.append(updateChkBox);
|
||||
updateOption.append('Update existing software');
|
||||
|
||||
// Create source directory input
|
||||
var scrDirectory = $('<li><label style="vertical-align: middle">Source directory:</label><input type="text" id="srcDirectory" name="srcDirectory" title="You must give the source directory containing the updated software packages"/></li>');
|
||||
// Browse server directory and files
|
||||
var srcDirBrowse = createButton('Browse');
|
||||
srcDirBrowse.serverBrowser({
|
||||
onSelect : function(path) {
|
||||
$('#srcDirectory').val(path);
|
||||
},
|
||||
onLoad : function() {
|
||||
return $('#srcDirectory').val();
|
||||
},
|
||||
knownExt : [ 'exe', 'js', 'txt' ],
|
||||
knownPaths : [ {
|
||||
text : 'Install',
|
||||
image : 'desktop.png',
|
||||
path : '/install'
|
||||
} ],
|
||||
imageUrl : 'images/serverbrowser/',
|
||||
systemImageUrl : 'images/serverbrowser/',
|
||||
handlerUrl : 'lib/getpath.php',
|
||||
title : 'Browse',
|
||||
requestMethod : 'POST',
|
||||
width : '500',
|
||||
height : '300',
|
||||
basePath : '/install' // Limit user to only install directory
|
||||
});
|
||||
scrDirectory.append(srcDirBrowse);
|
||||
scrDirectory.hide();
|
||||
optionsList.append(scrDirectory);
|
||||
|
||||
// Create other packages input
|
||||
var otherPkgs = $('<li><label style="vertical-align: middle">otherpkgs:</label><input type="text" id="otherpkgs" name="otherpkgs"/></li>');
|
||||
otherPkgs.hide();
|
||||
optionsList.append(otherPkgs);
|
||||
|
||||
// Create RPM flags input (only AIX)
|
||||
var aixRpmFlags = $('<li><label>rpm_flags:</label><input type="text" name="rpm_flags"/></li>');
|
||||
aixRpmFlags.hide();
|
||||
optionsList.append(aixRpmFlags);
|
||||
|
||||
// Create installp flags input (only AIX)
|
||||
var aixInstallPFlags = $('<li><label>installp_flags:</label><input type="text" name="installp_flags"/></li>');
|
||||
aixInstallPFlags.hide();
|
||||
optionsList.append(aixInstallPFlags);
|
||||
|
||||
// Create emgr flags input (only AIX)
|
||||
var aixEmgrFlags = $('<li><label>emgr_flags:</label><input type="text" name="emgr_flags"/></li>');
|
||||
aixEmgrFlags.hide();
|
||||
optionsList.append(aixEmgrFlags);
|
||||
|
||||
// Show flags when checked
|
||||
updateChkBox.bind('click', function(event) {
|
||||
if ($(this).is(':checked')) {
|
||||
scrDirectory.show();
|
||||
otherPkgs.show();
|
||||
if (osHash['AIX']) {
|
||||
aixRpmFlags.show();
|
||||
aixInstallPFlags.show();
|
||||
aixEmgrFlags.show();
|
||||
}
|
||||
} else {
|
||||
scrDirectory.hide();
|
||||
otherPkgs.hide();
|
||||
if (osHash['AIX']) {
|
||||
aixRpmFlags.hide();
|
||||
aixInstallPFlags.hide();
|
||||
aixEmgrFlags.hide();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Create postscripts input
|
||||
var postOption = $('<li></li>');
|
||||
var postChkBox = $('<input type="checkbox" id="P" name="P"/>');
|
||||
optionsList.append(postOption);
|
||||
postOption.append(postChkBox);
|
||||
postOption.append('Run postscripts');
|
||||
var postscripts = $('<li><label style="vertical-align: middle">Postscripts:</label><input type="text" id="postscripts" name="postscripts" title="You must give the postscript(s) to run"/></li>');
|
||||
postscripts.hide();
|
||||
optionsList.append(postscripts);
|
||||
|
||||
// Show alternate source directory when checked
|
||||
postChkBox.bind('click', function(event) {
|
||||
if ($(this).is(':checked')) {
|
||||
postscripts.show();
|
||||
} else {
|
||||
postscripts.hide();
|
||||
}
|
||||
});
|
||||
optionsList.append('<li><input type="checkbox" id="F" name="F"/>Distribute and synchronize files</li>');
|
||||
optionsList.append('<li><input type="checkbox" id="k" name="k"/>Update the ssh keys and host keys for the service nodes and compute nodes</li>');
|
||||
|
||||
// Create update OS checkbox
|
||||
if (!osHash['AIX']) {
|
||||
var osOption = $('<li></li>');
|
||||
var osChkBox = $('<input type="checkbox" id="o" name="o"/>');
|
||||
optionsList.append(osOption);
|
||||
osOption.append(osChkBox);
|
||||
osOption.append('Update the operating system');
|
||||
|
||||
var os = $('<li></li>').hide();
|
||||
var osLabel = $('<label>Operating system:</label>');
|
||||
var osInput = $('<input type="text" name="os" title="You must give the operating system to upgrade to, e.g. rhel5.5"/>');
|
||||
osInput.one('focus', function(){
|
||||
var tmp = $.cookie('xcat_osvers');
|
||||
if (tmp) {
|
||||
// Turn on auto complete
|
||||
$(this).autocomplete({
|
||||
source: tmp.split(',')
|
||||
});
|
||||
}
|
||||
});
|
||||
os.append(osLabel);
|
||||
os.append(osInput);
|
||||
optionsList.append(os);
|
||||
|
||||
// Show alternate source directory when checked
|
||||
osChkBox.bind('click', function(event) {
|
||||
if ($(this).is(':checked')) {
|
||||
os.show();
|
||||
} else {
|
||||
os.hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Generate tooltips
|
||||
updatenodeForm.find('div input[title]').tooltip({
|
||||
position: "center right",
|
||||
offset: [-2, 10],
|
||||
effect: "fade",
|
||||
opacity: 0.7,
|
||||
predelay: 800,
|
||||
events : {
|
||||
def : "mouseover,mouseout",
|
||||
input : "mouseover,mouseout",
|
||||
widget : "focus mouseover,blur mouseout",
|
||||
tooltip : "mouseover,mouseout"
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Ok
|
||||
*/
|
||||
var updateBtn = createButton('Update');
|
||||
updateBtn.css({
|
||||
'width': '80px',
|
||||
'display': 'block'
|
||||
});
|
||||
updateBtn.bind('click', function(event) {
|
||||
// Remove any warning messages
|
||||
$(this).parents('.ui-tabs-panel').find('.ui-state-error').remove();
|
||||
var ready = true;
|
||||
|
||||
// Generate arguments
|
||||
var chkBoxes = $("#" + newTabId + " input[type='checkbox']:checked");
|
||||
var optionsStr = '';
|
||||
var option;
|
||||
for ( var i = 0; i < chkBoxes.length; i++) {
|
||||
option = chkBoxes.eq(i).attr('name');
|
||||
optionsStr += '-' + option;
|
||||
|
||||
// If update all software is checked
|
||||
if (option == 'S') {
|
||||
var srcDir = $('#' + newTabId + ' input[name=allSwSrcDirectory]').val();
|
||||
if (srcDir) {
|
||||
optionsStr += ';-d ' + srcDir;
|
||||
}
|
||||
}
|
||||
|
||||
// If update software is checked
|
||||
if (option == 'S') {
|
||||
// Get source directory
|
||||
var srcDirectory = $('#' + newTabId + ' input[name=srcDirectory]').val();
|
||||
if (srcDirectory) {
|
||||
optionsStr += ';-d;' + srcDirectory;
|
||||
}
|
||||
|
||||
// Get otherpkgs
|
||||
var otherpkgs = $('#' + newTabId + ' input[name=otherpkgs]').val();
|
||||
if (otherpkgs) {
|
||||
optionsStr += ';otherpkgs=' + otherpkgs;
|
||||
}
|
||||
|
||||
// Get rpm_flags
|
||||
var rpm_flags = $('#' + newTabId + ' input[name=rpm_flags]').val();
|
||||
if (rpm_flags) {
|
||||
optionsStr += ';rpm_flags=' + rpm_flags;
|
||||
}
|
||||
|
||||
// Get installp_flags
|
||||
var installp_flags = $('#' + newTabId + ' input[name=installp_flags]').val();
|
||||
if (installp_flags) {
|
||||
optionsStr += ';installp_flags=' + installp_flags;
|
||||
}
|
||||
|
||||
// Get emgr_flags
|
||||
var emgr_flags = $('#' + newTabId + ' input[name=emgr_flags]').val();
|
||||
if (emgr_flags) {
|
||||
optionsStr += ';emgr_flags=' + emgr_flags;
|
||||
}
|
||||
}
|
||||
|
||||
// If postscripts is checked
|
||||
if (option == 'P') {
|
||||
// Get postscripts
|
||||
optionsStr += ';' + $('#' + newTabId + ' input[name=postscripts]').val();
|
||||
}
|
||||
|
||||
// If operating system is checked
|
||||
if (option == 'o') {
|
||||
// Get the OS
|
||||
optionsStr += ';' + $('#' + newTabId + ' input[name=os]').val();
|
||||
}
|
||||
|
||||
// Append ; to end of string
|
||||
if (i < (chkBoxes.length - 1)) {
|
||||
optionsStr += ';';
|
||||
}
|
||||
}
|
||||
|
||||
// If no inputs are empty
|
||||
if (ready) {
|
||||
// Get nodes
|
||||
var tgts = $('#' + newTabId + ' input[name=target]').val();
|
||||
|
||||
// Disable all inputs and Ok button
|
||||
$('#' + newTabId + ' input').attr('disabled', 'disabled');
|
||||
$(this).attr('disabled', 'true');
|
||||
|
||||
/**
|
||||
* (1) Boot to network
|
||||
*/
|
||||
$.ajax( {
|
||||
url : 'lib/cmd.php',
|
||||
dataType : 'json',
|
||||
data : {
|
||||
cmd : 'updatenode',
|
||||
tgt : tgts,
|
||||
args : optionsStr,
|
||||
msg : 'out=' + statBarId + ';cmd=updatenode;tgt=' + tgts
|
||||
},
|
||||
|
||||
success : updateStatusBar
|
||||
});
|
||||
|
||||
// Show status bar
|
||||
statusBar.show();
|
||||
} else {
|
||||
// Show warning message
|
||||
var warn = createWarnBar('You are missing some values');
|
||||
warn.prependTo($(this).parents('.ui-tabs-panel'));
|
||||
}
|
||||
});
|
||||
updatenodeForm.append(updateBtn);
|
||||
|
||||
// Append to discover tab
|
||||
tab.add(newTabId, 'Update', updatenodeForm, true);
|
||||
|
||||
// Select new tab
|
||||
tab.select(newTabId);
|
||||
/**
|
||||
* Load updatenode page
|
||||
*
|
||||
* @param tgtNodes Targets to run updatenode against
|
||||
*/
|
||||
function loadUpdatenodePage(tgtNodes) {
|
||||
// Get OS images
|
||||
$.ajax({
|
||||
url : 'lib/cmd.php',
|
||||
dataType : 'json',
|
||||
data : {
|
||||
cmd : 'tabdump',
|
||||
tgt : '',
|
||||
args : 'osimage',
|
||||
msg : ''
|
||||
},
|
||||
|
||||
success : function(data) {
|
||||
data = decodeRsp(data);
|
||||
setOSImageCookies(data);
|
||||
}
|
||||
});
|
||||
|
||||
// Get node OS
|
||||
var osHash = new Object();
|
||||
var nodes = tgtNodes.split(',');
|
||||
for (var i in nodes) {
|
||||
var os = getNodeAttr(nodes[i], 'os');
|
||||
var osBase = os.match(/[a-zA-Z]+/);
|
||||
if (osBase) {
|
||||
nodes[osBase] = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// Get nodes tab
|
||||
var tab = getNodesTab();
|
||||
|
||||
// Generate new tab ID
|
||||
var inst = 0;
|
||||
var newTabId = 'updatenodeTab' + inst;
|
||||
while ($('#' + newTabId).length) {
|
||||
// If one already exists, generate another one
|
||||
inst = inst + 1;
|
||||
newTabId = 'updatenodeTab' + inst;
|
||||
}
|
||||
|
||||
// Create rscan form
|
||||
var updatenodeForm = $('<div class="form"></div>');
|
||||
|
||||
// Create status bar
|
||||
var statBarId = 'updatenodeStatusBar' + inst;
|
||||
var statusBar = createStatusBar(statBarId).hide();
|
||||
|
||||
// Create loader
|
||||
var loader = createLoader('updatenodeLoader');
|
||||
statusBar.find('div').append(loader);
|
||||
|
||||
// Create info bar
|
||||
var infoBar = createInfoBar('Update nodes in an xCAT environment');
|
||||
updatenodeForm.append(statusBar, infoBar);
|
||||
|
||||
// Create VM fieldset
|
||||
var vmFS = $('<fieldset></fieldset>');
|
||||
var vmLegend = $('<legend>Virtual Machine</legend>');
|
||||
vmFS.append(vmLegend);
|
||||
updatenodeForm.append(vmFS);
|
||||
|
||||
var vmAttr = $('<div style="display: inline-table; vertical-align: middle;"></div>');
|
||||
vmFS.append($('<div style="display: inline-table; vertical-align: middle;"><img src="images/provision/computer.png"></img></div>'));
|
||||
vmFS.append(vmAttr);
|
||||
|
||||
// Create options fieldset
|
||||
var optionsFS = $('<fieldset></fieldset>');
|
||||
var optionsLegend = $('<legend>Options</legend>');
|
||||
optionsFS.append(optionsLegend);
|
||||
updatenodeForm.append(optionsFS);
|
||||
|
||||
var optionsAttr = $('<div style="display: inline-table; vertical-align: middle;"></div>');
|
||||
optionsFS.append($('<div style="display: inline-table; vertical-align: middle;"><img src="images/provision/setting.png" style="width: 70px;"></img></div>'));
|
||||
optionsFS.append(optionsAttr);
|
||||
|
||||
// Create target node or group input
|
||||
var tgt = $('<div><label>Target node range:</label><input type="text" name="target" value="' + tgtNodes + '" title="The node or node range to update"/></div>');
|
||||
vmAttr.append(tgt);
|
||||
|
||||
// Create options
|
||||
var optionsList = $('<ul></ul>');
|
||||
optionsAttr.append(optionsList);
|
||||
|
||||
// Create update all software checkbox (only AIX)
|
||||
if (osHash['AIX']) {
|
||||
var updateAllOption = $('<li></li>');
|
||||
var updateAllChkBox = $('<input type="checkbox" id="A" name="A"/>');
|
||||
updateAllOption.append(updateAllChkBox);
|
||||
optionsList.append(updateAllOption);
|
||||
updateAllOption.append('Install or update all software contained in the source directory');
|
||||
|
||||
// Create source directory input
|
||||
var allSwScrDirectory = $('<li><label style="vertical-align: middle">Source directory:</label><input type="text" id="allSwSrcDirectory" name="allSwSrcDirectory"/></li>');
|
||||
// Browse server directory and files
|
||||
var allSWSrcDirBrowse = createButton('Browse');
|
||||
allSWSrcDirBrowse.serverBrowser({
|
||||
onSelect : function(path) {
|
||||
$('#allSwSrcDirectory').val(path);
|
||||
},
|
||||
onLoad : function() {
|
||||
return $('#allSwSrcDirectory').val();
|
||||
},
|
||||
knownExt : [ 'exe', 'js', 'txt' ],
|
||||
knownPaths : [ {
|
||||
text : 'Install',
|
||||
image : 'desktop.png',
|
||||
path : '/install'
|
||||
} ],
|
||||
imageUrl : 'images/serverbrowser/',
|
||||
systemImageUrl : 'images/serverbrowser/',
|
||||
handlerUrl : 'lib/getpath.php',
|
||||
title : 'Browse',
|
||||
requestMethod : 'POST',
|
||||
width : '500',
|
||||
height : '300',
|
||||
basePath : '/install' // Limit user to only install directory
|
||||
});
|
||||
allSwScrDirectory.append(allSWSrcDirBrowse);
|
||||
allSwScrDirectory.hide();
|
||||
optionsList.append(allSwScrDirectory);
|
||||
|
||||
// Show source directory when checked
|
||||
updateAllChkBox.bind('click', function(event) {
|
||||
if ($(this).is(':checked')) {
|
||||
allSwScrDirectory.show();
|
||||
} else {
|
||||
allSwScrDirectory.hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Create update software checkbox
|
||||
var updateOption = $('<li></li>');
|
||||
var updateChkBox = $('<input type="checkbox" id="S" name="S"/>');
|
||||
optionsList.append(updateOption);
|
||||
updateOption.append(updateChkBox);
|
||||
updateOption.append('Update existing software');
|
||||
|
||||
// Create source directory input
|
||||
var scrDirectory = $('<li><label style="vertical-align: middle">Source directory:</label><input type="text" id="srcDirectory" name="srcDirectory" title="You must give the source directory containing the updated software packages"/></li>');
|
||||
// Browse server directory and files
|
||||
var srcDirBrowse = createButton('Browse');
|
||||
srcDirBrowse.serverBrowser({
|
||||
onSelect : function(path) {
|
||||
$('#srcDirectory').val(path);
|
||||
},
|
||||
onLoad : function() {
|
||||
return $('#srcDirectory').val();
|
||||
},
|
||||
knownExt : [ 'exe', 'js', 'txt' ],
|
||||
knownPaths : [ {
|
||||
text : 'Install',
|
||||
image : 'desktop.png',
|
||||
path : '/install'
|
||||
} ],
|
||||
imageUrl : 'images/serverbrowser/',
|
||||
systemImageUrl : 'images/serverbrowser/',
|
||||
handlerUrl : 'lib/getpath.php',
|
||||
title : 'Browse',
|
||||
requestMethod : 'POST',
|
||||
width : '500',
|
||||
height : '300',
|
||||
basePath : '/install' // Limit user to only install directory
|
||||
});
|
||||
scrDirectory.append(srcDirBrowse);
|
||||
scrDirectory.hide();
|
||||
optionsList.append(scrDirectory);
|
||||
|
||||
// Create other packages input
|
||||
var otherPkgs = $('<li><label style="vertical-align: middle">otherpkgs:</label><input type="text" id="otherpkgs" name="otherpkgs"/></li>');
|
||||
otherPkgs.hide();
|
||||
optionsList.append(otherPkgs);
|
||||
|
||||
// Create RPM flags input (only AIX)
|
||||
var aixRpmFlags = $('<li><label>rpm_flags:</label><input type="text" name="rpm_flags"/></li>');
|
||||
aixRpmFlags.hide();
|
||||
optionsList.append(aixRpmFlags);
|
||||
|
||||
// Create installp flags input (only AIX)
|
||||
var aixInstallPFlags = $('<li><label>installp_flags:</label><input type="text" name="installp_flags"/></li>');
|
||||
aixInstallPFlags.hide();
|
||||
optionsList.append(aixInstallPFlags);
|
||||
|
||||
// Create emgr flags input (only AIX)
|
||||
var aixEmgrFlags = $('<li><label>emgr_flags:</label><input type="text" name="emgr_flags"/></li>');
|
||||
aixEmgrFlags.hide();
|
||||
optionsList.append(aixEmgrFlags);
|
||||
|
||||
// Show flags when checked
|
||||
updateChkBox.bind('click', function(event) {
|
||||
if ($(this).is(':checked')) {
|
||||
scrDirectory.show();
|
||||
otherPkgs.show();
|
||||
if (osHash['AIX']) {
|
||||
aixRpmFlags.show();
|
||||
aixInstallPFlags.show();
|
||||
aixEmgrFlags.show();
|
||||
}
|
||||
} else {
|
||||
scrDirectory.hide();
|
||||
otherPkgs.hide();
|
||||
if (osHash['AIX']) {
|
||||
aixRpmFlags.hide();
|
||||
aixInstallPFlags.hide();
|
||||
aixEmgrFlags.hide();
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Create postscripts input
|
||||
var postOption = $('<li></li>');
|
||||
var postChkBox = $('<input type="checkbox" id="P" name="P"/>');
|
||||
optionsList.append(postOption);
|
||||
postOption.append(postChkBox);
|
||||
postOption.append('Run postscripts');
|
||||
var postscripts = $('<li><label style="vertical-align: middle">Postscripts:</label><input type="text" id="postscripts" name="postscripts" title="You must give the postscript(s) to run"/></li>');
|
||||
postscripts.hide();
|
||||
optionsList.append(postscripts);
|
||||
|
||||
// Show alternate source directory when checked
|
||||
postChkBox.bind('click', function(event) {
|
||||
if ($(this).is(':checked')) {
|
||||
postscripts.show();
|
||||
} else {
|
||||
postscripts.hide();
|
||||
}
|
||||
});
|
||||
optionsList.append('<li><input type="checkbox" id="F" name="F"/>Distribute and synchronize files</li>');
|
||||
optionsList.append('<li><input type="checkbox" id="k" name="k"/>Update the ssh keys and host keys for the service nodes and compute nodes</li>');
|
||||
|
||||
// Create update OS checkbox
|
||||
if (!osHash['AIX']) {
|
||||
var osOption = $('<li></li>');
|
||||
var osChkBox = $('<input type="checkbox" id="o" name="o"/>');
|
||||
optionsList.append(osOption);
|
||||
osOption.append(osChkBox);
|
||||
osOption.append('Update the operating system');
|
||||
|
||||
var os = $('<li></li>').hide();
|
||||
var osLabel = $('<label>Operating system:</label>');
|
||||
var osInput = $('<input type="text" name="os" title="You must give the operating system to upgrade to, e.g. rhel5.5"/>');
|
||||
osInput.one('focus', function(){
|
||||
var tmp = $.cookie('xcat_osvers');
|
||||
if (tmp) {
|
||||
// Turn on auto complete
|
||||
$(this).autocomplete({
|
||||
source: tmp.split(',')
|
||||
});
|
||||
}
|
||||
});
|
||||
os.append(osLabel);
|
||||
os.append(osInput);
|
||||
optionsList.append(os);
|
||||
|
||||
// Show alternate source directory when checked
|
||||
osChkBox.bind('click', function(event) {
|
||||
if ($(this).is(':checked')) {
|
||||
os.show();
|
||||
} else {
|
||||
os.hide();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Generate tooltips
|
||||
updatenodeForm.find('div input[title]').tooltip({
|
||||
position: "center right",
|
||||
offset: [-2, 10],
|
||||
effect: "fade",
|
||||
opacity: 0.7,
|
||||
predelay: 800,
|
||||
events : {
|
||||
def : "mouseover,mouseout",
|
||||
input : "mouseover,mouseout",
|
||||
widget : "focus mouseover,blur mouseout",
|
||||
tooltip : "mouseover,mouseout"
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Ok
|
||||
*/
|
||||
var updateBtn = createButton('Update');
|
||||
updateBtn.css({
|
||||
'width': '80px',
|
||||
'display': 'block'
|
||||
});
|
||||
updateBtn.bind('click', function(event) {
|
||||
// Remove any warning messages
|
||||
$(this).parents('.ui-tabs-panel').find('.ui-state-error').remove();
|
||||
var ready = true;
|
||||
|
||||
// Generate arguments
|
||||
var chkBoxes = $("#" + newTabId + " input[type='checkbox']:checked");
|
||||
var optionsStr = '';
|
||||
var option;
|
||||
for ( var i = 0; i < chkBoxes.length; i++) {
|
||||
option = chkBoxes.eq(i).attr('name');
|
||||
optionsStr += '-' + option;
|
||||
|
||||
// If update all software is checked
|
||||
if (option == 'S') {
|
||||
var srcDir = $('#' + newTabId + ' input[name=allSwSrcDirectory]').val();
|
||||
if (srcDir) {
|
||||
optionsStr += ';-d ' + srcDir;
|
||||
}
|
||||
}
|
||||
|
||||
// If update software is checked
|
||||
if (option == 'S') {
|
||||
// Get source directory
|
||||
var srcDirectory = $('#' + newTabId + ' input[name=srcDirectory]').val();
|
||||
if (srcDirectory) {
|
||||
optionsStr += ';-d;' + srcDirectory;
|
||||
}
|
||||
|
||||
// Get otherpkgs
|
||||
var otherpkgs = $('#' + newTabId + ' input[name=otherpkgs]').val();
|
||||
if (otherpkgs) {
|
||||
optionsStr += ';otherpkgs=' + otherpkgs;
|
||||
}
|
||||
|
||||
// Get rpm_flags
|
||||
var rpm_flags = $('#' + newTabId + ' input[name=rpm_flags]').val();
|
||||
if (rpm_flags) {
|
||||
optionsStr += ';rpm_flags=' + rpm_flags;
|
||||
}
|
||||
|
||||
// Get installp_flags
|
||||
var installp_flags = $('#' + newTabId + ' input[name=installp_flags]').val();
|
||||
if (installp_flags) {
|
||||
optionsStr += ';installp_flags=' + installp_flags;
|
||||
}
|
||||
|
||||
// Get emgr_flags
|
||||
var emgr_flags = $('#' + newTabId + ' input[name=emgr_flags]').val();
|
||||
if (emgr_flags) {
|
||||
optionsStr += ';emgr_flags=' + emgr_flags;
|
||||
}
|
||||
}
|
||||
|
||||
// If postscripts is checked
|
||||
if (option == 'P') {
|
||||
// Get postscripts
|
||||
optionsStr += ';' + $('#' + newTabId + ' input[name=postscripts]').val();
|
||||
}
|
||||
|
||||
// If operating system is checked
|
||||
if (option == 'o') {
|
||||
// Get the OS
|
||||
optionsStr += ';' + $('#' + newTabId + ' input[name=os]').val();
|
||||
}
|
||||
|
||||
// Append ; to end of string
|
||||
if (i < (chkBoxes.length - 1)) {
|
||||
optionsStr += ';';
|
||||
}
|
||||
}
|
||||
|
||||
// If no inputs are empty
|
||||
if (ready) {
|
||||
// Get nodes
|
||||
var tgts = $('#' + newTabId + ' input[name=target]').val();
|
||||
|
||||
// Disable all inputs and Ok button
|
||||
$('#' + newTabId + ' input').attr('disabled', 'disabled');
|
||||
$(this).attr('disabled', 'true');
|
||||
|
||||
/**
|
||||
* (1) Boot to network
|
||||
*/
|
||||
$.ajax( {
|
||||
url : 'lib/cmd.php',
|
||||
dataType : 'json',
|
||||
data : {
|
||||
cmd : 'updatenode',
|
||||
tgt : tgts,
|
||||
args : optionsStr,
|
||||
msg : 'out=' + statBarId + ';cmd=updatenode;tgt=' + tgts
|
||||
},
|
||||
|
||||
success : function(data) {
|
||||
data = decodeRsp(data);
|
||||
updateStatusBar(data);
|
||||
}
|
||||
});
|
||||
|
||||
// Show status bar
|
||||
statusBar.show();
|
||||
} else {
|
||||
// Show warning message
|
||||
var warn = createWarnBar('You are missing some values');
|
||||
warn.prependTo($(this).parents('.ui-tabs-panel'));
|
||||
}
|
||||
});
|
||||
updatenodeForm.append(updateBtn);
|
||||
|
||||
// Append to discover tab
|
||||
tab.add(newTabId, 'Update', updatenodeForm, true);
|
||||
|
||||
// Select new tab
|
||||
tab.select(newTabId);
|
||||
}
|
||||
+1461
-1434
File diff suppressed because it is too large
Load Diff
+257
-251
@@ -1,252 +1,258 @@
|
||||
/**
|
||||
* Global variables
|
||||
*/
|
||||
var provisionTabs; // Provision tabs
|
||||
|
||||
/**
|
||||
* Set the provision tab
|
||||
*
|
||||
* @param obj Tab object
|
||||
*/
|
||||
function setProvisionTab(obj) {
|
||||
provisionTabs = obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the provision tab
|
||||
*
|
||||
* @param Nothing
|
||||
* @return Tab object
|
||||
*/
|
||||
function getProvisionTab() {
|
||||
return provisionTabs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load provision page
|
||||
*/
|
||||
function loadProvisionPage() {
|
||||
// If the page is loaded
|
||||
if ($('#content').children().length) {
|
||||
// Do not load again
|
||||
return;
|
||||
}
|
||||
|
||||
// Get OS image names
|
||||
if (!$.cookie('xcat_imagenames')){
|
||||
$.ajax( {
|
||||
url : 'lib/cmd.php',
|
||||
dataType : 'json',
|
||||
data : {
|
||||
cmd : 'tabdump',
|
||||
tgt : '',
|
||||
args : 'osimage',
|
||||
msg : ''
|
||||
},
|
||||
|
||||
success : setOSImageCookies
|
||||
});
|
||||
}
|
||||
|
||||
// Get groups
|
||||
if (!$.cookie('xcat_groups')){
|
||||
$.ajax( {
|
||||
url : 'lib/cmd.php',
|
||||
dataType : 'json',
|
||||
data : {
|
||||
cmd : 'extnoderange',
|
||||
tgt : '/.*',
|
||||
args : 'subgroups',
|
||||
msg : ''
|
||||
},
|
||||
|
||||
success : setGroupsCookies
|
||||
});
|
||||
}
|
||||
|
||||
// Create info bar
|
||||
var infoBar = createInfoBar('Select a platform to provision or re-provision a node on, then click Ok.');
|
||||
|
||||
// Create provision page
|
||||
var provPg = $('<div class="form"></div>');
|
||||
provPg.append(infoBar);
|
||||
|
||||
// Create provision tab
|
||||
var tab = new Tab('provisionPageTabs');
|
||||
setProvisionTab(tab);
|
||||
tab.init();
|
||||
$('#content').append(tab.object());
|
||||
|
||||
// Create radio buttons for platforms
|
||||
var hwList = $('<ol>Platforms available:</ol>');
|
||||
var esx = $('<li><input type="radio" name="hw" value="esx" disabled/>ESX</li>');
|
||||
var kvm = $('<li><input type="radio" name="hw" value="kvm" disabled/>KVM</li>');
|
||||
var zvm = $('<li><input type="radio" name="hw" value="zvm" checked/>z\/VM</li>');
|
||||
var ipmi = $('<li><input type="radio" name="hw" value="ipmi" disabled/>iDataPlex</li>');
|
||||
var blade = $('<li><input type="radio" name="hw" value="blade" disabled/>BladeCenter</li>');
|
||||
var hmc = $('<li><input type="radio" name="hw" value="hmc" disabled/>System p</li>');
|
||||
|
||||
hwList.append(esx);
|
||||
hwList.append(kvm);
|
||||
hwList.append(zvm);
|
||||
hwList.append(blade);
|
||||
hwList.append(ipmi);
|
||||
hwList.append(hmc);
|
||||
provPg.append(hwList);
|
||||
|
||||
/**
|
||||
* Ok
|
||||
*/
|
||||
var okBtn = createButton('Ok');
|
||||
okBtn.bind('click', function(event) {
|
||||
// Get hardware that was selected
|
||||
var hw = $(this).parent().find('input[name="hw"]:checked').val();
|
||||
|
||||
var inst = 0;
|
||||
var newTabId = hw + 'ProvisionTab' + inst;
|
||||
while ($('#' + newTabId).length) {
|
||||
// If one already exists, generate another one
|
||||
inst = inst + 1;
|
||||
newTabId = hw + 'ProvisionTab' + inst;
|
||||
}
|
||||
|
||||
// Create an instance of the plugin
|
||||
var title = '';
|
||||
var plugin;
|
||||
switch (hw) {
|
||||
case "kvm":
|
||||
plugin = new kvmPlugin();
|
||||
title = 'KVM';
|
||||
break;
|
||||
case "esx":
|
||||
plugin = new esxPlugin();
|
||||
title = 'ESX';
|
||||
break;
|
||||
case "blade":
|
||||
plugin = new bladePlugin();
|
||||
title = 'BladeCenter';
|
||||
break;
|
||||
case "hmc":
|
||||
plugin = new hmcPlugin();
|
||||
title = 'System p';
|
||||
break;
|
||||
case "ipmi":
|
||||
plugin = new ipmiPlugin();
|
||||
title = 'iDataPlex';
|
||||
break;
|
||||
case "zvm":
|
||||
plugin = new zvmPlugin();
|
||||
title = 'z/VM';
|
||||
break;
|
||||
}
|
||||
|
||||
// Select tab
|
||||
tab.add(newTabId, title, '', true);
|
||||
tab.select(newTabId);
|
||||
plugin.loadProvisionPage(newTabId);
|
||||
});
|
||||
provPg.append(okBtn);
|
||||
|
||||
// Create resources tab
|
||||
var resrcPg = $('<div class="form"></div>');
|
||||
|
||||
// Create info bar
|
||||
var resrcInfoBar = createInfoBar('Select a platform to view its current resources.');
|
||||
resrcPg.append(resrcInfoBar);
|
||||
|
||||
// Create radio buttons for platforms
|
||||
var rsrcHwList = $('<ol>Platforms available:</ol>');
|
||||
esx = $('<li><input type="radio" name="rsrcHw" value="esx" disabled/>ESX</li>');
|
||||
kvm = $('<li><input type="radio" name="rsrcHw" value="kvm" disabled/>KVM</li>');
|
||||
zvm = $('<li><input type="radio" name="rsrcHw" value="zvm" checked/>z\/VM</li>');
|
||||
ipmi = $('<li><input type="radio" name="rsrcHw" value="ipmi" disabled/>iDataPlex</li>');
|
||||
blade = $('<li><input type="radio" name="rsrcHw" value="blade" disabled/>BladeCenter</li>');
|
||||
hmc = $('<li><input type="radio" name="rsrcHw" value="hmc" disabled/>System p</li>');
|
||||
|
||||
rsrcHwList.append(esx);
|
||||
rsrcHwList.append(kvm);
|
||||
rsrcHwList.append(zvm);
|
||||
rsrcHwList.append(blade);
|
||||
rsrcHwList.append(ipmi);
|
||||
rsrcHwList.append(hmc);
|
||||
|
||||
resrcPg.append(rsrcHwList);
|
||||
|
||||
var okBtn = createButton('Ok');
|
||||
okBtn.bind('click', function(event) {
|
||||
// Get hardware that was selected
|
||||
var hw = $(this).parent().find('input[name="rsrcHw"]:checked').val();
|
||||
|
||||
// Generate new tab ID
|
||||
var newTabId = hw + 'ResourceTab';
|
||||
if (!$('#' + newTabId).length) {
|
||||
// Create loader
|
||||
var loader = $('<center></center>').append(createLoader(hw + 'ResourceLoader'));
|
||||
|
||||
// Create an instance of the plugin
|
||||
var plugin = null;
|
||||
var displayName = "";
|
||||
switch (hw) {
|
||||
case "kvm":
|
||||
plugin = new kvmPlugin();
|
||||
displayName = "KVM";
|
||||
break;
|
||||
case "esx":
|
||||
plugin = new esxPlugin();
|
||||
displayName = "ESX";
|
||||
break;
|
||||
case "blade":
|
||||
plugin = new bladePlugin();
|
||||
displayName = "BladeCenter";
|
||||
break;
|
||||
case "hmc":
|
||||
plugin = new hmcPlugin();
|
||||
displayName = "System p";
|
||||
break;
|
||||
case "ipmi":
|
||||
plugin = new ipmiPlugin();
|
||||
displayName = "iDataPlex";
|
||||
break;
|
||||
case "zvm":
|
||||
plugin = new zvmPlugin();
|
||||
displayName = "z\/VM";
|
||||
break;
|
||||
}
|
||||
|
||||
// Add resource tab and load resources
|
||||
tab.add(newTabId, displayName, loader, true);
|
||||
plugin.loadResources();
|
||||
}
|
||||
|
||||
// Select tab
|
||||
tab.select(newTabId);
|
||||
});
|
||||
|
||||
resrcPg.append(okBtn);
|
||||
|
||||
// Add provision tab
|
||||
tab.add('provisionTab', 'Provision', provPg, false);
|
||||
// Add image tab
|
||||
tab.add('imagesTab', 'Images', '', false);
|
||||
// Add resource tab
|
||||
tab.add('resourceTab', 'Resources', resrcPg, false);
|
||||
|
||||
// Load tabs onselect
|
||||
$('#provisionPageTabs').bind('tabsselect', function(event, ui){
|
||||
// Load image page
|
||||
if (!$('#imagesTab').children().length && ui.index == 1) {
|
||||
$('#imagesTab').append($('<center></center>').append(createLoader('')));
|
||||
loadImagesPage();
|
||||
}
|
||||
});
|
||||
|
||||
// Open the quick provision tab
|
||||
if (window.location.search) {
|
||||
tab.add('quickProvisionTab', 'Quick Provision', '', true);
|
||||
tab.select('quickProvisionTab');
|
||||
|
||||
var provForm = $('<div class="form"></div>');
|
||||
$('#quickProvisionTab').append(provForm);
|
||||
appendProvisionSection('quick', provForm);
|
||||
}
|
||||
/**
|
||||
* Global variables
|
||||
*/
|
||||
var provisionTabs; // Provision tabs
|
||||
|
||||
/**
|
||||
* Set the provision tab
|
||||
*
|
||||
* @param obj Tab object
|
||||
*/
|
||||
function setProvisionTab(obj) {
|
||||
provisionTabs = obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the provision tab
|
||||
*
|
||||
* @param Nothing
|
||||
* @return Tab object
|
||||
*/
|
||||
function getProvisionTab() {
|
||||
return provisionTabs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Load provision page
|
||||
*/
|
||||
function loadProvisionPage() {
|
||||
// If the page is loaded
|
||||
if ($('#content').children().length) {
|
||||
// Do not load again
|
||||
return;
|
||||
}
|
||||
|
||||
// Get OS image names
|
||||
if (!$.cookie('xcat_imagenames')){
|
||||
$.ajax( {
|
||||
url : 'lib/cmd.php',
|
||||
dataType : 'json',
|
||||
data : {
|
||||
cmd : 'tabdump',
|
||||
tgt : '',
|
||||
args : 'osimage',
|
||||
msg : ''
|
||||
},
|
||||
|
||||
success : function(data) {
|
||||
data = decodeRsp(data);
|
||||
setOSImageCookies(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Get groups
|
||||
if (!$.cookie('xcat_groups')){
|
||||
$.ajax( {
|
||||
url : 'lib/cmd.php',
|
||||
dataType : 'json',
|
||||
data : {
|
||||
cmd : 'extnoderange',
|
||||
tgt : '/.*',
|
||||
args : 'subgroups',
|
||||
msg : ''
|
||||
},
|
||||
|
||||
success : function(data) {
|
||||
data = decodeRsp(data);
|
||||
setGroupsCookies(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Create info bar
|
||||
var infoBar = createInfoBar('Select a platform to provision or re-provision a node on, then click Ok.');
|
||||
|
||||
// Create provision page
|
||||
var provPg = $('<div class="form"></div>');
|
||||
provPg.append(infoBar);
|
||||
|
||||
// Create provision tab
|
||||
var tab = new Tab('provisionPageTabs');
|
||||
setProvisionTab(tab);
|
||||
tab.init();
|
||||
$('#content').append(tab.object());
|
||||
|
||||
// Create radio buttons for platforms
|
||||
var hwList = $('<ol>Platforms available:</ol>');
|
||||
var esx = $('<li><input type="radio" name="hw" value="esx" disabled/>ESX</li>');
|
||||
var kvm = $('<li><input type="radio" name="hw" value="kvm" disabled/>KVM</li>');
|
||||
var zvm = $('<li><input type="radio" name="hw" value="zvm" checked/>z\/VM</li>');
|
||||
var ipmi = $('<li><input type="radio" name="hw" value="ipmi" disabled/>iDataPlex</li>');
|
||||
var blade = $('<li><input type="radio" name="hw" value="blade" disabled/>BladeCenter</li>');
|
||||
var hmc = $('<li><input type="radio" name="hw" value="hmc" disabled/>System p</li>');
|
||||
|
||||
hwList.append(esx);
|
||||
hwList.append(kvm);
|
||||
hwList.append(zvm);
|
||||
hwList.append(blade);
|
||||
hwList.append(ipmi);
|
||||
hwList.append(hmc);
|
||||
provPg.append(hwList);
|
||||
|
||||
/**
|
||||
* Ok
|
||||
*/
|
||||
var okBtn = createButton('Ok');
|
||||
okBtn.bind('click', function(event) {
|
||||
// Get hardware that was selected
|
||||
var hw = $(this).parent().find('input[name="hw"]:checked').val();
|
||||
|
||||
var inst = 0;
|
||||
var newTabId = hw + 'ProvisionTab' + inst;
|
||||
while ($('#' + newTabId).length) {
|
||||
// If one already exists, generate another one
|
||||
inst = inst + 1;
|
||||
newTabId = hw + 'ProvisionTab' + inst;
|
||||
}
|
||||
|
||||
// Create an instance of the plugin
|
||||
var title = '';
|
||||
var plugin;
|
||||
switch (hw) {
|
||||
case "kvm":
|
||||
plugin = new kvmPlugin();
|
||||
title = 'KVM';
|
||||
break;
|
||||
case "esx":
|
||||
plugin = new esxPlugin();
|
||||
title = 'ESX';
|
||||
break;
|
||||
case "blade":
|
||||
plugin = new bladePlugin();
|
||||
title = 'BladeCenter';
|
||||
break;
|
||||
case "hmc":
|
||||
plugin = new hmcPlugin();
|
||||
title = 'System p';
|
||||
break;
|
||||
case "ipmi":
|
||||
plugin = new ipmiPlugin();
|
||||
title = 'iDataPlex';
|
||||
break;
|
||||
case "zvm":
|
||||
plugin = new zvmPlugin();
|
||||
title = 'z/VM';
|
||||
break;
|
||||
}
|
||||
|
||||
// Select tab
|
||||
tab.add(newTabId, title, '', true);
|
||||
tab.select(newTabId);
|
||||
plugin.loadProvisionPage(newTabId);
|
||||
});
|
||||
provPg.append(okBtn);
|
||||
|
||||
// Create resources tab
|
||||
var resrcPg = $('<div class="form"></div>');
|
||||
|
||||
// Create info bar
|
||||
var resrcInfoBar = createInfoBar('Select a platform to view its current resources.');
|
||||
resrcPg.append(resrcInfoBar);
|
||||
|
||||
// Create radio buttons for platforms
|
||||
var rsrcHwList = $('<ol>Platforms available:</ol>');
|
||||
esx = $('<li><input type="radio" name="rsrcHw" value="esx" disabled/>ESX</li>');
|
||||
kvm = $('<li><input type="radio" name="rsrcHw" value="kvm" disabled/>KVM</li>');
|
||||
zvm = $('<li><input type="radio" name="rsrcHw" value="zvm" checked/>z\/VM</li>');
|
||||
ipmi = $('<li><input type="radio" name="rsrcHw" value="ipmi" disabled/>iDataPlex</li>');
|
||||
blade = $('<li><input type="radio" name="rsrcHw" value="blade" disabled/>BladeCenter</li>');
|
||||
hmc = $('<li><input type="radio" name="rsrcHw" value="hmc" disabled/>System p</li>');
|
||||
|
||||
rsrcHwList.append(esx);
|
||||
rsrcHwList.append(kvm);
|
||||
rsrcHwList.append(zvm);
|
||||
rsrcHwList.append(blade);
|
||||
rsrcHwList.append(ipmi);
|
||||
rsrcHwList.append(hmc);
|
||||
|
||||
resrcPg.append(rsrcHwList);
|
||||
|
||||
var okBtn = createButton('Ok');
|
||||
okBtn.bind('click', function(event) {
|
||||
// Get hardware that was selected
|
||||
var hw = $(this).parent().find('input[name="rsrcHw"]:checked').val();
|
||||
|
||||
// Generate new tab ID
|
||||
var newTabId = hw + 'ResourceTab';
|
||||
if (!$('#' + newTabId).length) {
|
||||
// Create loader
|
||||
var loader = $('<center></center>').append(createLoader(hw + 'ResourceLoader'));
|
||||
|
||||
// Create an instance of the plugin
|
||||
var plugin = null;
|
||||
var displayName = "";
|
||||
switch (hw) {
|
||||
case "kvm":
|
||||
plugin = new kvmPlugin();
|
||||
displayName = "KVM";
|
||||
break;
|
||||
case "esx":
|
||||
plugin = new esxPlugin();
|
||||
displayName = "ESX";
|
||||
break;
|
||||
case "blade":
|
||||
plugin = new bladePlugin();
|
||||
displayName = "BladeCenter";
|
||||
break;
|
||||
case "hmc":
|
||||
plugin = new hmcPlugin();
|
||||
displayName = "System p";
|
||||
break;
|
||||
case "ipmi":
|
||||
plugin = new ipmiPlugin();
|
||||
displayName = "iDataPlex";
|
||||
break;
|
||||
case "zvm":
|
||||
plugin = new zvmPlugin();
|
||||
displayName = "z\/VM";
|
||||
break;
|
||||
}
|
||||
|
||||
// Add resource tab and load resources
|
||||
tab.add(newTabId, displayName, loader, true);
|
||||
plugin.loadResources();
|
||||
}
|
||||
|
||||
// Select tab
|
||||
tab.select(newTabId);
|
||||
});
|
||||
|
||||
resrcPg.append(okBtn);
|
||||
|
||||
// Add provision tab
|
||||
tab.add('provisionTab', 'Provision', provPg, false);
|
||||
// Add image tab
|
||||
tab.add('imagesTab', 'Images', '', false);
|
||||
// Add resource tab
|
||||
tab.add('resourceTab', 'Resources', resrcPg, false);
|
||||
|
||||
// Load tabs onselect
|
||||
$('#provisionPageTabs').bind('tabsselect', function(event, ui){
|
||||
// Load image page
|
||||
if (!$('#imagesTab').children().length && ui.index == 1) {
|
||||
$('#imagesTab').append($('<center></center>').append(createLoader('')));
|
||||
loadImagesPage();
|
||||
}
|
||||
});
|
||||
|
||||
// Open the quick provision tab
|
||||
if (window.location.search) {
|
||||
tab.add('quickProvisionTab', 'Quick Provision', '', true);
|
||||
tab.select('quickProvisionTab');
|
||||
|
||||
var provForm = $('<div class="form"></div>');
|
||||
$('#quickProvisionTab').append(provForm);
|
||||
appendProvisionSection('quick', provForm);
|
||||
}
|
||||
}
|
||||
+2191
-2152
File diff suppressed because it is too large
Load Diff
+1101
-1068
File diff suppressed because it is too large
Load Diff
+240
-224
@@ -1,225 +1,241 @@
|
||||
<?php
|
||||
/* Required libraries */
|
||||
$TOPDIR = '..';
|
||||
require_once "$TOPDIR/lib/functions.php";
|
||||
require_once "$TOPDIR/lib/jsonwrapper.php";
|
||||
|
||||
/**
|
||||
* Issue a xCAT command, e.g. rinv gpok123 all
|
||||
* This will handle most commands. If not, you can create your own .php.
|
||||
* Look at zCmd.php for an example.
|
||||
*
|
||||
* @param $cmd The xCAT command
|
||||
* @param $tgt The target node or group
|
||||
* @param $args The xCAT command arguments, separated by semicolons
|
||||
* @param $opts The xCAT command options, separated by semicolons
|
||||
* @return The xCAT response. Replies are in the form of JSON
|
||||
*/
|
||||
if (isset($_GET["cmd"])) {
|
||||
// HTTP GET requests
|
||||
$cmd = $_GET["cmd"];
|
||||
$tgt = $_GET["tgt"];
|
||||
$args = $_GET["args"];
|
||||
|
||||
// File contents in case of file write
|
||||
if (isset($_GET["cont"])) {
|
||||
$cont = $_GET["cont"];
|
||||
}
|
||||
|
||||
// Special messages put here
|
||||
// This gets sent back to the AJAX request as is.
|
||||
$msg = $_GET["msg"];
|
||||
|
||||
// If no $tgt is given, set $tgt to NULL
|
||||
if (!$tgt) {
|
||||
$tgt = NULL;
|
||||
}
|
||||
|
||||
// If no $msg is given, set $msg to NULL
|
||||
if (!$msg) {
|
||||
$msg = NULL;
|
||||
}
|
||||
|
||||
// If no $args are given, set $args_array to NULL
|
||||
// Separators used are: || or ;
|
||||
$args_array = array();
|
||||
if ($args) {
|
||||
// If $args contains multiple arguments, split it into an array
|
||||
if (strpos($args, "||")) {
|
||||
// Split the arguments into an array
|
||||
$args_array = array();
|
||||
$args_array = explode("||", $args);
|
||||
} else if (strpos($args, ";")) {
|
||||
// Split the arguments into an array
|
||||
$args_array = array();
|
||||
$args_array = explode(";", $args);
|
||||
} else {
|
||||
$args_array = array($args);
|
||||
}
|
||||
}
|
||||
|
||||
// If no $opts are given, set $opts_array to NULL
|
||||
$opts_array = array();
|
||||
if (isset($_GET["opts"])) {
|
||||
$opts = $_GET["opts"];
|
||||
|
||||
// If $args contains multiple arguments, split it into an array
|
||||
if (strpos($opts, "|")) {
|
||||
// Split the arguments into an array
|
||||
$opts_array = array();
|
||||
$opts_array = explode("|", $opts);
|
||||
} if (strpos($opts, ";")) {
|
||||
// Split the arguments into an array
|
||||
$opts_array = array();
|
||||
$opts_array = explode(";", $opts);
|
||||
} else {
|
||||
$opts_array = array($opts);
|
||||
}
|
||||
}
|
||||
|
||||
// Time needed to update /etc/hosts
|
||||
if (strncasecmp($cmd, "makehosts", 9) == 0) {
|
||||
sleep(5);
|
||||
}
|
||||
|
||||
// Submit request and get response
|
||||
$xml = docmd($cmd, $tgt, $args_array, $opts_array);
|
||||
// If the output is flushed, do not return output in JSON
|
||||
if (in_array("flush", $opts_array)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$rsp = array();
|
||||
|
||||
// webrun pping and gangliastatus output needs special handling
|
||||
if (strncasecmp($cmd, "webrun", 6) == 0 && (stristr($args, "pping") || stristr($args, "gangliastatus") || stristr($args, "chtab"))) {
|
||||
$rsp = extractWebrun($xml);
|
||||
}
|
||||
// nodels output needs special handling
|
||||
else if (strncasecmp($cmd, "nodels", 6) == 0) {
|
||||
// Handle the output the same way as webrun
|
||||
$rsp = extractNodels($xml);
|
||||
}
|
||||
// extnoderange output needs special handling
|
||||
// This command gets the nodes and groups
|
||||
else if (strncasecmp($cmd, "extnoderange", 12) == 0) {
|
||||
$rsp = extractExtnoderange($xml);
|
||||
}
|
||||
// Write contents to file
|
||||
else if (strncasecmp($cmd, "write", 4) == 0) {
|
||||
// Directory should be /var/opt/xcat/profiles
|
||||
// You can write anything to that directory
|
||||
$file = "$tgt";
|
||||
$handle = fopen($file, 'w') or die("Cannot open $file");
|
||||
fwrite($handle, $cont);
|
||||
fclose($handle);
|
||||
|
||||
$rsp = "Directory entry written to $file";
|
||||
}
|
||||
// Handle the typical output
|
||||
else {
|
||||
foreach ($xml->children() as $child) {
|
||||
foreach ($child->children() as $data) {
|
||||
if($data->name) {
|
||||
$node = $data->name;
|
||||
|
||||
if ($data->data->contents) {
|
||||
$cont = $data->data->contents;
|
||||
} else {
|
||||
$cont = $data->data;
|
||||
}
|
||||
|
||||
if ($data->data->desc) {
|
||||
$cont = $data->data->desc . ": " . $cont;
|
||||
}
|
||||
|
||||
$cont = str_replace(":|:", "\n", $cont);
|
||||
array_push($rsp, "$node: $cont");
|
||||
} else if (strlen("$data") > 2) {
|
||||
$data = str_replace(":|:", "\n", $data);
|
||||
array_push($rsp, "$data");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Reply in the form of JSON
|
||||
$rtn = array("rsp" => $rsp, "msg" => $msg);
|
||||
echo json_encode($rtn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the output for a webrun command
|
||||
*
|
||||
* @param $xml The XML output from docmd()
|
||||
* @return An array containing the output
|
||||
*/
|
||||
function extractWebrun($xml) {
|
||||
$rsp = array();
|
||||
$i = 0;
|
||||
|
||||
// Extract data returned
|
||||
foreach($xml->children() as $nodes){
|
||||
foreach($nodes->children() as $node){
|
||||
// Get the node name
|
||||
$name = $node->name;
|
||||
|
||||
// Get the content
|
||||
$status = $node->data;
|
||||
$status = str_replace(":|:", "\n", $status);
|
||||
|
||||
// Add to return array
|
||||
$rsp[$i] = array("$name", "$status");
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
return $rsp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the output for a nodels command
|
||||
*
|
||||
* @param $xml The XML output from docmd()
|
||||
* @return An array containing the output
|
||||
*/
|
||||
function extractNodels($xml) {
|
||||
$rsp = array();
|
||||
$i = 0;
|
||||
|
||||
// Extract data returned
|
||||
foreach($xml->children() as $nodes){
|
||||
foreach($nodes->children() as $node){
|
||||
// Get the node name
|
||||
$name = $node->name;
|
||||
// Get the content
|
||||
$status = $node->data->contents;
|
||||
$status = str_replace(":|:", "\n", $status);
|
||||
|
||||
$description = $node->data->desc;
|
||||
// Add to return array
|
||||
$rsp[$i] = array("$name", "$status", "$description");
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
return $rsp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the output for a extnoderange command
|
||||
*
|
||||
* @param $xml The XML output from docmd()
|
||||
* @return The nodes and groups
|
||||
*/
|
||||
function extractExtnoderange($xml) {
|
||||
$rsp = array();
|
||||
|
||||
// Extract data returned
|
||||
foreach ($xml->xcatresponse->intersectinggroups as $group) {
|
||||
array_push($rsp, "$group");
|
||||
}
|
||||
|
||||
return $rsp;
|
||||
}
|
||||
<?php
|
||||
/* Required libraries */
|
||||
$TOPDIR = '..';
|
||||
require_once "$TOPDIR/lib/functions.php";
|
||||
require_once "$TOPDIR/lib/jsonwrapper.php";
|
||||
|
||||
/**
|
||||
* Issue a xCAT command, e.g. rinv gpok123 all
|
||||
* This will handle most commands. If not, you can create your own .php.
|
||||
* Look at zCmd.php for an example.
|
||||
*
|
||||
* @param $cmd The xCAT command
|
||||
* @param $tgt The target node or group
|
||||
* @param $args The xCAT command arguments, separated by semicolons
|
||||
* @param $opts The xCAT command options, separated by semicolons
|
||||
* @return The xCAT response. Replies are in the form of JSON
|
||||
*/
|
||||
if (isset($_GET["cmd"])) {
|
||||
// HTTP GET requests
|
||||
$cmd = $_GET["cmd"];
|
||||
$tgt = $_GET["tgt"];
|
||||
$args = $_GET["args"];
|
||||
|
||||
// File contents in case of file write
|
||||
if (isset($_GET["cont"])) {
|
||||
$cont = $_GET["cont"];
|
||||
}
|
||||
|
||||
// Special messages put here
|
||||
// This gets sent back to the AJAX request as is.
|
||||
$msg = $_GET["msg"];
|
||||
|
||||
// If no $tgt is given, set $tgt to NULL
|
||||
if (!$tgt) {
|
||||
$tgt = NULL;
|
||||
}
|
||||
|
||||
// If no $msg is given, set $msg to NULL
|
||||
if (!$msg) {
|
||||
$msg = NULL;
|
||||
}
|
||||
|
||||
// If no $args are given, set $args_array to NULL
|
||||
// Separators used are: || or ;
|
||||
$args_array = array();
|
||||
if ($args) {
|
||||
// If $args contains multiple arguments, split it into an array
|
||||
if (strpos($args, "||")) {
|
||||
// Split the arguments into an array
|
||||
$args_array = array();
|
||||
$args_array = explode("||", $args);
|
||||
} else if (strpos($args, ";")) {
|
||||
// Split the arguments into an array
|
||||
$args_array = array();
|
||||
$args_array = explode(";", $args);
|
||||
} else {
|
||||
$args_array = array($args);
|
||||
}
|
||||
}
|
||||
|
||||
// If no $opts are given, set $opts_array to NULL
|
||||
$opts_array = array();
|
||||
if (isset($_GET["opts"])) {
|
||||
$opts = $_GET["opts"];
|
||||
|
||||
// If $args contains multiple arguments, split it into an array
|
||||
if (strpos($opts, "|")) {
|
||||
// Split the arguments into an array
|
||||
$opts_array = array();
|
||||
$opts_array = explode("|", $opts);
|
||||
} if (strpos($opts, ";")) {
|
||||
// Split the arguments into an array
|
||||
$opts_array = array();
|
||||
$opts_array = explode(";", $opts);
|
||||
} else {
|
||||
$opts_array = array($opts);
|
||||
}
|
||||
}
|
||||
|
||||
// Time needed to update /etc/hosts
|
||||
if (strncasecmp($cmd, "makehosts", 9) == 0) {
|
||||
sleep(5);
|
||||
}
|
||||
|
||||
// Submit request and get response
|
||||
$xml = docmd($cmd, $tgt, $args_array, $opts_array);
|
||||
// If the output is flushed, do not return output in JSON
|
||||
if (in_array("flush", $opts_array)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$rsp = array();
|
||||
|
||||
// webrun pping and gangliastatus output needs special handling
|
||||
if (strncasecmp($cmd, "webrun", 6) == 0 && (stristr($args, "pping") || stristr($args, "gangliastatus") || stristr($args, "chtab"))) {
|
||||
$rsp = extractWebrun($xml);
|
||||
}
|
||||
// nodels output needs special handling
|
||||
else if (strncasecmp($cmd, "nodels", 6) == 0) {
|
||||
// Handle the output the same way as webrun
|
||||
$rsp = extractNodels($xml);
|
||||
}
|
||||
// extnoderange output needs special handling
|
||||
// This command gets the nodes and groups
|
||||
else if (strncasecmp($cmd, "extnoderange", 12) == 0) {
|
||||
$rsp = extractExtnoderange($xml);
|
||||
}
|
||||
// Write contents to file
|
||||
else if (strncasecmp($cmd, "write", 4) == 0) {
|
||||
// Directory should be /var/opt/xcat/profiles
|
||||
// You can write anything to that directory
|
||||
$file = "$tgt";
|
||||
$handle = fopen($file, 'w') or die("Cannot open $file");
|
||||
fwrite($handle, $cont);
|
||||
fclose($handle);
|
||||
|
||||
$rsp = "Directory entry written to $file";
|
||||
}
|
||||
// Handle the typical output
|
||||
else {
|
||||
foreach ($xml->children() as $child) {
|
||||
foreach ($child->children() as $data) {
|
||||
if($data->name) {
|
||||
$node = $data->name;
|
||||
|
||||
if ($data->data->contents) {
|
||||
$cont = $data->data->contents;
|
||||
} else {
|
||||
$cont = $data->data;
|
||||
}
|
||||
|
||||
if ($data->data->desc) {
|
||||
$cont = $data->data->desc . ": " . $cont;
|
||||
}
|
||||
|
||||
$cont = str_replace(":|:", "\n", $cont);
|
||||
array_push($rsp, "$node: $cont");
|
||||
} else if (strlen("$data") > 2) {
|
||||
$data = str_replace(":|:", "\n", $data);
|
||||
array_push($rsp, "$data");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Remove any HTML that could be used for XSS attacks
|
||||
foreach ($rsp as $key => &$value) {
|
||||
$whatami = gettype($value);
|
||||
if ("string" != $whatami) {
|
||||
//echo "found a non string in rsp array \n";
|
||||
foreach ($value as $key2 => $value2){
|
||||
//echo "Key2:$key2 Value2 type:",gettype($value2)," value2 data: $value2 \n";
|
||||
$value[$key2] = htmlentities($value2, ENT_QUOTES | ENT_HTML5, 'UTF-8');
|
||||
}
|
||||
} else {
|
||||
//echo "Key:$key Value type:",gettype($value)," value data: $value \n";
|
||||
$rsp[$key] = htmlentities($value, ENT_QUOTES | ENT_HTML5, 'UTF-8');
|
||||
//echo "New value: $rsp[$key] \n";
|
||||
}
|
||||
}
|
||||
$msg = htmlentities($msg, ENT_QUOTES | ENT_HTML5, 'UTF-8');
|
||||
|
||||
// Reply in the form of JSON
|
||||
$rtn = array("rsp" => $rsp, "msg" => $msg);
|
||||
echo json_encode($rtn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the output for a webrun command
|
||||
*
|
||||
* @param $xml The XML output from docmd()
|
||||
* @return An array containing the output
|
||||
*/
|
||||
function extractWebrun($xml) {
|
||||
$rsp = array();
|
||||
$i = 0;
|
||||
|
||||
// Extract data returned
|
||||
foreach($xml->children() as $nodes){
|
||||
foreach($nodes->children() as $node){
|
||||
// Get the node name
|
||||
$name = $node->name;
|
||||
|
||||
// Get the content
|
||||
$status = $node->data;
|
||||
$status = str_replace(":|:", "\n", $status);
|
||||
|
||||
// Add to return array
|
||||
$rsp[$i] = array("$name", "$status");
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
return $rsp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the output for a nodels command
|
||||
*
|
||||
* @param $xml The XML output from docmd()
|
||||
* @return An array containing the output
|
||||
*/
|
||||
function extractNodels($xml) {
|
||||
$rsp = array();
|
||||
$i = 0;
|
||||
|
||||
// Extract data returned
|
||||
foreach($xml->children() as $nodes){
|
||||
foreach($nodes->children() as $node){
|
||||
// Get the node name
|
||||
$name = $node->name;
|
||||
// Get the content
|
||||
$status = $node->data->contents;
|
||||
$status = str_replace(":|:", "\n", $status);
|
||||
|
||||
$description = $node->data->desc;
|
||||
// Add to return array
|
||||
$rsp[$i] = array("$name", "$status", "$description");
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
return $rsp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the output for a extnoderange command
|
||||
*
|
||||
* @param $xml The XML output from docmd()
|
||||
* @return The nodes and groups
|
||||
*/
|
||||
function extractExtnoderange($xml) {
|
||||
$rsp = array();
|
||||
|
||||
// Extract data returned
|
||||
foreach ($xml->xcatresponse->intersectinggroups as $group) {
|
||||
array_push($rsp, "$group");
|
||||
}
|
||||
|
||||
return $rsp;
|
||||
}
|
||||
?>
|
||||
+205
-189
@@ -1,190 +1,206 @@
|
||||
<?php
|
||||
/* Required libraries */
|
||||
$TOPDIR = '..';
|
||||
require_once "$TOPDIR/lib/srv_functions.php";
|
||||
require_once "$TOPDIR/lib/jsonwrapper.php";
|
||||
|
||||
/**
|
||||
* Issue a xCAT command, e.g. rinv gpok123 all. This will handle most commands.
|
||||
* If not, you can create your own .php. Look at zCmd.php for an example.
|
||||
*
|
||||
* @param $cmd The xCAT command
|
||||
* @param $tgt The target node or group
|
||||
* @param $args The xCAT command arguments, separated by semicolons
|
||||
* @param $opts The xCAT command options, separated by semicolons
|
||||
* @return The xCAT response. Replies are in the form of JSON
|
||||
*/
|
||||
if (isset($_GET["cmd"])) {
|
||||
// HTTP GET requests
|
||||
$cmd = $_GET["cmd"];
|
||||
$tgt = $_GET["tgt"];
|
||||
$args = $_GET["args"];
|
||||
|
||||
// Special messages put here
|
||||
// This gets sent back to the AJAX request as is.
|
||||
$msg = $_GET["msg"];
|
||||
|
||||
// If no $tgt is given, set $tgt to NULL
|
||||
if (!$tgt) {
|
||||
$tgt = NULL;
|
||||
}
|
||||
|
||||
// If no $msg is given, set $msg to NULL
|
||||
if (!$msg) {
|
||||
$msg = NULL;
|
||||
}
|
||||
|
||||
// If no $args are given, set $args_array to NULL
|
||||
$args_array = array();
|
||||
if ($args) {
|
||||
// If $args contains multiple arguments, split it into an array
|
||||
if (strpos($args,";")) {
|
||||
// Split the arguments into an array
|
||||
$args_array = array();
|
||||
$args_array = explode(";", $args);
|
||||
} else {
|
||||
$args_array = array($args);
|
||||
}
|
||||
}
|
||||
|
||||
// If no $opts are given, set $opts_array to NULL
|
||||
$opts_array = array();
|
||||
if (isset($_GET["opts"])) {
|
||||
$opts = $_GET["opts"];
|
||||
|
||||
// If $args contains multiple arguments, split it into an array
|
||||
if (strpos($opts,";")) {
|
||||
// Split the arguments into an array
|
||||
$opts_array = array();
|
||||
$opts_array = explode(";", $opts);
|
||||
} else {
|
||||
$opts_array = array($opts);
|
||||
}
|
||||
}
|
||||
|
||||
// Submit request and get response
|
||||
$xml = docmd($cmd, $tgt, $args_array, $opts_array);
|
||||
// If the output is flushed, do not return output in JSON
|
||||
if (in_array("flush", $opts_array)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$rsp = array();
|
||||
|
||||
// webrun pping and gangliastatus output needs special handling
|
||||
if(strncasecmp($cmd, "webrun", 6) == 0 && (stristr($args, "pping") || stristr($args, "gangliastatus") || stristr($args, "chtab"))) {
|
||||
$rsp = extractWebrun($xml);
|
||||
}
|
||||
// nodels output needs special handling
|
||||
else if(strncasecmp($cmd, "nodels", 6) == 0) {
|
||||
// Handle the output the same way as webrun
|
||||
$rsp = extractNodels($xml);
|
||||
}
|
||||
// extnoderange output needs special handling
|
||||
// This command gets the nodes and groups
|
||||
else if(strncasecmp($cmd, "extnoderange", 12) == 0) {
|
||||
$rsp = extractExtnoderange($xml);
|
||||
}
|
||||
// Handle the typical output
|
||||
else {
|
||||
foreach ($xml->children() as $child) {
|
||||
foreach ($child->children() as $data) {
|
||||
if($data->name) {
|
||||
$node = $data->name;
|
||||
|
||||
if($data->data->contents){
|
||||
$cont = $data->data->contents;
|
||||
} else {
|
||||
$cont = $data->data;
|
||||
}
|
||||
|
||||
$cont = str_replace(":|:", "\n", $cont);
|
||||
array_push($rsp, "$node: $cont");
|
||||
} else if (strlen("$data") > 2) {
|
||||
$data = str_replace(":|:", "\n", $data);
|
||||
array_push($rsp, "$data");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Reply in the form of JSON
|
||||
$rtn = array("rsp" => $rsp, "msg" => $msg);
|
||||
echo json_encode($rtn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the output for a webrun command
|
||||
*
|
||||
* @param $xml The XML output from docmd()
|
||||
* @return An array containing the output
|
||||
*/
|
||||
function extractWebrun($xml) {
|
||||
$rsp = array();
|
||||
$i = 0;
|
||||
|
||||
// Extract data returned
|
||||
foreach($xml->children() as $nodes){
|
||||
foreach($nodes->children() as $node){
|
||||
// Get the node name
|
||||
$name = $node->name;
|
||||
|
||||
// Get the content
|
||||
$status = $node->data;
|
||||
$status = str_replace(":|:", "\n", $status);
|
||||
|
||||
// Add to return array
|
||||
$rsp[$i] = array("$name", "$status");
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
return $rsp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the output for a nodels command
|
||||
*
|
||||
* @param $xml The XML output from docmd()
|
||||
* @return An array containing the output
|
||||
*/
|
||||
function extractNodels($xml) {
|
||||
$rsp = array();
|
||||
$i = 0;
|
||||
|
||||
// Extract data returned
|
||||
foreach($xml->children() as $nodes){
|
||||
foreach($nodes->children() as $node){
|
||||
// Get the node name
|
||||
$name = $node->name;
|
||||
// Get the content
|
||||
$status = $node->data->contents;
|
||||
$status = str_replace(":|:", "\n", $status);
|
||||
|
||||
$description = $node->data->desc;
|
||||
// Add to return array
|
||||
$rsp[$i] = array("$name", "$status", "$description");
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
return $rsp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the output for a extnoderange command
|
||||
*
|
||||
* @param $xml The XML output from docmd()
|
||||
* @return The nodes and groups
|
||||
*/
|
||||
function extractExtnoderange($xml) {
|
||||
$rsp = array();
|
||||
|
||||
// Extract data returned
|
||||
foreach ($xml->xcatresponse->intersectinggroups as $group) {
|
||||
array_push($rsp, "$group");
|
||||
}
|
||||
|
||||
return $rsp;
|
||||
}
|
||||
<?php
|
||||
/* Required libraries */
|
||||
$TOPDIR = '..';
|
||||
require_once "$TOPDIR/lib/srv_functions.php";
|
||||
require_once "$TOPDIR/lib/jsonwrapper.php";
|
||||
|
||||
/**
|
||||
* Issue a xCAT command, e.g. rinv gpok123 all. This will handle most commands.
|
||||
* If not, you can create your own .php. Look at zCmd.php for an example.
|
||||
*
|
||||
* @param $cmd The xCAT command
|
||||
* @param $tgt The target node or group
|
||||
* @param $args The xCAT command arguments, separated by semicolons
|
||||
* @param $opts The xCAT command options, separated by semicolons
|
||||
* @return The xCAT response. Replies are in the form of JSON
|
||||
*/
|
||||
if (isset($_GET["cmd"])) {
|
||||
// HTTP GET requests
|
||||
$cmd = $_GET["cmd"];
|
||||
$tgt = $_GET["tgt"];
|
||||
$args = $_GET["args"];
|
||||
|
||||
// Special messages put here
|
||||
// This gets sent back to the AJAX request as is.
|
||||
$msg = $_GET["msg"];
|
||||
|
||||
// If no $tgt is given, set $tgt to NULL
|
||||
if (!$tgt) {
|
||||
$tgt = NULL;
|
||||
}
|
||||
|
||||
// If no $msg is given, set $msg to NULL
|
||||
if (!$msg) {
|
||||
$msg = NULL;
|
||||
}
|
||||
|
||||
// If no $args are given, set $args_array to NULL
|
||||
$args_array = array();
|
||||
if ($args) {
|
||||
// If $args contains multiple arguments, split it into an array
|
||||
if (strpos($args,";")) {
|
||||
// Split the arguments into an array
|
||||
$args_array = array();
|
||||
$args_array = explode(";", $args);
|
||||
} else {
|
||||
$args_array = array($args);
|
||||
}
|
||||
}
|
||||
|
||||
// If no $opts are given, set $opts_array to NULL
|
||||
$opts_array = array();
|
||||
if (isset($_GET["opts"])) {
|
||||
$opts = $_GET["opts"];
|
||||
|
||||
// If $args contains multiple arguments, split it into an array
|
||||
if (strpos($opts,";")) {
|
||||
// Split the arguments into an array
|
||||
$opts_array = array();
|
||||
$opts_array = explode(";", $opts);
|
||||
} else {
|
||||
$opts_array = array($opts);
|
||||
}
|
||||
}
|
||||
|
||||
// Submit request and get response
|
||||
$xml = docmd($cmd, $tgt, $args_array, $opts_array);
|
||||
// If the output is flushed, do not return output in JSON
|
||||
if (in_array("flush", $opts_array)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$rsp = array();
|
||||
|
||||
// webrun pping and gangliastatus output needs special handling
|
||||
if(strncasecmp($cmd, "webrun", 6) == 0 && (stristr($args, "pping") || stristr($args, "gangliastatus") || stristr($args, "chtab"))) {
|
||||
$rsp = extractWebrun($xml);
|
||||
}
|
||||
// nodels output needs special handling
|
||||
else if(strncasecmp($cmd, "nodels", 6) == 0) {
|
||||
// Handle the output the same way as webrun
|
||||
$rsp = extractNodels($xml);
|
||||
}
|
||||
// extnoderange output needs special handling
|
||||
// This command gets the nodes and groups
|
||||
else if(strncasecmp($cmd, "extnoderange", 12) == 0) {
|
||||
$rsp = extractExtnoderange($xml);
|
||||
}
|
||||
// Handle the typical output
|
||||
else {
|
||||
foreach ($xml->children() as $child) {
|
||||
foreach ($child->children() as $data) {
|
||||
if($data->name) {
|
||||
$node = $data->name;
|
||||
|
||||
if($data->data->contents){
|
||||
$cont = $data->data->contents;
|
||||
} else {
|
||||
$cont = $data->data;
|
||||
}
|
||||
|
||||
$cont = str_replace(":|:", "\n", $cont);
|
||||
array_push($rsp, "$node: $cont");
|
||||
} else if (strlen("$data") > 2) {
|
||||
$data = str_replace(":|:", "\n", $data);
|
||||
array_push($rsp, "$data");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Remove any HTML that could be used for XSS attacks
|
||||
foreach ($rsp as $key => &$value) {
|
||||
$whatami = gettype($value);
|
||||
if ("string" != $whatami) {
|
||||
//echo "found a non string in rsp array \n";
|
||||
foreach ($value as $key2 => $value2){
|
||||
//echo "Key2:$key2 Value2 type:",gettype($value2)," value2 data: $value2 \n";
|
||||
$value[$key2] = htmlentities($value2, ENT_QUOTES | ENT_HTML5, 'UTF-8');
|
||||
}
|
||||
} else {
|
||||
//echo "Key:$key Value type:",gettype($value)," value data: $value \n";
|
||||
$rsp[$key] = htmlentities($value, ENT_QUOTES | ENT_HTML5, 'UTF-8');
|
||||
//echo "New value: $rsp[$key] \n";
|
||||
}
|
||||
}
|
||||
$msg = htmlentities($msg, ENT_QUOTES | ENT_HTML5, 'UTF-8');
|
||||
|
||||
// Reply in the form of JSON
|
||||
$rtn = array("rsp" => $rsp, "msg" => $msg);
|
||||
echo json_encode($rtn);
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the output for a webrun command
|
||||
*
|
||||
* @param $xml The XML output from docmd()
|
||||
* @return An array containing the output
|
||||
*/
|
||||
function extractWebrun($xml) {
|
||||
$rsp = array();
|
||||
$i = 0;
|
||||
|
||||
// Extract data returned
|
||||
foreach($xml->children() as $nodes){
|
||||
foreach($nodes->children() as $node){
|
||||
// Get the node name
|
||||
$name = $node->name;
|
||||
|
||||
// Get the content
|
||||
$status = $node->data;
|
||||
$status = str_replace(":|:", "\n", $status);
|
||||
|
||||
// Add to return array
|
||||
$rsp[$i] = array("$name", "$status");
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
return $rsp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the output for a nodels command
|
||||
*
|
||||
* @param $xml The XML output from docmd()
|
||||
* @return An array containing the output
|
||||
*/
|
||||
function extractNodels($xml) {
|
||||
$rsp = array();
|
||||
$i = 0;
|
||||
|
||||
// Extract data returned
|
||||
foreach($xml->children() as $nodes){
|
||||
foreach($nodes->children() as $node){
|
||||
// Get the node name
|
||||
$name = $node->name;
|
||||
// Get the content
|
||||
$status = $node->data->contents;
|
||||
$status = str_replace(":|:", "\n", $status);
|
||||
|
||||
$description = $node->data->desc;
|
||||
// Add to return array
|
||||
$rsp[$i] = array("$name", "$status", "$description");
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
|
||||
return $rsp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the output for a extnoderange command
|
||||
*
|
||||
* @param $xml The XML output from docmd()
|
||||
* @return The nodes and groups
|
||||
*/
|
||||
function extractExtnoderange($xml) {
|
||||
$rsp = array();
|
||||
|
||||
// Extract data returned
|
||||
foreach ($xml->xcatresponse->intersectinggroups as $group) {
|
||||
array_push($rsp, "$group");
|
||||
}
|
||||
|
||||
return $rsp;
|
||||
}
|
||||
?>
|
||||
+38
-35
@@ -1,36 +1,39 @@
|
||||
<?php
|
||||
/* Required libraries */
|
||||
$TOPDIR = '..';
|
||||
require_once "$TOPDIR/lib/functions.php";
|
||||
require_once "$TOPDIR/lib/jsonwrapper.php";
|
||||
|
||||
/**
|
||||
* This will handle system commands, e.g. rpm -qa xCAT
|
||||
*
|
||||
* @param $cmd The system command
|
||||
* @return The system response. Replies are in the form of JSON
|
||||
*/
|
||||
if (!isAuthenticated()) {
|
||||
echo ("<b>Please login before continuing!</b>");
|
||||
exit;
|
||||
}
|
||||
|
||||
if (isset($_GET["cmd"])) {
|
||||
// HTTP GET requests
|
||||
$cmd = $_GET["cmd"];
|
||||
$msg = NULL;
|
||||
$ret = "";
|
||||
|
||||
if (isset($_GET["msg"])) {
|
||||
$msg = $_GET["msg"];
|
||||
}
|
||||
|
||||
if ($cmd == "ostype") {
|
||||
$ret = strtolower(PHP_OS);
|
||||
} else {
|
||||
$ret = shell_exec($cmd);
|
||||
}
|
||||
|
||||
echo json_encode(array("rsp"=>$ret, "msg" => $msg));
|
||||
}
|
||||
<?php
|
||||
/* Required libraries */
|
||||
$TOPDIR = '..';
|
||||
require_once "$TOPDIR/lib/functions.php";
|
||||
require_once "$TOPDIR/lib/jsonwrapper.php";
|
||||
|
||||
/**
|
||||
* This will handle system commands, e.g. rpm -qa xCAT
|
||||
*
|
||||
* @param $cmd The system command
|
||||
* @return The system response. Replies are in the form of JSON
|
||||
*/
|
||||
if (!isAuthenticated()) {
|
||||
echo ("<b>Please login before continuing!</b>");
|
||||
exit;
|
||||
}
|
||||
|
||||
if (isset($_GET["cmd"])) {
|
||||
// HTTP GET requests
|
||||
$cmd = $_GET["cmd"];
|
||||
$msg = NULL;
|
||||
$ret = "";
|
||||
|
||||
if (isset($_GET["msg"])) {
|
||||
$msg = $_GET["msg"];
|
||||
}
|
||||
|
||||
if ($cmd == "ostype") {
|
||||
$ret = strtolower(PHP_OS);
|
||||
} else {
|
||||
$ret = shell_exec($cmd);
|
||||
}
|
||||
|
||||
// Remove any HTML that could be used for XSS attacks
|
||||
$ret = htmlentities($ret, ENT_QUOTES | ENT_HTML5, 'UTF-8');
|
||||
$msg = htmlentities($msg, ENT_QUOTES | ENT_HTML5, 'UTF-8');
|
||||
echo json_encode(array("rsp"=>$ret, "msg" => $msg));
|
||||
}
|
||||
?>
|
||||
+158
-141
@@ -1,142 +1,159 @@
|
||||
<?php
|
||||
/* Required libraries */
|
||||
$TOPDIR = '..';
|
||||
require_once "$TOPDIR/lib/functions.php";
|
||||
require_once "$TOPDIR/lib/jsonwrapper.php";
|
||||
|
||||
/**
|
||||
* Issue an xCAT command (only for z)
|
||||
*
|
||||
* @param $cmd The xCAT command
|
||||
* @param $tgt The target node or group
|
||||
* @param $args The xCAT command arguments, separated by semicolons
|
||||
* @return The xCAT response. Replies are in the form of JSON
|
||||
*/
|
||||
if (isset($_GET["cmd"])) {
|
||||
// HTTP GET requests
|
||||
$cmd = $_GET["cmd"];
|
||||
$tgt = $_GET["tgt"];
|
||||
$args = $_GET["args"];
|
||||
|
||||
// Attachments are put here
|
||||
$att = $_GET["att"];
|
||||
|
||||
// Special messages put here
|
||||
$msg = $_GET["msg"];
|
||||
|
||||
// If no $tgt is given, set $tgt to NULL
|
||||
if (!$tgt) {
|
||||
$tgt = NULL;
|
||||
}
|
||||
|
||||
// If no $args is given, set $args to NULL
|
||||
if (!$args) {
|
||||
$args = NULL;
|
||||
}
|
||||
|
||||
// If no $msg is given, set $msg to NULL
|
||||
if (!$msg) {
|
||||
$msg = NULL;
|
||||
}
|
||||
|
||||
// If no $att is given, set $att to NULL
|
||||
if (!$att) {
|
||||
$att = NULL;
|
||||
}
|
||||
|
||||
// If $args contains multiple arguments, split it into an array
|
||||
// Separators used are: || or ;
|
||||
if (strpos($args, "||")) {
|
||||
// Split the arguments into an array
|
||||
$arr = array();
|
||||
$arr = explode("||", $args);
|
||||
} else if (strpos($args, ";")) {
|
||||
// Split the arguments into an array
|
||||
$arr = array();
|
||||
$arr = explode(";", $args);
|
||||
} else {
|
||||
$arr = array($args);
|
||||
}
|
||||
|
||||
$rsp = array();
|
||||
|
||||
// Replace user entry
|
||||
if (strncasecmp($cmd, "chvm", 4) == 0 && strncasecmp($arr[0], "--replacevs", 11) == 0) {
|
||||
// Directory /var/tmp permissions = 777
|
||||
// You can write anything to that directory
|
||||
$userEntry = "/var/tmp/$tgt.txt";
|
||||
$handle = fopen($userEntry, 'w') or die("Cannot open $userEntry");
|
||||
fwrite($handle, $att);
|
||||
fclose($handle);
|
||||
|
||||
// CLI command: chvm gpok249 --replacevs /tmp/dirEntry.txt
|
||||
// Replace user entry
|
||||
array_push($arr, $userEntry);
|
||||
$xml = docmd($cmd, $tgt, $arr, NULL);
|
||||
foreach ($xml->children() as $child) {
|
||||
foreach ($child->children() as $data) {
|
||||
$data = str_replace(":|:", "\n", $data);
|
||||
array_push($rsp, "$data");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create virtual server
|
||||
else if (strncasecmp($cmd, "mkvm", 4) == 0) {
|
||||
// Directory /var/tmp permissions = 777
|
||||
// You can write anything to that directory
|
||||
$userEntry = "/var/tmp/$tgt.txt";
|
||||
$handle = fopen($userEntry, 'w') or die("Cannot open $userEntry");
|
||||
fwrite($handle, $att);
|
||||
fclose($handle);
|
||||
|
||||
// CLI command: mkvm gpok3 /tmp/gpok3.txt
|
||||
// Create user entry
|
||||
array_unshift($arr, $userEntry);
|
||||
$xml = docmd($cmd, $tgt, $arr, NULL);
|
||||
foreach ($xml->children() as $child) {
|
||||
foreach ($child->children() as $data) {
|
||||
$data = str_replace(":|:", "\n", $data);
|
||||
array_push($rsp, "$data");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Run shell script
|
||||
// This is a typical command used by all platforms. It is put here because
|
||||
// most of the code needed are already here
|
||||
else if (strncasecmp($cmd, "xdsh", 4) == 0) {
|
||||
// Directory /var/tmp permissions = 777
|
||||
// You can write anything to that directory
|
||||
$msgArgs = explode(";", $msg);
|
||||
$inst = str_replace("out=scriptStatusBar", "", $msgArgs[0]);
|
||||
$script = "/var/tmp/script$inst.sh";
|
||||
|
||||
// Write to file
|
||||
$handle = fopen($script, 'w') or die("Cannot open $script");
|
||||
fwrite($handle, $att);
|
||||
fclose($handle);
|
||||
|
||||
// Change it to executable
|
||||
chmod($script, 0777);
|
||||
|
||||
// CLI command: xdsh gpok3 -e /var/tmp/gpok3.sh
|
||||
// Create user entry
|
||||
array_push($arr, $script);
|
||||
$xml = docmd($cmd, $tgt, $arr, NULL);
|
||||
foreach ($xml->children() as $child) {
|
||||
foreach ($child->children() as $data) {
|
||||
$data = str_replace(":|:", "\n", $data);
|
||||
array_push($rsp, "$data");
|
||||
}
|
||||
}
|
||||
|
||||
// Remove this file
|
||||
unlink($script);
|
||||
}
|
||||
|
||||
// Reply in the form of JSON
|
||||
$rtn = array("rsp" => $rsp, "msg" => $msg);
|
||||
echo json_encode($rtn);
|
||||
}
|
||||
<?php
|
||||
/* Required libraries */
|
||||
$TOPDIR = '..';
|
||||
require_once "$TOPDIR/lib/functions.php";
|
||||
require_once "$TOPDIR/lib/jsonwrapper.php";
|
||||
|
||||
/**
|
||||
* Issue an xCAT command (only for z)
|
||||
*
|
||||
* @param $cmd The xCAT command
|
||||
* @param $tgt The target node or group
|
||||
* @param $args The xCAT command arguments, separated by semicolons
|
||||
* @return The xCAT response. Replies are in the form of JSON
|
||||
*/
|
||||
if (isset($_GET["cmd"])) {
|
||||
// HTTP GET requests
|
||||
$cmd = $_GET["cmd"];
|
||||
$tgt = $_GET["tgt"];
|
||||
$args = $_GET["args"];
|
||||
|
||||
// Attachments are put here
|
||||
$att = $_GET["att"];
|
||||
|
||||
// Special messages put here
|
||||
$msg = $_GET["msg"];
|
||||
|
||||
// If no $tgt is given, set $tgt to NULL
|
||||
if (!$tgt) {
|
||||
$tgt = NULL;
|
||||
}
|
||||
|
||||
// If no $args is given, set $args to NULL
|
||||
if (!$args) {
|
||||
$args = NULL;
|
||||
}
|
||||
|
||||
// If no $msg is given, set $msg to NULL
|
||||
if (!$msg) {
|
||||
$msg = NULL;
|
||||
}
|
||||
|
||||
// If no $att is given, set $att to NULL
|
||||
if (!$att) {
|
||||
$att = NULL;
|
||||
}
|
||||
|
||||
// If $args contains multiple arguments, split it into an array
|
||||
// Separators used are: || or ;
|
||||
if (strpos($args, "||")) {
|
||||
// Split the arguments into an array
|
||||
$arr = array();
|
||||
$arr = explode("||", $args);
|
||||
} else if (strpos($args, ";")) {
|
||||
// Split the arguments into an array
|
||||
$arr = array();
|
||||
$arr = explode(";", $args);
|
||||
} else {
|
||||
$arr = array($args);
|
||||
}
|
||||
|
||||
$rsp = array();
|
||||
|
||||
// Replace user entry
|
||||
if (strncasecmp($cmd, "chvm", 4) == 0 && strncasecmp($arr[0], "--replacevs", 11) == 0) {
|
||||
// Directory /var/tmp permissions = 777
|
||||
// You can write anything to that directory
|
||||
$userEntry = "/var/tmp/$tgt.txt";
|
||||
$handle = fopen($userEntry, 'w') or die("Cannot open $userEntry");
|
||||
fwrite($handle, $att);
|
||||
fclose($handle);
|
||||
|
||||
// CLI command: chvm gpok249 --replacevs /tmp/dirEntry.txt
|
||||
// Replace user entry
|
||||
array_push($arr, $userEntry);
|
||||
$xml = docmd($cmd, $tgt, $arr, NULL);
|
||||
foreach ($xml->children() as $child) {
|
||||
foreach ($child->children() as $data) {
|
||||
$data = str_replace(":|:", "\n", $data);
|
||||
array_push($rsp, "$data");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Create virtual server
|
||||
else if (strncasecmp($cmd, "mkvm", 4) == 0) {
|
||||
// Directory /var/tmp permissions = 777
|
||||
// You can write anything to that directory
|
||||
$userEntry = "/var/tmp/$tgt.txt";
|
||||
$handle = fopen($userEntry, 'w') or die("Cannot open $userEntry");
|
||||
fwrite($handle, $att);
|
||||
fclose($handle);
|
||||
|
||||
// CLI command: mkvm gpok3 /tmp/gpok3.txt
|
||||
// Create user entry
|
||||
array_unshift($arr, $userEntry);
|
||||
$xml = docmd($cmd, $tgt, $arr, NULL);
|
||||
foreach ($xml->children() as $child) {
|
||||
foreach ($child->children() as $data) {
|
||||
$data = str_replace(":|:", "\n", $data);
|
||||
array_push($rsp, "$data");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Run shell script
|
||||
// This is a typical command used by all platforms. It is put here because
|
||||
// most of the code needed are already here
|
||||
else if (strncasecmp($cmd, "xdsh", 4) == 0) {
|
||||
// Directory /var/tmp permissions = 777
|
||||
// You can write anything to that directory
|
||||
$msgArgs = explode(";", $msg);
|
||||
$inst = str_replace("out=scriptStatusBar", "", $msgArgs[0]);
|
||||
$script = "/var/tmp/script$inst.sh";
|
||||
|
||||
// Write to file
|
||||
$handle = fopen($script, 'w') or die("Cannot open $script");
|
||||
fwrite($handle, $att);
|
||||
fclose($handle);
|
||||
|
||||
// Change it to executable
|
||||
chmod($script, 0777);
|
||||
|
||||
// CLI command: xdsh gpok3 -e /var/tmp/gpok3.sh
|
||||
// Create user entry
|
||||
array_push($arr, $script);
|
||||
$xml = docmd($cmd, $tgt, $arr, NULL);
|
||||
foreach ($xml->children() as $child) {
|
||||
foreach ($child->children() as $data) {
|
||||
$data = str_replace(":|:", "\n", $data);
|
||||
array_push($rsp, "$data");
|
||||
}
|
||||
}
|
||||
|
||||
// Remove this file
|
||||
unlink($script);
|
||||
}
|
||||
|
||||
// Remove any HTML that could be used for XSS attacks
|
||||
foreach ($rsp as $key => &$value) {
|
||||
$whatami = gettype($value);
|
||||
if ("string" != $whatami) {
|
||||
//echo "found a non string in rsp array \n";
|
||||
foreach ($value as $key2 => $value2){
|
||||
//echo "Key2:$key2 Value2 type:",gettype($value2)," value2 data: $value2 \n";
|
||||
$value[$key2] = htmlentities($value2, ENT_QUOTES | ENT_HTML5, 'UTF-8');
|
||||
}
|
||||
} else {
|
||||
//echo "Key:$key Value type:",gettype($value)," value data: $value \n";
|
||||
$rsp[$key] = htmlentities($value, ENT_QUOTES | ENT_HTML5, 'UTF-8');
|
||||
//echo "New value: $rsp[$key] \n";
|
||||
}
|
||||
}
|
||||
$msg = htmlentities($msg, ENT_QUOTES | ENT_HTML5, 'UTF-8');
|
||||
|
||||
// Reply in the form of JSON
|
||||
$rtn = array("rsp" => $rsp, "msg" => $msg);
|
||||
echo json_encode($rtn);
|
||||
}
|
||||
?>
|
||||
+151
-7
@@ -44,6 +44,7 @@ use xCAT::zvmUtils;
|
||||
my $version = "1";
|
||||
|
||||
my $comments = ''; # Comments for the IVP run
|
||||
my $dataFile = ''; # Input data file
|
||||
my $decode = ''; # String specified by the --decode operand.
|
||||
my $disable = ''; # Disable scheduled IVP from running.
|
||||
my $displayHelp = 0; # Display help information
|
||||
@@ -56,6 +57,8 @@ my %hosts; # Information on host nodes known by xCAT
|
||||
my $id = ''; # Id of the IVP run
|
||||
my %ignored; # List of ignored messages
|
||||
my $ignoreCnt = 0; # Number of times we ignored a message
|
||||
my $issueCmdOverIUCV = ''; # Issue a command to a node over IUCV
|
||||
my $issueCmdToNode = ''; # Issue a command to a node using IUCV or SSH
|
||||
my %localIPs; # Hash of the Local IP addresses for the xCAT MN system
|
||||
my $logDir = '/var/log/xcat/ivp'; # Log location
|
||||
my $logFile = ''; # Log file name and location
|
||||
@@ -63,7 +66,7 @@ my $logFileHandle; # File handle for the log file.
|
||||
my @ivpSummary; # Summary output lines for an IVP run.
|
||||
my $locApplSystemRole = '/var/lib/sspmod/appliance_system_role';
|
||||
my %mnInfo; # Managed node environment information
|
||||
my %msgsToIgnore; # Hash of messages to ignore
|
||||
my %msgsToIgnore; # Hash of messages to ignore
|
||||
my $needToFinishLogFile = 0; # If 1 then finishLogFile() needs to be called
|
||||
my $nodeName = ''; # Name of node to be verified
|
||||
my $notify = 0; # Notify a user
|
||||
@@ -112,6 +115,14 @@ my %verifySets = (
|
||||
[ 'Encoding a string',
|
||||
'encodeDecodeString()',
|
||||
],
|
||||
'$issueCmdOverIUCV ne \'\'' =>
|
||||
[ 'Issue a command to a node using IUCV',
|
||||
'cmdOnVM( \'onlyIUCV\' )',
|
||||
],
|
||||
'$issueCmdToNode ne \'\'' =>
|
||||
[ 'Issue a command to a node using IUCV or SSH',
|
||||
'cmdOnVM( \'either\' )',
|
||||
],
|
||||
'$remove' =>
|
||||
[ 'Remove an automated periodic IVP',
|
||||
'removeIVP( $id )',
|
||||
@@ -159,7 +170,7 @@ my %verifySets = (
|
||||
'verifyPower( $nodeName )',
|
||||
'verifyAccess( $nodeName )',
|
||||
'getDistro( $nodeName )',
|
||||
'verifyService($nodeOrIP, "cloud-config,2,3,4,5 cloud-final,2,3,4,5 cloud-init,2,3,4,5 cloud-init-local,2,3,4,5")',
|
||||
'verifyService($nodeName, "cloud-config,2,3,4,5 cloud-final,2,3,4,5 cloud-init,2,3,4,5 cloud-init-local,2,3,4,5")',
|
||||
'showCILevel()',
|
||||
],
|
||||
'$verifyXcatconf4z' =>
|
||||
@@ -167,7 +178,7 @@ my %verifySets = (
|
||||
'verifyPower( $nodeName )',
|
||||
'verifyAccess( $nodeName )',
|
||||
'getDistro( $nodeName )',
|
||||
'verifyXcatconf4z()',
|
||||
'verifyXcatconf4z( $nodeName )',
|
||||
],
|
||||
'$test' =>
|
||||
[ 'Script test functon.',
|
||||
@@ -193,6 +204,14 @@ my $usage_string = "Usage:\n
|
||||
--capturereqs
|
||||
Verify that node meets system capture
|
||||
requirements for OpenStack.
|
||||
--cmdoveriucv <cmd>
|
||||
Issue a command to a node using IUCV.
|
||||
Specify a period for <cmd> when combining this
|
||||
option with the --file option.
|
||||
--cmdtonode <cmd> Issue a command to a node using IUCV or SSH
|
||||
if IUCV is not available.
|
||||
Specify a period for <cmd> when combining this
|
||||
option with the --file option.
|
||||
-c | --cloudinit
|
||||
Verify that node has cloud-init installed.
|
||||
--comments
|
||||
@@ -214,6 +233,9 @@ my $usage_string = "Usage:\n
|
||||
string from the zvmivp table. The <parm> must be
|
||||
an ASCII string. This function does not support
|
||||
encoding a UTF-8 character string.
|
||||
--file File location containing additional input.
|
||||
When used with the --cmdoveriucv or --cmdtonode
|
||||
operands, this file contains the command to issue.
|
||||
--fullivp
|
||||
Run the full end-to-end IVP. This
|
||||
verification checks the compute node and builds
|
||||
@@ -380,6 +402,127 @@ sub checkForDefault {
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------
|
||||
|
||||
=head3 cmdOnVM
|
||||
|
||||
Description : Send a command to a node and show the result.
|
||||
Arguments : Target function, either 'onlyIUCV' or 'either'.
|
||||
Returns : Return code:
|
||||
0 - Normal Linux success
|
||||
255 - Unable to SSH to system
|
||||
non-zero - command error
|
||||
Output from the command or a error string on an SSH failure.
|
||||
Example : $rc = cmdOnVM( 'onlyIUCV' );
|
||||
$rc = cmdOnVM( 'either' );
|
||||
|
||||
=cut
|
||||
|
||||
#-------------------------------------------------------
|
||||
sub cmdOnVM {
|
||||
my ( $targetFunc ) = @_;
|
||||
my $cmd = '';
|
||||
my $hcp = '';
|
||||
my @lines;
|
||||
my $rc = 0;
|
||||
my $out = '';
|
||||
my $sudo;
|
||||
my $user;
|
||||
my $userid = '';
|
||||
|
||||
# Get the command to issue.
|
||||
if ( $targetFunc eq 'onlyIUCV' ) {
|
||||
if ( $issueCmdOverIUCV ne '.' ) {
|
||||
$cmd = $issueCmdOverIUCV;
|
||||
}
|
||||
} else {
|
||||
if ( $issueCmdToNode ne '.' ) {
|
||||
$cmd = $issueCmdToNode;
|
||||
}
|
||||
}
|
||||
|
||||
# Use the data file if it was specified.
|
||||
if ( $dataFile ne '' ) {
|
||||
if ( -e $dataFile ) {
|
||||
open my $handle, '<', $dataFile;
|
||||
chomp( @lines = <$handle> );
|
||||
close $handle;
|
||||
if ( $lines[0] ne '' ) {
|
||||
$cmd = $lines[0];
|
||||
} else {
|
||||
logResponse( 'DF', 'GENERIC_RESPONSE', "$dataFile does not have anything in the first line.");
|
||||
goto FINISH_cmdUsingIUCV;
|
||||
}
|
||||
} else {
|
||||
logResponse( 'DF', 'GENERIC_RESPONSE', "$dataFile does not exist.");
|
||||
goto FINISH_cmdUsingIUCV;
|
||||
}
|
||||
}
|
||||
|
||||
# Verify that we have a command to issue.
|
||||
if ( $cmd eq '' ) {
|
||||
logResponse( 'DF', 'GENERIC_RESPONSE', "A command to issue was not specified.");
|
||||
goto FINISH_cmdUsingIUCV;
|
||||
}
|
||||
|
||||
($user, $sudo) = xCAT::zvmUtils->getSudoer();
|
||||
|
||||
# Get the required properties (hcp, userid, user) from the node
|
||||
$out = `/opt/xcat/bin/lsdef $nodeName -i hcp,userid`;
|
||||
$rc = $?;
|
||||
if ( $rc eq 0 ) {
|
||||
my $fndNode = 0;
|
||||
@lines = split( '\n', $out );
|
||||
my $host = '';
|
||||
foreach my $line ( @lines ) {
|
||||
$line =~ s/^\s+|\s+$//g; # trim blanks from both ends of the string
|
||||
if ( $line =~ /Object name:/ ) {
|
||||
$fndNode = 1;
|
||||
next;
|
||||
} elsif ( $line =~ /hcp\=/ ) {
|
||||
($hcp) = $line =~ m/hcp\=(.*)/;
|
||||
next;
|
||||
} elsif ( $line =~ /userid\=/ ) {
|
||||
($userid) = $line =~ m/userid\=(.*)/;
|
||||
next;
|
||||
}
|
||||
}
|
||||
if ( $fndNode != 1 ) {
|
||||
logResponse( 'DF', 'GENERIC_RESPONSE', "'$nodeName' is not an xCAT node." );
|
||||
goto FINISH_cmdUsingIUCV;
|
||||
}
|
||||
} else {
|
||||
$rc = logResponse( 'DFS', 'GNRL01', "$cmd", $rc, $out );
|
||||
goto FINISH_cmdUsingIUCV;
|
||||
}
|
||||
|
||||
# Send the command through IUCV
|
||||
logResponse( 'DF', '*NONFORMATTED*', "\n**************************\nData for the function call\n**************************" );
|
||||
logResponse( 'DF', '*NONFORMATTED*', " Node: $nodeName" );
|
||||
if ( $targetFunc eq 'onlyIUCV' ) {
|
||||
logResponse( 'DF', '*NONFORMATTED*', "z/VM userid: $userid" );
|
||||
logResponse( 'DF', '*NONFORMATTED*', " HCP: $hcp" );
|
||||
logResponse( 'DF', '*NONFORMATTED*', " User: $user" );
|
||||
logResponse( 'DF', '*NONFORMATTED*', " Function: xCAT::zvmUtils->execcmdthroughIUCV" );
|
||||
} else {
|
||||
logResponse( 'DF', '*NONFORMATTED*', " User: $user" );
|
||||
logResponse( 'DF', '*NONFORMATTED*', " Function: xCAT::zvmUtils->execcmdonVM" );
|
||||
}
|
||||
logResponse( 'DF', '*NONFORMATTED*', " Cmd: $cmd" );
|
||||
|
||||
logResponse( 'DF', '*NONFORMATTED*', "\n*********************\nInvoking the function\n*********************" );
|
||||
if ( $targetFunc eq 'onlyIUCV' ) {
|
||||
$out = xCAT::zvmUtils->execcmdthroughIUCV( $user, $hcp, $userid, $cmd );
|
||||
} else {
|
||||
$out = xCAT::zvmUtils->execcmdonVM( $user, $nodeName, $cmd );
|
||||
}
|
||||
logResponse( 'DF', '*NONFORMATTED*', "\n******\nResult\n******\n$out" );
|
||||
|
||||
FINISH_cmdUsingIUCV:
|
||||
return $rc;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------
|
||||
|
||||
=head3 driveCronList
|
||||
@@ -2590,7 +2733,7 @@ FINISH_verifyService:
|
||||
|
||||
Description : Verify xcatconf4z is properly installed
|
||||
and is the correct version.
|
||||
Arguments : None
|
||||
Arguments : Node name or IP address
|
||||
Returns : 0 - No error
|
||||
non-zero - Terminating error detected.
|
||||
Example : $rc = verifyXcatconf4z();
|
||||
@@ -2695,10 +2838,13 @@ if (!GetOptions(
|
||||
'disable' => \$disable,
|
||||
'enable' => \$enable,
|
||||
'encode=s' => \$encode,
|
||||
'file=s' => \$dataFile,
|
||||
'fullivp' => \$runFullIVP,
|
||||
'h|help' => \$displayHelp,
|
||||
'i|id=s' => \$id,
|
||||
'ignore=s' => \$ignoreOpt,
|
||||
'cmdoveriucv=s' => \$issueCmdOverIUCV,
|
||||
'cmdtonode=s' => \$issueCmdToNode,
|
||||
'n|node=s' => \$nodeName,
|
||||
'notify' => \$notifyOnErrorOrWarning,
|
||||
'openstackuser=s' => \$openstackUser,
|
||||
@@ -2810,9 +2956,7 @@ if ( $decode ne '' or
|
||||
$remove or
|
||||
$schedule ne '' ) {
|
||||
# IVP runs do not need the node.
|
||||
} elsif ( $nodeName ne '' ) {
|
||||
$nodeName = lc( $nodeName );
|
||||
} else {
|
||||
} elsif ( $nodeName eq '' ) {
|
||||
$rc = logResponse( 'DFS', 'OPER01', '-n or --node' );
|
||||
goto FINISH_main;
|
||||
}
|
||||
|
||||
+578
-127
File diff suppressed because it is too large
Load Diff
@@ -1945,8 +1945,9 @@ sub startDiscovery{
|
||||
'ldapsrv', 'lohcost',
|
||||
'maint', 'maint630', 'maint640',
|
||||
'migmaint', 'monwrite', 'mproute',
|
||||
'operator', 'operatns', 'opersymp', 'opncloud', 'osadmin1', 'osadmin2',
|
||||
'osadmin3', 'osamaint', 'osasf', 'ovfdev62',
|
||||
'operator', 'operatns', 'opersymp', 'opncloud',
|
||||
'osadmin1', 'osadmin2', 'osadmin3',
|
||||
'osamaint', 'osasf', 'ovfdev62',
|
||||
'perfsvm', 'persmapi', 'pmaint', 'portmap',
|
||||
'racfsmf', 'racfvm', 'racmaint', 'rexecd',
|
||||
'rscs', 'rscsauth', 'rscsdns', 'rxagent1',
|
||||
@@ -1955,8 +1956,8 @@ sub startDiscovery{
|
||||
'tcpip', 'tcpmaint', 'tsafvm',
|
||||
'uftd',
|
||||
'vmnfs', 'vmrmadmn', 'vmrmsvm',
|
||||
'vmservp', 'vmservr', 'vmservu', 'vmservs', 'vsmevsrv',
|
||||
'vsmguard', 'vsmproxy', 'vsmreqim', 'vsmreqin', 'vsmreqiu',
|
||||
'vmservp', 'vmservr', 'vmservu', 'vmservs', 'vsmevsrv',
|
||||
'vsmguard', 'vsmproxy', 'vsmreqim', 'vsmreqin', 'vsmreqiu',
|
||||
'vsmreqi6', 'vsmwork1', 'vsmwork2', 'vsmwork3', 'vsmwork4',
|
||||
'vsmwork5', 'vsmwork6', 'vsmwork7', 'vsmwork8', 'vsmwork9',
|
||||
'xcat', 'xcatserv', 'xchange',
|
||||
|
||||
@@ -46,9 +46,8 @@ Obsoletes: atftp-xcat
|
||||
%ifos linux
|
||||
#
|
||||
# PCM does not use or ship grub2-xcat
|
||||
Requires: grub2-xcat perl-Net-HTTPS-NB perl-HTTP-Async
|
||||
%if %nots390x
|
||||
Requires: grub2-xcat
|
||||
Requires: grub2-xcat perl-Net-HTTPS-NB perl-HTTP-Async
|
||||
%endif
|
||||
%endif
|
||||
%endif
|
||||
|
||||
+2395
-3329
File diff suppressed because it is too large
Load Diff
@@ -28,9 +28,12 @@ Conflicts: xCATsn
|
||||
Requires: perl-DBD-SQLite
|
||||
Requires: xCAT-client = 4:%{version}-%{release}
|
||||
Requires: xCAT-server = 4:%{version}-%{release}
|
||||
|
||||
%ifnarch s390x
|
||||
Requires: xCAT-probe = 4:%{version}-%{release}
|
||||
Requires: xCAT-genesis-scripts-x86_64 = 1:%{version}-%{release}
|
||||
Requires: xCAT-genesis-scripts-ppc64 = 1:%{version}-%{release}
|
||||
%endif
|
||||
|
||||
%define pcm %(if [ "$pcm" = "1" ];then echo 1; else echo 0; fi)
|
||||
%define notpcm %(if [ "$pcm" = "1" ];then echo 0; else echo 1; fi)
|
||||
@@ -86,8 +89,10 @@ Requires: ipmitool-xcat >= 1.8.17-1
|
||||
|
||||
%if %notpcm
|
||||
# PCM does not need or ship syslinux-xcat
|
||||
%ifnarch s390x
|
||||
Requires: syslinux-xcat
|
||||
%endif
|
||||
%endif
|
||||
|
||||
%description
|
||||
xCAT is a server management package intended for at-scale management, including
|
||||
|
||||
Reference in New Issue
Block a user