diff --git a/xCAT-UI/js/custom/hmc.js b/xCAT-UI/js/custom/hmc.js
index 6b65fcfd9..56651b238 100644
--- a/xCAT-UI/js/custom/hmc.js
+++ b/xCAT-UI/js/custom/hmc.js
@@ -162,6 +162,258 @@ hmcPlugin.prototype.loadResources = function() {
* @return Nothing
*/
hmcPlugin.prototype.addNode = function() {
- openDialog('info', 'Under construction');
+ var diaDiv = $('
');
+ diaDiv.append('Type: HMC Scan Node
');
+ diaDiv.append('
');
+
+ //show the dialog
+ diaDiv.dialog( {
+ modal : true,
+ width : 400,
+ title : 'Add System P Node',
+ close : function(){$('#addpnodeDiv').remove();}
+ });
+
+ //bind the select change event
+ $('#pnodetype').bind('change', function(){
+ $('#pnodeeditarea').empty();
+ if ('HMC' == $(this).val()){
+ $('#addpnodeDiv').dialog('option', 'width', '400');
+ $('#pnodeeditarea').append('Name: Username: ' +
+ 'Password: IP Adress: ');
+
+ $('#addpnodeDiv').dialog('option', 'buttons',
+ {'Add': function(){addHmcNode();},
+ 'Cancle': function(){$('#addpnodeDiv').dialog('close');}});
+ }
+ else{
+ //add loader image and delete buttons
+ $('#pnodeeditarea').append(createLoader());
+ $('#addpnodeDiv').dialog('option', 'buttons', {'Cancel': function(){$('#addpnodeDiv').dialog('close');}});
+ $('#addpnodeDiv').dialog('option', 'width', '650');
+ $.ajax({
+ url : 'lib/cmd.php',
+ dataType : 'json',
+ data : {
+ cmd : 'nodels',
+ tgt : 'all',
+ args : 'ppc.nodetype==hmc',
+ msg : ''
+ },
+ success : function(data){
+ $('#pnodeeditarea img').remove();
+ drawHmcSelector(data.rsp);
+ }
+ });
+ }
+ });
+
+ //trigger the selector change event
+ $('#pnodetype').trigger('change');
};
+/**
+ * add all hmcs into the dialog
+ *
+ * @return Nothing
+ */
+function drawHmcSelector(hmcs){
+ if (1 > hmcs.length){
+ $('#pnodeeditarea').append(createWarnBar('Please define HMC node first.'));
+ return;
+ }
+
+ //add all hmcs into a selecter, add a scan button
+ var hmcoption = '';
+ var scanbutton = createButton('Scan');
+ for (var i in hmcs){
+ hmcoption += '' + hmcs[i][0] + ' ';
+ }
+
+ $('#pnodeeditarea').append('HMC: ' + hmcoption + ' ');
+ $('#pnodeeditarea').append(scanbutton);
+
+ scanbutton.bind('click', function(){
+ var hmcname = $('#pnodeeditarea select').val();
+ $('#pnodeeditarea').append(createLoader());
+ $.ajax({
+ url : 'lib/cmd.php',
+ dataType : 'json',
+ data : {
+ cmd : 'rscan',
+ tgt : hmcname,
+ args : '',
+ msg : ''
+ },
+ success : function(data){
+ $('#pnodeeditarea img').remove();
+
+ //draw a table with checkbox
+ drawRscanResult(data.rsp[0]);
+
+ //add the add button
+ $('#addpnodeDiv').dialog('option', 'buttons',
+ {'Add': function(){addPNode();},
+ 'Cancle': function(){$('#addpnodeDiv').dialog('close');}});
+ }
+ });
+ });
+}
+
+function drawRscanResult(rscanresult){
+ var line = '';
+ var tempreg = /\S+/g;
+ var idpreg = /^\d+$/;
+ var resultDiv = $('
');
+ var rscantable = $('');
+ var temprow = '';
+ var colnum = 0;
+ var fields = 0;
+
+ $('#pnodeeditarea div').remove();
+ if (!rscanresult){
+ return;
+ }
+
+ var rows = rscanresult.split("\n");
+ if (rows.length < 2){
+ return;
+ }
+
+ //add the table header
+ fields = rows[0].match(tempreg);
+ colnum = fields.length;
+ temprow = ' ';
+ for(var i in fields){
+ temprow += '' + fields[i] + ' ';
+ }
+ rscantable.append(temprow);
+
+ //add the tbody
+ for (var i = 1; i < rows.length; i++){
+ line = rows[i];
+ if (!line){
+ continue;
+ }
+ var fields = line.match(tempreg);
+ if ('hmc' == fields[0]){
+ continue;
+ }
+
+ //may be the 3rd field(id) is empty, so we should add the new
+ if (!idpreg.test(fields[2])){
+ fields = [fields[0], fields[1], ''].concat(fields.slice(2));
+ }
+ temprow = ' ';
+
+ for(var j = 0; j < colnum; j++){
+ temprow += '';
+ if (fields[j]){
+ temprow += fields[j];
+ }
+ temprow += ' ';
+ }
+ temprow += ' ';
+ rscantable.append(temprow);
+ }
+
+ resultDiv.append(rscantable);
+ $('#pnodeeditarea').append(resultDiv);
+}
+/**
+ * Add hmc node
+ *
+ * @return Nothing
+ */
+function addHmcNode(){
+ var errorinfo = '';
+ var args = '';
+ $('#pnodeeditarea input').each(function(){
+ if (!$(this).val()){
+ errorinfo = 'You are missing input.';
+ }
+ args += $(this).val() + ',';
+ });
+
+ if (errorinfo){
+ //add warning message
+ alert(errorinfo);
+ return;
+ }
+
+ //disabled the button
+ $('.ui-dialog-buttonpane button').attr('disabled', 'disabled');
+
+ args = args.substr(0, args.length - 1);
+
+ $('#pnodeeditarea').append(createLoader());
+ //send the save hmc request
+ $.ajax({
+ url : 'lib/cmd.php',
+ dataType : 'json',
+ data : {
+ cmd : 'webrun',
+ tgt : '',
+ args : 'addpnode;hmc;' + args,
+ msg : ''
+ },
+ success : function(data){
+ //refresh the area on the right side
+ $('#addpnodeDiv').dialog('close');
+ $('.selectgroup').trigger('click');
+ }
+ });
+}
+
+/**
+ * Add system p node, contains frame, cec, lpar
+ *
+ * @return Nothing
+ */
+function addPNode(){
+ //get the hmc name
+ var hmcname = $('#pnodeeditarea select').val();
+ var nodename = '';
+ //get all need added node
+ $('#pnodeeditarea :checked').each(function(){
+ if ($(this).attr('name')){
+ nodename += $(this).attr('name') + ',';
+ }
+ });
+
+ if (!nodename){
+ alert('You should select nodes first!');
+ return;
+ }
+ //disabled the button
+ $('.ui-dialog-buttonpane button').attr('disabled', 'disabled');
+
+ nodename = nodename.substr(0, nodename.length - 1);
+ $('#pnodeeditarea').append(createLoader());
+ //send the add request
+ $.ajax({
+ url : 'lib/cmd.php',
+ dataType : 'json',
+ data : {
+ cmd : 'webrun',
+ tgt : '',
+ args : 'addpnode;node;' + hmcname + ',' + nodename,
+ msg : ''
+ },
+ success : function(data){
+ //refresh the area on the right side
+ $('#addpnodeDiv').dialog('close');
+ $('.selectgroup').trigger('click');
+ }
+ });
+}
+
+/**
+ * select all checkbox in a table
+ *
+ * @return Nothing
+ */
+function selectAllRscanNode(obj){
+ var status = $(obj).attr('checked');
+ $(obj).parents('table').find(':checkbox').attr('checked', status);
+}
\ No newline at end of file
diff --git a/xCAT-UI/js/nodes/nodes.js b/xCAT-UI/js/nodes/nodes.js
index 069a684e8..67654005c 100644
--- a/xCAT-UI/js/nodes/nodes.js
+++ b/xCAT-UI/js/nodes/nodes.js
@@ -211,17 +211,16 @@ function loadSummaryDetail(ev, seriesIndex, pointIndex, data){
var table = '';
switch (temp) {
case 'os':
- break;
case 'arch':
- break;
case 'provmethod':
- break;
- case 'nodetype':
+ case 'nodetype':{
table = 'nodetype';
- break;
- case 'status':
+ }
+ break;
+ case 'status': {
table = 'nodelist';
- break;
+ }
+ break;
}
var args = table + '.' + temp + '==';
@@ -395,8 +394,8 @@ function mkAddNodeLink() {
+ ''
+ 'iDataPlex '
+ 'BladeCenter '
- + 'System p '
- + 'System z '
+ + 'System P '
+ + 'System Z '
+ ' '
+ '');
diff --git a/xCAT-server/lib/xcat/plugins/web.pm b/xCAT-server/lib/xcat/plugins/web.pm
index acf10a62e..5413a3b75 100644
--- a/xCAT-server/lib/xcat/plugins/web.pm
+++ b/xCAT-server/lib/xcat/plugins/web.pm
@@ -55,7 +55,8 @@ sub process_request {
'summary' => \&web_summary,
'gangliashow' => \&web_gangliaShow,
'gangliacurrent' => \&web_gangliaLatest,
- 'rinstall' => \&web_rinstall
+ 'rinstall' => \&web_rinstall,
+ 'addpnode' => \&web_addpnode
);
#check whether the request is authorized or not
@@ -1889,4 +1890,65 @@ sub web_rinstall {
$callback->( { data => $out } );
}
+
+sub web_addpnode{
+ my ( $request, $callback, $sub_req ) = @_;
+ my $nodetype = $request->{arg}->[1];
+ my @tempArray = split(',', $request->{arg}->[2]);
+
+ my $hmcname = shift(@tempArray);
+ if ('hmc' eq $nodetype){
+ my $username = $tempArray[0];
+ my $passwd = $tempArray[1];
+ my $ip = $tempArray[2];
+ `/bin/grep '$hmcname' /etc/hosts`;
+ if ($?){
+ open(OUTPUTFILE, '>>/etc/hosts');
+ print OUTPUTFILE "$ip $hmcname\n";
+ close(OUTPUTFILE);
+ }
+
+ `chdef -t node -o $hmcname username=$username password=$passwd mgt=hmc nodetype=hmc groups=all`;
+ return;
+ }
+
+ my %temphash;
+ my $writeflag = 0;
+ my $line = '';
+ #save all node into a hash
+ foreach(@tempArray) {
+ $temphash{$_} = 1;
+ }
+ `rscan $hmcname -z > /tmp/rscanall.tmp`;
+ #if can not create the rscan result file, error
+ unless(-e '/tmp/rscanall.tmp'){
+ return;
+ }
+
+ open(INPUTFILE, '/tmp/rscanall.tmp');
+ open(OUTPUTFILE, '>/tmp/webrscan.tmp');
+ while($line=){
+ if ($line =~ /(\S+):$/){
+ if ($temphash{$1}){
+ $writeflag = 1;
+ print OUTPUTFILE $line;
+ }
+ else{
+ $writeflag = 0;
+ }
+ }
+ else{
+ if ($writeflag){
+ print OUTPUTFILE $line;
+ }
+ }
+ }
+
+ close(INPUTFILE);
+ close(OUTPUTFILE);
+ unlink('/tmp/rscanall.tmp');
+
+ `cat /tmp/webrscan.tmp | chdef -z`;
+ unlink('/tmp/webrscan.tmp');
+}
1;