2010-07-21 03:35:31 +00:00
|
|
|
/**
|
|
|
|
* Load update page
|
2010-11-17 18:53:40 +00:00
|
|
|
*
|
2010-07-21 03:35:31 +00:00
|
|
|
* @return Nothing
|
|
|
|
*/
|
2010-11-17 18:53:40 +00:00
|
|
|
function loadUpdatePage() {
|
|
|
|
var repositoryDiv = $('<div id="repository"></div>');
|
|
|
|
var rpmDiv = $('<div id="rpm"></div>');
|
|
|
|
var statusDiv = createStatusBar("update");
|
|
|
|
statusDiv.hide();
|
|
|
|
|
|
|
|
$('#updateTab').append(statusDiv);
|
2011-04-16 14:40:15 +00:00
|
|
|
$('#updateTab').append('<br/>');
|
2010-11-17 18:53:40 +00:00
|
|
|
$('#updateTab').append(repositoryDiv);
|
|
|
|
$('#updateTab').append(rpmDiv);
|
|
|
|
|
2010-12-03 22:09:36 +00:00
|
|
|
var infoBar = createInfoBar('Select the repository to use and the RPMs to update, then click Update.');
|
2010-11-17 18:53:40 +00:00
|
|
|
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
|
|
|
|
});
|
2010-10-08 03:03:42 +00:00
|
|
|
}
|
2010-07-21 03:35:31 +00:00
|
|
|
|
|
|
|
/**
|
2010-10-08 03:03:42 +00:00
|
|
|
* Show the RPM Repository, it can use user's last choice and input
|
2010-11-17 18:53:40 +00:00
|
|
|
*
|
|
|
|
* @param data
|
|
|
|
* Data returned from HTTP request
|
2010-07-21 03:35:31 +00:00
|
|
|
* @return Nothing
|
|
|
|
*/
|
|
|
|
function showRepository(data) {
|
2010-12-03 22:09:36 +00:00
|
|
|
var develRepository = "";
|
|
|
|
var stableRepository = "";
|
|
|
|
var show = "";
|
2010-11-17 18:53:40 +00:00
|
|
|
|
2011-04-16 14:40:15 +00:00
|
|
|
// Get the corresponding repository by OS Type
|
2012-03-14 19:20:37 +00:00
|
|
|
if (data.rsp == "aix") {
|
|
|
|
// No repository exists for AIX on sourceforge!
|
2010-12-03 22:09:36 +00:00
|
|
|
develRepository = "http://xcat.sourceforge.net/aix/devel/xcat-core/";
|
|
|
|
stableRepository = "http://xcat.sourceforge.net/aix/xcat-core/";
|
2010-11-17 18:53:40 +00:00
|
|
|
} else {
|
2012-03-14 19:20:37 +00:00
|
|
|
develRepository = "http://sourceforge.net/projects/xcat/files/yum/devel/xcat-core/";
|
|
|
|
stableRepository = "http://sourceforge.net/projects/xcat/files/yum/stable/xcat-core/";
|
2010-11-17 18:53:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var repoList = $('<ol></ol>');
|
|
|
|
|
2011-04-16 14:40:15 +00:00
|
|
|
// Display the Devel Repository, remember user's last selection
|
2010-12-03 22:09:36 +00:00
|
|
|
show = show + "<li><input type='radio' ";
|
2011-09-09 19:34:05 +00:00
|
|
|
if ($.cookie('xcatrepository') == 1) {
|
2010-12-03 22:09:36 +00:00
|
|
|
show = show + "checked='true'";
|
2010-11-17 18:53:40 +00:00
|
|
|
}
|
2010-12-03 22:09:36 +00:00
|
|
|
show = show + "name='reporadio' value='" + develRepository + "'>";
|
2011-04-16 14:40:15 +00:00
|
|
|
show = show + "<strong>Development</strong>: " + develRepository + "</li>";
|
2010-12-03 22:09:36 +00:00
|
|
|
repoList.append(show);
|
2010-11-17 18:53:40 +00:00
|
|
|
|
2011-04-16 14:40:15 +00:00
|
|
|
// Display the Stable Repository, remember user's last selection
|
2010-12-03 22:09:36 +00:00
|
|
|
show = "<li><input type='radio' ";
|
2011-09-09 19:34:05 +00:00
|
|
|
if ($.cookie('xcatrepository') == 2) {
|
2010-12-03 22:09:36 +00:00
|
|
|
show = show + "checked='true'";
|
2010-11-17 18:53:40 +00:00
|
|
|
}
|
2011-04-16 14:40:15 +00:00
|
|
|
show = show + "name='reporadio' value='" + stableRepository + "' checked='true'>";
|
|
|
|
show = show + "<strong>Stable</strong>: " + stableRepository + "</li>";
|
2010-12-03 22:09:36 +00:00
|
|
|
repoList.append(show);
|
2010-11-17 18:53:40 +00:00
|
|
|
|
2011-04-16 14:40:15 +00:00
|
|
|
// Display the Input Repository, remember user's last selection
|
2011-09-09 19:34:05 +00:00
|
|
|
if (($.cookie('xcatrepository')) && ($.cookie('xcatrepository') != 1)
|
|
|
|
&& ($.cookie('xcatrepository') != 2)) {
|
2010-12-03 22:09:36 +00:00
|
|
|
show = "<li><input type='radio' checked='true' name='reporadio' value=''>Other: ";
|
2011-04-16 14:40:15 +00:00
|
|
|
show += "<input style='width: 500px' id='repositoryaddr' value='"
|
|
|
|
+ $.cookie('xcatrepository') + "'</li>";
|
2010-11-17 18:53:40 +00:00
|
|
|
} else {
|
2010-12-03 22:09:36 +00:00
|
|
|
show = "<li><input type='radio' name='reporadio' value=''>Other: ";
|
|
|
|
show += "<input style='width: 500px' id='repositoryaddr' value=''</li>";
|
2010-11-17 18:53:40 +00:00
|
|
|
}
|
2010-12-03 22:09:36 +00:00
|
|
|
repoList.append(show);
|
2011-09-09 19:34:05 +00:00
|
|
|
|
2010-11-17 18:53:40 +00:00
|
|
|
$('#repository fieldset').append(repoList);
|
2010-07-21 03:35:31 +00:00
|
|
|
}
|
|
|
|
|
2010-11-17 18:53:40 +00:00
|
|
|
/**
|
|
|
|
* Show all xCAT RPMs
|
|
|
|
*
|
|
|
|
* @param data
|
|
|
|
* Data returned from HTTP request
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
2010-10-08 03:03:42 +00:00
|
|
|
function showRpmInfo(data) {
|
2010-12-03 22:09:36 +00:00
|
|
|
var rpms = null;
|
|
|
|
var show = "";
|
2011-04-16 14:40:15 +00:00
|
|
|
var rpmNames = new Array("xCAT-client", "perl-xCAT", "xCAT-server", "xCAT", "xCAT-rmc",
|
|
|
|
"xCAT-UI");
|
2010-11-17 18:53:40 +00:00
|
|
|
var temp = 0;
|
|
|
|
if (null == data.rsp) {
|
2010-12-03 22:09:36 +00:00
|
|
|
$('#rpm fieldset').append("Error getting RPMs!");
|
2010-11-17 18:53:40 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-12-03 22:09:36 +00:00
|
|
|
rpms = data.rsp.split(/\n/);
|
2011-09-09 19:34:05 +00:00
|
|
|
|
2011-04-16 14:40:15 +00:00
|
|
|
// No rpm installed, return
|
2010-12-03 22:09:36 +00:00
|
|
|
if (1 > rpms.length) {
|
|
|
|
$('#rpm fieldset').append("No RPMs installed!");
|
2010-11-17 18:53:40 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-04-16 14:40:15 +00:00
|
|
|
// Clear the old data
|
2010-11-17 18:53:40 +00:00
|
|
|
$('#rpm fieldset').children().remove();
|
2010-12-03 22:09:36 +00:00
|
|
|
$('#rpm fieldset').append("<legend>xCAT RPMs</legend>");
|
|
|
|
show = "<table id=rpmtable >";
|
2011-09-28 21:38:12 +00:00
|
|
|
show += "<thead class='ui-widget-header'><tr>";
|
2010-12-03 22:09:36 +00:00
|
|
|
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++) {
|
2011-04-16 14:40:15 +00:00
|
|
|
// Empty line continue
|
2011-09-09 19:34:05 +00:00
|
|
|
if (!rpms[temp]) {
|
2010-11-17 18:53:40 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-04-16 14:40:15 +00:00
|
|
|
// The RPM is not installed, continue
|
2011-09-09 19:34:05 +00:00
|
|
|
if (rpms[temp].indexOf("not") != -1) {
|
2010-11-17 18:53:40 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2011-04-16 14:40:15 +00:00
|
|
|
// Show the version in table
|
2010-12-03 22:09:36 +00:00
|
|
|
show += "<tr>";
|
|
|
|
show += "<td><input type='checkbox' value='" + rpmNames[temp] + "'></td>";
|
2011-04-16 14:40:15 +00:00
|
|
|
show += "<td>" + rpmNames[temp] + "</td><td>"
|
|
|
|
+ rpms[temp].substr(rpmNames[temp].length + 1) + "</td>";
|
2010-12-03 22:09:36 +00:00
|
|
|
show += "</tr>";
|
2010-11-17 18:53:40 +00:00
|
|
|
}
|
2010-12-03 22:09:36 +00:00
|
|
|
show += "</table>";
|
|
|
|
show += "<br\>";
|
|
|
|
$('#rpm fieldset').append(show);
|
2010-11-17 18:53:40 +00:00
|
|
|
|
2011-04-16 14:40:15 +00:00
|
|
|
// Add the update button
|
2010-11-17 18:53:40 +00:00
|
|
|
var updateButton = createButton('Update');
|
|
|
|
$('#rpm fieldset').append(updateButton);
|
|
|
|
updateButton.bind('click', function() {
|
|
|
|
updateRpm();
|
|
|
|
});
|
2010-07-21 03:35:31 +00:00
|
|
|
}
|
|
|
|
|
2010-11-17 18:53:40 +00:00
|
|
|
/**
|
|
|
|
* Select all checkboxes
|
|
|
|
*
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
2010-10-08 03:03:42 +00:00
|
|
|
function updateSelectAll() {
|
2010-11-17 18:53:40 +00:00
|
|
|
var check_status = $('#selectall').attr('checked');
|
|
|
|
$('input:checkbox').attr('checked', check_status);
|
2010-07-21 03:35:31 +00:00
|
|
|
}
|
|
|
|
|
2010-11-17 18:53:40 +00:00
|
|
|
/**
|
|
|
|
* Update selected xCAT RPMs
|
|
|
|
*
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
2010-10-08 03:03:42 +00:00
|
|
|
function updateRpm() {
|
2010-09-29 18:38:50 +00:00
|
|
|
// Remove any warning messages
|
|
|
|
$('#updateTab').find('.ui-state-error').remove();
|
2010-11-17 18:53:40 +00:00
|
|
|
|
|
|
|
var rpmPath = $('input[type=radio]:checked').val();
|
|
|
|
var rpmPathType = "0";
|
|
|
|
var rpms = "";
|
|
|
|
var temp = "";
|
|
|
|
|
|
|
|
if (undefined == rpmPath) {
|
|
|
|
rpmPath = "";
|
|
|
|
}
|
|
|
|
|
2011-04-16 14:40:15 +00:00
|
|
|
// Select other and we should use the value in the input
|
2010-11-17 18:53:40 +00:00
|
|
|
if ("" == rpmPath) {
|
2011-09-09 19:34:05 +00:00
|
|
|
// Store repo in a cookie
|
2010-11-17 18:53:40 +00:00
|
|
|
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) {
|
2010-12-03 22:09:36 +00:00
|
|
|
errMsg = "Please select an RPM!<br>";
|
2010-11-17 18:53:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!rpmPath) {
|
2011-04-16 14:40:15 +00:00
|
|
|
errMsg += "Please select or specify a repository!";
|
2010-11-17 18:53:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!rpms || !rpmPath) {
|
|
|
|
// Show warning message
|
|
|
|
var warn = createWarnBar(errMsg);
|
|
|
|
warn.prependTo($('#updateTab'));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2011-04-16 14:40:15 +00:00
|
|
|
// Remember users' choice and input
|
2010-11-17 18:53:40 +00:00
|
|
|
$.cookie('xcatrepository', rpmPathType, {
|
|
|
|
path : '/xcat',
|
|
|
|
expires : 10
|
|
|
|
});
|
|
|
|
|
|
|
|
$('#update').show();
|
2011-04-27 20:28:00 +00:00
|
|
|
$('#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'>");
|
2010-11-17 18:53:40 +00:00
|
|
|
$('#rpm button').attr('disabled', 'true');
|
|
|
|
|
2011-04-16 14:40:15 +00:00
|
|
|
// Send the update command to server
|
2010-11-17 18:53:40 +00:00
|
|
|
$.ajax( {
|
|
|
|
url : 'lib/cmd.php',
|
|
|
|
dataType : 'json',
|
|
|
|
data : {
|
|
|
|
cmd : 'webrun',
|
|
|
|
tgt : '',
|
|
|
|
args : 'update;' + rpms + ";" + rpmPath,
|
|
|
|
msg : ''
|
|
|
|
},
|
|
|
|
|
2011-04-16 14:40:15 +00:00
|
|
|
success : showUpdateResult
|
2010-11-17 18:53:40 +00:00
|
|
|
});
|
2010-07-21 03:35:31 +00:00
|
|
|
}
|
|
|
|
|
2010-11-17 18:53:40 +00:00
|
|
|
/**
|
|
|
|
* Show the results of the RPM update
|
|
|
|
*
|
|
|
|
* @param data
|
|
|
|
* Data returned from HTTP request
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
2011-04-16 14:40:15 +00:00
|
|
|
function showUpdateResult(data) {
|
2010-11-17 18:53:40 +00:00
|
|
|
var temp = 0;
|
2010-07-21 03:35:31 +00:00
|
|
|
$('#loadingpic').remove();
|
2010-11-17 18:53:40 +00:00
|
|
|
|
|
|
|
var resArray = data.rsp[0].split(/\n/);
|
|
|
|
if (0 < resArray.length) {
|
|
|
|
// Show last lines
|
|
|
|
if (('' == resArray[resArray.length - 1]) && (resArray.length > 1)) {
|
2011-04-27 20:28:00 +00:00
|
|
|
$('#update div').append('<pre>' + resArray[resArray.length - 2] + '</pre>');
|
2010-11-17 18:53:40 +00:00
|
|
|
} else {
|
2011-04-27 20:28:00 +00:00
|
|
|
$('#update div').append('<pre>' + resArray[resArray.length - 1] + '</pre>');
|
2010-11-17 18:53:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Create link to show details
|
2011-04-27 20:28:00 +00:00
|
|
|
$('#update div').append('<br/><a>Show details</a>');
|
|
|
|
$('#update div a').css( {
|
2011-04-16 14:40:15 +00:00
|
|
|
'color' : '#0000FF',
|
|
|
|
'cursor' : 'pointer'
|
2011-04-14 18:38:26 +00:00
|
|
|
}).bind('click', function() {
|
2010-11-17 18:53:40 +00:00
|
|
|
// Toggle details and change text
|
|
|
|
$('#resDetail').toggle();
|
2011-04-27 20:28:00 +00:00
|
|
|
if ($('#update div a').text() == 'Show details') {
|
|
|
|
$('#update div a').text('Hide details');
|
2010-11-17 18:53:40 +00:00
|
|
|
} else {
|
2011-04-27 20:28:00 +00:00
|
|
|
$('#update div a').text('Show details');
|
2010-11-17 18:53:40 +00:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2011-04-16 14:40:15 +00:00
|
|
|
var resDetail = $('<pre id="resDetail"></pre>');
|
2010-11-17 18:53:40 +00:00
|
|
|
resDetail.hide();
|
2011-04-27 20:28:00 +00:00
|
|
|
$('#update div').append(resDetail);
|
2010-11-17 18:53:40 +00:00
|
|
|
for (temp = 0; temp < resArray.length; temp++) {
|
2011-04-16 14:40:15 +00:00
|
|
|
resDetail.append(resArray[temp] + '<br/>');
|
2010-11-17 18:53:40 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-04-16 14:40:15 +00:00
|
|
|
// Update the rpm info
|
2010-11-17 18:53:40 +00:00
|
|
|
$.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', '');
|
2010-07-21 03:35:31 +00:00
|
|
|
}
|