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
This commit is contained in:
xq2005 2011-07-06 07:59:41 +00:00
parent e5e61b9571
commit f5600c7b64
2 changed files with 127 additions and 19 deletions

View File

@ -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!<br/>';
if (!origAttrs[nodeName]['mac'] || !origAttrs[nodeName]['ip']){
errormessage += 'All nodes should define ip and mac!<br/>';
break;
}
}
@ -3423,16 +3423,13 @@ function openQuickProvisionDia(tgtnodes){
showstr += '<tr><td>Target node:</td><td><input id="nodesinput" value="' + tgtnodes + '" readonly="readonly"></td></tr>';
showstr += '<tr><td>Arch:</td><td><input id="archinput" value="' + archtype + '" disabled="disabled"></td></tr>';
showstr += '<tr><td>Image:</td><td><select></select></td></tr>';
showstr += '<tr><td>OS:</td><td><input id="osinput" disabled="disabled"></td></tr>';
showstr += '<tr><td>Provmethod:</td><td><input id="provinput" disabled="disabled"></td></tr>';
showstr += '<tr><td>Profile:</td><td><input id="profinput" disabled="disabled"></td></tr>';
showstr += '<tr><td>Install Nic:</td><td><input id="inicinput" value="ent0"></td></tr>';
showstr += '<tr><td>Primary Nic:</td><td><input id="pnicinput" value="ent0"></td></tr>';
showstr += '<tr><td>xCAT Master:</td><td><input id="masterinput"></td></tr>';
showstr += '<tr><td>TFTP Server:</td><td><input id="tftpinput"></td></tr>';
showstr += '<tr><td>NFS Server:</td><td><input id="nfsinput"></td></tr>';
showstr += '</tbody></table>';
showstr += '<div id="imageinfo"></div>';
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('<option value="' + imagename + '">' + imagename + '</option>');
}
$('#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('<br/>');
$('#deployDiv').dialog( "option", "buttons", {'Close': function(){$(this).remove();clearTimeout(provisionClock);}});
$('#deployDiv').dialog( "option", "width", 600);
provisionFrame = $('<iframe id="provisionFrame" width="95%" height="90%"></iframe>');
$('#deployDiv').append(provisionFrame);
provisionFrame.attr('src', 'lib/cmd.php?cmd=webrun&tgt=&args=provision;' + nodesName + ';' + provisionArg + '&msg=&opts=flush');
provisionFrame.attr('src', url);
provisionStopCheck();
}

View File

@ -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;