Added support for native SCSI/FCP on xCAT-UI.

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@14048 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
phamt 2012-10-18 14:18:28 +00:00
parent b33442caa5
commit a9408ab0d1
4 changed files with 1109 additions and 122 deletions

View File

@ -347,7 +347,6 @@ legend {
.actionBar {
display: inline-table;
width: 50%;
}
.actionBar div {

View File

@ -209,7 +209,7 @@ zvmPlugin.prototype.loadServiceInventory = function(data) {
var inv = data.rsp[0].split(node + ':');
// Create array of property keys
var keys = new Array('userId', 'host', 'os', 'arch', 'hcp', 'priv', 'memory', 'proc', 'disk', 'nic');
var keys = new Array('userId', 'host', 'os', 'arch', 'hcp', 'priv', 'memory', 'proc', 'disk', 'zfcp', 'nic');
// Create hash table for property names
var attrNames = new Object();
@ -222,6 +222,7 @@ zvmPlugin.prototype.loadServiceInventory = function(data) {
attrNames['memory'] = 'Total Memory:';
attrNames['proc'] = 'Processors:';
attrNames['disk'] = 'Disks:';
attrNames['zfcp'] = 'zFCP:';
attrNames['nic'] = 'NICs:';
// Create hash table for node attributes
@ -269,7 +270,10 @@ zvmPlugin.prototype.loadServiceInventory = function(data) {
*/
fieldSet = $('<fieldset id="' + node + '_monitor"></fieldset>');
legend = $('<legend>Monitoring [<a style="font-weight: normal; color: blue; text-decoration: none;">Refresh</a>]</legend>');
fieldSet.append(legend);
fieldSet.append(legend);
// var info = createInfoBar('No data available');
// fieldSet.append(info.css('width', '300px'));
getMonitorMetrics(node);
// Refresh monitoring charts on-click
@ -457,6 +461,51 @@ zvmPlugin.prototype.loadServiceInventory = function(data) {
dasdTable.append(dasdBody);
item.append(dasdTable);
}
/**
* zFCP section
*/
else if (keys[k] == 'zfcp') {
// Create a label - Property name
label = $('<label>' + attrNames[keys[k]].replace(':', '') + '</label>');
item.append(label);
// Create a table to hold NIC data
var zfcpTable = $('<table></table>');
var zfcpBody = $('<tbody></tbody>');
// Table columns - Virtual device, Adapter Type, Port Name, # of Devices, MAC Address, and LAN Name
var zfcpTabRow = $('<thead class="ui-widget-header"> <th>Virtual Device #</th> <th>Port Name</th> <th>Unit Number</th> <th>Size</th></thead>');
zfcpTable.append(zfcpTabRow);
var zfcpVDev, zfcpPortName, zfcpLun, zfcpSize;
// Loop through each zFCP device
if (attrs[keys[k]]) {
for (l = 0; l < attrs[keys[k]].length; l++) {
if (attrs[keys[k]][l]) {
args = attrs[keys[k]][l].split(' ');
// Get zFCP virtual device, port name (WWPN), unit number (LUN), and size
zfcpVDev = $('<td>' + args[1].replace('0.0.', '') + '</td>');
zfcpPortName = $('<td>' + args[4] + '</td>');
zfcpLun = $('<td>' + args[7] + '</td>');
zfcpSize = $('<td>' + args[args.length - 2] + ' ' + args[args.length - 1] + '</td>');
// Create a new row for each zFCP device
zfcpTabRow = $('<tr></tr>');
zfcpTabRow.append(zfcpVDev);
zfcpTabRow.append(zfcpPortName);
zfcpTabRow.append(zfcpLun);
zfcpTabRow.append(zfcpSize);
zfcpBody.append(zfcpTabRow);
}
}
}
zfcpTable.append(zfcpBody);
item.append(zfcpTable);
}
/**
* NIC section
@ -934,7 +983,7 @@ zvmPlugin.prototype.loadInventory = function(data) {
statBar.hide();
// Create array of property keys
var keys = new Array('userId', 'host', 'os', 'arch', 'hcp', 'priv', 'memory', 'proc', 'disk', 'nic');
var keys = new Array('userId', 'host', 'os', 'arch', 'hcp', 'priv', 'memory', 'proc', 'disk', 'zfcp', 'nic');
// Create hash table for property names
var attrNames = new Object();
@ -947,6 +996,7 @@ zvmPlugin.prototype.loadInventory = function(data) {
attrNames['memory'] = 'Total Memory:';
attrNames['proc'] = 'Processors:';
attrNames['disk'] = 'Disks:';
attrNames['zfcp'] = 'zFCP:';
attrNames['nic'] = 'NICs:';
// Create hash table for node attributes
@ -1143,6 +1193,7 @@ zvmPlugin.prototype.loadInventory = function(data) {
// Open dialog to confirm
var confirmDialog = $('<div><p>Are you sure you want to remove this processor?</p></div>');
confirmDialog.dialog({
title: "Confirm",
modal: true,
width: 300,
buttons: {
@ -1249,6 +1300,7 @@ zvmPlugin.prototype.loadInventory = function(data) {
// Open dialog to confirm
var confirmDialog = $('<div><p>Are you sure you want to remove this disk?</p></div>');
confirmDialog.dialog({
title: "Confirm",
modal: true,
width: 300,
buttons: {
@ -1315,6 +1367,100 @@ zvmPlugin.prototype.loadInventory = function(data) {
item.append(dasdTable);
}
/**
* zFCP section
*/
else if (keys[k] == 'zfcp') {
// Create a label - Property name
label = $('<label>' + attrNames[keys[k]].replace(':', '') + '</label>');
item.append(label);
// Create a table to hold NIC data
var zfcpTable = $('<table></table>');
var zfcpBody = $('<tbody></tbody>');
var zfcpFooter = $('<tfoot></tfoot>');
/**
* Remove zFCP
*/
contextMenu = [ {
'Remove' : function(menuItem, menu) {
var addr = $(this).text();
var portName = $(this).parents('tr').find('td:eq(1)').text();
var unitNo = $(this).parents('tr').find('td:eq(2)').text();
// Open dialog to confirm
var confirmDialog = $('<div><p>Are you sure you want to remove this zFCP device?</p></div>');
confirmDialog.dialog({
title: "Confirm",
modal: true,
width: 300,
buttons: {
"Ok": function(){
removeZfcp(node, addr, portName, unitNo);
$(this).dialog("close");
},
"Cancel": function() {
$(this).dialog("close");
}
}
});
}
} ];
// Table columns - Virtual device, Adapter Type, Port Name, # of Devices, MAC Address, and LAN Name
var zfcpTabRow = $('<thead class="ui-widget-header"> <th>Virtual Device #</th> <th>Port Name</th> <th>Unit Number</th> <th>Size</th></thead>');
zfcpTable.append(zfcpTabRow);
var zfcpVDev, zfcpPortName, zfcpLun, zfcpSize;
// Loop through each zFCP device
if (attrs[keys[k]]) {
for (l = 0; l < attrs[keys[k]].length; l++) {
if (attrs[keys[k]][l]) {
args = attrs[keys[k]][l].split(' ');
// Get zFCP virtual device, port name (WWPN), unit number (LUN), and size
zfcpVDev = $('<td></td>');
zfcpLink = $('<a>' + args[1].replace('0.0.', '') + '</a>');
// Append context menu to link
zfcpLink.contextMenu(contextMenu, {
theme : 'vista'
});
zfcpVDev.append(zfcpLink);
zfcpPortName = $('<td>' + args[4] + '</td>');
zfcpLun = $('<td>' + args[7] + '</td>');
zfcpSize = $('<td>' + args[args.length - 2] + ' ' + args[args.length - 1] + '</td>');
// Create a new row for each zFCP device
zfcpTabRow = $('<tr></tr>');
zfcpTabRow.append(zfcpVDev);
zfcpTabRow.append(zfcpPortName);
zfcpTabRow.append(zfcpLun);
zfcpTabRow.append(zfcpSize);
zfcpBody.append(zfcpTabRow);
}
}
}
zfcpTable.append(zfcpBody);
/**
* Add zFCP device
*/
var addZfcpLink = $('<a>Add zFCP</a>');
addZfcpLink.bind('click', function(event) {
var hcp = attrs['hcp'][0].split('.');
openAddZfcpDialog(node, hcp[0]);
});
zfcpFooter.append(addZfcpLink);
zfcpTable.append(zfcpFooter);
item.append(zfcpTable);
}
/**
* NIC section
@ -1339,6 +1485,7 @@ zvmPlugin.prototype.loadInventory = function(data) {
// Open dialog to confirm
var confirmDialog = $('<div><p>Are you sure you want to remove this NIC?</p></div>');
confirmDialog.dialog({
title: "Confirm",
modal: true,
width: 300,
buttons: {
@ -1381,7 +1528,7 @@ zvmPlugin.prototype.loadInventory = function(data) {
args = attrs[keys[k]][l + 1].split(' ');
nicLanName = $('<td>' + args[args.length - 2] + ' ' + args[args.length - 1] + '</td>');
// Create a new row for each DASD
// Create a new row for each NIC
nicTabRow = $('<tr></tr>');
nicTabRow.append(nicVDev);
nicTabRow.append(nicType);

File diff suppressed because it is too large Load Diff

View File

@ -535,6 +535,27 @@ sub removeVM {
# Delete user entry
$out = `ssh $hcp "$::DIR/smcli Image_Delete_DM -T $userId -e 1"`;
xCAT::zvmUtils->printLn( $callback, "$node: $out" );
# Go through each pool and free zFCP devices belonging to node
my @pools = split("\n", `ssh $hcp "ls $::ZFCPPOOL"`);
my $pool;
my @luns;
my $update;
my $expression;
foreach (@pools) {
$pool = xCAT::zvmUtils->replaceStr( $_, ".conf", "" );
@luns = split("\n", `ssh $hcp "cat $::ZFCPPOOL/$_" | egrep -i $node`);
foreach (@luns) {
# Update entry: status,wwpn,lun,size,owner,channel,tag
my @info = split(',', $_);
$update = "free,$info[1],$info[2],$info[3],,,";
$expression = "'s#" . $_ . "#" .$update . "#i'";
$out = `ssh $hcp "sed --in-place -e $expression $::ZFCPPOOL/$pool.conf"`;
}
xCAT::zvmUtils->printLn($callback, "$node: Updating FCP device pool $pool... Done");
}
# Check for errors
my $rc = xCAT::zvmUtils->checkOutput( $callback, $out );
@ -708,7 +729,7 @@ sub changeVM {
}
}
# addzfcp2pool [pool] [status] [wwpn] [lun] [size] [owner]
# addzfcp2pool [pool] [status] [wwpn] [lun] [size] [owner (optional)]
elsif ( $args->[0] eq "--addzfcp2pool" ) {
# zFCP disk pool located on zHCP at /var/opt/zhcp/zfcp/{pool}.conf
# Entries contain: status,wwpn,lun,size,owner,channel,tag
@ -751,6 +772,7 @@ sub changeVM {
if (!(`ssh $hcp "test -e $::ZFCPPOOL/$pool.conf && echo Exists"`)) {
# Create pool configuration file
$out = `ssh $hcp "echo '#status,wwpn,lun,size,owner,channel,tag' > $::ZFCPPOOL/$pool.conf"`;
xCAT::zvmUtils->printLn( $callback, "$node: New zFCP device pool $pool created" );
}
# Do not update if the LUN already exists
@ -761,6 +783,7 @@ sub changeVM {
# Update file with given WWPN, LUN, size, and owner
$out = `ssh $hcp "echo \"$status,$wwpn,$lun,$size,$owner,,\" >> $::ZFCPPOOL/$pool.conf"`;
xCAT::zvmUtils->printLn( $callback, "$node: Adding zFCP device to $pool pool... Done" );
}
# addnic [address] [type] [device count]
@ -908,7 +931,7 @@ sub changeVM {
$sizeFound = $info[3];
$wwpn = $info[1];
$lun = $info[2];
} elsif ($info[3] >= $size) {
} elsif (!$sizeFound && $info[3] >= $size) {
$sizeFound = $info[3];
$wwpn = $info[1];
$lun = $info[2];
@ -1453,23 +1476,34 @@ sub changeVM {
return;
}
# Make sure WWPN and LUN do not have 0x prefix
$lun = xCAT::zvmUtils->replaceStr($lun, "0x", "");
my @luns;
if ($lun =~ m/,/i) {
@luns = split( ',', $lun );
} else {
push(@luns, $lun);
}
# Find disk pool (create one if non-existent)
if (!(`ssh $hcp "test -e $::ZFCPPOOL/$pool.conf && echo Exists"`)) {
xCAT::zvmUtils->printLn( $callback, "$node: (Error) zFCP pool does not exist" );
return;
}
# Do not update if LUN does not exists
if (!(`ssh $hcp "cat $::ZFCPPOOL/$pool.conf" | grep $lun`)) {
xCAT::zvmUtils->printLn( $callback, "$node: (Error) zFCP device does not exists" );
return;
# Go through each LUN
foreach (@luns) {
# Make sure WWPN and LUN do not have 0x prefix
$_ = xCAT::zvmUtils->replaceStr($_, "0x", "");
# Do not update if LUN does not exists
if (!(`ssh $hcp "cat $::ZFCPPOOL/$pool.conf" | grep $_`)) {
xCAT::zvmUtils->printLn( $callback, "$node: (Error) zFCP device $_ does not exists" );
return;
}
# Update file with given WWPN, LUN, size, and owner
$out = `ssh $hcp "sed --in-place -e /$_/d $::ZFCPPOOL/$pool.conf"`;
xCAT::zvmUtils->printLn( $callback, "$node: Removing zFCP device $_ from $pool pool... Done");
}
# Update file with given WWPN, LUN, size, and owner
$out = `ssh $hcp "sed --in-place -e /$lun/d $::ZFCPPOOL/$pool.conf"`;
}
# removedisk [virtual address]
@ -2316,7 +2350,7 @@ sub listVM {
# Go through each zFCP pool
my @pools = split("\n", `ssh $hcp "ls $::ZFCPPOOL"`);
foreach (@pools) {
$_ = uc(xCAT::zvmUtils->replaceStr( $_, ".conf", "" ));
$_ = xCAT::zvmUtils->replaceStr( $_, ".conf", "" );
$out .= "$_\n";
}
}