[pve-devel] [PATCH ifupdown2 1/2] patch: execute addons scripts before modules
Alexandre Derumier
aderumier at odiso.com
Mon Feb 3 06:30:28 CET 2020
ifupdown2.0 now setup address in pre-up, but ovs script also
create in pre-up, but after address module.
This patch execute addons scripts before ifupdown modules
---
...xecute-addons-scripts-before-modules.patch | 71 +++++++++++++++++++
debian/patches/series | 1 +
2 files changed, 72 insertions(+)
create mode 100644 debian/patches/pve/0008-execute-addons-scripts-before-modules.patch
diff --git a/debian/patches/pve/0008-execute-addons-scripts-before-modules.patch b/debian/patches/pve/0008-execute-addons-scripts-before-modules.patch
new file mode 100644
index 0000000..c165010
--- /dev/null
+++ b/debian/patches/pve/0008-execute-addons-scripts-before-modules.patch
@@ -0,0 +1,71 @@
+From f20723e25d5b12edc57b2a1fd0901bd3ee7c91a7 Mon Sep 17 00:00:00 2001
+From: Alexandre Derumier <aderumier at odiso.com>
+Date: Mon, 3 Feb 2020 05:56:49 +0100
+Subject: [PATCH] execute addons scripts before modules
+
+ip address are now setup in pre-up,
+but ovs interfaces are created in pre-up script too. (but after address module)
+
+We need to be sure than addons scripts are executed before modules
+
+Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
+---
+ ifupdown2/ifupdown/scheduler.py | 35 +++++++++++++++++----------------
+ 1 file changed, 18 insertions(+), 17 deletions(-)
+
+diff --git a/ifupdown2/ifupdown/scheduler.py b/ifupdown2/ifupdown/scheduler.py
+index 00130ad..8b78f05 100644
+--- a/ifupdown2/ifupdown/scheduler.py
++++ b/ifupdown2/ifupdown/scheduler.py
+@@ -84,6 +84,24 @@ class ifaceScheduler():
+ query_ifaceobj.set_state_n_status(ifaceState.from_str(op),
+ ifaceStatus.NOTFOUND)
+ return
++
++ if ifupdownobj.config.get('addon_scripts_support', '0') == '1':
++ # execute /etc/network/ scripts
++ os.environ['IFACE'] = ifaceobj.name if ifaceobj.name else ''
++ os.environ['LOGICAL'] = ifaceobj.name if ifaceobj.name else ''
++ os.environ['METHOD'] = ifaceobj.addr_method if ifaceobj.addr_method else ''
++ os.environ['ADDRFAM'] = ','.join(ifaceobj.addr_family) if ifaceobj.addr_family else ''
++ for mname in ifupdownobj.script_ops.get(op, []):
++ ifupdownobj.logger.debug('%s: %s : running script %s'
++ %(ifacename, op, mname))
++ try:
++ utils.exec_command(mname, env=cenv)
++ except Exception, e:
++ if "permission denied" in str(e).lower():
++ ifupdownobj.logger.warning('%s: %s %s' % (ifacename, op, str(e)))
++ else:
++ ifupdownobj.log_error('%s: %s %s' % (ifacename, op, str(e)))
++
+ for mname in ifupdownobj.module_ops.get(op):
+ m = ifupdownobj.modules.get(mname)
+ err = 0
+@@ -126,23 +144,6 @@ class ifaceScheduler():
+ ifaceobj.set_state_n_status(ifaceState.from_str(op),
+ status)
+
+- if ifupdownobj.config.get('addon_scripts_support', '0') == '1':
+- # execute /etc/network/ scripts
+- os.environ['IFACE'] = ifaceobj.name if ifaceobj.name else ''
+- os.environ['LOGICAL'] = ifaceobj.name if ifaceobj.name else ''
+- os.environ['METHOD'] = ifaceobj.addr_method if ifaceobj.addr_method else ''
+- os.environ['ADDRFAM'] = ','.join(ifaceobj.addr_family) if ifaceobj.addr_family else ''
+- for mname in ifupdownobj.script_ops.get(op, []):
+- ifupdownobj.logger.debug('%s: %s : running script %s'
+- %(ifacename, op, mname))
+- try:
+- utils.exec_command(mname, env=cenv)
+- except Exception, e:
+- if "permission denied" in str(e).lower():
+- ifupdownobj.logger.warning('%s: %s %s' % (ifacename, op, str(e)))
+- else:
+- ifupdownobj.log_error('%s: %s %s' % (ifacename, op, str(e)))
+-
+ @classmethod
+ def run_iface_list_ops(cls, ifupdownobj, ifaceobjs, ops):
+ """ Runs all operations on a list of interface
+--
+2.20.1
+
diff --git a/debian/patches/series b/debian/patches/series
index 3f39fc8..6f81e1f 100644
--- a/debian/patches/series
+++ b/debian/patches/series
@@ -6,3 +6,4 @@ pve/0004-don-t-remove-bridge-is-tap-veth-are-still-plugged.patch
pve/0005-ifreload-down-up-vxlan-interfaces-when-ifreload_down.patch
pve/0006-config-tuning.patch
pve/0007-networking.service-fix-dependencies-and-ordering.patch
+pve/0008-execute-addons-scripts-before-modules.patch
--
2.20.1
More information about the pve-devel
mailing list