diff --git a/lib/manageiq/appliance_console/message_configuration.rb b/lib/manageiq/appliance_console/message_configuration.rb index e7e0671c..3d8796ad 100644 --- a/lib/manageiq/appliance_console/message_configuration.rb +++ b/lib/manageiq/appliance_console/message_configuration.rb @@ -67,6 +67,10 @@ def ask_questions show_parameters return false unless agree("\nProceed? (Y/N): ") + if is_hostname?(message_server_host) + return false unless hostname_fqdn?(message_server_host) + end + return false unless host_reachable?(message_server_host, "Message Server Host:") true @@ -177,6 +181,22 @@ def file_contains?(path, content) true end + def is_hostname?(host) + require "resolv" + + return !(host =~ IP_REGEXP) + end + + def hostname_fqdn?(host) + require "socket" + + fqdn = Addrinfo.getaddrinfo(Socket.gethostname, nil).first.getnameinfo.first + unless host == fqdn + return false + end + true + end + def host_reachable?(host, what) require 'net/ping' say("Checking connectivity to #{host} ... ")