baremetal: Allow BM_SECOND_MAC to be unset

Currently DevStack registers the second nic of the baremetal
node even if BM_SECOND_MAC is not set or empty. However
an interface with an empty mac address causes dhcp to fail
(bug 1238595). And such operation will get to return a error
after the bug is resolved. So we should not register the
second nic if BM_SECOND_MAC is not set.

Related-Bug: #1238595
Change-Id: Ib3cc77686b72311403ccacbd70ae9cf43e6eb4c9
diff --git a/lib/baremetal b/lib/baremetal
index 52af420..f4d8589 100644
--- a/lib/baremetal
+++ b/lib/baremetal
@@ -449,8 +449,10 @@
        "$mac_1" \
        | grep ' id ' | get_field 2 )
     [ $? -eq 0 ] || [ "$id" ] || die $LINENO "Error adding baremetal node"
-    id2=$(nova baremetal-interface-add "$id" "$mac_2" )
-    [ $? -eq 0 ] || [ "$id2" ] || die $LINENO "Error adding interface to barmetal node $id"
+    if [ -n "$mac_2" ]; then
+        id2=$(nova baremetal-interface-add "$id" "$mac_2" )
+        [ $? -eq 0 ] || [ "$id2" ] || die $LINENO "Error adding interface to barmetal node $id"
+    fi
 }