# reduce security issues (due to the pre- and post- commands)
disable_cli_interfacesfile=0
-# Support /etc/network/if-*/ scripts
+
+# enable addon module syntax check:
+# Python addon modules register dictionary of supported attributes.
+# The syntax checker in ifupdown2 uses this dictionary for syntax
+# checks in the interfaces file. This works well, when only python modules
+# are used. But when a mix of scripts and modules are used (which is the
+# default case), you may get false warnings for attributes supported
+# by scripts
+addon_syntax_check=1
+
+# Support executing of ifupdown style scripts.
+# Note that by default python addon modules override scripts with the same
+# name
addon_scripts_support=0
+# enable python addons
+addon_python_modules_support=1
+
# By default ifupdown2 only supports a single vlan filtering bridge
# on the system. Set this flag to 1 to support multiple vlan
# filtering bridges
return None
return None
- @property
def get_env(self):
""" get shell environment variables the interface must execute in """
if not self.env:
config = self.config
env['IFACE'] = self.name
for attr, attr_value in config.items():
- attr_env_name = 'IF_%s' %attr.upper()
+ attr_env_name = 'IF_%s' %attr.upper().replace("-", "_")
env[attr_env_name] = attr_value[0]
- if env:
- self.env = env
+ self.env = env
def update_config(self, attr_name, attr_value):
""" add attribute name and value to the interface config """
self.pp = pprint.PrettyPrinter(indent=4)
self.modules = OrderedDict({})
self.module_attrs = {}
-
- self.load_addon_modules(self.addon_modules_dir)
- if self.flags.COMPAT_EXEC_SCRIPTS:
+
+ if self.config.get('addon_python_modules_support', '1') == '1':
+ self.load_addon_modules(self.addon_modules_dir)
+ if self.config.get('addon_scripts_support', '0') == '1':
self.load_scripts(self.scripts_dir)
self.dependency_graph = OrderedDict({})
nifaces.subscribe('iface_found', self._save_iface_squash)
else:
nifaces.subscribe('iface_found', self._save_iface)
- nifaces.subscribe('validateifaceattr',
- self._iface_configattr_syntax_checker)
- nifaces.subscribe('validateifaceobj', self._ifaceobj_syntax_checker)
+ if self.config.get('addon_syntax_check', '1') == '1':
+ nifaces.subscribe('validateifaceattr',
+ self._iface_configattr_syntax_checker)
+ nifaces.subscribe('validateifaceobj', self._ifaceobj_syntax_checker)
nifaces.load()
if nifaces.errors or nifaces.warns:
ret = False
def _compat_conv_op_to_mode(self, op):
""" Returns old op name to work with existing scripts """
- if op == 'pre-up':
+ if 'up' in op:
return 'start'
- elif op == 'pre-down':
+ elif 'down' in op:
return 'stop'
else:
return op
"""
cenv = None
- iface_env = ifaceobj.env
+ iface_env = ifaceobj.get_env()
if iface_env:
cenv = os.environ
if cenv:
cenv.update(iface_env)
else:
cenv = iface_env
- cenv['MODE'] = self._compat_conv_op_to_mode(op)
+ else:
+ cenv = {}
+ cenv['MODE'] = self._compat_conv_op_to_mode(op)
+ cenv['PHASE'] = op
+
return cenv
def _save_state(self):