On 03/11/15 at 02:03pm, Dave Young wrote:
On 03/10/15 at 06:48pm, Minfei Huang wrote:
The ipv6 address has the special character colon ":", so we can use the new function to pick it out. We can use the new function to parse the passed parameter. The passed parameter is hostname/domain, if it is satisfied with the condition that it is without colon ":", and contanis the [a-zA-Z].
Add a new function to simplify to get the ip address, if the specified address is a domain/hostname in /etc/kdump.conf. The function will parse the passed parameter, and use the "getent ahost" to get the ip address, if passed parameter is domain/hostname.
Signed-off-by: Minfei Huang mhuang@redhat.com
dracut-module-setup.sh | 1 + kdump-lib.sh | 62 +++++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 52 insertions(+), 11 deletions(-)
diff --git a/dracut-module-setup.sh b/dracut-module-setup.sh index 349c3c1..564f3e3 100755 --- a/dracut-module-setup.sh +++ b/dracut-module-setup.sh @@ -625,6 +625,7 @@ install() { inst "/bin/dd" "/bin/dd" inst "/bin/tail" "/bin/tail" inst "/bin/date" "/bin/date"
- inst "/bin/getent" "/bin/getent" inst "/bin/sync" "/bin/sync" inst "/bin/cut" "/bin/cut" inst "/sbin/makedumpfile" "/sbin/makedumpfile"
diff --git a/kdump-lib.sh b/kdump-lib.sh index b886c5d..62c7d1c 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -170,21 +170,61 @@ get_remote_host() echo $_config_val }
-# check the remote server ip address tpye -is_ipv6_target() +# wrap a function, so that we can use this function to get the ip address, +# if pass a parameter
How about: # Convert hostname to ip address, echo the original value if $1 is already an # ip address. # $1: hostname or ip address
will change.
+get_ip_address() {
- local _server _server_tmp
- local _ip_address
- _ip_address=`getent ahosts $1 | head -n 1 | cut -d' ' -f1`
- _ip_address=${_ip_address:-$1}
- echo $_ip_address
+}
+# the ipv6 address has the special character colon ":", so we can pick it out. +# we can pass a ip address, if ipv6 address, will return ipv6 address, +# otherwise return NULL
It does not return anything, it just echo $_server, btw since the function is simple and straitforward, the description is not necessary.
Since the input is possible hostname, how about change the function name to is_ipv6_host()
will change.
+is_ipv6_address() +{
- local _server=$(get_ip_address $1)
_addr is better than _server..
- echo $_server | grep -q ":"
+}
+get_netdev_target()
get_net_target or get_network_target is better..
+{
local _target
if is_ssh_dump_target; then
_server=`get_option_value ssh`
elif is_nfs_dump_target; then_target=`get_option_value ssh`
_server=`get_option_value nfs`
fi_target=`get_option_value nfs`
- [ -z "$_server" ] && return 1
- _server=`get_remote_host $_server`
- _server_tmp=$_server
- _server=`getent ahosts $_server | head -n 1 | cut -d' ' -f1`
- _server=${_server:-$_server_tmp}
- echo $_server | grep -q ":"
- [ -z "$_target" ] && return
- _target=`get_remote_host $_target`
- echo $_target
+}
+# check the remote server ip address tpye +is_ipv6_target() +{
- local _target=$(get_netdev_target)
- [ -z "$_target" ] && return 1
- echo $(is_ipv6_address $_target)
+}
+# if the passed parameter is hostname/domain, it will be satisfied with +# condition which it is without colon ":", and contains the [a-zA-Z]
What is the purpose of this function? What is the input? $1 = a hostname? or an ip address? or ssh/nfs option value in kdump.conf?
The input is a hostname. We use it to verify the input is hostname or not.
Is it used in later patches?
Yes, the later patch will use it. I will move it to the later patch.
Thanks Minfei
+is_hostname() +{
- local _hostname=`echo $1 | grep ":"`
+# ipv6 address
- if [ -n "$_hostname" ]; then
return 1
- else
echo $1 | grep -q "[a-zA-Z]"
- fi
}
1.9.3
kexec mailing list kexec@lists.fedoraproject.org https://lists.fedoraproject.org/mailman/listinfo/kexec