2010-07-21 03:35:31 +00:00
|
|
|
/**
|
|
|
|
* Load update page
|
|
|
|
*
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
|
|
|
function loadUpdatePage() {
|
2010-07-22 06:16:29 +00:00
|
|
|
var repositoryDiv = $('<div id="repository"></div>');
|
|
|
|
var rpmDiv = $('<div id="rpm"></div>');
|
|
|
|
var statusDiv = createStatusBar("update");
|
|
|
|
statusDiv.hide();
|
|
|
|
|
2010-07-27 01:38:45 +00:00
|
|
|
$('#updateTab').append(statusDiv);
|
|
|
|
$('#updateTab').append('<br>');
|
2010-07-21 03:35:31 +00:00
|
|
|
$('#updateTab').append(repositoryDiv);
|
|
|
|
$('#updateTab').append(rpmDiv);
|
2010-10-08 03:03:42 +00:00
|
|
|
|
|
|
|
var infoBar = createInfoBar('Select the RPM and repository, then press Update');
|
2010-07-22 06:16:29 +00:00
|
|
|
repositoryDiv.append(infoBar);
|
|
|
|
|
|
|
|
repositoryDiv.append("<fieldset><legend>Repository</legend></fieldset>");
|
2010-07-21 03:35:31 +00:00
|
|
|
|
2010-10-08 03:03:42 +00:00
|
|
|
$.ajax({
|
2010-07-21 03:35:31 +00:00
|
|
|
url : 'lib/systemcmd.php',
|
|
|
|
dataType : 'json',
|
|
|
|
data : {
|
|
|
|
cmd : 'ostype'
|
|
|
|
},
|
|
|
|
|
|
|
|
success : showRepository
|
|
|
|
});
|
|
|
|
|
2010-07-22 06:16:29 +00:00
|
|
|
rpmDiv.append("<fieldset></fieldset>");
|
2010-07-21 03:35:31 +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
|
|
|
|
});
|
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-07-21 03:35:31 +00:00
|
|
|
*
|
|
|
|
* @return Nothing
|
|
|
|
*/
|
|
|
|
function showRepository(data) {
|
|
|
|
var DevelRepository = "";
|
|
|
|
var StableRepository = "";
|
|
|
|
var Show = "";
|
|
|
|
|
2010-10-08 03:03:42 +00:00
|
|
|
// get the corresponding repository by OS Type
|
|
|
|
if ("aix" == data.rsp) {
|
2010-07-21 03:35:31 +00:00
|
|
|
DevelRepository = "http://xcat.sourceforge.net/aix/devel/xcat-core/";
|
|
|
|
StableRepository = "http://xcat.sourceforge.net/aix/xcat-core/";
|
2010-10-08 03:03:42 +00:00
|
|
|
} else {
|
2010-07-21 03:35:31 +00:00
|
|
|
DevelRepository = "http://xcat.sourceforge.net/yum/devel/xcat-core/";
|
|
|
|
StableRepository = "http://xcat.sourceforge.net/yum/xcat-core/";
|
|
|
|
}
|
|
|
|
|
2010-09-29 18:38:50 +00:00
|
|
|
var repoList = $('<ol></ol>');
|
|
|
|
|
2010-09-24 02:27:04 +00:00
|
|
|
//display the Devel Repository, remember user's last selection
|
2010-09-29 18:38:50 +00:00
|
|
|
Show = Show + "<li><input type='radio' ";
|
2010-10-08 03:03:42 +00:00
|
|
|
if (1 == $.cookie('xcatrepository')) {
|
2010-07-21 03:35:31 +00:00
|
|
|
Show = Show + "checked='true'";
|
|
|
|
}
|
|
|
|
|
|
|
|
Show = Show + "name='reporadio' value='" + DevelRepository + "'>";
|
2010-09-29 18:38:50 +00:00
|
|
|
Show = Show + DevelRepository + "(<strong>Devel</strong>)</li>";
|
2010-07-21 03:35:31 +00:00
|
|
|
|
2010-09-29 18:38:50 +00:00
|
|
|
repoList.append(Show);
|
2010-07-21 03:35:31 +00:00
|
|
|
|
2010-09-24 02:27:04 +00:00
|
|
|
//display the Stable Repository, remember user's last selection
|
2010-09-29 18:38:50 +00:00
|
|
|
Show = "<li><input type='radio' ";
|
2010-10-08 03:03:42 +00:00
|
|
|
if (2 == $.cookie('xcatrepository')) {
|
2010-07-21 03:35:31 +00:00
|
|
|
Show = Show + "checked='true'";
|
|
|
|
}
|
|
|
|
|
|
|
|
Show = Show + "name='reporadio' value='" + StableRepository + "'>";
|
2010-09-29 18:38:50 +00:00
|
|
|
Show = Show + StableRepository + "(<strong>Stable</strong>)</li>";
|
2010-07-21 03:35:31 +00:00
|
|
|
|
2010-09-29 18:38:50 +00:00
|
|
|
repoList.append(Show);
|
2010-07-21 03:35:31 +00:00
|
|
|
|
2010-09-24 02:27:04 +00:00
|
|
|
//display the Input Repository, remember user's last selection
|
2010-07-21 03:35:31 +00:00
|
|
|
if (($.cookie('xcatrepository'))
|
|
|
|
&& (1 != $.cookie('xcatrepository'))
|
2010-10-08 03:03:42 +00:00
|
|
|
&& (2 != $.cookie('xcatrepository'))) {
|
2010-09-29 18:38:50 +00:00
|
|
|
Show = "<li><input type='radio' checked='true' name='reporadio' value=''>Other: ";
|
|
|
|
Show += "<input style='width: 500px' id='repositoryaddr' value='" + $.cookie('xcatrepository') + "'</li>";
|
2010-10-08 03:03:42 +00:00
|
|
|
} else {
|
2010-09-29 18:38:50 +00:00
|
|
|
Show = "<li><input type='radio' name='reporadio' value=''>Other: ";
|
|
|
|
Show += "<input style='width: 500px' id='repositoryaddr' value=''</li>";
|
2010-07-21 03:35:31 +00:00
|
|
|
}
|
|
|
|
|
2010-09-29 18:38:50 +00:00
|
|
|
repoList.append(Show);
|
|
|
|
$('#repository fieldset').append(repoList);
|
2010-07-21 03:35:31 +00:00
|
|
|
}
|
|
|
|
|
2010-10-08 03:03:42 +00:00
|
|
|
function showRpmInfo(data) {
|
2010-07-21 03:35:31 +00:00
|
|
|
var Rpms = null;
|
|
|
|
var Show = "";
|
|
|
|
var RpmNames = new Array("xCAT-client","perl-xCAT","xCAT-server","xCAT","xCAT-rmc","xCAT-UI");
|
|
|
|
var temp = 0;
|
2010-10-08 03:03:42 +00:00
|
|
|
if(null == data.rsp) {
|
2010-07-22 06:16:29 +00:00
|
|
|
$('#rpm fieldset').append("Get Rpm Info Error!");
|
2010-07-21 03:35:31 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
Rpms = data.rsp.split(/\n/);
|
2010-10-08 03:03:42 +00:00
|
|
|
// no rpm installed, return
|
|
|
|
if (1 > Rpms.length) {
|
2010-07-22 06:16:29 +00:00
|
|
|
$('#rpm fieldset').append("No Rpm installed!");
|
2010-07-21 03:35:31 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2010-10-08 03:03:42 +00:00
|
|
|
// clear the old data
|
2010-07-22 06:16:29 +00:00
|
|
|
$('#rpm fieldset').children().remove();
|
|
|
|
$('#rpm fieldset').append("<legend>xCAT Rpm Info</legend>");
|
|
|
|
|
2010-07-21 03:35:31 +00:00
|
|
|
Show = "<table id=rpmtable >";
|
2010-09-29 18:38:50 +00:00
|
|
|
Show += "<thead><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>";
|
2010-07-21 03:35:31 +00:00
|
|
|
|
2010-10-08 03:03:42 +00:00
|
|
|
for (temp = 0; temp < Rpms.length; temp++) {
|
|
|
|
// empty line continue
|
|
|
|
if ("" == Rpms[temp]) {
|
2010-07-21 03:35:31 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2010-10-08 03:03:42 +00:00
|
|
|
// the rpm is not installed, continue
|
|
|
|
if (-1 != Rpms[temp].indexOf("not")) {
|
2010-07-21 03:35:31 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2010-10-08 03:03:42 +00:00
|
|
|
// show the version in table
|
2010-07-21 03:35:31 +00:00
|
|
|
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>";
|
2010-07-22 06:16:29 +00:00
|
|
|
Show += "<br\>";
|
|
|
|
$('#rpm fieldset').append(Show);
|
2010-07-21 03:35:31 +00:00
|
|
|
|
2010-10-08 03:03:42 +00:00
|
|
|
// add the update button
|
2010-07-21 03:35:31 +00:00
|
|
|
var updateButton = createButton('Update');
|
2010-07-22 06:16:29 +00:00
|
|
|
$('#rpm fieldset').append(updateButton);
|
2010-07-21 03:35:31 +00:00
|
|
|
updateButton.bind('click', function(){
|
|
|
|
updateRpm();
|
2010-10-08 03:03:42 +00:00
|
|
|
});
|
2010-07-21 03:35:31 +00:00
|
|
|
}
|
|
|
|
|
2010-10-08 03:03:42 +00:00
|
|
|
function updateSelectAll() {
|
2010-07-21 03:35:31 +00:00
|
|
|
var check_status = $('#selectall').attr('checked');
|
|
|
|
$('input:checkbox').attr('checked', check_status);
|
|
|
|
}
|
|
|
|
|
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-07-21 03:35:31 +00:00
|
|
|
var rpmPath = $('input[type=radio]:checked').val();
|
|
|
|
var rpmPathType = "0";
|
|
|
|
var rpms = "";
|
|
|
|
var temp = "";
|
|
|
|
|
2010-10-08 03:03:42 +00:00
|
|
|
if (undefined == rpmPath) {
|
2010-07-21 03:35:31 +00:00
|
|
|
rpmPath = "";
|
|
|
|
}
|
|
|
|
|
2010-10-08 03:03:42 +00:00
|
|
|
// select other and we should use the value in the input
|
|
|
|
if ("" == rpmPath) {
|
2010-07-21 03:35:31 +00:00
|
|
|
//user input the repo, and we must stroe it in the cookie
|
|
|
|
rpmPath = $('#repositoryaddr').val();
|
|
|
|
rpmPathType = rpmPath;
|
2010-10-08 03:03:42 +00:00
|
|
|
} else {
|
|
|
|
if(-1 == rpmPath.toLowerCase().indexOf("devel")) {
|
2010-07-21 03:35:31 +00:00
|
|
|
rpmPathType = "2";
|
2010-10-08 03:03:42 +00:00
|
|
|
} else {
|
2010-07-21 03:35:31 +00:00
|
|
|
rpmPathType = "1";;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
$("input[type=checkbox]:checked").each(function(){
|
|
|
|
temp = $(this).val();
|
2010-10-08 03:03:42 +00:00
|
|
|
if("" == temp) {
|
2010-07-21 03:35:31 +00:00
|
|
|
//continue;
|
|
|
|
return true;
|
|
|
|
}
|
2010-10-08 03:03:42 +00:00
|
|
|
|
2010-07-21 03:35:31 +00:00
|
|
|
var pattern = new RegExp("^" + temp + ",|," + temp + ",");;
|
2010-10-08 03:03:42 +00:00
|
|
|
if (pattern.test(rpms)) {
|
2010-07-21 03:35:31 +00:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
rpms = rpms + temp + ",";
|
|
|
|
});
|
|
|
|
|
2010-10-08 03:03:42 +00:00
|
|
|
if (0 < rpms.length) {
|
2010-07-21 03:35:31 +00:00
|
|
|
rpms = rpms.slice(0, -1);
|
|
|
|
}
|
2010-09-29 18:38:50 +00:00
|
|
|
|
|
|
|
// Check RPM and repository
|
|
|
|
var errMsg = '';
|
|
|
|
if (!rpms) {
|
|
|
|
errMsg = "Please select the rpm!<br>";
|
2010-07-21 03:35:31 +00:00
|
|
|
}
|
|
|
|
|
2010-09-29 18:38:50 +00:00
|
|
|
if (!rpmPath) {
|
|
|
|
errMsg += "Please select or input the repository!";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!rpms || !rpmPath) {
|
|
|
|
// Show warning message
|
|
|
|
var warn = createWarnBar(errMsg);
|
|
|
|
warn.prependTo($('#updateTab'));
|
|
|
|
return;
|
2010-07-21 03:35:31 +00:00
|
|
|
}
|
|
|
|
|
2010-10-08 03:03:42 +00:00
|
|
|
// remember users' choice and input
|
2010-07-21 03:35:31 +00:00
|
|
|
$.cookie('xcatrepository', rpmPathType, { path: '/xcat', expires: 10 });
|
|
|
|
|
2010-09-29 18:38:50 +00:00
|
|
|
$('#update').show();
|
2010-07-21 03:35:31 +00:00
|
|
|
$('#update').empty();
|
2010-09-17 06:00:34 +00:00
|
|
|
$('#update').append("<p>Updating <b>" + rpms + "</b> from <b>" + rpmPath + "</b></p>");
|
2010-09-29 18:38:50 +00:00
|
|
|
$('#update').append("<img id='loadingpic' src='images/loader.gif'>");
|
2010-07-22 06:16:29 +00:00
|
|
|
$('#rpm button').attr('disabled', 'true');
|
2010-07-21 03:35:31 +00:00
|
|
|
|
|
|
|
// send the update command to server
|
|
|
|
$.ajax( {
|
|
|
|
url : 'lib/cmd.php',
|
|
|
|
dataType : 'json',
|
|
|
|
data : {
|
|
|
|
cmd : 'webrun',
|
|
|
|
tgt : '',
|
|
|
|
args : 'update;' + rpms + ";" + rpmPath,
|
|
|
|
msg : ''
|
|
|
|
},
|
|
|
|
|
|
|
|
success : ShowUpdateResult
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2010-10-08 03:03:42 +00:00
|
|
|
function ShowUpdateResult(data) {
|
2010-07-21 03:35:31 +00:00
|
|
|
var temp = 0;
|
|
|
|
$('#loadingpic').remove();
|
2010-09-17 06:00:34 +00:00
|
|
|
|
|
|
|
var resArray = data.rsp[0].split(/\n/);
|
2010-10-08 03:03:42 +00:00
|
|
|
if (0 < resArray.length) {
|
2010-09-29 18:38:50 +00:00
|
|
|
// Show last lines
|
2010-09-25 10:04:27 +00:00
|
|
|
if (('' == resArray[resArray.length - 1]) && (resArray.length > 1)){
|
|
|
|
$('#update').append(resArray[resArray.length - 2]);
|
|
|
|
}
|
2010-10-08 03:03:42 +00:00
|
|
|
else {
|
2010-09-25 10:04:27 +00:00
|
|
|
$('#update').append(resArray[resArray.length - 1]);
|
|
|
|
}
|
2010-09-29 18:38:50 +00:00
|
|
|
|
|
|
|
// Create link to show details
|
|
|
|
$('#update').append('<br><a>Show details</a>');
|
|
|
|
$('#update a').bind('click', function(){
|
|
|
|
// Toggle details and change text
|
|
|
|
$('#resDetail').toggle();
|
|
|
|
if ($('#update a').text() == 'Show details') {
|
|
|
|
$('#update a').text('Hide details');
|
|
|
|
} else {
|
|
|
|
$('#update a').text('Show details');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
var resDetail = $('<div id="resDetail"></div>');
|
|
|
|
resDetail.hide();
|
|
|
|
$('#update').append(resDetail);
|
|
|
|
|
2010-10-08 03:03:42 +00:00
|
|
|
for (temp = 0; temp < resArray.length; temp++) {
|
2010-09-29 18:38:50 +00:00
|
|
|
resDetail.append(resArray[temp] + "<br>");
|
|
|
|
}
|
2010-07-21 03:35:31 +00:00
|
|
|
}
|
2010-07-22 06:16:29 +00:00
|
|
|
|
|
|
|
//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', '');
|
2010-07-21 03:35:31 +00:00
|
|
|
}
|