Skip to content

Commit 5b60c3b

Browse files
author
Olivier BLIN
committed
Implement new interfaces selection for ifdown
* The 'no ifaces found matching' exception has been replaced by a quiet early return
1 parent 1f8dce7 commit 5b60c3b

File tree

1 file changed

+10
-27
lines changed

1 file changed

+10
-27
lines changed

ifupdown2/ifupdown/ifupdownmain.py

+10-27
Original file line numberDiff line numberDiff line change
@@ -1911,7 +1911,7 @@ def _get_filtered_ifacenames_with_classes(self, all_itf, allow_classes, excludep
19111911

19121912
return filtered_ifacenames
19131913

1914-
def down(self, ops, auto=False, allow_classes=None, ifacenames=None,
1914+
def down(self, ops, all_itf=False, allow_classes=None, ifacenames=None,
19151915
excludepats=None, printdependency=None, usecurrentconfig=False,
19161916
type=None):
19171917
""" down an interface """
@@ -1922,7 +1922,7 @@ def down(self, ops, auto=False, allow_classes=None, ifacenames=None,
19221922
ifupdownflags.flags.CLASS = True
19231923
if not self.flags.ADDONS_ENABLE:
19241924
self.flags.STATEMANAGER_UPDATE = False
1925-
if auto:
1925+
if all_itf:
19261926
ifupdownflags.flags.ALL = True
19271927
ifupdownflags.flags.WITH_DEPENDS = True
19281928
# For down we need to look at old state, unless usecurrentconfig
@@ -1943,33 +1943,16 @@ def down(self, ops, auto=False, allow_classes=None, ifacenames=None,
19431943
if excludepats:
19441944
excludepats = self._preprocess_excludepats(excludepats)
19451945

1946-
filtered_ifacenames = None
1947-
if ifacenames:
1948-
# If iface list is given by the caller, always check if iface
1949-
# is present
1950-
try:
1951-
ifacenames = self._preprocess_ifacenames(ifacenames)
1952-
1953-
if allow_classes:
1954-
filtered_ifacenames = self._get_filtered_ifacenames_with_classes(auto, allow_classes, excludepats, ifacenames)
1955-
1956-
except Exception as e:
1957-
raise Exception('%s' %str(e) +
1958-
' (interface was probably never up ?)')
1959-
1960-
1961-
# if iface list not given by user, assume all from config file
1962-
if not ifacenames: ifacenames = list(self.ifaceobjdict.keys())
1963-
1964-
if not filtered_ifacenames:
1965-
# filter interfaces based on auto and allow classes
1966-
filtered_ifacenames = [i for i in ifacenames
1967-
if self._iface_whitelisted(auto, allow_classes,
1968-
excludepats, i)]
1946+
try:
1947+
# Get a filtered list of interfaces to work on
1948+
filtered_ifacenames = self._get_filtered_ifacenames_with_classes(
1949+
all_itf, allow_classes, excludepats, ifacenames)
1950+
except Exception as e:
1951+
raise Exception('%s' %str(e) +
1952+
' (interface was probably never up ?)')
19691953

19701954
if not filtered_ifacenames:
1971-
raise Exception('no ifaces found matching given allow lists ' +
1972-
'(or interfaces were probably never up ?)')
1955+
return
19731956

19741957
if printdependency:
19751958
self.populate_dependency_info(ops, filtered_ifacenames)

0 commit comments

Comments
 (0)