overall better handling and usage of exceptions
All checks were successful
bundlewrap/pipeline/head This commit looks good
All checks were successful
bundlewrap/pipeline/head This commit looks good
This commit is contained in:
parent
5d5930265a
commit
f8bbe00d47
21 changed files with 57 additions and 28 deletions
|
@ -1,3 +1,5 @@
|
|||
from bundlewrap.exceptions import BundleError
|
||||
|
||||
@metadata_reactor.provides(
|
||||
'iptables/bundle_rules/iptables',
|
||||
)
|
||||
|
@ -14,14 +16,14 @@ def port_rules_to_iptables(metadata):
|
|||
port, proto = portdef.split('/', 2)
|
||||
|
||||
if proto not in {'udp'}:
|
||||
raise Exception(f'iptables/port_rules: illegal identifier {portdef} in metadata for {node.name}')
|
||||
raise BundleError(f'iptables/port_rules: illegal identifier {portdef} in metadata for {node.name}')
|
||||
else:
|
||||
port = portdef
|
||||
proto = 'tcp'
|
||||
|
||||
for target in targets:
|
||||
if port == '*' and target == '*':
|
||||
raise Exception('iptables/port_rules: setting both port and target to * is unsupported')
|
||||
raise BundleError('iptables/port_rules: setting both port and target to * is unsupported')
|
||||
|
||||
comment = f'-m comment --comment "iptables port_rules {target}"'
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue