Skip to content

Commit

Permalink
Refactored LanItems#conf_set_hostname
Browse files Browse the repository at this point in the history
  • Loading branch information
mchf committed Nov 23, 2016
1 parent f726f9a commit 0de35f7
Showing 1 changed file with 5 additions and 10 deletions.
15 changes: 5 additions & 10 deletions src/modules/LanItems.rb
Expand Up @@ -2461,22 +2461,17 @@ def createUdevFromIfaceName(interfaces)
# DHCLIENT_SET_HOSTNAME which is set in /etc/sysconfig/network/dhcp and is
# used as default, one can specify the option even per interface. To avoid
# collisions / undeterministic behavior the system should be configured so,
# that just one DHCP interface can update the hostname. E.g. all but one DHCP
# interfaces can have this obtion set to "no" and only one to "yes".
# that just one DHCP interface can update the hostname. E.g. global option
# can be set to "no" and just only one ifcfg can have the option set to "yes".
#
# @param [String] device name where should be hostname configuration active
# @return [Boolean] false when the configuration cannot be set for a device
def conf_set_hostname(device)
dhcp_devs = find_dhcp_ifaces
return false if !find_dhcp_ifaces.include?(device)

return false if !dhcp_devs.include?(device)
clear_set_hostname

ret = (dhcp_devs - [device]).all? do |dev|
item_id = find_configured(dev)
SetItemSysconfigOpt(item_id, "DHCLIENT_SET_HOSTNAME", "no")
end

ret &&= SetItemSysconfigOpt(find_configured(device), "DHCLIENT_SET_HOSTNAME", "yes")
ret = SetItemSysconfigOpt(find_configured(device), "DHCLIENT_SET_HOSTNAME", "yes")

SetModified()

Expand Down

0 comments on commit 0de35f7

Please sign in to comment.