Class: Y2Firewall::Firewalld::ZoneReader

Inherits:
Object
  • Object
show all
Includes:
Yast::Logger
Defined in:
library/network/src/lib/y2firewall/firewalld/zone_reader.rb

Overview

Class to help parsing firewall-cmd --list-all-zones output

Constant Summary collapse

BOOLEAN_ATTRIBUTES =
["icmp-block-inversion", "masquerade"].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(zone_names, zones_definition) ⇒ ZoneReader

Constructor

Parameters:

  • zone_names (Array<String>)

    zone names

  • zones_definition (String)

    text with the complete definition of existing zones.


46
47
48
49
50
# File 'library/network/src/lib/y2firewall/firewalld/zone_reader.rb', line 46

def initialize(zone_names, zones_definition)
  @zone_names = zone_names
  @zones_definition = zones_definition
  @zone_entries = {}
end

Instance Attribute Details

#zone_entriesHash<String,Hash>

Returns stores the parsed configuration for eac zone indexed by its name.

Returns:

  • (Hash<String,Hash>)

    stores the parsed configuration for eac zone indexed by its name


34
35
36
# File 'library/network/src/lib/y2firewall/firewalld/zone_reader.rb', line 34

def zone_entries
  @zone_entries
end

#zone_namesArray<String] configured zone names

Returns Array<String] configured zone names.

Returns:

  • (Array<String] configured zone names)

    Array<String] configured zone names


31
32
33
# File 'library/network/src/lib/y2firewall/firewalld/zone_reader.rb', line 31

def zone_names
  @zone_names
end

#zones_definitionString

Returns zones definition to be parsed for initializing the zone objects.

Returns:

  • (String)

    zones definition to be parsed for initializing the zone objects


37
38
39
# File 'library/network/src/lib/y2firewall/firewalld/zone_reader.rb', line 37

def zones_definition
  @zones_definition
end

Instance Method Details

#readArray<Y2Firewall::Firewalld::Zone>

It reads the zone definition instantiating the defined zones and settings their attributes.

Returns:


56
57
58
59
60
61
# File 'library/network/src/lib/y2firewall/firewalld/zone_reader.rb', line 56

def read
  return [] if !@zone_names || @zone_names.empty?

  parse_zones
  initialize_zones
end