Module: Y2Firewall::Helpers::Interfaces

Included in:
Yast::CWMFirewallInterfacesClass
Defined in:
library/network/src/lib/y2firewall/helpers/interfaces.rb

Overview

Set of helpers methods for operating with NetworkInterfaces and firewalld zones.

Instance Method Summary collapse

Instance Method Details

#default_interfacesArray<String>

Return the name of interfaces which belongs to the default zone

Returns:

  • (Array<String>)

    default zone interface names


45
46
47
# File 'library/network/src/lib/y2firewall/helpers/interfaces.rb', line 45

def default_interfaces
  known_interfaces.reject(&:zone).map(&:name)
end

#default_zoneY2Firewall::Firewalld::Zone

Convenience method to return the default zone object

Returns:


61
62
63
# File 'library/network/src/lib/y2firewall/helpers/interfaces.rb', line 61

def default_zone
  @default_zone ||= firewalld.find_zone(firewalld.default_zone)
end

#firewalldY2Firewall::Firewalld

Return an instance of Y2Firewall::Firewalld

Returns:


38
39
40
# File 'library/network/src/lib/y2firewall/helpers/interfaces.rb', line 38

def firewalld
  Y2Firewall::Firewalld.instance
end

#interface_zone(name) ⇒ String?

Return the zone name for a given interface from the firewalld instance instead of from the API.

Parameters:

  • name (String)

    interface name

Returns:

  • (String, nil)

    zone name whether belongs to some or nil if not


54
55
56
# File 'library/network/src/lib/y2firewall/helpers/interfaces.rb', line 54

def interface_zone(name)
  Y2Firewall::Firewalld::Interface.new(name).zone
end

#known_interfacesArray<Y2Firewall::Firewalld::Interface>

Return an array with all the known (sysconfig configured) firewalld interfaces.

Returns:


69
70
71
72
73
# File 'library/network/src/lib/y2firewall/helpers/interfaces.rb', line 69

def known_interfaces
  return @known_interfaces if @known_interfaces

  @known_interfaces = Y2Firewall::Firewalld::Interface.known
end

#unknown_interfacesArray<Y2Firewall::Firewalld::Interface>

Return an array with all the interfaces configured in some firewalld zone but not configured in sysconfig.

Returns:


79
80
81
# File 'library/network/src/lib/y2firewall/helpers/interfaces.rb', line 79

def unknown_interfaces
  Y2Firewall::Firewalld::Interface.unknown
end