Skip to content

Commit

Permalink
use original approach for creating/deleting zone
Browse files Browse the repository at this point in the history
  • Loading branch information
jreidinger committed Nov 30, 2018
1 parent 93b9067 commit 64c2930
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
10 changes: 7 additions & 3 deletions library/network/src/lib/y2firewall/firewalld.rb
Original file line number Diff line number Diff line change
Expand Up @@ -176,16 +176,20 @@ def write_only
read unless read?
apply_zones_changes!
apply_attributes_changes!
# remove zones that is not in new zones map
(api.zones - zones.map(&:name)).each { |n| api.delete_zone(n) }
untouched!
true
end

# Apply the changes done in each of the modified zones. It will create or
# delete all the new or removed zones depending on each case.
def apply_zones_changes!
zones.select(&:modified?).each(&:apply_changes!)
zones.each do |zone|
api.create_zone(zone.name) unless current_zone_names.include?(zone.name)
zone.apply_changes! if zone.modified?
end
current_zone_names.each do |name|
api.delete_zone(name) if zones.none? { |z| z.name == name }
end
end

# Return a map with current firewalld settings.
Expand Down
5 changes: 0 additions & 5 deletions library/network/src/lib/y2firewall/firewalld/zone.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,6 @@ def full_name

# Apply all the changes in firewalld but do not reload it
def apply_changes!
# newly created zone
if !api.zones.include?(name)
log.info "adding new zone #{inspect}"
api.create_zone(name)
end
return true unless modified?

apply_relations_changes!
Expand Down

0 comments on commit 64c2930

Please sign in to comment.