From aba74b7d5275737621195c09b23e7945b3bb96d4 Mon Sep 17 00:00:00 2001 From: phamt Date: Fri, 8 Feb 2013 05:54:14 +0000 Subject: [PATCH] Fixed argument passing delimiter. Added warnings to the UI. Added check for userprefix file. git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/branches/2.8@15111 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd --- xCAT-UI/js/configure/users.js | 6 +- xCAT-UI/js/custom/esx.js | 9 ++ xCAT-UI/js/custom/kvm.js | 9 ++ xCAT-UI/js/custom/zvm.js | 8 +- xCAT-UI/js/custom/zvmUtils.js | 6 +- xCAT-UI/js/nodes/nodes.js | 186 +++++++++++++--------------- xCAT-UI/js/service/service.js | 42 +++---- xCAT-UI/js/ui.js | 14 +-- xCAT-UI/lib/cmd.php | 6 +- xCAT-UI/lib/zCmd.php | 6 +- xCAT-server/lib/xcat/plugins/zvm.pm | 134 +++++++++++--------- 11 files changed, 220 insertions(+), 206 deletions(-) diff --git a/xCAT-UI/js/configure/users.js b/xCAT-UI/js/configure/users.js index 3781df970..dda52524a 100644 --- a/xCAT-UI/js/configure/users.js +++ b/xCAT-UI/js/configure/users.js @@ -323,7 +323,7 @@ function openCreateUserDialog(data) { data : { cmd : 'webrun', tgt : '', - args : 'policy|' + priority + '|' + args, + args : 'policy||' + priority + '||' + args, msg : dialogId }, @@ -337,7 +337,7 @@ function openCreateUserDialog(data) { data : { cmd : 'webrun', tgt : '', - args : 'passwd|' + usrName + '|' + password, + args : 'passwd||' + usrName + '||' + password, msg : dialogId }, @@ -455,7 +455,7 @@ function openDeleteUserDialog(users) { data : { cmd : 'webrun', tgt : '', - args : 'deleteuser|' + users, + args : 'deleteuser||' + users, msg : dialogId }, success : updatePanel diff --git a/xCAT-UI/js/custom/esx.js b/xCAT-UI/js/custom/esx.js index 92b084c90..33f686a59 100644 --- a/xCAT-UI/js/custom/esx.js +++ b/xCAT-UI/js/custom/esx.js @@ -70,6 +70,15 @@ esxPlugin.prototype.loadConfigPage = function(tabId) { profileLnk.trigger('click'); }; +/** + * Migrate node + * + * @param node Node to migrate + */ +esxPlugin.prototype.loadMigratePage = function(node) { + openDialog('info', 'Not yet supported'); +}; + /** * Clone node (service page) * diff --git a/xCAT-UI/js/custom/kvm.js b/xCAT-UI/js/custom/kvm.js index 1f2ca89b1..4add9688d 100644 --- a/xCAT-UI/js/custom/kvm.js +++ b/xCAT-UI/js/custom/kvm.js @@ -68,6 +68,15 @@ kvmPlugin.prototype.loadConfigPage = function(tabId) { profileLnk.trigger('click'); }; +/** + * Migrate node + * + * @param node Node to migrate + */ +kvmPlugin.prototype.loadMigratePage = function(node) { + openDialog('info', 'Not yet supported'); +}; + /** * Clone node (service page) * diff --git a/xCAT-UI/js/custom/zvm.js b/xCAT-UI/js/custom/zvm.js index 015b050b2..a6dbf87f9 100644 --- a/xCAT-UI/js/custom/zvm.js +++ b/xCAT-UI/js/custom/zvm.js @@ -2394,18 +2394,16 @@ zvmPlugin.prototype.loadMigratePage = function(tgtNode) { if (maxQuiesce.val() <= 0) { args = args + "max_quiesce=NOLIMIT;"; } else { - args = args + "'max_quiesce=" + maxQuiesce.val() + "';"; + args = args + "max_quiesce=" + maxQuiesce.val() + ";"; } // Append force argument if ($("input[name=force]:checked").length > 0) { args = args + "'force=" $("input[name=force]:checked").each(function() { - args = args + $(this).val() + ' '; + args += $(this).val() + ' '; }); - args = args + "';"; - } else { - args = args + ";"; + args += "';"; } var statBarId = 'migrateStatusBar' + inst; diff --git a/xCAT-UI/js/custom/zvmUtils.js b/xCAT-UI/js/custom/zvmUtils.js index 5df11d311..8bc5dd041 100644 --- a/xCAT-UI/js/custom/zvmUtils.js +++ b/xCAT-UI/js/custom/zvmUtils.js @@ -1993,7 +1993,7 @@ function openAddScsi2SystemDialog(hcp) { data : { cmd : 'chhypervisor', tgt : hcp, - args : "--addscsi|" + num + "|" + pathArray + "|" + option + "|" + persist, + args : "--addscsi||" + num + "||" + pathArray + "||" + option + "||" + persist, msg : dialogId }, @@ -2707,7 +2707,7 @@ function removeZfcp(node, address, wwpn, lun) { data : { cmd : 'chvm', tgt : node, - args : '--removezfcp;' + address + ';' + wwpn + ';' + lun, + args : '--removezfcp||' + address + '||' + wwpn + '||' + lun, msg : node }, @@ -3624,7 +3624,7 @@ function openAddZfcp2PoolDialog() { data : { cmd : 'chvm', tgt : tgtHcp, - args : '--addzfcp2pool|' + tgtPool + '|' + tgtStatus + '|"' + tgtPortName + '"|' + tgtUnitNo + '|' + tgtSize + "| " + tgtRange + '|' + tgtOwner, + args : '--addzfcp2pool||' + tgtPool + '||' + tgtStatus + '||"' + tgtPortName + '"||' + tgtUnitNo + '||' + tgtSize + '||' + tgtRange + '||' + tgtOwner, msg : dialogId }, diff --git a/xCAT-UI/js/nodes/nodes.js b/xCAT-UI/js/nodes/nodes.js index 074d5d520..76b16a7f7 100644 --- a/xCAT-UI/js/nodes/nodes.js +++ b/xCAT-UI/js/nodes/nodes.js @@ -418,24 +418,24 @@ function mkAddNodeLink() { var plugin; switch(mgt) { - case "kvm": - plugin = new kvmPlugin(); - break; - case "esx": - plugin = new esxPlugin(); - break; - case "blade": - plugin = new bladePlugin(); - break; - case "hmc": - plugin = new hmcPlugin(); - break; - case "ipmi": - plugin = new ipmiPlugin(); - break; - case "zvm": - plugin = new zvmPlugin(); - break; + case "kvm": + plugin = new kvmPlugin(); + break; + case "esx": + plugin = new esxPlugin(); + break; + case "blade": + plugin = new bladePlugin(); + break; + case "hmc": + plugin = new hmcPlugin(); + break; + case "ipmi": + plugin = new ipmiPlugin(); + break; + case "zvm": + plugin = new zvmPlugin(); + break; } plugin.addNode(); @@ -686,24 +686,15 @@ function loadNodes(data) { // Create an instance of the plugin var plugin; switch(mgt) { - case "blade": - plugin = new bladePlugin(); - break; - case "fsp": - plugin = new fspPlugin(); - break; - case "hmc": - plugin = new hmcPlugin(); - break; - case "ipmi": - plugin = new ipmiPlugin(); - break; - case "ivm": - plugin = new ivmPlugin(); - break; - case "zvm": - plugin = new zvmPlugin(); - break; + case "kvm": + plugin = new kvmPlugin(); + break; + case "esx": + plugin = new esxPlugin(); + break; + case "zvm": + plugin = new zvmPlugin(); + break; } plugin.loadClonePage(tgtNodes[i]); @@ -741,34 +732,35 @@ function loadNodes(data) { var migrateLnk = $('Migrate'); migrateLnk.click(function() { var tgtNodes = getNodesChecked(nodesTableId).split(','); + var mgt = "", tmp = ""; for (var i in tgtNodes) { - var mgt = getNodeAttr(tgtNodes[i], 'mgt'); - - // Create an instance of the plugin - var plugin; - switch(mgt) { - case "blade": - plugin = new bladePlugin(); - break; - case "fsp": - plugin = new fspPlugin(); - break; - case "hmc": - plugin = new hmcPlugin(); - break; - case "ipmi": - plugin = new ipmiPlugin(); - break; - case "ivm": - plugin = new ivmPlugin(); - break; - case "zvm": - plugin = new zvmPlugin(); - break; + tmp = getNodeAttr(tgtNodes[i], 'mgt'); + if (!mgt) { + mgt = tmp + } else { + if (tmp != mgt) { + openDialog('warn', "You can pick only one type (mgt) of node to migrate!"); + return; + } } - - plugin.loadMigratePage(tgtNodes[i]); } + + // Create an instance of the plugin + var plugin; + switch(mgt) { + // Only hypervisors support migration + case "kvm": + plugin = new kvmPlugin(); + break; + case "esx": + plugin = new esxPlugin(); + break; + case "zvm": + plugin = new zvmPlugin(); + break; + } + + plugin.loadMigratePage(tgtNodes); }); // Update @@ -854,24 +846,24 @@ function loadNodes(data) { // Create an instance of the plugin var plugin; switch(mgt) { - case "blade": - plugin = new bladePlugin(); - break; - case "fsp": - plugin = new fspPlugin(); - break; - case "hmc": - plugin = new hmcPlugin(); - break; - case "ipmi": - plugin = new ipmiPlugin(); - break; - case "ivm": - plugin = new ivmPlugin(); - break; - case "zvm": - plugin = new zvmPlugin(); - break; + case "kvm": + plugin = new kvmPlugin(); + break; + case "esx": + plugin = new esxPlugin(); + break; + case "blade": + plugin = new bladePlugin(); + break; + case "hmc": + plugin = new hmcPlugin(); + break; + case "ipmi": + plugin = new ipmiPlugin(); + break; + case "zvm": + plugin = new zvmPlugin(); + break; } plugin.loadLogPage(tgtNodes[i]); @@ -1635,24 +1627,24 @@ function loadNode(e) { // Create an instance of the plugin var plugin; switch(mgt) { - case "blade": - plugin = new bladePlugin(); - break; - case "fsp": - plugin = new fspPlugin(); - break; - case "hmc": - plugin = new hmcPlugin(); - break; - case "ipmi": - plugin = new ipmiPlugin(); - break; - case "ivm": - plugin = new ivmPlugin(); - break; - case "zvm": - plugin = new zvmPlugin(); - break; + case "kvm": + plugin = new kvmPlugin(); + break; + case "esx": + plugin = new esxPlugin(); + break; + case "blade": + plugin = new bladePlugin(); + break; + case "hmc": + plugin = new hmcPlugin(); + break; + case "ipmi": + plugin = new ipmiPlugin(); + break; + case "zvm": + plugin = new zvmPlugin(); + break; } // Get tab area where a new tab will be inserted diff --git a/xCAT-UI/js/service/service.js b/xCAT-UI/js/service/service.js index e40140014..13da1083c 100644 --- a/xCAT-UI/js/service/service.js +++ b/xCAT-UI/js/service/service.js @@ -858,18 +858,15 @@ function loadNode(e) { // Create an instance of the plugin var plugin; switch (mgt) { - case "blade": - plugin = new bladePlugin(); - break; - case "hmc": - plugin = new hmcPlugin(); - break; - case "ipmi": - plugin = new ipmiPlugin(); - break; - case "zvm": - plugin = new zvmPlugin(); - break; + case "kvm": + plugin = new kvmPlugin(); + break; + case "esx": + plugin = new esxPlugin(); + break; + case "zvm": + plugin = new zvmPlugin(); + break; } // Select tab @@ -1317,18 +1314,15 @@ function cloneNode(tgtNodes) { // Create an instance of the plugin var plugin; switch (hw) { - case "blade": - plugin = new bladePlugin(); - break; - case "hmc": - plugin = new hmcPlugin(); - break; - case "ipmi": - plugin = new ipmiPlugin(); - break; - case "zvm": - plugin = new zvmPlugin(); - break; + case "kvm": + plugin = new kvmPlugin(); + break; + case "esx": + plugin = new esxPlugin(); + break; + case "zvm": + plugin = new zvmPlugin(); + break; } // Clone node diff --git a/xCAT-UI/js/ui.js b/xCAT-UI/js/ui.js index 6d1450914..10996f56d 100644 --- a/xCAT-UI/js/ui.js +++ b/xCAT-UI/js/ui.js @@ -676,21 +676,21 @@ function writeRsp(rsp, pattern) { * @param msg Message to show */ function openDialog(type, msg) { - var msgDialog; + var msgDialog = $('
'); + var title = ""; if (type == "warn") { // Create warning message - msgDialog = $('
' - + '

' + msg + '

' - + '
'); + msgDialog.append(createWarnBar(msg)); + title = "Warning"; } else { // Create info message - msgDialog = $('
' - + '

' + msg + '

' - +'
'); + msgDialog.append(createInfoBar(msg)); + title = "Info"; } // Open dialog msgDialog.dialog({ + title: title, modal: true, close: function(){ $(this).remove(); diff --git a/xCAT-UI/lib/cmd.php b/xCAT-UI/lib/cmd.php index eb3741775..f63f83000 100644 --- a/xCAT-UI/lib/cmd.php +++ b/xCAT-UI/lib/cmd.php @@ -41,14 +41,14 @@ if (isset($_GET["cmd"])) { } // If no $args are given, set $args_array to NULL - // Separators used are: | or ; + // Separators used are: || or ; $args_array = array(); if ($args) { // If $args contains multiple arguments, split it into an array - if (strpos($args, "|")) { + if (strpos($args, "||")) { // Split the arguments into an array $args_array = array(); - $args_array = explode("|", $args); + $args_array = explode("||", $args); } else if (strpos($args, ";")) { // Split the arguments into an array $args_array = array(); diff --git a/xCAT-UI/lib/zCmd.php b/xCAT-UI/lib/zCmd.php index 7bdf07b81..c2a21eebf 100644 --- a/xCAT-UI/lib/zCmd.php +++ b/xCAT-UI/lib/zCmd.php @@ -45,11 +45,11 @@ if (isset($_GET["cmd"])) { } // If $args contains multiple arguments, split it into an array - // Separators used are: | or ; - if (strpos($args, "|")) { + // Separators used are: || or ; + if (strpos($args, "||")) { // Split the arguments into an array $arr = array(); - $arr = explode("|", $args); + $arr = explode("||", $args); } else if (strpos($args, ";")) { // Split the arguments into an array $arr = array(); diff --git a/xCAT-server/lib/xcat/plugins/zvm.pm b/xCAT-server/lib/xcat/plugins/zvm.pm index 4062375cc..8e8e6d2e3 100644 --- a/xCAT-server/lib/xcat/plugins/zvm.pm +++ b/xCAT-server/lib/xcat/plugins/zvm.pm @@ -138,6 +138,9 @@ sub process_request { # Directory where executables are on zHCP $::DIR = "/opt/zhcp/bin"; + # Directory where system config is on zHCP + $::SYSCONF = "/opt/zhcp/conf"; + # Directory where zFCP disk pools are on zHCP $::ZFCPPOOL = "/var/opt/zhcp/zfcp"; @@ -2874,71 +2877,80 @@ sub makeVM { $macId = xCAT::zvmUtils->replaceStr( $macId, ":", "" ); $macId = substr( $macId, 6 ); } else { + my $prefix; + if (`ssh -o ConnectTimeout=5 $::SUDOER\@$hcp "$::SUDO test -f $::SYSCONF/userprefix && echo Exists"`) { + $prefix = `ssh -o ConnectTimeout=5 $::SUDOER\@$hcp "$::SUDO cat $::SYSCONF/userprefix"`; + $prefix =~ s/\s*$//; + $prefix =~ s/^\s*//; + } # Get zHCP MAC address # The MAC address prefix is the same for all network devices - $out = `ssh -o ConnectTimeout=5 $::SUDOER\@$hcp "/sbin/modprobe vmcp"`; - $out = `ssh -o ConnectTimeout=5 $::SUDOER\@$hcp "$::SUDO /sbin/vmcp q v nic" | grep "MAC:"`; - if ($out) { - @lines = split( "\n", $out ); - @words = split( " ", $lines[0] ); - - # Extract MAC prefix - my $prefix = $words[1]; - $prefix = xCAT::zvmUtils->replaceStr( $prefix, "-", "" ); - $prefix = substr( $prefix, 0, 6 ); - - # Generate MAC address - my $mac; - while ($generateNew) { - - # If no MACID is found, get one - $macId = xCAT::zvmUtils->getMacID($::SUDOER, $hcp); - if ( !$macId ) { - xCAT::zvmUtils->printLn( $callback, "$node: (Error) Could not generate MACID" ); - return; - } - - # Create MAC address - $mac = $prefix . $macId; - - # If length is less than 12, append a zero - if ( length($mac) != 12 ) { - $mac = "0" . $mac; - } - - # Format MAC address - $mac = - substr( $mac, 0, 2 ) . ":" - . substr( $mac, 2, 2 ) . ":" - . substr( $mac, 4, 2 ) . ":" - . substr( $mac, 6, 2 ) . ":" - . substr( $mac, 8, 2 ) . ":" - . substr( $mac, 10, 2 ); - - # Check 'mac' table for MAC address - my $tab = xCAT::Table->new( 'mac', -create => 1, -autocommit => 0 ); - my @entries = $tab->getAllAttribsWhere( "mac = '" . $mac . "'", 'node' ); - - # If MAC address exists - if (@entries) { - # Generate new MACID - $out = xCAT::zvmUtils->generateMacId($::SUDOER, $hcp); - $generateNew = 1; - } else { - $generateNew = 0; - - # Save MAC address in 'mac' table - xCAT::zvmUtils->setNodeProp( 'mac', $node, 'mac', $mac ); - - # Generate new MACID - $out = xCAT::zvmUtils->generateMacId($::SUDOER, $hcp); - } - } # End of while ($generateNew) - } else { - xCAT::zvmUtils->printLn( $callback, "$node: (Error) Could not find the MAC address of the zHCP" ); - xCAT::zvmUtils->printLn( $callback, "$node: (Solution) Verify that the node's zHCP($hcp) is correct, the node is online, and the SSH keys are setup for the zHCP" ); + if (!$prefix) { + $out = `ssh -o ConnectTimeout=5 $::SUDOER\@$hcp "/sbin/modprobe vmcp"`; + $out = `ssh -o ConnectTimeout=5 $::SUDOER\@$hcp "$::SUDO /sbin/vmcp q v nic" | grep "MAC:"`; + if ($out) { + @lines = split( "\n", $out ); + @words = split( " ", $lines[0] ); + + # Extract MAC prefix + $prefix = $words[1]; + $prefix = xCAT::zvmUtils->replaceStr( $prefix, "-", "" ); + $prefix = substr( $prefix, 0, 6 ); + } else { + xCAT::zvmUtils->printLn( $callback, "$node: (Error) Could not find the MAC address of the zHCP" ); + xCAT::zvmUtils->printLn( $callback, "$node: (Solution) Verify that the node's zHCP($hcp) is correct, the node is online, and the SSH keys are setup for the zHCP" ); + return; + } } + + # Generate MAC address + my $mac; + while ($generateNew) { + + # If no MACID is found, get one + $macId = xCAT::zvmUtils->getMacID($::SUDOER, $hcp); + if ( !$macId ) { + xCAT::zvmUtils->printLn( $callback, "$node: (Error) Could not generate MACID" ); + return; + } + + # Create MAC address + $mac = $prefix . $macId; + + # If length is less than 12, append a zero + if ( length($mac) != 12 ) { + $mac = "0" . $mac; + } + + # Format MAC address + $mac = + substr( $mac, 0, 2 ) . ":" + . substr( $mac, 2, 2 ) . ":" + . substr( $mac, 4, 2 ) . ":" + . substr( $mac, 6, 2 ) . ":" + . substr( $mac, 8, 2 ) . ":" + . substr( $mac, 10, 2 ); + + # Check 'mac' table for MAC address + my $tab = xCAT::Table->new( 'mac', -create => 1, -autocommit => 0 ); + my @entries = $tab->getAllAttribsWhere( "mac = '" . $mac . "'", 'node' ); + + # If MAC address exists + if (@entries) { + # Generate new MACID + $out = xCAT::zvmUtils->generateMacId($::SUDOER, $hcp); + $generateNew = 1; + } else { + $generateNew = 0; + + # Save MAC address in 'mac' table + xCAT::zvmUtils->setNodeProp( 'mac', $node, 'mac', $mac ); + + # Generate new MACID + $out = xCAT::zvmUtils->generateMacId($::SUDOER, $hcp); + } + } # End of while ($generateNew) } # Create virtual server