Skip to content

Commit

Permalink
Implemented initialization of DHCP_IFACES combo
Browse files Browse the repository at this point in the history
  • Loading branch information
mchf committed Nov 22, 2016
1 parent f1e78aa commit b06bfb1
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/include/network/services/dns.rb
Expand Up @@ -474,8 +474,15 @@ def use_dhcp_hostname?
def InitDhcpIfaces(_key)
UI.ChangeWidget(Id("DHCP_IFACES"), :Enabled, use_dhcp_hostname?)

items = LanItems.find_dhcp_ifaces.map do |iface|
Item(Id(iface), iface, false)
hostname_ifaces = LanItems.find_set_hostname_ifaces

# translators: no device selected placeholder
none_label = "none"
items = [Item(Id(none_label), _(none_label), hostname_ifaces.empty?)]

items += LanItems.find_dhcp_ifaces.map do |iface|
selected = hostname_ifaces.first == iface
Item(Id(iface), iface, selected)
end

UI.ChangeWidget(Id("DHCP_IFACES"), :Items, items)
Expand Down
13 changes: 13 additions & 0 deletions src/modules/LanItems.rb
Expand Up @@ -930,6 +930,19 @@ def find_dhcp_ifaces
GetDeviceNames(items)
end

# Finds all devices which has DHCLIENT_SET_HOSTNAME set to "yes"
#
# @return [Array] list of NIC names which has the option set to "yes"
def find_set_hostname_ifaces
items = GetNetcardInterfaces().select do |iface|
ifcfg = GetDeviceMap(iface) || {}

ifcfg["DHCLIENT_SET_HOSTNAME"] == "yes"
end

GetDeviceNames(items)
end

# Get list of all configured interfaces
#
# return [Array] list of strings - interface names (eth0, ...)
Expand Down

0 comments on commit b06bfb1

Please sign in to comment.