From b2d4f247e22d601d25cea272a156a2085c5e4a2e Mon Sep 17 00:00:00 2001
From: wanghuaz <wanghuaz@8638fb3e-16cb-4fca-ae20-7b5d299a9bcd>
Date: Thu, 5 Nov 2009 04:15:18 +0000
Subject: [PATCH] Fixed the issue that openfirmware produce the garbage which
 will impact the conserver's parser

git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@4477 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
---
 xCAT-server/sbin/lpar_netboot.expect | 30 +++++++++++++++++++++-------
 1 file changed, 23 insertions(+), 7 deletions(-)

diff --git a/xCAT-server/sbin/lpar_netboot.expect b/xCAT-server/sbin/lpar_netboot.expect
index e80232315..802de12af 100644
--- a/xCAT-server/sbin/lpar_netboot.expect
+++ b/xCAT-server/sbin/lpar_netboot.expect
@@ -694,13 +694,29 @@ proc get_mac_addr { phandle } {
     # used to eliminate the spaces put in by the dump command.
     # state 2, mac-address on stack
     set done(2) 0
-    set cmd(2) "dump\r"
-    set msg(2) "$PROGRAM Status: mac-address displayed, stack empty\n"
-    set pattern(2) "(.*)(: )(.*)( :)(.*)(: ok)"
+    set cmd(2) ": dump-mac ( prop-addr prop-len -- ) \
+                cr  \
+                dup decode-bytes  2swap 2drop   ( data-addr data-len ) \
+                ( data-len ) 0 ?do \
+                    dup c@ 2 u.r                  ( data-addr ) \
+                    char+                        ( data-addr' ) \
+                loop \
+                drop \
+                cr \
+                ; \r"
+    set msg(2) "$PROGRAM Status: set command\n"
+    set pattern(2) "(.*)ok"
     set newstate(2) 3
 
-    # state 3, all done
-    set done(3) 1
+    set done(3) 0
+    set cmd(3) "dump-mac\r"
+    set msg(3) "$PROGRAM Status: mac-address displayed, stack empty\n"
+    set pattern(3) "dump-mac(.*)ok"
+    set newstate(3) 4
+
+
+    # state 4, all done
+    set done(4) 1
 
     set state 0
     set timeout 60     ;# shouldn't take long
@@ -769,8 +785,8 @@ proc get_mac_addr { phandle } {
         }
     }
     # if the state is 0, 1, or 2, an error occurred and the join will fail
-    if { $state == 3 } {
-        set mac_address [ join $expect_out(3,string) "" ]
+    if { $state == 4 } {
+        set mac_address [ join $expect_out(1,string) "" ]
         set rc 0
         return $mac_address
     } else {