Module: Y2Firewall::Firewalld::Api::Zones

Included in:
Y2Firewall::Firewalld::Api
Defined in:
library/network/src/lib/y2firewall/firewalld/api/zones.rb

Overview

This module contains specific api methods for handling zones configuration.

Instance Method Summary collapse

Instance Method Details

#add_interface(zone, interface, permanent: permanent?) ) ⇒ Boolean

command to be executed



113
114
115
# File 'library/network/src/lib/y2firewall/firewalld/api/zones.rb', line 113

def add_interface(zone, interface, permanent: permanent?)
  run_command("--zone=#{zone}", "--add-interface=#{interface}", permanent: permanent)
end

#add_masquerade(zone) ⇒ Boolean



249
250
251
252
253
# File 'library/network/src/lib/y2firewall/firewalld/api/zones.rb', line 249

def add_masquerade(zone)
  return true if masquerade_enabled?(zone)

  run_command("--zone=#{zone}", "--add-masquerade")
end

#add_port(zone, port, permanent: permanent?) ) ⇒ Boolean

command to be executed



197
198
199
# File 'library/network/src/lib/y2firewall/firewalld/api/zones.rb', line 197

def add_port(zone, port, permanent: permanent?)
  run_command("--zone=#{zone}", "--add-port=#{port}", permanent: permanent)
end

#add_protocol(zone, protocol, permanent: permanent?) ) ⇒ Boolean

command to be executed



206
207
208
# File 'library/network/src/lib/y2firewall/firewalld/api/zones.rb', line 206

def add_protocol(zone, protocol, permanent: permanent?)
  run_command("--zone=#{zone}", "--add-protocol=#{protocol}", permanent: permanent)
end

#add_service(zone, service, permanent: permanent?) ) ⇒ Boolean

command to be executed



188
189
190
# File 'library/network/src/lib/y2firewall/firewalld/api/zones.rb', line 188

def add_service(zone, service, permanent: permanent?)
  run_command("--zone=#{zone}", "--add-service=#{service}", permanent: permanent)
end

#add_source(zone, source, permanent: permanent?) ) ⇒ Boolean

command to be executed



140
141
142
# File 'library/network/src/lib/y2firewall/firewalld/api/zones.rb', line 140

def add_source(zone, source, permanent: permanent?)
  run_command("--zone=#{zone}", "--add-source=#{source}", permanent: permanent)
end

#change_interface(zone, interface, permanent: permanent?) ) ⇒ Boolean

command to be executed



131
132
133
# File 'library/network/src/lib/y2firewall/firewalld/api/zones.rb', line 131

def change_interface(zone, interface, permanent: permanent?)
  run_command("--zone=#{zone}", "--change-interface=#{interface}", permanent: permanent)
end

#change_source(zone, source, permanent: permanent?) ) ⇒ Boolean

command to be executed



158
159
160
# File 'library/network/src/lib/y2firewall/firewalld/api/zones.rb', line 158

def change_source(zone, source, permanent: permanent?)
  run_command("--zone=#{zone}", "--change-source=#{source}", permanent: permanent)
end

#interface_enabled?(zone, interface, permanent: permanent?) ) ⇒ Boolean

command to be executed



104
105
106
# File 'library/network/src/lib/y2firewall/firewalld/api/zones.rb', line 104

def interface_enabled?(zone, interface, permanent: permanent?)
  query_command("--zone=#{zone} --query-interface=#{interface}", permanent: permanent)
end

#interface_zone(interface, permanent: permanent?) ) ⇒ String?

Return the name of the zone the interface belongs to or nil.

command to be executed



95
96
97
# File 'library/network/src/lib/y2firewall/firewalld/api/zones.rb', line 95

def interface_zone(interface, permanent: permanent?)
  string_command("--get-zone-of-interface=#{interface}", permanent: permanent)
end

#list_all(zone, permanent: permanent?) ) ⇒ Array<String>

command to be executed



76
77
78
# File 'library/network/src/lib/y2firewall/firewalld/api/zones.rb', line 76

def list_all(zone, permanent: permanent?)
  string_command("--zone=#{zone}", "--list-all", permanent: permanent).split(" ")
end

#list_all_zones(permanent: permanent?) ) ⇒ Array<String>

command to be executed



83
84
85
# File 'library/network/src/lib/y2firewall/firewalld/api/zones.rb', line 83

def list_all_zones(permanent: permanent?)
  string_command("--list-all-zones", permanent: permanent).split("\n")
end

#list_interfaces(zone, permanent: permanent?) ) ⇒ Array<String>

command to be executed



40
41
42
# File 'library/network/src/lib/y2firewall/firewalld/api/zones.rb', line 40

def list_interfaces(zone, permanent: permanent?)
  string_command("--zone=#{zone}", "--list-interfaces", permanent: permanent).split(" ")
end

#list_ports(zone, permanent: permanent?) ) ⇒ Array<String>



54
55
56
# File 'library/network/src/lib/y2firewall/firewalld/api/zones.rb', line 54

def list_ports(zone, permanent: permanent?)
  string_command("--zone=#{zone}", "--list-ports", permanent: permanent).split(" ")
end

#list_protocols(zone, permanent: permanent?) ) ⇒ Array<String>



60
61
62
# File 'library/network/src/lib/y2firewall/firewalld/api/zones.rb', line 60

def list_protocols(zone, permanent: permanent?)
  string_command("--zone=#{zone}", "--list-protocols", permanent: permanent).split(" ")
end

#list_services(zone, permanent: permanent?) ) ⇒ Arrray<String>

command to be executed



48
49
50
# File 'library/network/src/lib/y2firewall/firewalld/api/zones.rb', line 48

def list_services(zone, permanent: permanent?)
  string_command("--zone=#{zone}", "--list-services", permanent: permanent).split(" ")
end

#list_sources(zone, permanent: permanent?) ) ⇒ Array<String>

command to be executed



68
69
70
# File 'library/network/src/lib/y2firewall/firewalld/api/zones.rb', line 68

def list_sources(zone, permanent: permanent?)
  string_command("--zone=#{zone}", "--list-sources", permanent: permanent).split(" ")
end

#masquerade_enabled?(zone) ⇒ Boolean



243
244
245
# File 'library/network/src/lib/y2firewall/firewalld/api/zones.rb', line 243

def masquerade_enabled?(zone)
  query_command("--zone=#{zone}", "--query-masquerade")
end

#port_enabled?(zone, port) ⇒ Boolean



172
173
174
# File 'library/network/src/lib/y2firewall/firewalld/api/zones.rb', line 172

def port_enabled?(zone, port)
  query_command("--zone=#{zone}", "--query-port=#{port}")
end

#protocol_enabled?(zone, protocol) ⇒ Boolean



179
180
181
# File 'library/network/src/lib/y2firewall/firewalld/api/zones.rb', line 179

def protocol_enabled?(zone, protocol)
  query_command("--zone=#{zone}", "--query-protocol=#{protocol}")
end

#remove_interface(zone, interface, permanent: permanent?) ) ⇒ Boolean

command to be executed



122
123
124
# File 'library/network/src/lib/y2firewall/firewalld/api/zones.rb', line 122

def remove_interface(zone, interface, permanent: permanent?)
  run_command("--zone=#{zone}", "--remove-interface=#{interface}", permanent: permanent)
end

#remove_masquerade(zone) ⇒ Boolean



257
258
259
260
261
# File 'library/network/src/lib/y2firewall/firewalld/api/zones.rb', line 257

def remove_masquerade(zone)
  return true if !masquerade_enabled?(zone)

  run_command("--zone=#{zone}", "--remove-masquerade")
end

#remove_port(zone, port, permanent: permanent?) ) ⇒ Boolean

command to be executed



228
229
230
# File 'library/network/src/lib/y2firewall/firewalld/api/zones.rb', line 228

def remove_port(zone, port, permanent: permanent?)
  run_command("--zone=#{zone}", "--remove-port=#{port}", permanent: permanent)
end

#remove_protocol(zone, protocol, permanent: permanent?) ) ⇒ Boolean

command to be executed



237
238
239
# File 'library/network/src/lib/y2firewall/firewalld/api/zones.rb', line 237

def remove_protocol(zone, protocol, permanent: permanent?)
  run_command("--zone=#{zone}", "--remove-protocol=#{protocol}", permanent: permanent)
end

#remove_service(zone, service, permanent: permanent?) ) ⇒ Boolean

command to be executed



215
216
217
218
219
220
221
# File 'library/network/src/lib/y2firewall/firewalld/api/zones.rb', line 215

def remove_service(zone, service, permanent: permanent?)
  if offline?
    run_command("--zone=#{zone}", "--remove-service-from-zone=#{service}")
  else
    run_command("--zone=#{zone}", "--remove-service=#{service}", permanent: permanent)
  end
end

#remove_source(zone, source, permanent: permanent?) ) ⇒ Boolean

command to be executed



149
150
151
# File 'library/network/src/lib/y2firewall/firewalld/api/zones.rb', line 149

def remove_source(zone, source, permanent: permanent?)
  run_command("--zone=#{zone}", "--remove-source=#{source}", permanent: permanent)
end

#service_enabled?(zone, service) ⇒ Boolean



165
166
167
# File 'library/network/src/lib/y2firewall/firewalld/api/zones.rb', line 165

def service_enabled?(zone, service)
  query_command("--zone=#{zone}", "--query-service=#{service}")
end

#zonesArray<String>



32
33
34
# File 'library/network/src/lib/y2firewall/firewalld/api/zones.rb', line 32

def zones
  string_command("--get-zones").split(" ")
end