firewall: Get service ports details

Add interface to get port types and numbers for a service.

Signed-off-by: James Valleroy <jvalleroy@mailbox.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
James Valleroy authored and Sunil Mohan Adapa committed 2019-04-28 20:59:15 -07:00
1 parent 51fc87f1bc
commit e5081018a3
2 files changed
+23 -2

No files matched your search

+16 -2
View File
@@ -46,6 +46,12 @@ def parse_arguments():
'--zone', help='Zone from which the list is to be retrieved',
required=True)
# Get service ports
get_service_ports = subparsers.add_parser(
'get-service-ports', help='Get list of ports for service')
get_service_ports.add_argument('--service', help='Name of service',
required=True)
# Get interface status
get_interfaces = subparsers.add_parser(
'get-interfaces', help='Get list of interfaces in a zone')
@@ -105,8 +111,8 @@ def _flush_iptables_rules():
def set_firewall_backend(backend):
"""Set FirewallBackend attribute to the specified string."""
conf_file = '/etc/firewalld/firewalld.conf'
aug = augeas.Augeas(flags=augeas.Augeas.NO_LOAD +
augeas.Augeas.NO_MODL_AUTOLOAD)
aug = augeas.Augeas(
flags=augeas.Augeas.NO_LOAD + augeas.Augeas.NO_MODL_AUTOLOAD)
# lens for shell-script config file
aug.set('/augeas/load/Shellvars/lens', 'Shellvars.lns')
@@ -150,6 +156,14 @@ def subcommand_get_enabled_services(arguments):
['firewall-cmd', '--zone', arguments.zone, '--list-services'])
def subcommand_get_service_ports(arguments):
"""Print list of ports for service"""
subprocess.call([
'firewall-cmd', '--permanent', '--service', arguments.service,
'--get-ports'
])
def subcommand_get_interfaces(arguments):
"""Print the list of interfaces in a zone."""
subprocess.call(