diff --git a/xCAT-UI/js/provision/images.js b/xCAT-UI/js/provision/images.js
index 48fa1d84f..df57fab9b 100644
--- a/xCAT-UI/js/provision/images.js
+++ b/xCAT-UI/js/provision/images.js
@@ -135,6 +135,12 @@ function loadImages(data) {
loadCopyCdPage();
});
+ // Create new button
+ var newBtn = createButton("Create Image");
+ newBtn.bind('click',function(event){
+ loadCreateImage();
+ });
+
// Create edit button
var editBtn = createButton('Edit');
editBtn.bind('click', function(event){
@@ -170,6 +176,7 @@ function loadImages(data) {
*/
var actionsBar = $('
').css('margin', '10px 0px');
actionsBar.append(copyLinuxBtn);
+ actionsBar.append(newBtn);
actionsBar.append(editBtn);
actionsBar.append(saveBtn);
actionsBar.append(undoBtn);
@@ -418,6 +425,195 @@ function setImageDefAttrs(data) {
} // End of for
}
+/**
+ *Load create image page
+ *
+ *@param Nothing
+ * Create a new image for provision
+ *@return Nothing
+ */
+function loadCreateImage(){
+ // get nodes tab
+ var tab=getProvisionTab();
+ var tabId = 'createImageTab';
+ //Generate new tab ID
+ if($('#' + tabId).length){
+ 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.');
+ setPropsForm.append(infoBar);
+
+ // Create an input for each generate attribute
+ var showStr = '';
+ //os version selector
+ showStr += '';
+ //os arch selector
+ showStr += '';
+ //net boot interface input
+ showStr += '';
+ //profile selector
+ showStr += '';
+ //boot method selector
+ showStr += '';
+
+ // advanced software when select the compute profile
+ showStr += '';
+
+ setPropsForm.append(showStr);
+
+ var createImageBtn=createButton("CreateImage");
+ createImageBtn.bind('click',function(event){
+ createImage();
+ });
+
+ setPropsForm.append(createImageBtn);
+ 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();
+
+ $('#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'
+ },
+ success : function(data){
+ var installPath = '/install/post/otherpkgs/' + $("#createImageTab #osvers").val() + '/' +
+ $("#createImageTab #osarch").val() + '/gpfs';
+ //remove the loading image.
+ $('#createImageTab #gpfsli').find('img').remove();
+
+ //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);
+ }
+ }
+ });
+}
/**
* Load set image properties page
*
diff --git a/xCAT-server/lib/xcat/plugins/web.pm b/xCAT-server/lib/xcat/plugins/web.pm
index edf49a455..be12cbb28 100644
--- a/xCAT-server/lib/xcat/plugins/web.pm
+++ b/xCAT-server/lib/xcat/plugins/web.pm
@@ -57,6 +57,7 @@ sub process_request {
'monls' => \&web_monls,
'discover' => \&web_discover,
'updatevpd' => \&web_updatevpd,
+ 'createimage' => \&web_createimage
#'xdsh' => \&web_xdsh,
#THIS list needs to be updated
);
@@ -1027,4 +1028,205 @@ sub web_updatevpd{
$vpdtab->close();
}
+sub web_createimage{
+ my ( $request, $callback, $sub_req ) = @_;
+ my $ostype = $request->{arg}->[1];
+ my $osarch = lc($request->{arg}->[2]);
+ my $profile = $request->{arg}->[3];
+ my $bootif = $request->{arg}->[4];
+ my $imagetype = lc($request->{arg}->[5]);
+ my @softArray;
+ my $netdriver = '';
+ my $installdir = xCAT::Utils->getInstallDir();
+ my $tempos = $ostype;
+ $tempos =~ s/[0-9]//;
+ my $CONFILE;
+ my $archFlag = 0;
+ my $ret = '';
+ my $cmdPath = '';
+
+ if ($request->{arg}->[6]){
+ @softArray = split(',' , $request->{arg}->[6]);
+
+ #check the arch
+ if('ppc64' ne $osarch){
+ $callback->({data=>'Error: only support PPC64!'});
+ return;
+ }
+
+ #check the osver
+ unless (-e "/opt/xcat/share/xcat/IBMhpc/IBMhpc.$ostype.ppc64.pkglist"){
+ $callback->({data=>'Error: only support rhels6 and sles11!'});
+ return;
+ }
+
+ #check the custom package, if the path is not exist, must create the dir first
+ if (-e "$installdir/custom/netboot/$ostype/"){
+ #the path is exist, so archive all file under this path.
+ opendir(TEMPDIR, "$installdir/custom/netboot/$ostype/");
+ my @fileArray = readdir(TEMPDIR);
+ closedir(TEMPDIR);
+ if (2 < scalar(@fileArray)){
+ $archFlag = 1;
+ unless (-e "/tmp/webImageArch/"){
+ system("mkdir -p /tmp/webImageArch/");
+ }
+ system("mv $installdir/custom/netboot/$ostype/*.* /tmp/webImageArch/");
+ }
+ else{
+ $archFlag = 0;
+ }
+ }
+ else{
+ #do not need to archive
+ $archFlag = 0;
+ system("mkdir -p $installdir/custom/netboot/$ostype/");
+ }
+
+ #write pkglist
+ open($CONFILE, ">$installdir/custom/netboot/$ostype/$profile.pkglist");
+ print $CONFILE "#INCLUDE:/opt/xcat/share/xcat/IBMhpc/IBMhpc.$ostype.ppc64.pkglist# \n";
+ close($CONFILE);
+
+ #write otherpkglist
+ open($CONFILE, ">$installdir/custom/netboot/$ostype/$profile.otherpkgs.pkglist");
+ print $CONFILE "\n";
+ close($CONFILE);
+
+ #write exlist for stateless
+ open($CONFILE, ">/install/custom/netboot/$ostype/$profile.exlist");
+ print $CONFILE "#INCLUDE:/opt/xcat/share/xcat/IBMhpc/IBMhpc.$ostype.$osarch.exlist#\n";
+ close($CONFILE);
+
+ #write postinstall
+ open($CONFILE, ">$installdir/custom/netboot/$ostype/$profile.postinstall");
+ print $CONFILE "/opt/xcat/share/xcat/IBMhpc/IBMhpc.$tempos.postinstall \$1 \$2 \$3 \$4 \$5 \n";
+ close($CONFILE);
+
+ for my $soft (@softArray){
+ $soft = lc($soft);
+ if ('gpfs' eq $soft){
+ web_gpfsConfigure($ostype, $profile, $installdir);
+ }
+ }
+
+ #chmod
+ system("chmod 755 $installdir/custom/netboot/$ostype/*.*");
+ }
+
+ if ($bootif =~ /hf/i){
+ $netdriver = 'hf_if';
+ }
+ else{
+ $netdriver = 'ibmveth';
+ }
+
+ if ($tempos =~ /rh/i){
+ $cmdPath = "/opt/xcat/share/xcat/netboot/rh";
+ }
+ else{
+ $cmdPath = "/opt/xcat/share/xcat/netboot/sles";
+ }
+ #for stateless only run packimage is ok
+ if ('stateless' eq $imagetype){
+ my $retInfo = xCAT::Utils->runcmd( "${cmdPath}/genimage -i $bootif -n $netdriver -o $ostype -p $profile", -1, 1 );
+ $ret = join ("\n", @$retInfo);
+ if ($::RUNCMD_RC){
+ $callback->({data=>$ret});
+ return;
+ }
+ $ret .= "\n";
+ my $retInfo = xCAT::Utils->runcmd( "packimage -o $ostype -p $profile -a $osarch", -1, 1 );
+ $ret .= join ("\n", @$retInfo);
+ }
+ else{
+ #for statelist we should check the litefile table
+ #step1 save the old litefile table content into litefilearchive.csv
+ system('tabdump litefile > /tmp/litefilearchive.csv');
+
+ #step2 write the new litefile.csv for this lite image
+ open ($CONFILE, ">/tmp/litefile.csv");
+ print $CONFILE "#image,file,options,comments,disable\n";
+ print $CONFILE '"ALL","/etc/lvm/","tmpfs",,' . "\n";
+ print $CONFILE '"ALL","/etc/ntp.conf","tmpfs",,' . "\n";
+ print $CONFILE '"ALL","/etc/resolv.conf","tmpfs",,' . "\n";
+ print $CONFILE '"ALL","/etc/sysconfig/","tmpfs",,' . "\n";
+ print $CONFILE '"ALL","/etc/yp.conf","tmpfs",,' . "\n";
+ print $CONFILE '"ALL","/etc/ssh/","tmpfs",,' . "\n";
+ print $CONFILE '"ALL","/var/","tmpfs",,' . "\n";
+ print $CONFILE '"ALL","/tmp/","tmpfs",,' . "\n";
+ print $CONFILE '"ALL","/root/.ssh/","tmpfs",,' . "\n";
+ print $CONFILE '"ALL","/opt/xcat/","tmpfs",,' . "\n";
+ print $CONFILE '"ALL","/xcatpost/","tmpfs",,' . "\n";
+
+ if ('rhels' eq $tempos){
+ print $CONFILE '"ALL","/etc/adjtime","tmpfs",,' . "\n";
+ print $CONFILE '"ALL","/etc/securetty","tmpfs",,' . "\n";
+ print $CONFILE '"ALL","/etc/rsyslog.conf","tmpfs",,' . "\n";
+ print $CONFILE '"ALL","/etc/rsyslog.conf.XCATORIG","tmpfs",,' . "\n";
+ print $CONFILE '"ALL","/etc/udev/","tmpfs",,' . "\n";
+ print $CONFILE '"ALL","/etc/ntp.conf.predhclient","tmpfs",,' . "\n";
+ print $CONFILE '"ALL","/etc/resolv.conf.predhclient","tmpfs",,' . "\n";
+ }
+ else{
+ print $CONFILE '"ALL","/etc/ntp.conf.org","tmpfs",,' . "\n";
+ print $CONFILE '"ALL","/etc/syslog-ng/","tmpfs",,' . "\n";
+ print $CONFILE '"ALL","/etc/fstab","tmpfs",,' . "\n";
+ }
+ close($CONFILE);
+
+ for my $soft (@softArray){
+ $soft = lc($soft);
+ system ("grep '^[^#]' /opt/xcat/share/xcat/IBMhpc/$soft/litefile.csv >> /tmp/litefile.csv");
+ }
+
+ system("tabrestore /tmp/litefile.csv");
+
+ #create the image
+ my $retInfo = xCAT::Utils->runcmd( "${cmdPath}/genimage -i $bootif -n $netdriver -o $ostype -p $profile", -1, 1 );
+ $ret = join ("\n", @$retInfo);
+ if ($::RUNCMD_RC){
+ $callback->({data=>$ret});
+ return;
+ }
+ $ret .= "\n";
+ my $retInfo = xCAT::Utils->runcmd( "liteimg -o $ostype -p $profile -a $osarch", -1, 1 );
+ $ret .= join ("\n", @$retInfo);
+
+ #restore the litefile table
+ system("rm -r /tmp/litefile.csv ; mv /tmp/litefilearchive.csv /tmp/litefile.csv ; tabrestore /tmp/litefile.csv");
+ }
+
+ #recover all file in the $installdir/custom/netboot/$ostype/
+ if ($request->{arg}->[6]){
+ system("rm -f $installdir/custom/netboot/$ostype/*.*");
+ }
+
+ if ($archFlag){
+ system("mv /tmp/webImageArch/*.* $installdir/custom/netboot/$ostype/");
+ }
+ $callback->({data=>$ret});
+ return;
+}
+
+sub web_gpfsConfigure{
+ my ($ostype, $profile, $installdir) = @_;
+ my $CONFILE;
+ #other pakgs
+ open($CONFILE, ">>$installdir/custom/netboot/$ostype/$profile.otherpkgs.pkglist");
+ print $CONFILE "#INCLUDE:/opt/xcat/share/xcat/IBMhpc/gpfs/gpfs.otherpkgs.pkglist#\n";
+ close($CONFILE);
+
+ #exlist
+ open ($CONFILE, ">>/install/custom/netboot/$ostype/$profile.exlist");
+ print $CONFILE "#INCLUDE:/opt/xcat/share/xcat/IBMhpc/gpfs/gpfs.exlist#\n";
+ close ($CONFILE);
+
+ #postinstall
+ system ('cp /opt/xcat/share/xcat/IBMhpc/gpfs/gpfs_mmsdrfs /install/postscripts/gpfs_mmsdrfs');
+ open($CONFILE, ">>$installdir/custom/netboot/$ostype/$profile.postinstall");
+ print $CONFILE "NODESETSTATE=genimage installroot=\$1 /opt/xcat/share/xcat/IBMhpc/gpfs/gpfs_updates \n";
+ print $CONFILE "installroot=$1 /install/postscripts/gpfs_mmsdrfs\n";
+ close($CONFILE);
+}
1;
\ No newline at end of file