From dbac1c093e2b4e11bc5c697149f2a10b89fd64e7 Mon Sep 17 00:00:00 2001 From: Julien Fortin Date: Wed, 16 Nov 2016 12:02:54 +0100 Subject: [PATCH] addons: usercmd: ifquery lists user commands and sets unknown status Ticket: CM-12724 Reviewed By: Roopa, Nikhil G, Daniel W Testing Done: $ ifquery br0 auto br0 iface br0 bridge-ports tap17 tap19 up ls -l $ ifquery br0 -c auto br0 iface br0 [pass] up ls -l [] bridge-ports tap17 tap19 [pass] Signed-off-by: Julien Fortin --- addons/usercmds.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/addons/usercmds.py b/addons/usercmds.py index 2358266..212d661 100644 --- a/addons/usercmds.py +++ b/addons/usercmds.py @@ -50,12 +50,24 @@ class usercmds(ifupdownaddons.modulebase.moduleBase): str(e).strip('\n'))) pass + def _query_check(self, ifaceobj, ifaceobjcurr): + if ifaceobj.config: + for ops in ['pre-up', + 'up', + 'post-up', + 'pre-down', + 'down', + 'post-down']: + for cmd in ifaceobj.config.get(ops, []): + ifaceobjcurr.update_config_with_status(ops, cmd, -1) + _run_ops = {'pre-up' : _run_command, 'pre-down' : _run_command, 'up' : _run_command, 'post-up' : _run_command, 'down' : _run_command, - 'post-down' : _run_command} + 'post-down' : _run_command, + 'query-checkcurr': _query_check} def get_ops(self): """ returns list of ops supported by this module """ @@ -80,4 +92,7 @@ class usercmds(ifupdownaddons.modulebase.moduleBase): op_handler = self._run_ops.get(operation) if not op_handler: return - op_handler(self, ifaceobj, operation) + if operation == 'query-checkcurr': + op_handler(self, ifaceobj, query_ifaceobj) + else: + op_handler(self, ifaceobj, operation)