Independent tool for IBM IP info. to DUMMYIP conversion

Robotframework RUN command not providing consistent output.
Hence removed inline code to convert IPs to DUMMYIP.

Instead call new "convert_ip_to_dummy" program.

Resolves: openbmc/openbmc-test-automation#455

Change-Id: Ia5e8c4f7f3ef04545d667f032add36df8a35458d
Signed-off-by: Sivas SRR <sivas.srr@in.ibm.com>
diff --git a/lib/openbmc_ffdc_methods.robot b/lib/openbmc_ffdc_methods.robot
index 5a6f5ba..9ee8775 100755
--- a/lib/openbmc_ffdc_methods.robot
+++ b/lib/openbmc_ffdc_methods.robot
@@ -154,14 +154,10 @@
     ...                file name in the current FFDC directory.
     [Arguments]        ${key_index}
 
-    # To build IP address in searchable form eg: dummy\.domain\.com
-    ${OPENBMC_HOST_REGEX}=  Run  echo ${OPENBMC_HOST} | sed 's/\(\.\)/\\\1/g'
     @{cmd_list}=      Get ffdc bmc file   ${key_index}
     :FOR  ${cmd}  IN  @{cmd_list}
     \   ${logpath}=  Catenate  SEPARATOR=   ${LOG_PREFIX}   ${cmd[0]}.txt
     \   Execute Command and Write FFDC  ${cmd[0]}  ${cmd[1]}   ${logpath}
-    # Rename OPENBMC_HOST IP address from given file to DUMMYIP
-    \   Run  sed -i 's/'${OPENBMC_HOST_REGEX}'/DUMMYIP/g' ${logpath}
 
 
 
diff --git a/tools/convert_ip_to_dummy b/tools/convert_ip_to_dummy
new file mode 100755
index 0000000..79f0f25
--- /dev/null
+++ b/tools/convert_ip_to_dummy
@@ -0,0 +1,29 @@
+#!/bin/bash
+
+# This program will modify a file by substituting all instances of a specified
+# IP with "DUMMYIP".  This is useful for making the IP address generic and thus
+# searchable.
+
+# Description of argument(s):
+# ip_addr    An IP address.
+# file_path  The path to a file which is to be modified.
+
+# Get arguments.
+ip_addr="${1}" ; shift
+file_path="${1}" ; shift
+
+# Validate arguments.
+if [ -z "${ip_addr}" ] ; then
+  echo "**ERROR** You must provide an IP address as the first positional" \
+       "parameter." >&2
+  exit 1
+fi
+
+if [ -z "${file_path}" ] ; then
+  echo "**ERROR** You must provide a file path as the second positional" \
+       "parameter." >&2
+  exit 1
+fi
+
+ip_addr_regex=`echo ${ip_addr} | sed 's/\(\.\)/\\\./g'`
+sed -i 's/'${ip_addr_regex}'/DUMMYIP/g'  ${file_path}