From f5600c7b6475e3af7abae66bef8e1957398e9e5b Mon Sep 17 00:00:00 2001 From: xq2005 Date: Wed, 6 Jul 2011 07:59:41 +0000 Subject: [PATCH] support provision for aix on nodes page git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@10021 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-UI/js/nodes/nodes.js | 28 +++---- xCAT-server/lib/xcat/plugins/web.pm | 118 +++++++++++++++++++++++++++- 2 files changed, 127 insertions(+), 19 deletions(-) diff --git a/xCAT-UI/js/nodes/nodes.js b/xCAT-UI/js/nodes/nodes.js index 3cebc96b5..80193f085 100644 --- a/xCAT-UI/js/nodes/nodes.js +++ b/xCAT-UI/js/nodes/nodes.js @@ -3392,8 +3392,8 @@ function openQuickProvisionDia(tgtnodes){ //check the mac address for (index in nodeArray){ - if (!origAttrs[nodeName]['mac']){ - errormessage += 'All nodes should define mac!
'; + if (!origAttrs[nodeName]['mac'] || !origAttrs[nodeName]['ip']){ + errormessage += 'All nodes should define ip and mac!
'; break; } } @@ -3423,16 +3423,13 @@ function openQuickProvisionDia(tgtnodes){ showstr += 'Target node:'; showstr += 'Arch:'; showstr += 'Image:'; - showstr += 'OS:'; - showstr += 'Provmethod:'; - showstr += 'Profile:'; showstr += 'Install Nic:'; showstr += 'Primary Nic:'; showstr += 'xCAT Master:'; showstr += 'TFTP Server:'; showstr += 'NFS Server:'; showstr += ''; - + showstr += '
'; diaDiv.append(showstr); diaDiv.dialog({ modal: true, @@ -3445,13 +3442,14 @@ function openQuickProvisionDia(tgtnodes){ }); $('#deployDiv select').parent().append(createLoader()); + $.ajax({ url : 'lib/cmd.php', dataType : 'json', data : { cmd : 'lsdef', tgt : '', - args : '-t;osimage;-w;osarch==' + archtype, + args : '-t;osimage', msg : '' }, @@ -3473,14 +3471,6 @@ function openQuickProvisionDia(tgtnodes){ $('#deployDiv select').append(''); } - $('#deployDiv select').bind('change',function(){ - var areaArray = $(this).val().split('-'); - $('#deployDiv #osinput').val(areaArray[0]); - $('#deployDiv #provinput').val(areaArray[2]); - $('#deployDiv #profinput').val(areaArray[3]); - }); - - $('#deployDiv select').trigger('change'); $('#deployDiv').dialog( "option", "buttons", {'Ok': function(){quickProvision();}, 'Cancel': function(){$(this).remove();}} ); @@ -3499,6 +3489,8 @@ function quickProvision(){ var nodesName = ''; var provisionArg = ''; var provisionFrame; + var imageName = ''; + var url = ''; $('#deployDiv .ui-state-error').remove(); $('#deployDiv input').each(function(){ if ('' == $(this).val()){ @@ -3517,14 +3509,18 @@ function quickProvision(){ }); nodesName = argsArray.shift(); + imageName = $('#deployDiv select').val(); provisionArg = argsArray.join(','); + url = 'lib/cmd.php?cmd=webrun&tgt=&args=provision;' + nodesName + ';' + imageName + ';' + provisionArg + '&msg=&opts=flush'; + + //show the result $('#deployDiv').empty().append(createLoader()).append('
'); $('#deployDiv').dialog( "option", "buttons", {'Close': function(){$(this).remove();clearTimeout(provisionClock);}}); $('#deployDiv').dialog( "option", "width", 600); provisionFrame = $(''); $('#deployDiv').append(provisionFrame); - provisionFrame.attr('src', 'lib/cmd.php?cmd=webrun&tgt=&args=provision;' + nodesName + ';' + provisionArg + '&msg=&opts=flush'); + provisionFrame.attr('src', url); provisionStopCheck(); } diff --git a/xCAT-server/lib/xcat/plugins/web.pm b/xCAT-server/lib/xcat/plugins/web.pm index afb85e23c..c5e9b33d0 100644 --- a/xCAT-server/lib/xcat/plugins/web.pm +++ b/xCAT-server/lib/xcat/plugins/web.pm @@ -210,7 +210,7 @@ sub web_mkcondition { my $conditionName = $request->{arg}->[2]; my $groupName = $request->{arg}->[3]; - my $retInfo = xCAT::Utils->runcmd( 'nodels ' . $groupName . " nodetype.nodetype", -1, 1 ); + my $retInfo = xCAT::Utils->runcmd( 'nodels ' . $groupName . " ppc.nodetype", -1, 1 ); foreach my $line (@$retInfo) { my @temp = split( ':', $line ); if ( @temp[1] !~ /lpar/ ) { @@ -1154,7 +1154,34 @@ sub web_restoreChange { sub web_provision{ my ( $request, $callback, $sub_req ) = @_; my $nodes = $request->{arg}->[1]; - my ($arch, $os, $provmethod, $profile, $inic, $pnic, $master, $tftp, $nfs)= split(/,/,$request->{arg}->[2]); + my $imageName = $request->{arg}->[2]; + my ($arch, $inic, $pnic, $master, $tftp, $nfs) = split(/,/,$request->{arg}->[3]); + my $line = ''; + my %imageattr; + my $retinfo = xCAT::Utils->runcmd("lsdef -t osimage -l $imageName", -1, 1); + #parse output, get the os name, type + foreach $line(@$retinfo){ + if ($line =~ /(\w+)=(\S*)/){ + $imageattr{$1} = $2; + } + } + + #check the output + unless($imageattr{'osname'}){ + web_infomsg("Image infomation error. Check the image first.\nprovision stop.", $callback); + return; + } + + if($imageattr{'osname'} =~ /aix/i){ + web_provisionaix($nodes, $imageName, $imageattr{'nimtype'}, $inic, $pnic, $master, $tftp, $nfs, $callback); + } + else{ + web_provisionlinux($nodes, $arch, $imageattr{'osvers'}, $imageattr{'provmethod'}, $imageattr{'profile'}, $inic, $pnic, $master, $tftp, $nfs, $callback); + } +} + +sub web_provisionlinux{ + my ($nodes, $arch, $os, $provmethod, $profile, $inic, $pnic, $master, $tftp, $nfs, $callback) = @_; my $outputMessage = ''; my $retvalue = 0; my $netboot = ''; @@ -1191,7 +1218,7 @@ sub web_provision{ $cmd = "service dhcpd restart"; web_runcmd($cmd, $callback); #conserver - $cmd = "makeconservercf;service conserver stop;service conserver start"; + $cmd = "makeconservercf $nodes"; web_runcmd($cmd, $callback); if ($::RUNCMD_RC){ web_infomsg("Configure conserver error.\nprovision stop.", $callback); @@ -1233,6 +1260,91 @@ sub web_provision{ web_infomsg("Provision on $nodes success.\nprovision stop."); } +sub web_provisionaix{ + my ($nodes, $imagename, $nimtype, $inic, $pnic, $master, $tftp, $nfs, $callback) = @_; + my $outputMessage = ''; + my $retinfo; + my %nimhash; + my $line; + my @updatenodes; + my @addnodes; + my $cmd = ''; + #set attibutes + $cmd = "chdef -t node -o $nodes installnic=$inic tftpserver=$tftp nfsserver=$nfs xcatmaster=$master primarynic=$pnic"; + web_runcmd($cmd, $callback); + if ($::RUNCMD_RC){ + web_infomsg("Change nodes' attributes error.\nprovision stop.", $callback); + return; + } + #get all nim resource to filter nodes + $retinfo = xCAT::Utils->runcmd("lsnim -c machines", -1, 1); + foreach $line (@$retinfo){ + if($line =~ /(\S+)\s+\S+/){ + $nimhash{$1} = 1; + } + } + + foreach my $node(split(/,/, $nodes)){ + if ($nimhash{$node}){ + push(@updatenodes, $node); + } + else{ + push(@addnodes, $node); + } + } + + #xcat2nim + if(0 < scalar(@addnodes)){ + $cmd = "xcat2nim -t node -o " . join(",", @addnodes); + web_runcmd($cmd, $callback); + if ($::RUNCMD_RC){ + web_infomsg("xcat2nim command error.\nprovision stop.", $callback); + return; + } + } + + #update nimnode + if(0 < scalar(@updatenodes)){ + $cmd = "xcat2nim -u -t node -o " . join(",", @updatenodes); + web_runcmd($cmd, $callback); + if ($::RUNCMD_RC){ + web_infomsg("xcat2nim command error.\nprovision stop.", $callback); + return; + } + } + + #make con server + $cmd = "makeconservercf $nodes"; + web_runcmd($cmd, $callback); + if ($::RUNCMD_RC){ + web_infomsg("Configure conserver error.\nprovision stop.", $callback); + return; + } + + #nodeset + if ($nimtype =~ /diskless/){ + $cmd = "mkdsklsnode -i $imagename $nodes"; + } + else{ + $cmd = "nimnodeset -i $imagename $nodes"; + } + web_runcmd($cmd, $callback); + if ($::RUNCMD_RC){ + web_infomsg("Set node install method error.\nprovision stop.", $callback); + return; + } + + #reboot nodes + $cmd = "rnetboot $nodes"; + web_runcmd($cmd, $callback); + if ($::RUNCMD_RC){ + web_infomsg("Reboot nodes error.\nprovision stop.", $callback); + return; + } + + web_infomsg("Provision on $nodes success.\nprovision stop."); +} + #run the cmd by xCAT::Utils->runcmd and show information. sub web_runcmd{ my $cmd = shift;