module HttpdConfigmapGenerator::Base::Network
Constants
- HOSTNAME_COMMAND
Public Instance Methods
domain()
click to toggle source
# File lib/httpd_configmap_generator/base/network.rb, line 10 def domain domain_from_host(opts[:host]) end
domain_from_host(host)
click to toggle source
# File lib/httpd_configmap_generator/base/network.rb, line 14 def domain_from_host(host) host.gsub(/^([^.]+\.)/, '') if host.present? && host.include?('.') end
fetch_network_file(source_file, target_file)
click to toggle source
# File lib/httpd_configmap_generator/base/network.rb, line 27 def fetch_network_file(source_file, target_file) require "net/http" delete_target_file(target_file) create_target_directory(target_file) info_msg("Downloading #{source_file} ...") result = Net::HTTP.get_response(URI(source_file)) raise "Failed to fetch URL file source #{source_file}" unless result.kind_of?(Net::HTTPSuccess) File.write(target_file, result.body) end
host_reachable?(host)
click to toggle source
# File lib/httpd_configmap_generator/base/network.rb, line 18 def host_reachable?(host) require "net/ping" Net::Ping::External.new(host).ping end
realm()
click to toggle source
# File lib/httpd_configmap_generator/base/network.rb, line 6 def realm domain.upcase end
update_hostname(host)
click to toggle source
# File lib/httpd_configmap_generator/base/network.rb, line 23 def update_hostname(host) command_run!(HOSTNAME_COMMAND, :params => [host]) if command_run(HOSTNAME_COMMAND).output.strip != host end