Skip to content

Commit

Permalink
Merge pull request #4 from mchf/bnc887139-unconfigured-interfaces
Browse files Browse the repository at this point in the history
Allow ip aware interfaces for selection only
  • Loading branch information
mchf committed Aug 7, 2014
2 parents c40b9db + 0804e52 commit 7cb94d4
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 19 deletions.
7 changes: 7 additions & 0 deletions package/yast2-dhcp-server.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Thu Aug 7 08:36:22 UTC 2014 - mfilka@suse.com

- bnc#887139
- selected device has to have an ip assigned.
- 3.1.3

-------------------------------------------------------------------
Mon Mar 31 13:24:17 CEST 2014 - locilka@suse.com

Expand Down
2 changes: 1 addition & 1 deletion package/yast2-dhcp-server.spec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@


Name: yast2-dhcp-server
Version: 3.1.2
Version: 3.1.3
Release: 0

BuildRoot: %{_tmppath}/%{name}-%{version}-build
Expand Down
35 changes: 17 additions & 18 deletions src/include/dhcp-server/dialogs2.rb
Original file line number Diff line number Diff line change
Expand Up @@ -588,38 +588,37 @@ def CardSelectionStore(key, event)
nil
end

# Checks if selected devices are suitable to run dhcp server
#
# A device is valid when:
# - it has an IP already assigned
# - it has statically configured IP
def CardSelectionValidate(key, event)
event = deep_copy(event)
return true if Ops.get(event, "ID") == :abort
return true if event["ID"] == :abort
return false if !@ifaces

allowed_interfaces = []
configured_interfaces = []
Builtins.foreach(@ifaces) do |iface, settings|
if Ops.get_boolean(@ifaces, [iface, "active"], false) == true
allowed_interfaces = Builtins.add(allowed_interfaces, iface)
if DhcpServer.GetInterfaceInformation(iface) != {}
configured_interfaces = Builtins.add(configured_interfaces, iface)
end
raise Break
end
allowed_interfaces = @ifaces.select { |i, s| s && s["active"] }
unconfigured_interface = allowed_interfaces.any? do |iface, settings|
DhcpServer.GetInterfaceInformation(iface).empty?
end
if Ops.less_or_equal(Builtins.size(allowed_interfaces), 0)

if allowed_interfaces.empty?
# TRANSLATORS: popup error, DHCP Server needs to run on one or more interfaces,
# currently no one is selected
Report.Error(_("At least one network interface must be selected."))
return false
end

if Ops.less_or_equal(Builtins.size(configured_interfaces), 0)
if unconfigured_interface
# TRANSLATORS: popup error, DHCP Server requires selected interface to have
# at least minimal configuration
return Popup.ContinueCancel(
Report.Error(
_(
"The selected network interface is not configured (no assigned IP address \n" +
"and netmask). Using it in the DHCP server configuration may not work.\n" +
"Really use this interface?\n"
"One or more selected network interfaces is not configured (no assigned IP address \n" +
"and netmask)."
)
)
return false
end
true
end
Expand Down

0 comments on commit 7cb94d4

Please sign in to comment.