diff --git a/xCAT-UI/js/provision/images.js b/xCAT-UI/js/provision/images.js index df57fab9b..1ccc2e9ed 100644 --- a/xCAT-UI/js/provision/images.js +++ b/xCAT-UI/js/provision/images.js @@ -437,183 +437,133 @@ function loadCreateImage(){ var tab=getProvisionTab(); var tabId = 'createImageTab'; //Generate new tab ID - if($('#' + tabId).length){ + if($('#' + tabId).size()){ tab.select(tabId); return ; } - - // Open new tab - // Create set properties form - var setPropsForm = $('
'); - var infoBar= createInfoBar('Input the image info ,you want to generate. When you finished, click generate.'); + var showStr = ''; + var imageOsvers = $.cookie("osvers").split(","); + var imageArch = $.cookie("osarchs").split(","); + + // Create set properties form + var setPropsForm = $('
'); + + //show the infomation + var infoBar= createInfoBar('Input the image info ,you want to generate. Click generate.'); setPropsForm.append(infoBar); - // Create an input for each generate attribute - var showStr = ''; //os version selector - showStr += '

'; + showStr += '

'; + //os arch selector - showStr += '

'; + showStr += '

'; + //net boot interface input showStr += '

'; //profile selector - showStr += '

' + + '' + '

'; //boot method selector - showStr += '

' + + '' + '

'; - // advanced software when select the compute profile - showStr += '
HPC Software Stack
'; - setPropsForm.append(showStr); + createHpcSelect(setPropsForm); - var createImageBtn=createButton("CreateImage"); - createImageBtn.bind('click',function(event){ - createImage(); - }); - - setPropsForm.append(createImageBtn); + //add and show the tab tab.add(tabId, 'Create Image', setPropsForm, true); tab.select(tabId); - //for the profile select, if not compute could not select the software - $('#createImageTab #profile').bind('change', function(){ - if('compute' != $(this).attr('value')){ - $('#createImageTab #hpcsoft').hide(); - } - else{ - $('#createImageTab #hpcsoft').show(); - } - }); -} - -/** - * use users' input or select to create image - * - * @param - * - * @return Nothing - */ -function createImage(){ - var osvers = $("#createImageTab #osvers").val(); - var osarch = $("#createImageTab #osarch").val(); - var profile = $("#createImageTab #profile").val(); - var bootInterface = $("#createImageTab #netbootif").val(); - var bootMethod = $("#createImageTab #bootmethod").val(); + //check the selected osver and osarch for hcp stack select, if they are validated, + //then show the hpc stack select area. + hpcShow(); - $('#createImageTab .ui-state-error').remove(); - - if (!bootInterface){ - $("#createImageTab").prepend('
' + - '

Input the netboot interface please.

'); - return; - } - - var createImageArgs = "createimage;" + osvers + ";" + osarch + ";" + profile + ";" + bootInterface + ";" + - bootMethod + ";"; - - $("#createImageTab :checkbox:checked").each(function (){ - createImageArgs+=$(this).attr("name")+","; - }); - - createImageArgs=createImageArgs.substring(0,(createImageArgs.length-1)); - $.ajax({ - url : 'lib/cmd.php', - dataType : 'json', - data : { - cmd : 'webrun', - tgt : '', - args : createImageArgs, - msg : '' - }, - success : function(data){ - - } - }); -} - -/** - * when users want to install gpfs on compute node, - * should check the rpms install and copy status first. - * - * @param - * - * @return Nothing - */ -function gpfsCheck(obj) { - if(0 < $('#createImageTab #gpfsli .ui-icon-circle-check').size()){ - return; - } - - $('#createImageTab #gpfsli .ui-state-error').remove(); - $('#createImageTab #gpfsli').append(createLoader()); $.ajax({ url : 'lib/systemcmd.php', dataType : 'json', - data:{ - cmd : 'rpm -q gpfs.base gpfs.gpl gpfs.msg xCAT-IBMhpc createrepo' - }, - success : function(data){ - var checkResult=data.rsp.split("\n"); - var errorStr = ''; - - for (var i in checkResult){ - if (-1 != checkResult[i].indexOf("not installed")){ - errorStr += ' ' + checkResult[i] + ','; - } - } - - if ('' != errorStr){ - errorStr = errorStr.substr(0, errorStr.length - 1); - $(":checkbox[name=gpfs]").attr("checked",false); - //add the error - var errorPart = '
' + - '' + errorStr + '
'; - $('#createImageTab #gpfsli').find('img').remove(); - $('#createImageTab #gpfsli').append(errorPart); - return; - } - - gpfsCopyCheck(); - } - }); -} - -function gpfsCopyCheck(){ - var osvers=$("#createImageTab #osvers").val(); - var osarch=$("#createImageTab #osarch").val(); - $.ajax({ - url: 'lib/systemcmd.php', - dataType : 'json', data : { - cmd : 'ls /install/post/otherpkgs/' + osvers + '/' + osarch + '/gpfs/gpfs.gplbin*.rpm' + cmd : 'lsb_release -d;uname -p' }, success : function(data){ - var installPath = '/install/post/otherpkgs/' + $("#createImageTab #osvers").val() + '/' + - $("#createImageTab #osarch").val() + '/gpfs'; - //remove the loading image. - $('#createImageTab #gpfsli').find('img').remove(); + var tempArray = data.rsp.split("\n"); + var mnOs = tempArray[0]; + var mnArch = tempArray[1]; + tempArray = mnOs.split(" "); + // get the the version of mn + if(mnOs.indexOf("Red Hat")!= -1 ){ + mnOs="rhels" + tempArray[6]; + } - //check the return information - if (null == data.rsp){ - var errorPart = '
' + - 'Build the GPFS portability layer rpm, install it and copy it into ' + - installPath + '.
For information: Install/Build GPFS
'; - $('#createImageTab #gpfsli').append(errorPart); - $(":checkbox[name=gpfs]").attr("checked",false); - } - else{ - var infoPart = '
'; - $('#createImageTab #gpfsli').append(infoPart); - } + $('#createImageTab option[value=' + mnOs + ']').attr('selected', 'selected'); + $('#createImageTab option[value=' + mnArch + ']').attr('selected', 'selected'); + // The button used to create images is created here. + var createImageBtn=createButton("CreateImage"); + createImageBtn.bind('click',function(event){ + createImage(); + }); + + $('#createImageTab').append(createImageBtn); + + // check the option ,Decide to show the hpcsoft or not + hpcShow(); } }); + } + +function createHpcSelect(container){ + var hpcFieldset = $('
'); + hpcFieldset.append('HPC Software Stack'); + var str = 'Before selecting the software, you should have the following already completed for your xCAT cluster:

' + + '1. If you are using xCAT hierarchy, your service nodes are installed and running.
' + + '2. Your compute nodes are defined to xCAT, and you have verified your hardware control capabilities, ' + + 'gathered MAC addresses, and done all the other necessary preparations for a diskless install.
' + + '3. You should have a diskless image created with the base OS installed and verified on at least one test node.
' + + '4. You should install the softwares on the management node, and copy all correponding packages into the location ' + + '"/install/custom/otherpkgs/" based on ' + + 'these documentations.
'; + + hpcFieldset.append(createInfoBar(str)); + // advanced software when select the compute profile + str = ''; + hpcFieldset.append(str); + + container.append(hpcFieldset); +} +/** + * check the Option , Decide to show the hpcsoft or not + * + * + * @param + * + * @return Nothing + */ +function hpcShow(){ + // The current ui only support rhels 6 + // if you want support all delete the subcheck + if($('#createImageTab #osvers').attr('value')!="rhels6"||$('#createImageTab #osarch').attr('value')!="ppc64"||$('#createImageTab #profile').attr('value')!="compute"){ + $('#createImageTab #hpcsoft').hide(); + }else { + $('#createImageTab #hpcsoft').show(); + } +} + /** * Load set image properties page * @@ -1051,4 +1001,276 @@ function loadCopyCdPage() { tab.add(newTabId, 'Copy', copyLinuxForm, true); tab.select(newTabId); +} + +/** + * use users' input or select to create image + * + * @param + * + * @return Nothing + */ +function createImage(){ + var osvers = $("#createImageTab #osvers").val(); + var osarch = $("#createImageTab #osarch").val(); + var profile = $("#createImageTab #profile").val(); + var bootInterface = $("#createImageTab #netbootif").val(); + var bootMethod = $("#createImageTab #bootmethod").val(); + + $('#createImageTab .ui-state-error').remove(); + // If there no input for the bootInterface + if (!bootInterface){ + $("#createImageTab").prepend('
' + + '

Input the netboot interface please.

'); + return; + } + + var createImageArgs = "createimage;" + osvers + ";" + osarch + ";" + profile + ";" + bootInterface + ";" + + bootMethod + ";"; + + $("#createImageTab :checkbox:checked").each(function (){ + createImageArgs+=$(this).attr("name")+","; + }); + + createImageArgs=createImageArgs.substring(0,(createImageArgs.length-1)); + $.ajax({ + url : 'lib/cmd.php', + dataType : 'json', + data : { + cmd : 'webrun', + tgt : '', + args : createImageArgs, + msg : '' + }, + success : function(data){ + + } + }); +} + +/** + * when users want to install gpfs on compute node, + * should check the rpms install and copy status first. + * + * @param + * + * @return Nothing + */ +function gpfsCheck(obj) { + if(0 < $('#createImageTab #gpfsli .ui-icon-circle-check').size()){ + return; + } + + $('#createImageTab #gpfsli .ui-state-error').remove(); + $('#createImageTab #gpfsli').append(createLoader()); + $.ajax({ + url : 'lib/systemcmd.php', + dataType : 'json', + data:{ + cmd : 'rpm -q gpfs.base gpfs.gpl gpfs.msg xCAT-IBMhpc createrepo' + }, + success : function(data){ + if (rpmCheck(data.rsp, 'gpfs')){ + var osvers=$("#createImageTab #osvers").val(); + var osarch=$("#createImageTab #osarch").val(); + var cmd = 'ls /install/post/otherpkgs/' + osvers + '/' + osarch + '/gpfs/gpfs.gplbin*.rpm'; + rpmCopyCheck(cmd); + } + } + }); +} + +/** +* when users want to install rsct on compute node, +* They should install the rsct on mn . +* The rsctCheck check the basic configuration of rsct. +* +* @param +* +* @return Nothing +*/ +function rsctCheck(obj){ + if (0 < $('#createImageTab #rsctli .ui-icon-circle-check').size()){ + return; + } + $('#createImageTab #rsctli .ui-state-error').remove(); + $('#createImageTab #rsctli').append(createLoader()); + $.ajax({ + url : 'lib/systemcmd.php', + dataType : 'json', + data: { + cmd : 'rpm -q rsct.core rsct.core.utils src createrepo' + }, + success : function (data){ + if (rpmCheck(data.rsp, 'rsct')){ + var osvers = $("#createImageTab #osvers").val(); + var osarch = $("#createImageTab #osarch").val(); + var cmd = 'ls /install/post/otherpkgs/' + osvers + '/' + osarch + '/rsct/rsct.core*.rpm ' + + '/install/post/otherpkgs/' + osvers + '/' + osarch + '/rsct/rsct.core.utils*.rpm ' + + '/install/post/otherpkgs/' + osvers + '/' + osarch + '/rsct/src*.rpm 2>&1'; + rpmCopyCheck(cmd); + } + } + }); +} + +/** +* When users want to install PE on their compute node. +* The peCheck will check the info of mn. +* And return the info to users. +* +* @param +* +* @return Nothing +*/ +function peCheck(obj){ + //verify result is ok, the return; + if (0 < $('#createImageTab #peli .ui-icon-circle-check').size()){ + return; + } + + //delete the error part + $('#createImageTab #peli .ui-state-error').remove(); + $('#createImageTab #peli').append(createLoader()); + $.ajax({ + url : 'lib/systemcmd.php', + dataType : 'json', + data : { + cmd : 'rpm -q src IBM_pe_license ibm_lapi ibm_pe ppe ' + }, + success : function(data){ + if (rpmCheck(data.rsp, 'pe')){ + var osvers=$("#createImageTab #osvers").val(); + var osarch=$("#createImageTab #osarch").val(); + var cmd = 'ls /install/post/otherpkgs/' + osvers + '/' + osarch + '/pe/IBM_pe_licence*.rpm ' + + '/install/post/otherpkgs/' + osvers + '/' + osarch + '/pe/src*.rpm ' + + '/install/post/otherpkgs/' + osvers + '/' + osarch + '/pe/ibm_lapi*.rpm ' + + '/install/post/otherpkgs/' + osvers + '/' + osarch + '/pe/ibm_pe*.rpm ' + + '/install/post/otherpkgs/' + osvers + '/' + osarch + '/pe/ppe*.rpm 2>&1'; + rpmCopyCheck(cmd); + } + } + }); +} + +function esslCheck(obj){ + if(0 < $('#createImageTab #esslli .ui-icon-circle-check').size()){ + return; + } + + $('#createImageTab #esslli .ui-state-error').remove(); + //before select the essl, must select pe first + if (false == $('#createImageTab input[name=pe]').attr('checked')){ + var errorStr = '
You must select the pe first.
'; + $('#createImageTab #esslli').append(errorStr); + $(':checkbox[name=essl]').attr("checked",false); + return; + } + + $.ajax({ + url : 'lib/systemcmd.php', + dataType : 'json', + data : { + cmd : 'rpm -q essl.common essl.licens essl.rte pessl.license pessl.msg pessl.rte.ppe' + }, + success : function(data){ + if (rpmCheck(data.rsp, 'pe')){ + var osvers=$("#createImageTab #osvers").val(); + var osarch=$("#createImageTab #osarch").val(); + var cmd = 'ls /install/post/otherpkgs/' + osvers + '/' + osarch + '/essl/essl.common*.rpm ' + + '/install/post/otherpkgs/' + osvers + '/' + osarch + '/essl/essl.licens*.rpm ' + + '/install/post/otherpkgs/' + osvers + '/' + osarch + '/essl/essl.rte*.rpm ' + + '/install/post/otherpkgs/' + osvers + '/' + osarch + '/essl/pessl.license*.rpm ' + + '/install/post/otherpkgs/' + osvers + '/' + osarch + '/essl/pessl.msg*.rpm 2>&1'; + rpmCopyCheck(cmd); + } + } + }); +} + +/** +* When the rpm check info return, check if all rpms are installed. +* +* @param checkInfo: "rpm -q ***"'s return +* name: software name +* +* @return true: the rpms are all installed +* false: some of the rpms are not installed, detail add into the page. +*/ +function rpmCheck(checkInfo, name){ + var errorStr = ''; + + var checkArray = checkInfo.split("\n"); + for(var i in checkArray){ + if(-1 != checkArray[i].indexOf("not install")){ + errorStr += checkArray[i] + "
"; + } + } + + if ('' == errorStr){ + return true; + } + + errorStr = errorStr.substr(0, errorStr.length - 1); + $(':checkbox[name=' + name + ']').attr("checked",false); + //add the error + var errorPart = '
' + errorStr + '
'; + $('#createImageTab #' + name + 'li').find('img').remove(); + $('#createImageTab #' + name + 'li').append(errorPart); + return; +} + +/** +* check the rpm list result, to create the error message +* +* @param name: software name +* +* @return +*/ +function rpmCopyCheck(checkCmd){ + $.ajax({ + url: 'lib/systemcmd.php', + dataType : 'json', + data : { + cmd : checkCmd + }, + success : function(data){ + //remove the loading image. + var errorStr = ''; + var softwareName = ''; + //check the return information + var reg = /.+:(.+): No such.*/; + var resultArray = data.rsp.split("\n"); + for(var i in resultArray){ + var temp = reg.exec(resultArray[i]); + if (temp){ + //find out the path and rpm name + var pos = temp[1].lastIndexOf('/'); + var path = temp[1].substring(0, pos); + var rpmName = temp[1].substring(pos + 1).replace('*', ''); + errorStr += 'Copy ' + rpmName + ' to ' + path + '
'; + //find out the software name + if ('' == softwareName){ + pos = path.lastIndexOf('/'); + softwareName = path.substring(pos + 1); + } + } + } + + $('#createImageTab #' + softwareName + 'li').find('img').remove(); + //no error, show the check image + if ('' == errorStr){ + var infoPart = '
'; + $('#createImageTab #' + softwareName + 'li').append(infoPart); + } + else{ + //show the error message + errorStr = '
' + + 'To install the rsct on your compute node. You should:
' + + errorStr + '
'; + $('#createImageTab #' + softwareName + 'li').append(errorStr); + $(':checkbox[name=' + softwareName + ']').attr("checked",false); + } + } + }); } \ No newline at end of file