From bb1f68f44000a1e34825d81cc2811d00e51e6b23 Mon Sep 17 00:00:00 2001
From: phamt <phamt@8638fb3e-16cb-4fca-ae20-7b5d299a9bcd>
Date: Fri, 15 Feb 2013 22:52:59 +0000
Subject: [PATCH] Fix MAC address prefix.

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@15191 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
---
 xCAT-server/lib/xcat/plugins/zvm.pm | 30 +++++++++--------------------
 1 file changed, 9 insertions(+), 21 deletions(-)

diff --git a/xCAT-server/lib/xcat/plugins/zvm.pm b/xCAT-server/lib/xcat/plugins/zvm.pm
index b324cf388..e679785b9 100644
--- a/xCAT-server/lib/xcat/plugins/zvm.pm
+++ b/xCAT-server/lib/xcat/plugins/zvm.pm
@@ -2919,31 +2919,19 @@ 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*//;
-        }
+    	$out = `ssh -o ConnectTimeout=5 $::SUDOER\@$hcp "/sbin/modprobe vmcp"`;
+    	
+    	my $prefix = `ssh -o ConnectTimeout=5 $::SUDOER\@$hcp "$::SUDO /sbin/vmcp q vmlan" | egrep -i "USER Prefix:"`;
+        $prefix =~ s/(.*?)USER Prefix:(.*)/$2/;
+        $prefix =~ s/^\s+//;
+        $prefix =~ s/\s+$//;
     	                
         # Get zHCP MAC address
         # The MAC address prefix is the same for all network devices
         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;
-	        }
+            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