Skip to content

Commit 1e4e089

Browse files
author
Olivier BLIN
committed
Add support to call ifupdown on all interfaces
For ifupdown compatibility, '--all' implies '--allow auto'. '--allow-all' parameter offers a way to have all interfaces without implicit filter. On ifquery, --all is implicit when no interfaces are provided. So 'ifquery --allow-all' shows information on all interfaces.
1 parent bff9eab commit 1e4e089

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

ifupdown2/ifupdown/argv.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -142,14 +142,21 @@ def __call__(self, _parser, namespace, values, option_string=None):
142142
help='interface list separated by spaces. ')
143143
argparser.add_argument('-a', '--all', action='store_true',
144144
help='process all interfaces (limited by --allow= filter)')
145-
argparser.add_argument('--allow', dest='CLASS', action='append',
145+
allow_group = argparser.add_mutually_exclusive_group(required=False)
146+
allow_group.add_argument('--allow', dest='CLASS', action='append',
146147
help='ignore non-"allow-CLASS" interfaces (default is [auto] when -a/--all else [])')
148+
# For ifupdown compatibility, '--all' implies '--allow auto'. '--allow-all' parameter offers
149+
# a way to have all interfaces without implicit filter.
150+
allow_group.add_argument('--allow-all', action='store_true',
151+
help='ensure non-"allow-CLASS" is set to []')
147152

148153
def argparser_interfaces_selection_post_validate(self):
149154
""" Set and validate interfaces selection options """
150155

151-
# Default filter scope is auto/allow-auto when -a/--all option is set
152-
if self.args.all and not self.args.CLASS:
156+
if self.args.allow_all:
157+
self.args.CLASS = []
158+
elif self.args.all and not self.args.CLASS:
159+
# Default filter scope is auto/allow-auto when -a/--all option is set
153160
self.args.CLASS = ['auto']
154161

155162
if self.args.iflist and self.args.all:

0 commit comments

Comments
 (0)