Module: Y2Firewall::Firewalld::Api::Services
- Included in:
- Y2Firewall::Firewalld::Api
- Defined in:
- library/network/src/lib/y2firewall/firewalld/api/services.rb
Overview
This module contains specific API methods for handling services definition and configuration.
Instance Method Summary collapse
-
#add_service_port(service, port, permanent: permanent?) ) ⇒ Boolean
True if port was removed from service.
-
#create_service(service) ⇒ Boolean
Creates a new service definition for the given service name.
-
#delete_service(service) ⇒ Boolean
Remove the service definition for the given service name.
-
#info_service(service, permanent: permanent?) ) ⇒ Array<String>
Show all the service declaration (name, description, ports, protocols and modules).
-
#modify_service_description(service, long_description) ⇒ Object
Modify the long description of the service.
-
#modify_service_short(service, short_description) ⇒ Object
Modify the full name or short description of the service.
-
#remove_service_port(service, port, permanent: permanent?) ) ⇒ Boolean
True if port was removed from service.
-
#service_description(service, permanent: permanent?) ) ⇒ String
Description for service.
-
#service_modules(service, permanent: permanent?) ) ⇒ Array<String>
The firewall service modules.
-
#service_ports(service, permanent: permanent?) ) ⇒ Array<String>
Return the list of ports allowed by the given service.
-
#service_protocols(service, permanent: permanent?) ) ⇒ Array<String>
The firewall service protocols.
-
#service_short(service, permanent: permanent?) ) ⇒ String
Full name or short description of the service.
-
#service_supported?(service) ⇒ Boolean
Returns whether the service definition for the service name given is present or not.
-
#services ⇒ Array<String>
Return the list of availale firewalld services.
Instance Method Details
#add_service_port(service, port, permanent: permanent?) ) ⇒ Boolean
Returns True if port was removed from service.
150 151 152 |
# File 'library/network/src/lib/y2firewall/firewalld/api/services.rb', line 150 def add_service_port(service, port, permanent: permanent?) modify_command("--service=#{service}", "--add-port=#{port}", permanent: permanent) end |
#create_service(service) ⇒ Boolean
Creates a new service definition for the given service name
34 35 36 |
# File 'library/network/src/lib/y2firewall/firewalld/api/services.rb', line 34 def create_service(service) modify_command("--new-service=#{service}", permanent: !offline?) end |
#delete_service(service) ⇒ Boolean
Remove the service definition for the given service name
42 43 44 |
# File 'library/network/src/lib/y2firewall/firewalld/api/services.rb', line 42 def delete_service(service) modify_command("--delete-service=#{service}", permanent: !offline?) end |
#info_service(service, permanent: permanent?) ) ⇒ Array<String>
Show all the service declaration (name, description, ports, protocols and modules)
60 61 62 |
# File 'library/network/src/lib/y2firewall/firewalld/api/services.rb', line 60 def info_service(service, permanent: permanent?) string_command("--info-service=#{service}", "--verbose", permanent: permanent).split("\n") end |
#modify_service_description(service, long_description) ⇒ Object
Modify the long description of the service
96 97 98 99 |
# File 'library/network/src/lib/y2firewall/firewalld/api/services.rb', line 96 def modify_service_description(service, long_description) modify_command("--service=#{service}", "--set-description=#{long_description}", permanent: !offline?) end |
#modify_service_short(service, short_description) ⇒ Object
Modify the full name or short description of the service
79 80 81 82 |
# File 'library/network/src/lib/y2firewall/firewalld/api/services.rb', line 79 def modify_service_short(service, short_description) modify_command("--service=#{service}", "--set-short=#{short_description}", permanent: !offline?) end |
#remove_service_port(service, port, permanent: permanent?) ) ⇒ Boolean
Returns True if port was removed from service.
141 142 143 |
# File 'library/network/src/lib/y2firewall/firewalld/api/services.rb', line 141 def remove_service_port(service, port, permanent: permanent?) modify_command("--service=#{service}", "--remove-port=#{port}", permanent: permanent) end |
#service_description(service, permanent: permanent?) ) ⇒ String
Returns Description for service.
88 89 90 |
# File 'library/network/src/lib/y2firewall/firewalld/api/services.rb', line 88 def service_description(service, permanent: permanent?) string_command("--service=#{service}", "--get-description", permanent: permanent) end |
#service_modules(service, permanent: permanent?) ) ⇒ Array<String>
Returns The firewall service modules.
132 133 134 |
# File 'library/network/src/lib/y2firewall/firewalld/api/services.rb', line 132 def service_modules(service, permanent: permanent?) string_command("--service=#{service}", "--get-modules", permanent: permanent).split end |
#service_ports(service, permanent: permanent?) ) ⇒ Array<String>
Return the list of ports allowed by the given service
116 117 118 |
# File 'library/network/src/lib/y2firewall/firewalld/api/services.rb', line 116 def service_ports(service, permanent: permanent?) string_command("--service=#{service}", "--get-ports", permanent: permanent).split end |
#service_protocols(service, permanent: permanent?) ) ⇒ Array<String>
Returns The firewall service protocols.
124 125 126 |
# File 'library/network/src/lib/y2firewall/firewalld/api/services.rb', line 124 def service_protocols(service, permanent: permanent?) string_command("--service=#{service}", "--get-protocols", permanent: permanent).split end |
#service_short(service, permanent: permanent?) ) ⇒ String
Full name or short description of the service
70 71 72 73 |
# File 'library/network/src/lib/y2firewall/firewalld/api/services.rb', line 70 def service_short(service, permanent: permanent?) # these may not exist on early firewalld releases string_command("--service=#{service}", "--get-short", permanent: permanent) end |
#service_supported?(service) ⇒ Boolean
Returns whether the service definition for the service name given is present or not.
106 107 108 |
# File 'library/network/src/lib/y2firewall/firewalld/api/services.rb', line 106 def service_supported?(service) services.include?(service) end |
#services ⇒ Array<String>
Return the list of availale firewalld services
49 50 51 |
# File 'library/network/src/lib/y2firewall/firewalld/api/services.rb', line 49 def services string_command("--get-services").split end |